Dispose() public method

public Dispose ( ) : void
return void
Esempio n. 1
0
 /// <summary>
 /// Invalidates <em>this</em> layer over the given Region. (In 1x1 space.)
 /// </summary>
 public void Invalidate(Region region)
 {
     if (this.Substrate != null)
     {
         System.Drawing.Region r = null;
         try {
             r = new System.Drawing.Region(region.GetRegionData());
             r.Transform(InvertMatrix(this.To1x1Transform));
             if (this.Substrate.InvokeRequired)
             {
                 this.Substrate.Invoke(new SubstrateInvalidateDelegate(SubstrateInvalidate), new object[] { r });
             }
             else
             {
                 this.Substrate.Invalidate(r);
             }
         }
         catch (System.ArgumentException ex) {
             // This happened once during live stream playback
             // apparently inside the Invert operation above.
             Debug.WriteLine(ex.ToString());
         }
         catch (InvalidOperationException ex) {
             // This can happen due to a GDI+ threading issue when trying to clone a Transform. "Object is in use elsewhere."
             Debug.WriteLine(ex.ToString());
         }
         finally {
             if (r != null)
             {
                 r.Dispose();
             }
         }
     }
     this.OnInvalidated(new RegionEventArgs(region));
 }
Esempio n. 2
0
		private void DrawPointerDown(Graphics g)
		{
			Point[] points = new Point[] { new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1), new Point(ThumbBounds.Left, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), ThumbBounds.Location, new Point(ThumbBounds.Right - 1, ThumbBounds.Top), new Point(ThumbBounds.Right - 1, (ThumbBounds.Bottom - (ThumbBounds.Width / 2)) - 1), new Point(ThumbBounds.Left + (ThumbBounds.Width / 2), ThumbBounds.Bottom - 1) };
			GraphicsPath path = new GraphicsPath();
			path.AddLines(points);
			Region region = new Region(path);
			g.Clip = region;

			if (ThumbState == 3 || !base.Enabled)
				ControlPaint.DrawButton(g, ThumbBounds, ButtonState.All);
			else
				g.Clear(SystemColors.Control);

			g.ResetClip();
			region.Dispose();
			path.Dispose();
			Point[] pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLightLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDarkDark, pointArray2);
			points[0].Offset(0, -1);
			points[1].Offset(1, 0);
			points[2].Offset(1, 1);
			points[3].Offset(-1, 1);
			points[4].Offset(-1, 0);
			points[5] = points[0];
			pointArray2 = new Point[] { points[0], points[1], points[2], points[3] };
			g.DrawLines(SystemPens.ControlLight, pointArray2);
			pointArray2 = new Point[] { points[3], points[4], points[5] };
			g.DrawLines(SystemPens.ControlDark, pointArray2);
		}
Esempio n. 3
0
 public override void Dispose()
 {
     if (rgn != null)
     {
         rgn.Dispose();
         rgn = null;
     }
 }
Esempio n. 4
0
 private void Form2_Load(object sender, EventArgs e)
 {
     GraphicsPath gp = new GraphicsPath();
     gp.AddEllipse(pic1.ClientRectangle);
     Region region = new Region(gp);
     pic1.Region = region;
     gp.Dispose();
     region.Dispose();
 }
Esempio n. 5
0
        private Vector2D method_3(string text, IList <Vector2D> characterAdvances)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(Vector2D.Zero);
            }
            Vector2D vector2D        = Vector2D.Zero;
            Graphics measureGraphics = Class940.MeasureGraphics;

            if (characterAdvances != null)
            {
                CharacterRange[] ranges = new CharacterRange[text.Length];
                for (int First = 0; First < text.Length; ++First)
                {
                    ranges[First] = new CharacterRange(First, 1);
                }
                StringFormat stringFormat = new StringFormat(StringFormat.GenericTypographic);
                stringFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap;
                stringFormat.SetMeasurableCharacterRanges(ranges);
                System.Drawing.Region[] regionArray = measureGraphics.MeasureCharacterRanges(text, this.class1060_0.Font, (RectangleF)Rectangle.Empty, stringFormat);
                if (regionArray.Length > 0)
                {
                    for (int index = 0; index < regionArray.Length; ++index)
                    {
                        System.Drawing.Region region = regionArray[index];
                        RectangleF            bounds = region.GetBounds(measureGraphics);
                        region.Dispose();
                        vector2D = new Vector2D((double)bounds.Right, 0.0);
                        characterAdvances.Add(vector2D);
                    }
                }
                stringFormat.Dispose();
            }
            else
            {
                CharacterRange[] ranges = new CharacterRange[1] {
                    new CharacterRange(0, text.Length)
                };
                StringFormat stringFormat = new StringFormat(StringFormat.GenericTypographic);
                stringFormat.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces | StringFormatFlags.NoWrap;
                stringFormat.SetMeasurableCharacterRanges(ranges);
                System.Drawing.Region[] regionArray = measureGraphics.MeasureCharacterRanges(text, this.class1060_0.Font, (RectangleF)Rectangle.Empty, stringFormat);
                if (regionArray.Length > 0)
                {
                    System.Drawing.Region region = regionArray[regionArray.Length - 1];
                    RectangleF            bounds = region.GetBounds(measureGraphics);
                    region.Dispose();
                    vector2D = new Vector2D((double)bounds.Right, 0.0);
                }
                stringFormat.Dispose();
            }
            return(vector2D);
        }
Esempio n. 6
0
        /// <summary>
        /// Paints to one image the series of layers between start and length
        /// and returns that image. Of all these layers, only start should have
        /// the UsesNonOpaqueOverwrite property true (and it need not have that
        /// property set to true).
        /// </summary>
        private void LayerSeriesPaint(int start, int length, Image image)
        {
            Debug.Assert(start >= 0 && start + length <= this.myLayers.Count && length > 0);

            // Establish the region that needs to be painted for all layers.
            // The region to be painted is union of all regions' dirty areas.
            System.Drawing.Region region = new System.Drawing.Region();
            for (int i = start; i < start + length; i++)
            {
                Debug.Assert(i == start ||
                             !((SlideViewLayer)this.myLayers[i]).UsesNonOpaqueOverwrite ||
                             !((SlideViewLayer)this.myLayers[i]).VisibleLayer);
                if (this.myLayerDirtyRegions[i] != null)
                {
                    region.Union((System.Drawing.Region) this.myLayerDirtyRegions[i]);
                }
            }

            // Set up the graphics context.
            Graphics g = Graphics.FromImage(image);

            g.Clip = region;

            // Clear the canvas for painting.
            g.Clear(Color.Transparent);

            // Paint the layers
            for (int i = start; i < start + length; i++)
            {
                if (((SlideViewLayer)this.myLayers[i]).VisibleLayer)
                {
                    ((SlideViewLayer)this.myLayers[i]).Paint(g);
                }
                if (this.myLayerDirtyRegions[i] != null)
                {
                    ((System.Drawing.Region) this.myLayerDirtyRegions[i]).Dispose();
                }
                this.myLayerDirtyRegions[i] = null;
            }

            g.Dispose();
            region.Dispose();
        }
Esempio n. 7
0
 public static Rectangle DrawIcons(Graphics gr, Rectangle aTextRect, CustomAppointment anAppointment, ImageList anAppIcons)
 {
     if ((anAppIcons != null) && (anAppointment.IconIndexes != null))
     {
         int length = anAppointment.IconIndexes.Length;
         int width = anAppIcons.ImageSize.Width;
         int num3 = aTextRect.Width / 3;
         if ((aTextRect.Width / 2) > width)
         {
             int x = (aTextRect.Right - 1) - width;
             int y = aTextRect.Y + 1;
             Region clip = gr.Clip;
             Region region2 = new Region(aTextRect);
             region2.Intersect(clip);
             gr.Clip = region2;
             for (int i = length - 1; i >= 0; i--)
             {
                 using (Image image = anAppIcons.Images[anAppointment.IconIndexes[i]])
                 {
                     Rectangle rect = new Rectangle(x, y, width, width);
                     DrawSingleIcon(gr, rect, image);
                 }
                 x -= width;
                 if (num3 >= (x - aTextRect.X))
                 {
                     aTextRect.Width -= width * (length - i);
                     return aTextRect;
                 }
             }
             gr.ResetClip();
             region2.Dispose();
             region2 = null;
             if (clip != null)
             {
                 gr.Clip = clip;
             }
             aTextRect.Width -= width * length;
         }
     }
     return aTextRect;
 }
Esempio n. 8
0
		private void Form1_Paint(object sender, PaintEventArgs e)
		{
			e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

			// Clip to path (with shape).
			Rectangle rectangle = new Rectangle(10, 10, 250, 50);
			GraphicsPath path = new GraphicsPath();
			path.AddEllipse(rectangle);
			e.Graphics.DrawPath(Pens.Red, path);
			
			// Set the clipping.
			Region clippingRegion = new Region(path);
			if (chkClipping.Checked) e.Graphics.Clip = clippingRegion;

			// Draw in the clipped region.
			e.Graphics.DrawString("Clipped", 
				new Font("Verdana", 36, FontStyle.Bold), Brushes.Black, 10, 10);

			clippingRegion.Dispose();
			path.Dispose();

			// Rest the clipping region.
			e.Graphics.ResetClip();
			
			// Clip to path (which represents text).
			path = new GraphicsPath();
			path.AddString("Clipped", new FontFamily("Verdana"), 0, 70, new Point(10, 130), new StringFormat());
			e.Graphics.DrawPath(Pens.Blue, path);

			// Set the clipping.
			clippingRegion = new Region(path);
			if (chkClipping.Checked) e.Graphics.Clip = clippingRegion;

			// Draw a series of ellipsis in the clipped region.
			for (int i = 0; i < 40; i++)
			{
				e.Graphics.DrawEllipse(Pens.Red, 180 - i*3, 180 - i*3, i*6, i*6);			
			}
			clippingRegion.Dispose();
			path.Dispose();
		}
