Esempio n. 1
0
        public IStyleGroup CreateStyleGroup(string name, IStyle parentStyle, bool forEdge)
        {
            var styleGroup = new StyleGroup(name, parentStyle);

            var defaultStyle = new Style(name + ".Default", styleGroup);

            styleGroup.DefaultStyle   = defaultStyle;
            styles[defaultStyle.Name] = defaultStyle;

            var selectedStyle = new Style(name + ".Selected", styleGroup);

            styleGroup.SelectedStyle   = selectedStyle;
            styles[selectedStyle.Name] = selectedStyle;

            var hoveredStyle = new Style(name + ".Hovered", styleGroup);

            styleGroup.HoveredStyle   = hoveredStyle;
            styles[hoveredStyle.Name] = hoveredStyle;

            if (!forEdge)
            {
                selectedStyle.FillColor = DrawingExtensions.FromArgb(200, this.ParentStyle.FillColor);
                hoveredStyle.FillColor  = DrawingExtensions.FromArgb(200, this.ParentStyle.FillColor);
            }
            else
            {
                defaultStyle.PaintData = false;

                defaultStyle.Font = CreateFont(
                    this.ParentStyle.Font.Family,
                    this.ParentStyle.Font.Size - 2).WithStyle(FontStyle.Italic);

                selectedStyle.LineWidth = styleGroup.DefaultStyle.LineWidth * 2;
                selectedStyle.PaintData = true;

                hoveredStyle.StrokeColor = DrawingExtensions.FromArgb(150, styleGroup.DefaultStyle.StrokeColor);
                hoveredStyle.PaintData   = true;
            }

            return(styleGroup);
        }
Esempio n. 2
0
        public virtual void CopyTo(IStyleSheet other)
        {
            base.CopyTo(other);
            other.BackColor = this.BackColor;

            other.ParentStyle = MakeCopy(this.ParentStyle, null);
            other.BaseStyle   = MakeCopy(this.BaseStyle, other.ParentStyle);

            Func <IStyleGroup, IStyleGroup> makeCopy = (source) => {
                IStyleGroup sink = null;
                if (source != null)
                {
                    sink = new StyleGroup(source.Name, other.BaseStyle);
                    source.CopyTo(sink);
                }
                return(sink);
            };

            other.ItemStyle = makeCopy(this.ItemStyle);
            other.EdgeStyle = makeCopy(this.EdgeStyle);
        }