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);
        }
Пример #2
0
        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();
        }
Пример #4
0
 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();
 }
        public Image GetImage(Type type, string imgName, bool large)
        {
            if ((large && (this.largeImage == null)) || (!large && (this.smallImage == null)))
            {
                Point point      = new Point(0x20, 0x20);
                Image largeImage = null;
                if (large)
                {
                    largeImage = this.largeImage;
                }
                else
                {
                    largeImage = this.smallImage;
                }
                if (largeImage == null)
                {
                    largeImage = GetImageFromResource(type, imgName, large);
                }
                if ((large && (this.largeImage == null)) && (this.smallImage != null))
                {
                    largeImage = new Bitmap((Bitmap)this.smallImage, point.X, point.Y);
                }
                Bitmap img = largeImage as Bitmap;
                if (img != null)
                {
                    MakeBackgroundAlphaZero(img);
                }
                if (largeImage == null)
                {
                    largeImage = DefaultComponent.GetImage(type, large);
                }
                if (large)
                {
                    this.largeImage = largeImage;
                }
                else
                {
                    this.smallImage = largeImage;
                }
            }
            Image image2 = large ? this.largeImage : this.smallImage;

            if (this.Equals(Default))
            {
                this.largeImage = null;
                this.smallImage = null;
            }
            return(image2);
        }
Пример #7
0
        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);
        }
Пример #8
0
 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));
                }
            }
        }