コード例 #1
0
        private void LB_Scenes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbScenes.SelectedItem != null)
            {
                selectedScene = MainForm.Project.Scenes.Where(x => x.Name == lbScenes.SelectedItem.ToString()).FirstOrDefault();
                RefreshTTImages();

                float min = (panel1.Width - 26f) / (float)selectedScene.PixelSize.Width;
                Percent          = min;
                pbDrawSpace.Size = selectedScene.PixelSizeZoomed(Percent);
                Overlay.Refresh();
            }
        }
コード例 #2
0
        public FrmGraphicsEditor()
        {
            InitializeComponent();
            PolyEditMode = EnumPolyEditMode.MoveImage;



            Overlay = new GraphicalOverlay()
            {
                Owner = pbDrawSpace
            };

            Overlay.Paint += Overlay_Paint;
            InitTSEvents();
            InitPbDrawSpace();

            btnNewTTImage.Click += BtnTTImageNew_Click;
            btnDelTTImage.Click += (_, __) => { if (lbTTImages.SelectedItem != null)
                                                {
                                                    selectedScene.TTImages.RemoveAt(lbTTImages.SelectedIndex); RefreshTTImages(); Overlay.Refresh();
                                                }
            };
            btnMoveUpTTImage.Click += (_, __) => { if (lbTTImages.SelectedIndex > 0)
                                                   {
                                                       SwapImages(lbTTImages.SelectedIndex, lbTTImages.SelectedIndex - 1); RefreshTTImages(); Overlay.Refresh();
                                                   }
            };
            btnMoveDownTTImage.Click += (_, __) => { if (lbTTImages.SelectedIndex < lbTTImages.Items.Count - 1)
                                                     {
                                                         SwapImages(lbTTImages.SelectedIndex, lbTTImages.SelectedIndex + 1); RefreshTTImages(); Overlay.Refresh();
                                                     }
            };

            var SceneContext = new ContextMenu();

            SceneContext.MenuItems.Add("New", (_, __) =>
            {
                if (MainForm.Project == null)
                {
                    return;
                }
                using (var f = new frmScene(MainForm.Project.Scenes.ToArray()))
                {
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        MainForm.Project.Scenes.Add(f.Result);
                        RefreshScenes();
                        lbScenes.SelectedIndex = lbScenes.Items.Count - 1;
                    }
                }
            });
            SceneContext.MenuItems.Add("Edit", (_, __) =>
            {
                if (MainForm.Project == null || lbScenes.SelectedItem == null)
                {
                    return;
                }

                using (var f = new frmScene(MainForm.Project.Scenes.ToArray(), MainForm.Project.Scenes[lbScenes.SelectedIndex]))
                {
                    if (f.ShowDialog() == DialogResult.OK)
                    {
                        var s           = MainForm.Project.Scenes[lbScenes.SelectedIndex];
                        s.Name          = f.Result.Name;
                        s.ResolutionDPI = f.Result.ResolutionDPI;
                        s.CanvasSize    = f.Result.CanvasSize;

                        RefreshScenes();
                    }
                }
            });
            lbScenes.ContextMenu = SceneContext;

            lbOids.SelectedIndexChanged     += LbOids_SelectedIndexChanged;
            lbScenes.SelectedIndexChanged   += LB_Scenes_SelectedIndexChanged;
            tsPolygons.SelectedIndexChanged += (_, __) =>
            {
                if (selectedSceneOid != null)
                {
                    int i = tsPolygons.SelectedIndex;
                    if (i > -1 && selectedSceneOid.Polygons.Count > 0)
                    {
                        selectedpolygon = selectedSceneOid.Polygons[i];
                        Overlay.Refresh();
                    }
                }
            };

            btnOnSwitchOid.Click += (_, __) =>
            {
                if (selectedScene == null)
                {
                    return;
                }

                lbOids.SelectedIndex = -1;
                tsPolygons.Items.Clear();


                if (selectedScene.StartOid == null)
                {
                    selectedScene.StartOid = new SceneOid("os_start");
                    selectedSceneOid       = selectedScene.StartOid;
                }
                if (selectedScene.StartOid.Polygons == null || selectedScene.StartOid.Polygons.Count == 0)
                {
                    selectedSceneOid = selectedScene.StartOid;
                    tsAddPoly.PerformClick();
                }
                selectedSceneOid = selectedScene.StartOid;


                tsPolygons.Items.AddRange(selectedSceneOid.Polygons.ToArray());
                if (tsPolygons.Items.Count > 0)
                {
                    tsPolygons.SelectedIndex = 0;
                }
            };

            RefreshScenes();
            RefreshNodes();
            tsImgMove.PerformClick();
        }