private void Path_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { mDragging = false; Mouse.Capture(null); //var bitMapImage = Image_Show.Source as BitmapImage; var left = Grid_Iner.Margin.Left / Grid_Show.Width; var top = Grid_Iner.Margin.Top / Grid_Show.Height; var right = Grid_Iner.Margin.Right / Grid_Show.Width; var bottom = Grid_Iner.Margin.Bottom / Grid_Show.Height; //var x = System.Math.Round(Grid_Iner.Margin.Left / Grid_Show.Width * bitMapImage.PixelWidth); //var y = System.Math.Round(Grid_Iner.Margin.Top / Grid_Show.Height * bitMapImage.PixelHeight); //var width = System.Math.Round((Grid_Show.Width - Grid_Iner.Margin.Left - Grid_Iner.Margin.Right) / Grid_Show.Width * bitMapImage.PixelWidth); //var height = System.Math.Round((Grid_Show.Height - Grid_Iner.Margin.Top - Grid_Iner.Margin.Bottom) / Grid_Show.Height * bitMapImage.PixelHeight); //var tempValue = new CodeLinker.Scale9SpriteInfo(); //tempValue.CenterRect = new Int32Rect((int)x, (int)y, (int)width, (int)height); //tempValue.ImageFileString = Value.ImageFileString; //Value = tempValue; //TextBlock_Info.Text = Value.ToString(); Scale9Info = new EngineNS.Thickness(left, top, right, bottom); }
private void TextBlock_V_Bottom_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { TextBlock text = sender as TextBlock; var str = text.Text.Replace("%", ""); var value = System.Convert.ToInt32(str) * 0.01f; if (LockV) { Scale9Info = new EngineNS.Thickness(Scale9Info.Left, value, Scale9Info.Right, value); } else { Scale9Info = new EngineNS.Thickness(Scale9Info.Left, Scale9Info.Top, Scale9Info.Right, value); } }
public static void OnScale9InfoChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Scale9InfoSetter control = d as Scale9InfoSetter; EngineNS.Thickness newValue = (EngineNS.Thickness)e.NewValue; var left = newValue.Left * control.Grid_Show.Width; var top = newValue.Top * control.Grid_Show.Height; var right = newValue.Right * control.Grid_Show.Width; var bottom = newValue.Bottom * control.Grid_Show.Height; control.Path_Left.Margin = new Thickness(left - control.Path_Left.Width / 2, 0, 0, 0); control.Path_Right.Margin = new Thickness(0, 0, right - control.Path_Right.Width / 2, 0); control.Path_Top.Margin = new Thickness(0, top - control.Path_Top.Height / 2, 0, 0); control.Path_Bottom.Margin = new Thickness(0, 0, 0, bottom - control.Path_Bottom.Height / 2); control.Grid_Iner.Margin = new Thickness(left, top, right, bottom); control.Path_ShowLeft.Margin = new Thickness(left, 0, 0, 0); control.Path_ShowRight.Margin = new Thickness(0, 0, right, 0); control.Path_ShowTop.Margin = new Thickness(0, top, 0, 0); control.Path_ShowBottom.Margin = new Thickness(0, 0, 0, bottom); }