public ScrollPanel(Window window, CreationFlag creationFlags) : base(window, creationFlags, TypeName) { this.verticalScrollBar = CreateControl<ScrollBar>(CreationFlag.InternalControl); this.horizontalScrollBar = CreateControl<ScrollBar>(CreationFlag.InternalControl); this.internalPanel = CreateControl<ScrollPanelInternal>(CreationFlag.InternalControl); this.horizontalScrollBar.Vertical = false; this.internalPanel.BackColor = Colors.None; base.AddControl(this.verticalScrollBar); base.AddControl(this.horizontalScrollBar); base.AddControl(this.internalPanel); }
/// <summary> /// Creates track bar control. /// </summary> /// <param name="window">window it belongs to.</param> /// <param name="creationFlags">creation flags.</param> public TrackBar(Window window, CreationFlag creationFlags) : base(window, creationFlags, TypeName) { this.backPanel = CreateControl<Panel>(CreationFlag.InternalControl); this.sliderButton = CreateControl<Button>(CreationFlag.InternalControl); this.sliderButton.MousePress += (x, y) => { this.trackerDragging = true; }; this.sliderButton.MouseRelease += (x, y) => { this.trackerDragging = false; }; this.sliderButton.MouseMoved += this.SliderButtonMouseMoved; this.backPanel.Border = BorderStyle.Lowered; this.BackColor = Colors.None; AddControl(this.backPanel); AddControl(this.sliderButton); }
/// <summary> /// Creates color chooser window. /// </summary> /// <param name="desktop">desktop it belongs to.</param> public ColorChooser(Desktop desktop) : base(desktop, CreationFlag.FlagsNone, "") { this.colorPanel = CreateControl<Panel>(); this.redSelector = CreateControl<TrackBar>(); this.greenSelector = CreateControl<TrackBar>(); this.blueSelector = CreateControl<TrackBar>(); this.alphaSelector = CreateControl<TrackBar>(); this.colors = CreateControl<ComboBox>(); this.Text = "Select color"; this.Modal = true; this.MinSize = new Size2d(450, 330); this.Bounds = new Rectangle((desktop.Width - this.MinSize.Width) / 2, (desktop.Height - this.MinSize.Height) / 2, this.MinSize.Width, this.MinSize.Height); this.colorPanel.Bounds = new Rectangle(121, 210, 317, 50); this.colorPanel.Border = BorderStyle.Lowered; Button cancelButton = CreateControl<Button>(); cancelButton.Text = "Cancel"; cancelButton.Bounds = new Rectangle(343, 277, 95, 24); cancelButton.DialogResult = DialogResult.DialogResultCancel; cancelButton.Anchor = AnchorStyle.AnchorBottom | AnchorStyle.AnchorRight; Button selectButton = CreateControl<Button>(); selectButton.Text = "Select"; selectButton.Bounds = new Rectangle(245, 277, 95, 24); selectButton.DialogResult = DialogResult.DialogResultOK; selectButton.Anchor = AnchorStyle.AnchorBottom | AnchorStyle.AnchorRight; Control systemColorsLabel = CreateControl<Label>(); systemColorsLabel.Text = "System color"; systemColorsLabel.Bounds = new Rectangle(10, 43 - 35, 120, 24); Control redLabel = CreateControl<Label>(); redLabel.Text = "Red"; redLabel.Bounds = new Rectangle(10, 43, 120, 35); Control greenLabel = CreateControl<Label>(); greenLabel.Text = "Green"; greenLabel.Bounds = new Rectangle(10, 43 + 35, 120, 35); Control blueLabel = CreateControl<Label>(); blueLabel.Text = "Blue"; blueLabel.Bounds = new Rectangle(10, 43 + 35 + 35, 120, 35); Control alphaLabel = CreateControl<Label>(); alphaLabel.Text = "Alpha"; alphaLabel.Bounds = new Rectangle(10, 43 + 35 + 35 + 35, 120, 35); this.redSelector.Bounds = new Rectangle(121, 43, 317, 35); this.redSelector.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.redSelector.ValueChanged += this.ColorSelectorValueChanged; this.greenSelector.Bounds = new Rectangle(121, 43 + 35, 317, 35); this.greenSelector.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.greenSelector.ValueChanged += this.ColorSelectorValueChanged; this.blueSelector.Bounds = new Rectangle(121, 43 + 35 + 35, 317, 35); this.blueSelector.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.blueSelector.ValueChanged += this.ColorSelectorValueChanged; this.alphaSelector.Bounds = new Rectangle(121, 43 + 35 + 35 + 35, 317, 35); this.alphaSelector.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.alphaSelector.ValueChanged += this.ColorSelectorValueChanged; this.colors.Bounds = new Rectangle(121, 43 - 35, 317, 24); this.colors.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.colors.SelectedItemChanged += new UIEventHandler<ComboBox>(ColorItemChanged); foreach (Color color in this.Desktop.Theme.Colors.SystemColors) { this.colors.AddItem(color.Name, color.Name, "", color); } AddControl(systemColorsLabel); AddControl(redLabel); AddControl(greenLabel); AddControl(blueLabel); AddControl(alphaLabel); AddControl(selectButton); AddControl(cancelButton); AddControl(this.colorPanel); AddControl(this.redSelector); AddControl(this.greenSelector); AddControl(this.blueSelector); AddControl(this.alphaSelector); AddControl(this.colors); }
/// <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; }