Example #1
0
 /// <summary>
 /// アイコンの画像領域以外の領域(4隅)を取得します
 /// </summary>
 /// <returns></returns>
 private System.Drawing.Region getInvRegion()
 {
     if (invRegion == null)
     {
         invRegion = new System.Drawing.Region();
         invRegion.Exclude(getGraphicsPath());
     }
     return(invRegion);
 }
		public override void Draw(RangePaintEventArgs e)
		{
			RangeRegion region = mSelection.GetSelectionRegion();

			if (region.IsEmpty())
				return;

			// get visible range for scrollable area
			Range visibleScrollabeRange = mSelection.Grid.RangeAtAreaExpanded(CellPositionType.Scrollable);
			
			
			System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

			CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
			// get focus rectangle
			// clipped to visible range
			Range focusClippedRange = visibleScrollabeRange.Intersect(new Range(mSelection.ActivePosition, mSelection.ActivePosition));
			System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(focusClippedRange.Start);

			//Draw each selection range
			foreach (Range rangeToLoop in region)
			{
				// intersect given range with visible range
				// this way we ensure we don't loop through thousands
				// of rows to calculate rectToDraw
				Range rng = visibleScrollabeRange.Intersect(rangeToLoop);
				

				System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
				if (rectToDraw == System.Drawing.Rectangle.Empty)
					continue;

				System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

				if (rectToDraw.IntersectsWith(focusRect))
					regionToDraw.Exclude(focusRect);

				e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

				//Draw the border only if there isn't a editing cell
				// and is the range that contains the focus or there is a single range
				if (rng.Contains(mSelection.ActivePosition) || region.Count == 1)
				{
					if (focusContext.IsEditing() == false)
						mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
				}
			}

			//Draw Focus
			System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
			e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
		}
Example #3
0
        public override void Draw(RangePaintEventArgs e)
        {
            RangeRegion region = mSelection.GetSelectionRegion();

            if (region.IsEmpty())
            {
                return;
            }

            System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);

            System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(mSelection.ActivePosition);

            RangeCollection ranges = region.GetRanges();

            //Draw each selection range
            foreach (Range rng in ranges)
            {
                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

                if (rectToDraw.IntersectsWith(focusRect))
                {
                    regionToDraw.Exclude(focusRect);
                }

                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

                //Draw the border only if there isn't a editing cell
                // and is the range that contains the focus or there is a single range
                if (rng.Contains(mSelection.ActivePosition) || ranges.Count == 1)
                {
                    if (focusContext == null || focusContext.IsEditing() == false)
                    {
                        mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
                    }
                }
            }

            //Draw Focus
            System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
            e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
        }
Example #4
0
 public void subtract(Area rhs)
 {
     if (rhs == null)
     {
         return;
     }
     if (rhs.region == null)
     {
         return;
     }
     if (region == null)
     {
         region = new System.Drawing.Region();
     }
     region.Exclude(rhs.region);
 }
