Beispiel #1
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            controlComboBox.Items.Clear();
            ControlManager.Instance().Clear();

            form      = new GuiControls.Form();
            form.Text = form.Name = "Form1";
            AddControlToList(form);
        }
Beispiel #2
0
        public MainForm()
        {
            InitializeComponent();

            Text += Assembly.GetExecutingAssembly().GetName().Version.ToString(2);

            stickToolBoxToggle = false;

            var allControlsGroup = new ToolboxGroup("All Controls");

            allControlsGroup.Items.Add(new ToolboxItem("Button", 0, ControlType.Button));
            allControlsGroup.Items.Add(new ToolboxItem("CheckBox", 1, ControlType.CheckBox));
            allControlsGroup.Items.Add(new ToolboxItem("ColorBar", 2, ControlType.ColorBar));
            allControlsGroup.Items.Add(new ToolboxItem("ColorPicker", 3, ControlType.ColorPicker));
            allControlsGroup.Items.Add(new ToolboxItem("ComboBox", 4, ControlType.ComboBox));
            allControlsGroup.Items.Add(new ToolboxItem("GroupBox", 5, ControlType.GroupBox));
            allControlsGroup.Items.Add(new ToolboxItem("HotkeyControl", 14, ControlType.HotkeyControl));
            allControlsGroup.Items.Add(new ToolboxItem("Label", 6, ControlType.Label));
            allControlsGroup.Items.Add(new ToolboxItem("LinkLabel", 7, ControlType.LinkLabel));
            allControlsGroup.Items.Add(new ToolboxItem("ListBox", 8, ControlType.ListBox));
            allControlsGroup.Items.Add(new ToolboxItem("Panel", 9, ControlType.Panel));
            allControlsGroup.Items.Add(new ToolboxItem("PictureBox", 10, ControlType.PictureBox));
            allControlsGroup.Items.Add(new ToolboxItem("ProgressBar", 11, ControlType.ProgressBar));
            allControlsGroup.Items.Add(new ToolboxItem("RadioButton", 12, ControlType.RadioButton));
            allControlsGroup.Items.Add(new ToolboxItem("TabControl", 13, ControlType.TabControl));
            allControlsGroup.Items.Add(new ToolboxItem("TextBox", 14, ControlType.TextBox));
            allControlsGroup.Items.Add(new ToolboxItem("Timer", 15, ControlType.Timer));
            allControlsGroup.Items.Add(new ToolboxItem("TrackBar", 16, ControlType.TrackBar));
            allControlsGroup.Expanded = true;
            controlToolbox.Groups.Add(allControlsGroup.Caption, allControlsGroup);

            controlToolbox.MouseLeave += new DelayedEventHandler(300, delegate
            {
                if (!stickToolBoxToggle)
                {
                    controlToolbox.Visible = false;
                }
            }).OnDelay;

            canvasPictureBox.AllowDrop = true;

            Renderer = Graphics.FromHwnd(Handle);
            Renderer.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit;

            form          = new GuiControls.Form(new Point(6, 6));
            form.Text     = form.Name = "Form1";
            form.DragEnd += control_DragEnd;
            AddControlToList(form);

            var category = controlPropertyGrid.SelectedGridItem;

            while (category.Parent != null)
            {
                category = category.Parent;
            }
            category.GridItems["Events"].Expanded = false;
        }
Beispiel #3
0
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.DefaultExt = "xml";
            ofd.Filter     = "OSHGui File (*.xml)|*.xml";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var control = ControlSerializer.Deserialize(XElement.Load(ofd.FileName));
                    if (control is GuiControls.Form)
                    {
                        form          = control as GuiControls.Form;
                        form.DragEnd += control_DragEnd;

                        ControlManager.Instance().Clear();
                        ControlManager.Instance().RegisterControl(control);

                        form.RegisterInternalControls();

                        controlComboBox.Items.Clear();
                        controlComboBox.Items.AddRange(ControlManager.Instance().Controls.ToArray());
                        controlComboBox.SelectedItem = control;

                        foreach (var scalableControl in ControlManager.Instance().Controls.OfType <ScalableControl>())
                        {
                            if (scalableControl != form)
                            {
                                scalableControl.MouseDown += control_MouseDown;
                                scalableControl.MouseMove += control_MouseMove;
                                scalableControl.MouseUp   += control_MouseUp;
                                scalableControl.DragEnd   += control_DragEnd;
                            }
                        }

                        canvasPictureBox.Invalidate();
                    }
                    else
                    {
                        MessageBox.Show("Invalid file!");
                    }
                }
                catch (Exception serializeError)
                {
                    MessageBox.Show("Error while parsing " + Path.GetFileName(ofd.FileName) + "\n\n" + serializeError.Message, "OSHGui Parse Error");
                }
            }
        }