public void SelectedFrame(int idx) { mSelectedFrame = null; if (mUVAnim == null) { return; } if (idx < 0 || idx >= mUVAnim.Frames.Count) { return; } Grid_SelectRect.Visibility = System.Windows.Visibility.Visible; mSelectedFrame = mUVAnim.Frames[idx]; //Canvas.SetLeft(Grid_SelectRect, Canvas.GetLeft(mUsedRectangleList[idx])); SelectRectLeft = Canvas.GetLeft(mUsedRectangleList[idx]); //Canvas.SetTop(Grid_SelectRect, Canvas.GetTop(mUsedRectangleList[idx])); SelectRectTop = Canvas.GetTop(mUsedRectangleList[idx]); //Grid_SelectRect.Width = mUsedRectangleList[idx].Width; //Grid_SelectRect.Height = mUsedRectangleList[idx].Height; SelectRectWidth = mUsedRectangleList[idx].Width; SelectRectHeight = mUsedRectangleList[idx].Height; }
public void AutoGridOperation() { if (mUVAnim == null) { return; } AutoGridSetWindow win = new AutoGridSetWindow(); if (win.ShowDialog() == true) { if (win.GridColumn == 0 || win.GridRow == 0) { return; } mUVAnim.Frames.Clear(); var columnWidth = (mWidth / win.GridColumn) * 1.0f / mWidth; var rowHeight = (mHeight / win.GridRow) * 1.0f / mHeight; for (UInt16 row = 0; row < win.GridRow; row++) { for (UInt16 column = 0; column < win.GridColumn; column++) { var frame = new EngineNS.UISystem.UVFrame(); frame.U = column * columnWidth; frame.V = row * rowHeight; frame.SizeU = columnWidth; frame.SizeV = rowHeight; mUVAnim.Frames.Add(frame); } } if (OnUpdateUVAnimFrames != null) { OnUpdateUVAnimFrames(mUVAnim); } var noUse = SetUVAnim(mUVAnim); } }
private async Task UpdateImageShow(EngineNS.UISystem.UVFrame frame) { if (frame == null) { return; } if (frame.ParentAnim == null) { return; } if (frame.ParentAnim.TextureObject == null) { return; } string strPath = frame.ParentAnim.TextureRName.Address; var texInfo = frame.ParentAnim.TextureObject.TxPicDesc; int left = (int)(frame.U * texInfo.Width); int top = (int)(frame.V * texInfo.Height); int width = (int)(frame.SizeU * texInfo.Width); int height = (int)(frame.SizeV * texInfo.Height); Image_Show.Source = await EditorCommon.ImageInit.GetImage(strPath, new System.Windows.Int32Rect(left, top, width, height)); var bitmap = Image_Show.Source as BitmapSource; if (bitmap != null) { // 宽度不小于300, 高度不小于200 if (bitmap.PixelHeight > bitmap.PixelWidth) { //var delta = bitmap.PixelWidth * 1.0 / bitmap.PixelHeight; //var tempWidth = Grid_Show.Height * delta; ////if(tempWidth < 300) ////{ //// Grid_Show.Height = 300.0 / delta; //// tempWidth = Grid_Show.Height * delta; ////} //Grid_Show.Width = tempWidth; Grid_Show.Height = 500; Grid_Show.Width = Grid_Show.Height * bitmap.PixelWidth / bitmap.PixelHeight; } else { //var delta = bitmap.PixelHeight * 1.0 / bitmap.PixelWidth; //var tempHeight = Grid_Show.Width * delta; ////if (tempHeight < 200) ////{ //// Grid_Show.Width = 200.0 / delta; //// tempHeight = Grid_Show.Width * delta; ////} //Grid_Show.Height = tempHeight; Grid_Show.Width = 500; Grid_Show.Height = Grid_Show.Width * bitmap.PixelHeight / bitmap.PixelWidth; } mStep = Grid_Show.Width / bitmap.PixelWidth; } }