Beispiel #1
0
        /// <summary>
        /// Renders property row at X, Y position
        /// </summary>
        /// <param name="graphics">graphics api to do rendering</param>
        /// <param name="X">X coordinate</param>
        /// <param name="Y">Y coordiante</param>
        protected override void Render(Graphics graphics, int x, int y)
        {
            if (null == this.parentGrid)
            {
                this.parentGrid = (PropertyGrid)this.Parent.Parent;
            }

            if (true == this.parentGrid.ShowRowsSeparator)
            {
                graphics.SetColor(this.parentGrid.RowSeparatorColor);
                graphics.DrawRectangle(x + this.Bounds.X, y + this.Bounds.Y + this.Bounds.Height, this.Bounds.Width, this.parentGrid.RowSeparatorHeight);
            }

            if (true == this.parentGrid.ShowKeyValueSeparator)
            {
                graphics.SetColor(this.parentGrid.KeyValueSeparatorColor);
                graphics.DrawRectangle(x + this.Bounds.X + this.Bounds.Width / 2, y + this.Bounds.Y, this.parentGrid.KeyValueSeparatorWidth, this.Bounds.Height);
            }

            RenderName(graphics, x, y);

            if (null == this.property)
            {
                return;
            }

            //RenderValue(render, X, Y);

            if (null != this.inputControl)
            {
                this.inputControl.Bounds.UpdateSize(this.Bounds.Width / 2 + 1, 1, this.Bounds.Width / 2-1, this.Bounds.Height-1);
            }
            else
            {
                CreateInputControl();
            }

            //if (false == this.inputControl.HasFocus())
            {
                if (this.property.ToString() != this.inputControl.Text)
                {
                    this.inputControl.Text = this.property.ToString();
                }
            }

            if (true == this.parentGrid.ShowSideBar)
            {
                this.IconImageOffset.X = 16;
                this.TextOffset.X = 16;
            }
            else
            {
                this.IconImageOffset.X = 0;
                this.TextOffset.X = 0;
            }

            RenderControls(graphics, x, y);
        }
Beispiel #2
0
        internal override void UpdateSize()
        {
            if (null == this.parentGrid)
            {
                this.parentGrid = (PropertyGrid)this.Parent;
            }

            int step = 8 + this.parentGrid.FontInfo.Size;

            int h = step;

            if ((this.parentGrid.RowHeight > 0) && (this.parentGrid.RowHeight > this.parentGrid.FontInfo.Size))
            {
                step = 8 + this.parentGrid.RowHeight;
            }

            if (true == this.expanded)
            {
                foreach (Control controls in this.Controls)
                {
                    controls.SetSize(0, h, this.Bounds.Width, step);
                    h += step;
                }
            }
            else
            {
                foreach (Control controls in this.Controls)
                {
                    controls.SetSize(-10000, -10000, 0, 0);
                }
            }

            this.Bounds.Height = h;
        }
