private void BottomLeftDown(Grid grid, UIElement source) { var gridtop = (double)grid.GetValue(Canvas.TopProperty); var gridleft = (double)grid.GetValue(Canvas.LeftProperty); // 横 Line1.X1 = 32; Line1.Y1 = gridtop + grid.Width - 32; Line1.X2 = gridleft + 32; Line1.Y2 = gridtop + grid.Width - 32; // 縦 Line2.X1 = gridleft + 32; Line2.Y1 = Height - 48; Line2.X2 = gridleft + 32; Line2.Y2 = gridtop + grid.Width - 32; Line1.Visibility = System.Windows.Visibility.Visible; Line2.Visibility = System.Windows.Visibility.Visible; topLeft.Background = new SolidColorBrush(Colors.White); topRight.Background = new SolidColorBrush(Colors.White); bottomLeft.Background = new SolidColorBrush(Colors.Red); bottomRight.Background = new SolidColorBrush(Colors.White); }
public void Defaults() { Grid g = new Grid(); Assert.AreEqual(0, g.GetValue(Grid.ColumnProperty), "#1"); Assert.AreEqual(1, g.GetValue(Grid.ColumnSpanProperty), "#2"); Assert.AreEqual(0, g.GetValue(Grid.RowProperty), "#3"); Assert.AreEqual(1, g.GetValue(Grid.RowSpanProperty), "#4"); Assert.AreEqual(false, g.GetValue(Grid.ShowGridLinesProperty), "#5"); // Succeeds in Silverlight 3 Rectangle r1 = new Rectangle(); Rectangle r2 = new Rectangle(); g.Children.Add(r1); g.Children.Add(r2); Assert.AreEqual(0, Grid.GetColumn(r1), "#6"); Assert.AreEqual(0, Grid.GetColumn(r2), "#7"); Assert.AreEqual(0, Grid.GetRow(r1), "#8"); Assert.AreEqual(0, Grid.GetRow(r2), "#9"); }
public static AutoRowDefinitions GetAutoRowDefinitions(Grid element) { return (AutoRowDefinitions)element.GetValue(AutoRowDefinitionsProperty); }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { #region 接受页面传值 IDictionary<string, string> para = this.NavigationContext.QueryString; if (para.Count > 0) { gameClass = (para["gameClass"]).ToString().Trim(); imgUri = (para["imgUri"]).ToString().Trim(); } #endregion #region 处理墓碑错误 if (app.str_Uri != null) { NavigationService.Navigate(new Uri("/ChoosePictures.xaml?gameClass=" + gameClass, UriKind.Relative)); } app.str_Uri = null; #endregion #region 处理表格和图片相关初始值 switch (gameClass) { case "5And5": InitializeAboutGameClass(5,5,75,75,25);//5*5 break; case "4And4": InitializeAboutGameClass(4,4,90,90,16);//4*4 break; case "3And3": InitializeAboutGameClass(3,3,120,120,9);//3*3 break; default: break; } #endregion #region 创建方格和加载图片 ImageBrush berriesBrush = new ImageBrush(); berriesBrush.ImageSource = new BitmapImage( new Uri(@"bg_InGame.jpg", UriKind.Relative) ); Carrier.Background = berriesBrush; //Image Map = new Image(); //Map.Width = 480; //Map.Height = 800; //Map.Source = new BitmapImage((new Uri(@"bg_InGame.jpg", UriKind.Relative))); //Carrier.Children.Add(Map); //Map.SetValue(Canvas.ZIndexProperty, -1);//ZIndexProperty附加属性,这样它就相当于地图背景的作用 Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported); Table t = new Table(tableColumn, tableRow, smallSquareWidth, smallSquareHeight); g = t.CreateTable(); Carrier.Children.Add(g); littleImages = new MyImages(smallSquareWidth, smallSquareHeight); List<Image> listImages = littleImages.CreateImages(imgsCount,imgUri); try { foreach (var u in listImages) { Carrier.Children.Add(u); } } catch { } tableVectors = new vector2D[tableRow + 1, tableColumn + 1]; vector2D a = new vector2D(); for (int i = 0; i < tableRow + 1; i++) { for (int j = 0; j < tableColumn + 1; j++) { a.x = j * t.SmallSquareWidth + (480 - t.Column * t.SmallSquareWidth) / 2; a.y = i * t.SmallSquareHeight; tableVectors[i, j] = a; } } #region 原图 originalImage.Name = "originalImage"; #region 从存储过程中读取原图 IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication(); if (!isf.DirectoryExists(imgUri)) isf.CreateDirectory(imgUri); string[] imgsNames = isf.GetFileNames(imgUri + "/originalImage*.jpg"); try { using (IsolatedStorageFileStream isfStream = isf.OpenFile(imgUri + "/" + imgsNames[0], FileMode.Open, FileAccess.Read)) { BitmapImage bmpImg = new BitmapImage(); bmpImg.SetSource(isfStream); originalImage.Source = bmpImg; } } catch { } #endregion //originalImage.Source = new BitmapImage(new Uri("img/5And5/1/originalImage.jpg", UriKind.Relative)); originalImage.Width = g.Width; originalImage.Height = g.Height; Thickness gMargin = (Thickness)g.GetValue(MarginProperty); Canvas.SetLeft(originalImage, gMargin.Left); Canvas.SetTop(originalImage, gMargin.Top); Canvas.SetZIndex(originalImage, -1); try { Carrier.Children.Add(originalImage); } catch { } originalImage.Visibility = Visibility.Collapsed; #endregion #endregion #region 读取独立存储空间 //switch (MusicName) //{ // case "Set Fire To The Rain": ReadIsolatedStorageFile(highPointCount[0], 1);//读取独立存储空间的歌曲高潮点文件,highPointCount[]歌曲名,1文件名 // break; // case "What Doesn't Kill You": ReadIsolatedStorageFile(highPointCount[1], 2);//读取独立存储空间的歌曲高潮点文件 // break; // default: break; //} #endregion }
/// <summary>Возвращает заданное значение количества колонок. /// Оно может отличаться от реального значения, /// если коллекция колонок изменялась иным образом.</summary> /// <param name="grid">Grid в котором было задано количество колонок.</param> /// <returns>Заданное значение.</returns> public static int GetColumns(System.Windows.Controls.Grid grid) { return((int)grid.GetValue(ColumnsProperty)); }
private void BottomLeftUp(Grid grid, UIElement source) { Line1.Visibility = System.Windows.Visibility.Collapsed; Line2.Visibility = System.Windows.Visibility.Collapsed; buttonState.Children.RemoveRange(1, 4); buttonState = null; // 移動先の設定 var gridtop = (double)grid.GetValue(Canvas.TopProperty); var gridleft = (double)grid.GetValue(Canvas.LeftProperty); // bottom + left を起点に変更する var button = layoutDic[grid.Uid]; button.Top = double.MaxValue; button.Bottom = Height - gridtop - grid.Height + 32; button.Left = gridleft + 32; button.Right = double.MaxValue; }
private void TopRightUp(Grid grid, UIElement source) { Line1.Visibility = System.Windows.Visibility.Collapsed; Line2.Visibility = System.Windows.Visibility.Collapsed; buttonState.Children.RemoveRange(1, 4); buttonState = null; var gridtop = (double)grid.GetValue(Canvas.TopProperty); var gridleft = (double)grid.GetValue(Canvas.LeftProperty); // top + right を起点に変更する var button = layoutDic[grid.Uid]; button.Top = gridtop + 32; button.Bottom = double.MaxValue; button.Left = double.MaxValue; button.Right = Width - gridleft - grid.Width + 32; }
public static KeyGesture GetDecrementKeyGesture(Grid grid) { Guard.ArgumentNotNull(grid, "grid"); return (KeyGesture)grid.GetValue(DecrementKeyGestureProperty); }
/// <summary> /// Gets the value of <see cref="RowsProperty"/> for a given <see cref="Grid"/>. /// </summary> /// <param name="obj">The given <see cref="Grid"/>.</param> /// <returns>The value of <see cref="RowsProperty"/>.</returns> public static string GetRows(Grid obj) => (string)obj.GetValue(RowsProperty);
public static int GetTargetColumn(Grid grid) { Guard.ArgumentNotNull(grid, "grid"); return (int)grid.GetValue(TargetColumnProperty); }
/// <summary> /// Gets the value of <see cref="ColumnsProperty"/> for a given <see cref="Grid"/>. /// </summary> /// <param name="obj">The given <see cref="Grid"/>.</param> /// <returns>The value of <see cref="ColumnsProperty"/>.</returns> public static string GetColumns(Grid obj) => (string)obj.GetValue(ColumnsProperty);
public static ColumnDefinitions GetColumnDefinitions(System.Windows.Controls.Grid element) { return((ColumnDefinitions)element.GetValue(ColumnDefinitionsProperty)); }
public static string GetWith(Grid element) { return (string)element.GetValue(WithProperty); }
public static string GetRows(Grid element) { return (string)element.GetValue(RowsProperty); }
public static string GetColumns(Grid element) { return (string)element.GetValue(ColumnsProperty); }