Esempio n. 1
0
        private void InitUI()
        {
            Debug.WriteLine("Initializing UI objects.");

            #region Editor and Canvas

            Debug.WriteLine("Loading canvas...");
            this.editor = new DefaultEditor();
            this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.editor);

            ICanvas canvas2 = new DefaultCanvas();
            canvas2.Name = "Layer";
            this.editor.AddCanvas(canvas2);

            #endregion

            #region Commands

            //BlackCanvasBgCommand blackCanvasBgCmd = new BlackCanvasBgCommand(this.canvas);
            //WhiteCanvasBgCommand whiteCanvasBgCmd = new WhiteCanvasBgCommand(this.canvas);

            #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...");
            this.toolbox.AddTool(new SelectionTool());
            this.toolbox.AddSeparator();
            this.toolbox.AddTool(new LineTool());
            this.toolbox.AddTool(new RectangleTool());
            this.toolbox.AddTool(new TextTool());
            this.toolbox.ToolSelected += Toolbox_ToolSelected;
            this.toolbox.AddTool(new RedFillColor());
            this.toolbox.AddTool(new BlueFillColor());
            this.toolbox.AddTool(new GreenFillColor());
            this.toolbox.AddTool(new RedBorderColor());
            this.toolbox.AddTool(new BlueBorderColor());
            this.toolbox.AddTool(new GreenBorderColor());

            #endregion
        }
