public FilePicker(Window window, CreationFlag creationFlags) : base(window, creationFlags, TypeName) { this.selectButton = CreateControl<Button>(CreationFlag.InternalControl); this.Border = BorderStyle.Lowered; this.NeedTranslation = false; this.selectButton.NeedTranslation = false; this.selectButton.Text = ".."; this.selectButton.Clicked += this.ButtonClicked; this.BackColor = window.Desktop.Theme.Colors.Window; this.TextAlignment = ContentAlignment.MiddleLeft; AddControl(this.selectButton); }
/// <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); }
private void ButtonClicked(Button sender, EventArgs e) { if (null != this.Window) { Desktop desktop = this.Window.Desktop; if (null != desktop) { Window window = desktop.NewRegisteredWindow(FileChooser.TypeName); if (null != window) { window.Closing += this.FileChooserClosing; } } } }
/// <summary> /// Creates combo box control /// </summary> /// <param name="window">window it belongs to</param> /// <param name="creationFlags">creation flags</param> public ComboBox(Window window, CreationFlag creationFlags) : base(window, creationFlags, TypeName) { this.button = CreateControl<Button>(CreationFlag.InternalControl); this.TextAlignment = ContentAlignment.MiddleLeft; this.IconAlignment = ContentAlignment.MiddleLeft; this.IconSize = IconSize.IconSmall; this.IconImageOffset.X = 2; this.IconImageOffset.Y = 3; this.Border = BorderStyle.BorderLoweredDouble; this.button.IconAlignment = ContentAlignment.MiddleCenter; this.button.Icon = this.Window.Desktop.Theme.ThemeFolder + "/images/combobox_icon_down"; this.button.Clicked += this.ButtonClicked; this.AddControl(this.button); }
/// <summary> /// Creates scrollbar control. /// </summary> /// <param name="window">window it belongs to.</param> /// <param name="creationFlags">creation falgs.</param> public ScrollBar(Window window, CreationFlag creationFlags) : base(window, creationFlags, TypeName) { this.increaseButton = CreateControl<Button>(CreationFlag.InternalControl); this.decreaseButton = CreateControl<Button>(CreationFlag.InternalControl); this.sliderButton = CreateControl<Button>(CreationFlag.InternalControl); AddControl(this.increaseButton); AddControl(this.decreaseButton); AddControl(this.sliderButton); this.increaseButton.Clicked += (x, Y) => { this.Position += this.stepSize; }; this.decreaseButton.Clicked += (x, y) => { this.Position -= this.stepSize; }; this.sliderButton.MouseMoved += new UIEventHandler<Button>(SliderMouseMoved); this.sliderButton.MousePress += (x, y) => { this.sliderDragging = true; }; this.sliderButton.MouseRelease += (x, y) => { this.sliderDragging = false; }; this.Vertical = true; }
public MenuRibbon(Window window, CreationFlag creationFlags) : base(window, creationFlags) { this.Type = TypeName; this.menuButton = CreateControl<Button>(); this.menuButton.Height = 28; this.menuButton.Text = "Menu"; this.menuButton.FontInfo.Name = "Calibri"; this.menuButton.FontInfo.Bold = true; this.menuButton.FontInfo.Size = 20; this.menuButton.TextColor = Colors.White; this.menuButton.BackColor = Colors.None; this.menuButton.Border = BorderStyle.None; this.menuButton.Clicked += (x, y) => { this.Active = !this.Active; }; AddControl(this.menuButton); this.BackColor = Colors.None; }
/// <summary> /// Creates message box window. /// </summary> /// <param name="desktop">desktop it belongs to.</param> public MessageBox(Desktop desktop) : base(desktop, CreationFlag.FlagsNone, "") { this.Type = TypeName; this.textLabel1 = CreateControl<Label>(); this.textLabel2 = CreateControl<Label>(); this.yesButton = CreateControl<Button>(); this.noButton = CreateControl<Button>(); this.cancelButton = CreateControl<Button>(); this.MinSize = new Size2d(590, 130); this.Bounds = new Rectangle((desktop.Width - this.MinSize.Width) / 2, (desktop.Height - this.MinSize.Height) / 2, this.MinSize.Width, this.MinSize.Height); this.Modal = true; this.Sizeable = false; this.Skinned = true; this.textLabel1.Bounds = new Rectangle(10, 10, 570, 24); this.textLabel2.Bounds = new Rectangle(40, 10, 570, 24); this.textLabel1.Anchor = AnchorStyle.AnchorTop | AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight; this.textLabel2.Anchor = AnchorStyle.AnchorTop | AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight; this.yesButton.DialogResult = DialogResult.DialogResultYes; this.noButton.DialogResult = DialogResult.DialogResultNo; this.cancelButton.DialogResult = DialogResult.DialogResultCancel; this.yesButton.Anchor = AnchorStyle.AnchorBottom; this.noButton.Anchor = AnchorStyle.AnchorBottom; this.cancelButton.Anchor = AnchorStyle.AnchorBottom; AddControl(this.yesButton); AddControl(this.noButton); AddControl(this.cancelButton); AddControl(this.textLabel1); AddControl(this.textLabel2); PlaceButtons(); }
private void ButtonClicked(Button sender, System.EventArgs e) { if (null != this.Window) { Desktop desktop = this.Window.Desktop; if (null != desktop) { Window window = desktop.NewRegisteredWindow(ColorChooser.TypeName); if (null != window) { window.Closing += this.ColorChooserClosing; ((ColorChooser)window).SelectedColor = this.BackColor; } } } }
/// <summary> /// Creates info panel control. /// </summary> /// <param name="window">window it belongs to</param> /// <param name="creationFlags">creation flags</param> public InfoPanel(Window window, CreationFlag creationFlags) : base(window, creationFlags) { this.Type = TypeName; this.imageBorder = CreateControl<Button>(); this.image = CreateControl<Button>(); this.titleLabel = CreateControl<Button>(); this.subTitleLabel = CreateControl<Button>(); this.commentLabel = CreateControl<Button>(); this.imageBorder.Bounds = new Rectangle(0, 0, 200, 120); this.imageBorder.BackColor = Colors.Black; this.imageBorder.Border = BorderStyle.None; this.imageBorder.BackImage = ""; this.image.Bounds = new Rectangle(10, 10, 180, 100); this.image.BackImageLayout = ImageLayout.ImageLayoutStretch; this.image.Border = BorderStyle.None; this.titleLabel.FontInfo.SetFontInfo("Arial", 12, true, false); this.titleLabel.Bounds = new Rectangle(220, 0, 230, 20); this.titleLabel.TextAlignment = ContentAlignment.MiddleLeft; this.titleLabel.BackColor = Colors.None; this.titleLabel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.titleLabel.TextColor = this.TextColor; this.titleLabel.Border = BorderStyle.None; this.titleLabel.BackImage = ""; this.subTitleLabel.FontInfo.SetFontInfo("Arial", 12, false, false); this.subTitleLabel.Bounds = new Rectangle(220, 20, 230, 20); this.subTitleLabel.TextAlignment = ContentAlignment.MiddleLeft; this.subTitleLabel.BackColor = Colors.None; this.subTitleLabel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.subTitleLabel.TextColor = this.TextColor; this.subTitleLabel.Border = BorderStyle.None; this.subTitleLabel.BackImage = ""; this.commentLabel.FontInfo.SetFontInfo("Arial", 12, false, false); this.commentLabel.Bounds = new Rectangle(220, 40, 230, 20); this.commentLabel.TextAlignment = ContentAlignment.MiddleLeft; this.commentLabel.BackColor = Colors.None; this.commentLabel.Anchor = AnchorStyle.AnchorLeft | AnchorStyle.AnchorRight | AnchorStyle.AnchorTop; this.commentLabel.TextColor = this.TextColor; this.commentLabel.Border = BorderStyle.None; this.commentLabel.BackImage = ""; this.MinSize = new Size2d(200, 100); this.Bounds = new Rectangle(0, 0, 470, 120); this.Border = BorderStyle.None; this.BackImage = ""; this.AddControl(this.imageBorder); this.AddControl(this.titleLabel); this.AddControl(this.subTitleLabel); this.AddControl(this.commentLabel); this.imageBorder.AddControl(this.image); this.imageBorder.Clicked += this.ChildControlClicked; this.titleLabel.Clicked += this.ChildControlClicked; this.subTitleLabel.Clicked += this.ChildControlClicked; this.commentLabel.Clicked += this.ChildControlClicked; this.image.Clicked += this.ChildControlClicked; }
/// <summary> /// Handles mouse move event on tracker button. /// </summary> /// <param name="sender">tracker button.</param> /// <param name="args">arguments.</param> private void SliderButtonMouseMoved(Button sender, EventArgs args) { if (true == this.trackerDragging) { Window window = null; for (Control control = this; control != null; control = control.Parent) { if (null == control.Parent) { window = (Window)control; } } Desktop desktop = window.Desktop; if (null != desktop) { if (true == this.vertical) { int y = desktop.MouseY; int sy = this.TranslateY(y); if ((sy >= 0) && (sy <= this.bounds.Height - this.buttonSize)) { this.Position = (float)(sy - this.buttonSize) / (float)(this.bounds.Height - this.buttonSize); } else if (sy < 0.0f) { this.Position = 0.0f; } else if (sy > this.bounds.Height - this.buttonSize) { this.Position = 1.0f; } } else { int x = desktop.MouseX; int sx = this.TranslateX(x); if ((sx >= 0) && (sx <= this.bounds.Width - this.buttonSize)) { this.Position = (float)(sx) / (float)(this.bounds.Width - this.buttonSize); } else if (sx < 0.0f) { this.Position = 0.0f; } else if (sx > this.Bounds.Width - this.buttonSize) { this.Position = 1.0f; } } } } }
private void SelectButtonClicked(Button sender, EventArgs e) { if (null != this.Window) { Desktop desktop = this.Window.Desktop; if (null != desktop) { Window anchorChooserWindow = desktop.NewRegisteredWindow(AnchorChooser.TypeName); if (null != anchorChooserWindow) { anchorChooserWindow.Closing += this.AnchorChooserWindowClosing; ((AnchorChooser)anchorChooserWindow).SelectedAnchor = this.selectedAnchor; } } } }
/// <summary> /// Handles slider mouse move event. /// </summary> /// <param name="sender">slider button</param> /// <param name="args">arguments</param> private void SliderMouseMoved(Button sender, EventArgs args) { if (true == this.sliderDragging) { Desktop desktop = this.Window.Desktop; if (null != desktop) { if (true == this.vertical) { int y = desktop.MouseY; int sy = this.TranslateY(y); if ((sy >= this.buttonSize) && (sy <= this.bounds.Height - this.buttonSize)) { this.Position = (float)this.maxSize * (float)(sy - this.buttonSize) / (float)(this.bounds.Height - this.buttonSize * 2); } else if (sy < this.buttonSize) { this.Position = 0; } else if (sy > this.bounds.Height - this.buttonSize) { this.Position = (float)(this.maxSize); } } else { int x = desktop.MouseX; int sx = this.TranslateX(x); if ((sx >= 16) && (sx <= this.bounds.Width - this.buttonSize)) { this.Position = (float)this.maxSize * (float)(sx - this.buttonSize) / (float)(this.bounds.Width - this.buttonSize * 2); } else if (sx < this.buttonSize) { this.Position = 0; } else if (sx > this.bounds.Width - this.buttonSize) { this.Position = (float)(this.maxSize); } } } } }
/// <summary> /// Handles delete selected element event. /// </summary> /// <param name="sender">clicked button</param> /// <param name="e">arguments</param> private void DeleteButtonClicked(Button sender, EventArgs e) { if (null != this.activeControl) { if (this.activeControl != this.activeWindow) { this.activeControl.Parent.RemoveControl(this.activeControl); SetControl(null, true); } } }
private void VADemoClicked(Button sender, EventArgs args) { this.activeDesktop = this.engine.NewDesktop(null, "hl2/theme/"); this.activeDesktop.SetSize(this.GraphicsDevice.Viewport.Width, this.GraphicsDevice.Viewport.Height); var mainWindow = this.activeDesktop.NewWindow("va/main.window.xml"); mainWindow.Animations.Add(new LinearPropertyAnimation(0, 100, 0.5, (x) => { mainWindow.Opacity = (float)x / 100.0f; })); mainWindow.Animations.Add(new LinearPropertyAnimation(800, 0, 0.5, (x) => { mainWindow.X = x; })); mainWindow.Closing += this.GameDemoMainWindowClosing; }
private void MEDemoClicked(Button sender, EventArgs args) { this.activeDesktop = this.engine.NewDesktop(null, "me/theme/"); this.activeDesktop.SetSize(this.GraphicsDevice.Viewport.Width, this.GraphicsDevice.Viewport.Height); var mainWindow = this.activeDesktop.NewWindow("me/main.window.xml"); mainWindow.Animations.Add(new LinearPropertyAnimation(0, 100, 0.5, (x) => { mainWindow.Opacity = (float)x / 100.0f; })); mainWindow.Animations.Add(new LinearPropertyAnimation(800, 0, 0.5, (x) => { mainWindow.X = x; })); mainWindow.Closing += this.GameDemoMainWindowClosing; var story = mainWindow.FindControl<MenuRibbon>("story"); var options = mainWindow.FindControl<MenuRibbon>("options"); var extra = mainWindow.FindControl<MenuRibbon>("extra"); meMenus.Clear(); meMenus.Add(story); meMenus.Add(options); meMenus.Add(extra); story.ActiveChanged += this.MERibbonActiveChanged; options.ActiveChanged += this.MERibbonActiveChanged; extra.ActiveChanged += this.MERibbonActiveChanged; }
/// <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); }