Esempio n. 9
0
        public GraphicsContext(Graphics g)
        {
            Matrix transform = g.Transform;

            if (!transform.IsIdentity)
            {
                _transformOffset = transform.Offset;
            }
            transform.Dispose();

            Region clip = g.Clip;

            if (clip.IsInfinite(g))
            {
                clip.Dispose();
            }
            else
            {
                _clipRegion = clip;
            }
        }
        public GraphicsContext(Graphics g)
        {
            Matrix transform = g.Transform;

            if (!transform.IsIdentity)
            {
                float[] elements = transform.Elements;
                this.transformOffset.X = elements[4];
                this.transformOffset.Y = elements[5];
            }
            transform.Dispose();
            Region clip = g.Clip;

            if (clip.IsInfinite(g))
            {
                clip.Dispose();
            }
            else
            {
                this.clipRegion = clip;
            }
        }
        // 绘制剪裁效果,即除剪裁区域外整个图片的其他部分都绘制一层阴影。
        private void DrawCrop(Graphics g)
        {
            if ((this.Capture ||
                 ((_cropMode == false) ||
                  (_editMode == false))))
            {
                return;
            }
            if (_cropHelper.Empty)
            {
                return;
            }
            // 获取剪裁区域
            Rectangle area = _cropHelper.SelectedArea;

            // 绘制阴影区域
            System.Drawing.Region region = new System.Drawing.Region(_photoBounds);
            region.Exclude(area);
            g.FillRegion(_brushDimCrop, region);
            region.Dispose();
            // 绘制区域的边界
            ControlPaint.DrawFocusRectangle(g, _cropHelper.SelectedArea, Color.White, Color.Black);
        }
 private void ClearInsertionMark(ToolStripItem item)
 {
     if ((ToolStripDesigner.LastCursorPosition == Point.Empty) || (ToolStripDesigner.LastCursorPosition != Cursor.Position))
     {
         ToolStripKeyboardHandlingService keyBoardHandlingService = this.GetKeyBoardHandlingService(item);
         if ((keyBoardHandlingService == null) || !keyBoardHandlingService.TemplateNodeActive)
         {
             Rectangle empty = Rectangle.Empty;
             if ((item != null) && (item.Site != null))
             {
                 IDesignerHost service = (IDesignerHost) item.Site.GetService(typeof(IDesignerHost));
                 if (service != null)
                 {
                     empty = GetPaintingBounds(service, item);
                     empty.Inflate(1, 1);
                     Region r = new Region(empty);
                     try
                     {
                         empty.Inflate(-2, -2);
                         r.Exclude(empty);
                         BehaviorService behaviorService = this.GetBehaviorService(item);
                         if ((behaviorService != null) && (empty != Rectangle.Empty))
                         {
                             behaviorService.Invalidate(r);
                         }
                     }
                     finally
                     {
                         r.Dispose();
                         r = null;
                     }
                 }
             }
         }
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Paint the panel in which we depict the trial among its targets and show the path the mouse took.
        /// </summary>
        /// <param name="sender">The sender of this event.</param>
        /// <param name="e">The arguments for this event.</param>
        private void pnlTrial_Paint(object sender, PaintEventArgs e)
        {
            if (_tdata != null)
            {
                //
                // We'll have to map from the original trial area to where we're drawing here.
                //
                RectangleF rTo   = pnlTrial.ClientRectangle; // this panel's client area
                RectangleF rFrom = _sdata.ScreenBounds;      // the screen's boundaries used for these trials
                //(Note: Owner.ClientRectangle would work only if the trials were run on this same machine.)

                //
                // Our zoom slider allows zooming in or out (10%-190%). We have to carefully
                // adjust our percent: when rFrom shrinks, stuff drawn in rTo will enlarge,
                // and when rFrom enlarges, stuff drawn in rTo will shrink. So we can't
                // naively use the percent we get off the slider. It feels right enough.
                //
                float pct = 1f + (1f - trkZoom.Value / 100.0f);      // adjust
                rFrom = GeotrigEx.ScaleRectangleF(rFrom, pct * pct); // square

                //
                // If we're zoomed in past 100%, then perform semantic zooming to the endpoint click
                // by moving a percentage of the way from our default origin to having the point in
                // the dead center of the panel.
                //
                if (pct < 1f)
                {
                    rFrom.X = (float)GeotrigEx.MapValue(pct * pct, 1, 0, rFrom.X, _tdata.End.X - rFrom.Width / 2);
                    rFrom.Y = (float)GeotrigEx.MapValue(pct * pct, 1, 0, rFrom.Y, _tdata.End.Y - rFrom.Height / 2);
                }

                //
                // Draw all the targets for this condition.
                //
                foreach (System.Drawing.Region rgn in _cdata.TargetRegions)
                {
                    System.Drawing.Region grgn = GeotrigEx.MapRegion(rgn, rFrom, rTo);
                    e.Graphics.FillRegion(Brushes.LightGray, grgn);
                    rgn.Dispose();
                    grgn.Dispose();
                }

                //
                // Draw the active target for this condition.
                //
                System.Drawing.Region trgn = GeotrigEx.MapRegion(_tdata.TargetRegion, rFrom, rTo);
                e.Graphics.FillRegion(Brushes.DeepSkyBlue, trgn);
                trgn.Dispose();

                //
                // Draw the movement path.
                //
                Pen pen;
                if (_tdata.IsError)
                {
                    pen = new Pen(Color.Red);
                }
                else
                {
                    pen = new Pen(Color.Green);
                }

                for (int i = 1; i < _tdata.Movement.NumMoves; i++)
                {
                    TimePointF p0 = GeotrigEx.MapPoint(_tdata.Movement[i - 1], rFrom, rTo);
                    TimePointF p1 = GeotrigEx.MapPoint(_tdata.Movement[i], rFrom, rTo);
                    e.Graphics.DrawLine(pen, p0, p1);
                }

                //
                // Draw the start point as a hollow circle, and the end as an X.
                //
                PointF start = GeotrigEx.MapPoint(_tdata.Start, rFrom, rTo);
                PointF end   = GeotrigEx.MapPoint(_tdata.End, rFrom, rTo);

                pen.Width = 2f;
                e.Graphics.DrawEllipse(pen, start.X - 3f, start.Y - 3f, 6f, 6f);
                e.Graphics.DrawLine(pen, end.X - 5f, end.Y - 5f, end.X + 5f, end.Y + 5f);
                e.Graphics.DrawLine(pen, end.X - 5f, end.Y + 5f, end.X + 5f, end.Y - 5f);
                pen.Dispose();
            }
        }
Esempio n. 14
0
		/* 
			Horizontal trackbar 
		  
			Does not matter the size of the control, Win32 always draws:
				- Ticks starting from pixel 13, 8
				- Channel starting at pos 8, 19 and ends at Width - 8
				- Autosize makes always the control 45 pixels high
				- Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
				
		*/
		private void DrawTrackBar_Horizontal (Graphics dc, Rectangle clip_rectangle, TrackBar tb,
			ref Rectangle thumb_pos, ref Rectangle thumb_area, Brush br_thumb,
			float ticks, int value_pos, bool mouse_value) {			
			Point toptick_startpoint = new Point ();
			Point bottomtick_startpoint = new Point ();
			Point channel_startpoint = new Point ();
			float pixel_len;
			float pixels_betweenticks;
			Rectangle area = tb.ClientRectangle;
			
			GetTrackBarDrawingInfo (tb , out pixels_betweenticks, out thumb_area, out thumb_pos, out channel_startpoint, out bottomtick_startpoint, out toptick_startpoint);

			#region Track
			TrackBarDrawHorizontalTrack (dc, thumb_area, channel_startpoint, clip_rectangle);
			#endregion

			#region Thumb
			switch (tb.TickStyle) {
			case TickStyle.BottomRight:
			case TickStyle.None:
				thumb_pos.Y = channel_startpoint.Y - 8;
				TrackBarDrawHorizontalThumbBottom (dc, thumb_pos, br_thumb, clip_rectangle, tb);
				break;
			case TickStyle.TopLeft:
				thumb_pos.Y = channel_startpoint.Y - 10;
				TrackBarDrawHorizontalThumbTop (dc, thumb_pos, br_thumb, clip_rectangle, tb);
				break;
			default:
				thumb_pos.Y = area.Y + 10;
				TrackBarDrawHorizontalThumb (dc, thumb_pos, br_thumb, clip_rectangle, tb);
				break;
			}
			#endregion

			pixel_len = thumb_area.Width - 11;
			pixels_betweenticks = pixel_len / ticks;

			thumb_area.Y = thumb_pos.Y;
			thumb_area.X = channel_startpoint.X;
			thumb_area.Height = thumb_pos.Height;
			#region Ticks
			if (pixels_betweenticks <= 0)
				return;
			if (tb.TickStyle == TickStyle.None)
				return;
			Region outside = new Region (area);
			outside.Exclude (thumb_area);

			if (outside.IsVisible (clip_rectangle)) {
				ITrackBarTickPainter tick_painter = TrackBarGetHorizontalTickPainter (dc);

				if ((tb.TickStyle & TickStyle.BottomRight) == TickStyle.BottomRight) {
					float y = area.Y + bottomtick_startpoint.Y;
					for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {					
						float x = area.X + bottomtick_startpoint.X + inc;
						tick_painter.Paint (
							x, y, 
							x, y + (inc == 0 || inc + pixels_betweenticks >= pixel_len + 1 ? 3 : 2));
					}
				}

				if ((tb.TickStyle & TickStyle.TopLeft) == TickStyle.TopLeft) {
					float y = area.Y + toptick_startpoint.Y;
					for (float inc = 0; inc < pixel_len + 1; inc += pixels_betweenticks) {					
						float x = area.X + toptick_startpoint.X + inc;
						tick_painter.Paint (
							x, y - (inc == 0 || (inc + pixels_betweenticks) >= pixel_len + 1 ? 3 : 2), 
							x, y);
					}			
				}
			}
			
			outside.Dispose ();
			#endregion
		}
Esempio n. 15
0
 public void DrawControl(Graphics gr)
 {
     Region region = new Region(this.ClientRectangle);
     gr.Clip = region;
     Rectangle clientRectangle = this.ClientRectangle;
     int num = 0;
     for (int i = 0; i < this.m_Buttons.Count; i++)
     {
         if (this.m_Buttons[i].Visible)
         {
             num++;
         }
     }
     int x = this.m_Location.X + this.KMargin;
     int y = this.m_Location.Y + this.KMargin;
     int width = ((this.Width - this.KMargin) / num) - this.KMargin;
     int height = this.Height - (this.KMargin * 2);
     int num7 = 0;
     for (int j = 0; j < this.m_Buttons.Count; j++)
     {
         BottomBarButton aButton = this.m_Buttons[j];
         if (aButton.Visible)
         {
             this.m_Buttons[j].ClientRectangle = new Rectangle(x, y, width, height);
             this.DrawButton(gr, aButton);
             num7++;
             if (num7 == num)
             {
                 x += this.Width - (this.KMargin + width);
             }
             else
             {
                 x += this.KMargin + width;
             }
         }
     }
     gr.ResetClip();
     region.Dispose();
     region = null;
 }
Esempio n. 16
0
		void OnMouseLeave (object sender, EventArgs e)
		{
			Region region_to_invalidate = new Region ();
			region_to_invalidate.MakeEmpty ();
			bool dirty = false;
			if (ThemeEngine.Current.ScrollBarHasHoverArrowButtonStyle) {
				region_to_invalidate.Union (first_arrow_area);
				region_to_invalidate.Union (second_arrow_area);
				dirty = true;
			} else
				if (ThemeEngine.Current.ScrollBarHasHotElementStyles)
					if (first_button_entered) {
						region_to_invalidate.Union (first_arrow_area);
						dirty = true;
					} else if (second_button_entered) {
						region_to_invalidate.Union (second_arrow_area);
						dirty = true;
					}
			if (ThemeEngine.Current.ScrollBarHasHotElementStyles)
				if (thumb_entered) {
					region_to_invalidate.Union (thumb_pos);
					dirty = true;
				}
			first_button_entered = false;
			second_button_entered = false;
			thumb_entered = false;
			if (dirty)
				Invalidate (region_to_invalidate);
			region_to_invalidate.Dispose ();
		}
Esempio n. 17
0
        private void Invalidate(int i1, int i2)
        {
            Rectangle rect;

            if (i2 == -1)
            {
                i2 = i1;
            }

            rect = rectangles[i2];
            Region r = new Region(rect);
            if (i1 != -1)
            {
                try
                {
                    rect = rectangles[i1];
                    r.Union(rect);
                }
                catch (IndexOutOfRangeException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            r.Translate(AutoScrollPosition.X, AutoScrollPosition.Y);
            Invalidate(r);
            r.Dispose();
        }
Esempio n. 18
0
		internal void MouseMove(Point mouseLocation)
		{
			Region prevBtnRgn = new Region(m_prevBtnRect);
			Region nextBtnRgn = new Region(m_nextBtnRect);
			Region prevYearBtnRgn = new Region(m_prevYearBtnRect);
			Region nextYearBtnRgn = new Region(m_nextYearBtnRect);
            mcButtonState oldPrevMonthState = m_prevBtnState;
            mcButtonState oldNextMonthState = m_nextBtnState;
            mcButtonState oldPrevYearState = m_prevYearBtnState;
            mcButtonState oldNextYearState = m_nextYearBtnState;


			if (m_monthSelector)
			{
				// If not within left scroll button, make sure its not pushed
                if (!prevBtnRgn.IsVisible(mouseLocation))
                {
                    if (m_prevBtnState != mcButtonState.Inactive) m_prevBtnState = mcButtonState.Normal;
                }
                else if (m_prevBtnState != mcButtonState.Inactive)
                    m_prevBtnState = mcButtonState.Hot;

                if (oldPrevMonthState != m_prevBtnState)
                    DrawButton(m_calendar.CreateGraphics(),m_prevBtnState,mcHeaderButtons.PreviousMonth,m_prevBtnRect); 
                // If not within right scroll button, make sure its not pushed
                if (!nextBtnRgn.IsVisible(mouseLocation))
                {
                    if (m_nextBtnState != mcButtonState.Inactive) m_nextBtnState = mcButtonState.Normal;
                }
                else if (m_nextBtnState != mcButtonState.Inactive) 
                    m_nextBtnState = mcButtonState.Hot; 
			
                if (oldNextMonthState != m_nextBtnState)
                    DrawButton(m_calendar.CreateGraphics(), m_nextBtnState, mcHeaderButtons.NextMonth, m_nextBtnRect); 
            }
			if (m_yearSelector)
			{
				// If not within left scroll button, make sure its not pushed
                if (!prevYearBtnRgn.IsVisible(mouseLocation))
                {
                    if (m_prevYearBtnState != mcButtonState.Inactive) m_prevYearBtnState = mcButtonState.Normal;
                }
                else if (m_prevYearBtnState != mcButtonState.Inactive) 
                    m_prevYearBtnState = mcButtonState.Hot;

                if (oldPrevYearState != m_prevYearBtnState)
                    DrawButton(m_calendar.CreateGraphics(), m_prevYearBtnState, mcHeaderButtons.PreviousYear, m_prevYearBtnRect); 
          
						
				// If not within right scroll button, make sure its not pushed
                if (!nextYearBtnRgn.IsVisible(mouseLocation))
                {
                    if (m_nextYearBtnState != mcButtonState.Inactive) m_nextYearBtnState = mcButtonState.Normal;
                }
                else if (m_nextYearBtnState != mcButtonState.Inactive) 
                    m_nextYearBtnState = mcButtonState.Hot;

                if (oldNextYearState != m_nextYearBtnState)
                    DrawButton(m_calendar.CreateGraphics(), m_nextYearBtnState, mcHeaderButtons.NextYear, m_nextYearBtnRect); 
          
            }

			if (m_region.IsVisible(mouseLocation))
				m_calendar.ActiveRegion = mcCalendarRegion.Header;  
			
			
			prevBtnRgn.Dispose();
			nextBtnRgn.Dispose();
			prevYearBtnRgn.Dispose();
			nextYearBtnRgn.Dispose();

        }
Esempio n. 19
0
 private void PrepareTouchBackground(Graphics gr, Rectangle rect, Pen frame, out bool aNeedScrollbar)
 {
     int num = this.TouchBgrdHeight(rect);
     if (this.m_TouchBgrdHeight != num)
     {
         this.ResetTouchBgrd();
     }
     this.m_TouchBgrdHeight = num;
     if (this.m_Background == null)
     {
         this.m_ClientRectangle = rect;
         this.m_Background = new Bitmap(rect.Width, this.m_TouchBgrdHeight);
         this.m_indexChanged = true;
     }
     Graphics.FromImage(this.m_Background);
     Rectangle rectangle = rect;
     Region region = new Region(rect);
     gr.Clip = region;
     rectangle.Location = new Point(rect.X, rect.Y - this.m_VScrollShift);
     this.DrawBackground(gr, rectangle, frame, out aNeedScrollbar);
     gr.ResetClip();
     region.Dispose();
     region = null;
     this.m_OldNeedScrollbarState = aNeedScrollbar;
 }
Esempio n. 20
0
		public override void DataGridPaintRowContents (Graphics g, int row, Rectangle row_rect, bool is_newrow,
							       Rectangle clip, DataGrid grid)
		{
			Rectangle rect_cell = new Rectangle ();
			int col_pixel;
			Color backcolor, forecolor;
			Brush backBrush, foreBrush;
			Rectangle not_usedarea = Rectangle.Empty;

			rect_cell.Y = row_rect.Y;
			rect_cell.Height = row_rect.Height;

			if (grid.IsSelected (row)) {
				backcolor =  grid.SelectionBackColor;
				forecolor =  grid.SelectionForeColor;
			} else {
				if (row % 2 == 0) {
					backcolor =  grid.BackColor;
				} else {
					backcolor =  grid.AlternatingBackColor;
				}

				forecolor =  grid.ForeColor;
			}			


			backBrush = ResPool.GetSolidBrush (backcolor);
			foreBrush = ResPool.GetSolidBrush (forecolor);

			// PaintCells at row, column
			int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
			DataGridCell current_cell = grid.CurrentCell;

			if (column_cnt > 0) {
				Region prev_clip = g.Clip;
				Region current_clip;

				for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
					if (grid.CurrentTableStyle.GridColumnStyles[column].bound == false)
						continue;

					col_pixel = grid.GetColumnStartingPixel (column);

					rect_cell.X = row_rect.X + col_pixel - grid.HorizPixelOffset;
					rect_cell.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;

					if (clip.IntersectsWith (rect_cell)) {
						current_clip = new Region (rect_cell);
						current_clip.Intersect (row_rect);
						current_clip.Intersect (prev_clip);
						g.Clip = current_clip;

						Brush colBackBrush = backBrush;
						Brush colForeBrush = foreBrush;

						// If we are in the precise cell we are editing, then use the normal colors
						// even if we are selected.
						if (grid.is_editing && column == current_cell.ColumnNumber && row == current_cell.RowNumber) {
							colBackBrush = ResPool.GetSolidBrush (grid.BackColor);
							colForeBrush = ResPool.GetSolidBrush (grid.ForeColor);
						}

						if (is_newrow) {
							grid.CurrentTableStyle.GridColumnStyles[column].PaintNewRow (g, rect_cell, 
														     colBackBrush,
														     colForeBrush);
						} else {
							grid.CurrentTableStyle.GridColumnStyles[column].Paint (g, rect_cell, grid.ListManager, row,
													       colBackBrush,
													       colForeBrush,
													       grid.RightToLeft == RightToLeft.Yes);
						}

						current_clip.Dispose ();
					}
				}

				g.Clip = prev_clip;
			
				if (row_rect.X + row_rect.Width > rect_cell.X + rect_cell.Width) {
					not_usedarea.X = rect_cell.X + rect_cell.Width;
					not_usedarea.Width = row_rect.X + row_rect.Width - rect_cell.X - rect_cell.Width;
					not_usedarea.Y = row_rect.Y;
					not_usedarea.Height = row_rect.Height;
				}
			}
			else {
				not_usedarea = row_rect;
			}

			if (!not_usedarea.IsEmpty && clip.IntersectsWith (not_usedarea))
				g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor),
						 not_usedarea);
		}
Esempio n. 21
0
 private void Form1_Load(object sender, EventArgs e)
 {
     GraphicsPath gp = new GraphicsPath();
     gp.AddEllipse(pictureBox1.ClientRectangle);
     Region re = new System.Drawing.Region(gp);
     pictureBox1.Region = re;
     gp.Dispose();
     re.Dispose();
     cmbType.SelectedIndex = 0;  //选中返修类型的第一项
     // cmbStation.SelectedIndex = 0;
     label3.Text = clsCommon.userName + "  您好!";//显示用户名
     workID = clsCommon.userName;
     if (clsCommon.userPermissions == "超级用户")//设置用户权限
     {
         员工管理ToolStripMenuItem.Visible = true;
     }
     else
     {
         员工管理ToolStripMenuItem.Visible = false;
     }
     DataReflsh();
 }
Esempio n. 22
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                
                rangee = ClientRectangle.Width;
                inc = (maximum - minimum) / rangee;
                dra = (loopend1) / inc;
                dra2 = (loopstart1) / inc;
                //float fx = BLUE_Thumb.Width * .50f;
               // float fy = BLUE_Thumb.Height * .40f;
                //Bitmap offScreenBmp;
                //offScreenBmp = new Bitmap(this.Width, this.Height);
                //Graphics g = Graphics.FromImage(offScreenBmp);
                Rectangle destRect1 = new Rectangle(BLUE_Thumb.Left, BLUE_Thumb.Top, BLUE_Thumb.Width, BLUE_Thumb.Height);

                 GraphicsPath path = new GraphicsPath();
                

                    if (tricktype == TrickType.Round)
                    {
                        path.AddEllipse(destRect1);
                    }
                    else
                    {
                        path.AddRectangle(destRect1);
                    }
                    Region reg = new Region(path);


                  LinearGradientBrush lgb = new LinearGradientBrush(destRect1,
                       color_Trick1, color_Trick2, 90, true);
                  lgb.SetBlendTriangularShape(0.5f);

                        //Graphics g = BLUE_Thumb.CreateGraphics())
                        //g.FillRegion(lgb, reg);

                        BLUE_Thumb.Region = reg;
                    
                
                
                switch (m.Msg)
                {
                    case Api.WM_ERASEBKGND:
                        Bitmap bmp;
                        Rectangle srceRect;
                        Rectangle destRect;


                    
                        // Create a memory bitmap to use as double buffer
                        Bitmap offScreenBmp;
                        offScreenBmp = new Bitmap(this.Width, this.Height);
                       Graphics g = Graphics.FromImage(offScreenBmp);
                       //g.SmoothingMode = SmoothingMode.AntiAlias;
                        if (this.BackgroundImage != null)
                        {
                            bmp = new Bitmap(this.BackgroundImage);
                            srceRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
                            destRect = new Rectangle(0, 0, this.Width + 100, this.Height);
                            g.DrawImage(bmp, destRect, srceRect, GraphicsUnit.Pixel);
                            bmp.Dispose();
                        }
                        else
                        {
                            SolidBrush myBrush = new SolidBrush(this.BackColor);
                            g.FillRectangle(myBrush, 0, 0, this.Width, this.Height);
                            myBrush.Dispose();

                            
                           
                        }

                        Pen LEFTorTOPblue = new Pen(color_LEFTorTOPblue);
                        Pen LEFTorTOPdark = new Pen(color_LEFTorTOPdark);
                        Pen MIDDLEblue = new Pen(color_MIDDLEblue);

                        Pen MIDDLEdark = new Pen(color_MIDDLEdark);
                        Pen RIGHTorBOTTOMblue = new Pen(color_RIGHTorBOTTOMblue);
                        Pen RIGHTorBOTTOMdark = new Pen(color_RIGHTorBOTTOMdark);
                        Pen loopred=new Pen(Color.Red);

                        if (Orientation() == Horz)
                        {
                            int y = ClientRectangle.Height / 2;
                            if (y * 2 < ClientRectangle.Height) y -= 1;

                            if (Minimum > Maximum)
                            {
                                g.DrawLine(LEFTorTOPdark, new Point(0, y - 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y - 1));
                                g.DrawLine(LEFTorTOPblue, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y - 1), new Point(ClientRectangle.Width, y - 1));
                                g.DrawLine(MIDDLEdark, new Point(0, y), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y));
                                g.DrawLine(MIDDLEblue, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y), new Point(ClientRectangle.Width, y));
                                g.DrawLine(RIGHTorBOTTOMdark, new Point(0, y + 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y + 1));
                                g.DrawLine(RIGHTorBOTTOMblue, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y + 1), new Point(ClientRectangle.Width, y + 1));
                            }
                            else
                            {
                                g.DrawLine(LEFTorTOPblue, new Point(0, y - 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y - 1));
                                g.DrawLine(LEFTorTOPdark, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y - 1), new Point(ClientRectangle.Width, y - 1));
                                g.DrawLine(MIDDLEblue, new Point(0, y), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y));
                                g.DrawLine(MIDDLEdark, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y), new Point(ClientRectangle.Width, y));
                                g.DrawLine(RIGHTorBOTTOMblue, new Point(0, y + 1), new Point(BLUE_Thumb.Left + BLUE_Thumb.Width / 2, y + 1));
                                g.DrawLine(RIGHTorBOTTOMdark, new Point(BLUE_Thumb.Left + 1 + BLUE_Thumb.Width / 2, y + 1), new Point(ClientRectangle.Width, y + 1));
                                g.DrawLine(loopred, (int)(dra), y,(int)dra2, y);
                            }
                        }
                        else
                        {
                            int x = ClientRectangle.Width / 2;

                            if (Minimum > Maximum)
                            {
                                g.DrawLine(LEFTorTOPdark, new Point(x - 1, 0), new Point(x - 1, BLUE_Thumb.Top + BLUE_Thumb.Width / 2));
                                g.DrawLine(LEFTorTOPblue, new Point(x - 1, BLUE_Thumb.Top + 1 + BLUE_Thumb.Width / 2), new Point(x - 1, ClientRectangle.Height));
                                g.DrawLine(MIDDLEdark, new Point(x, 0), new Point(x, BLUE_Thumb.Top + BLUE_Thumb.Width / 2));
                                g.DrawLine(MIDDLEblue, new Point(x, BLUE_Thumb.Top + 1 + BLUE_Thumb.Width / 2), new Point(x, ClientRectangle.Height));
                                g.DrawLine(RIGHTorBOTTOMdark, new Point(x + 1, 0), new Point(x + 1, BLUE_Thumb.Top + BLUE_Thumb.Width / 2));
                                g.DrawLine(RIGHTorBOTTOMblue, new Point(x + 1, BLUE_Thumb.Top + 1 + BLUE_Thumb.Width / 2), new Point(x + 1, ClientRectangle.Height));
                            }
                            else
                            {
                                g.DrawLine(LEFTorTOPblue, new Point(x - 1, 0), new Point(x - 1, BLUE_Thumb.Top + BLUE_Thumb.Width / 2));
                                g.DrawLine(LEFTorTOPdark, new Point(x - 1, BLUE_Thumb.Top + 1 + BLUE_Thumb.Width / 2), new Point(x - 1, ClientRectangle.Height));
                                g.DrawLine(MIDDLEblue, new Point(x, 0), new Point(x, BLUE_Thumb.Top + BLUE_Thumb.Width / 2));
                                g.DrawLine(MIDDLEdark, new Point(x, BLUE_Thumb.Top + 1 + BLUE_Thumb.Width / 2), new Point(x, ClientRectangle.Height));
                                g.DrawLine(RIGHTorBOTTOMblue, new Point(x + 1, 0), new Point(x + 1, BLUE_Thumb.Top + BLUE_Thumb.Width / 2));
                                g.DrawLine(RIGHTorBOTTOMdark, new Point(x + 1, BLUE_Thumb.Top + 1 + BLUE_Thumb.Width / 2), new Point(x + 1, ClientRectangle.Height));
                            }
                        }

                        // Draw thumb tracker
                      //bmp = new Bitmap(BLUE_Thumb.BackgroundImage);
                       bmp = new Bitmap(BLUE_Thumb.Width,BLUE_Thumb.Height);
                        bmp.MakeTransparent(Color.FromArgb(255, 0, 255));
                        srceRect = new Rectangle(0, 0, BLUE_Thumb.Width, BLUE_Thumb.Height);
                        destRect = new Rectangle(BLUE_Thumb.Left, BLUE_Thumb.Top, BLUE_Thumb.Width, BLUE_Thumb.Height);
                         path = new GraphicsPath();
                        if (tricktype == TrickType.Round)
                        {
                            path.AddEllipse(destRect);
                        }
                        else
                        {
                            path.AddRectangle(destRect);
                        }
                        reg = new Region(path);
                        lgb = new LinearGradientBrush(destRect,
                              color_Trick1, color_Trick2, 90,true);
                        //lgb.SetBlendTriangularShape(0.5f);
                       
                                            g.FillRegion(lgb, reg);
                        BLUE_Thumb.Region = reg;
                       g.DrawImage(bmp, destRect, srceRect, GraphicsUnit.Pixel);
                        path.Dispose();
                        reg.Dispose();
                        //borderBrush.Dispose();
                        
                        lgb.Dispose();
                        bmp.Dispose();

                        
                            
                        

                        // Release pen resources
                        LEFTorTOPblue.Dispose();
                        LEFTorTOPdark.Dispose();
                        MIDDLEblue.Dispose();
                        MIDDLEdark.Dispose();
                        RIGHTorBOTTOMblue.Dispose();
                        RIGHTorBOTTOMdark.Dispose();

                        // Release graphics
                        g.Dispose();

                        // Swap memory bitmap (End double buffer)
                        g = Graphics.FromHdc(m.WParam);
                        g.DrawImage(offScreenBmp, 0, 0);
                        g.Dispose();
                        offScreenBmp.Dispose();

                        break;

                    default:
                        base.WndProc(ref m);
                        break;
                }
            }
            catch { };
        }
 internal void GiveFeedback(object sender, GiveFeedbackEventArgs e)
 {
     this.lastEffect = e.Effect;
     if ((this.data.Target == null) || (e.Effect == DragDropEffects.None))
     {
         if (this.clearDragImageRect != this.dragImageRect)
         {
             this.ClearAllDragImages();
             this.clearDragImageRect = this.dragImageRect;
         }
         if (this.dragAssistanceManager != null)
         {
             this.dragAssistanceManager.EraseSnapLines();
         }
     }
     else
     {
         bool flag = false;
         Point mousePosition = Control.MousePosition;
         bool flag2 = Control.ModifierKeys == Keys.Alt;
         if (flag2 && (this.dragAssistanceManager != null))
         {
             this.dragAssistanceManager.EraseSnapLines();
         }
         if (this.data.Target.Equals(this.data.Source) && (this.lastEffect != DragDropEffects.Copy))
         {
             e.UseDefaultCursors = false;
             Cursor.Current = Cursors.Default;
         }
         else
         {
             e.UseDefaultCursors = true;
         }
         Control target = this.data.Target as Control;
         if ((mousePosition != this.lastFeedbackLocation) || (flag2 && (this.dragAssistanceManager != null)))
         {
             if (!this.data.Target.Equals(this.lastDropTarget))
             {
                 this.serviceProviderTarget = target.Site;
                 if (this.serviceProviderTarget == null)
                 {
                     return;
                 }
                 IDesignerHost service = (IDesignerHost) this.serviceProviderTarget.GetService(typeof(IDesignerHost));
                 if (service == null)
                 {
                     return;
                 }
                 this.targetAllowsSnapLines = true;
                 ControlDesigner designer = service.GetDesigner(target) as ControlDesigner;
                 if ((designer != null) && !designer.ParticipatesWithSnapLines)
                 {
                     this.targetAllowsSnapLines = false;
                 }
                 this.statusCommandUITarget = new StatusCommandUI(this.serviceProviderTarget);
                 if ((this.lastDropTarget == null) || (service != this.destHost))
                 {
                     if ((this.destHost != null) && (this.destHost != this.srcHost))
                     {
                         this.behaviorServiceTarget.EnableAllAdorners(true);
                     }
                     this.behaviorServiceTarget = (BehaviorService) this.serviceProviderTarget.GetService(typeof(BehaviorService));
                     if (this.behaviorServiceTarget == null)
                     {
                         return;
                     }
                     this.GetParentSnapInfo(target, this.behaviorServiceTarget);
                     if (service != this.srcHost)
                     {
                         this.DisableAdorners(this.serviceProviderTarget, this.behaviorServiceTarget, true);
                     }
                     this.ClearAllDragImages();
                     if (this.lastDropTarget != null)
                     {
                         for (int i = 0; i < this.dragObjects.Count; i++)
                         {
                             Control c = (Control) this.dragObjects[i];
                             Rectangle rect = this.behaviorServiceSource.ControlRectInAdornerWindow(c);
                             rect.Location = this.behaviorServiceSource.AdornerWindowPointToScreen(rect.Location);
                             rect.Location = this.behaviorServiceTarget.MapAdornerWindowPoint(IntPtr.Zero, rect.Location);
                             if (i == 0)
                             {
                                 if (this.dragImageRegion != null)
                                 {
                                     this.dragImageRegion.Dispose();
                                 }
                                 this.dragImageRegion = new Region(rect);
                             }
                             else
                             {
                                 this.dragImageRegion.Union(rect);
                             }
                         }
                     }
                     if (this.graphicsTarget != null)
                     {
                         this.graphicsTarget.Dispose();
                     }
                     this.graphicsTarget = this.behaviorServiceTarget.AdornerWindowGraphics;
                     flag = true;
                     this.destHost = service;
                 }
                 this.lastDropTarget = this.data.Target;
             }
             if (this.ShowHideDragControls(this.lastEffect == DragDropEffects.Copy) && !flag)
             {
                 flag = true;
             }
             if (flag && this.behaviorServiceTarget.UseSnapLines)
             {
                 if (this.dragAssistanceManager != null)
                 {
                     this.dragAssistanceManager.EraseSnapLines();
                 }
                 this.dragAssistanceManager = new DragAssistanceManager(this.serviceProviderTarget, this.graphicsTarget, this.dragObjects, null, this.lastEffect == DragDropEffects.Copy);
             }
             Point pt = new Point((mousePosition.X - this.initialMouseLoc.X) + this.dragComponents[this.primaryComponentIndex].originalControlLocation.X, (mousePosition.Y - this.initialMouseLoc.Y) + this.dragComponents[this.primaryComponentIndex].originalControlLocation.Y);
             pt = this.MapPointFromSourceToTarget(pt);
             Rectangle dragBounds = new Rectangle(pt.X, pt.Y, this.dragComponents[this.primaryComponentIndex].dragImage.Width, this.dragComponents[this.primaryComponentIndex].dragImage.Height);
             if (this.dragAssistanceManager != null)
             {
                 if (this.targetAllowsSnapLines && !flag2)
                 {
                     this.lastSnapOffset = this.dragAssistanceManager.OnMouseMove(dragBounds);
                 }
                 else
                 {
                     this.dragAssistanceManager.OnMouseMove(new Rectangle(-100, -100, 0, 0));
                 }
             }
             else if (!this.parentGridSize.IsEmpty)
             {
                 this.lastSnapOffset = this.AdjustToGrid(pt);
             }
             pt.X += this.lastSnapOffset.X;
             pt.Y += this.lastSnapOffset.Y;
             this.dragComponents[this.primaryComponentIndex].draggedLocation = this.MapPointFromTargetToSource(pt);
             Rectangle dragImageRect = this.dragImageRect;
             pt = new Point((mousePosition.X - this.initialMouseLoc.X) + this.originalDragImageLocation.X, (mousePosition.Y - this.initialMouseLoc.Y) + this.originalDragImageLocation.Y) {
                 X = pt.X + this.lastSnapOffset.X,
                 Y = pt.Y + this.lastSnapOffset.Y
             };
             this.dragImageRect.Location = pt;
             dragImageRect.Location = this.MapPointFromSourceToTarget(dragImageRect.Location);
             Rectangle a = this.dragImageRect;
             a.Location = this.MapPointFromSourceToTarget(a.Location);
             Region region = new Region(Rectangle.Union(a, dragImageRect));
             region.Exclude(a);
             using (Region region2 = this.dragImageRegion.Clone())
             {
                 region2.Translate((int) ((mousePosition.X - this.initialMouseLoc.X) + this.lastSnapOffset.X), (int) ((mousePosition.Y - this.initialMouseLoc.Y) + this.lastSnapOffset.Y));
                 region2.Complement(a);
                 region2.Union(region);
                 this.behaviorServiceTarget.Invalidate(region2);
             }
             region.Dispose();
             if (this.graphicsTarget != null)
             {
                 this.graphicsTarget.SetClip(a);
                 this.graphicsTarget.DrawImage(this.dragImage, a.X, a.Y);
                 this.graphicsTarget.ResetClip();
             }
             Control dragComponent = this.dragComponents[this.primaryComponentIndex].dragComponent as Control;
             if (dragComponent != null)
             {
                 Point p = this.behaviorServiceSource.AdornerWindowPointToScreen(this.dragComponents[this.primaryComponentIndex].draggedLocation);
                 p = target.PointToClient(p);
                 if (target.IsMirrored && dragComponent.IsMirrored)
                 {
                     p.Offset(-dragComponent.Width, 0);
                 }
                 if (this.statusCommandUITarget != null)
                 {
                     this.statusCommandUITarget.SetStatusInformation(dragComponent, p);
                 }
             }
             if (((this.dragAssistanceManager != null) && !flag2) && this.targetAllowsSnapLines)
             {
                 this.dragAssistanceManager.RenderSnapLinesInternal();
             }
             this.lastFeedbackLocation = mousePosition;
         }
         this.data.Target = null;
     }
 }
