Beispiel #1
1
        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, Rectangle gripRect, bool enableShadows, bool useroundedCorners)
        {
            if (appointment == null)
                throw new ArgumentNullException("appointment");

            if (g == null)
                throw new ArgumentNullException("g");

            if (rect.Width != 0 && rect.Height != 0)
                using (StringFormat format = new StringFormat())
                {
                    format.Alignment = StringAlignment.Near;
                    format.LineAlignment = StringAlignment.Near;

                    if ((appointment.Locked) && isSelected)
                    {
                        // Draw back
                        using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }
                    else
                    {
                        // Draw back
                        using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                            g.FillRectangle(m_Brush, rect);
                    }

                    if (isSelected)
                    {
                        using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                            g.DrawRectangle(m_Pen, rect);

                        Rectangle m_BorderRectangle = rect;

                        m_BorderRectangle.Inflate(2, 2);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);

                        m_BorderRectangle.Inflate(-4, -4);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, m_BorderRectangle);
                    }
                    else
                    {
                        // Draw gripper
                        gripRect.Width += 1;

                        using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                            g.FillRectangle(m_Brush, gripRect);

                        using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                            g.DrawRectangle(m_Pen, rect);
                    }

                    rect.X += gripRect.Width;
                    g.DrawString(appointment.Subject, this.BaseFont, SystemBrushes.WindowText, rect, format);
                }
        }
Beispiel #2
0
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Изменение цветов кисти.
            /// Метод автоматически вызывается после установки соответствующих свойств
            /// </summary>
            //---------------------------------------------------------------------------------------------------------
            protected virtual void RaiseColorChanged()
            {
#if USE_WINDOWS
                System.Windows.Media.DrawingBrush    hatch_brush = mWindowsBrush as System.Windows.Media.DrawingBrush;
                System.Windows.Media.DrawingGroup    dg          = hatch_brush.Drawing as System.Windows.Media.DrawingGroup;
                System.Windows.Media.GeometryDrawing gd          = dg.Children[0] as System.Windows.Media.GeometryDrawing;
                if (mIsBackground)
                {
                    gd.Brush = XWindowsColorManager.GetBrushByColor(mBackgroundColor);
                }
                else
                {
                    gd.Brush = null;
                }
                gd.Pen.Brush = XWindowsColorManager.GetBrushByColor(mForegroundColor);

                // 2) Информируем об изменении
                NotifyPropertyChanged(PropertyArgsWindowsBrush);
#endif
#if USE_GDI
                if (mDrawingBrush != null)
                {
                    mDrawingBrush.Dispose();
                }
                mDrawingBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross,
                                                                        mForegroundColor, mBackgroundColor);
#endif
#if USE_SHARPDX
                if (mD2DBrush != null)
                {
                    SharpDX.Direct2D1.SolidColorBrush d2d_solid_brush = mD2DBrush as SharpDX.Direct2D1.SolidColorBrush;
                    d2d_solid_brush.Color = mForegroundColor;
                }
#endif
            }
Beispiel #3
0
        void DrawBubble(Report rpt, Graphics g, Brush brush, Point p, int iRow, int iCol, double bmin, double bmax, double bv)
        {
            Pen pen      = null;
            int diameter = BubbleSize(rpt, iRow, iCol, bmin, bmax, bv);          // set diameter of bubble

            int radius = diameter / 2;

            try
            {
                if (this.ChartDefn.Type == ChartTypeEnum.Scatter &&
                    brush.GetType() == typeof(System.Drawing.Drawing2D.HatchBrush))
                {
                    System.Drawing.Drawing2D.HatchBrush tmpBrush = (System.Drawing.Drawing2D.HatchBrush)brush;
                    SolidBrush br = new SolidBrush(tmpBrush.ForegroundColor);
                    pen = new Pen(new SolidBrush(tmpBrush.ForegroundColor));
                    DrawLegendMarker(g, br, pen, SeriesMarker[iCol - 1], p.X - radius, p.Y - radius, diameter);
                    DrawDataPoint(rpt, g, new Point(p.X - 3, p.Y + 3), iRow, iCol);
                }
                else
                {
                    pen = new Pen(brush);
                    DrawLegendMarker(g, brush, pen, ChartMarkerEnum.Bubble, p.X - radius, p.Y - radius, diameter);
                    DrawDataPoint(rpt, g, new Point(p.X - 3, p.Y + 3), iRow, iCol);
                }
            }
            finally
            {
                if (pen != null)
                {
                    pen.Dispose();
                }
            }

            return;
        }
Beispiel #4
0
        /// <summary>
        /// Handles Paint event.
        /// </summary>
        /// <param name="e">Event arguments.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle buttonRect = new Rectangle(ClientRectangle.Left + 2,
                                                 ClientRectangle.Top + 2,
                                                 ClientRectangle.Width - 4,
                                                 ClientRectangle.Height - 4);

            System.Drawing.Drawing2D.HatchBrush brush;
            if (buttonState)
            {
                brush = new System.Drawing.Drawing2D.HatchBrush(
                    System.Drawing.Drawing2D.HatchStyle.DarkHorizontal, Color.Red, Color.White);
            }
            else
            {
                brush = new System.Drawing.Drawing2D.HatchBrush(
                    System.Drawing.Drawing2D.HatchStyle.DarkVertical, Color.Green, Color.White);
            }

            e.Graphics.FillRectangle(brush, buttonRect);
            if (Focused)
            {
                ControlPaint.DrawFocusRectangle(e.Graphics, ClientRectangle);
            }
        }
Beispiel #5
0
        public SpriteForm(ProjectMainForm parent, Spriteset ss, Sprite s)
        {
            m_parent = parent;

            m_ss = ss;

            InitializeComponent();

            SetSprite(s);
            m_toolbox   = new Toolbox_Sprite();
            m_optionbox = new Optionbox_Sprite();
            m_arrowbox  = new Arrowbox_Sprite();

            MdiParent       = parent;
            FormBorderStyle = FormBorderStyle.SizableToolWindow;
            StartPosition   = FormStartPosition.Manual;
            Visible         = false;
            ControlBox      = false;

            // Set to 16x.
            cbZoom.SelectedIndex = (int)ZoomLevel.Zoom_16x;

            if (m_brushTransparent == null)
            {
                m_brushTransparent = new System.Drawing.Drawing2D.HatchBrush(
                    Options.TransparentPattern,
                    Color.LightGray, Color.Transparent);
            }
        }
Beispiel #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            System.Drawing.Pen pen =
                new System.Drawing.Pen(this.ForeColor, 0);

            Rectangle rect = this.ClientRectangle;

            rect.Width  -= 1;
            rect.Height -= 1;

            System.Drawing.Brush backBrush =
                new System.Drawing.Drawing2D.HatchBrush(
                    System.Drawing.Drawing2D.HatchStyle.SmallCheckerBoard,
                    this.ForeColor, this.BackColor);
            e.Graphics.FillRectangle(backBrush, rect);
            backBrush.Dispose();

            if (_brush != null)
            {
                e.Graphics.FillRectangle(_brush, rect);
            }
            e.Graphics.DrawRectangle(pen, rect);

            pen.Dispose();
        }
Beispiel #7
0
 //------------------------------------------------------------------------
 private void CGanttTree_DragOver(object sender, DragEventArgs e)
 {
     UndrawZoneDestDragDrop();
     if (e.Data.GetDataPresent(typeof(TreeNode)) && !LockEdition)
     {
         TreeNode nodeMoved = e.Data.GetData(typeof(TreeNode)) as TreeNode;
         TreeNode nodeDest  = null;
         bool     bAfter    = false;
         Point    pt        = PointToClient(new Point(e.X, e.Y));
         GetDestDragDrop(nodeMoved, pt, ref nodeDest, ref bAfter);
         if (nodeDest != null)
         {
             e.Effect = DragDropEffects.Move;
             Rectangle rct = nodeDest.Bounds;
             using (Graphics g = CreateGraphics())
             {
                 Brush br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.DottedGrid, Color.Black, Color.Blue);
                 int   nY = rct.Top;
                 if (bAfter)
                 {
                     nY = rct.Bottom;
                 }
                 m_rectZoneDestDragDrop = new Rectangle(0, nY - 1, Width, 3);
                 g.FillRectangle(br, m_rectZoneDestDragDrop);
                 br.Dispose();
             }
         }
         else
         {
             e.Effect = DragDropEffects.None;
             m_rectZoneDestDragDrop = new Rectangle(0, 0, 0, 0);
         }
     }
 }
Beispiel #8
0
        public Palette256Form(ProjectMainForm parent, Palette256 p)
        {
            m_parent  = parent;
            m_palette = p;

            InitializeComponent();

            MdiParent       = parent;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            StartPosition   = FormStartPosition.Manual;
            Visible         = false;
            ControlBox      = false;

            if (m_palette.IsBackground)
            {
                Text = "BgPalette '" + p.Name + "'";
            }
            else
            {
                Text = "Palette '" + p.Name + "'";
            }

            if (m_brushTransparent == null)
            {
                m_brushTransparent = new System.Drawing.Drawing2D.HatchBrush(
                    Options.TransparentPattern,
                    Color.LightGray, Color.Transparent);
            }
        }
        public Palette256Form(ProjectMainForm parent, Palette256 p)
        {
            m_parent = parent;
            m_palette = p;

            InitializeComponent();

            MdiParent = parent;
            FormBorderStyle = FormBorderStyle.FixedToolWindow;
            StartPosition = FormStartPosition.Manual;
            Visible = false;
            ControlBox = false;

            if (m_palette.IsBackground)
                Text = "BgPalette '" + p.Name + "'";
            else
                Text = "Palette '" + p.Name + "'";

            if (m_brushTransparent == null)
            {
                m_brushTransparent = new System.Drawing.Drawing2D.HatchBrush(
                        Options.TransparentPattern,
                        Color.LightGray, Color.Transparent);
            }
        }
