Esempio n. 1
0
        void Tool_FileRawImage(object sender, FileRawImageEventArgs e)
        {
            IntPtr       ip           = e.Image.GetHbitmap();
            BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                ip,
                IntPtr.Zero,
                Int32Rect.Empty,
                BitmapSizeOptions.FromEmptyOptions());

            bitmapFrame             = BitmapFrame.Create(bitmapSource);
            ImageViewer.ImageSource = bitmapFrame;
            var atlasElements = new List <HandyControl.Data.KleiTextureAtlasElement>();

            if (e.AtlasElements.Count != 0)
            {
                SaveAllButton.IsEnabled   = true;
                ShowGridButton.Visibility = Visibility.Collapsed;
                GridSizeGrid.Visibility   = Visibility.Collapsed;
                ViewModel.IsShowGrid      = false;
                foreach (var atlas in e.AtlasElements)
                {
                    var atlasElement = new HandyControl.Data.KleiTextureAtlasElement(atlas.Name, atlas.ImgHMin, atlas.ImgHMax, atlas.ImgVMin, atlas.ImgVMax);
                    atlasElements.Add(atlasElement);
                }
            }
            else
            {
                ShowGridButton.Visibility  = Visibility.Visible;
                GridSizeGrid.Visibility    = Visibility.Visible;
                ViewModel.IsShowGrid       = true;
                ShowGridText.Text          = "隐藏网格";
                GridSizeWidthTextBox.Text  = "64";
                GridSizeHeightTextBox.Text = "64";
                ImageViewer.ShowGrid       = ViewModel.IsShowGrid;
                SaveAllButton.IsEnabled    = false;
            }
            ImageViewer.AtlasElements     = atlasElements;
            ImageViewer.FileName          = e.FileName;
            ImageViewer.FileDirectory     = e.FileDirectory;
            AntiElectionButton.Visibility = Visibility.Visible;
            SaveButton.Visibility         = Visibility.Visible;
            SaveAllButton.Visibility      = Visibility.Visible;
            DeleteObject(ip);
            //zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom);
        }
Esempio n. 2
0
        void tool_FileRawImage(object sender, FileRawImageEventArgs e)
        {
            atlasElementsCountIntToolStripLabel.Text = e.AtlasElements.Count.ToString();
            atlasElementsListToolStripComboBox.ComboBox.SelectedIndex = -1;
            atlasElementsListToolStripComboBox.ComboBox.Items.Clear();

            graphicsPath = null;
            atlasElementsListToolStripComboBox.Enabled = atlasElementBorderColors.Enabled = false;
            atlasElementWidthToolStrip.Text = atlasElementHeightToolStrip.Text = atlasElementXToolStrip.Text = atlasElementYToolStrip.Text = "0";

            if (e.AtlasElements.Count > 0)
            {
                graphicsPath = new GraphicsPath();
                atlasElementsListToolStripComboBox.Enabled = atlasElementBorderColors.Enabled = true;
                foreach (KleiTextureAtlasElement el in e.AtlasElements)
                {
                    atlasElementsListToolStripComboBox.Items.Add(el);
                }
            }

            imageBox.Image = e.Image;
            zoomLevelToolStripComboBox.Text = string.Format("{0}%", imageBox.Zoom);
        }