Beispiel #3
0
        protected override void Render(Graphics graphics, int x, int y)
        {
            if (null == this.parentGrid)
            {
                this.parentGrid = (PropertyGrid)this.Parent;
            }

            int hh = 8 + this.parentGrid.FontInfo.Size;

            if (true == this.parentGrid.ShowSideBar)
            {
                // Render TopLine
                graphics.SetColor(this.Window.Desktop.Theme.Colors.Control);
                graphics.DrawRectangle(x + this.Bounds.X, y + this.Bounds.Y, this.Bounds.Width, hh);
            }

            if (true == this.parentGrid.ShowGroupLine)
            {
                graphics.SetColor(this.parentGrid.BorderColor);
                graphics.DrawRectangle(x + this.bounds.X, y + this.bounds.Y + hh - 1, this.bounds.Width, 1);
            }

            if (true == this.parentGrid.ShowPlus)
            {
                // Render Plus
                graphics.SetColor(this.PlusColor);
                graphics.DrawRectangle(this.Bounds.X + x + 3, this.Bounds.Y + y + 4, hh - 7, hh - 7);
                graphics.SetColor(this.Window.Desktop.Theme.Colors.Control);
                graphics.DrawRectangle(this.Bounds.X + x + 4, this.Bounds.Y + y + 5, hh - 9, hh - 9);
                graphics.SetColor(this.PlusColor);
                graphics.DrawRectangle(this.Bounds.X + x + 2 + 3, this.Bounds.Y + y + 4 + 4, 4 + 1, 1);

                if (false == this.expanded)
                {
                    graphics.DrawRectangle(this.Bounds.X + x + 2 + 2 + 3, this.Bounds.Y + y + 1 + 5, 1, 5);
                }

                if (true == this.HasFocus)
                {
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.HighlightBorder, 0.5f);
                    graphics.DrawBox(x + this.bounds.X, y + this.bounds.Y, this.bounds.Width, hh);
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.Highlight, 0.5f);
                    graphics.DrawRectangle(x + this.bounds.X + 1, y + this.bounds.Y + 1, this.bounds.Width - 2, hh - 2);
                }

                // Render text
                graphics.SetColor(this.parentGrid.TextColor);
                if (null != this.parentGrid.FontInfo.Font)
                {
                    this.parentGrid.FontInfo.Font.DrawText(graphics, this.Bounds.X + x + hh, this.Bounds.Y + y + 4, this.controlText);
                }
            }
            else
            {
                if (true == this.HasFocus)
                {
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.HighlightBorder, 0.5f);
                    graphics.DrawBox(x + this.bounds.X, y + this.Bounds.Y, this.bounds.Width, hh);
                    graphics.SetColor(this.Window.Desktop.Theme.Colors.Highlight, 0.5f);
                    graphics.DrawRectangle(x + this.Bounds.X + 1, y + this.Bounds.Y + 1, this.Bounds.Width - 2, hh - 2);
                }

                // Render text
                graphics.SetColor(this.parentGrid.TextColor);
                if (null != this.parentGrid.FontInfo.Font)
                {
                    this.parentGrid.FontInfo.Font.DrawText(graphics, this.Bounds.X + x + 3, this.Bounds.Y + y + 4, this.controlText);
                }
            }

            // Render text
            if ((0 != this.parentGrid.ValueText.Length) && (null != this.parentGrid.FontInfo.Font))
            {
                graphics.SetColor(this.parentGrid.TextColor);
                this.parentGrid.FontInfo.Font.DrawText(graphics, 4 + x + this.Bounds.X + this.Bounds.Width / 2, this.Bounds.Y + y + 4, this.parentGrid.ValueText);
            }

            RenderControls(graphics, x, y);
        }