Beispiel #10
0
 private void listBoxHintergrundStil_DrawItem(object sender, DrawItemEventArgs e)
 {
     System.Drawing.Drawing2D.HatchBrush boxPinsel = new System.Drawing.Drawing2D.HatchBrush(hinterGrundStil[e.Index], Color.Black, Color.White);
     //den Hintergrund setzen
     e.DrawBackground();
     //die Muster
     e.Graphics.FillRectangle(boxPinsel, e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Width - 1, e.Bounds.Height - 1);
 }
Beispiel #11
0
        protected override void View_Paint(object sender, PaintEventArgs e)
        {
            // We don't use the base class logic because the last several bits we don't really want:
            // we don't want the usual page background with a grid.  Helpful to have the grid when editing, but we don't want it to display at runtime
            // There is also no need to draw the outside page area; it's nicer just to extend the background colour is needed
            m_BaseBuffer.InvalidateAll();
            if (this.DesignMode)
            {
                return;
            }
            if (m_Page == null)
            {
                e.Graphics.Clear(Color.Tomato);
                return;
            }
            try
            {
                using (Graphics gr = m_BaseBuffer.PrepareDraw())
                {
                    using (NetCanvas canvas = new NetCanvas(gr))
                    {
                        if (gr != null)
                        {
                            // some redrawing is required
                            PrepareGraphics(gr);
                            gr.Clear(Color.FromKnownColor(KnownColor.Control));
                            //gr.Clear(m_Page.Colour)
                            //m_Page.DrawBackground(gr, m_zoom)' Would also draw grid and (possibly) origin
                            if (!BeingEdited)
                            {
                                m_Page.DrawShapes(canvas, m_Zoom, m_PixelsPerDocumentX, this);
                            }
                            else
                            {
                                using (System.Drawing.Drawing2D.HatchBrush br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.DiagonalCross, Color.FromArgb(255, 200, 200), Color.Empty))
                                {
                                    gr.FillRectangle(br, m_Page.Bounds);
                                }

                                using (Font objFont = new Font(FontFamily.GenericSansSerif, 14f / (m_Zoom * m_PixelsPerDocumentX), FontStyle.Bold, GraphicsUnit.Point)
                                       )                          // Division is because a scale transform is applied to increase size by this
                                {
                                    gr.DrawString(Strings.Item("Palette_BeingEdited"), objFont, Brushes.DarkGray, m_Page.Bounds, GUIUtilities.StringFormatCentreCentre);
                                }
                            }
                            // Does not draw the outside valid page grey area
                        }
                    }
                }

                // now that the buffers are ready, we can draw it on screen
                e.Graphics.DrawImageUnscaled(m_BaseBuffer.m_bmp, 0, 0);
            }
            catch (Exception ex)
            {
                Utilities.LogSubError(ex.Message);
            }
        }
Beispiel #12
0
 //---------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Обновление ресурса System.Drawing
 /// </summary>
 //---------------------------------------------------------------------------------------------------------
 public override void UpdateDrawingResource()
 {
     if (mDrawingBrush != null)
     {
         mDrawingBrush.Dispose();
     }
     mDrawingBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross,
                                                             mForegroundColor, mBackgroundColor);
 }
Beispiel #13
0
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     if (!m_Applicable)
     {
         e.Graphics.Clear(this.BackColor);
     }
     else if (!m_bolDisplayCurrentColour)
     {
         // draw standard selection marker (in design mode also)
         if (g_Bitmap16 == null)
         {
             g_Bitmap16 = ColourPanel.GenerateMoreColoursBitmap(ColourPanel.GetStandard17Colours());
         }
         e.Graphics.DrawImage(g_Bitmap16, new Rectangle(0, 0, Width, Height));
     }
     else if (this.DesignMode)
     {
         e.Graphics.Clear(Color.LightBlue);
     }
     else
     {
         if (m_Current.IsEmpty)
         {
             e.Graphics.Clear(Color.White);
             Image image = BlackWhite ? Resources.AM.BlackWhiteText : Resources.AM.RedCross;
             if (image != null && m_Applicable)
             {
                 e.Graphics.DrawImageUnscaled(image, (Width - image.Width) / 2, (Height - image.Height) / 2);
                 image.Dispose();
             }
         }
         else if (m_Current.A < 255)
         {
             e.Graphics.Clear(this.BackColor);
             using (SolidBrush br = new SolidBrush(m_Current))
             {
                 e.Graphics.FillRectangle(br, 0, 0, Width, Height);
             }
         }
         else
         {
             e.Graphics.Clear(m_Current);
         }
     }
     if (!m_Applicable || !Enabled)
     {
         using (Brush br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.DiagonalCross, Color.Gray))
             e.Graphics.FillRectangle(br, new Rectangle(0, 0, Width, Height));
     }
     if (Focused)
     {
         e.Graphics.DrawRectangle(GUIUtilities.FocusPen, 3, 3, Width - 6, Height - 6);
     }
 }
        void DrawBubble(Report rpt, Graphics g, Brush brush, Point p, int iRow, int iCol, double bmin, double bmax, double bv, double xv, double yv)
        {
            Pen pen      = null;
            int diameter = BubbleSize(rpt, iRow, iCol, bmin, bmax, bv);          // set diameter of bubble

            int radius = diameter / 2;

            try
            {
                if (this.ChartDefn.Type == ChartTypeEnum.Scatter &&
                    brush.GetType() == typeof(System.Drawing.Drawing2D.HatchBrush))
                {
                    System.Drawing.Drawing2D.HatchBrush tmpBrush = (System.Drawing.Drawing2D.HatchBrush)brush;
                    SolidBrush br = new SolidBrush(tmpBrush.ForegroundColor);
                    pen = new Pen(new SolidBrush(tmpBrush.ForegroundColor));
                    DrawLegendMarker(g, br, pen, SeriesMarker[iCol - 1], p.X - radius, p.Y - radius, diameter);
                    DrawDataPoint(rpt, g, new Point(p.X - 3, p.Y + 3), iRow, iCol);
                }
                else
                {
                    pen = new Pen(brush);
                    DrawLegendMarker(g, brush, pen, ChartMarkerEnum.Bubble, p.X - radius, p.Y - radius, diameter);
                    DrawDataPoint(rpt, g, new Point(p.X - 3, p.Y + 3), iRow, iCol);
                }
                //Add a metafilecomment to use as a tooltip GJL 26092008

                if (_showToolTips || _showToolTipsX)
                {
                    string display = "";
                    if (_showToolTipsX)
                    {
                        display = xv.ToString(_tooltipXFormat);
                    }
                    if (_showToolTips)
                    {
                        if (display.Length > 0)
                        {
                            display += " , ";
                        }
                        display += yv.ToString(_tooltipYFormat);
                    }
                    String val = "ToolTip:" + display + "|X:" + (int)(p.X - 3) + "|Y:" + (int)(p.Y - 3) + "|W:" + 6 + "|H:" + 6;
                    g.AddMetafileComment(new System.Text.ASCIIEncoding().GetBytes(val));
                }
            }
            finally
            {
                if (pen != null)
                {
                    pen.Dispose();
                }
            }

            return;
        }
Beispiel #15
0
        internal void DrawLegendLineMarker(Graphics g, Brush b, Pen p, ChartMarkerEnum marker, int x, int y, int mSize)
        {
            if (b.GetType() == typeof(System.Drawing.Drawing2D.HatchBrush))
            {
                System.Drawing.Drawing2D.HatchBrush hb = (System.Drawing.Drawing2D.HatchBrush)b;
                b = new SolidBrush(hb.ForegroundColor);
            }

            Pen p2;

            Point[] points;
            switch (marker)
            {
            case ChartMarkerEnum.Bubble:
            case ChartMarkerEnum.Circle:
                g.FillEllipse(b, x, y, mSize, mSize);
                break;

            case ChartMarkerEnum.Square:
                g.FillRectangle(b, x, y, mSize, mSize);
                break;

            case ChartMarkerEnum.Plus:

                p2 = new Pen(b, 2.0f);
                g.DrawLine(p2, new Point(x + (mSize + 1) / 2, y), new Point(x + (mSize + 1) / 2, y + mSize));
                //g.DrawLine(p2, new Point(x + (mSize + 1) / 2, y + (mSize + 1) / 2), new Point(x + mSize, y + (mSize + 1) / 2));
                break;

            case ChartMarkerEnum.Diamond:
                points    = new Point[5];
                points[0] = points[4] = new Point(x + (mSize + 1) / 2, y);      // starting and ending point
                points[1] = new Point(x, y + (mSize + 1) / 2);
                points[2] = new Point(x + (mSize + 1) / 2, y + mSize);
                points[3] = new Point(x + mSize, y + (mSize + 1) / 2);
                g.FillPolygon(b, points);
                break;

            case ChartMarkerEnum.Triangle:
                points    = new Point[4];
                points[0] = points[3] = new Point(x + (mSize + 1) / 2, y);      // starting and ending point
                points[1] = new Point(x, y + mSize);
                points[2] = new Point(x + mSize, y + mSize);
                g.FillPolygon(b, points);
                break;

            case ChartMarkerEnum.X:
                p2 = new Pen(b, 2.0f);
                g.DrawLine(p2, new Point(x, y), new Point(x + mSize, y + mSize));
                g.DrawLine(p2, new Point(x, y + mSize), new Point(x + mSize, y));
                break;
            }
            return;
        }
