예제 #1
0
        protected static Color SetColorAccToState(FunctionEditState _state)
        {
            switch (_state)
            {
            case FunctionEditState.IS_BEING_DRAWIN:
                return(Colors.Black);

            case FunctionEditState.SELECTED:
                return(Colors.OrangeRed);

            default:
                return(Colors.DimGray);
            }
        }
예제 #2
0
        protected void DrawText(double _x, double _y, int _tag, string _content, FunctionEditState _state = FunctionEditState.REGULAR)
        {
            // scale input for drawing on the canvas
            double x_scaled = (_x - this.xs[0]) * this.fact_x;
            double y_scaled = this.canvas.Height - (_y - this.ys[0]) * this.fact_y;

            TextBlock tb = new TextBlock();

            tb.Height = 20;
            tb.Width  = 60;
            tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            tb.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            tb.Margin     = new Thickness(x_scaled - 60, y_scaled - 20, 0, 0);
            tb.Foreground = new SolidColorBrush(MValueFunct2DBase.SetColorAccToState(_state));
            tb.Tag        = _tag;
            tb.Text       = _content;

            this.canvas.Children.Add(tb);
        }
예제 #3
0
        protected void DrawPoint(double _x, double _y, int _tag, FunctionEditState _state = FunctionEditState.REGULAR)
        {
            // scale input for drawing on the canvas
            double x_scaled = (_x - this.xs[0]) * this.fact_x;
            double y_scaled = this.canvas.Height - (_y - this.ys[0]) * this.fact_y;

            Rectangle rect = new Rectangle();

            rect.Height = 6;
            rect.Width  = 6;
            rect.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            rect.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            rect.Margin          = new Thickness(x_scaled - 3, y_scaled - 3, 0, 0);
            rect.Stroke          = new SolidColorBrush(MValueFunct2DBase.SetColorAccToState(_state));
            rect.StrokeThickness = 2;
            rect.Tag             = _tag;
            rect.ToolTip         = "(" + _x.ToString("F2", MValueFunct2DBase.FORMATTER) + " " +
                                   _y.ToString("F2", MValueFunct2DBase.FORMATTER) + ")";
            this.canvas.Children.Add(rect);
        }
예제 #4
0
        protected void DrawLine(double _x1, double _y1, double _x2, double _y2, Point _tag, FunctionEditState _state = FunctionEditState.REGULAR)
        {
            // scale input for drawing on the canvas
            double x1_scaled = (_x1 - this.xs[0]) * this.fact_x;
            double y1_scaled = this.canvas.Height - (_y1 - this.ys[0]) * this.fact_y;
            double x2_scaled = (_x2 - this.xs[0]) * this.fact_x;
            double y2_scaled = this.canvas.Height - (_y2 - this.ys[0]) * this.fact_y;

            Line li = new Line();

            li.X1              = x1_scaled;
            li.Y1              = y1_scaled;
            li.X2              = x2_scaled;
            li.Y2              = y2_scaled;
            li.Stroke          = new SolidColorBrush(MValueFunct2DBase.SetColorAccToState(_state));
            li.StrokeThickness = 2;
            li.Tag             = _tag;
            li.SetValue(RenderOptions.EdgeModeProperty, EdgeMode.Aliased);
            li.MouseUp += line_MouseUp;
            this.canvas.Children.Add(li);
        }