Example #5
0
        //private static SySal.DAQSystem.Scanning.ZoneDesc[] GetRegionScans(SySal.DAQSystem.Scanning.ZoneDesc newZones, SySal.DAQSystem.Scanning.ZoneDesc[] oldZones)
        //{
        //    if (oldZones.Length == 1) return GetRegionScans(newZones, oldZones[0]);

        //    foreach (SySal.DAQSystem.Scanning.ZoneDesc o in oldZones)
        //    {
        //        newZones = GetRegionScans(newZones, o);
        //    }
        //    return newZones;
        //}

        private static SySal.DAQSystem.Scanning.ZoneDesc[] GetRegionScans(SySal.DAQSystem.Scanning.ZoneDesc newZone, SySal.DAQSystem.Scanning.ZoneDesc oldZone)
        {
            float scale = 1000;

            float x      = Convert.ToSingle(newZone.MinX / scale);
            float y      = Convert.ToSingle(newZone.MinY / scale);
            float width  = Convert.ToSingle((newZone.MaxX - newZone.MinX) / scale);
            float height = Convert.ToSingle((newZone.MaxY - newZone.MinY) / scale);

            System.Drawing.RectangleF ZoneToScan = new System.Drawing.RectangleF(x, y, width, height);

            x      = Convert.ToSingle(oldZone.MinX / scale);
            y      = Convert.ToSingle(oldZone.MinY / scale);
            width  = Convert.ToSingle((oldZone.MaxX - oldZone.MinX) / scale);
            height = Convert.ToSingle((oldZone.MaxY - oldZone.MinY) / scale);
            System.Drawing.RectangleF OldZone = new System.Drawing.RectangleF(x, y, width, height);

            Console.WriteLine("ZoneToScan: " + ZoneToScan.Left + " " + ZoneToScan.Right + " " + ZoneToScan.Top + " " + ZoneToScan.Bottom);
            Console.WriteLine("OldZone:    " + OldZone.Left + " " + OldZone.Right + " " + OldZone.Top + " " + OldZone.Bottom);

            System.Drawing.Region NewRegion = new System.Drawing.Region(ZoneToScan);

            NewRegion.Exclude(OldZone);

            System.Drawing.RectangleF[] rectangles = NewRegion.GetRegionScans(new System.Drawing.Drawing2D.Matrix());

            if (rectangles.Length == 0)
            {
                return(null);
            }

            SySal.DAQSystem.Scanning.ZoneDesc[] zones = new SySal.DAQSystem.Scanning.ZoneDesc[rectangles.Length];

            for (int i = 0; i < zones.Length; i++)
            {
                zones[i]      = new SySal.DAQSystem.Scanning.ZoneDesc();
                zones[i].MinX = rectangles[i].Left * scale;
                zones[i].MaxX = rectangles[i].Right * scale;
                zones[i].MinY = rectangles[i].Top * scale;
                zones[i].MaxY = rectangles[i].Bottom * scale;
            }
            return(zones);
        }
Example #6
0
        public override void Draw(RangePaintEventArgs e)
        {
            RangeRegion region = mSelection.GetSelectionRegion();

            if (region.IsEmpty())
                return;

            System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
            System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(mSelection.ActivePosition);

            RangeCollection ranges = region.GetRanges();

            //Draw each selection range
            foreach (Range rng in ranges)
            {
                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                    continue;

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

                if (rectToDraw.IntersectsWith(focusRect))
                    regionToDraw.Exclude(focusRect);

                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

                //Draw the border only if there isn't a editing cell
                // and is the range that contains the focus or there is a single range
                if (rng.Contains(mSelection.ActivePosition) || ranges.Count == 1)
                {
                    if (focusContext == null || focusContext.IsEditing() == false)
                        mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
                }
            }

            //Draw Focus
            System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
            e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
        }
        public override void Draw(RangePaintEventArgs e)
        {
            RangeRegion region = mSelection.GetSelectionRegion();

            if (region.IsEmpty())
            {
                return;
            }

            // get visible range for scrollable area
            // AlanP: June 2014.  Changed the call from RangeAtAreaExpanded to RangeAtArea to fix a bug that occurred on Partner/Find screen
            // The grid on this screen has 3 fixed columns on the left but the highlight was always applied to the cell 'behind' the last fixed column
            //   as well as the rest of the row.  This is because of getting the 'expanded' range.
            // To be honest I don't understand what the expanded range is for.  The comment for it is not helpful (to me anyway).
            // It may be something to do with drawing the focus cell?  If we see a problem later we could revies this code
            //Range visibleScrollabeRange = mSelection.Grid.RangeAtAreaExpanded(CellPositionType.Scrollable);
            Range visibleScrollableRange = mSelection.Grid.RangeAtArea(CellPositionType.Scrollable);

            System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            // In OP we would like to have the rows of fixed columns highlighted as well - this seems non-standard
            // This code is the same as is used in the standard code below, but for the FixedLeft Range
            Range visibleFixedLeftRange = mSelection.Grid.RangeAtArea(CellPositionType.FixedLeft);

            foreach (Range rangeToLoop in region)
            {
                Range rng = visibleFixedLeftRange.Intersect(rangeToLoop);
                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);
                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);
            }

            // Deal with the focus rectangle...  The original grid code does not seem to support the focus being on a fixed column, which seems like a bug
            //  but does not affect OpenPetra
            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
            // get focus rectangle
            // clipped to visible range
            Range focusClippedRange = visibleScrollableRange.Intersect(new Range(mSelection.ActivePosition, mSelection.ActivePosition));

            System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(focusClippedRange.Start);

            //Draw each selection range
            foreach (Range rangeToLoop in region)
            {
                // intersect given range with visible range
                // this way we ensure we don't loop through thousands
                // of rows to calculate rectToDraw
                Range rng = visibleScrollableRange.Intersect(rangeToLoop);

                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

                if (rectToDraw.IntersectsWith(focusRect))
                {
                    regionToDraw.Exclude(focusRect);
                }

                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

                //Draw the border only if there isn't a editing cell
                // and is the range that contains the focus or there is a single range
                if (rng.Contains(mSelection.ActivePosition) || region.Count == 1)
                {
                    if (focusContext.IsEditing() == false)
                    {
                        mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
                    }
                }
            }

            //Draw Focus
            System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
            e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
        }
