예제 #1
0
        private void MergeSchemeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openToolkitFileDialog.InitialDirectory = Path.Combine(Application.StartupPath, "Toolkit");
            if (openToolkitFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            PuzzleToolkit mergeToolkit = PuzzleToolkit.LoadFromFile(openToolkitFileDialog.FileName);
            Dictionary <string, PuzzleToolkitItem> dict = new Dictionary <string, PuzzleToolkitItem>();

            foreach (PuzzleToolkitItem item in toolkit.Items)
            {
                if (!dict.ContainsKey(item.Name))
                {
                    dict.Add(item.Name, item);
                }
            }
            int count = 0;

            foreach (PuzzleToolkitItem item in mergeToolkit.Items)
            {
                if (!dict.ContainsKey(item.Name))
                {
                    dict.Add(item.Name, item);
                    toolkit.Items.Add(item);
                    count += 1;
                }
            }
            MessageBox.Show(string.Format(Resources.Lang.Info_AddItems, count));
            InitToolkit(toolkit);
            UpdateToolkitListView();
        }
예제 #2
0
        private void ResetToDefaultToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PuzzleToolkit inputToolkit = PuzzleToolkit.CreateDefaultPuzzleToolkit();

            InitToolkit(inputToolkit);
            UpdateToolkitListView();
        }
예제 #3
0
        void InitToolkit(PuzzleToolkit inputToolkit = null)
        {
            if (inputToolkit == null)
            {
                try
                {
                    inputToolkit = PuzzleToolkit.LoadFromFile(Path.Combine(Application.StartupPath, "toolkit/current.toolkit"));
                }
                catch
                {
                    inputToolkit = PuzzleToolkit.CreateDefaultPuzzleToolkit();
                    if (MessageBox.Show(Resources.Lang.Warnings_CorruptedToolkit, Resources.Lang.Warning, MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        inputToolkit.SaveToFile(Path.Combine(Application.StartupPath, "toolkit/current.toolkit"));
                    }
                }
            }
            toolkit = inputToolkit;
            ImageList imageList = new ImageList
            {
                ColorDepth = ColorDepth.Depth32Bit,
                ImageSize  = new Size(toolkitIconSize, toolkitIconSize)
            };

            ToolkitListView.LargeImageList = imageList;
            toolkitListViewItems           = new List <ListViewItem>();
            foreach (PuzzleToolkitItem item in toolkit.Items)
            {
                imageList.Images.Add(item.GetImage(toolkitIconSize, toolkitIconSize));
                ListViewItem listViewItem = new ListViewItem(item.Name, imageList.Images.Count - 1);
                listViewItem.Tag  = item;
                listViewItem.Name = item.Name;
                toolkitListViewItems.Add(listViewItem);
            }
        }
예제 #4
0
        void UpdateDecoratorPreview(bool resetScale)
        {
            Decorator selectedDecorator = null;

            if (puzzlePropertyGrid.SelectedObject is GraphElement graphElement)
            {
                selectedDecorator = graphElement.Decorator;
            }
            if (puzzlePropertyGrid.SelectedObject is Decorator)
            {
                selectedDecorator = puzzlePropertyGrid.SelectedObject as Decorator;
            }
            if (editView != null)
            {
                decoratorPreviewBuffer.Graphics.Clear(editView.Graph.MetaData.BackgroundColor);
                if (selectedDecorator != null)
                {
                    if (resetScale)
                    {
                        decoratorPreviewScale = PuzzleToolkit.GetSuggestedDecorationScale(selectedDecorator);
                    }
                    PuzzleGraphRenderer renderer = new PuzzleGraphRenderer(decoratorPreviewBuffer.Graphics);
                    double width  = decoratorPreviewPictureBox.Width;
                    double height = decoratorPreviewPictureBox.Height;
                    renderer.DrawDecorator(selectedDecorator, new MathHelper.Vector(width / 2.0, height / 2.0),
                                           height * decoratorPreviewScale, editView.Graph.MetaData, editView.Graph.MetaData.BackgroundColor, true);
                }
                decoratorPreviewBuffer.Render();
            }
        }
예제 #5
0
 private void LoadSchemeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openToolkitFileDialog.InitialDirectory = Path.Combine(Application.StartupPath, "Toolkit");
     if (openToolkitFileDialog.ShowDialog() == DialogResult.Cancel)
     {
         return;
     }
     toolkit = PuzzleToolkit.LoadFromFile(openToolkitFileDialog.FileName);
     InitToolkit(toolkit);
     UpdateToolkitListView();
 }
예제 #6
0
 private void ToolkitAdd_Click(object sender, EventArgs e)
 {
     if (editView != null)
     {
         if (editView.SelectedObjects.Count == 0)
         {
             MessageBox.Show(Resources.Lang.Errors_NoElement);
             return;
         }
         Decorator decorator = editView.SelectedObjects[0].Decorator;
         if (string.IsNullOrWhiteSpace(toolkitTextBox.Text))
         {
             MessageBox.Show(Resources.Lang.Errors_NameEmpty);
             return;
         }
         string name = toolkitTextBox.Text;
         double size = PuzzleToolkit.GetSuggestedDecorationScale(decorator);
         toolkit.Items.Add(new PuzzleToolkitDecoratorItem(name, decorator, size));
         InitToolkit(toolkit);
         UpdateToolkitListView();
     }
 }
