Exemplo n.º 1
0
        public SchematicEditor(Circuit.Schematic Schematic)
            : base(Schematic)
        {
            InitializeComponent();

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, Save_Executed));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.SaveAs, SaveAs_Executed));

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Delete, Delete_Executed, Delete_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Cut, Cut_Executed, Cut_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Copy, Copy_Executed, Copy_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Paste, Paste_Executed, Paste_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.SelectAll, SelectAll_Executed, SelectAll_CanExecute));

            CommandBindings.Add(new CommandBinding(ApplicationCommands.Undo, Undo_Executed, Undo_CanExecute));
            CommandBindings.Add(new CommandBinding(ApplicationCommands.Redo, Redo_Executed, Redo_CanExecute));

            Focusable = true;
            Cursor = Cursors.Cross;

            edits = new EditStack();

            Tool = new SelectionTool(this);

            Width = 1600;
            Height = 1600;

            Origin = SnapToGrid(new Circuit.Coord((int)Width / 2, (int)Height / 2));
        }
Exemplo n.º 2
0
 public MainWindow()
     : base(Gtk.WindowType.Toplevel)
 {
     Build ();
     _undoManager = new UndoManager ();
     View = new StandardDrawingView (this);
     _scrolledwindow.Add ((Widget) View);
     Tool = new SelectionTool (this);
     UndoManager.StackChanged += delegate {
         UpdateUndoRedoSensitiveness ();
     };
     ShowAll ();
 }
Exemplo n.º 3
0
 private void Init()
 {
     // initialized some variables
     ShowGridOn = true;
     ShowWalkableOn = false;
     SelectedTile = null;
     Selection = new SelectionTool();
     Format = ImageFormat.Bmp;
     Language = ProgrammingLanguage.CPP;
 }
Exemplo n.º 4
0
        public OverlayTool[] ToolList; // is filled in the constructor


        public PdfOverlayModel(IPdfOverlayView View, IOverlayShapeFactory ShapeFactory)
        {
            this.View = View;
            this.ShapeFactory = ShapeFactory;
            _DisplayTree = new TikzDisplayTree( p => TikzToScreen(p, false) );

            // initialize tools
            selectionTool = new SelectionTool(this);

            // must be in the same order as the ToolType enum
            ToolList = new OverlayTool[] { selectionTool, new NodeTool(this), new EdgeTool(this), new PathTool(this), new SmoothCurveTool(this),
                                           new BezierTool(this), new RectangleTool(this), new EllipseTool(this), new GridTool(this), new ArcTool(this), new ArcEditTool(this) };
        }       