Esempio n. 2
0
        private void ExportToImages_Click(object sender, EventArgs e)
        {
            curCanvas = (DefaultCanvas)editor.GetSelectedCanvas();
            curCanvas.DeselectAllObjects();
            Bitmap bitmap = new Bitmap(curCanvas.Width, curCanvas.Height);

            curCanvas.DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter       = "PNG Image Files (*.png)|*.png";
            dialog.DefaultExt   = "png";
            dialog.AddExtension = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                bitmap.Save(dialog.FileName, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Esempio n. 3
0
        private void InitUI()
        {
            //parent dari canvas
            editor = new DefaultEditor();
            //genereate menu bar
            MenuStrip         MenuBar    = new MenuStrip();
            ToolStripMenuItem file       = new ToolStripMenuItem("File");
            ToolStripMenuItem edit       = new ToolStripMenuItem("Edit");
            ToolStripMenuItem arrange    = new ToolStripMenuItem("Arrange");
            ToolStripMenuItem sendToBack = new ToolStripMenuItem("Send to back");

            sendToBack.Click += SendToBack_Click;
            ToolStripMenuItem sendToFront = new ToolStripMenuItem("Send to front");

            sendToFront.Click += SendToFront_Click;
            ToolStripMenuItem newFile = new ToolStripMenuItem("New");

            newFile.Click += NewFile_Click;
            ToolStripMenuItem removeFile = new ToolStripMenuItem("Remove current canvas");

            removeFile.Click += RemoveFile_Click;
            ToolStripMenuItem newplugin = new ToolStripMenuItem("Add Plugin");

            newplugin.Click += Newplugin_Click;
            ToolStripMenuItem exportToImages = new ToolStripMenuItem("Export to Images");

            exportToImages.Click += ExportToImages_Click;
            ToolStripMenuItem groupObject = new ToolStripMenuItem("Group current and previous object");

            groupObject.Click += GroupObject_Click;
            ToolStripMenuItem unGroupObject = new ToolStripMenuItem("Ungroup Object");

            unGroupObject.Click += UnGroupObject_Click;
            ToolStripMenuItem deleteObject = new ToolStripMenuItem("Delete seleceted object");

            deleteObject.Click += DeleteObject_Click;

            ToolStripMenuItem exit = new ToolStripMenuItem("Exit");

            exit.Click += Exit_Click;
            ToolStripMenuItem undo         = new ToolStripMenuItem("Undo");
            ToolStripMenuItem redo         = new ToolStripMenuItem("Redo");
            ToolStripMenuItem resizecanvas = new ToolStripMenuItem("Resize Canvas");

            resizecanvas.Click += Resizecanvas_Click;

            ToolStripContainer toolContainer = new ToolStripContainer();

            toolContainer.ContentPanel.Controls.Add((System.Windows.Forms.Control)editor);
            curCanvas      = new DefaultCanvas(undoRedo);
            curCanvas.Name = "Main";
            editor.AddCanvas(curCanvas);

            // Generate Toolbar
            toolbar = new DefaultToolbar();
            ToolStripContainer toolStripContainer = new ToolStripContainer();

            toolStripContainer.Height = 32;
            toolStripContainer.TopToolStripPanel.Controls.Add((System.Windows.Forms.Control) this.toolbar);
            UndoToolbarItem undoItem = new UndoToolbarItem(undoRedo, curCanvas);
            RedoToolbarItem redoItem = new RedoToolbarItem(undoRedo, curCanvas);

            toolbar.AddToolbarItem(undoItem);
            toolbar.AddToolbarItem(redoItem);
            toolbar.AddSeparator();
            toolStripContainer.Dock = DockStyle.Top;

            //meyusun menu bar
            MenuBar.Items.Add(file);
            MenuBar.Items.Add(edit);
            MenuBar.Items.Add(arrange);

            edit.DropDown.Items.Add(undo);
            edit.DropDown.Items.Add(redo);
            edit.DropDown.Items.Add(resizecanvas);
            edit.DropDown.Items.Add(deleteObject);

            file.DropDown.Items.Add(newFile);
            file.DropDown.Items.Add(newplugin);
            file.DropDown.Items.Add(exportToImages);
            file.DropDown.Items.Add(removeFile);
            file.DropDown.Items.Add(exit);

            arrange.DropDown.Items.Add(sendToBack);
            arrange.DropDown.Items.Add(sendToFront);
            arrange.DropDown.Items.Add(groupObject);
            arrange.DropDown.Items.Add(unGroupObject);

            MenuBar.Dock = DockStyle.Top;

            //set size form
            this.Height = this.tinggi;
            this.Width  = this.lebar;

            //deklarasi accordion form
            Accordion acc = new Accordion();

            acc.CheckBoxMargin   = new Padding(2);
            acc.ContentMargin    = new Padding(5, 5, 5, 5);
            acc.ContentPadding   = new Padding(1);
            acc.Insets           = new Padding(5);
            acc.ControlBackColor = System.Drawing.Color.White;
            acc.Width            = 200;

            //deklarasi panel pertama
            //deklarasi size button
            int tinggi = 100;
            int lebar  = 100;

            tlp             = new DefaultToolbox();
            tlp.TabStop     = true;
            tlp.MaximumSize = new Size(new Point(300));

            Tools.SelectionTool pilih = new Tools.SelectionTool(undoRedo);
            pilih.Height                = tinggi;
            pilih.Width                 = lebar;
            pilih.Image                 = null;
            pilih.BackgroundImage       = Resources.Assets.cursor;
            pilih.BackgroundImageLayout = ImageLayout.Zoom;
            tlp.AddTool(pilih);

            Tools.TextTool txtTool = new Tools.TextTool();
            txtTool.Height                = tinggi;
            txtTool.Width                 = lebar;
            txtTool.Image                 = null;
            txtTool.BackgroundImage       = Resources.Assets.font;
            txtTool.BackgroundImageLayout = ImageLayout.Zoom;
            tlp.AddTool(txtTool);

            if (plugins != null)
            {
                for (int i = 0; i < this.plugins.Length; i++)
                {
                    this.tlp.Register(plugins[i]);
                }
            }
            acc.Add((System.Windows.Forms.Control)tlp, "Wireframes", "Enter the client's information.", 0, true);//memasukkan panel pertama

            acc.Add(new System.Windows.Forms.TextBox {
                Dock = DockStyle.Fill, Multiline = true, BackColor = Color.White
            }, "Memo", "Additional Client Info", 1, true, contentBackColor: Color.Transparent);                                                                                                            //menambahkan panel kedua

            acc.Dock = DockStyle.Fill;

            mainPanel.Dock = DockStyle.Fill;
            mainPanel.Panel1.Controls.Add(acc);
            mainPanel.FixedPanel       = FixedPanel.Panel1;
            mainPanel.MinimumSize      = new Size(300, 200);
            mainPanel.Panel2.BackColor = System.Drawing.Color.White;
            toolContainer.Dock         = DockStyle.Fill;
            mainPanel.Panel2.Controls.Add(toolContainer);
            mainPanel.SplitterWidth    = 15;
            mainPanel.SplitterDistance = 300;

            Controls.Add(mainPanel);
            Controls.Add(toolStripContainer);
            Controls.Add(MenuBar);
            this.tlp.ToolSelected += Toolbox_ToolSelected;

            newSVGToolPhone("phone-line.svg");
            newSVGToolWireframe("chatting.svg");
            newSVGToolWireframe("image-feed.svg");
            newSVGToolWireframe("insta-feed.svg");
            newSVGToolWireframe("list.svg");
            newSVGToolWireframe("login.svg");
            newSVGToolWireframe("modal-popup.svg");
            newSVGToolWireframe("product-detail.svg");
            newSVGToolWireframe("user-feed.svg");
            newSVGToolWireframe("video-detail.svg");
            newSVGToolWireframe("post-with-image.svg");
        }
Esempio n. 4
0
        private void InitUI()
        {
            Debug.WriteLine("Initializing UI objects.");

            #region Editor and Canvas

            Debug.WriteLine("Loading canvas...");
            this.editor = new DefaultEditor();
            this.toolStripContainer1.ContentPanel.Controls.Add((Control)this.editor);

            ICanvas canvas1 = new DefaultCanvas();
            canvas1.Name = "Untitled-1";
            this.editor.AddCanvas(canvas1);
            #endregion

            #region Commands

            //BlackCanvasBgCommand blackCanvasBgCmd = new BlackCanvasBgCommand(this.canvas);
            //WhiteCanvasBgCommand whiteCanvasBgCmd = new WhiteCanvasBgCommand(this.canvas);

            #endregion

            #region Menubar

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

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

            DefaultMenuItem newMenuItem = new DefaultMenuItem("New");
            fileMenuItem.AddMenuItem(newMenuItem);
            fileMenuItem.AddSeparator();
            DefaultMenuItem exitMenuItem = new DefaultMenuItem("Exit");
            fileMenuItem.AddMenuItem(exitMenuItem);

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

            DefaultMenuItem undoMenuItem = new DefaultMenuItem("Undo");
            editMenuItem.AddMenuItem(undoMenuItem);
            DefaultMenuItem redoMenuItem = new DefaultMenuItem("Redo");
            editMenuItem.AddMenuItem(redoMenuItem);

            //DefaultMenuItem viewMenuItem = new DefaultMenuItem("View");
            //this.menubar.AddMenuItem(viewMenuItem);

            //DefaultMenuItem helpMenuItem = new DefaultMenuItem("Help");
            //this.menubar.AddMenuItem(helpMenuItem);

            //DefaultMenuItem aboutMenuItem = new DefaultMenuItem("About");
            //helpMenuItem.AddMenuItem(aboutMenuItem);

            #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...");
            this.toolbox.AddTool(new SelectionTool());
            this.toolbox.AddSeparator();
            this.toolbox.AddTool(new LineTool());
            this.toolbox.AddTool(new RectangleTool());
            this.toolbox.AddTool(new CircleTool());
            this.toolbox.AddTool(new AddTextTool());

            if (plugins != null)
            {
                for (int i = 0; i < this.plugins.Length; i++)
                {
                    this.toolbox.Register(plugins[i]);
                }
            }

            this.toolbox.ToolSelected += Toolbox_ToolSelected;



            #endregion

            #region Toolbar

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

            ExampleToolbarItem toolItem1 = new ExampleToolbarItem();
            //toolItem1.SetCommand(whiteCanvasBgCmd);
            ExampleToolbarItem toolItem2 = new ExampleToolbarItem();
            //toolItem2.SetCommand(blackCanvasBgCmd);

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

            #endregion
        }