コード例 #1
0
        public ViewRectangle GetIntersection(ViewRectangle rectangleA, ViewRectangle rectangleB)
        {
            Rectangle firstRectangle  = rectangleA.ConvertToRectangle();
            Rectangle secondRectangle = rectangleB.ConvertToRectangle();

            return(new ViewRectangle(firstRectangle.GetIntersection(secondRectangle)));
        }
コード例 #2
0
        public bool TestContain(ViewRectangle rectangleA, ViewRectangle rectangleB)
        {
            Rectangle firstRectangle  = rectangleA.ConvertToRectangle();
            Rectangle secondRectangle = rectangleB.ConvertToRectangle();

            return(firstRectangle.Contains(secondRectangle));
        }
コード例 #3
0
ファイル: ImageStrip.cs プロジェクト: vip57884381/Paint.Net
        public int ViewPointToItemIndex(Point viewPt)
        {
            if (!ViewRectangle.Contains(viewPt))
            {
                return(-1);
            }

            Size itemSize = ItemSize;
            int  index    = viewPt.X / itemSize.Width;

            return(index);
        }
コード例 #4
0
        public ViewRectangle GetContained(ViewRectangle rectangleA, ViewRectangle rectangleB)
        {
            Rectangle firstRectangle  = rectangleA.ConvertToRectangle();
            Rectangle secondRectangle = rectangleB.ConvertToRectangle();

            if (firstRectangle.Contains(secondRectangle))
            {
                return(rectangleB);
            }

            return(new ViewRectangle(null));
        }
コード例 #5
0
        private void AddRectangle(double startX, double startY, double width, double height)
        {
            ViewRectangle viewRectangle = new ViewRectangle(startX, startY, width, height);

            DataContext.Rectangles.Add(viewRectangle);
            _notFirstRectangle = true;

            Rectangle rect = new Rectangle {
                Width = width, Height = width, Stroke = Brushes.Black
            };

            RectCanvas.Children.Add(rect);
            Canvas.SetLeft(rect, startX);
            Canvas.SetTop(rect, startY);
        }
コード例 #6
0
ファイル: ChartOverviewBox.cs プロジェクト: Yahasana/Blumind
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            MouseDownButton = e.Button;
            if (e.Button == MouseButtons.Left)
            {
                TempViewRectangle = ViewRectangle;
                Capture           = true;
                MouseDownPoint    = new Point(e.X, e.Y);

                if (!ViewRectangle.Contains(e.X, e.Y))
                {
                    int x = Math.Min(FullRectangle.X + FullRectangle.Width - ViewRectangle.Width,
                                     Math.Max(FullRectangle.X, (e.X - ViewRectangle.Width / 2)));
                    int y = Math.Min(FullRectangle.Y + FullRectangle.Height - ViewRectangle.Height,
                                     Math.Max(FullRectangle.Y, (e.Y - ViewRectangle.Height / 2)));
                    SetViewRectangle(new Rectangle(x, y, ViewRectangle.Width, ViewRectangle.Height));
                }
                MouseDownViewRectangle = ViewRectangle;
            }
        }
コード例 #7
0
        private void CheckContainment_Click(object sender, RoutedEventArgs e)
        {
            List <ViewRectangle> containedAreas = new List <ViewRectangle>();

            // Go through all of the rectangles on the page, compare them to each other for intersection
            for (int i = 0; i < DataContext.Rectangles.Count; i++)
            {
                for (int j = 0; j < DataContext.Rectangles.Count; j++)
                {
                    if (i != j)
                    {
                        ViewRectangle area = DataContext.GetContained(DataContext.Rectangles[i], DataContext.Rectangles[j]);
                        if (area.Equals(null))
                        {
                            continue;
                        }

                        containedAreas.Add(area);
                    }
                }
            }

            ColorIntersectingRectangles(containedAreas);
        }