protected virtual void AddDefaultToolStripButtons() { ManifestResources res = new ManifestResources("BinaryComponents.SuperList.Resources"); _columnButton = new ToolStripButton(); _columnButton.Name = "_columnButton"; _columnButton.Image = res.GetIcon("ColumnsButton.ico").ToBitmap(); _columnButton.Text = "Columns"; _columnButton.Click += _columnButton_Click; _columnButton.ToolTipText = "Click to display available columns that you can either group on or show in the actual list"; _columnButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; _collapseGroupButton = new ToolStripButton(); _collapseGroupButton.Visible = true; _collapseGroupButton.Name = "collapseAllGroupsButton"; _collapseGroupButton.Image = res.GetIcon("CollapseAllGroupsButton.ico").ToBitmap(); _collapseGroupButton.Click += _collapseGroupButton_Click; _collapseGroupButton.DisplayStyle = ToolStripItemDisplayStyle.Image; _collapseGroupButton.ToolTipText = "Click to collapse all groups within the list"; _expandGroupsButton = new ToolStripButton(); _expandGroupsButton.Visible = true; _expandGroupsButton.Name = "expandAllGroupsButton"; _expandGroupsButton.Image = res.GetIcon("ExpandAllGroupsButton.ico").ToBitmap(); _expandGroupsButton.Click += _expandGroupsButton_Click; _expandGroupsButton.DisplayStyle = ToolStripItemDisplayStyle.Image; _expandGroupsButton.ToolTipText = "Click to expand all groups within the list"; AddToolStripItems(new ToolStripItem[] { _columnButton, _collapseGroupButton, _expandGroupsButton }); }
public ToolStripItem CreateMenuItem(IWin32Window window, ToolStrip menu, SidebarControl sidebarControl) { Debug.Assert(window != null); Debug.Assert(menu != null); this.Window = window; this.Menu = menu; this.MenuItem = new ToolStripSplitButton(this.DisplayName, ManifestResources.GetBitmap("DmmLog.Resources.DmmMenu.png")) { DoubleClickEnabled = true, ForeColor = SystemColors.GrayText, Tag = this, ToolTipText = this.Driver.Capabilities.DisplayName }; this.MenuItem.ButtonClick += delegate(object sender, EventArgs e) { sidebarControl.SelectedDevice = this; }; this.MenuItem.ButtonDoubleClick += delegate(object sender, EventArgs e) { if (this.IsConnected == false) { this.Connect(); } }; this.MenuItem.DropDownOpening += delegate(object sender, EventArgs e) { this.MenuItem.DropDownItems.Clear(); FillDeviceDropDown(this.MenuItem.DropDownItems, this, sidebarControl); }; return(this.MenuItem); }
public void Test_PackUri_EmbeddedResourceExists() { var packUri = new Uri($@"{PackUriHelper.UriSchemePack}://application:,,,/Dapplo.Addons.Tests;component/TestFiles/embedded-dapplo.png"); var resources = new ManifestResources(s => AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(assembly => assembly.GetName().Name == s)); Assert.True(resources.EmbeddedResourceExists(packUri)); }
private void loadIcon(string strIconResourceName) { Stream stm = ManifestResources.GetManifestResource(strIconResourceName); Image img = ByteImageConverter.StreamToImage(stm); img.Width = 20; img.Height = 20; img.HorizontalAlignment = HorizontalAlignment.Stretch; img.VerticalAlignment = VerticalAlignment.Stretch; this.Icon = img; }
public void Test_PackUri_GetResource() { var packUri = new Uri($@"{PackUriHelper.UriSchemePack}://application:,,,/Dapplo.Addons.Tests;component/TestFiles/embedded-dapplo.png"); var resources = new ManifestResources(s => AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(assembly => assembly.GetName().Name == s)); using (var stream = resources.ResourceAsStream(packUri)) { Assert.NotNull(stream); Assert.True(stream.Length > 0); } }
private void FillDeviceDropDown(ToolStripItemCollection menu, Device device, SidebarControl sidebarControl) { if (this.IsConnected == true) { var mnuDisconnect = new ToolStripMenuItem("Disconnect"); mnuDisconnect.Click += delegate(object sender, EventArgs e) { sidebarControl.Invalidate(); this.Disconnect(); }; menu.Add(mnuDisconnect); } else if (this.IsConnected == false) { var mnuConnect = new ToolStripMenuItem("Connect"); mnuConnect.Click += delegate(object sender, EventArgs e) { this.Connect(); }; menu.Add(mnuConnect); } else { menu.Add(new ToolStripMenuItem("Connecting...") { Enabled = false }); } menu.Add(new ToolStripSeparator()); var mnuConfigure = new ToolStripMenuItem("Configure", ManifestResources.GetBitmap("DmmLog.Resources.DmmMenuEdit.png")); if (this.IsConnected == false) { mnuConfigure.Click += delegate(object sender, EventArgs e) { String newDisplayName = this.DisplayName; String newSettings = this.Settings; switch (this.Driver.Capabilities.Interface) { case DmmDriverInterface.None: { using (var frm = new NewDeviceNoInterfaceForm(this)) { if (frm.ShowDialog(this.Window) == DialogResult.OK) { newDisplayName = frm.SelectedDisplayName; newSettings = ""; } } } break; case DmmDriverInterface.SerialPort: { using (var frm = new NewDeviceSerialInterfaceForm(this)) { if (frm.ShowDialog(this.Window) == DialogResult.OK) { newDisplayName = frm.SelectedDisplayName; newSettings = frm.SelectedSettings; } } } break; default: throw new NotSupportedException("Unknown interface '" + this.Driver.Capabilities.Interface.ToString() + "'."); } if (!string.Equals(this.DisplayName, newDisplayName, StringComparison.Ordinal)) //change display name { this.DisplayName = newDisplayName; if (this.MenuItem != null) { this.MenuItem.Text = this.DisplayName; } } if (!string.Equals(this.Settings, newSettings, StringComparison.Ordinal)) //change settings { this.Settings = newSettings; this.Instance.Dispose(); this.Instance = this.Driver.GetInstance(this.Settings); } }; } else { mnuConfigure.Enabled = false; } menu.Add(mnuConfigure); var mnuRemove = new ToolStripMenuItem("Remove", ManifestResources.GetBitmap("DmmLog.Resources.DmmMenuRemove.png")); if (this.IsConnected == false) { mnuRemove.Click += delegate(object sender, EventArgs e) { if (Medo.MessageBox.ShowQuestion(this.Window, "Do you really want to remove " + this.DisplayName + "?", MessageBoxButtons.YesNo) == DialogResult.Yes) { Devices.Remove(this); this.Menu.Items.Remove(this.MenuItem); } sidebarControl.Invalidate(); }; } else { mnuRemove.Enabled = false; } menu.Add(mnuRemove); }