예제 #1
0
        public override TextBox CreateTextBox(Point mousePosition)
        {
            TextBox tb;
            // Get cell where mouse cursor is currently over.
            Point localMousePos = Canvas.PointToClient(mousePosition);

            editCol = -1;
            editRow = -1;
            int cellWidth  = DisplayRectangle.Width / Columns;
            int cellHeight = DisplayRectangle.Height / Rows;

            if (DisplayRectangle.Contains(localMousePos))
            {
                editCol     = (localMousePos.X - DisplayRectangle.Left) / cellWidth;
                editRow     = (localMousePos.Y - DisplayRectangle.Top) / cellHeight;
                tb          = new TextBox();
                tb.Location = DisplayRectangle.TopLeftCorner().Move(editCol * cellWidth, editRow * cellHeight + cellHeight / 2 - 10);
                tb.Size     = new Size(cellWidth, 20);
                string text;
                cellText.TryGetValue(new Cell()
                {
                    Column = editCol, Row = editRow
                }, out text);
                tb.Text = text;
            }
            else
            {
                tb = base.CreateTextBox(mousePosition);
            }

            return(tb);
        }
예제 #2
0
파일: ListBox.cs 프로젝트: windygu/noForms
 public override void Draw(IDraw renderArgument, Region dirty)
 {
     PoisitionItems();
     renderArgument.uDraw.FillRectangle(DisplayRectangle, brushy2);
     // so that the box overdraws the childrens
     renderArgument.uDraw.DrawRectangle(DisplayRectangle.Inflated(new Thickness(-.5f)), brushy1, strokey);
 }
예제 #3
0
파일: Button.cs 프로젝트: windygu/noForms
        void Button_SizeChanged(Size obj)
        {
            var ir = DisplayRectangle.Inflated(new Thickness(-edge.strokeWidth));

            textData.width  = ir.width;
            textData.height = ir.height;
        }
예제 #4
0
        public override void Draw(Graphics gr)
        {
            // While this clips the region, the lines are no longer antialiased.

            /*
             * GraphicsPath gp = new GraphicsPath();
             * gp.AddPolygon(path);
             * Region region = new Region(gp);
             * gr.SetClip(region, CombineMode.Replace);
             * gr.IntersectClip(DisplayRectangle);
             * ...
             * gr.ResetClip();
             */

            // Drawing onto a bitmap that constrains the drawing area fixes the trail problem
            // but still has issues with larger pen widths (try 10) as triangle points are clipped.
            Rectangle r      = DisplayRectangle.Grow(2);
            Bitmap    bitmap = new Bitmap(r.Width, r.Height);
            Graphics  g2     = Graphics.FromImage(bitmap);

            g2.SmoothingMode = SmoothingMode.AntiAlias;
            Point[] path = ZPath();
            g2.FillPolygon(FillBrush, path);
            g2.DrawPolygon(BorderPen, path);
            gr.DrawImage(bitmap, DisplayRectangle.X, DisplayRectangle.Y);
            bitmap.Dispose();
            g2.Dispose();
            base.Draw(gr);
        }
        protected override void InnerDraw(Graphics g, int useLength)
        {
            int   lastBand      = -1; //последний активный столбик
            float maxInLastBand = 0f; //максимальное значение частоты в последнем столбике

            for (int i = 0; i < useLength; i++)
            {
                int band = (int)((float)i / useLength * BandsCount);

                if (band > lastBand) //если сменился столбик
                {
                    //обнуляем показатель
                    lastBand      = band;
                    maxInLastBand = 0f;
                }

                float analogValue = DisplayRectangle.NormalizedHeight(SpectrumValues[i]);
                if (analogValue > maxInLastBand)
                {
                    maxInLastBand = analogValue; //пересохраняем частоту

                    DrawBand(g, band, analogValue);
                }
            }
        }