예제 #7
0
        public static PuzzleToolkit CreateDefaultPuzzleToolkit()
        {
            List <List <Node> > exampleShapes = new List <List <Node> >()
            {
                new List <Node>()
                {
                    new Node(1.0, 1.0), new Node(2.0, 1.0), new Node(2.0, 2.0), new Node(1.0, 2.0)
                }
            };
            List <int> exampleIndex = new List <int>()
            {
                0
            };
            PuzzleToolkit Toolkit = new PuzzleToolkit();

            Toolkit.Items.Add(new PuzzleToolkitMiscItem(Resources.Lang.Pointer, "Icons/Cursor.png"));
            Toolkit.Items.Add(new PuzzleToolkitMiscItem(Resources.Lang.Painter, "Icons/Paint.png"));
            // Toolkit.Items.Add(new PuzzleToolkitMiscItem(Resources.Lang.ColorPicker, Image.FromFile("Icons/ColorPicker.png")));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Empty, null));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Eliminator, new PuzzleGraph.Decorators.EliminatorDecorator()));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Triangle1, new PuzzleGraph.Decorators.TriangleDecorator()
            {
                Count = 1
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Triangle2, new PuzzleGraph.Decorators.TriangleDecorator()
            {
                Count = 2
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Triangle3, new PuzzleGraph.Decorators.TriangleDecorator()
            {
                Count = 3
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Triangle4, new PuzzleGraph.Decorators.TriangleDecorator()
            {
                Count = 4
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Arrow, new PuzzleGraph.Decorators.ArrowDecorator()
            {
                Count = 2
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Tetris, new PuzzleGraph.Decorators.TetrisDecorator()
            {
                Indexes = exampleIndex, Shapes = exampleShapes
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.HollowTetris, new PuzzleGraph.Decorators.HollowTetrisDecorator()
            {
                Indexes = exampleIndex, Shapes = exampleShapes
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.SkewTetris, new PuzzleGraph.Decorators.TetrisDecorator()
            {
                Indexes = exampleIndex, Shapes = exampleShapes, Angle = -15
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.SkewHollowTetris, new PuzzleGraph.Decorators.HollowTetrisDecorator()
            {
                Indexes = exampleIndex, Shapes = exampleShapes, Angle = -15
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Star, new PuzzleGraph.Decorators.StarDecorator()));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Square, new PuzzleGraph.Decorators.SquareDecorator()));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Circle, new PuzzleGraph.Decorators.CircleDecorator()));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Ring, new PuzzleGraph.Decorators.RingDecorator()));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Point, new PuzzleGraph.Decorators.PointDecorator(), 0.5));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.SelfIntersection, new PuzzleGraph.Decorators.SelfIntersectionDecorator(), 0.5));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Broken, new PuzzleGraph.Decorators.BrokenDecorator(), 0.25));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Start, new PuzzleGraph.Decorators.StartDecorator(), 0.25));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndR, new PuzzleGraph.Decorators.EndDecorator()
            {
                Angle = 0
            }, 0.25));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndL, new PuzzleGraph.Decorators.EndDecorator()
            {
                Angle = 180
            }, 0.25));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndU, new PuzzleGraph.Decorators.EndDecorator()
            {
                Angle = -90
            }, 0.25));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndD, new PuzzleGraph.Decorators.EndDecorator()
            {
                Angle = 90
            }, 0.25));
            // Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndRD, new PuzzleGraph.Decorators.EndDecorator() { Angle = 45 }, 0.25));
            // Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndLD, new PuzzleGraph.Decorators.EndDecorator() { Angle = 135 }, 0.25));
            // Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndLU, new PuzzleGraph.Decorators.EndDecorator() { Angle = -135 }, 0.25));
            // Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.EndRU, new PuzzleGraph.Decorators.EndDecorator() { Angle = -45 }, 0.25));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Text, new PuzzleGraph.Decorators.TextDecorator()
            {
                Font = SystemFonts.MessageBoxFont, Text = "A"
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Symbol, new PuzzleGraph.Decorators.TextDecorator()
            {
                Font = SystemFonts.MessageBoxFont, Text = "\u2460"
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Emoji, new PuzzleGraph.Decorators.TextDecorator()
            {
                Font = new Font("Segoe UI Emoji", 9), Text = "\U0001F600"
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.Box, new PuzzleGraph.Decorators.BoxDecorator()));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.VerticalSymmetry, new PuzzleGraph.Decorators.SymmetryPuzzleDecorator()
            {
                IsRotational = false, Angle = 0
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.HorizontalSymmetry, new PuzzleGraph.Decorators.SymmetryPuzzleDecorator()
            {
                IsRotational = false, Angle = 90
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.RotationalSymmetry, new PuzzleGraph.Decorators.SymmetryPuzzleDecorator()
            {
                IsRotational = true, Angle = 0
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.ParallelSymmetry, new PuzzleGraph.Decorators.ParallelPuzzleDecorator()
            {
                TranslationX = 0.35, TranslationY = 0.0
            }));
            Toolkit.Items.Add(new PuzzleToolkitDecoratorItem(Resources.Lang.ThreeWaySymmetry, new PuzzleGraph.Decorators.ThreeWayPuzzleDecorator()
            {
                Angle = 0
            }));
            return(Toolkit);
        }