Esempio n. 24
0
        private void dragSelector_Selected(object sender, DragSelectionEventArgs e)
        {
            List<object> pickedItems = new List<object>();
            Region region = new Region(e.Bounds);
            foreach (IPickingAdapter pickingAdapter in m_pickingAdapters)
            {
                pickedItems.AddRange(pickingAdapter.Pick(region));
            }
            region.Dispose();
            
            foreach (IPickingAdapter2 pickingAdapter in m_pickingAdapters2)
            {
                pickedItems.AddRange(pickingAdapter.Pick(e.Bounds));
            }

            Keys modifiers = Control.ModifierKeys;
            if ((modifiers & m_toggleModifierKey) != 0)
            {
                m_selectionContext.ToggleRange(pickedItems);
            }
            else if ((modifiers & m_extendModifierKey) != 0)
            {
                m_selectionContext.AddRange(pickedItems);
            }
            else
            {
                m_selectionContext.SetRange(pickedItems);
            }
        }
 protected override void OnPrintPage(PrintPageEventArgs printPageArg)
 {
     base.OnPrintPage(printPageArg);
     AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;
     Graphics graphics = printPageArg.Graphics;
     graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
     graphics.SmoothingMode = SmoothingMode.HighQuality;
     if (this.currentPrintablePage.IsEmpty)
     {
         this.PrepareToPrint(printPageArg);
     }
     Margins hardMargins = this.GetHardMargins(graphics);
     Margins margins2 = new Margins(Math.Max(printPageArg.PageSettings.Margins.Left, hardMargins.Left), Math.Max(printPageArg.PageSettings.Margins.Right, hardMargins.Right), Math.Max(printPageArg.PageSettings.Margins.Top, hardMargins.Top), Math.Max(printPageArg.PageSettings.Margins.Bottom, hardMargins.Bottom));
     Size size = new Size(printPageArg.PageBounds.Size.Width - (margins2.Left + margins2.Right), printPageArg.PageBounds.Size.Height - (margins2.Top + margins2.Bottom));
     Rectangle rect = new Rectangle(margins2.Left, margins2.Top, size.Width, size.Height);
     Region region = new Region(rect);
     try
     {
         graphics.TranslateTransform((float) -hardMargins.Left, (float) -hardMargins.Top);
         graphics.FillRectangle(ambientTheme.BackgroundBrush, rect);
         graphics.DrawRectangle(ambientTheme.ForegroundPen, rect);
         if (ambientTheme.WorkflowWatermarkImage != null)
         {
             ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, rect, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, 0.25f, false);
         }
         Matrix transform = graphics.Transform;
         Region clip = graphics.Clip;
         graphics.Clip = region;
         graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
         Point point = new Point((this.currentPrintablePage.X * size.Width) - this.workflowAlignment.X, (this.currentPrintablePage.Y * size.Height) - this.workflowAlignment.Y);
         graphics.TranslateTransform((float) (rect.Left - point.X), (float) (rect.Top - point.Y));
         graphics.ScaleTransform(this.scaling, this.scaling);
         Size empty = Size.Empty;
         empty.Width = Convert.ToInt32(Math.Ceiling((double) (((float) size.Width) / this.scaling)));
         empty.Height = Convert.ToInt32(Math.Ceiling((double) (((float) size.Height) / this.scaling)));
         Point point2 = Point.Empty;
         point2.X = Convert.ToInt32(Math.Ceiling((double) (((float) this.workflowAlignment.X) / this.scaling)));
         point2.Y = Convert.ToInt32(Math.Ceiling((double) (((float) this.workflowAlignment.Y) / this.scaling)));
         Rectangle viewPort = new Rectangle((this.currentPrintablePage.X * empty.Width) - point2.X, (this.currentPrintablePage.Y * empty.Height) - point2.Y, empty.Width, empty.Height);
         using (PaintEventArgs args = new PaintEventArgs(graphics, this.workflowView.RootDesigner.Bounds))
         {
             ((IWorkflowDesignerMessageSink) this.workflowView.RootDesigner).OnPaint(args, viewPort);
         }
         graphics.Clip = clip;
         graphics.Transform = transform;
         HeaderFooterData headerFooterPrintData = new HeaderFooterData {
             Font = ambientTheme.Font,
             PageBounds = printPageArg.PageBounds,
             PageBoundsWithoutMargin = rect,
             HeaderFooterMargins = new Margins(0, 0, this.pageSetupData.HeaderMargin, this.pageSetupData.FooterMargin),
             PrintTime = this.printTime,
             CurrentPage = (this.currentPrintablePage.X + (this.currentPrintablePage.Y * this.totalPrintablePages.X)) + 1,
             TotalPages = this.totalPrintablePages.X * this.totalPrintablePages.Y,
             Scaling = this.scaling
         };
         WorkflowDesignerLoader service = ((IServiceProvider) this.workflowView).GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
         headerFooterPrintData.FileName = (service != null) ? service.FileName : string.Empty;
         if (this.pageSetupData.HeaderTemplate.Length > 0)
         {
             this.PrintHeaderFooter(graphics, true, headerFooterPrintData);
         }
         if (this.pageSetupData.FooterTemplate.Length > 0)
         {
             this.PrintHeaderFooter(graphics, false, headerFooterPrintData);
         }
         printPageArg.HasMorePages = this.MoveNextPage();
     }
     catch (Exception exception)
     {
         DesignerHelpers.ShowError(this.workflowView, DR.GetString("SelectedPrinterIsInvalidErrorMessage", new object[0]) + "\n" + exception.Message);
         printPageArg.Cancel = true;
         printPageArg.HasMorePages = false;
     }
     finally
     {
         region.Dispose();
     }
     if (!printPageArg.HasMorePages)
     {
         this.workflowView.PerformLayout();
     }
 }
