コード例 #1
0
ファイル: Form1.cs プロジェクト: xy19xiaoyu/DotNetBar2Demos
        /// <summary>
        /// Render the Value onto the control at post-render indicator time
        /// </summary>
        /// <param name="sender">KnobControl</param>
        /// <param name="e">PostRenderEventArgs</param>
        private void PostRenderKnobIndicator1(object sender, PostRenderEventArgs e)
        {
            KnobControl kc = sender as KnobControl;

            if (kc != null)
            {
                // Draw the knob Value (with an offset shadow)
                // on top of the KnobIndicator

                using (Font font = new Font("Arial", 30, FontStyle.Regular))
                {
                    using (StringFormat strFormat = new StringFormat(StringFormatFlags.NoClip))
                    {
                        strFormat.Alignment = StringAlignment.Center;

                        string s = kc.Value.ToString();

                        if (s.EndsWith(".0"))
                        {
                            s = s.Substring(0, s.Length - 2);
                        }

                        RectangleF r = GetTextRect(e.Bounds, font);

                        r.Offset(2, 2);
                        e.Graphics.DrawString(s, font, Brushes.Black, r, strFormat);

                        r.Offset(-2, -2);
                        e.Graphics.DrawString(s, font, Brushes.White, r, strFormat);
                    }
                }
            }
        }
コード例 #2
0
        public void ActivateIn(IEditorContainer newWindow)
        {
            container = newWindow;

            var knob = new KnobControl();

            knob.Location = new Point(0, 0);
            this.Controls.Add(knob);
            Adorn(knob);

            Adorn <Connector>(knob).Add("knobOut", new Point(12, 12), Color.SkyBlue);


            var oscillo = new Oscilloscope();

            oscillo.Location = new Point(400, 400);
            this.Controls.Add(oscillo);
            Adorn(oscillo);

            Adorn <Connector>(oscillo).Add("oscilloIn", new Point(12, 12), Color.Pink);


            var t = new TestGraph();

            t.Location = new Point(200, 200);
            this.Controls.Add(t);
            Adorn(t);
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: xy19xiaoyu/DotNetBar2Demos
        /// <summary>
        /// UpdateLabel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="label"></param>
        private void UpdateLabel(object sender, Label label)
        {
            KnobControl kc = sender as KnobControl;

            if (kc != null)
            {
                label.Text = kc.Value.ToString();
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: xy19xiaoyu/DotNetBar2Demos
        /// <summary>
        /// Renders a hilight focus rect
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RenderFocusRect(object sender, RenderFocusRectEventArgs e)
        {
            KnobControl kc = sender as KnobControl;

            if (kc != null)
            {
                Color c = Color.FromArgb(80, Color.Yellow);

                using (LinearGradientBrush lbr = new LinearGradientBrush(e.Bounds, Color.White, c, 45f))
                    e.Graphics.FillEllipse(lbr, e.Bounds);
            }
        }
コード例 #5
0
ファイル: Form1.cs プロジェクト: xy19xiaoyu/DotNetBar2Demos
        /// <summary>
        /// Render a plum colored circle at pre-render tick label time
        /// </summary>
        /// <param name="sender">KnobControl</param>
        /// <param name="e">PreRenderEventArgs</param>
        private void PreRenderTickLabel(object sender, PreRenderEventArgs e)
        {
            KnobControl kc = sender as KnobControl;

            if (kc != null)
            {
                // Locate where the current "value label" is located,
                // and then render our circle accordingly

                Point pt = GetLabelPoint(kc, e);

                e.Graphics.FillEllipse(Brushes.Plum,
                                       new Rectangle(pt.X, pt.Y, 20, 20));
            }
        }
コード例 #6
0
ファイル: Form1.cs プロジェクト: xy19xiaoyu/DotNetBar2Demos
        /// <summary>
        /// Returns tick label point
        /// </summary>
        /// <returns>Upper left tick label rect of the control</returns>
        private Point GetLabelPoint(KnobControl kc, PreRenderEventArgs e)
        {
            decimal count = kc.MaxValue - kc.MinValue;

            double rad = GetRadians(
                (float)((kc.SweepAngle * kc.Value) / count + kc.StartAngle));

            int x  = e.Bounds.X + e.Bounds.Width / 2;
            int dx = e.Bounds.Width / 2;

            Point pt = new Point();

            pt.X = (int)(Math.Cos(rad) * dx + x - 10);
            pt.Y = (int)(Math.Sin(rad) * dx + x - 10);

            return(pt);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: xy19xiaoyu/DotNetBar2Demos
        /// <summary>
        /// Render the control Value at post-render indicator time
        /// </summary>
        /// <param name="sender">KnobControl</param>
        /// <param name="e">PostRenderEventArgs</param>
        private void PostRenderKnobIndicator2(object sender, PostRenderEventArgs e)
        {
            KnobControl kc = sender as KnobControl;

            if (kc != null)
            {
                // Draw the knob Value on top of the KnobIndicator

                using (Font font = new Font("Arial", 16, FontStyle.Regular))
                {
                    using (StringFormat strFormat = new StringFormat(StringFormatFlags.NoClip))
                    {
                        strFormat.Alignment = StringAlignment.Center;

                        RectangleF r = GetTextRect(e.Bounds, font);

                        e.Graphics.DrawString(kc.Value.ToString(), font, Brushes.Black, r, strFormat);
                    }
                }
            }
        }
コード例 #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="knobControl">Associated knob control</param>
 public KnobStyle1(KnobControl knobControl)
     : base(knobControl)
 {
 }
コード例 #9
0
 /// <summary>
 /// KnobControlActionList
 /// </summary>
 /// <param name="knobControl">Associated KnobControl</param>
 public KnobControlActionList(KnobControl knobControl)
     : base(knobControl)
 {
     _KnobControl = knobControl;
 }
コード例 #10
0
        internal Rectangle ZoneIndicatorBounds; // Zone indicator bounding rectangle

        #endregion

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="knobControl">Associated knob control</param>
        public BaseKnob(KnobControl knobControl)
        {
            Knob = knobControl;

            DefaultColorTable = new KnobColorTable();
        }