public EventCommandGroup(System.Xml.XmlNode node, EventCommandProvider provider)
        {
            Commands = new Dictionary<string, EventCommand>();
            Provider = provider;
            ID = node.Attributes["ID"].Value;
            Name = node.Attributes["Name"].Value;
            ForeColor = (node.Attributes["ForeColor"] != null) ?
                Core.DrawingHelper.ParseColor(node.Attributes["ForeColor"].Value) :
                System.Drawing.SystemColors.WindowText;

            foreach (System.Xml.XmlNode cmd in node.ChildNodes)
            {
                if (cmd.Name != "EventCommand") continue;

                EventCommand item = new EventCommand(cmd, this);

                this.Commands.Add(item.ID, item);
            }
        }
Beispiel #2
0
        public EventCommandGroup(System.Xml.XmlNode node, EventCommandProvider provider)
        {
            Commands  = new Dictionary <string, EventCommand>();
            Provider  = provider;
            ID        = node.Attributes["ID"].Value;
            Name      = node.Attributes["Name"].Value;
            ForeColor = (node.Attributes["ForeColor"] != null) ?
                        Core.DrawingHelper.ParseColor(node.Attributes["ForeColor"].Value) :
                        System.Drawing.SystemColors.WindowText;

            foreach (System.Xml.XmlNode cmd in node.ChildNodes)
            {
                if (cmd.Name != "EventCommand")
                {
                    continue;
                }

                EventCommand item = new EventCommand(cmd, this);

                this.Commands.Add(item.ID, item);
            }
        }
            protected override void DrawText(int id, string str, System.Drawing.Font font, System.Drawing.Brush fc, System.Drawing.Rectangle bounds, System.Drawing.StringFormat sf, System.Drawing.Graphics g, bool selected)
            {
                float fix = g.MeasureString("傻", font).Width * 2 - g.MeasureString("傻逼", font).Width;
                int   indentw = (int)(g.MeasureString(strCommand, font).Width - fix);
                int   indent = GetIndent(id);
                int   x, height, y;

                x      = bounds.X; y = bounds.Y;
                height = bounds.Height;
                EventCommand cmd = GetCodeCommand(id);

                x += indent * indentw + indentw;
                if (cmd != null && cmd.IsGenerated)
                {
                    int iw = (int)(g.MeasureString(strIndent, font).Width - fix);
                    g.DrawString(strIndent, font, fc, new System.Drawing.Rectangle(x - iw, y, bounds.Right - x + iw, height));
                }
                else
                {
                    g.DrawString(strCommand, font, fc, new System.Drawing.Rectangle(x - indentw, y, bounds.Right - x + indentw, height));
                }

                if (GetCode(id) == "0")
                {
                    return;
                }

                if (cmd != null && !selected)
                {
                    fc = new System.Drawing.SolidBrush(cmd.Group.ForeColor);
                }

                string drawing;

                if (cmd == null)
                {
                    drawing = strUnknown;
                }
                else
                {
                    drawing = cmd.FormatParams(this.Items[id] as RubyObject);
                }

                string draw;

                while (drawing.Length > 0)
                {
                    int pos = drawing.IndexOf("{hide}");
                    if (pos > 0)
                    {
                        draw    = drawing.Substring(0, pos);
                        drawing = drawing.Substring(pos);
                        g.DrawString(draw, font, fc, new System.Drawing.Rectangle(x, y, bounds.Right - x, height), sf);
                        x += (int)(g.MeasureString(draw, font).Width - fix);
                    }
                    else if (pos == 0)
                    {
                        pos     = drawing.IndexOf("{/hide}");
                        draw    = drawing.Substring(6, pos - 6);
                        drawing = drawing.Substring(pos + 7);
                        x      += (int)(g.MeasureString(draw, font).Width - fix);
                    }
                    else
                    {
                        g.DrawString(drawing, font, fc, new System.Drawing.Rectangle(x, y, bounds.Right - x, height), sf);
                        drawing = "";
                    }
                }
            }