Exemple #1
0
        private void CurveTypeDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (EditCurve == null)
            {
                return;
            }

            EditCurve.Type = (ResponseCurve.CurveType)CurveTypeDropdown.SelectedIndex;
            CurvePictureBox.Refresh();
        }
Exemple #2
0
        internal void AttachCurve(ResponseCurve curve)
        {
            EditCurve = curve;

            CurveTypeDropdown.SelectedIndex = (int)curve.Type;
            SlopeEditBox.Value           = (decimal)curve.Slope;
            ExponentEditBox.Value        = (decimal)curve.Exponent;
            HorizontalShiftEditBox.Value = (decimal)curve.XShift;
            VerticalShiftEditBox.Value   = (decimal)curve.YShift;

            CurvePictureBox.Refresh();
        }
        private void CurveTypeDropdown_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (EditingCurve == null)
            {
                return;
            }

            var prev = EditingCurve.Type;

            EditingCurve.Type = (ResponseCurve.CurveType)CurveTypeDropdown.SelectedIndex;
            CurvePictureBox.Refresh();

            if (EditingCurve.Type != prev)
            {
                EditingProject.MarkDirty();
            }
        }
Exemple #4
0
        public EditWidgetResponseCurve()
        {
            InitializeComponent();
            CurveTypeDropdown.SelectedIndex = 0;

            var arrowcap = new System.Drawing.Drawing2D.AdjustableArrowCap(5.0f, 5.0f);

            ThickBlackArrowPen.CustomStartCap = arrowcap;
            ThickBlackArrowPen.CustomEndCap   = arrowcap;

            CurvePictureBox.Paint += (e, args) =>
            {
                args.Graphics.DrawLine(ThickBlackArrowPen, ConvertXYToPoint(-0.2, 0.0), ConvertXYToPoint(1.2, 0.0));
                args.Graphics.DrawLine(ThickBlackArrowPen, ConvertXYToPoint(0.0, -0.2), ConvertXYToPoint(0.0, 1.2));

                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(-0.2, 1.0), ConvertXYToPoint(1.2, 1.0));
                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(1.0, -0.2), ConvertXYToPoint(1.0, 1.2));

                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(-0.035, 0.25), ConvertXYToPoint(0.035, 0.25));
                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(-0.04, 0.5), ConvertXYToPoint(0.04, 0.5));
                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(-0.035, 0.75), ConvertXYToPoint(0.035, 0.75));

                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(0.25, -0.035), ConvertXYToPoint(0.25, 0.035));
                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(0.5, -0.04), ConvertXYToPoint(0.5, 0.04));
                args.Graphics.DrawLine(Pens.Black, ConvertXYToPoint(0.75, -0.035), ConvertXYToPoint(0.75, 0.035));

                if (EditCurve == null)
                {
                    return;
                }

                Point previousPoint = ConvertXYToPoint(0.0, EditCurve.ComputeValue(0.0));

                for (double x = 0.0; x <= 1.0; x += 0.001)
                {
                    double y = EditCurve.ComputeValue(x);
                    Point  p = ConvertXYToPoint(x, y);

                    args.Graphics.DrawLine(Pens.Blue, previousPoint, p);
                    previousPoint = p;
                }
            };

            SlopeEditBox.ValueChanged += (e, args) =>
            {
                if (EditCurve == null)
                {
                    return;
                }

                EditCurve.Slope = (double)SlopeEditBox.Value;

                CurvePictureBox.Refresh();
            };

            ExponentEditBox.ValueChanged += (e, args) =>
            {
                if (EditCurve == null)
                {
                    return;
                }

                EditCurve.Exponent = (double)ExponentEditBox.Value;

                CurvePictureBox.Refresh();
            };

            HorizontalShiftEditBox.ValueChanged += (e, args) =>
            {
                if (EditCurve == null)
                {
                    return;
                }

                EditCurve.XShift = (double)HorizontalShiftEditBox.Value;

                CurvePictureBox.Refresh();
            };

            VerticalShiftEditBox.ValueChanged += (e, args) =>
            {
                if (EditCurve == null)
                {
                    return;
                }

                EditCurve.YShift = (double)VerticalShiftEditBox.Value;

                CurvePictureBox.Refresh();
            };
        }