Esempio n. 26
0
		public override void DataGridPaintColumnHeaders (Graphics g, Rectangle clip, DataGrid grid)
		{
			if (!grid.CurrentTableStyle.ColumnHeadersVisible)
				return;

			Rectangle columns_area = grid.column_headers_area;

			// Paint corner shared between row and column header
			if (grid.CurrentTableStyle.CurrentRowHeadersVisible) {
				Rectangle rect_bloc = grid.column_headers_area;
				rect_bloc.Width = grid.RowHeaderWidth;
				if (clip.IntersectsWith (rect_bloc)) {
					if (grid.FlatMode)
						g.FillRectangle (ResPool.GetSolidBrush (grid.CurrentTableStyle.CurrentHeaderBackColor), rect_bloc);
					else
						CPDrawBorder3D (g, rect_bloc, Border3DStyle.RaisedInner, 
							Border3DSide.Left | Border3DSide.Right | 
							Border3DSide.Top | Border3DSide.Bottom | Border3DSide.Middle, 
							grid.CurrentTableStyle.CurrentHeaderBackColor);
				}

				columns_area.X += grid.RowHeaderWidth;
				columns_area.Width -= grid.RowHeaderWidth;
			}

			// Set column painting
			Rectangle rect_columnhdr = new Rectangle ();
			int col_pixel;
			Region current_clip;
			Region prev_clip = g.Clip;
			rect_columnhdr.Y = columns_area.Y;
			rect_columnhdr.Height = columns_area.Height;

			int column_cnt = grid.FirstVisibleColumn + grid.VisibleColumnCount;
			for (int column = grid.FirstVisibleColumn; column < column_cnt; column++) {
				if (grid.CurrentTableStyle.GridColumnStyles[column].bound == false)
					continue;
				
				col_pixel = grid.GetColumnStartingPixel (column);
				rect_columnhdr.X = columns_area.X + col_pixel - grid.HorizPixelOffset;
				rect_columnhdr.Width = grid.CurrentTableStyle.GridColumnStyles[column].Width;

				if (clip.IntersectsWith (rect_columnhdr) == false)
					continue;

				current_clip = new Region (rect_columnhdr);
				current_clip.Intersect (columns_area);
				current_clip.Intersect (prev_clip);
				g.Clip = current_clip;

				DataGridPaintColumnHeader (g, rect_columnhdr, grid, column);

				current_clip.Dispose ();
			}

			g.Clip = prev_clip;
				
			Rectangle not_usedarea = grid.column_headers_area;
			not_usedarea.X = (column_cnt == 0) ? grid.RowHeaderWidth : rect_columnhdr.X + rect_columnhdr.Width;
			not_usedarea.Width = grid.ClientRectangle.X + grid.ClientRectangle.Width - not_usedarea.X;
			g.FillRectangle (ResPool.GetSolidBrush (grid.BackgroundColor), not_usedarea);
		}