예제 #6
0
        public virtual List <ConnectionPoint> GetConnectionPoints()
        {
            List <ConnectionPoint> connectionPoints = new List <ConnectionPoint>();

            if (HasCornerConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.TopLeft, DisplayRectangle.TopLeftCorner()));
                connectionPoints.Add(new ConnectionPoint(GripType.TopRight, DisplayRectangle.TopRightCorner()));
                connectionPoints.Add(new ConnectionPoint(GripType.BottomLeft, DisplayRectangle.BottomLeftCorner()));
                connectionPoints.Add(new ConnectionPoint(GripType.BottomRight, DisplayRectangle.BottomRightCorner()));
            }

            if (HasCenterConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.LeftMiddle, DisplayRectangle.LeftMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.RightMiddle, DisplayRectangle.RightMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.TopMiddle, DisplayRectangle.TopMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.BottomMiddle, DisplayRectangle.BottomMiddle()));
            }

            if (HasLeftRightConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.LeftMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.RightMiddle()));
            }

            if (HasTopBottomConnections)
            {
                connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.TopMiddle()));
                connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomMiddle()));
            }

            return(connectionPoints);
        }
예제 #7
0
        public virtual ShapeAnchor GetBottomRightAnchor()
        {
            Size        anchorSize = new Size(anchorWidthHeight, anchorWidthHeight);
            Rectangle   r          = new Rectangle(DisplayRectangle.BottomRightCorner().Move(-anchorWidthHeight, -anchorWidthHeight), anchorSize);
            ShapeAnchor anchor     = new ShapeAnchor(GripType.BottomRight, r, Cursors.SizeNWSE);

            return(anchor);
        }
예제 #8
0
        protected void UpdateDisplayRectangle(Graphics gr)
        {
            SizeF size   = gr.MeasureString(Text, TextFont);
            Point center = DisplayRectangle.Center();

            // Grow so selection is not right on top of text, and so that anti-aliasing has some room.
            DisplayRectangle = new Rectangle(center.X - (int)(size.Width / 2), center.Y - (int)(size.Height) / 2, (int)size.Width, (int)size.Height).Grow(3);
        }
예제 #9
0
 protected override void OnMouseLeave(EventArgs e)
 {
     if (DisplayRectangle.Contains(PointToClient(Cursor.Position)))
     {
         return;
     }
     base.OnMouseLeave(e);
 }
예제 #10
0
        public override void Draw(Graphics gr, bool showSelection = true)
        {
            SizeF size    = gr.MeasureString(TOOLBOX_TEXT, TextFont);
            Point textpos = DisplayRectangle.Center().Move((int)(-size.Width / 2), (int)(-size.Height / 2));

            gr.DrawString(TOOLBOX_TEXT, TextFont, brush, textpos);
            base.Draw(gr, showSelection);
        }
예제 #11
0
 private void DragForm(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && DisplayRectangle.Contains(e.Location))
     {
         Core.ReleaseCapture();
         Core.SendMessage(Handle, Core.WM_NCLBUTTONDOWN, Core.HTCAPTION, 0);
     }
 }
예제 #12
0
        public virtual List <ShapeAnchor> GetAnchors()
        {
            // draw anchors
            List <ShapeAnchor> anchors = new List <ShapeAnchor>();
            AnchorBox          r;
            int anchorSize = 6;

            if (HasCornerAnchors) // tai cac canh
            {
                Point newPoint = new Point();
                newPoint = DisplayRectangle.TopLeft();
                r        = new AnchorBox(DisplayRectangle.TopLeft(), anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.TopLeft, r, Cursors.SizeNWSE));

                newPoint = DisplayRectangle.TopRight();
                newPoint.Offset(-anchorWidthHeight, 0);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.TopRight, r, Cursors.SizeNESW));

                newPoint = DisplayRectangle.BottomLeft();
                newPoint.Offset(0, -anchorWidthHeight);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.BottomLeft, r, Cursors.SizeNESW));

                newPoint = DisplayRectangle.BottomRight();
                newPoint.Offset(-anchorWidthHeight, -anchorWidthHeight);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.BottomRight, r, Cursors.SizeNWSE));
            }

            if (HasCenterAnchors || HasLeftRightAnchors) // tai trai va phai
            {
                Point newPoint = DisplayRectangle.LeftMiddle();
                newPoint.Offset(0, -anchorWidthHeight / 2);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.LeftMiddle, r, Cursors.SizeWE));

                newPoint = DisplayRectangle.RightMiddle();
                newPoint.Offset(-anchorWidthHeight, -anchorWidthHeight / 2);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.RightMiddle, r, Cursors.SizeWE));
            }

            if (HasCenterAnchors || HasTopBottomAnchors) // tai vi tri tren va duoi
            {
                Point newPoint = new Point();
                newPoint = DisplayRectangle.TopMiddle();
                newPoint.Offset(-anchorWidthHeight / 2, 0);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.TopMiddle, r, Cursors.SizeNS));
                newPoint = DisplayRectangle.BottomMiddle();
                newPoint.Offset(-anchorWidthHeight / 2, -anchorWidthHeight);
                r = new AnchorBox(newPoint, anchorSize);
                anchors.Add(new ShapeAnchor(ShapeAnchor.GripType.BottomMiddle, r, Cursors.SizeNS));
            }

            return(anchors);
        }