Exemplo n.º 5
0
        public OverlayTool[] ToolList; // is filled in the constructor


        public PdfOverlayModel(IPdfOverlayView View, IOverlayShapeFactory ShapeFactory)
        {
            this.View = View;
            this.ShapeFactory = ShapeFactory;

            // initialize tools
            selectionTool = new SelectionTool(this);

            // must be in the order of ToolType
            ////ToolList = new OverlayTool[] { selectionTool, nodeTool, edgeTool, pathTool, smoothCurveTool, bezierTool, rectangleTool, ellipseTool, gridTool, arcTool, arcEditTool };
            ToolList = new OverlayTool[] { selectionTool, new NodeTool(this), new EdgeTool(this), new PathTool(this), new SmoothCurveTool(this),
                                           new BezierTool(this), new RectangleTool(this), new EllipseTool(this), new GridTool(this), new ArcTool(this), new ArcEditTool(this) };
            ////foreach (OverlayTool t in ToolList)
            ////    t.overlay = this;
        }       
    private void HandleRightclick(EventType typeForControl, int controlId)
    {
        TacticsTerrainMesh terrain = (TacticsTerrainMesh)target;

        switch (typeForControl)
        {
        case EventType.MouseDown:
            if (tool != SelectionTool.Select)
            {
                TerrainQuad quad = GetSelectedQuad();
                if (quad != null)
                {
                    ConsumeEvent(controlId);
                    primarySelection = quad;
                    selectionSize    = new Vector2(1.0f, 1.0f);
                    CaptureSelection(quad);
                    tool = SelectionTool.Paint;
                    mode = EditMode.RlickDrag;
                }
            }
            break;

        case EventType.MouseDrag:
            if (mode == EditMode.RlickDrag)
            {
                ConsumeEvent(controlId);
                TerrainQuad quad = GetSelectedQuad();
                if (quad != null && quad.normal == primarySelection.normal)
                {
                    selectedQuads = MathHelper3D.GetQuadsInRect(quads, quad, primarySelection);
                }
            }
            break;

        case EventType.MouseUp:
            switch (mode)
            {
            case EditMode.Selected:
                mode = EditMode.None;
                break;

            case EditMode.RlickDrag:
                mode = EditMode.None;
                TerrainQuad quad = GetSelectedQuad();
                if (quad != null && quad.normal == primarySelection.normal)
                {
                    selectedQuads = MathHelper3D.GetQuadsInRect(quads, quad, primarySelection);
                    Vector3 v1 = quad.pos;
                    Vector3 v2 = primarySelection.pos;
                    float   x1 = Mathf.Min(v1.x, v2.x);
                    float   x2 = Mathf.Max(v1.x, v2.x);
                    float   y1 = Mathf.Min(v1.y, v2.y);
                    float   y2 = Mathf.Max(v1.y, v2.y);
                    float   z1 = Mathf.Min(v1.z, v2.z);
                    float   z2 = Mathf.Max(v1.z, v2.z);
                    if (z1 != z2 && y1 != y2)
                    {
                        paletteBufferSize = new Vector2Int((int)(z2 - z1 + 1), (int)((y2 - y1 + 0.5f) * 2.0f));
                        paletteBuffer     = new Tile[paletteBufferSize.x * paletteBufferSize.y];
                        for (float z = z1; z <= z2; z += 1.0f)
                        {
                            for (float y = y1; y <= y2; y += 0.5f)
                            {
                                TerrainQuad at = quads[new Vector3(v1.x, y, z)][quad.normal];
                                paletteBuffer[(int)(paletteBufferSize.x * (2.0f * (y - y1)) + (z - z1))] = at.tile;
                            }
                        }
                    }
                    else if (x1 != x2 && y1 != y2)
                    {
                        paletteBufferSize = new Vector2Int((int)(x2 - x1 + 1), (int)((y2 - y1 + 0.5f) * 2.0f));
                        paletteBuffer     = new Tile[paletteBufferSize.x * paletteBufferSize.y];
                        for (float x = x1; x <= x2; x += 1.0f)
                        {
                            for (float y = y1; y <= y2; y += 0.5f)
                            {
                                TerrainQuad at = quads[new Vector3(x, y, v1.z)][quad.normal];
                                paletteBuffer[(int)(paletteBufferSize.x * (2.0f * (y - y1)) + (x - x1))] = at.tile;
                            }
                        }
                    }
                    else
                    {
                        paletteBufferSize = new Vector2Int((int)(x2 - x1 + 1), (int)(z2 - z1 + 1));
                        paletteBuffer     = new Tile[paletteBufferSize.x * paletteBufferSize.y];
                        for (float x = x1; x <= x2; x += 1.0f)
                        {
                            for (float z = z1; z <= z2; z += 1.0f)
                            {
                                TerrainQuad at = quads[new Vector3(x, v1.y, z)][quad.normal];
                                paletteBuffer[(int)(paletteBufferSize.x * (z - z1) + (x - x1))] = at.tile;
                            }
                        }
                    }
                    selectionSize = paletteBufferSize;
                }
                break;
            }
            break;
        }
    }