Esempio n. 27
0
        // While still in design this function draws directly to the component.
        // Once design is complete it will paint to a image, then the image painted to the component for a little speed boost.
        private void DrawKillCircles(Graphics g, Kill kKill, KillDisplayDetails kddKillDetails) {

            PointF pntLineStart = new PointF((float)kKill.KillerLocation.X, (float)kKill.KillerLocation.Y);
            PointF pntLineEnd = new PointF((float)kKill.VictimLocation.X, (float)kKill.VictimLocation.Y);
            PointF pntLineHalfway = new PointF(pntLineStart.X - (pntLineStart.X - pntLineEnd.X) / 2, pntLineStart.Y - (pntLineStart.Y - pntLineEnd.Y) / 2 - 3);
            PointF pntLineHalfway2 = new PointF(pntLineStart.X - (pntLineStart.X - pntLineEnd.X) / 2, pntLineStart.Y - (pntLineStart.Y - pntLineEnd.Y) / 2 - 4);

            LinearGradientBrush killBrush = this.GetKillColour(this.KillColours, kKill, kddKillDetails);

            GraphicsPath gpKillCircles = new GraphicsPath();
            gpKillCircles.AddEllipse(new Rectangle(kKill.KillerLocation.X - this.ErrorRadius, kKill.KillerLocation.Y - this.ErrorRadius, this.ErrorRadius * 2, this.ErrorRadius * 2));
            gpKillCircles.AddEllipse(new Rectangle(kKill.VictimLocation.X - this.ErrorRadius, kKill.VictimLocation.Y - this.ErrorRadius, this.ErrorRadius * 2, this.ErrorRadius * 2));
            gpKillCircles.FillMode = FillMode.Winding;

            //GraphicsPath gpKill = new GraphicsPath();
            GraphicsPath gpKill = (GraphicsPath)gpKillCircles.Clone();
            gpKill.AddClosedCurve(new PointF[] { pntLineStart, pntLineHalfway, pntLineEnd, pntLineHalfway2 });
            //gpKill.AddEllipse(new Rectangle(kKill.KillerLocation.X - this.ErrorRadius, kKill.KillerLocation.Y - this.ErrorRadius, this.ErrorRadius * 2, this.ErrorRadius * 2));
            //gpKill.AddEllipse(new Rectangle(kKill.VictimLocation.X - this.ErrorRadius, kKill.VictimLocation.Y - this.ErrorRadius, this.ErrorRadius * 2, this.ErrorRadius * 2));
            gpKill.FillMode = FillMode.Winding;

            GraphicsPath gpKillOutline = (GraphicsPath)gpKill.Clone();
            //GraphicsPath gpKillOutline = new GraphicsPath(gpKill.PathPoints, gpKill.PathTypes);
            Matrix gpKillMatrix = new Matrix();
            gpKillOutline.Widen(this.m_pTwoWidth, gpKillMatrix, 0.01F);

            Region reKillOutline = new Region(gpKillOutline);
            reKillOutline.Exclude(gpKill);
            reKillOutline.Exclude(gpKillCircles);

            Region reKill = new Region(gpKill);
            reKill.Union(gpKillCircles);

            //Region reKillDropshadow = new Region(gpKill);
            //reKillDropshadow.Union(gpKillCircles);
            //reKillDropshadow.Union(reKillOutline);
            //reKillDropshadow.Translate(0.4F, 1.0F);

            if (reKill.IsVisible(this.ClientPointToGame(this.PointToClient(Cursor.Position))) == true) {
                kddKillDetails.IsMouseOver = true;
                kddKillDetails.Opacity = 1.0F;
            }
            else {
                kddKillDetails.IsMouseOver = false;
            }

            //g.FillRegion(new SolidBrush(Color.FromArgb((int)(64.0F * kddKillDetails.Opacity), Color.Black)), reKillDropshadow);
            g.FillRegion(killBrush, reKill);
            g.FillRegion(new SolidBrush(Color.FromArgb((int)(255.0F * kddKillDetails.Opacity), Color.Black)), reKillOutline);

            if (this.LoadedMapImagePack != null) {

                Image imgDeathIcon = null;
                if (kKill.Headshot == true) {
                    imgDeathIcon = this.LoadedMapImagePack.CompensateImageRotation(this.LoadedMapImagePack.GetIcon("Headshot"));
                }
                else {
                    imgDeathIcon = this.LoadedMapImagePack.CompensateImageRotation(this.LoadedMapImagePack.GetIcon("Death"));
                }

                if (imgDeathIcon != null) {
                    ColorMatrix colormatrix = new ColorMatrix();
                    colormatrix.Matrix00 = 1.0F;
                    colormatrix.Matrix11 = 1.0F;
                    colormatrix.Matrix22 = 1.0F;
                    colormatrix.Matrix33 = kddKillDetails.Opacity;
                    colormatrix.Matrix44 = 1.0F;
                    ImageAttributes imgattr = new ImageAttributes();
                    imgattr.SetColorMatrix(colormatrix);

                    Rectangle destRect = new Rectangle((int)pntLineEnd.X - 12, (int)pntLineEnd.Y - 12, 24, 24);
                    g.DrawImage(imgDeathIcon, destRect, 0, 0, imgDeathIcon.Width, imgDeathIcon.Height, GraphicsUnit.Pixel, imgattr);

                    imgattr.Dispose();
                    imgDeathIcon.Dispose();
                }
            }

            this.DrawMapText(g, kKill.Victim.SoldierName, kKill.VictimLocation, 16, kddKillDetails.Opacity);
            this.DrawMapText(g, kKill.Killer.SoldierName, kKill.KillerLocation, 16, kddKillDetails.Opacity);

            killBrush.Dispose();
            gpKillCircles.Dispose();
            gpKill.Dispose();
            gpKillOutline.Dispose();
            gpKillMatrix.Dispose();
            reKill.Dispose();
        }