예제 #13
0
        public virtual void DrawText(Graphics gr)
        {
            SizeF size    = gr.MeasureString(Text, TextFont);
            Point textpos = DisplayRectangle.Center().Move((int)(-size.Width / 2), (int)(-size.Height / 2));
            Brush brush   = new SolidBrush(TextColor);

            gr.DrawString(Text, TextFont, brush, textpos);
            brush.Dispose();
        }
 protected override void OnMouseUp(MouseEventArgs mevent)
 {
     ReleaseButton();
     if (DisplayRectangle.Contains(mevent.Location))
     {
         HighlightButton();
     }
     base.OnMouseUp(mevent);
 }
예제 #15
0
        public virtual TextBox CreateTextBox(Point mousePosition)
        {
            TextBox tb = new TextBox();

            tb.Location = DisplayRectangle.LeftMiddle().Move(0, -10);
            tb.Size     = new Size(DisplayRectangle.Width, 20);
            tb.Text     = Text;

            return(tb);
        }
예제 #16
0
 protected override void InnerDraw(Graphics g, int useLength)
 {
     for (int i = 0; i < useLength; i++)
     {
         float x      = DisplayRectangle.NormalizedWidth((float)i / useLength);
         float height =
             DisplayRectangle.NormalizedHeight(SpectrumValues[i]);
         g.FillRectangle(Brush, DisplayRectangle.Left + x, DisplayRectangle.Bottom - height, 1, height);
     }
 }
예제 #17
0
        public override List <ConnectionPoint> GetConnectionPoints()
        {
            List <ConnectionPoint> connectionPoints = new List <ConnectionPoint>();

            connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.TopMiddle()));
            connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomMiddle()));
            connectionPoints.Add(new ConnectionPoint(GripType.Start, DisplayRectangle.BottomLeftCorner()));
            connectionPoints.Add(new ConnectionPoint(GripType.End, DisplayRectangle.BottomRightCorner()));

            return(connectionPoints);
        }
예제 #18
0
        public override void Draw(Graphics g)
        {
            var heightL = DisplayRectangle.NormalizedHeight(NormalizedVolumeL);
            var heightR = DisplayRectangle.NormalizedHeight(NormalizedVolumeR);

            g.FillRectangle(LeftBrush, DisplayRectangle.Left, DisplayRectangle.Bottom - heightL,
                            DisplayRectangle.CenterW, heightL);

            g.FillRectangle(RightBrush, DisplayRectangle.CenterW, DisplayRectangle.Bottom - heightR,
                            DisplayRectangle.CenterW, heightR);
        }
예제 #19
0
파일: Button.cs 프로젝트: windygu/noForms
        // Render methody
        public override void Draw(IDraw rt, Region dirty)
        {
            float lt = edge.strokeWidth;
            float bv = lt / 2;
            var   lr = DisplayRectangle.Inflated(new Thickness(-bv));
            var   ir = DisplayRectangle.Inflated(new Thickness(-lt));

            rt.uDraw.FillRectangle(ir, brushFill);
            rt.uDraw.DrawRectangle(lr, brushLine, edge);
            rt.uDraw.DrawText(textData, ir.Location, brushText, UTextDrawOptions.Clip, false);
        }
예제 #20
0
 protected override void OnMouseUp(MouseEventArgs mevent)
 {
     highlightRect.Location = new Point(0, 0);
     highlightAlphaTop      = 255;
     highlightAlphaBottom   = 0;
     if (DisplayRectangle.Contains(mevent.Location))
     {
         animateMouseOverTimer.Start();
     }
     base.OnMouseUp(mevent);
 }
