/// <summary> /// Determines if coordinated are inside this control. /// </summary> /// <param name="X">X coordinate.</param> /// <param name="Y">Y coordinate.</param> /// <returns></returns> internal override bool IsInside(int x, int y) { ScrollPanel scrollPanel = (ScrollPanel)this.Parent; Rectangle r = scrollPanel.Bounds; int w = r.Width; int h = r.Height; if ((null != scrollPanel.verticalScrollBar) && (scrollPanel.verticalScrollBar.Visible)) { w -= scrollPanel.verticalScrollBar.ButtonSize; } if ((null != scrollPanel.horizontalScrollBar) && (scrollPanel.horizontalScrollBar.Visible)) { h -= scrollPanel.horizontalScrollBar.ButtonSize; } if ((x >= 0) && (y >= 0) && (x <= w) && (y <= h)) { return(base.IsInside(x, y)); } else { return(false); } }
/// <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; }
private void OpenList() { if (0 == this.items.Count) { return; } Window window = this.Window.Desktop.NewTempWindow(""); int cx = 0; int cy = window.TopOffset; for (Control control = this; control != null; control = control.Parent) { cx += control.Bounds.X; cy += control.Bounds.Y; } ScrollPanel scrollPanel = window.CreateControl <ScrollPanel>(); scrollPanel.Border = BorderStyle.Flat; scrollPanel.BackColor = Colors.White; scrollPanel.FillParent = true; window.AddControl(scrollPanel); ListBox listBox = window.CreateControl <ListBox>(); listBox.ListStyle = ListStyle.Details; listBox.Border = BorderStyle.None; listBox.Name = "listBoxItems"; scrollPanel.AddControl(listBox); bool hasIcon = false; foreach (ComboBoxItem item in this.items) { if (((null != item.Icon) && (item.Icon.Length > 0)) || (null != item.image)) { hasIcon = true; break; } } foreach (ComboBoxItem item in this.items) { ListItem listItem = window.CreateControl <ListItem>(); listItem.ListStyle = ListStyle.Details; listItem.Text = item.Text; listItem.Tag = item; /* if (null != item.image) * { * listItem.IconPicture = item.image; * } * else */ { listItem.Icon = item.Icon; } listItem.Clicked += this.ItemClicked; listItem.BackColor = Colors.None; // listItem.SetFont(this.m_strFontName, this.m_nFontSize, this.m_bFontBold, this.m_bFontItalic); listItem.NeedTranslation = this.NeedTranslation; if (false == hasIcon) { listItem.TextOffset.X = 0; listItem.TextOffset.Y = 0; } listBox.AddControl(listItem); } int maxHeight = this.items.Count * (12 + this.FontInfo.Size + 1); if (maxHeight > 300) { maxHeight = 300; listBox.Bounds = new Rectangle(1, 1, this.Bounds.Width - 4 - scrollPanel.horizontalScrollBar.ButtonSize, 0); } else { listBox.Bounds = new Rectangle(0, 0, this.Bounds.Width - 4, 0); } listBox.BackColor = Colors.None; listBox.AutoSize = true; window.Bounds = new Rectangle(cx, cy + this.Bounds.Height, this.Bounds.Width, maxHeight + 3); window.Border = BorderStyle.None; window.BackColor = Colors.None; window.Moveable = false; window.Sizeable = true; window.Closing += this.WindowClosing; this.listWindow = window; }
/// <summary> /// Creates files chooser window. /// </summary> /// <param name="desktop">desktop it belongs to.</param> public FileChooser(Desktop desktop) : base(desktop, CreationFlag.FlagsNone, "") { this.filesListListBox = CreateControl<ListBox>(); this.filtersComboBox = CreateControl<ComboBox>(); this.fileNameTextBox = CreateControl<TextBox>(); this.desktopItem = CreateControl<ListItem>(); this.myDocumentsItem = CreateControl<ListItem>(); this.myComputerItem = CreateControl<ListItem>(); this.NetworkItem = CreateControl<ListItem>(); this.virtualFileSystemItem = CreateControl<ListItem>(); this.drivesComboBox = CreateControl<ComboBox>(); this.upButton = CreateControl<Button>(); this.selectButton = CreateControl<Button>(); this.filesScrollPanel = CreateControl<ScrollPanel>(); this.BackColor = this.Desktop.Theme.Colors.Control; this.MinSize = new Size2d(563, 412); this.Text = "Select File"; this.Opacity = 1.0f; this.Modal = true; this.Bounds = new Rectangle((desktop.Width - this.MinSize.Width) / 2, (desktop.Height - this.MinSize.Height) / 2, this.MinSize.Width, this.MinSize.Height); this.HasShadow = true; this.selectButton.Anchor = AnchorStyle.AnchorBottom | AnchorStyle.AnchorRight; this.selectButton.Text = "Open"; this.selectButton.Bounds = new Rectangle(477, 330, 75, 23); this.selectButton.DialogResult = DialogResult.DialogResultOK; AddControl(this.selectButton); Button cancelButton = CreateControl<Button>(); cancelButton.Anchor = AnchorStyle.AnchorBottom | AnchorStyle.AnchorRight; cancelButton.Text = "Cancel"; cancelButton.Bounds = new Rectangle(477, 357, 75, 23); cancelButton.DialogResult = DialogResult.DialogResultCancel; AddControl(cancelButton); Label lookInLabel = CreateControl<Label>(); lookInLabel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop; lookInLabel.Text = "Look in:"; lookInLabel.Bounds = new Rectangle(10, 10, 87, 23); AddControl(lookInLabel); Label fileNameLabel = CreateControl<Label>(); fileNameLabel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorBottom; fileNameLabel.Text = "File name:"; fileNameLabel.Bounds = new Rectangle(103, 331, 97, 23); AddControl(fileNameLabel); Label filterLabel = CreateControl<Label>(); filterLabel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorBottom; filterLabel.Text = "Files of type:"; filterLabel.Bounds = new Rectangle(103, 359, 97, 23); AddControl(filterLabel); ListBox sideListBox = CreateControl<ListBox>(); sideListBox.Opacity = 0.5f; sideListBox.Border = BorderStyle.BorderLoweredDouble; sideListBox.BackColor = this.Desktop.Theme.Colors.ControlDark; sideListBox.AutoSize = false; sideListBox.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop | AnchorStyle.AnchorBottom; sideListBox.Bounds = new Rectangle(10, 39, 87, 338); AddControl(sideListBox); this.desktopItem.Bounds = new Rectangle(2, 2, 82, 60); this.desktopItem.Text = "Desktop"; this.desktopItem.Clicked += (sender, args) => { FillList(this.desktopFolder); }; sideListBox.AddControl(this.desktopItem); this.myDocumentsItem.Bounds = new Rectangle(2, 2, 62, 60); this.myDocumentsItem.Text = "My Documents"; this.myDocumentsItem.Clicked += (sender, args) => { FillList(GetFile(this.desktopFolder, FileTypes.MyDocuments)); }; sideListBox.AddControl(this.myDocumentsItem); this.myComputerItem.Bounds = new Rectangle(2, 2, 122, 60); this.myComputerItem.Text = "My Computer"; this.myComputerItem.Clicked += (sender, args) => { FillList(GetFile(this.desktopFolder, FileTypes.MyComputer)); }; sideListBox.AddControl(this.myComputerItem); this.NetworkItem.Bounds = new Rectangle(2, 2, 182, 60); this.NetworkItem.Text = "Network"; this.NetworkItem.Clicked += (sender, args) => { FillList(GetFile(this.desktopFolder, FileTypes.Network)); }; sideListBox.AddControl(this.NetworkItem); this.virtualFileSystemItem.Bounds = new Rectangle(2, 2, 242, 60); this.virtualFileSystemItem.Text = "Virtual FS"; this.virtualFileSystemItem.Clicked += this.VirtualFileSystemClicked; sideListBox.AddControl(this.virtualFileSystemItem); this.filesScrollPanel.Border = BorderStyle.BorderLoweredDouble; this.filesScrollPanel.BackColor = this.Window.Desktop.Theme.Colors.Window; this.filesScrollPanel.Anchor = AnchorStyle.AnchorBottom | AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop | AnchorStyle.AnchorRight; this.filesScrollPanel.Opacity = 0.5f; this.filesScrollPanel.Bounds = new Rectangle(103, 39, 450, 283); AddControl(this.filesScrollPanel); this.filesListListBox.Border = BorderStyle.None; this.filesListListBox.BackColor = Colors.None; this.filesListListBox.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorTop; this.filesListListBox.Bounds = new Rectangle(0, 0, 430, 0); this.filesListListBox.ListStyle = ListStyle.Details; this.filesListListBox.AutoSize = true; this.filesScrollPanel.AddControl(this.filesListListBox); this.fileNameTextBox.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorBottom; this.fileNameTextBox.Bounds = new Rectangle(199, 332, 266, 22); AddControl(this.fileNameTextBox); this.drivesComboBox.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.drivesComboBox.Bounds = new Rectangle(103, 10, 421, 22); this.drivesComboBox.SelectedItemChanged += new UIEventHandler<ComboBox>(DrivesSelectedItemChanged); this.drivesComboBox.NeedTranslation = false; AddControl(this.drivesComboBox); this.filtersComboBox.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorBottom; this.filtersComboBox.Bounds = new Rectangle(199, 359, 266, 22); this.filtersComboBox.SelectedItemChanged += (sender, args) => { FillList(this.activeVirtualFolder); }; AddControl(this.filtersComboBox); this.upButton.Anchor = AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.upButton.Bounds = new Rectangle(528, 10, 23, 23); this.upButton.Icon = (this.Window.Desktop.Theme.ThemeFolder + "icons/button_up"); this.upButton.Clicked += this.UpButtonClicked; AddControl(this.upButton); IVirtualFile myComputer = GetFile(this.desktopFolder, FileTypes.MyComputer); if (null != myComputer) { foreach (IVirtualFile file in myComputer.ChildFiles) { ComboBoxItem item = this.drivesComboBox.AddItem(file.Name, file.Name, "", file); item.SetIcon(FileUtils.Platform.GetFileIcon(file.Name, false, this.Engine, this.Window.Desktop.Theme)); } } this.desktopItem.icon = new ImageObject(FileUtils.Platform.GetDesktopIcon(true, this.Engine, this.Window.Desktop.Theme), this.Engine, null); this.myDocumentsItem.icon = new ImageObject(FileUtils.Platform.GetMyDocumentsIcon(true, this.Engine, this.Window.Desktop.Theme), this.Engine, null); this.myComputerItem.icon = new ImageObject(FileUtils.Platform.GetMyComputerIcon(true, this.Engine, this.Window.Desktop.Theme), this.Engine, null); this.NetworkItem.icon = new ImageObject(FileUtils.Platform.GetNetworkIcon(true, this.Engine, this.Window.Desktop.Theme), this.Engine, null); this.virtualFileSystemItem.icon = new ImageObject(FileUtils.Platform.GetIcon(4, true, this.Engine, this.Window.Desktop.Theme), this.Engine, null); List<String> extensions = new List<String>(); extensions.Add(""); AddFilter("All files (*.*)", extensions); extensions = new List<String>(); extensions.Add(".avi"); extensions.Add(".omg"); extensions.Add(".mpg"); AddFilter("Video files (*.avi; *.omg; *.mpg)", extensions); extensions = new List<String>(); extensions.Add(".mp3"); extensions.Add(".ogg"); extensions.Add(".wav"); AddFilter("Audio files (*.mp3; *.ogg; *.wav)", extensions); extensions = new List<String>(); extensions.Add(".txt"); extensions.Add(".doc"); extensions.Add(".pdf"); AddFilter("Documents (*.txt; *.doc; *.pdf)", extensions); extensions = new List<String>(); extensions.Add(".png"); extensions.Add(".jpg"); extensions.Add(".tga"); AddFilter("Images (*.png; *.jpg; *.tga)", extensions); FillList(this.desktopFolder); }