Esempio n. 28
0
		public override void DataGridPaintParentRows (Graphics g, Rectangle clip, DataGrid grid)
		{
			Rectangle rect_row = new Rectangle ();

			rect_row.X = grid.ParentRowsArea.X;
			rect_row.Width = grid.ParentRowsArea.Width;
			rect_row.Height = (grid.CaptionFont.Height + 3);

			object[] parentRows = grid.data_source_stack.ToArray();
			
			Region current_clip;
			Region prev_clip = g.Clip;
			for (int row = 0; row < parentRows.Length; row++) {
				rect_row.Y = grid.ParentRowsArea.Y + row * rect_row.Height;

				if (clip.IntersectsWith (rect_row) == false)
					continue;

				current_clip = new Region (rect_row);
				current_clip.Intersect (prev_clip);
				g.Clip = current_clip;

				DataGridPaintParentRow (g, rect_row, (DataGridDataSource)parentRows[parentRows.Length - row - 1], grid);

				current_clip.Dispose ();
			}
			
			g.Clip = prev_clip;
		}
Esempio n. 29
0
 protected void DrawText(Graphics gr, ToolbarItem anItem, Rectangle aClientRect)
 {
     if ((anItem.Text != null) && (anItem.Text.Length != 0))
     {
         int num4;
         int num5;
         SolidBrush brush = new SolidBrush(anItem.ForeColor);
         string[] strArray = anItem.Text.Replace(@"\n", @"\").Split(new char[] { '\\' });
         SizeF ef = new SizeF(0f, 0f);
         float width = 0f;
         float height = 0f;
         for (int i = 0; i < strArray.Length; i++)
         {
             ef = gr.MeasureString(strArray[i], anItem.Font);
             if (width < ef.Width)
             {
                 width = ef.Width;
             }
             if (height < ef.Height)
             {
                 height = ef.Height;
             }
         }
         SizeF textSize = new SizeF(width, height * strArray.Length);
         this.GetTextLocation(anItem, aClientRect, textSize, out num4, out num5);
         Rectangle layoutRectangle = new Rectangle(aClientRect.X + num4, aClientRect.Y + num5, ((int) textSize.Width) + 1, ((int) textSize.Height) + 1);
         layoutRectangle.Height = (int) height;
         Region region = new Region(aClientRect);
         gr.Clip = region;
         StringFormat stringFormat = this.GetStringFormat(anItem.TextAlignment);
         for (int j = 0; j < strArray.Length; j++)
         {
             gr.DrawString(strArray[j], anItem.Font, brush, layoutRectangle, stringFormat);
             layoutRectangle.Y += (int) height;
         }
         gr.ResetClip();
         region.Dispose();
         region = null;
         brush.Dispose();
         brush = null;
     }
 }
Esempio n. 30
0
		private void drawCells(Graphics g, System.Drawing.Pen pen,
			System.Drawing.Brush brText, RectangleF rc)
		{
			// DrawBorder3D does not honor clipping, so...
			CellFrameStyle cb = cellBorders;
			if (flowChart.NowPrinting && cb == CellFrameStyle.System3D)
				cb = CellFrameStyle.Simple;

			// draw the cells
			if (cells != null)
			{
				bool[,] coveredCells =
					hasSpanningCells ? getCoveredCells() : null;
				RectangleF cellsRect = RectangleF.FromLTRB(rc.Left,
					rc.Top + captionHeight, rc.Right, rc.Bottom);

				int rowFrom = CurrentRow - maxRowSpan + 1;
				if (rowFrom < 0)
					rowFrom = 0;

				float h = rc.Top + captionHeight;
				for (int r = rowFrom; r < rowsCount; r++)
				{
					RectangleF cellRect = rc;
					cellRect.Y = h;
					if (cellRect.Top >= rc.Bottom) break;

					cellRect.Height = ((Row)rowsList[r]).Height;

					if (cellRect.Bottom >= rc.Bottom) break;

					// If it is a hidden row below a collapsed header row, skip it
					if (isRowCollapsed(r))
						continue;

					if (rowFrom >= currScrollRow)
						h += ((Row)rowsList[r]).Height;

					for (int c = 0; c < columnsCount; ++c)
					{
						RectangleF imgRect = RectangleF.Empty;
						cellRect = getSpannedCellRect(r, c, true, ref imgRect);

						if (cellRect.Height == 0 ||
							cellRect.Width == 0 ||
							cellRect.Bottom <= cellsRect.Top)
							continue;

						Cell cell = (Cell)cells[r * columnsCount + c];

						if (!hasSpanningCells)
						{
							cell.draw(g, pen, brText, cellRect, Font, cb, r, c, imgRect);
						}
						else
						{
							// If the cell is covered by a spanned cell
							// and is not a span cell itself, do not draw it
							if (!coveredCells[c,r] ||
								(cell.RowSpan != 1 || cell.ColumnSpan != 1))
							{
								if (cell.RowSpan != 1 || cell.ColumnSpan != 1)
								{
									RectangleF cellVisibleRect =
										RectangleF.Intersect(cellRect, cellsRect);

									// Clip with the visible rect, and draw in the
									// absolute rect
									Region oldClip = g.Clip;
									Region newClip = new Region(cellVisibleRect);
									newClip.Intersect(oldClip);
									g.Clip = newClip;

									cell.draw(g, pen, brText, cellRect, Font, cb, r, c, imgRect);

									g.Clip = oldClip;
									newClip.Dispose();
								}
								else
								{
									cell.draw(g, pen, brText, cellRect, Font, cb, r, c, imgRect);
								}
							}
						}

						cellRect.X = cellRect.Right;
						if (cellRect.Left >= rc.Right) break;
					}
				}
			}
		}
Esempio n. 31
0
		internal bool ImageHitTest(Point p)
		{
			
			bool status = false;
			if ((!m_userDrawn) && (m_dayImage!=null) && (Month.EnableImageClick))
			{				  
				Region r = new Region(m_imageRect);
				if (r.IsVisible(p))
					status = true;
				else
					status = false;
				r.Dispose();
			}

			return status;

		}
Esempio n. 32
0
		internal void MouseClick(Point mouseLocation, MouseButtons button, mcClickMode mode)
		{
			Region leftBtnRgn = new Region(m_prevBtnRect);
			Region rightBtnRgn = new Region(m_nextBtnRect);
			Region leftYearBtnRgn = new Region(m_prevYearBtnRect);
			Region rightYearBtnRgn = new Region(m_nextYearBtnRect);
			MouseButtons selectButton;
			
			if (SystemInformation.MouseButtonsSwapped)
				selectButton = MouseButtons.Right;
			else
				selectButton = MouseButtons.Left;

			bool btnClick = false;
			
			if (m_region.IsVisible(mouseLocation))
			{
				if (button == selectButton)
				{
					if (m_monthSelector)
					{
						if ( (leftBtnRgn.IsVisible(mouseLocation)) &&  (m_prevBtnState!=mcButtonState.Inactive) &&
							(m_prevBtnState!=mcButtonState.Pushed) )
						{
							m_prevBtnState = mcButtonState.Pushed;
							if (this.PrevMonthButtonClick!=null)
								this.PrevMonthButtonClick(this,new EventArgs());			
							btnClick = true;
						}
						if ( (rightBtnRgn.IsVisible(mouseLocation)) && (m_nextBtnState!=mcButtonState.Inactive) &&
							(m_nextBtnState!=mcButtonState.Pushed) )
						{
							m_nextBtnState = mcButtonState.Pushed;
							if (this.NextMonthButtonClick!=null)
								this.NextMonthButtonClick(this,new EventArgs());
							btnClick = true;
						}
					}
					if (m_yearSelector)
					{
						if ( (leftYearBtnRgn.IsVisible(mouseLocation)) &&  (m_prevYearBtnState!=mcButtonState.Inactive) &&
							(m_prevYearBtnState!=mcButtonState.Pushed) )
						{
							m_prevYearBtnState = mcButtonState.Pushed;
							if (this.PrevYearButtonClick!=null)
								this.PrevYearButtonClick(this,new EventArgs());			
							btnClick = true;
						}
						if ( (rightYearBtnRgn.IsVisible(mouseLocation)) && (m_nextYearBtnState!=mcButtonState.Inactive) &&
							(m_nextYearBtnState!=mcButtonState.Pushed) )
						{
							m_nextYearBtnState = mcButtonState.Pushed;
							if (this.NextYearButtonClick!=null)
								this.NextYearButtonClick(this,new EventArgs());
							btnClick = true;
						}
					}
				}
				else
				{
					if (m_contextMenu)
					{
						DisplayMonthContextMenu(mouseLocation);
					}
				}
				
				if (mode == mcClickMode.Single)
				{
					if ((this.Click!=null) && (!btnClick))
						this.Click(this,new ClickEventArgs(button));
				}
				else
				{
					if ((this.DoubleClick!=null) && (!btnClick))
						this.DoubleClick(this,new ClickEventArgs(button));	
				}
			}
			
			leftBtnRgn.Dispose();
			rightBtnRgn.Dispose();
			leftYearBtnRgn.Dispose();
			rightYearBtnRgn.Dispose();
		}
Esempio n. 33
0
 protected override void OnPaint(PaintEventArgs e)
 {
     try
     {
         base.OnPaint(e);
         if (base.ClientRectangle.Width - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength) > 0 && base.ClientRectangle.Height - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength) > 0)
         {
             DrawGraphics _DrawGraphics   = new DrawGraphics();
             int          left            = base.ClientRectangle.Left;
             int          top             = base.ClientRectangle.Top;
             Rectangle    clientRectangle = base.ClientRectangle;
             Rectangle    rectangle       = base.ClientRectangle;
             Rectangle    width           = new Rectangle(left, top, clientRectangle.Width - 1, rectangle.Height - 1);
             e.Graphics.SmoothingMode     = SmoothingMode.AntiAlias;
             e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
             SolidBrush solidBrush = new SolidBrush(base.Parent.BackColor);
             e.Graphics.FillRectangle(solidBrush, base.ClientRectangle);
             Pen pen = new Pen(solidBrush);
             e.Graphics.DrawRectangle(pen, base.ClientRectangle);
             pen.Dispose();
             solidBrush.Dispose();
             StringFormat stringFormat = new StringFormat()
             {
                 Alignment     = StringAlignment.Center,
                 LineAlignment = StringAlignment.Center
             };
             if (this.m_TextVisible && this.Text != string.Empty || !this.m_IndicatorAutoSize)
             {
                 int m_IndicatorWidth2  = this.m_IndicatorWidth;
                 int m_IndicatorHeight2 = this.m_IndicatorHeight;
                 if (m_IndicatorWidth2 > width.Width)
                 {
                     m_IndicatorWidth2 = width.Width;
                 }
                 if (m_IndicatorHeight2 > width.Height)
                 {
                     m_IndicatorHeight2 = width.Height;
                 }
                 width.Width  = m_IndicatorWidth2;
                 width.Height = m_IndicatorHeight2;
                 if (this.m_TextPosition == DAS_TextPosStyle.TPS_Left)
                 {
                     int       x_ClientRectangle = base.ClientRectangle.X;
                     Rectangle clientRectangle1  = base.ClientRectangle;
                     width.X = x_ClientRectangle + clientRectangle1.Width - 1 - m_IndicatorWidth2;
                     int       y_ClientRectangle = base.ClientRectangle.Y;
                     Rectangle rectangle1        = base.ClientRectangle;
                     width.Y = y_ClientRectangle + (rectangle1.Height - 1 - m_IndicatorHeight2) / 2;
                     stringFormat.Alignment = StringAlignment.Near;
                 }
                 else if (this.m_TextPosition == DAS_TextPosStyle.TPS_Right)
                 {
                     width.X = base.ClientRectangle.X;
                     int       num = base.ClientRectangle.Y;
                     Rectangle clientRectangle2 = base.ClientRectangle;
                     width.Y = num + (clientRectangle2.Height - 1 - m_IndicatorHeight2) / 2;
                     stringFormat.Alignment = StringAlignment.Far;
                 }
                 else if (this.m_TextPosition == DAS_TextPosStyle.TPS_Top)
                 {
                     int       x1         = base.ClientRectangle.X;
                     Rectangle rectangle2 = base.ClientRectangle;
                     width.X = x1 + (rectangle2.Width - 1 - m_IndicatorWidth2) / 2;
                     int       y1 = base.ClientRectangle.Y;
                     Rectangle clientRectangle3 = base.ClientRectangle;
                     width.Y = y1 + (clientRectangle3.Height - 1 - m_IndicatorHeight2);
                     stringFormat.LineAlignment = StringAlignment.Near;
                 }
                 else if (this.m_TextPosition != DAS_TextPosStyle.TPS_Bottom)
                 {
                     int       num1       = base.ClientRectangle.X;
                     Rectangle rectangle3 = base.ClientRectangle;
                     width.X = num1 + (rectangle3.Width - 1 - m_IndicatorWidth2) / 2;
                     int       y2 = base.ClientRectangle.Y;
                     Rectangle clientRectangle4 = base.ClientRectangle;
                     width.Y = y2 + (clientRectangle4.Height - 1 - m_IndicatorHeight2) / 2;
                 }
                 else
                 {
                     int       x2         = base.ClientRectangle.X;
                     Rectangle rectangle4 = base.ClientRectangle;
                     width.X = x2 + (rectangle4.Width - 1 - m_IndicatorWidth2) / 2;
                     width.Y = base.ClientRectangle.Y;
                     stringFormat.LineAlignment = StringAlignment.Far;
                 }
             }
             Rectangle    rectangle5   = new Rectangle(width.Left + this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1, width.Top + this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1, width.Width - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1), width.Height - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1));
             GraphicsPath graphicsPath = null;
             if (this.m_Shape != DAS_ShapeStyle.SS_Rect && this.m_Shape != DAS_ShapeStyle.SS_RoundRect && this.m_Shape != DAS_ShapeStyle.SS_Circle)
             {
                 graphicsPath = new GraphicsPath();
                 _DrawGraphics.method_6(graphicsPath, width, this.m_Shape, this.m_ArrowWidth + this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength, this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength);
             }
             if (!this.m_Value)
             {
                 _DrawGraphics.SetValue(e.Graphics, rectangle5, this.m_Shape, graphicsPath, this.m_OffColor, this.m_OffGradientColor, this.m_GradientType, this.m_GradientAngle, this.m_GradientRate, this.m_RoundRadius - this.m_BorderExteriorLength - this.m_OuterBorderLength - this.m_MiddleBorderLength - this.m_InnerBorderLength, this.m_ArrowWidth, this.m_ShinePosition);
             }
             else
             {
                 _DrawGraphics.SetValue(e.Graphics, rectangle5, this.m_Shape, graphicsPath, this.m_OnColor, this.m_OnGradientColor, this.m_GradientType, this.m_GradientAngle, this.m_GradientRate, this.m_RoundRadius - this.m_BorderExteriorLength - this.m_OuterBorderLength - this.m_MiddleBorderLength - this.m_InnerBorderLength, this.m_ArrowWidth, this.m_ShinePosition);
             }
             if (graphicsPath != null)
             {
                 graphicsPath.Dispose();
             }
             if (this.m_Shape == DAS_ShapeStyle.SS_Rect)
             {
                 _DrawGraphics.SetRect(e.Graphics, width, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness);
             }
             else if (this.m_Shape == DAS_ShapeStyle.SS_RoundRect)
             {
                 System.Drawing.Region region        = new System.Drawing.Region(base.ClientRectangle);
                 GraphicsPath          graphicsPath1 = new GraphicsPath();
                 _DrawGraphics.SetRoundRect(graphicsPath1, rectangle5, this.m_RoundRadius - this.m_BorderExteriorLength - this.m_OuterBorderLength - this.m_MiddleBorderLength - this.m_InnerBorderLength);
                 region.Exclude(graphicsPath1);
                 SolidBrush solidBrush1 = new SolidBrush(base.Parent.BackColor);
                 e.Graphics.FillRegion(solidBrush1, region);
                 solidBrush1.Dispose();
                 graphicsPath1.Dispose();
                 region.Dispose();
                 _DrawGraphics.SetRoundRect2(e.Graphics, width, this.m_RoundRadius, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, (long)this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness);
             }
             else if (this.m_Shape != DAS_ShapeStyle.SS_Circle)
             {
                 _DrawGraphics.SetArrow(e.Graphics, width, this.m_Shape, this.m_RoundRadius, this.m_ArrowWidth, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, (long)this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness);
             }
             else
             {
                 System.Drawing.Region region1       = new System.Drawing.Region(base.ClientRectangle);
                 GraphicsPath          graphicsPath2 = new GraphicsPath();
                 graphicsPath2.AddEllipse(rectangle5);
                 region1.Exclude(graphicsPath2);
                 SolidBrush solidBrush2 = new SolidBrush(base.Parent.BackColor);
                 e.Graphics.FillRegion(solidBrush2, region1);
                 solidBrush2.Dispose();
                 graphicsPath2.Dispose();
                 region1.Dispose();
                 _DrawGraphics.SetCircle(e.Graphics, width, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, (long)this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness);
             }
             if (this.m_TextVisible && this.Text != string.Empty)
             {
                 SolidBrush solidBrush3 = new SolidBrush(this.ForeColor);
                 e.Graphics.DrawString(this.Text, this.Font, solidBrush3, base.ClientRectangle, stringFormat);
                 solidBrush3.Dispose();
             }
         }
     }
     catch (ApplicationException applicationException)
     {
         MessageBox.Show(applicationException.ToString());
     }
 }