Beispiel #16
0
        public void Button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            fig.Show();

                if (CheckBox1.Checked == true)
                {
                    Font MyFont1 = new Font("Microsoft Sans Serif", 36);
                    G.DrawString("TEXT", MyFont1, Brushes.Blue, 370, 260);
                }

                if (CheckBox2.Checked == true)
                {
                    Pen MyPen1 = new Pen(Color.Red, 1);
                    Brush MyBrush1 = new SolidBrush(Color.Green);
                    G.DrawEllipse(MyPen1, 200, 140, 100, 100);
                    G.FillEllipse(MyBrush1, 201, 141, 99, 99);
                }

                if (CheckBox3.Checked == true)
                {
                    Font MyFont1 = new Font("Microsoft Sans Serif", 36);
                    G.DrawString("y=" + Function.Result(int.Parse(ListBox1.Text)), MyFont1, Brushes.Black, 20, 30);
                }

                if (CheckBox4.Checked == true)
                {
                    Pen MyPen1 = new Pen(Color.Black, 1);
                    Brush MyBrush1 = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Horizontal, Color.Red, Color.Empty);
                    Point[] points = { new Point(30, 250),
                                     new Point(60, 200),
                                     new Point(90, 250),
                                     new Point(60, 300)};
                                G.DrawPolygon(MyPen1, points);
                                G.FillPolygon(MyBrush1, points);
                }

                if (RadioButton1.Checked == true)
                {
                    Pen MyPen1 = new Pen(Color.Black, 1);
                    Brush MyBrush1 = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.BackwardDiagonal, Color.Green, Color.Empty);
                    G.DrawRectangle(MyPen1, 370, 20, 100, 100);
                    G.FillRectangle(MyBrush1, 371, 21, 99, 99);
                }

                else if (RadioButton2.Checked == true)
                {
                    Pen MyPen1 = new Pen(Color.Black, 1);
                    Brush MyBrush1 = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Vertical, Color.Red, Color.Empty);
                    G.DrawEllipse(MyPen1, 370, 140, 140, 100);
                    G.FillEllipse(MyBrush1, 371, 141, 139, 99);
                }
        }
Beispiel #17
0
        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, int gripWidth)
        {
            StringFormat m_Format = new StringFormat();

            m_Format.Alignment     = StringAlignment.Near;
            m_Format.LineAlignment = StringAlignment.Near;

            if ((appointment.Locked) && isSelected)
            {
                // Draw back
                using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                    g.FillRectangle(m_Brush, rect);
            }
            else
            {
                // Draw back
                using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                    g.FillRectangle(m_Brush, rect);
            }

            if (isSelected)
            {
                using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                    g.DrawRectangle(m_Pen, rect);

                Rectangle m_BorderRectangle = rect;

                m_BorderRectangle.Inflate(2, 2);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, m_BorderRectangle);

                m_BorderRectangle.Inflate(-4, -4);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, m_BorderRectangle);
            }
            else
            {
                // Draw gripper
                Rectangle m_GripRectangle = rect;
                m_GripRectangle.Width = gripWidth + 1;

                using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                    g.FillRectangle(m_Brush, m_GripRectangle);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, rect);
            }

            rect.X += gripWidth;
            g.DrawString(appointment.Title, this.BaseFont, SystemBrushes.WindowText, rect, m_Format);
        }
Beispiel #18
0
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Конструктор инициализирует объект класса указанными параметрами
            /// </summary>
            /// <param name="name">Имя кисти</param>
            //---------------------------------------------------------------------------------------------------------
            public CCadBrushHatch(String name)
            {
                mName      = name;
                mBrushFill = TCadBrushFillType.Hatching;
#if USE_WINDOWS
                mWindowsBrush = new System.Windows.Media.DrawingBrush();
#endif
#if USE_GDI
                mDrawingBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross,
                                                                        mForegroundColor);
#endif
            }
Beispiel #19
0
        public override void DrawAppointment(Graphics g, Rectangle rect, Appointment appointment, bool isSelected, int gripWidth)
        {
            StringFormat m_Format = new StringFormat();
            m_Format.Alignment = StringAlignment.Near;
            m_Format.LineAlignment = StringAlignment.Near;

            if ((appointment.Locked) && isSelected)
            {
                // Draw back
                using (Brush m_Brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Wave, Color.LightGray, appointment.Color))
                    g.FillRectangle(m_Brush, rect);
            }
            else
            {
                // Draw back
                using (SolidBrush m_Brush = new SolidBrush(appointment.Color))
                    g.FillRectangle(m_Brush, rect);
            }

            if (isSelected)
            {
                using (Pen m_Pen = new Pen(appointment.BorderColor, 4))
                    g.DrawRectangle(m_Pen, rect);

                Rectangle m_BorderRectangle = rect;

                m_BorderRectangle.Inflate(2, 2);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, m_BorderRectangle);

                m_BorderRectangle.Inflate(-4, -4);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, m_BorderRectangle);
            }
            else
            {
                // Draw gripper
                Rectangle m_GripRectangle = rect;
                m_GripRectangle.Width = gripWidth + 1;

                using (SolidBrush m_Brush = new SolidBrush(appointment.BorderColor))
                    g.FillRectangle(m_Brush, m_GripRectangle);

                using (Pen m_Pen = new Pen(SystemColors.WindowFrame, 1))
                    g.DrawRectangle(m_Pen, rect);
            }

            rect.X += gripWidth;
            g.DrawString(appointment.Title, this.BaseFont, SystemBrushes.WindowText, rect, m_Format);
        }
Beispiel #20
0
        private void button4_Click(object sender, EventArgs e)
        {
            Graphics zeichenflaeche = CreateGraphics();
            Pen      stift          = new Pen(Color.Black);
            Brush    pinsel         = new SolidBrush(Color.Blue);

            //einen Pinsel für ein Muster erzeugen wichtig
            //es läuft über einen Konstruktor

            System.Drawing.Drawing2D.HatchBrush musterPinsel = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross, Color.Blue, Color.Green);

            zeichenflaeche.FillRectangle(musterPinsel, 150, 110, 90, 90);
        }
Beispiel #21
0
        public static WindowsBrush FromBrush(DeviceContext dc, Brush originalBrush)
        {
            if (originalBrush is SolidBrush)
            {
                return(new WindowsSolidBrush(dc, ((SolidBrush)originalBrush).Color));
            }

            if (originalBrush is System.Drawing.Drawing2D.HatchBrush)
            {
                System.Drawing.Drawing2D.HatchBrush hatchBrush = ((System.Drawing.Drawing2D.HatchBrush)originalBrush);
                return(new WindowsHatchBrush(dc, (WindowsHatchStyle)hatchBrush.HatchStyle, hatchBrush.ForegroundColor, hatchBrush.BackgroundColor));
            }

            Debug.Fail("Don't know how to convert this brush!");
            return(null);
        }
Beispiel #22
0
 protected override void WndProc(ref Message m)
 {
     //We have to change the clientsize to make room for borders
     //if not, the border is limited in how thick it is.
     if (m.Msg == 0x83)       //WM_NCCALCSIZE
     {
         if (m.WParam == IntPtr.Zero)
         {
             RECT rect = (RECT)Marshal.PtrToStructure(m.LParam, typeof(RECT));
             rect.left   += clientPadding;
             rect.right  -= clientPadding;
             rect.top    += clientPadding;
             rect.bottom -= clientPadding;
             Marshal.StructureToPtr(rect, m.LParam, false);
         }
         else
         {
             NCCALSIZE_PARAMS rects = (NCCALSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALSIZE_PARAMS));
             rects.newWindow.left   += clientPadding;
             rects.newWindow.right  -= clientPadding;
             rects.newWindow.top    += clientPadding;
             rects.newWindow.bottom -= clientPadding;
             Marshal.StructureToPtr(rects, m.LParam, false);
         }
     }
     if (m.Msg == 0x85)       //WM_NCPAINT
     {
         IntPtr wDC = GetWindowDC(Handle);
         using (Graphics g = Graphics.FromHdc(wDC)){
             Rectangle rect  = new Rectangle(0, 0, Width, Height);
             Rectangle inner = new Rectangle(0, 0, Width, Height);
             inner.Offset(actualBorderWidth + 2, actualBorderWidth + 2);
             inner.Width  -= 2 * actualBorderWidth + 4;
             inner.Height -= 2 * actualBorderWidth + 4;
             Region r = new Region(rect);
             r.Xor(inner);
             using (System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SmallCheckerBoard, Color.Green, Color.Red))
             {
                 g.FillRegion(brush, r);
             }
         }
         return;
     }
     base.WndProc(ref m);
 }
        public ColorEncodingView(ProjectMainForm parent, Subpalette p)
        {
            m_parent = parent;

            InitializeComponent();
            this.DialogResult = DialogResult.No;

            m_subpalette = p;

            AdjustColorScrollbars();

            if (m_brushTransparent == null)
            {
                m_brushTransparent = new System.Drawing.Drawing2D.HatchBrush(
                        Options.TransparentPattern,
                        Color.LightGray, Color.Transparent);
            }
        }
Beispiel #24
0
        public EmfHatchFillBrush(BinaryReader _br)
        {
            Int32 HatchStyle = _br.ReadInt32();

            byte fA,fR,fG,fB;
            fB = _br.ReadByte();
            fG = _br.ReadByte();
            fR = _br.ReadByte();
            fA = _br.ReadByte();

            byte bA,bR,bG,bB;
            bB = _br.ReadByte();
            bG = _br.ReadByte();
            bR = _br.ReadByte();
            bA = _br.ReadByte();

            myBrush = new System.Drawing.Drawing2D.HatchBrush((System.Drawing.Drawing2D.HatchStyle) HatchStyle,Color.FromArgb(fA,fR,fG,fB),Color.FromArgb(bA,bR,bG,bB));
        }
