Ejemplo n.º 1
0
        public static System.Windows.Forms.TextFormatFlags ContentAligmentToTextFormatFlags(DevAge.Drawing.ContentAlignment a)
        {
            System.Windows.Forms.TextFormatFlags f = (System.Windows.Forms.TextFormatFlags) 0;

            if (Drawing.Utilities.IsBottom(a))
            {
                f |= System.Windows.Forms.TextFormatFlags.Bottom;
            }
            else if (Drawing.Utilities.IsTop(a))
            {
                f |= System.Windows.Forms.TextFormatFlags.Top;
            }
            else //if (Drawing.Utilities.IsMiddle(a))
            {
                f |= System.Windows.Forms.TextFormatFlags.VerticalCenter;
            }


            if (Drawing.Utilities.IsLeft(a))
            {
                f |= System.Windows.Forms.TextFormatFlags.Left;
            }
            else if (Drawing.Utilities.IsRight(a))
            {
                f |= System.Windows.Forms.TextFormatFlags.Right;
            }
            else //if (Drawing.Utilities.IsCenter(a))
            {
                f |= System.Windows.Forms.TextFormatFlags.HorizontalCenter;
            }

            return(f);
        }
Ejemplo n.º 2
0
 public WrapStringResult GetToolTip(System.Drawing.Font _font, int _preferedWidth, System.Windows.Forms.TextFormatFlags _flag)
 {
     return(this.GetToolTip(false, _font, _preferedWidth, _flag));
 }