Esempio n. 34
0
		public void DefaultProperties ()
		{
			Bitmap bmp = new Bitmap (200, 200);
			Graphics g = Graphics.FromImage (bmp);
			Region r = new Region ();

			Assert.AreEqual (r.GetBounds (g), g.ClipBounds, "DefaultProperties1");
			Assert.AreEqual (CompositingMode.SourceOver, g.CompositingMode, "DefaultProperties2");
			Assert.AreEqual (CompositingQuality.Default, g.CompositingQuality, "DefaultProperties3");
			Assert.AreEqual (InterpolationMode.Bilinear, g.InterpolationMode, "DefaultProperties4");
			Assert.AreEqual (1, g.PageScale, "DefaultProperties5");
			Assert.AreEqual (GraphicsUnit.Display, g.PageUnit, "DefaultProperties6");
			Assert.AreEqual (PixelOffsetMode.Default, g.PixelOffsetMode, "DefaultProperties7");
			Assert.AreEqual (new Point (0, 0), g.RenderingOrigin, "DefaultProperties8");
			Assert.AreEqual (SmoothingMode.None, g.SmoothingMode, "DefaultProperties9");
			Assert.AreEqual (TextRenderingHint.SystemDefault, g.TextRenderingHint, "DefaultProperties10");

			r.Dispose ();
		}
Esempio n. 35
0
 protected override void OnPaint(PaintEventArgs e)
 {
     if (this.m_groups != null)
     {
         this.CreateGdiObjects();
         this.CreateMemoryBitmap();
         Region region = new Region(e.ClipRectangle);
         this.m_graphics.Clip = region;
         Size size = new Size(0, 0);
         if (this.m_showTitle)
         {
             size = this.m_graphics.MeasureString(this.Text, this.Font).ToSize();
             try
             {
                 if (this.m_brushTitleBack != null)
                 {
                     this.m_graphics.FillRectangle(this.m_brushTitleBack, 0, 0, base.ClientSize.Width, size.Height + 8);
                 }
             }
             catch (ArgumentException)
             {
             }
             this.m_graphics.DrawString(this.Text, this.Font, this.m_brushTitleFore, (float) 4f, (float) 4f);
             this.m_graphics.DrawLine(this.m_penFrame, 0, size.Height + 8, base.ClientSize.Width, size.Height + 8);
             size.Height += 9;
         }
         int height = size.Height;
         int width = base.ClientSize.Width;
         int num3 = base.ClientSize.Height - height;
         if (num3 < 0)
         {
             num3 = base.ClientSize.Height;
         }
         Rectangle rect = new Rectangle(0, height, width, num3);
         if (this.m_groups.Show)
         {
             Rectangle rectangle2 = rect;
             try
             {
                 if (this.m_brushGroupsBack != null)
                 {
                     this.m_graphics.FillRectangle(this.m_brushGroupsBack, rectangle2);
                 }
             }
             catch (ArgumentException)
             {
             }
             rect = this.m_groups.Draw(this.m_graphics, rectangle2, this.m_penFrame);
         }
         else
         {
             try
             {
                 if (this.m_brushTitleBack != null)
                 {
                     this.m_graphics.FillRectangle(this.m_brushTitleBack, rect);
                 }
             }
             catch (ArgumentException)
             {
             }
         }
         if (!this.m_groups.Show && (this.m_groups.SelectedIndex < 0))
         {
             this.m_groups.m_bDoInvalidate = false;
             if (this.m_groups.Count > 0)
             {
                 this.m_groups.SelectedIndex = 0;
             }
             else
             {
                 this.m_groups.SelectedIndex = -1;
             }
         }
         if (((this.m_groups.m_selectedIndex >= 0) && (this.m_groups.Count > 0)) && (this.m_groups.m_selectedIndex < this.m_groups.Count))
         {
             this.m_groups[this.m_groups.m_selectedIndex].Draw(this.m_graphics, rect, this.m_penFrame, this.m_backgroundImage);
         }
         e.Graphics.DrawImage(this.m_bmp, 0, 0);
         region.Dispose();
         region = null;
     }
 }