Beispiel #25
0
        public ColorEncodingView(ProjectMainForm parent, Subpalette p)
        {
            m_parent = parent;

            InitializeComponent();
            this.DialogResult = DialogResult.No;

            m_subpalette = p;

            AdjustColorScrollbars();

            if (m_brushTransparent == null)
            {
                m_brushTransparent = new System.Drawing.Drawing2D.HatchBrush(
                    Options.TransparentPattern,
                    Color.LightGray, Color.Transparent);
            }
        }
Beispiel #26
0
        private void DoInstructions(Single recX, Single recY, Single recWidth, Single recHeight, Brush b, Single StartAngle, Single SweepAngle)
        {
            PagePie pl = new PagePie();

            pl.StartAngle = StartAngle;
            pl.SweepAngle = SweepAngle;

            StyleInfo SI = new StyleInfo();

            pl.X = X + recX * SCALEFACTOR;
            pl.Y = Y + recY * SCALEFACTOR;
            pl.W = recWidth * SCALEFACTOR;
            pl.H = recHeight * SCALEFACTOR;

            switch (b.GetType().Name)
            {
            case "SolidBrush":
                System.Drawing.SolidBrush theBrush = (System.Drawing.SolidBrush)b;
                SI.Color           = theBrush.Color;
                SI.BackgroundColor = theBrush.Color;
                break;

            case "LinearGradientBrush":
                System.Drawing.Drawing2D.LinearGradientBrush linBrush = (System.Drawing.Drawing2D.LinearGradientBrush)b;
                SI.BackgroundGradientType     = BackgroundGradientTypeEnum.LeftRight;
                SI.BackgroundColor            = linBrush.LinearColors[0];
                SI.BackgroundGradientEndColor = linBrush.LinearColors[1];
                break;

            case "HatchBrush":
                System.Drawing.Drawing2D.HatchBrush hatBrush = (System.Drawing.Drawing2D.HatchBrush)b;
                SI.BackgroundColor = hatBrush.BackgroundColor;
                SI.Color           = hatBrush.ForegroundColor;

                SI.PatternType = StyleInfo.GetPatternType(hatBrush.HatchStyle);
                break;

            default:
                break;
            }

            pl.SI = SI;
            items.Add(pl);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.DesignMode)
            {
                string versionString = ((AssemblyFileVersionAttribute)Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyFileVersionAttribute))).Version;
                string copyright     = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyCopyrightAttribute))).Copyright;

                using (Brush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SolidDiamond, Color.FromArgb(240, 240, 240), Color.White))
                    e.Graphics.FillRectangle(brush, this.ClientRectangle);

                e.Graphics.DrawString(
                    string.Format("Skybound GeckoFX v{0}\r\n{1}\r\n" + "http://www.geckofx.org", versionString, copyright),
                    SystemFonts.MessageBoxFont,
                    Brushes.Black,
                    new RectangleF(2, 2, this.Width - 4, this.Height - 4));
                e.Graphics.DrawRectangle(SystemPens.ControlDark, 0, 0, Width - 1, Height - 1);
            }
            base.OnPaint(e);
        }
Beispiel #28
0
            public surface_store(int i_surf_id, List <point2d> i_surface_nodes, List <edge2d> i_surface_edges, int surf_count)
            {
                this._surface_id = i_surf_id; // add surface id
                surface_nodes.AddRange(i_surface_nodes);
                surface_edges.AddRange(i_surface_edges);

                List <PointF> temp_sur_pts = new List <PointF>();

                //foreach (point2d pt in this.surface_nodes)
                //{
                //    temp_sur_pts.Add(pt.get_point());
                //}

                temp_sur_pts.Add(this.surface_edges[0].start_pt.get_point()); // Add the first point of the surface edge
                foreach (edge2d ed in this.surface_edges)
                {
                    temp_sur_pts.Add(ed.end_pt.get_point()); // since all the surface edges are interconnected only store the end points
                    //surface_path.AddLine(ed.start_pt.get_point(), ed.end_pt.get_point());
                }



                // Set the path of outter surface
                System.Drawing.Drawing2D.GraphicsPath surface_path = new System.Drawing.Drawing2D.GraphicsPath();
                surface_path.StartFigure();
                surface_path.AddPolygon(temp_sur_pts.ToArray());
                surface_path.CloseFigure();

                // set region
                surface_region = new Region(surface_path);


                Color hatch_color = Form1.the_static_class.GetRandomColor(surf_count);

                System.Drawing.Drawing2D.HatchStyle hatch_style = Form1.the_static_class.GetRandomHatchStyle(surf_count);
                Color trans_color = Color.FromArgb(0, 10, 10, 10);

                tri_brush = new System.Drawing.Drawing2D.HatchBrush(hatch_style, hatch_color, trans_color);

                signed_area_chk = this.SignedPolygonArea();
                surface_area    = Math.Abs(signed_area_chk);
            }
Beispiel #29
0
 private void buttonEasy_Click(object sender, EventArgs e)
 {
     zeichenfläche.Clear(BackColor);
     stift.Color = Color.Red;
     zeichenfläche.DrawRectangle(stift, 10, 10, 100, 100);
     stift.Color     = Color.Green;
     stift.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;
     stift.Width     = 3;
     zeichenfläche.DrawLine(stift, 0, 120, 100, 120);
     stift.Color     = Color.Blue;
     stift.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
     zeichenfläche.DrawLine(stift, 0, 140, 100, 140);
     stift.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
     stift.Width     = 10;
     zeichenfläche.DrawLine(stift, 0, 160, 100, 160);
     pinsel.Color = Color.Red;
     zeichenfläche.FillRectangle(pinsel, 150, 10, 90, 90);
     System.Drawing.Drawing2D.HatchBrush musterPinsel = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Cross, Color.Blue, Color.Green);
     zeichenfläche.FillRectangle(musterPinsel, 150, 110, 90, 90);
 }
Beispiel #30
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            if (this.Enabled)
            {
                System.Drawing.Drawing2D.HatchBrush hb = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.ForwardDiagonal, bkcolor, dwcolor);
                Pen p = new Pen(dwcolor);

                if (rect.Height < 2)
                {
                    e.Graphics.DrawLine(p, rect.X, rect.Y, rect.X + Width, rect.Y);
                }
                else
                {
                    e.Graphics.FillRectangle(hb, rect);
                }

                hb.Dispose();
                p.Dispose();
            }
        }
        public HatchBrush GetHatchBrush(HatchStyle style, SolidColor foreColor, SolidColor backColor)
        {
            HatchStyleBrushInfo info = new HatchStyleBrushInfo(style, foreColor, backColor);

            lock (this.hatchBrushes)
            {
                if (hatchBrushes.TryGetValue(info, out var hb))
                {
                    return(hb);
                }
                else
                {
                    HatchBrush b = new HatchBrush(style, foreColor, backColor);
                    hatchBrushes.Add(info, b);

                    Logger.Log("resource pool", "add hatch brush, count: " + hatchBrushes.Count);
                    return(b);
                }
            }
        }
Beispiel #32
0
        public EmfHatchFillBrush(BinaryReader _br)
        {
            Int32 HatchStyle = _br.ReadInt32();

            byte fA, fR, fG, fB;

            fB = _br.ReadByte();
            fG = _br.ReadByte();
            fR = _br.ReadByte();
            fA = _br.ReadByte();

            byte bA, bR, bG, bB;

            bB = _br.ReadByte();
            bG = _br.ReadByte();
            bR = _br.ReadByte();
            bA = _br.ReadByte();

            myBrush = new System.Drawing.Drawing2D.HatchBrush((System.Drawing.Drawing2D.HatchStyle)HatchStyle, Color.FromArgb(fA, fR, fG, fB), Color.FromArgb(bA, bR, bG, bB));
        }
Beispiel #33
0
        private void Redraw()
        {
            System.Drawing.Bitmap img = new System.Drawing.Bitmap(
                pictureBox1.ClientRectangle.Width, pictureBox1.ClientRectangle.Height);
            System.Drawing.Graphics g     = System.Drawing.Graphics.FromImage(img);
            System.Drawing.Pen      pen   = new System.Drawing.Pen(System.Drawing.Color.Black);
            System.Drawing.Brush    brush = new System.Drawing.Drawing2D.HatchBrush(
                System.Drawing.Drawing2D.HatchStyle.DiagonalCross, System.Drawing.Color.Red);

            foreach (SurfacePacker.RectHolder <object> r in packer)
            {
                g.FillRectangle(brush, Interop.Convert(r.Rect));
                g.DrawRectangle(pen, Interop.Convert(r.Rect));
            }

            g.Dispose();

            pictureBox1.Image = img;

            statusBar1.Panels[0].Text = "Percentage Used: " + (int)(packer.PixelsUsedPercentage * 100 + 0.5);
        }
Beispiel #34
0
        /// ///////////////////////
        protected override void MyDraw(CContextDessinObjetGraphique ctx)
        {
            Graphics g = ctx.Graphic;
            Brush    b;

            if (m_hatchStyle != null)
            {
                b = new System.Drawing.Drawing2D.HatchBrush(m_hatchStyle.Value, ForeColor, BackColor);
            }
            else
            {
                b = new SolidBrush(BackColor);
            }
            Rectangle rect = new Rectangle(Position, Size);

            //rect = contexte.ConvertToAbsolute(rect);
            g.FillEllipse(b, rect);
            b.Dispose();
            DrawCadre(g);
            base.MyDraw(ctx);
        }