Ejemplo n.º 3
0
 public WrapStringResult GetToolTip(bool ignoreWarning, System.Drawing.Font _font, int _preferedWidth, System.Windows.Forms.TextFormatFlags _flag)
 {
     System.Text.StringBuilder sb = new System.Text.StringBuilder();
     sb.AppendFormat("- " + LanguageManager.GetMessageText("PSO2Plugin_Filename", "Filename: {0}"), this.Filename);
     sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Author", "Author: {0}"), string.IsNullOrWhiteSpace(this.Author) ? "Unknown" : this.Author);
     if (!string.IsNullOrWhiteSpace(this.Version))
     {
         sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Version", "Version: {0}"), this.Version);
     }
     sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Description", "Description: {0}"), string.IsNullOrWhiteSpace(this.Description) ? "None" : this.Description);
     if (!string.IsNullOrWhiteSpace(this.Homepage))
     {
         sb.AppendFormat("\r\n- " + LanguageManager.GetMessageText("PSO2Plugin_Homepage", "Homepage: {0}"), this.Homepage);
     }
     if (!ignoreWarning && !this.Managed)
     {
         sb.Append("\r\n" + this.GetWarningMessage());
     }
     return(TextRendererWrapper.WrapString(sb.ToString(), _preferedWidth, _font, _flag));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Draws model elements, using the DotSpatial approach
        /// </summary>
        /// <param name="dispacement">X,Y point</param>
        /// <param name="graph">graphics</param>
        /// <param name="Shape">Shape: can be rectangle, ellipse, or triangle</param>
        public void Draw(Point displacement, Graphics graph, DotSpatial.Modeling.Forms.ModelShape Shape)
        {
            Rectangle rectToDraw = Rect;

            //Get x,y
            Point topLeft = new Point();

            topLeft.X = Rect.X;
            topLeft.Y = Rect.Y;

            //Sets up the colors to use
            Pen   outlinePen     = new Pen(DotSpatial.Symbology.SymbologyGlobal.ColorFromHsl(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.6 * Highlight), 1.0F);
            Color gradientTop    = DotSpatial.Symbology.SymbologyGlobal.ColorFromHsl(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 0.7 * Highlight);
            Color gradientBottom = DotSpatial.Symbology.SymbologyGlobal.ColorFromHsl(Color.GetHue(), Color.GetSaturation(), Color.GetBrightness() * 1.0 * Highlight);

            //The path used for drop shadows
            GraphicsPath shadowPath = new GraphicsPath();
            ColorBlend   colorBlend = new ColorBlend(3);

            colorBlend.Colors    = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DarkGray), Color.FromArgb(180, Color.DimGray) };
            colorBlend.Positions = new float[] { 0f, 0.125f, 1f };

            RectangleF textRect = new RectangleF(0, 0, 0, 0);

            //stores temporary model name
            string modelID = _modelID;

            #region Draw Ellipse Object
            //Draws Ellipse Shapes
            if (Shape == ModelShape.Ellipse)
            {
                //Adjust size of ellipse to fit text
                SizeF textSize = graph.MeasureString(_modelID, _font);

                if (!_modelID.Contains(" "))
                {
                    string newID = null;
                    //try splitting model based on Capital Letters
                    if (Regex.IsMatch(_modelID.Substring(1, _modelID.Length - 1), "[A-Z]"))
                    {
                        for (int i = 0; i <= _modelID.Length - 1; i++)
                        {
                            if (Char.IsUpper(_modelID[i]) && i > 0)
                            {
                                newID += " " + _modelID[i];
                            }
                            else
                            {
                                newID += _modelID[i];
                            }
                        }
                        modelID = newID; //set the model id equal to the new id
                    }
                    else                 //clip the modelID to fit within the ellipse
                    {
                        if (_modelID.Length < 10)
                        {
                            newID = _modelID;
                        }
                        else if (_modelID.Length <= 20)
                        {
                            newID = _modelID.Substring(0, 10) + " " + _modelID.Substring(9, _modelID.Length - 9);
                        }
                        else
                        {
                            newID = _modelID.Substring(0, 10) + " " + _modelID.Substring(9, 10);
                        }
                        modelID = newID;//set the model id equal to the new id
                    }


                    //_modelID = _modelID.Substring(0, 20);
                    //while ((textSize.Width > Rect.Width) || (textSize.Height > Rect.Height))
                    //{
                    //    Rect.Width++;
                    //    Rect.Height++;
                    //}
                }
                textRect = new RectangleF(topLeft.X + 1, topLeft.Y + (Rect.Height - textSize.Height) / 2, Rect.Width, textSize.Height);


                //Draws the shadow
                shadowPath.AddEllipse(topLeft.X, topLeft.Y, Rect.Width + 7, Rect.Height + 7);
                PathGradientBrush shadowBrush = new PathGradientBrush(shadowPath);
                shadowBrush.WrapMode            = WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the Ellipse
                Rectangle           fillArea = new Rectangle(topLeft.X, topLeft.Y, Rect.Width, Rect.Height);
                LinearGradientBrush myBrush  = new LinearGradientBrush(fillArea, gradientBottom, gradientTop, LinearGradientMode.Vertical);
                graph.FillEllipse(myBrush, topLeft.X, topLeft.Y, Rect.Width, Rect.Height);
                graph.SmoothingMode = SmoothingMode.AntiAlias;
                //graph.PixelOffsetMode = PixelOffsetMode.HighQuality;
                graph.DrawEllipse(outlinePen, topLeft.X, topLeft.Y, Rect.Width, Rect.Height);

                //update model rectangle
                Rect.Height = Convert.ToInt32(Math.Max(textRect.Height, Rect.Height));
                Rect.Width  = Convert.ToInt32(Math.Max(textRect.Width, Rect.Width));
                Rect.X      = topLeft.X;
                Rect.Y      = topLeft.Y;

                Rectangle TextRectangle = Rectangle.Ceiling(textRect);
                TextRectangle.Width += 2;

                StringFormat strFormat = new StringFormat();
                strFormat.Alignment     = StringAlignment.Center;
                strFormat.LineAlignment = StringAlignment.Center;
                graph.DrawString(modelID, Font, new SolidBrush(Color.FromArgb(250, Color.Black)), Rect, strFormat);

                //Garbage collection
                myBrush.Dispose();
            }
            #endregion

            #region Draw Triangular Object
            //Draws Triangular Shapes
            if (Shape == ModelShape.Triangle)
            {
                //Draws the shadow
                Point[] ptShadow = new Point[4];
                ptShadow[0] = new Point(topLeft.X + (Rect.Width / 2), topLeft.Y - 5);
                ptShadow[1] = new Point(topLeft.X + Rect.Width + 7, topLeft.Y + (Rect.Height / 2));
                ptShadow[2] = new Point(topLeft.X + (Rect.Width / 2), topLeft.Y + Rect.Height + 5);
                ptShadow[3] = new Point(topLeft.X, topLeft.Y + (Rect.Height / 2));

                shadowPath.AddLines(ptShadow);
                PathGradientBrush shadowBrush = new PathGradientBrush(shadowPath);
                shadowBrush.WrapMode            = WrapMode.Clamp;
                shadowBrush.InterpolationColors = colorBlend;
                graph.FillPath(shadowBrush, shadowPath);

                //Draws the shape
                Point[] pt = new Point[4];
                pt[0] = new Point(topLeft.X + (Rect.Width / 2), topLeft.Y);
                pt[1] = new Point(topLeft.X + Rect.Width, topLeft.Y + (Rect.Height / 2));
                pt[2] = new Point(topLeft.X + (Rect.Width / 2), topLeft.Y + Rect.Height);
                pt[3] = new Point(topLeft.X, topLeft.Y + (Rect.Height / 2));

                GraphicsPath myPath = new GraphicsPath();
                myPath.AddLines(pt);
                Rectangle           fillArea = new Rectangle(topLeft.X - (Rect.Width / 2), topLeft.Y, Rect.Width, Rect.Height);
                LinearGradientBrush myBrush  = new LinearGradientBrush(fillArea, gradientBottom, gradientTop, LinearGradientMode.Vertical);
                graph.FillPath(myBrush, myPath);
                graph.DrawPath(outlinePen, myPath);

                //Draws the text
                SizeF textSize = graph.MeasureString("Trigger", Font, Rect.Width);

                //if ((textSize.Width > Rect.Width) || (textSize.Height > Rect.Height))
                //    textRect = new RectangleF(topLeft.X - (Rect.Width - textSize.Width) / 2, topLeft.Y + (Rect.Height - textSize.Height) / 2, textSize.Width, textSize.Height);
                //else
                textRect = new RectangleF(topLeft.X, topLeft.Y + (Rect.Height - textSize.Height) / 2, Rect.Width, textSize.Height);

                //Update model rectangle
                Rect.Height = Convert.ToInt32(Math.Max(textRect.Height, Rect.Height));
                Rect.Width  = Convert.ToInt32(Math.Max(textRect.Width, Rect.Width));
                Rect.X      = topLeft.X;
                Rect.Y      = topLeft.Y;

                //draw text
                Rectangle TextRectangle = Rectangle.Ceiling(textRect);
                TextRectangle.Width += 2;
                System.Windows.Forms.TextFormatFlags flags = System.Windows.Forms.TextFormatFlags.HorizontalCenter |
                                                             System.Windows.Forms.TextFormatFlags.VerticalCenter | System.Windows.Forms.TextFormatFlags.WordBreak;
                System.Windows.Forms.TextRenderer.DrawText(graph, "Trigger", Font, TextRectangle, Color.Black, flags);

                //Garbage collection
                myBrush.Dispose();
            }
            #endregion


            //Garbage collection
            shadowPath.Dispose();
            outlinePen.Dispose();
        }
 public static void DrawText(this VisualStyleRenderer rnd, IDeviceContext dc, ref Rectangle bounds, string text, System.Windows.Forms.TextFormatFlags flags, NativeMethods.DrawThemeTextOptions options)
 {
     NativeMethods.RECT rc = new NativeMethods.RECT(bounds);
     using (SafeGDIHandle hdc = new SafeGDIHandle(dc))
         NativeMethods.DrawThemeTextEx(rnd.Handle, hdc, rnd.Part, rnd.State, text, text.Length, (int)flags, ref rc, ref options);
     bounds = rc;
 }
 public static void DrawGlowingText(this VisualStyleRenderer rnd, IDeviceContext dc, Rectangle bounds, string text, Font font, Color color, System.Windows.Forms.TextFormatFlags flags)
 {
     DrawWrapper(rnd, dc, bounds,
                 delegate(IntPtr memoryHdc) {
         // Create and select font
         using (NativeMethods.SafeDCObjectHandle fontHandle = new NativeMethods.SafeDCObjectHandle(memoryHdc, font.ToHfont()))
         {
             // Draw glowing text
             NativeMethods.DrawThemeTextOptions dttOpts = new NativeMethods.DrawThemeTextOptions(true);
             dttOpts.TextColor             = color;
             dttOpts.GlowSize              = 10;
             dttOpts.AntiAliasedAlpha      = true;
             NativeMethods.RECT textBounds = new NativeMethods.RECT(4, 0, bounds.Right - bounds.Left, bounds.Bottom - bounds.Top);
             NativeMethods.DrawThemeTextEx(rnd.Handle, memoryHdc, rnd.Part, rnd.State, text, text.Length, (int)flags, ref textBounds, ref dttOpts);
         }
     }
                 );
 }
Ejemplo n.º 7
0
 public void DrawText(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string textToDraw, bool drawDisabled, System.Windows.Forms.TextFormatFlags flags)
 {
 }
Ejemplo n.º 8
0
 public System.Drawing.Rectangle GetTextExtent(System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string textToDraw, System.Windows.Forms.TextFormatFlags flags)
 {
 }
Ejemplo n.º 9
0
 public bool TextRequiresWordBreak(string text, System.Drawing.Font font, System.Drawing.Size size, System.Windows.Forms.TextFormatFlags flags)
 {
 }
Ejemplo n.º 10
0
 public System.Drawing.Size GetTextSize(string text, System.Drawing.Font font, System.Drawing.Size proposedConstraints, System.Windows.Forms.TextFormatFlags flags)
 {
 }