예제 #21
0
        public override void Draw(Graphics gr)
        {
            base.Draw(gr);
            Rectangle r = DisplayRectangle.Grow(-4);

            control.Location             = r.Location;
            control.Size                 = r.Size;
            control.Text                 = Text;
            control.Font                 = TextFont;
            ((TextBox)control).Multiline = Multiline;
        }
예제 #22
0
        public override void Draw(Graphics gr)
        {
            base.Draw(gr);
            Rectangle r = DisplayRectangle.Grow(-4);

            control.Location = r.Location;
            control.Size     = r.Size;
            control.Text     = Text;
            control.Enabled  = Enabled;
            control.Visible  = Visible;
        }
예제 #23
0
 // Mouse Hooks
 public void MouseUpDown(Point location, MouseButton mb, NoForms.Common.ButtonState bs, bool inComponent, bool amClipped)
 {
     foreach (IComponent c in components)
     {
         if (c.visible)
         {
             c.MouseUpDown(location, mb, bs, c.DisplayRectangle.Contains(location),
                           amClipped ? true : !DisplayRectangle.Contains(location));
         }
     }
 }
예제 #24
0
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     if (AutoShow)
     {
         if (DisplayRectangle.Contains(Control.MousePosition) == false)
         {
             Hide();
         }
     }
 }
예제 #25
0
 public override void Draw(IDraw ra, Region dirty)
 {
     // Draw bg
     ra.uDraw.FillRectangle(DisplayRectangle, back);
     ra.uDraw.DrawRectangle(DisplayRectangle.Inflated(new Thickness(-.5f)), edge, edgeStroke);
     if (SelectionOptions.Count > 0)
     {
         Point tp = new Point(DisplayRectangle.left + textPad, DisplayRectangle.top + textPad);
         selectyTexty.text = SelectionOptions.Count > _selectedOption ? SelectionOptions[_selectedOption] : "";
         ra.uDraw.DrawText(selectyTexty, tp, edge, UTextDrawOptions.Clip, false);
     }
 }
예제 #26
0
 protected virtual void DrawTag(Graphics gr)
 {
     if (FillBrush.Color.ToArgb() == tagPen.Color.ToArgb())
     {
         Rectangle r = DisplayRectangle.Grow(-2);
         gr.DrawRectangle(altTagPen, r);
     }
     else
     {
         Rectangle r = DisplayRectangle.Grow(-2);
         gr.DrawRectangle(tagPen, r);
     }
 }
예제 #27
0
        public override void Draw(Graphics gr)
        {
            base.Draw(gr);
            Rectangle r = DisplayRectangle.Grow(-4);

            ((TrackBar)control).Minimum = Minimum;
            ((TrackBar)control).Maximum = Maximum;
            control.Location            = r.Location;
            control.Size    = r.Size;
            control.Text    = Text;
            control.Enabled = Enabled;
            control.Visible = Visible;
        }
예제 #28
0
            protected override void OnDragOver(DragEventArgs drgevent)
            {
                Point point    = PointToClient(new Point(drgevent.X, drgevent.Y));
                int   tabIndex = !DisplayRectangle.Contains(point) ? GetTabIndexAtPoint(point) : -1;

                if (tabIndex > 0 && point.X < (DiagramImageWidth / 2))
                {
                    // We're on the left edge, activate the previous tab
                    --tabIndex;
                }
                SetDragActivateTimer(tabIndex);
                base.OnDragOver(drgevent);
            }
예제 #29
0
 public override void MouseMove(Point location, bool inComponent, bool amClipped)
 {
     base.MouseMove(location, inComponent, amClipped);
     foreach (IComponent c in components)
     {
         if (c.visible)
         {
             bool child_inComponent = c.DisplayRectangle.Contains(location);
             bool child_amClipped   = amClipped ? true : !DisplayRectangle.Contains(location);
             c.MouseMove(location, child_inComponent, child_amClipped);
         }
     }
 }
예제 #30
0
        public override void Draw(Graphics gr)
        {
            Pen pen = (Pen)BorderPen.Clone();

            if (ShowLineAsSelected)
            {
                pen.Color = pen.Color.ToArgb() == Color.Red.ToArgb() ? Color.Blue : Color.Red;
            }

            gr.DrawLine(pen, DisplayRectangle.LeftMiddle(), DisplayRectangle.RightMiddle());
            pen.Dispose();

            base.Draw(gr);
        }