Example #8
0
        public override void Draw(RangePaintEventArgs e)
        {
            RangeRegion region = mSelection.GetSelectionRegion();

            if (region.IsEmpty())
            {
                return;
            }

            //[email protected]: To support freezePanes enahancement
            // get visible range for data area
            Range dataRange = mSelection.Grid.CompleteRange;

            System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
            // get focus rectangle
            // clipped to visible range
            Range focusClippedRange = dataRange.Intersect(new Range(mSelection.ActivePosition, mSelection.ActivePosition));

            System.Drawing.Rectangle focusRect = e.Grid.PositionToVisibleRectangle(focusClippedRange.Start);

            //[email protected]: To support smooth scrolling. Otherwise transform will not be applied.
            focusRect.X -= (int)e.GraphicsCache.Graphics.Transform.OffsetX;
            focusRect.Y -= (int)e.GraphicsCache.Graphics.Transform.OffsetY;

            bool isFocusCellVisible = e.Grid.IsCellVisible(focusContext.Position, true);

            //Draw each selection range
            foreach (Range rangeToLoop in region)
            {
                // intersect given range with visible range
                // this way we ensure we don't loop through thousands
                // of rows to calculate rectToDraw
                Range rng = dataRange.Intersect(rangeToLoop);

                //[email protected]: To support freezePanes enahancement
                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToVisibleRectangle(rng);

                //[email protected]: To support smooth scrolling. Otherwise transform will not be applied.
                rectToDraw.X -= (int)e.GraphicsCache.Graphics.Transform.OffsetX;
                rectToDraw.Y -= (int)e.GraphicsCache.Graphics.Transform.OffsetY;

                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

                Range cellRange = e.Grid.PositionToCellRange(focusContext.Position);
                //[email protected]: To support freezePanes enahancement: Only if the cell is visible exclude it. It can be hidden under a fixedrow\column
                if (rectToDraw.IntersectsWith(focusRect) && (isFocusCellVisible || rng.Contains(cellRange)))
                {
                    regionToDraw.Exclude(focusRect);
                }

                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

                var partType = GetBorderType(e.Grid, rng);

                //Draw the border only if there isn't a editing cell
                // and is the range that contains the focus or there is a single range
                if ((rng.Contains(mSelection.ActivePosition) || region.Count == 1) && partType != BorderPartType.None)
                {
                    //if (!focusContext.IsEditing())
                    //[email protected]: the border should be drawn even when editing,

                    mSelection.Border.Draw(e.GraphicsCache, rectToDraw, partType);
                }
            }

            //[email protected]: To support freezePanes enahancement: Only if the cell is visible exclude it. It can be hidden under a fixedrow\column
            if (isFocusCellVisible)
            //Draw Focus
            {
                System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
                e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
            }
        }
