コード例 #1
0
        internal static void DefaultPrepareFillDraw(FillStyleC fillStyle, DrawResources resources, bool hasText)
        {
            // note ONLY does this level - also need to call MyBase.PrepareDraw or similar
            Color colour = fillStyle.Colour;

            if (resources.FillAlpha != 255)
            {
                colour = Color.FromArgb(resources.FillAlpha * fillStyle.Colour.A / 256, fillStyle.Colour);
            }
            switch (fillStyle.Pattern)
            {
            case FillStyleC.Patterns.Solid:
                resources.MainBrush = resources.Graphics.CreateFill(colour);
                break;

            case FillStyleC.Patterns.Empty:
                resources.MainBrush = null;
                break;

            case FillStyleC.Patterns.Texture:
                if (resources.FillAlpha >= 128 || hasText == false)
                {
                    // note: textures not drawn if v transparent (cos can't draw them transparent at all) and has text
                    // this means they don't draw in the selection layer for example
                    resources.MainBrush = resources.Graphics.CreateTextureBrush(fillStyle.Texture, Geometry.INCH / 92);
                }
                break;

            default:
                resources.MainBrush = resources.Graphics.CreateHatchBrush(colour, Color.Empty, fillStyle.Pattern);
                break;
            }
        }
コード例 #2
0
        public override void CopyFrom(Datum other, CopyDepth depth, Mapping mapID)
        {
            base.CopyFrom(other, depth, mapID);
            Filled filled = (Filled)other;

            if (depth >= CopyDepth.Undo)
            {
                if (FillStyle == null || FillStyle == filled.FillStyle)
                {
                    FillStyle = new FillStyleC();
                }
                FillStyle.CopyFrom(filled.FillStyle);
            }
            else
            {
                if (FillStyle == null)
                {
                    FillStyle = filled.FillStyle;
                }
            }
        }
コード例 #3
0
ファイル: Scriptable.cs プロジェクト: stuart2w/SAW
            /// <summary>Writes the styles from this object into the normal (non-highlight) styles in the shape</summary>
            public void ApplyToShape(Shape shape)
            {
                FillStyleC fill = (FillStyleC)shape.StyleObjectForParameter(Parameters.FillColour);

                if (fill != null)
                {
                    fill.Colour = FillColour;
                }
                LineStyleC line = (LineStyleC)shape.StyleObjectForParameter(Parameters.LineColour);

                if (line != null)
                {
                    line.Colour = LineColour;
                    line.Width  = LineWidth * 2 - 1;
                }
                TextStyleC text = (TextStyleC)shape.StyleObjectForParameter(Parameters.TextColour);

                if (text != null)
                {
                    text.Colour = TextColour;
                }
            }
コード例 #4
0
ファイル: Scriptable.cs プロジェクト: stuart2w/SAW
            /// <summary>Creates an instance initialised with the current (non-highlight) styles stored in a shape</summary>
            public static HighlightStyleC FromShape(Shape shape)
            {
                var        highlight = new HighlightStyleC();
                FillStyleC fill      = (FillStyleC)shape.StyleObjectForParameter(Parameters.FillColour);

                if (fill != null)
                {
                    highlight.FillColour = fill.Colour;
                }
                LineStyleC line = (LineStyleC)shape.StyleObjectForParameter(Parameters.LineColour);

                if (line != null)
                {
                    highlight.LineColour = line.Colour;
                    highlight.LineWidth  = (line.Width + 1) / 2;
                }
                TextStyleC text = (TextStyleC)shape.StyleObjectForParameter(Parameters.TextColour);

                if (text != null)
                {
                    highlight.TextColour = text.Colour;
                }
                return(highlight);
            }
コード例 #5
0
 public override void Load(DataReader reader)
 {
     base.Load(reader);
     FillStyle = FillStyleC.Read(reader);
 }
コード例 #6
0
        // base class for any shape which can be filled with a colour

        protected Filled()
        {
            FillStyle = new FillStyleC();
        }