private iconLabel createIcon(Type type) { Bitmap bmp = null; iconLabel icon = new iconLabel(); icon.Text = ""; icon.Tag = type; icon.ImageAlign = ContentAlignment.MiddleCenter; System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { bmp = (System.Drawing.Bitmap)tba.GetImage(type); } if (bmp != null) { icon.Image = bmp; } else { icon.Text = type.Name; } icon.Size = new Size(22, 22); icon.Click += new EventHandler(TypeIcons_Click); return(icon); }
private void UpdateToolboxItems(int tabIndex) { Toolbox.ToolsListBox.Items.Clear(); Toolbox.ToolsListBox.Items.Add(pointer); if (Toolbox.Tabs.Count <= 0) { return; } ToolboxTab toolboxTab = Toolbox.Tabs[tabIndex]; ToolboxItemCollection toolboxItems = toolboxTab.ToolboxItems; foreach (ToolboxItem toolboxItem in toolboxItems) { Type type = toolboxItem.Type; System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(type); System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (System.Drawing.Bitmap)tba.GetImage(type); } Toolbox.ToolsListBox.Items.Add(tbi); } }
public ReturnIcon(RaisDataType dataType) { Location = new Point(300, 300); SaveLocation(); this.Size = new Size(32, 32); System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(this.GetType())[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { bmp = (System.Drawing.Bitmap)tba.GetImage(this.GetType()); } MathNodeRoot root = new MathNodeRoot(); root.IsVariableHolder = true; var = new MathNodeVariableDummy(root); root[0] = var; if (dataType != null) { var.VariableType = dataType; var.TypeDefined = true; } LinkLineNodeInPort port = new LinkLineNodeInPort(var); port.ClearLine(); port.SetPrevious(null); port.Owner = this; port.HideLabel(); var.InPort = port; port.Owner = this; port.Label.Visible = false; port.Location = new Point(this.Left + this.Width / 2 - port.Width / 2, this.Top - port.Height); port.SaveLocation(); }
public xToolboxItem(Type t) : base(t) { m_type = t; if (t != null) { System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(t)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { Bitmap = (System.Drawing.Bitmap)tba.GetImage(t); } } else { DisplayName = " Pointer"; System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(typeof(xToolboxItem))[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { Bitmap = (System.Drawing.Bitmap)tba.GetImage(typeof(xToolboxItem)); } else { Bitmap = new System.Drawing.Bitmap(16, 16); } } }
private void DrawToolBoxItem() { if (this.ToolboxItems == null) { return; } if (this.ToolboxItems.Count == 0) { return; } this.SuspendLayout(); for (int i = this.ToolboxItems.Count - 1; i >= 0; i--) { Type type = this.ToolboxItems[i].Type; System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(type); System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { tbi.Bitmap = (System.Drawing.Bitmap)tba.GetImage(type); } DrawToolBoxItem(tbi, this.ToolboxItems[i].Name); } this.ResumeLayout(); }
static ToolboxBitmapAttribute() { SafeNativeMethods.Gdip.DummyFunction(); Bitmap img = null; Stream manifestResourceStream = typeof(ToolboxBitmapAttribute).Module.Assembly.GetManifestResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp"); if (manifestResourceStream != null) { img = new Bitmap(manifestResourceStream); MakeBackgroundAlphaZero(img); } DefaultComponent = new ToolboxBitmapAttribute(img, null); }
static ToolboxBitmapAttribute() { Bitmap bitmap = null; Stream stream = typeof(ToolboxBitmapAttribute).Module.Assembly.GetManifestResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp"); if (stream != null) { bitmap = new Bitmap(stream); MakeBackgroundAlphaZero(bitmap); } DefaultComponent = new ToolboxBitmapAttribute(bitmap, null); }
private static void CreateToolboxBitmapAttributeForActivity(AttributeTableBuilder builder, System.Resources.ResourceReader resourceReader, Type builtInActivityType) { System.Drawing.Bitmap bitmap = ExtractBitmapResource(resourceReader, builtInActivityType.IsGenericType ? builtInActivityType.Name.Split('`')[0] : builtInActivityType.Name); if (bitmap != null) { bitmap.Save(@"C:\temp\icons\Archive\" + builtInActivityType.Name + ".png", System.Drawing.Imaging.ImageFormat.Png); Type tbaType = typeof(System.Drawing.ToolboxBitmapAttribute); Type imageType = typeof(System.Drawing.Image); ConstructorInfo constructor = tbaType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { imageType, imageType }, null); System.Drawing.ToolboxBitmapAttribute tba = constructor.Invoke(new object[] { bitmap, bitmap }) as System.Drawing.ToolboxBitmapAttribute; builder.AddCustomAttributes(builtInActivityType, tba); } }
static ToolboxBitmapAttribute() { SafeNativeMethods.Gdip.DummyFunction(); Bitmap img = null; Stream manifestResourceStream = typeof(ToolboxBitmapAttribute).Module.Assembly.GetManifestResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp"); if (manifestResourceStream != null) { img = new Bitmap(manifestResourceStream); MakeBackgroundAlphaZero(img); } DefaultComponent = new ToolboxBitmapAttribute(img, null); }
static ToolboxBitmapAttribute() { // When we call Gdip.DummyFunction, JIT will make sure Gdip..cctor will be called. SafeNativeMethods.Gdip.DummyFunction(); Stream stream = BitmapSelector.GetResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp"); Debug.Assert(stream != null, "DefaultComponent.bmp must be present as an embedded resource."); var bitmap = new Bitmap(stream); MakeBackgroundAlphaZero(bitmap); s_defaultComponent = new ToolboxBitmapAttribute(bitmap, null); }
public override bool Equals(object value) { if (value == this) { return(true); } ToolboxBitmapAttribute attribute = value as ToolboxBitmapAttribute; if (attribute == null) { return(false); } return((attribute.smallImage == this.smallImage) && (attribute.largeImage == this.largeImage)); }
private void AddToolBox(Type type, Type TypeBmp, string DisplayName) { ToolboxItem toolboxItem = new ToolboxItem(type); toolboxItem.DisplayName = DisplayName; System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(TypeBmp)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; Bitmap bmp = (System.Drawing.Bitmap)tba.GetImage(TypeBmp); toolboxItem.Bitmap = bmp; this.Items.Add(toolboxItem); }
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); }
static ToolboxBitmapAttribute() { // Ensure Gdip type initializer has run. SafeNativeMethods.Gdip.DummyFunction(); Bitmap bitmap = null; Stream stream = BitmapSelector.GetResourceStream(typeof(ToolboxBitmapAttribute), "DefaultComponent.bmp"); if (stream != null) { bitmap = new Bitmap(stream); MakeBackgroundAlphaZero(bitmap); } s_defaultComponent = new ToolboxBitmapAttribute(bitmap, null); }
/// <include file='doc\ToolboxBitmapAttribute.uex' path='docs/doc[@for="ToolboxBitmapAttribute.Equals"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override bool Equals(object value) { if (value == this) { return(true); } ToolboxBitmapAttribute attr = value as ToolboxBitmapAttribute; if (attr != null) { return(attr.smallImage == smallImage && attr.largeImage == largeImage); } return(false); }
public xToolboxItem(Type t, Bitmap bmp) : base(t) { m_type = t; if (bmp != null) { Bitmap = bmp; } else { System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(t)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; if (tba != null) { Bitmap = (System.Drawing.Bitmap)tba.GetImage(t); } } }
public override void OnDraw(System.Drawing.Graphics g) { Type t = typeof(LogicValueEquality); System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(t)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute; Bitmap bmp = (System.Drawing.Bitmap)tba.GetImage(t); float enclosureWidth = 0; float enclosureHeight = 0; float yParenthesis = 0; SizeF size1 = this[0].CalculateDrawSize(g); SizeF size2 = this[1].CalculateDrawSize(g); float h = size1.Height; if (h < size2.Height) { h = size2.Height; } SizeF size3 = new SizeF(h, h); bool useParenthesis = (this.Rank() < this.Parent.Rank()); if (useParenthesis) { SizeF size4 = g.MeasureString("(", ftParenthesis); enclosureWidth = size4.Width; enclosureHeight = size4.Height; } float w = size1.Width + size2.Width + size3.Width + enclosureWidth + enclosureWidth; if (IsFocused) { g.FillRectangle(this.TextBrushBKFocus0, new Rectangle(0, 0, (int)w, (int)h)); } float y = 0; if (size1.Height < h) { y = (h - size1.Height) / (float)2; } float x = size1.Width + size3.Width + enclosureWidth; if (useParenthesis) { if (enclosureHeight < h) { yParenthesis = (h - enclosureHeight) / (float)2; } if (IsFocused) { g.DrawString("(", ftParenthesis, this.TextBrushFocus, new PointF(0, yParenthesis)); } else { g.DrawString("(", ftParenthesis, this.TextBrush, new PointF(0, yParenthesis)); } } // System.Drawing.Drawing2D.GraphicsState gt = g.Save(); g.TranslateTransform(enclosureWidth, y); this[0].Position = new Point(this.Position.X + (int)enclosureWidth, Position.Y + (int)y); this[0].Draw(g); g.Restore(gt); y = 0; if (size3.Height < h) { y = (h - size3.Height) / (float)2; } //draw operator gt = g.Save(); g.TranslateTransform(size1.Width + enclosureWidth, y); g.DrawImage(bmp, new RectangleF(0, 0, size3.Width, size3.Height)); g.Restore(gt); // y = 0; if (size2.Height < h) { y = (h - size2.Height) / (float)2; } gt = g.Save(); g.TranslateTransform(x, y); this[1].Position = new Point(Position.X + (int)x, (int)y + Position.Y); this[1].Draw(g); g.Restore(gt); // if (useParenthesis) { if (IsFocused) { g.DrawString(")", ftParenthesis, this.TextBrushFocus, new PointF(x + size2.Width, yParenthesis)); } else { g.DrawString(")", ftParenthesis, this.TextBrush, new PointF(x + size2.Width, yParenthesis)); } } }