Beispiel #35
0
        private void ImageYarat()
        {
            this.familyName = System.Drawing.FontFamily.GenericSerif.Name;

            // 32bit bmp yaratalim
            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(this.m_width, this.m_height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            // cizim icin bir graphics nesnesi yaratalim.
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            System.Drawing.Rectangle rec = new System.Drawing.Rectangle(0, 0, this.m_width, this.m_height);
            // Resimde arka alani dolduralim
            System.Drawing.Drawing2D.HatchBrush hb = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SmallConfetti, System.Drawing.Color.LightGray, System.Drawing.Color.White);
            g.FillRectangle(hb, rec);
            System.Drawing.Font font = new System.Drawing.Font(this.familyName, this.FontSize, System.Drawing.FontStyle.Bold);
            // textin formatini belirleyelim
            System.Drawing.StringFormat format = new System.Drawing.StringFormat();
            format.Alignment     = System.Drawing.StringAlignment.Center;
            format.LineAlignment = System.Drawing.StringAlignment.Center;
            // bir path belirleyip, texte random olarak aci verelim
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddString(this.m_text, font.FontFamily, (int)font.Style, font.Size, rec, format);
            float v = 4;

            System.Drawing.PointF[]         p      = { new System.Drawing.PointF(this.random.Next(rec.Width) / v, this.random.Next(rec.Height) / v), new System.Drawing.PointF(rec.Width - this.random.Next(rec.Width) / v, this.random.Next(rec.Height) / v), new System.Drawing.PointF(this.random.Next(rec.Width) / v, rec.Height - this.random.Next(rec.Height) / v), new System.Drawing.PointF(rec.Width - this.random.Next(rec.Width) / v, rec.Height - this.random.Next(rec.Height) / v) };
            System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
            matrix.Translate(0f, 0f);
            path.Warp(p, rec, matrix, System.Drawing.Drawing2D.WarpMode.Perspective, 0);
            hb = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.LargeConfetti, System.Drawing.Color.LightGray, System.Drawing.Color.Blue);
            g.FillPath(hb, path);
            for (int i = 0; i <= (int)(rec.Width * rec.Height / 30) - 1; i++)
            {
                int x = this.random.Next(rec.Width);
                int y = this.random.Next(rec.Height);
                int w = this.random.Next(rec.Width / 50);
                int h = this.random.Next(rec.Width / 40);
                g.FillEllipse(hb, x, y, w, h);
            }
            this.m_image = bitmap;
        }
Beispiel #36
0
		protected override void OnPaint(PaintEventArgs e)
		{
			System.Drawing.Pen pen = 
				new System.Drawing.Pen(this.ForeColor, 0);

			Rectangle rect = this.ClientRectangle;
			rect.Width -= 1;
			rect.Height -= 1;

			System.Drawing.Brush backBrush =
				new System.Drawing.Drawing2D.HatchBrush(
					System.Drawing.Drawing2D.HatchStyle.SmallCheckerBoard,
					this.ForeColor, this.BackColor);
			e.Graphics.FillRectangle(backBrush, rect);
			backBrush.Dispose();

			if (_brush != null)
				e.Graphics.FillRectangle(_brush, rect);
			e.Graphics.DrawRectangle(pen, rect);

            pen.Dispose();
		}
        void DrawLineBetweenPoints(Graphics g, Report rpt, Brush brush, Point[] points, int intLineSize)
        {
            if (points.Length <= 1)             // Need at least 2 points
            {
                return;
            }

            Pen p = null;

            try
            {
                if (brush.GetType() == typeof(System.Drawing.Drawing2D.HatchBrush))
                {
                    System.Drawing.Drawing2D.HatchBrush tmpBrush = (System.Drawing.Drawing2D.HatchBrush)brush;
                    p = new Pen(new SolidBrush(tmpBrush.ForegroundColor), intLineSize); //1.5F);    // todo - use line from style ????
                }
                else
                {
                    p = new Pen(brush, intLineSize);
                }

                if ((ChartSubTypeEnum)Enum.Parse(typeof(ChartSubTypeEnum), _ChartDefn.Subtype.EvaluateString(rpt, _row)) == ChartSubTypeEnum.Smooth && points.Length > 2)
                {
                    g.DrawCurve(p, points, 0.5F);
                }
                else
                {
                    g.DrawLines(p, points);
                }
            }
            finally
            {
                if (p != null)
                {
                    p.Dispose();
                }
            }
            return;
        }
Beispiel #38
0
        //        protected override CreateParams CreateParams
        //        {
        //            get
        //            {
        //                CreateParams cp = base.CreateParams;
        //                cp.ExStyle |= 0x20;
        //                return cp;
        //            }
        //        }
        //
        //        protected override void OnMove(EventArgs e)
        //        {
        //            RecreateHandle();
        //        }
        //
        //        protected override void OnPaintBackground(PaintEventArgs e)
        //        {
        //            // do nothing
        //        }
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);

            int ym;
            switch (LineVerticalAlign)
            {
                case LineVerticalAlign.Top:
                    ym = 0;
                    break;
                case LineVerticalAlign.Middle:
                    ym = Convert.ToInt32(Math.Ceiling((decimal)Size.Height / 2)) - 1;
                    break;
                case LineVerticalAlign.Bottom:
                    ym = Size.Height - 2;
                    break;
                default:
                    ym = 0;
                    break;
            }

            SizeF captionSizeF = e.Graphics.MeasureString(Caption, this.Font, this.Width - CaptionMarginSpace * 2, StringFormat.GenericDefault);
            int captionLength = Convert.ToInt32(captionSizeF.Width);

            int beforeCaption;
            int afterCaption;

            if (Caption == "")
            {
                beforeCaption = CaptionMarginSpace;
                afterCaption = CaptionMarginSpace;
            }
            else
            {
                switch (CaptionOrizontalAlign)
                {
                    case CaptionOrizontalAlign.Left:
                        beforeCaption = CaptionMarginSpace;
                        afterCaption = CaptionMarginSpace + CaptionPadding * 2 + captionLength;
                        break;
                    case CaptionOrizontalAlign.Center:
                        beforeCaption = (Width - captionLength) / 2 - CaptionPadding;
                        afterCaption = (Width - captionLength) / 2 + captionLength + CaptionPadding;
                        break;
                    case CaptionOrizontalAlign.Right:
                        beforeCaption = Width - CaptionMarginSpace * 2 - captionLength;
                        afterCaption = Width - CaptionMarginSpace;
                        break;
                    default:
                        beforeCaption = CaptionMarginSpace;
                        afterCaption = CaptionMarginSpace;
                        break;
                }
            }

            // Lines
            if (_LineOrientation == LineOrientation.Horizontal)
            {
                // -------
                // |      ...caption...
                e.Graphics.DrawLines(new Pen(SystemColors.ControlDark, 1),
                    new Point[] {
                                new Point(0, ym + 1),
                                new Point(0, ym),
                                new Point(beforeCaption, ym)
                            }
                    );

                //                  -------
                //	      ...caption...
                e.Graphics.DrawLines(new Pen(SystemColors.ControlDark, 1),
                    new Point[] {
                                new Point(afterCaption, ym),
                                new Point(this.Width, ym)
                            }
                    );

                //        ...caption...
                // -------
                e.Graphics.DrawLines(new Pen(SystemColors.ControlLightLight, 1),
                    new Point[] {
                                new Point(0, ym + 1),
                                new Point(beforeCaption, ym + 1)
                            }
                    );

                //        ...caption...       |
                //                  -------
                e.Graphics.DrawLines(new Pen(SystemColors.ControlLightLight, 1),
                    new Point[] {
                                new Point(afterCaption, ym + 1),
                                new Point(this.Width, ym + 1),
                                new Point(this.Width, ym)
                            }
                    );
            }
            else if (_LineOrientation == LineOrientation.Vertical)
            {
                System.Drawing.Drawing2D.HatchBrush aHatchBrush = new
                    System.Drawing.Drawing2D.HatchBrush
                    (System.Drawing.Drawing2D.HatchStyle.Vertical,
                    SystemColors.ControlLightLight,
                    SystemColors.ControlDark);

                Pen myPen = new Pen(aHatchBrush, 2);
                e.Graphics.DrawLine(myPen, beforeCaption / 2, 0, beforeCaption / 2, ClientRectangle.Height);
                myPen.Dispose(); aHatchBrush.Dispose();
            }

            // Render caption
            if (Caption != "")
            {
                switch (_LineOrientation)
                {
                    case LineOrientation.Horizontal:
                        e.Graphics.FillRectangle(new SolidBrush(BackColor),
                            beforeCaption + CaptionPadding, 1,
                            e.Graphics.MeasureString(Caption, this.Font).Width,
                            e.Graphics.MeasureString(Caption, this.Font).Height
                            );
                        e.Graphics.DrawString(Caption, this.Font, new SolidBrush(this.ForeColor), beforeCaption + CaptionPadding, 1);
                        break;
                    case LineOrientation.Vertical:
                        e.Graphics.FillRectangle(new SolidBrush(BackColor),
                            0, beforeCaption + CaptionPadding,
                            e.Graphics.MeasureString(Caption, this.Font).Height,
                            e.Graphics.MeasureString(Caption, this.Font).Width
                            );
                        e.Graphics.DrawString(Caption, this.Font, new SolidBrush(this.ForeColor), 0, beforeCaption + CaptionPadding, new StringFormat(StringFormatFlags.DirectionVertical));
                        break;
                }
            }

            //			e.Graphics.DrawLines(new Pen(Color.Red, 1),
            //				new Point[] {
            //								new Point(0, 0),
            //								new Point(this.Width-1, 0),
            //								new Point(this.Width-1, this.Height-1),
            //								new Point(0, this.Height-1),
            //								new Point(0, 0)
            //							}
            //				);
        }
