public static void OnBindInstanceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { Scale9InfoSetter control = d as Scale9InfoSetter; var noUse = control.UpdateImageShow(e.NewValue as EngineNS.UISystem.UVFrame); //UISystem.UVFrame frame = e.NewValue as UISystem.UVFrame; //if (frame == null) // return; //if(frame.ParentAnim == null) // return; //if(frame.ParentAnim.TextureObject == null) // return; //string strPath = CSUtility.Support.IFileManager.Instance.Root + frame.ParentAnim.Texture; //int left = (int)(frame.U * frame.ParentAnim.TextureObject.Width); //int top = (int)(frame.V * frame.ParentAnim.TextureObject.Height); //int width = (int)(frame.SizeU * frame.ParentAnim.TextureObject.Width); //int height = (int)(frame.SizeV * frame.ParentAnim.TextureObject.Height); //control.Image_Show.Source = EditorCommon.ImageInit.GetImage(strPath, new System.Windows.Int32Rect(left, top, width, height)); //var bitmap = control.Image_Show.Source as BitmapSource; //if (bitmap != null) //{ // if (bitmap.PixelHeight > bitmap.PixelWidth) // control.Grid_Show.Width = control.Grid_Show.Height * bitmap.PixelWidth / bitmap.PixelHeight; // else // control.Grid_Show.Height = control.Grid_Show.Width * bitmap.PixelHeight / bitmap.PixelWidth; //} }
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); }