Beispiel #4
0
        /// <summary>
        /// Constructs designer window object.
        /// </summary>
        /// <param name="engine">engine to get avaialble controls</param>
        /// <param name="desktop">desktop this window belongs to</param>
        public DesignWindow(UIEngine engine, Desktop desktop)
            : base(desktop, CreationFlag.FlagsNone, "")
        {
            this.controlsList = CreateControl<ComboBox>();
            this.controlProperties = CreateControl<PropertyGrid>();
            this.designPanel = CreateControl<Panel>();
            this.toolBox = CreateControl<ScrollPanel>();

            this.BackColor = this.Desktop.Theme.Colors.ControlDark;
            this.Bounds = new Rectangle(50, 50, 640, 480);
            this.MinSize = new Size2d(640, 480);

            this.menu = CreateControl<Menu>();
            this.AddControl(this.menu);

            MenuItem fileMenu = this.menu.AddItem("File");
            fileMenu.AddItem("New").Clicked += (x, y) => { NewWindow(); };
            fileMenu.AddItem("");
            fileMenu.AddItem("Open...").Clicked += new UIEventHandler<MenuItem>(OpenClicked);
            fileMenu.AddItem("Save").Clicked += (x, y) => { SaveWindow(); };
            fileMenu.AddItem("Save as...").Clicked += (x, y) => { SaveAsWindow(); };
            fileMenu.AddItem("");
            fileMenu.AddItem("Exit").Clicked += new UIEventHandler<MenuItem>(DesignWindowCloseClicked);

            MenuItem helpMenu = this.menu.AddItem("Help");
            helpMenu.AddItem("About").Clicked += (x, y) => { this.Desktop.NewRegisteredWindow(AboutWindow.TypeName); };

            ToolBar toolBar = CreateControl<ToolBar>();
            toolBar.Bounds = new Rectangle(2, 20, this.Bounds.Width - 4, 24);
            toolBar.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop | AnchorStyle.AnchorRight;
            toolBar.BackColor = new Color(217, 214, 207);
            this.AddControl(toolBar);

            Button newButton = CreateControl<Button>();
            newButton.Icon = "ui/design/new";
            newButton.Border = BorderStyle.None;
            newButton.BackColor = new Color(217, 214, 207);
            newButton.BackImage = "";
            newButton.Bounds = new Rectangle(8, 2, 20, 20);
            newButton.Clicked += (x, y) => { NewWindow(); };
            toolBar.AddControl(newButton);

            Button deleteButton = CreateControl<Button>();
            deleteButton.Icon = ("ui/design/delete");
            deleteButton.Border = BorderStyle.None;
            deleteButton.BackColor = new Color(217, 214, 207);
            deleteButton.BackImage = "";
            deleteButton.Bounds = new Rectangle(34, 2, 20, 20);
            deleteButton.Clicked += this.DeleteButtonClicked;
            toolBar.AddControl(deleteButton);

            Label controls = CreateControl<Label>();
            controls.BackColor = this.Desktop.Theme.Colors.HighlightBorder;
            controls.Text = "Controls";
            controls.TextAlignment = ContentAlignment.MiddleLeft;
            controls.TextColor = Colors.Black;
            controls.Bounds = new Rectangle(2, 44, 150, 17);
            controls.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop;
            this.AddControl(controls);

            this.toolBox.Bounds = new Rectangle(2, 61, 150, 374);
            this.toolBox.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop | AnchorStyle.AnchorBottom;
            this.AddControl(this.toolBox);

            int h = 5;

            foreach (KeyValuePair<String, KeyValuePair<Type, IControlsCreator>> controlType in this.Engine.ControlTypes)
            {
                KeyValuePair<Type, IControlsCreator> creator = controlType.Value;

                if (true == creator.Value.ShowInDesigner)
                {
                    Button button = this.toolBox.CreateControl<Button>();
                    button.Bounds = new Rectangle(8, h, this.toolBox.Bounds.Width - 30, 20);
                    button.Border = BorderStyle.None;
                    button.BackImage = "";
                    button.Name = controlType.Key;
                    button.TextAlignment = ContentAlignment.MiddleLeft;
                    button.TextOffset.X = 4;
                    button.TextOffset.Y = 0;
                    button.Text = controlType.Key;
                    button.Clicked += (x, y) => { SelectControlType(x); };
                    this.toolBox.AddControl(button);

                    h += 24;
                }
            }

            int propertiesWidth = 210;

            Label propertiesLabel = CreateControl<Label>();
            propertiesLabel.BackColor = this.Desktop.Theme.Colors.HighlightBorder;
            propertiesLabel.Text = "Properties";
            propertiesLabel.TextAlignment = ContentAlignment.MiddleLeft;
            propertiesLabel.Bounds = new Rectangle(this.Bounds.Width - propertiesWidth - 2, 44, propertiesWidth - 2, 17);
            propertiesLabel.Anchor = AnchorStyle.AnchorTop | AnchorStyle.AnchorRight;
            this.AddControl(propertiesLabel);

            this.controlsList.Bounds = new Rectangle(this.Bounds.Width - propertiesWidth - 2, 61, propertiesWidth - 2, 23);
            this.controlsList.Anchor = AnchorStyle.AnchorTop | AnchorStyle.AnchorRight;
            this.controlsList.Border = BorderStyle.Lowered;
            this.controlsList.BackColor = Colors.White;
            this.controlsList.SelectedItemChanged += this.ControlsListSelectedItemChanged;
            this.AddControl(this.controlsList);

            this.controlProperties.Bounds = new Rectangle(this.Bounds.Width - propertiesWidth - 2, 84, propertiesWidth - 2, 351);
            this.controlProperties.Anchor = AnchorStyle.AnchorTop | AnchorStyle.AnchorRight | AnchorStyle.AnchorBottom;
            this.AddControl(this.controlProperties);

            StatusBar statusBar = CreateControl<StatusBar>();
            statusBar.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorBottom;
            statusBar.Bounds = new Rectangle(2, this.Bounds.Height - 23 - 4 - 18, this.Bounds.Width - 4, 23);
            statusBar.Text = "Ready";
            statusBar.TextAlignment = ContentAlignment.MiddleLeft;
            this.AddControl(statusBar);

            this.designPanel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorBottom | AnchorStyle.AnchorTop;
            this.designPanel.Bounds = new Rectangle(152, 44, 276, 391);
            this.designPanel.BackColor = this.Desktop.Theme.Colors.ControlDark;
            this.designPanel.Border = BorderStyle.Lowered;
            this.AddControl(this.designPanel);

            this.HasShadow = true;
            this.CenterDesktop = true;
        }