Example #9
0
        public override void Draw(RangePaintEventArgs e)
        {
            RangeRegion region = mSelection.GetSelectionRegion();

            if (region.IsEmpty())
            {
                return;
            }

            // get visible range for scrollable area
            Range visibleScrollabeRange = mSelection.Grid.RangeAtAreaExpanded(CellPositionType.Scrollable);


            System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
            // get focus rectangle
            // clipped to visible range
            Range focusClippedRange = visibleScrollabeRange.Intersect(new Range(mSelection.ActivePosition, mSelection.ActivePosition));

            System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(focusClippedRange.Start);

            //Draw each selection range
            foreach (Range rangeToLoop in region)
            {
                // intersect given range with visible range
                // this way we ensure we don't loop through thousands
                // of rows to calculate rectToDraw
                Range rng = visibleScrollabeRange.Intersect(rangeToLoop);


                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

                if (rectToDraw.IntersectsWith(focusRect))
                {
                    regionToDraw.Exclude(focusRect);
                }

                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

                //Draw the border only if there isn't a editing cell
                // and is the range that contains the focus or there is a single range
                if (rng.Contains(mSelection.ActivePosition) || region.Count == 1)
                {
                    if (focusContext.IsEditing() == false)
                    {
                        mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
                    }
                }
            }

            //Draw Focus
            System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
            e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
        }
Example #10
0
		public override void Draw(RangePaintEventArgs e)
		{
			RangeRegion region = mSelection.GetSelectionRegion();

			if (region.IsEmpty())
				return;

			// get visible range for scrollable area
            // AlanP: June 2014.  Changed the call from RangeAtAreaExpanded to RangeAtArea to fix a bug that occurred on Partner/Find screen
            // The grid on this screen has 3 fixed columns on the left but the highlight was always applied to the cell 'behind' the last fixed column
            //   as well as the rest of the row.  This is because of getting the 'expanded' range.
            // To be honest I don't understand what the expanded range is for.  The comment for it is not helpful (to me anyway).
            // It may be something to do with drawing the focus cell?  If we see a problem later we could revies this code
            //Range visibleScrollabeRange = mSelection.Grid.RangeAtAreaExpanded(CellPositionType.Scrollable);
            Range visibleScrollableRange = mSelection.Grid.RangeAtArea(CellPositionType.Scrollable);
			
			System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            // In OP we would like to have the rows of fixed columns highlighted as well - this seems non-standard
            // This code is the same as is used in the standard code below, but for the FixedLeft Range
            Range visibleFixedLeftRange = mSelection.Grid.RangeAtArea(CellPositionType.FixedLeft);
            foreach (Range rangeToLoop in region)
            {
                Range rng = visibleFixedLeftRange.Intersect(rangeToLoop);
                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                    continue;

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);
                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);
            }

			// Deal with the focus rectangle...  The original grid code does not seem to support the focus being on a fixed column, which seems like a bug
            //  but does not affect OpenPetra
            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
			// get focus rectangle
			// clipped to visible range
            Range focusClippedRange = visibleScrollableRange.Intersect(new Range(mSelection.ActivePosition, mSelection.ActivePosition));
			System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(focusClippedRange.Start);

			//Draw each selection range
			foreach (Range rangeToLoop in region)
			{
				// intersect given range with visible range
				// this way we ensure we don't loop through thousands
				// of rows to calculate rectToDraw
                Range rng = visibleScrollableRange.Intersect(rangeToLoop);

				System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
				if (rectToDraw == System.Drawing.Rectangle.Empty)
					continue;

				System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

				if (rectToDraw.IntersectsWith(focusRect))
					regionToDraw.Exclude(focusRect);

				e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

				//Draw the border only if there isn't a editing cell
				// and is the range that contains the focus or there is a single range
				if (rng.Contains(mSelection.ActivePosition) || region.Count == 1)
				{
					if (focusContext.IsEditing() == false)
						mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
				}
			}

			//Draw Focus
			System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
			e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
		}