Пример #1
0
 protected abstract void DrawRectangleInternal(Pen pen, double x, double y, double width, double height);
Пример #2
0
 public void DrawRectangle(Pen pen, Rectangle rect)
 {
     DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
 }
Пример #3
0
 protected abstract void DrawLineInternal(Pen pen, double x1, double y1, double x2, double y2);
Пример #4
0
 public void DrawRectangle(Pen pen, double x, double y, double width, double height)
 {
     DrawRectangleInternal(pen, x, y, width, height);
 }
Пример #5
0
 private Pen PenFromOutline(Outline outline)
 {
     if (outline is SolidOutline)
     {
         Pen pen = new Pen(Color.FromString((outline as SolidOutline).Color), new Measurement(outline.Width, MeasurementUnit.Pixel));
         return pen;
     }
     else
     {
         Console.WriteLine("uwt-theme: PenFromOutline: outline used to create pen must be SolidOutline");
         return Pens.Black;
     }
 }
Пример #6
0
 public void DrawLine(Pen pen, double x1, double y1, double x2, double y2)
 {
     DrawLineInternal(pen, x1, y1, x2, y2);
 }
Пример #7
0
        private void DrawRenderingAction(RenderingAction action, Control component, Dictionary<string, object> variables)
        {
            if (variables == null) variables = new Dictionary<string, object>();
            Dictionary<string, object> dict = new Dictionary<string, object>();

            foreach (KeyValuePair<string, object> kvp in variables)
            {
                dict.Add(kvp.Key, kvp.Value);
            }

            Rectangle bounds = component.Parent.Layout.GetControlBounds(component);

            dict.Add("Component.Width", bounds.Width);
            dict.Add("Component.Height", bounds.Height);

            /*
            if (component is System.Windows.Forms.ToolStripDropDownMenu)
            {
                System.Windows.Forms.ToolStripDropDownMenu tsddm = (component as System.Windows.Forms.ToolStripDropDownMenu);
                if (tsddm.OwnerItem != null)
                {
                    dict.Add("Component.Parent.Width", tsddm.OwnerItem.Width);
                    dict.Add("Component.Parent.Height", tsddm.OwnerItem.Height);
                }
            }
            if (component is System.Windows.Forms.ToolStripSplitButton)
            {
                dict.Add("Component.ButtonWidth", (component as System.Windows.Forms.ToolStripSplitButton).ButtonBounds.Width);
                dict.Add("Component.DropDownButtonWidth", (component as System.Windows.Forms.ToolStripSplitButton).DropDownButtonBounds.Width);
            }
            */

            if (action is RectangleRenderingAction)
            {
                RectangleRenderingAction act = (action as RectangleRenderingAction);

                double x = act.X.Evaluate(dict) + bounds.X;
                double y = act.Y.Evaluate(dict) + bounds.Y;
                double w = act.Width.Evaluate(dict);
                double h = act.Height.Evaluate(dict);

                if (act.Fill != null)
                {
                    FillRectangle(BrushFromFill(act.Fill, new Rectangle(x, y, w, h)), x, y, w, h);
                }
                if (act.Outline != null)
                {
                    if (act.Outline is SolidOutline)
                    {
                        DrawRectangle(PenFromOutline(act.Outline), x, y, w - 1, h - 1);
                    }
                    else if (act.Outline is ThreeDOutline)
                    {
                        ThreeDOutline threed = (act.Outline as ThreeDOutline);

                        Color lightColor = Color.Empty;
                        Color darkColor = Color.Empty;

                        switch (threed.Type)
                        {
                            case ThreeDOutlineType.Inset:
                            {
                                lightColor = Color.FromString(threed.DarkColor);
                                darkColor = Color.FromString(threed.LightColor);
                                break;
                            }
                            case ThreeDOutlineType.Outset:
                            {
                                lightColor = Color.FromString(threed.LightColor);
                                darkColor = Color.FromString(threed.DarkColor);
                                break;
                            }
                        }

                        Pen lightPen = new Pen(lightColor, new Measurement(act.Outline.Width, MeasurementUnit.Pixel));
                        Pen darkPen = new Pen(darkColor, new Measurement(act.Outline.Width, MeasurementUnit.Pixel));

                        DrawLine(lightPen, x, y, x + w, y);
                        DrawLine(lightPen, x, y, x, y + h);
                        DrawLine(darkPen, x + w - 1, y, x + w - 1, y + h - 1);
                        DrawLine(darkPen, x, y + h - 1, x + w - 1, y + h - 1);
                    }
                }
            }
            else if (action is LineRenderingAction)
            {
                LineRenderingAction act = (action as LineRenderingAction);

                double x1 = act.X1.Evaluate(dict) + bounds.X;
                double y1 = act.Y1.Evaluate(dict) + bounds.Y;
                double x2 = act.X2.Evaluate(dict);
                double y2 = act.Y2.Evaluate(dict);

                if (act.Outline != null)
                {
                    DrawLine(PenFromOutline(act.Outline), x1, y1, x2, y2);
                }
            }
            else if (action is TextRenderingAction)
            {
                TextRenderingAction act = (action as TextRenderingAction);

                int x = (int)Math.Round(act.X.Evaluate(dict) + bounds.X);
                int y = (int)Math.Round(act.Y.Evaluate(dict) + bounds.Y);
                int width = (int)Math.Round(act.Width.Evaluate(dict));
                int height = (int)Math.Round(act.Height.Evaluate(dict));
                Color color = Color.FromString(act.Color);
                string value = act.Value.ReplaceVariables(dict);

                // graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

                Font font = SystemFonts.MenuFont;
                /*
                if (act.Font != null)
                {
                    font = Font.FromFamily(act.Font, 8);
                }
                */
                DrawText(value, font, new Rectangle(x, y, width, height), color, act.HorizontalAlignment, act.VerticalAlignment);
            }
        }
 protected override void DrawRectangleInternal(Pen pen, double x, double y, double width, double height)
 {
     mvarGraphics.DrawRectangle(PenToNativePen(pen), (float)x, (float)y, (float)width, (float)height);
 }
 protected override void DrawLineInternal(Pen pen, double x1, double y1, double x2, double y2)
 {
     mvarGraphics.DrawLine(PenToNativePen(pen), (float)x1, (float)y1, (float)x2, (float)y2);
 }
 private System.Drawing.Pen PenToNativePen(Pen pen)
 {
     System.Drawing.Pen retval = new System.Drawing.Pen(ColorToNativeColor(pen.Color), (float)(pen.Width.ConvertTo(MeasurementUnit.Pixel).Value));
     retval.DashStyle = PenStyleToDashStyle(pen.Style);
     return retval;
 }