Exemplo n.º 7
0
        private void InitUI()
        {
            Debug.WriteLine("Initializing UI objects.");

            IPanel canvas1 = new DefaultPanel();

            #region Toolbar

            // Initializing toolbar
            Debug.WriteLine("Loading toolbar...");
            this.toolbar = new DefaultToolbar();
            this.toolStripContainer1.TopToolStripPanel.Controls.Add((Control)this.toolbar);

            UnDoRedo undoredo = new UnDoRedo();

            ToolbarItem toolItem1 = new ToolbarItem("undo", IconSet.undo, canvas1);
            toolItem1.UnDoObject = undoredo;
            //toolItem1.SetCommand(whiteCanvasBgCmd);
            ToolbarItem toolItem2 = new ToolbarItem("redo", IconSet.redo, canvas1);
            toolItem2.UnDoObject = undoredo;
            //toolItem2.SetCommand(blackCanvasBgCmd);

            this.toolbar.AddToolbarItem(toolItem1);
            this.toolbar.AddSeparator();
            this.toolbar.AddToolbarItem(toolItem2);

            #endregion

            #region Editor and Panel
            Debug.WriteLine("Loading panel...");
            this.editor = new DefaultEditor();
            this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.editor);


            canvas1.Name       = "Untitled-1";
            canvas1.UnDoObject = undoredo;
            this.editor.AddCanvas(canvas1);

            /*IPanel canvas2 = new DefaultPanel();
             * canvas2.Name = "Untitled-2";
             * this.editor.AddCanvas(canvas2);*/
            #endregion

            #region Menubar
            Debug.WriteLine("Loading menubar...");
            this.menubar = new DefaultMenubar();
            this.Controls.Add((Control)this.menubar);

            DefaultMenuItem exampleMenuItem1 = new DefaultMenuItem("File");
            this.menubar.AddMenuItem(exampleMenuItem1);

            DefaultMenuItem exampleMenuItem11 = new DefaultMenuItem("New Mindmap");
            exampleMenuItem1.AddMenuItem(exampleMenuItem11);
            DefaultMenuItem exampleMenuItem12 = new DefaultMenuItem("Open Mindmap");
            exampleMenuItem1.AddMenuItem(exampleMenuItem12);
            DefaultMenuItem exampleMenuItem13 = new DefaultMenuItem("Close");
            exampleMenuItem1.AddMenuItem(exampleMenuItem13);

            DefaultMenuItem exampleMenuItem2 = new DefaultMenuItem("Edit");
            this.menubar.AddMenuItem(exampleMenuItem2);

            DefaultMenuItem exampleMenuItem21 = new DefaultMenuItem("Add Proccess");
            exampleMenuItem2.AddMenuItem(exampleMenuItem21);

            DefaultMenuItem exampleMenuItem3 = new DefaultMenuItem("Export");
            this.menubar.AddMenuItem(exampleMenuItem3);
            DefaultMenuItem exampleMenuItem31 = new DefaultMenuItem("Image");
            exampleMenuItem3.AddMenuItem(exampleMenuItem31);
            DefaultMenuItem exampleMenuItem311 = new DefaultMenuItem("JPEG");
            exampleMenuItem31.AddMenuItem(exampleMenuItem311);
            DefaultMenuItem exampleMenuItem312 = new DefaultMenuItem("PNG");
            exampleMenuItem31.AddMenuItem(exampleMenuItem312);
            DefaultMenuItem exampleMenuItem32 = new DefaultMenuItem("PDF");
            exampleMenuItem3.AddMenuItem(exampleMenuItem32);
            #endregion

            #region Toolbox

            // Initializing toolbox
            Debug.WriteLine("Loading toolbox...");
            this.toolbox = new DefaultToolbox();
            this.toolStripContainer1.LeftToolStripPanel.Controls.Add((Control)this.toolbox);
            //this.editor.Toolbox = toolbox;

            #endregion

            #region Tools

            // Initializing tools
            Debug.WriteLine("Loading tools...");
            ITool selectionTool = new SelectionTool();
            selectionTool.UnDoObject = undoredo;
            this.toolbox.AddTool(selectionTool);
            this.toolbox.AddSeparator();
            this.toolbox.AddTool(new LineTool());
            this.toolbox.AddTool(new RectangleTool());
            this.toolbox.AddTool(new TextTool());
            this.toolbox.ToolSelected += Toolbox_ToolSelected;
            #endregion
        }
Exemplo n.º 8
0
        private void SetTool()
        {
            //
            // Toolbar
            //
            ToolBar = new Toolbar();
            ToolBar.SetActiveCanvas(DrawingCanvas);
            ToolBar.AddSeparator();
            ToolBar.ItemClicked += new ToolStripItemClickedEventHandler(Toolbar_ItemClicked);

            OutlineColorChooser OColorChooser = new OutlineColorChooser();

            ToolBar.AddTool(OColorChooser);
            ToolBar.AddSeparator();

            FillColorChooser IColorChooser = new FillColorChooser();

            ToolBar.AddTool(IColorChooser);
            ToolBar.AddSeparator();

            this.Controls.Add(ToolBar);
            //
            // Toolbox
            //
            ToolBox = new Toolbox();
            ToolBox.SetActiveCanvas(DrawingCanvas);

            LineTool LineToolStrip = new LineTool();

            LineToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            LineToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(LineToolStrip);

            EllipseTool EllipseToolStrip = new EllipseTool();

            EllipseToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            EllipseToolStrip.SubscribeFill(IColorChooser);
            EllipseToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(EllipseToolStrip);

            RectangleTool RectangleToolStrip = new RectangleTool();

            RectangleToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            RectangleToolStrip.SubscribeFill(IColorChooser);
            RectangleToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(RectangleToolStrip);
            ToolBox.AddSeparator();

            SelectionTool SelectionToolStrip = new SelectionTool();

            SelectionToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            ToolBox.AddTool(SelectionToolStrip);
            ToolBox.AddSeparator();

            LineFillTool LineFillToolStrip = new LineFillTool();

            LineFillToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            LineFillToolStrip.SubscribeLine(OColorChooser);
            ToolBox.AddTool(LineFillToolStrip);

            FillTool FillToolStrip = new FillTool();

            FillToolStrip.Click += new EventHandler(Toolbox_ItemClicked);
            FillToolStrip.SubscribeFill(IColorChooser);
            ToolBox.AddTool(FillToolStrip);

            this.Controls.Add(ToolBox);
        }
