コード例 #1
0
ファイル: DrawingBoard.cs プロジェクト: xknife-erian/nknife
 protected override void OnMouseClick(MouseEventArgs e)
 {
     base.OnMouseClick(e);
     if (e.Button != MouseButtons.None)
     {
         if (ImagePanelDesignMode == DrawingBoardDesignMode.Zooming)
         {
             if (e.Button == MouseButtons.Left && e.Clicks == 1) //左键单击
             {
                 if ((ModifierKeys & Keys.Shift) == Keys.Shift)  //是否按着Shift键
                 {
                     ShrinkDesignPanel(e.Location);
                 }
                 else
                 {
                     EnlargeDesignPanel(e.Location);
                 }
             }
         }
         else
         {
             RectangleList rl = _Parent.Rectangles;
             foreach (RectangleF rect in rl)
             {
                 var epoint = new Point((int)(e.X / _Parent.Zoom), (int)(e.Y / _Parent.Zoom));
                 if (rect.Contains(epoint))
                 {
                     _Parent.OnRectangleClick(new RectangleClickEventArgs(e, ImagePanelDesignMode, rect));
                     return;
                 }
             }
             _Parent.OnRectangleClick(new RectangleClickEventArgs(e, ImagePanelDesignMode, Rectangle.Empty));
         }
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: NikitaDocent/bynaryTree
        static void Main(string[] args)
        {
            Rectangle rec1 = new Rectangle(10, 10, "Yellow", "Blue");
            Rectangle rec2 = new Rectangle(11, 30, "Yellow", "Blue");
            RectangleList <Rectangle> rectangles  = new RectangleList <Rectangle>();
            BinaryTree <Rectangle>    rectangles1 = new BinaryTree <Rectangle>();

            rectangles.Add(rec1);
            rectangles1.Add(rec1);
            rectangles.Add(rec2);
            rectangles1.Add(rec2);
        }
コード例 #3
0
ファイル: DrawingBoard.cs プロジェクト: xknife-erian/nknife
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            Graphics g      = pe.Graphics;
            var      border = new Pen(Color.Red, 1)
            {
                DashStyle = DashStyle.Dash
            };
            RectangleList rl = _Parent.Rectangles;

            if (rl.Count > 0)
            {
                //采用在内存中绘制好新图的方式贴图的方式进行绘制
                using (Graphics imgG = Graphics.FromImage(_CurrentImage))
                {
                    imgG.DrawImage(_SourceImage, new Point(0, 0));
                    foreach (RectangleF rect in rl)
                    {
                        if (rl.Current.Contains(rect)) //选中的矩形
                        {
                            var b = new SolidBrush(Color.FromArgb(80, 255, 255, 0));
                            imgG.FillRectangle(b, rect.X, rect.Y, rect.Width, rect.Height);
                        }
                        else if (rect == rl.Hover) //鼠标滑过的矩形
                        {
                            var b = new SolidBrush(Color.FromArgb(40, 80, 180, 0));
                            imgG.FillRectangle(b, rect.X, rect.Y, rect.Width, rect.Height);
                        }
                        else //普通矩形
                        {
                            var b = new SolidBrush(Color.FromArgb(40, 255, 0, 0));
                            imgG.FillRectangle(b, rect.X, rect.Y, rect.Width, rect.Height);
                        }
                        imgG.DrawRectangle(Pens.Red, rect.X, rect.Y, rect.Width, rect.Height);
                    }
                    imgG.Dispose();
                }
                //将画好的新图贴到当前控件的工作区
                g.DrawImage(_CurrentImage, ClientRectangle, new Rectangle(0, 0, _CurrentImage.Width, _CurrentImage.Height), GraphicsUnit.Pixel);
            }

            //画正在拖动的矩形
            if (_IsDesign)
            {
                var rect = new Rectangle(_EndDesign, new Size(Math.Abs(_CurrentDesign.X - _StartDesign.X), Math.Abs(_CurrentDesign.Y - _StartDesign.Y)));
                g.DrawRectangle(border, rect);
            }
            //为了美观,绘制一个矩形外边框
            g.DrawLines(Pens.Black, new[]
            {
                new Point(0, 0), new Point(0, Height - 1), new Point(Width - 1, Height - 1), new Point(Width - 1, 0), new Point(0, 0)
            });
        }
コード例 #4
0
        private void InitYangYaoInfo(PointF startPoint, int totalWidth, int heigth, int midWidth = 0)
        {
            Yang    = new Yang();
            YaoEr   = "0";
            YaoName = Yang.Name + YaoName;
            var size = new Size(totalWidth, heigth);

            Rectangle = new RectangleF(startPoint, size);
            if (RectangleList == null)
            {
                RectangleList = new List <RectangleF>();
            }
            RectangleList.Add(Rectangle);
        }
コード例 #5
0
ファイル: DrawingBoard.cs プロジェクト: xknife-erian/nknife
 protected override void OnMouseDoubleClick(MouseEventArgs e)
 {
     base.OnMouseDoubleClick(e);
     if (e.Button == MouseButtons.Left)
     {
         RectangleList rl = _Parent.Rectangles;
         foreach (RectangleF rect in rl)
         {
             var epoint = new Point((int)(e.X / _Parent.Zoom), (int)(e.Y / _Parent.Zoom));
             if (rect.Contains(epoint))
             {
                 _Parent.OnRectangleDoubleClick(new RectangleClickEventArgs(e, ImagePanelDesignMode, rect));
                 break;
             }
         }
     }
 }
コード例 #6
0
ファイル: DrawingBoard.cs プロジェクト: xknife-erian/nknife
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            switch (ImagePanelDesignMode)
            {
            case DrawingBoardDesignMode.Designing:
            {
                _StartDesign = new Point(e.X, e.Y);
                _IsDesign    = true;
                break;
            }

            case DrawingBoardDesignMode.Selecting:
            {
                RectangleList rl = _Parent.Rectangles;
                foreach (RectangleF rect in rl)
                {
                    var epoint = new Point((int)(e.X / _Parent.Zoom), (int)(e.Y / _Parent.Zoom));
                    if (rect.Contains(epoint))
                    {
                        if (!rl.Current.Contains(rect))
                        {
                            rl.Current.Add(rect);
                            _Parent.OnSelected(new RectangleSelectedEventArgs(rect, e));
                        }
                        else
                        {
                            if (e.Button == MouseButtons.Left)
                            {
                                rl.Current.Remove(rect);     //如果是已选的,置为未选择状态
                            }
                        }
                        Invalidate();
                        break;
                    }
                }
                break;
            }

            case DrawingBoardDesignMode.Dragging:
            {
                _StartDragging = e.Location;
                break;
            }
            }
        }