Beispiel #39
0
 internal void DrawPlusMinusLines(Graphics g)
 {
     if(!IsInATreeListView) return;
     if(TreeListView._updating) return;
     Debug.Assert(!TreeListView.InvokeRequired);
     if(!TreeListView.ShowPlusMinus || TreeListView.Columns.Count == 0) return;
     int itemLevel = Level;
     Rectangle plusminusRect = GetBounds(TreeListViewItemBoundsPortion.PlusMinus);
     Rectangle entireRect = GetBounds(TreeListViewItemBoundsPortion.Entire);
     System.Drawing.Drawing2D.HatchBrush hb = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent50, TreeListView.PlusMinusLineColor, BackColor);
     Pen pen = new Pen(hb);
     Point point1, point2;
     #region Vertical line
     point1 = new Point(
         plusminusRect.Right - SystemInformation.SmallIconSize.Width / 2 - 1,
         entireRect.Top);
     point2 = new Point( point1.X, entireRect.Bottom);
     // If ListView has no items that have the same level before this item
     if(!HasLevelBeforeItem(itemLevel)) point1.Y += SystemInformation.SmallIconSize.Height / 2;
     // If ListView has no items that have the same level after this item
     if(!HasLevelAfterItem(itemLevel)) point2.Y -= SystemInformation.SmallIconSize.Height / 2 + 1;
     if(TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
         g.DrawLine(pen, point1, point2);
     #endregion
     #region Horizontal line
     point1 = new Point(
         plusminusRect.Right - SystemInformation.SmallIconSize.Width / 2 - 1,
         GetBounds(TreeListViewItemBoundsPortion.Entire).Top + SystemInformation.SmallIconSize.Height /2);
     point2 = new Point(plusminusRect.Right + 1, point1.Y);
     if(TreeListView.Columns[0].Width > (Level + 1) * SystemInformation.SmallIconSize.Width)
         g.DrawLine(pen, point1, point2);
     #endregion
     #region Lower Level lines
     for(int level = Level - 1; level > -1; level--)
         if(HasLevelAfterItem(level))
         {
             point1 = new Point(
                 SystemInformation.SmallIconSize.Width * (2*level + 1) / 2 + entireRect.X,
                 entireRect.Top);
             point2 = new Point(
                 point1.X, entireRect.Bottom);
             if(TreeListView.Columns[0].Width > (level + 1) * SystemInformation.SmallIconSize.Width)
                 g.DrawLine(pen, point1, point2);
         }
     #endregion
     pen.Dispose();
     hb.Dispose();
 }
Beispiel #40
0
        protected void GenerateImage()
        {
            Random random = new Random();
            // Create a new 32-bit bitmap image.
            Bitmap bitmap = new Bitmap(230,37,PixelFormat.Format32bppArgb);

            // Create a graphics object for drawing.
            System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            Rectangle rect = new Rectangle(0, 0, 230, 37);

            // Fill in the background.
            System.Drawing.Drawing2D.HatchBrush hatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent50, Color.LightGray, Color.White);
            //SolidBrush hatchBrush = new SolidBrush(Color.Red);

            String strText =(String)Session["ImageSID"];
            g.FillRectangle(hatchBrush, rect);

            // Set up the text font.
            SizeF size;
            float fontSize = rect.Height -12;
            // Adjust the font size until the text fits within the image.
             Font font = new Font("Century Schoolbook",fontSize, FontStyle.Bold);
                size = g.MeasureString(strText, font);
            // Set up the text format.
            StringFormat format = new StringFormat();
            format.Alignment = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            // Create a path using the text and warp it randomly.
            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddString(
              strText,
              font.FontFamily,
              (int)font.Style,
              font.Size, rect,
              format);
            float v = 12F;
            PointF[] points =
              {
            new PointF(
              random.Next(rect.Width) / v,
              random.Next(rect.Height) / v),
            new PointF(
              rect.Width - random.Next(rect.Width) / v,
              random.Next(rect.Height) / v),
            new PointF(
              random.Next(rect.Width) / v,
              rect.Height - random.Next(rect.Height) / v),
            new PointF(
              rect.Width - random.Next(rect.Width) / v,
              rect.Height - random.Next(rect.Height) / v)
              };
            //points={0,0,0,0};
            System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
            matrix.Translate(0F, 0F);
            path.Warp(points, rect, matrix, System.Drawing.Drawing2D.WarpMode.Perspective, 0F);

            // Draw the text.
            hatchBrush = new System.Drawing.Drawing2D.HatchBrush(
              System.Drawing.Drawing2D.HatchStyle.Percent50,
              Color.LightSlateGray,
              Color.DarkGray);
            g.FillPath(hatchBrush, path);

            // Add some random noise.
            int m = Math.Max(rect.Width, rect.Height);
            for (int i = 0; i < (int)(rect.Width * rect.Height / 30F); i++)
            {
                int x = random.Next(rect.Width);
                int y = random.Next(rect.Height);
                int w = random.Next(m / 50);
                int h = random.Next(m / 50);
                g.FillEllipse(hatchBrush, x, y, w, h);
            }

            // Clean up.
            font.Dispose();
            hatchBrush.Dispose();
            g.Dispose();

            // Set the image.
            this.Response.Clear();
            this.Response.ContentType = "image/jpeg";

            // Write the image to the response stream in JPEG format.
            bitmap.Save(this.Response.OutputStream, ImageFormat.Jpeg);

            // Dispose of the CAPTCHA image object.
            bitmap.Dispose();
        }
Beispiel #41
0
        private byte[] GenerateCaptchaImage(string text, int width, int height)
        {
            Random random = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), System.Globalization.NumberStyles.HexNumber));

            System.Drawing.Font font;
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bmp);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
            System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SmallConfetti, System.Drawing.Color.LightGray, System.Drawing.Color.White);
            graphics.FillRectangle(brush, rect);

            float emSize = rect.Height + 1;

            do {
                emSize--;
                font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, emSize, System.Drawing.FontStyle.Bold);
            } while (graphics.MeasureString(text, font).Width > rect.Width);

            System.Drawing.StringFormat format = new System.Drawing.StringFormat {
                Alignment = System.Drawing.StringAlignment.Center,
                LineAlignment = System.Drawing.StringAlignment.Center
            };

            System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
            path.AddString(text, font.FontFamily, (int)font.Style, 75f, rect, format);
            float num2 = 4f;
            System.Drawing.PointF[] destPoints = new System.Drawing.PointF[] { new System.Drawing.PointF(((float)random.Next(rect.Width)) / num2, ((float)random.Next(rect.Height)) / num2), new System.Drawing.PointF(rect.Width - (((float)random.Next(rect.Width)) / num2), ((float)random.Next(rect.Height)) / num2), new System.Drawing.PointF(((float)random.Next(rect.Width)) / num2, rect.Height - (((float)random.Next(rect.Height)) / num2)), new System.Drawing.PointF(rect.Width - (((float)random.Next(rect.Width)) / num2), rect.Height - (((float)random.Next(rect.Height)) / num2)) };
            System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix();
            matrix.Translate(0f, 0f);
            path.Warp(destPoints, rect, matrix, System.Drawing.Drawing2D.WarpMode.Perspective, 0f);
            brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Percent10, System.Drawing.Color.Black, System.Drawing.Color.SkyBlue);
            graphics.FillPath(brush, path);

            int num3 = Math.Max(rect.Width, rect.Height);
            for (int i = 0; i < ((int)(((float)(rect.Width * rect.Height)) / 30f)); i++) {
                int x = random.Next(rect.Width);
                int y = random.Next(rect.Height);
                int w = random.Next(num3 / 50);
                int h = random.Next(num3 / 50);
                graphics.FillEllipse(brush, x, y, w, h);
            }
            font.Dispose();
            brush.Dispose();
            graphics.Dispose();

            System.IO.MemoryStream imageStream = new System.IO.MemoryStream();
            bmp.Save(imageStream, System.Drawing.Imaging.ImageFormat.Jpeg);

            byte[] imageContent = new Byte[imageStream.Length];
            imageStream.Position = 0;
            imageStream.Read(imageContent, 0, (int)imageStream.Length);
            return imageContent;
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.DesignMode)
            {
                string versionString = ((AssemblyFileVersionAttribute)Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyFileVersionAttribute))).Version;
                string copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyCopyrightAttribute))).Copyright;

                using (Brush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SolidDiamond, Color.FromArgb(240, 240, 240), Color.White))
                    e.Graphics.FillRectangle(brush, this.ClientRectangle);

                e.Graphics.DrawString("OpenGeckoSharp v" + versionString + "\r\n" + copyright + "\r\n" + "http://devatan.tk/", SystemFonts.MessageBoxFont, Brushes.Black,
                    new RectangleF(2, 2, this.Width-4, this.Height-4));
                e.Graphics.DrawRectangle(SystemPens.ControlDark, 0, 0, Width-1, Height-1);
            }
            base.OnPaint(e);
        }
Beispiel #43
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (this.DesignMode)
            {
                string versionString = ((AssemblyFileVersionAttribute)Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyFileVersionAttribute))).Version;
                string copyright = ((AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyCopyrightAttribute))).Copyright;

                using (Brush brush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.SolidDiamond, Color.FromArgb(240, 240, 240), Color.White))
                    e.Graphics.FillRectangle(brush, this.ClientRectangle);

                e.Graphics.DrawString(String.Format("Skybound GeckoFX v{0}{1}{2}{1}http://www.geckofx.org", versionString, Environment.NewLine, copyright), SystemFonts.MessageBoxFont, Brushes.Black,
                    new RectangleF(2, 2, this.Width-4, this.Height-4));
                e.Graphics.DrawRectangle(SystemPens.ControlDark, 0, 0, Width-1, Height-1);
            }
            base.OnPaint(e);
        }
