<phone:PhoneApplicationPage x:Class="SE_Matrix_2d_v_1.MainPage" x:Name="SE_Matrix_2d_v_1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True"> <!--LayoutRoot , --> <Grid x:Name="LayoutRoot" Background="Transparent" Tap="Event_Grid_Tap_LayoutRoot"> </Grid> </phone:PhoneApplicationPage>
using System.Windows.Media; // using System.Threading.Tasks; // using System.Diagnostics; // . Debug.WriteLine( SomethingYouNeedToSee);
// public MainPage() { InitializeComponent(); CreateElement(); }
public partial class MainPage : PhoneApplicationPage { // double ScreenWidth = System.Windows.Application.Current.Host.Content.ActualWidth; double ScreenHeight = System.Windows.Application.Current.Host.Content.ActualHeight; ...
// countWidth = (int)Math.Round(ScreenWidth / 50); countHeight = (int)Math.Round(ScreenHeight / 50);
// countWidth = (int)Math.Round(this.ScreenWidth / 50); countHeight = (int)Math.Round(this.ScreenHeight / 50);
// for (i = 0; i < countWidth; i++) { for (j = 0; j < countHeight; j++) { // TextBlock TextBlock element = new TextBlock(); // TextBlock element.Name = "TB_" + i + "_" + j; // //element.Text = char.ConvertFromUtf32(random.Next(0x4E00, 0x4FFF)); // element.Text = ""; // // TextBlock int wx = i * 50; int wy = j * 50; element.Margin = new Thickness(wx, wy, 0, 0); // element.Foreground = new SolidColorBrush(Colors.Green); // element.FontSize = 36; // Grid LayoutRoot.Children.Add(element); } }
// , public void CreateElement() { int i, j, countWidth, countHeight; // countWidth = (int)Math.Round(this.ScreenWidth / 50); countHeight = (int)Math.Round(this.ScreenHeight / 50); // for (i = 0; i < countWidth; i++) { for (j = 0; j < countHeight; j++) { // TextBlock TextBlock element = new TextBlock(); // Border Border elementBorder = new Border(); // TextBlock elementBorder.Name = "B_" + i + "_" + j; // TextBlock element.Name = "TB_" + i + "_" + j; // //element.Text = char.ConvertFromUtf32(random.Next(0x4E00, 0x4FFF)); // element.Text = ""; // // TextBlock int wx = i * 50; int wy = j * 50; element.Margin = new Thickness(wx, wy, 0, 0); // element.Foreground = new SolidColorBrush(Colors.Green); // element.FontSize = 36; // Border elementBorder.Margin = new Thickness(wx, wy, 0, 0); // elementBorder.BorderThickness = new Thickness(1); // elementBorder.BorderBrush = new SolidColorBrush(Colors.Green); // TextBlock Border elementBorder.Child = element; // Grid LayoutRoot.Children.Add(elementBorder); } } }
<Border BorderThickness="1" BorderBrush="Black" Background="Green" CornerRadius="5"> <TextBlock Text="Description"/> </Border>
// Grid ( ) private void Event_Grid_Tap_LayoutRoot(object sender, System.Windows.Input.GestureEventArgs e) { Start(); }
// public async void Start() { int count, iteration; // iteration = 1; count = 0; // while (count < iteration) { // int ranX = random.Next(0, 10); // int ranY = random.Next(0, 20); // int length = random.Next(3, 7); // int time = random.Next(30, 70); await Task.Delay(1); // await RandomElementQ_Async(ranX, ranY, length, time); count++; } }
// , public async Task RandomElementQ_Async(int x, int y, int length, int timeOut) { // , . Dictionary<int, TextBlock> dicElem = new Dictionary<int, TextBlock>(); // , , if ((y + i) < countHeight && (y + i) >= 0). 4 . int count = 0; // length for (int i = 0; i < length; i++) { // , // int countHeight = (int)Math.Round(ScreenHeight / 50); // , , if ((y + i) < countHeight) { // , string elementName = "TB_" + x + "_" + (y + i); // object wantedNode = LayoutRoot.FindName(elementName); TextBlock element = (TextBlock)wantedNode; // , "" "" dicElem[count] = (element); // . ( ) - , - . // 1, , 255 . int rf = (int)Math.Round(255 / (double)(i + 1)) - 1; // , . . await Change(element, timeOut, 255); // , . , . for (int k = 0; k <= i; k++) { // "" (, y = -5) if (dicElem.ContainsKey(k)) { // , . "" TextBlock previousElement = dicElem[k]; // // (rf * (k + 1)) - 20 , // ( ) Task dsvv = Change(previousElement, timeOut, (rf * (k + 1)) - 20); } } count++; } } }
// public async Task Change(TextBlock txt, int timeOut, int Opacity) { // SolidColorBrush NewColor = new SolidColorBrush(new Color() { A = (byte)(255) /*Opacity*/, R = (byte)(0) /*Red*/, G = (byte)(Opacity) /*Green*/, B = (byte)(0) /*Blue*/ }); // "" 1 "" txt.Foreground = NewColor; // for (int i = 0; i < 5; i++) { // txt.Text = char.ConvertFromUtf32(random.Next(0x4E00, 0x4FFF)); // await Task.Delay(timeOut); } }
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using System.Threading.Tasks; using System.Diagnostics; namespace SE_Matrix_2d_v_1 { public partial class MainPage : PhoneApplicationPage { // Random random = new Random(); // double ScreenWidth = System.Windows.Application.Current.Host.Content.ActualWidth; double ScreenHeight = System.Windows.Application.Current.Host.Content.ActualHeight; // public MainPage() { InitializeComponent(); CreateElement(); } // , public void CreateElement() { int i, j, countWidth, countHeight; // countWidth = (int)Math.Round(this.ScreenWidth / 50); countHeight = (int)Math.Round(this.ScreenHeight / 50); // for (i = 0; i < countWidth; i++) { for (j = 0; j < countHeight; j++) { // TextBlock TextBlock element = new TextBlock(); // TextBlock element.Name = "TB_" + i + "_" + j; // //element.Text = char.ConvertFromUtf32(random.Next(0x4E00, 0x4FFF)); // element.Text = ""; // // TextBlock int wx = i * 50; int wy = j * 50; element.Margin = new Thickness(wx, wy, 0, 0); // element.Foreground = new SolidColorBrush(Colors.Green); // element.FontSize = 36; // Grid LayoutRoot.Children.Add(element); } } } // Grid ( ) private void Event_Grid_Tap_LayoutRoot(object sender, System.Windows.Input.GestureEventArgs e) { Start(); } // public async void Start() { int count, iteration; // iteration = 1; count = 0; // while (count < iteration) { // int ranX = random.Next(0, 10); // int ranY = random.Next(0, 20); // int length = random.Next(3, 7); // int time = random.Next(30, 70); await Task.Delay(1); // await RandomElementQ_Async(ranX, ranY, length, time); count++; } } // , public async Task RandomElementQ_Async(int x, int y, int length, int timeOut) { // , . Dictionary<int, TextBlock> dicElem = new Dictionary<int, TextBlock>(); // , , if ((y + i) < countHeight && (y + i) >= 0). 4 . int count = 0; // length for (int i = 0; i < length; i++) { // , // int countHeight = (int)Math.Round(ScreenHeight / 50); // , , if ((y + i) < countHeight) { // , string elementName = "TB_" + x + "_" + (y + i); // object wantedNode = LayoutRoot.FindName(elementName); TextBlock element = (TextBlock)wantedNode; // , "" "" dicElem[count] = (element); // . ( ) - , - . // 1, , 255 . int rf = (int)Math.Round(255 / (double)(i + 1)) - 1; // , . . await Change(element, timeOut, 255); // , . , . for (int k = 0; k <= i; k++) { // "" (, y = -5) if (dicElem.ContainsKey(k)) { // , . "" TextBlock previousElement = dicElem[k]; // // (rf * (k + 1)) - 20 , // ( ) Task dsvv = Change(previousElement, timeOut, (rf * (k + 1)) - 20); } } count++; } } } // public async Task Change(TextBlock element, int timeOut, int Opacity) { // SolidColorBrush NewColor = new SolidColorBrush(new Color() { A = (byte)(255) /*Opacity*/, R = (byte)(0) /*Red*/, G = (byte)(Opacity) /*Green*/, B = (byte)(0) /*Blue*/ }); // "" 1 "" element.Foreground = NewColor; // for (int i = 0; i < 5; i++) { // element.Text = char.ConvertFromUtf32(random.Next(0x4E00, 0x4FFF)); // await Task.Delay(timeOut); } } // ApplicationBar //private void BuildLocalizedApplicationBar() //{ // // ApplicationBar ApplicationBar. // ApplicationBar = new ApplicationBar(); // // AppResources. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative)); // appBarButton.Text = AppResources.AppBarButtonText; // ApplicationBar.Buttons.Add(appBarButton); // // AppResources. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText); // ApplicationBar.MenuItems.Add(appBarMenuItem); //} } }
Source: https://habr.com/ru/post/195422/
All Articles