コード例 #7
0
ファイル: DrawingBoard.cs プロジェクト: xknife-erian/nknife
        public void RemoveSelectedRectangle()
        {
            RectangleList rl = _Parent.Rectangles;

            if (rl.Current.Count > 0)
            {
                DialogResult ds = MessageBox.Show(this, "是否删除被选择的矩形设计区?", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (ds == DialogResult.Yes)
                {
                    foreach (RectangleF rect in rl.Current)
                    {
                        rl.Remove(rect);
                    }
                    rl.Current.Clear();
                    Invalidate();
                }
            }
        }
コード例 #8
0
ファイル: JsonTools.cs プロジェクト: Sinnaj94/csharp-games
        public List <IntRect> GetAnimation(Texture texture)
        {
            //TODO: Outsourcing
            //Go through Columns (Y)
            if (startColumn == endColumn)
            {
                for (int r = startRow; r <= endRow; r++)
                {
                    RectangleList.Add(GetRect(r, startColumn, texture));
                }
            }
            else
            {
                for (int c = startColumn; c < sheetSize.Y; c++)
                {
                    //Go thorugh Y
                    for (int r = 0; r < sheetSize.X; r++)
                    {
                        if (c == startColumn)
                        {
                            if (r >= startRow)
                            {
                                RectangleList.Add(GetRect(r, c, texture));
                            }
                        }
                        else if (c == endColumn)
                        {
                            if (r <= endRow)
                            {
                                RectangleList.Add(GetRect(r, c, texture));
                            }
                        }
                        else if (c > startColumn && c < endColumn)
                        {
                            RectangleList.Add(GetRect(r, c, texture));
                        }
                    }
                }
            }

            size = RectangleList.Count;
            return(RectangleList);
        }
コード例 #9
0
ファイル: DrawingBoard.cs プロジェクト: xknife-erian/nknife
        private void MouseMoveSelecting(MouseEventArgs e)
        {
            RectangleList rl = _Parent.Rectangles;

            foreach (RectangleF rect in rl)
            {
                var epoint = new Point((int)(e.X / _Parent.Zoom), (int)(e.Y / _Parent.Zoom));
                if (rect.Contains(epoint))
                {
                    if (!rl.Current.Contains(rect) && rect != rl.Hover)
                    {
                        rl.Hover = rect;
                        Invalidate();
                        _Parent.OnSelecting(new RectangleSelectingEventArgs(rect));
                        break;
                    }
                }
            }
        }
コード例 #10
0
        public PictureFrame()
        {
            Rectangles = new RectangleList();
            InitializeComponent();

            _HScrollBar.Dock          = DockStyle.Bottom;
            _HScrollBar.Enabled       = false;
            _HScrollBar.ValueChanged += _HScrollBar_ValueChanged;
            _VScrollBar.Dock          = DockStyle.Right;
            _VScrollBar.Enabled       = false;
            _VScrollBar.ValueChanged += _VScrollBar_ValueChanged;
            _DrawingBoard             = new DrawingBoard {
                Visible = false
            };
            _DrawingBoard.BoardDragging += _DrawingBoard_PanelDragging;
            _DrawingBoard.Zoomed        += _DrawingBoard_PanelZoomed;

            Controls.Add(_VScrollBar);
            Controls.Add(_HScrollBar);
            Controls.Add(_DrawingBoard);
        }
コード例 #11
0
ファイル: GameState.cs プロジェクト: sitoader-zz/ColorBlind
        private void Stop(object sender, RoutedEventArgs e)
        {
            if (this.DrawTimer != null)
            {
                this.DrawTimer.Dispose();

                Paused         = false;
                this.DrawTimer = null;

                lock (RectangleList)
                {
                    RectangleList.Clear();
                    GameArea.Children.Clear();
                }

                this.HardTimer.Dispose();
                Slowness  = SlownessDefault;
                Blinkness = BlinknessDefault;

                StopScore();
            }
        }
コード例 #12
0
 /// <summary>
 /// 更新矩形列表
 /// </summary>
 /// <param name="rectangleList"></param>
 public void UpdateRectangleList(RectangleList rectangleList)
 {
     Rectangles = rectangleList;
 }