Beispiel #44
0
        public static Layer Parse(string FileName)
        {
            Layer lr = new Layer();
            StreamReader sr = new StreamReader((System.IO.Stream)File.OpenRead(FileName), System.Text.Encoding.Default);
            string str = null;
            str = sr.ReadLine();
            while (str.IndexOf("data", StringComparison.CurrentCultureIgnoreCase) == -1)
                str = sr.ReadLine();
            sr.ReadLine();
            while (!sr.EndOfStream)
            {
                str = sr.ReadLine();
                if (str.Contains("Point"))
                {
                    string[] Coords = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    str = sr.ReadLine();
                    Point p;
                    if (str.Contains("Symbol"))
                    {
                        string[] Symbol = str.Split(new char[] { ' ', ',', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
                        p = new Point(Convert.ToDouble(Coords[1]), Convert.ToDouble(Coords[2]), Convert.ToChar(Convert.ToInt32(Symbol[1]) + 1));
                        Color color = IntToColor(Convert.ToInt32(Symbol[2]));
                        p.SolidBrush = new SolidBrush(color);
                        p.Font = new Font("MapInfo Symbols", Convert.ToInt32(Symbol[3]));
                    }
                    else
                    {
                        p = new Point(Convert.ToDouble(Coords[1]), Convert.ToDouble(Coords[2]), '*');
                        p.SolidBrush = new SolidBrush(Color.Black);
                        p.Font = new Font("MapInfo Symbols", 18);
                    }
                    p.Visibility = true;
                    lr.AddMapObject(p);
                }
                else
                    if (str.Contains("Line"))
                    {
                        string[] Coords = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        str = sr.ReadLine();
                        Line l = new Line(Convert.ToDouble(Coords[1]), Convert.ToDouble(Coords[2]), Convert.ToDouble(Coords[3]), Convert.ToDouble(Coords[1]));
                        if (str.Contains("Pen"))
                        {
                            string[] Pen = str.Split(new char[] { ' ', ',', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
                            int Width = Convert.ToInt32(Pen[1]);
                            l.Visibility = true;
                            Color color = IntToColor(Convert.ToInt32(Pen[3]));
                            l.Pen = new Pen(color, Width);
                            switch (Pen[2])
                            {
                                case "1":
                                    l.Pen.Color = Color.FromArgb(0);
                                    break;
                                case "2":
                                    l.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                                    break;
                                case "3":
                                    l.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                    break;
                                case "4":
                                    l.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                    break;
                                case "5":
                                    l.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                                    break;
                                default:
                                    l.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                                    break;
                            }
                        }
                        else
                        {
                            l.Pen = new Pen(Color.Black, 5);
                            l.Visibility = true;
                        }
                        lr.AddMapObject(l);
                    }
                    else
                        if (str.Contains("Pline"))
                        {
                            string[] Pline = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                            string[] Coords;
                            List<Polyline> list = new List<Polyline>();
                            Polyline pl = null;
                            Pen p = null;
                            int numsections;
                            if (Pline.Length == 3)
                                numsections = Convert.ToInt32(Pline[2]); //Количество секций мультиполилинии
                            else
                                numsections = 1;
                            int counter = 0;
                            int numpts; //Количество точек в текущей секции
                            string[] ar;
                            while (counter < numsections)
                            {
                                if (Pline.Length == 2)
                                    numpts = Convert.ToInt32(Pline[1]);
                                else
                                {
                                    str = sr.ReadLine();
                                    ar = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    numpts = Convert.ToInt32(ar[0]);
                                }
                                counter++;
                                pl = new Polyline();
                                pl.Visibility = true;
                                for (int i = 0; i < numpts; i++)
                                {
                                    str = sr.ReadLine();
                                    Coords = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    pl.AddNode(Convert.ToDouble(Coords[0]), Convert.ToDouble(Coords[1]));
                                }
                                list.Add(pl);
                            }
                            str = sr.ReadLine();
                            if (str.Contains("Pen"))
                            {
                                string[] Pen = str.Split(new char[] { ' ', ',', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
                                int Width = Convert.ToInt32(Pen[1]);
                                Color color = IntToColor(Convert.ToInt32(Pen[3]));
                                p = new Pen(color, Width);
                                switch (Pen[2])
                                {
                                    case "1":
                                        p.Color = Color.FromArgb(0);
                                        break;
                                    case "2":
                                        p.DashStyle= System.Drawing.Drawing2D.DashStyle.Solid;
                                        break;
                                    case "3":
                                        p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                        break;
                                    case "4":
                                        p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                        break;
                                    case "5":
                                        p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                                        break;
                                    default:
                                        p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                                        break;
                                }
                            }
                            else
                            {
                                p = new Pen(Color.Black, 5);
                            }
                            foreach (Polyline polyline in list)
                            {
                                polyline.Pen = p;
                                lr.AddMapObject(polyline);
                            }
                        }
                        else
                            if (str.Contains("Region"))
                            {
                                Polygon pg = null;
                                System.Drawing.Brush br = null;
                                string[] Region = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                string[] Coords;
                                string[] Brush;
                                Color ForegroundColor;
                                Color BackgroundColor;
                                Pen p = null;
                                List<Polygon> list = new List<Polygon>();
                                int numsections = Convert.ToInt32(Region[1]); //Количество секций мультиполигона
                                int counter = 0;
                                string[] ar;
                                int numpts; //Количество вершин полигона в текущей секции
                                while (counter < numsections)
                                {
                                    str = sr.ReadLine();
                                    ar = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    numpts = Convert.ToInt32(ar[0]);
                                    pg = new Polygon();
                                    pg.Visibility = true;
                                    for (int i = 0; i < numpts; i++)
                                    {
                                        str = sr.ReadLine();
                                        Coords = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                        pg.AddNode(Convert.ToDouble(Coords[0]), Convert.ToDouble(Coords[1]));

                                    }
                                    counter++;
                                    list.Add(pg);
                                }
                                str = sr.ReadLine();
                                if (str.Contains("Pen"))
                                {
                                    string[] Pen = str.Split(new char[] { ' ', ',', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
                                    int Width = Convert.ToInt32(Pen[1]);
                                    Color color = IntToColor(Convert.ToInt32(Pen[3]));
                                    p = new Pen(color, Width);
                                    switch (Pen[2])
                                    {
                                        case "1":
                                            p.Color = Color.FromArgb(0);
                                            break;
                                        case "2":
                                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                                            break;
                                        case "3":
                                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                            break;
                                        case "4":
                                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                                            break;
                                        case "5":
                                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                                            break;
                                        default:
                                            p.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot;
                                            break;
                                    }
                                    str = sr.ReadLine();
                                }
                                else
                                    p = new Pen(Color.Black, 5);
                                if (str.Contains("Brush"))
                                {
                                    Brush = str.Split(new char[] { ' ', '(', ')', ',' }, StringSplitOptions.RemoveEmptyEntries);
                                    ForegroundColor = IntToColor(Convert.ToInt32(Brush[2]));
                                    if (Brush.Length == 4)
                                        BackgroundColor = IntToColor(Convert.ToInt32(Brush[3]));
                                    else
                                        BackgroundColor = Color.White;
                                    switch (Brush[1])
                                    {
                                        case "1":
                                            br = new System.Drawing.SolidBrush(Color.FromArgb(0));
                                            break;
                                        case "2":
                                            br = new System.Drawing.SolidBrush(ForegroundColor);
                                            break;
                                        case "3":
                                            br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Horizontal, ForegroundColor, BackgroundColor);
                                            break;
                                        case "4":
                                            br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.Vertical, ForegroundColor, BackgroundColor);
                                            break;
                                        case "5":
                                            br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.BackwardDiagonal, ForegroundColor, BackgroundColor);
                                            break;
                                        case "6":
                                            br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.ForwardDiagonal, ForegroundColor, BackgroundColor);
                                            break;
                                        default:
                                            br = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.LargeGrid, ForegroundColor, BackgroundColor);
                                            break;
                                    }
                                }
                                else
                                    br = new System.Drawing.SolidBrush(Color.Green);
                                foreach (Polygon polygon in list)
                                {
                                    polygon.Brush = br;
                                    polygon.Pen = p;
                                    lr.AddMapObject(polygon);
                                }

                            }
                            else
                                if (str.Contains("Text"))
                                {
                                    string[] Text = str.Split(new char[] { ' ', '"' }, StringSplitOptions.RemoveEmptyEntries);
                                    string[] Font;
                                    string text;
                                    string[] Coords;
                                    Text txt;
                                    SolidBrush sb;
                                    Font font;
                                    if (Text.Length == 2)
                                        text = Text[1];
                                    else
                                    {
                                        str = sr.ReadLine();
                                        Text = str.Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries);
                                        text = Text[0];
                                    }
                                    str = sr.ReadLine();
                                    Coords = str.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                    str = sr.ReadLine();
                                    if (str.IndexOf("font", StringComparison.CurrentCultureIgnoreCase) != -1)
                                    {
                                        FontStyle fs = FontStyle.Regular;
                                        Font = str.Split(new char[] { ' ', '"', ',', ')', '(', ']', '[' }, StringSplitOptions.RemoveEmptyEntries);
                                        sb = new SolidBrush(IntToColor(Convert.ToInt32(Font[4])));
                                        switch (Font[2])
                                        {
                                            case "1":
                                                fs = FontStyle.Bold;
                                                break;
                                            case "2":
                                                fs = FontStyle.Italic;
                                                break;
                                            case "3":
                                                fs = FontStyle.Underline;
                                                break;
                                        }
                                        font = new Font(Font[1], Convert.ToInt32(Font[3]), fs);
                                    }
                                    else
                                    {
                                        font = new Font("TimesNewRoman", 14);
                                        sb = new SolidBrush(Color.Black);
                                    }
                                    txt = new Text(text, font, Convert.ToDouble(Coords[0]), Convert.ToDouble(Coords[1]));
                                    txt.SolidBrush = sb;
                                    txt.Visibility = true;
                                    lr.AddMapObject(txt);
                                }
            }
            lr.MapObjects.Sort(delegate(MapObject mo1, MapObject mo2)
            { return mo1.Priority.CompareTo(mo2.Priority); });
            return lr;
        }
Beispiel #45
0
        private void UpdatePreview(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            int w = ctlPreview.Width;
            int h = ctlPreview.Height;
            float margX = (float)w / 10.0f;
            float margY = (float)h / 10.0f;
            float w16 = (float)w * 0.8f;
            float h16 = w16 / 16.0f * 9.0f;
            float w4 = h16 / 3.0f * 4.0f * (float)numNlsZoom.Value / 100.0f;
            float h4 = h16 * (float)numNlsZoom.Value / 100.0f;
            float wCenter4 = w4 * (float)numNlsCenterZone.Value / 100.0f ;
            float wCenterOrig4 = h16 / 3.0f * 4.0f * (float)numNlsCenterZone.Value / 100.0f;
            float wCenter16 = w4 * (float)numNlsCenterZone.Value / 100.0f * (float)numNlsStretchX.Value / 100.0f;
            float vertOff = (h4 - h16) * ((float)numNlsVertPos.Value /100.0f - 0.5f);

            e.Graphics.Clear(Color.White);

            PointF[] p = new PointF[4];

            // draw gradients

            p[0] = new PointF((w / 2 - w16 / 2), (h / 2 - h16 / 2));
            p[1] = new PointF((w / 2 - wCenter16 / 2), (h / 2 - h16 / 2));
            p[2] = new PointF((w / 2 - wCenter16 / 2), (h / 2 + h16 / 2));
            p[3] = new PointF((w / 2 - w16 / 2), (h / 2 + h16 / 2));

            System.Drawing.Drawing2D.LinearGradientBrush brOrangeGradientL = 
                new System.Drawing.Drawing2D.LinearGradientBrush(
                    new RectangleF(p[1], new SizeF((w16 - wCenterOrig4)/2, p[2].Y - p[0].Y)), 
                    Color.Orange, Color.White, 180, false);
            e.Graphics.FillPolygon(brOrangeGradientL, p);

            p[0] = new PointF((w / 2 + w16 / 2), (h / 2 - h16 / 2));
            p[1] = new PointF((w / 2 + wCenter16 / 2), (h / 2 - h16 / 2));
            p[2] = new PointF((w / 2 + wCenter16 / 2), (h / 2 + h16 / 2));
            p[3] = new PointF((w / 2 + w16 / 2), (h / 2 + h16 / 2));

            System.Drawing.Drawing2D.LinearGradientBrush brOrangeGradientR =
                new System.Drawing.Drawing2D.LinearGradientBrush(
                    new RectangleF(p[1], new SizeF((w16 - wCenterOrig4) / 2, p[2].Y - p[0].Y)),
                    Color.Orange, Color.White, 0, false);
            e.Graphics.FillPolygon(brOrangeGradientR, p);

            // draw 16:9 center zone

            p[0] = new PointF((w / 2 - wCenter16 / 2), (h / 2 - h16 / 2));
            p[1] = new PointF((w / 2 + wCenter16 / 2), (h / 2 - h16 / 2));
            p[2] = new PointF((w / 2 + wCenter16 / 2), (h / 2 + h16 / 2));
            p[3] = new PointF((w / 2 - wCenter16 / 2), (h / 2 + h16 / 2));

            e.Graphics.FillPolygon(Brushes.Orange, p);
            e.Graphics.DrawPolygon(Pens.Gold, p);

            // draw 4:3 center zone

            p[0] = new PointF((w / 2 - wCenter4 / 2), (h / 2 - h4 / 2) + vertOff);
            p[1] = new PointF((w / 2 + wCenter4 / 2), (h / 2 - h4 / 2) + vertOff);
            p[2] = new PointF((w / 2 + wCenter4 / 2), (h / 2 + h4 / 2) + vertOff);
            p[3] = new PointF((w / 2 - wCenter4 / 2), (h / 2 + h4 / 2) + vertOff);

            System.Drawing.Drawing2D.HatchBrush brGrayHatch =
                new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.BackwardDiagonal, Color.LightGray, Color.Transparent);
            e.Graphics.FillPolygon(brGrayHatch, p);

            // draw 4:3 rect

            p[0] = new PointF((w / 2 - w4 / 2), (h / 2 - h4 / 2) + vertOff);
            p[1] = new PointF((w / 2 + w4 / 2), (h / 2 - h4 / 2) + vertOff);
            p[2] = new PointF((w / 2 + w4 / 2), (h / 2 + h4 / 2) + vertOff);
            p[3] = new PointF((w / 2 - w4 / 2), (h / 2 + h4 / 2) + vertOff);

            e.Graphics.DrawPolygon(Pens.LightGray, p);

            // draw 16:9 rect

            p[0] = new PointF((w / 2 - w16 / 2), (h / 2 - h16 / 2));
            p[1] = new PointF((w / 2 + w16 / 2), (h / 2 - h16 / 2));
            p[2] = new PointF((w / 2 + w16 / 2), (h / 2 + h16 / 2));
            p[3] = new PointF((w / 2 - w16 / 2), (h / 2 + h16 / 2));

            e.Graphics.DrawPolygon(Pens.Red, p);

        }
Beispiel #46
0
		private void drawPolygon(Shapefile_Polygon polygon, Graphics g, Color c, GeographicBoundingBox dstBB, Size imageSize)
		{
			if(polygon.Parts.Length > 1)
			{
				if(m_ShapeTileArgs.PolygonFill)
				{
					if(m_ShapeTileArgs.ShapeFillStyle == ShapeFillStyle.Solid)
					{
						using(SolidBrush brush = new SolidBrush(c))
						{
							g.FillPolygon(brush, getScreenPoints(polygon.Points, 0, polygon.Parts[1], dstBB, imageSize));
						}
					}
					else
					{
						using(System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(
								  getGDIHatchStyle(m_ShapeTileArgs.ShapeFillStyle),
								  c,
								  System.Drawing.Color.Black))
						{
							g.FillPolygon(brush, getScreenPoints(polygon.Points, 0, polygon.Parts[1], dstBB, imageSize));
						}
					}
				}
				
				if(m_ShapeTileArgs.OutlinePolygons)
				{
					using(Pen p = new Pen(m_ShapeTileArgs.LineColor, m_ShapeTileArgs.LineWidth))
					{
						for(int partsItr = 0; partsItr < polygon.Parts.Length - 1; partsItr++)
						{
							g.DrawPolygon(p, 
								getScreenPoints(polygon.Points, polygon.Parts[partsItr], polygon.Parts[partsItr+1] - polygon.Parts[partsItr], dstBB, imageSize));
						}

						g.DrawPolygon(p, 
							getScreenPoints(polygon.Points, polygon.Parts[polygon.Parts.Length - 1],
							polygon.Points.Length - polygon.Parts[polygon.Parts.Length - 1], dstBB, imageSize)
							);
					}
				}

				if(m_ShapeTileArgs.PolygonFill)
				{
					if(m_ShapeTileArgs.ShapeFillStyle == ShapeFillStyle.Solid)
					{
						using(SolidBrush brush = new SolidBrush(System.Drawing.Color.Black))
						{
							for(int partsItr = 1; partsItr < polygon.Parts.Length - 1; partsItr++)
							{
								g.FillPolygon(brush, 
									getScreenPoints(polygon.Points, polygon.Parts[partsItr], polygon.Parts[partsItr+1] - polygon.Parts[partsItr], dstBB, imageSize)
									);
							}

							g.FillPolygon(brush, 
								getScreenPoints(polygon.Points, polygon.Parts[polygon.Parts.Length - 1],
								polygon.Points.Length - polygon.Parts[polygon.Parts.Length - 1], dstBB, imageSize)
								);
						}
					}
					else
					{
						using(System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(
								  getGDIHatchStyle(m_ShapeTileArgs.ShapeFillStyle),
								  c,
								  System.Drawing.Color.Black))
						{
							for(int partsItr = 1; partsItr < polygon.Parts.Length - 1; partsItr++)
							{
								g.FillPolygon(brush, 
									getScreenPoints(polygon.Points, polygon.Parts[partsItr], polygon.Parts[partsItr+1] - polygon.Parts[partsItr], dstBB, imageSize)
									);
							}

							g.FillPolygon(brush, 
								getScreenPoints(polygon.Points, polygon.Parts[polygon.Parts.Length - 1],
								polygon.Points.Length - polygon.Parts[polygon.Parts.Length - 1], dstBB, imageSize)
								);
						}
					}
				}				
			}
			else
			{
				if(m_ShapeTileArgs.PolygonFill)
				{
					if(m_ShapeTileArgs.ShapeFillStyle == ShapeFillStyle.Solid)
					{
						using(SolidBrush brush = new SolidBrush(c))
						{
							g.FillPolygon(brush, getScreenPoints(polygon.Points, 0, polygon.Points.Length, dstBB, imageSize));
						}
					}
					else
					{
						using(System.Drawing.Drawing2D.HatchBrush brush = new System.Drawing.Drawing2D.HatchBrush(
								  getGDIHatchStyle(m_ShapeTileArgs.ShapeFillStyle),
								  c,
								  System.Drawing.Color.Black))
						{
							g.FillPolygon(brush, getScreenPoints(polygon.Points, 0, polygon.Points.Length, dstBB, imageSize));
						}
					}
				}

				
				if(m_ShapeTileArgs.OutlinePolygons)
				{
					using(Pen p = new Pen(m_ShapeTileArgs.LineColor, m_ShapeTileArgs.LineWidth))
					{
						g.DrawPolygon(p, getScreenPoints(polygon.Points, 0, polygon.Points.Length, dstBB, imageSize));
					}
				}
			}
		}