Esempio n. 36
0
        private void DrawTabFocusIndicator(GraphicsPath tabpath, int index, Graphics graphics)
        {
            if (this._FocusTrack && this._TabControl.Focused && index == this._TabControl.SelectedIndex)
            {
                Brush focusBrush = null;
                RectangleF pathRect = tabpath.GetBounds();
                Rectangle focusRect = Rectangle.Empty;
                switch (this._TabControl.Alignment)
                {
                    case TabAlignment.Top:
                        focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Y, (int)pathRect.Width, 4);
                        focusBrush = new LinearGradientBrush(focusRect, this._FocusColor, SystemColors.Window, LinearGradientMode.Vertical);
                        break;
                    case TabAlignment.Bottom:
                        focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Bottom - 4, (int)pathRect.Width, 4);
                        focusBrush = new LinearGradientBrush(focusRect, SystemColors.ControlLight, this._FocusColor, LinearGradientMode.Vertical);
                        break;
                    case TabAlignment.Left:
                        focusRect = new Rectangle((int)pathRect.X, (int)pathRect.Y, 4, (int)pathRect.Height);
                        focusBrush = new LinearGradientBrush(focusRect, this._FocusColor, SystemColors.ControlLight, LinearGradientMode.Horizontal);
                        break;
                    case TabAlignment.Right:
                        focusRect = new Rectangle((int)pathRect.Right - 4, (int)pathRect.Y, 4, (int)pathRect.Height);
                        focusBrush = new LinearGradientBrush(focusRect, SystemColors.ControlLight, this._FocusColor, LinearGradientMode.Horizontal);
                        break;
                }

                //	Ensure the focus stip does not go outside the tab
                Region focusRegion = new Region(focusRect);
                focusRegion.Intersect(tabpath);
                graphics.FillRegion(focusBrush, focusRegion);
                focusRegion.Dispose();
                focusBrush.Dispose();
            }
        }
Esempio n. 37
0
 /// <summary>
 /// Draws an upwards facing pointer
 /// </summary>
 /// <param name="g">The graphics context</param>
 private void DrawPointerUp(Graphics g)
 {
     Point[] points = new Point[6]
     {
         new Point(this.ThumbBounds.Left, this.ThumbBounds.Bottom - 1),
         new Point(this.ThumbBounds.Left, this.ThumbBounds.Top + (this.ThumbBounds.Width / 2)),
         new Point(this.ThumbBounds.Left + (this.ThumbBounds.Width / 2), this.ThumbBounds.Top),
         new Point(this.ThumbBounds.Right - 1, this.ThumbBounds.Top + (this.ThumbBounds.Width / 2)),
         new Point(this.ThumbBounds.Right - 1, this.ThumbBounds.Bottom - 1),
         new Point(this.ThumbBounds.Left, this.ThumbBounds.Bottom - 1)
     };
     GraphicsPath path = new GraphicsPath();
     path.AddLines(points);
     Region region = new Region(path);
     g.Clip = region;
     if ((this.ThumbState == 3) || !this.Enabled)
     {
         ControlPaint.DrawButton(g, this.ThumbBounds, ButtonState.All);
     }
     else
     {
         g.Clear(SystemColors.Control);
     }
     g.ResetClip();
     region.Dispose();
     path.Dispose();
     // Draw light shadow
     Point[] shadowPoints = new Point[] { points[0], points[1], points[2] };
     g.DrawLines(SystemPens.ControlLightLight, shadowPoints);
     // Draw dark shadow
     shadowPoints = new Point[] { points[2], points[3], points[4], points[5] };
     g.DrawLines(SystemPens.ControlDarkDark, shadowPoints);
     points[0].Offset(1, -1);
     points[1].Offset(1, 0);
     points[2].Offset(0, 1);
     points[3].Offset(-1, 0);
     points[4].Offset(-1, -1);
     points[5] = points[0];
     shadowPoints = new Point[] { points[0], points[1], points[2] };
     g.DrawLines(SystemPens.ControlLight, shadowPoints);
     shadowPoints = new Point[] { points[2], points[3], points[4], points[5] };
     g.DrawLines(SystemPens.ControlDark, shadowPoints);
 }
        protected override void OnPrintPage(PrintPageEventArgs printPageArg)
        {
            base.OnPrintPage(printPageArg);

            AmbientTheme ambientTheme = WorkflowTheme.CurrentTheme.AmbientTheme;

            Graphics graphics = printPageArg.Graphics;
            graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            graphics.SmoothingMode = SmoothingMode.HighQuality;

            //STEP1: We get the printer graphics only in the OnPrintPage function hence for layouting we need to call this function
            if (this.currentPrintablePage.IsEmpty)
                PrepareToPrint(printPageArg);

            //STEP2: GET ALL THE VALUES NEEDED FOR CALCULATION
            Margins hardMargins = GetHardMargins(graphics);
            Margins margins = new Margins(Math.Max(printPageArg.PageSettings.Margins.Left, hardMargins.Left),
                                          Math.Max(printPageArg.PageSettings.Margins.Right, hardMargins.Right),
                                          Math.Max(printPageArg.PageSettings.Margins.Top, hardMargins.Top),
                                          Math.Max(printPageArg.PageSettings.Margins.Bottom, hardMargins.Bottom));
            Size printableArea = new Size(printPageArg.PageBounds.Size.Width - (margins.Left + margins.Right), printPageArg.PageBounds.Size.Height - (margins.Top + margins.Bottom));
            Rectangle boundingRectangle = new Rectangle(margins.Left, margins.Top, printableArea.Width, printableArea.Height);
            Region clipRegion = new Region(boundingRectangle);

            try
            {
                graphics.TranslateTransform(-hardMargins.Left, -hardMargins.Top);
                graphics.FillRectangle(ambientTheme.BackgroundBrush, boundingRectangle);
                graphics.DrawRectangle(ambientTheme.ForegroundPen, boundingRectangle);

                //Draw the watermark image
                if (ambientTheme.WorkflowWatermarkImage != null)
                    ActivityDesignerPaint.DrawImage(graphics, ambientTheme.WorkflowWatermarkImage, boundingRectangle, new Rectangle(Point.Empty, ambientTheme.WorkflowWatermarkImage.Size), ambientTheme.WatermarkAlignment, AmbientTheme.WatermarkTransparency, false);

                Matrix oldTransform = graphics.Transform;
                Region oldClipRegion = graphics.Clip;
                graphics.Clip = clipRegion;
                graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                //STEP3: PRINT
                //Printer bitmap starts at the unprintable top left corner, hence, need to take it into account - move by the unprintable area:
                //Setup the translation and scaling for the page printing
                Point pageOffset = new Point(this.currentPrintablePage.X * printableArea.Width - this.workflowAlignment.X, this.currentPrintablePage.Y * printableArea.Height - this.workflowAlignment.Y);
                graphics.TranslateTransform(boundingRectangle.Left - pageOffset.X, boundingRectangle.Top - pageOffset.Y);
                graphics.ScaleTransform(this.scaling, this.scaling);

                //Calculate the viewport by reverse scaling the printable area size
                Size viewPortSize = Size.Empty;
                viewPortSize.Width = Convert.ToInt32(Math.Ceiling((float)printableArea.Width / this.scaling));
                viewPortSize.Height = Convert.ToInt32(Math.Ceiling((float)printableArea.Height / this.scaling));

                Point scaledAlignment = Point.Empty;
                scaledAlignment.X = Convert.ToInt32(Math.Ceiling((float)this.workflowAlignment.X / this.scaling));
                scaledAlignment.Y = Convert.ToInt32(Math.Ceiling((float)this.workflowAlignment.Y / this.scaling));

                Rectangle viewPort = new Rectangle(this.currentPrintablePage.X * viewPortSize.Width - scaledAlignment.X, this.currentPrintablePage.Y * viewPortSize.Height - scaledAlignment.Y, viewPortSize.Width, viewPortSize.Height);

                using (PaintEventArgs paintEventArgs = new PaintEventArgs(graphics, this.workflowView.RootDesigner.Bounds))
                {
                    ((IWorkflowDesignerMessageSink)this.workflowView.RootDesigner).OnPaint(paintEventArgs, viewPort);
                }

                graphics.Clip = oldClipRegion;
                graphics.Transform = oldTransform;

                //Now prepare the graphics for header footer printing
                HeaderFooterData headerFooterData = new HeaderFooterData();
                headerFooterData.Font = ambientTheme.Font;
                headerFooterData.PageBounds = printPageArg.PageBounds;
                headerFooterData.PageBoundsWithoutMargin = boundingRectangle;
                headerFooterData.HeaderFooterMargins = new Margins(0, 0, this.pageSetupData.HeaderMargin, this.pageSetupData.FooterMargin);
                headerFooterData.PrintTime = this.printTime;
                headerFooterData.CurrentPage = this.currentPrintablePage.X + this.currentPrintablePage.Y * this.totalPrintablePages.X + 1;
                headerFooterData.TotalPages = this.totalPrintablePages.X * this.totalPrintablePages.Y;
                headerFooterData.Scaling = this.scaling;
                WorkflowDesignerLoader serviceDesignerLoader = ((IServiceProvider)this.workflowView).GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                headerFooterData.FileName = (serviceDesignerLoader != null) ? serviceDesignerLoader.FileName : String.Empty;

                //Print the header
                if (this.pageSetupData.HeaderTemplate.Length > 0)
                    PrintHeaderFooter(graphics, true, headerFooterData);

                //footer
                if (this.pageSetupData.FooterTemplate.Length > 0)
                    PrintHeaderFooter(graphics, false, headerFooterData);

                //are there more pages left?
                printPageArg.HasMorePages = MoveNextPage();
            }
            catch (Exception exception)
            {
                DesignerHelpers.ShowError(this.workflowView, DR.GetString(DR.SelectedPrinterIsInvalidErrorMessage) + "\n" + exception.Message);
                printPageArg.Cancel = true;
                printPageArg.HasMorePages = false;
            }
            finally
            {
                clipRegion.Dispose();
            }

            if (!printPageArg.HasMorePages)
                this.workflowView.PerformLayout(); //no more pages - redo regular layout using screen graphics
        }
Esempio n. 39
0
 protected virtual void RedrawBorder()
 {
     Region r = new Region();
     Size bs = new Size(SystemInformation.Border3DSize.Width /* * NativeFunctions.BorderMultiplierFactor*/,
         SystemInformation.Border3DSize.Height /* * NativeFunctions.BorderMultiplierFactor*/);
     r.Union(new Rectangle(0, 0, this.Width, bs.Height));
     r.Union(new Rectangle(this.Height - bs.Height, 0, this.Width, bs.Height));
     r.Union(new Rectangle(0, 0, bs.Width, this.Height));
     r.Union(new Rectangle(this.Width - bs.Width, 0, bs.Width, this.Height));
     this.Invalidate(r, true);
     r.Dispose();
     this.Update();
 }