public void GetImage_NullComponent_ReturnsNull() { var attribute = new ToolboxBitmapAttribute((string)null); Assert.Null(attribute.GetImage((object)null)); Assert.Null(attribute.GetImage((object)null, true)); }
// Methods public ListBoxItem(DataGridViewColumn column, ExtDataGridColumnCollectionDialog owner, ComponentDesigner compDesigner) { this.column = column; this.owner = owner; this.compDesigner = compDesigner; if (this.compDesigner != null) { this.compDesigner.Initialize(column); TypeDescriptor.CreateAssociation(this.column, this.compDesigner); } ToolboxBitmapAttribute attribute = TypeDescriptor.GetAttributes(column)[ExtDataGridColumnCollectionDialog.toolboxBitmapAttributeType] as ToolboxBitmapAttribute; if (attribute != null) { this.toolboxBitmap = attribute.GetImage(column, false); } else { //this.toolboxBitmap = this.owner.SelectedColumnsItemBitmap; } DataGridViewColumnDesigner designer = compDesigner as DataGridViewColumnDesigner; if (designer != null) { //designer.LiveDataGridView = this.owner.liveDataGridView; } }
private void SetSelectedChart() { if (_component.ChartControl != null) { lblDestination.Text = ((Control)_component.ChartControl).Name; try { Image resultImage = null; AttributeCollection attrCol = TypeDescriptor.GetAttributes(_component.CurrentAdapter.GetType()); ToolboxBitmapAttribute imageAttr = (ToolboxBitmapAttribute)attrCol[typeof(ToolboxBitmapAttribute)]; if (imageAttr != null) { resultImage = imageAttr.GetImage(_component.CurrentAdapter.GetType(), false);//false - 16x16, true - 32x32 int index = 0; imageListCharts.Images.Add(resultImage); index = imageListCharts.Images.Count; lblDestination.ImageIndex = index; } } catch { } InitSeriesList(); } }
public static Image GetToolboxImage(Type activityType) { if (activityType == null) { throw new ArgumentNullException("activityType"); } Image toolBoxImage = null; if (activityType != null) { object[] attribs = activityType.GetCustomAttributes(typeof(ToolboxBitmapAttribute), false); if (attribs != null && attribs.GetLength(0) == 0) { attribs = activityType.GetCustomAttributes(typeof(ToolboxBitmapAttribute), true); } ToolboxBitmapAttribute toolboxBitmapAttribute = (attribs != null && attribs.GetLength(0) > 0) ? attribs[0] as ToolboxBitmapAttribute : null; if (toolboxBitmapAttribute != null) { toolBoxImage = toolboxBitmapAttribute.GetImage(activityType); } } return(toolBoxImage); }
protected virtual void CreateDragFeedbackImages(IList <Activity> draggedActivities) { Bitmap draggedImage = null; if (draggedActivities.Count > 0) { Bitmap image = null; String description = String.Empty; if (draggedActivities.Count > 1) { image = DR.GetImage(DR.Activities) as Bitmap; description = DR.GetString(DR.ActivitiesDesc); } else { ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(draggedActivities[0].GetType())[typeof(ToolboxBitmapAttribute)]; image = toolboxBitmapAttribute.GetImage(draggedActivities[0].GetType()) as Bitmap; description = draggedActivities[0].GetType().Name; } if (image != null && description.Length > 0) { //Start creating a bitmap WorkflowView parentView = ParentView; Rectangle imageRectangle = (image != null) ? new Rectangle(Point.Empty, image.Size) : Rectangle.Empty; Rectangle descriptionRectangle = (description.Length > 0) ? new Rectangle(Point.Empty, new Size(AmbientTheme.DragImageTextSize.Width, parentView.Font.Height + 2)) : Rectangle.Empty; if (!imageRectangle.IsEmpty) { descriptionRectangle.Offset(imageRectangle.Width + AmbientTheme.DragImageMargins.Width, 0); } Size draggedImageSize = parentView.LogicalSizeToClient(new Size(imageRectangle.Width + descriptionRectangle.Width, Math.Max(imageRectangle.Height, descriptionRectangle.Height))); draggedImage = new Bitmap(draggedImageSize.Width, draggedImageSize.Height, PixelFormat.Format32bppArgb); using (Graphics draggedImageGraphics = Graphics.FromImage(draggedImage)) using (Brush backgroundBrush = new SolidBrush(Color.FromArgb(0, 255, 0, 255))) { draggedImageGraphics.ScaleTransform(ScaleZoomFactor, ScaleZoomFactor); draggedImageGraphics.FillRectangle(backgroundBrush, new Rectangle(0, 0, draggedImage.Width, draggedImage.Height)); if (image != null) { draggedImageGraphics.DrawImage(image, new Rectangle(Point.Empty, image.Size)); } if (description.Length > 0) { StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Near; stringFormat.Trimming = StringTrimming.EllipsisCharacter; stringFormat.LineAlignment = StringAlignment.Center; draggedImageGraphics.DrawString(description, parentView.Font, SystemBrushes.WindowText, descriptionRectangle, stringFormat); } } } } this.dragImage = draggedImage; }
protected virtual void CreateDragFeedbackImages(IList <Activity> draggedActivities) { Bitmap image = null; if (draggedActivities.Count > 0) { Bitmap bitmap2 = null; string s = string.Empty; if (draggedActivities.Count > 1) { bitmap2 = DR.GetImage("Activities") as Bitmap; s = DR.GetString("ActivitiesDesc", new object[0]); } else { ToolboxBitmapAttribute attribute = (ToolboxBitmapAttribute)TypeDescriptor.GetAttributes(draggedActivities[0].GetType())[typeof(ToolboxBitmapAttribute)]; bitmap2 = attribute.GetImage(draggedActivities[0].GetType()) as Bitmap; s = draggedActivities[0].GetType().Name; } if ((bitmap2 != null) && (s.Length > 0)) { WorkflowView parentView = base.ParentView; Rectangle rectangle = (bitmap2 != null) ? new Rectangle(Point.Empty, bitmap2.Size) : Rectangle.Empty; Rectangle layoutRectangle = (s.Length > 0) ? new Rectangle(Point.Empty, new Size(AmbientTheme.DragImageTextSize.Width, parentView.Font.Height + 2)) : Rectangle.Empty; if (!rectangle.IsEmpty) { layoutRectangle.Offset(rectangle.Width + AmbientTheme.DragImageMargins.Width, 0); } Size size = parentView.LogicalSizeToClient(new Size(rectangle.Width + layoutRectangle.Width, Math.Max(rectangle.Height, layoutRectangle.Height))); image = new Bitmap(size.Width, size.Height, PixelFormat.Format32bppArgb); using (Graphics graphics = Graphics.FromImage(image)) { using (Brush brush = new SolidBrush(Color.FromArgb(0, 0xff, 0, 0xff))) { graphics.ScaleTransform(this.ScaleZoomFactor, this.ScaleZoomFactor); graphics.FillRectangle(brush, new Rectangle(0, 0, image.Width, image.Height)); if (bitmap2 != null) { graphics.DrawImage(bitmap2, new Rectangle(Point.Empty, bitmap2.Size)); } if (s.Length > 0) { StringFormat format = new StringFormat { Alignment = StringAlignment.Near, Trimming = StringTrimming.EllipsisCharacter, LineAlignment = StringAlignment.Center }; graphics.DrawString(s, parentView.Font, SystemBrushes.WindowText, layoutRectangle, format); } } } } } this.dragImage = image; }
static Toolbox() { foreach (KeyValuePair <string, Type[]> keyValuePair in Toolbox.toolboxControls) { ToolboxItem value = new ToolboxItem(keyValuePair.Value[1]); Toolbox.toolboxItemDictionary.Add(keyValuePair.Key, value); ToolboxBitmapAttribute toolboxBitmapAttribute = TypeDescriptor.GetAttributes(keyValuePair.Value[0])[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; Bitmap bitmap = (Bitmap)toolboxBitmapAttribute.GetImage(keyValuePair.Value[0]); Icon icon = Icon.FromHandle(bitmap.GetHicon()); Toolbox.iconLibrary.Icons.Add(keyValuePair.Key, icon); } }
private void InitToolBox() { //- Add the toolboxItems to the future toolbox //- the pointer //ToolboxItem toolPointer = new System.Drawing.Design.ToolboxItem(); //toolPointer.DisplayName = $"<Pointer>"; //toolPointer.Bitmap = new System.Drawing.Bitmap(16, 16); //_ctrlToolBox.Items.Add(toolPointer); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(Button))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(CheckBox))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(ComboBox))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(ContextMenuStrip))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(DataGridView))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(GroupBox))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(ImageList))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(Label))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(LinkLabel))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(ListView))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(OpenFileDialog))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(Panel))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(PictureBox))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(ProgressBar))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(MenuStrip))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(RadioButton))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(StatusBar))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(TabControl))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(TextBox))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(Timer))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(ToolBar))); //_ctrlToolBox.Items.Add(new ToolboxItem(typeof(TreeView))); var pointer = new ToolboxItem(); pointer.DisplayName = "<Pointer>"; pointer.Bitmap = new Bitmap(16, 16); _ctrlToolBox.Items.Add(pointer); foreach (Type type in _windowsFormsToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } _ctrlToolBox.Items.Add(tbi); } //- init the (UDesigner)pDesignerCore _idesigner.CtrlToolbox = _ctrlToolBox; _ctrlToolBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.Toolbox_DrawItem); _ctrlToolBox.Invalidate(); }
private Image GetControlIcon(object control) { ToolboxBitmapAttribute attribute = TypeDescriptor.GetAttributes(control)[toolboxBitmapAttributeType] as ToolboxBitmapAttribute; if (attribute != null) { //img里取到的即是控件textBox1在工具箱中的图标 return(attribute.GetImage(control, true)); } return(null); }
private Image GetChartImage(Type chartType) { AttributeCollection attrCol = TypeDescriptor.GetAttributes(chartType); ToolboxBitmapAttribute imageAttr = (ToolboxBitmapAttribute)attrCol[typeof(ToolboxBitmapAttribute)]; if (imageAttr != null) { return(imageAttr.GetImage(chartType.GetType(), false));//false - 16x16, true - 32x32 } return(new Bitmap(16, 16)); }
private void InitializePanelControls() { this._selectLabel.Text = System.Design.SR.GetString("CreateDataSource_SelectType"); this._idLabel.Text = System.Design.SR.GetString("CreateDataSource_ID"); base.OKButton.Enabled = false; this.Text = System.Design.SR.GetString("CreateDataSource_Title"); this._descriptionBox.Text = System.Design.SR.GetString("CreateDataSource_SelectTypeDesc"); base.AccessibleDescription = System.Design.SR.GetString("CreateDataSource_Description"); base.CaptionLabel.Text = System.Design.SR.GetString("CreateDataSource_Caption"); this.UpdateFonts(); ISite site = this.GetSite(); if (site != null) { IComponentDiscoveryService service = (IComponentDiscoveryService)site.GetService(typeof(IComponentDiscoveryService)); IDesignerHost designerHost = (IDesignerHost)site.GetService(typeof(IDesignerHost)); if (service != null) { ICollection componentTypes = service.GetComponentTypes(designerHost, this._dataSourceType); if (componentTypes != null) { ImageList list = new ImageList { ColorDepth = ColorDepth.Depth32Bit }; System.Type[] array = new System.Type[componentTypes.Count]; componentTypes.CopyTo(array, 0); foreach (System.Type type in array) { System.ComponentModel.AttributeCollection attributes = TypeDescriptor.GetAttributes(type); Bitmap image = null; if (attributes != null) { ToolboxBitmapAttribute attribute = attributes[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if ((attribute != null) && !attribute.Equals(ToolboxBitmapAttribute.Default)) { image = attribute.GetImage(type, true) as Bitmap; } } if (image == null) { image = new Bitmap(base.GetType(), "CustomDataSource.bmp"); } list.ImageSize = new Size(0x20, 0x20); list.Images.Add(type.FullName, image); this._dataSourceTypesListView.Items.Add(new DataSourceListViewItem(type)); } this._dataSourceTypesListView.Sort(); this._dataSourceTypesListView.LargeImageList = list; } } } }
private Image GetBitmapFromComponent(Type type) { Image bmp = ToolboxBitmapAttribute.GetImageFromResource(type, null, false) as Bitmap; if (bmp != null) { return(bmp); } else { return(ToolboxBitmapAttribute.Default.GetImage(type)); } }
// only call this for well known items. private static Bitmap GetKnownToolboxBitmap(Type itemType) { if (s_cachedWinformsImages == null) { s_cachedWinformsImages = new Dictionary <Type, Bitmap>(); } if (!s_cachedWinformsImages.ContainsKey(itemType)) { Bitmap knownImage = ToolboxBitmapAttribute.GetImageFromResource(itemType, null, false) as Bitmap; s_cachedWinformsImages[itemType] = knownImage; return(knownImage); } return(s_cachedWinformsImages[itemType]); }
public void GetImage_Default_ReturnsExpected() { ToolboxBitmapAttribute attribute = ToolboxBitmapAttribute.Default; using (Image image = attribute.GetImage(typeof(ToolboxBitmapAttributeTests), "bitmap_173x183_indexed_8bit", large: true)) { Assert.Equal(new Size(32, 32), image.Size); } using (Image image = attribute.GetImage(typeof(ToolboxBitmapAttributeTests), "bitmap_173x183_indexed_8bit", large: false)) { Assert.Equal(new Size(173, 183), image.Size); } }
private static Bitmap GetKnownToolboxBitmap(System.Type itemType) { if (CachedWinformsImages == null) { CachedWinformsImages = new Dictionary <System.Type, Bitmap>(); } if (!CachedWinformsImages.ContainsKey(itemType)) { Bitmap bitmap = ToolboxBitmapAttribute.GetImageFromResource(itemType, null, false) as Bitmap; CachedWinformsImages[itemType] = bitmap; return(bitmap); } return(CachedWinformsImages[itemType]); }
// Determine if two objects are equal. public override bool Equals(Object obj) { ToolboxBitmapAttribute other = (obj as ToolboxBitmapAttribute); if (other != null) { return(imageFile == other.imageFile && t == other.t && name == other.name); } else { return(false); } }
public void GetImage_Component_ReturnsExpected() { ToolboxBitmapAttribute attribute = new ToolboxBitmapAttribute((string)null); using (Image smallImage = attribute.GetImage(new bitmap_173x183_indexed_8bit(), large: false)) { Assert.Equal(new Size(173, 183), smallImage.Size); using (Image largeImage = attribute.GetImage(new bitmap_173x183_indexed_8bit(), large: true)) { Assert.Equal(new Size(32, 32), largeImage.Size); } } }
public void GetImage_TypeFileNameBool_ReturnsExpected(string fileName, int width, int height) { var attribute = new ToolboxBitmapAttribute((string)null); using (Image image = attribute.GetImage(typeof(ToolboxBitmapAttributeTests), fileName, large: true)) { Assert.Equal(new Size(32, 32), image.Size); } using (Image image = attribute.GetImage(typeof(ToolboxBitmapAttributeTests), fileName, large: false)) { Assert.Equal(new Size(width, height), image.Size); } }
// <snippet4> private Image GetImageOfCustomControl(Control userControl) { Image controlImage = null; AttributeCollection attrCol = TypeDescriptor.GetAttributes(userControl); ToolboxBitmapAttribute imageAttr = (ToolboxBitmapAttribute) attrCol[typeof(ToolboxBitmapAttribute)]; if (imageAttr != null) { controlImage = imageAttr.GetImage(userControl); } return(controlImage); }
// Fill our ListBoxes with the appropriate ToolboxItems. private void FillToolbox() { foreach (ListBarGroup tab in listBar1.Groups) { tab.Items.Add(pointerItem); } foreach (List <ToolboxItem> t in listAll) { t.Add(pointer); } foreach (Type type in windowsFormsToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } listWindowsForms_ti.Add(tbi); AddBarItem(listWindowsForms, tbi); } foreach (Type type in componentsToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } listComponents_ti.Add(tbi); AddBarItem(listComponents, tbi); } foreach (Type type in dataToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } listData_ti.Add(tbi); AddBarItem(listData, tbi); } }
public void Ctor_Type_String(Type type, string fileName, int width, int height) { var attribute = new ToolboxBitmapAttribute(type, fileName); using (Image image = attribute.GetImage(type, fileName, false)) { if (width == -1 && height == -1) { Assert.Throws <ArgumentException>(null, () => image.Size); } else { Assert.Equal(new Size(width, height), image.Size); } } }
public void Ctor_FileName(string fileName, Size size) { var attribute = new ToolboxBitmapAttribute(fileName); using (Image image = attribute.GetImage(null)) { if (size == Size.Empty) { Assert.Throws <ArgumentException>(null, () => image.Size); } else { Assert.Equal(size, image.Size); } } }
public void Ctor_FileName(string fileName, Size size) { var attribute = new ToolboxBitmapAttribute(fileName); using (Image image = attribute.GetImage(null)) { if (size == Size.Empty) { AssertDefaultSize(image); } else { Assert.Equal(size, image.Size); } } }
public void Ctor_Type(Type type, int width, int height) { var attribute = new ToolboxBitmapAttribute(type); using (Image image = attribute.GetImage(type)) { if (width == -1 && height == -1) { AssertDefaultSize(image); } else { Assert.Equal(new Size(width, height), image.Size); } } }
private void FillToolbox() { this.listWindowsForms.Items.Add(this.pointer); foreach (System.Type type in this.windowsFormsToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba == null) { } this.listWindowsForms.Items.Add(tbi); } this.listWindowsForms.DrawItem += new DrawItemEventHandler(this.list_DrawItem); this.listWindowsForms.KeyDown += new KeyEventHandler(this.list_KeyDown); this.listWindowsForms.MeasureItem += new MeasureItemEventHandler(this.list_MeasureItem); this.listWindowsForms.MouseDown += new MouseEventHandler(this.list_MouseDown); }
public Class1() { List <string> res = new List <string>(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()); res.ForEach(r => { Debug.WriteLine(r); }); Debug.WriteLine(System.IO.Path.GetExtension("Res.BMP.BitmapPreview.bmp")); ToolboxBitmapAttribute tb = new ToolboxBitmapAttribute(typeof(MainWindow), "Res.BMP.BitmapPreview.bmp"); //var smallImage = typeof(ToolboxBitmapAttribute).GetField("smallImage",BindingFlags.NonPublic|BindingFlags.Instance); var fields = typeof(ToolboxBitmapAttribute).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); fields.ToList().ForEach(f => { Debug.WriteLine(f.Name); }); var smallImage = typeof(ToolboxBitmapAttribute).GetField("smallImage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); Image img = (Image)smallImage.GetValue(tb); }
public Image GetIcon() { try { Type connType = ConnectionType; if (connType == null) { return(null); } Image img = ToolboxBitmapAttribute.GetImageFromResource(ConnectionType, null, true); return(img); } catch (Exception) { return(null); } }
public bool Execute(object source, object target) { var FolderView = (IFolderView)GetService(typeof(IFolderView)); string CurrentFolderLocalPath = GetFolderLocalPath(FolderView.CurrentFolder); CommandProcessorController Controller = new CmdPromptTabController(); if (Controller.Start(CurrentFolderLocalPath)) { var TabManager = (ITabManager)GetService(typeof(ITabManager)); ITab Tab = TabManager.AddNewTab(Controller.OutputBox, "Command Processor"); Tab.Image = ToolboxBitmapAttribute.GetImageFromResource(typeof(NewCmdPromptTabCommand), "application_xp_terminal.png", false); Tab.Select(); return(true); } return(false); }
/// <summary> /// paint the listbox items /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ItemsListBox_DrawItem(object sender, DrawItemEventArgs e) { ListBox listbox = sender as ListBox; if (e.Index == -1) { return; } Rectangle rect = new Rectangle(e.Bounds.X, e.Bounds.Y, Width, e.Bounds.Height); Brush b = brush; // If this item is the currently selected item, draw it with a highlight. if (listbox.SelectedIndex == e.Index) { b = Brushes.Moccasin; } e.Graphics.FillRectangle(b, rect); Control control = listbox.Items[e.Index] as Control; Control controlForBitmap = control is DotNetComponentWrapper ? ((DotNetComponentWrapper)control).WrappedControl : control; // get the bitmap ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(controlForBitmap)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; Bitmap bitmap = (Bitmap)tba.GetImage(controlForBitmap); Rectangle bitmapBounds = new Rectangle(rect.Location.X + 20, rect.Location.Y + 2, 16, 16); Rectangle stringBounds = new Rectangle(rect.Location.X + bitmapBounds.Width + 25, rect.Location.Y, 145, rect.Height); StringFormat format = new StringFormat(); format.LineAlignment = StringAlignment.Center; format.Alignment = StringAlignment.Near; format.FormatFlags = StringFormatFlags.NoWrap; format.Trimming = StringTrimming.EllipsisCharacter; e.Graphics.DrawImage(bitmap, bitmapBounds); e.Graphics.DrawString((string)((ControlDesignerInfo)control.Tag).Properties[Constants.WinPropName].Value, font, Brushes.Black, stringBounds, format); }
// Fill our ListBoxes with the appropriate ToolboxItems. private void FillToolbox() { foreach (TabPage tab in tabControl.TabPages) { ListBox list = tab.Controls[0] as ListBox; list.Items.Add(pointer); } foreach (Type type in etoFormsToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } listEtoForms.Items.Add(tbi); } foreach (Type type in componentsToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } listComponents.Items.Add(tbi); } foreach (Type type in dataToolTypes) { ToolboxItem tbi = new ToolboxItem(type); ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(ToolboxBitmapAttribute)] as ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (Bitmap)tba.GetImage(type); } listData.Items.Add(tbi); } }
public override void Initialize(IComponent component) { this.toolStripContainer = (ToolStripContainer) component; base.Initialize(component); base.AutoResizeHandles = true; this.topToolStripPanel = this.toolStripContainer.TopToolStripPanel; this.bottomToolStripPanel = this.toolStripContainer.BottomToolStripPanel; this.leftToolStripPanel = this.toolStripContainer.LeftToolStripPanel; this.rightToolStripPanel = this.toolStripContainer.RightToolStripPanel; this.contentToolStripPanel = this.toolStripContainer.ContentPanel; this.panels = new Control[] { this.contentToolStripPanel, this.leftToolStripPanel, this.rightToolStripPanel, this.topToolStripPanel, this.bottomToolStripPanel }; ToolboxBitmapAttribute attribute = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_BottomToolStripPanel.bmp"); ToolboxBitmapAttribute attribute2 = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_RightToolStripPanel.bmp"); ToolboxBitmapAttribute attribute3 = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_TopToolStripPanel.bmp"); ToolboxBitmapAttribute attribute4 = new ToolboxBitmapAttribute(typeof(ToolStripPanel), "ToolStripContainer_LeftToolStripPanel.bmp"); TypeDescriptor.AddAttributes(this.bottomToolStripPanel, new Attribute[] { attribute, new DescriptionAttribute("bottom") }); TypeDescriptor.AddAttributes(this.rightToolStripPanel, new Attribute[] { attribute2, new DescriptionAttribute("right") }); TypeDescriptor.AddAttributes(this.leftToolStripPanel, new Attribute[] { attribute4, new DescriptionAttribute("left") }); TypeDescriptor.AddAttributes(this.topToolStripPanel, new Attribute[] { attribute3, new DescriptionAttribute("top") }); base.EnableDesignMode(this.topToolStripPanel, "TopToolStripPanel"); base.EnableDesignMode(this.bottomToolStripPanel, "BottomToolStripPanel"); base.EnableDesignMode(this.leftToolStripPanel, "LeftToolStripPanel"); base.EnableDesignMode(this.rightToolStripPanel, "RightToolStripPanel"); base.EnableDesignMode(this.contentToolStripPanel, "ContentPanel"); this.designerHost = (IDesignerHost) this.GetService(typeof(IDesignerHost)); if (this.selectionSvc == null) { this.selectionSvc = (ISelectionService) this.GetService(typeof(ISelectionService)); } if (this.topToolStripPanel != null) { (this.designerHost.GetDesigner(this.topToolStripPanel) as ToolStripPanelDesigner).ExpandTopPanel(); } this.TopToolStripPanelVisible = this.toolStripContainer.TopToolStripPanelVisible; this.LeftToolStripPanelVisible = this.toolStripContainer.LeftToolStripPanelVisible; this.RightToolStripPanelVisible = this.toolStripContainer.RightToolStripPanelVisible; this.BottomToolStripPanelVisible = this.toolStripContainer.BottomToolStripPanelVisible; }
static ToolboxBitmapAttribute() { //Fix for Dev10 560430. When we call Gdip.DummyFunction, JIT will make sure Gdip..cctor will be called before SafeNativeMethods.Gdip.DummyFunction(); Bitmap bitmap = null; Stream stream = BitmapSelector.GetResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp"); if (stream != null) { bitmap = new Bitmap(stream); MakeBackgroundAlphaZero(bitmap); } DefaultComponent = new ToolboxBitmapAttribute(bitmap, null); }