Exemplo n.º 9
0
        private void setTool(string name)
        {
            if (Tool != null)
            {
                Tool.Exit();
            }
            if (tools.ContainsKey(name))
            {
                Tool = tools[name];
            }
            else
            {
                switch (name)
                {
                case "move":
                    Tool = new MoveTool(Project);
                    break;

                case "pencil":
                    Tool = new Pencil(Project, MyForeColor);
                    break;

                case "eraser":
                    Tool = new Eraser(Project);
                    break;

                case "picker":
                    Tool = new ColorPicker(Project, MyForeColor, MyBackColor);
                    (Tool as ColorPicker).ColorChanged += colorPicker_ColorChanged;
                    break;

                case "selection":
                    Tool = new SelectionTool(Project);
                    break;

                case "transform":
                    Tool = new Transform(Project);
                    break;

                case "shape":
                    Tool = new Shape(Project, MyForeColor, MyBackColor);
                    break;

                case "stamp":
                    Tool = new CloneStamp(Project);
                    break;

                case "brush":
                    Tool = new FuzzyBrush(Project);
                    break;

                default:
                    throw new ArgumentException();
                }
                Tool.Invalidated   += Tool_Invalidated;
                Tool.CursorChanged += Tool_CursorChanged;
                tools[name]         = Tool;
            }
            Tool.Init();
            updateToolColor();
            Tool_CursorChanged(this, null);
            setToolPanel();
        }
Exemplo n.º 10
0
        public static void Update(/*GameTime gameTime*/)
        {
            if (ModUtils.NetworkMode != NetworkMode.Server)
            {
                ModUtils.PreviousKeyboardState = Main.keyState;
                ModUtils.PreviousMouseState    = ModUtils.MouseState;
                ModUtils.MouseState            = Mouse.GetState();

                ModUtils.SetDeltaTime(/*gameTime*/);
                ModUtils.Update();
                //HEROsModVideo.Services.MobHUD.MobInfo.Update();
                //CheckIfGameEnteredOrLeft();
                //Update all services in the ServiceController
                foreach (var service in ServiceController.Services)
                {
                    service.Update();
                }
                MasterView.UpdateMaster();
                SelectionTool.Update();
                //if (Main.ingameOptionsWindow && (IngameOptions.category == 2 || IngameOptions.category == 3))
                //{
                //	HEROsModMod.UIKit.MasterView.gameScreen.AddChild(new HEROsModMod.UIKit.UIComponents.KeybindWindow());
                //	IngameOptions.Close();
                //}

                // This is the alternate tooltip code.
                //if (!Main.gameMenu)
                //{
                //	ModUtils.ItemTooltip.Update();
                //}

                // Unused 3D code

                //float speed = .03f;
                //if (Main.keyState.IsKeyDown(Keys.Left))
                //{
                //	angle -= speed;
                //}
                //if (Main.keyState.IsKeyDown(Keys.Right))
                //{
                //	angle += speed;
                //}
                //if (Main.keyState.IsKeyDown(Keys.Up))
                //{
                //	angle2 -= speed;
                //}
                //if (Main.keyState.IsKeyDown(Keys.Down))
                //{
                //	angle2 += speed;
                //}
                //if (Main.keyState.IsKeyDown(Keys.X))
                //{
                //	zoom += speed;
                //}
                //if (Main.keyState.IsKeyDown(Keys.Z))
                //{
                //	zoom -= speed;

                //}

                //Matrix worldMatrix = Matrix.Identity
                //	* Matrix.CreateTranslation(new Vector3(-Main.screenWidth / 2, -Main.screenHeight / 2, 0f))
                //	* Matrix.CreateRotationX(angle2)
                //	* Matrix.CreateRotationY(angle)
                //	* Matrix.CreateTranslation(new Vector3(Main.screenWidth / 2 / zoom, Main.screenHeight / 2 / zoom, 0f))
                //	* Matrix.CreateScale(zoom);

                //   ModUtils.TextureExtruder.WorldView = worldMatrix;
            }
            HEROsModNetwork.Network.Update();
            //	HEROsModNetwork.CTF.CaptureTheFlag.Update();
        }