Exemple #1
0
        private void View_ParametricFunctionFormOkPressed(string arg1, string arg2)
        {
            try
            {
                string PostfixExpression_1;
                string PostfixExpression_2;

                if (!Exists($"[{arg1};{arg2}]"))
                {
                    PostfixExpression_1 = Parser.ConvertToPostfix(arg1);
                    PostfixExpression_2 = Parser.ConvertToPostfix(arg2);

                    View.Sheet = depiction.DrawCurve(pen, scale, PostfixExpression_1, PostfixExpression_2);

                    FunctionsToDraw.Add(new Curve(arg1, arg2, PostfixExpression_1, PostfixExpression_2, pen.Color, pen.Width, pen.DashStyle));

                    View.MessageBoard += $"Set Parametric function: [{arg1};{arg2}]";

                    View.AddfunctionInListBox("[" + arg1 + ";" + arg2 + "]", pen.Color);
                }
            }
            catch (Exception exception)
            {
                View.MessageBoard += exception.Message;
            }
        }
        private void TracingDataForm_KeyDown(object sender, KeyEventArgs e)
        {
            int offsetX = Scale;
            int offsetY = Scale;

            switch (e.KeyCode)
            {
            case Keys.Oemcomma:    //<
                MoveLineLeft();
                break;

            case Keys.OemPeriod:    //>
                MoveLineRight();
                break;

            case Keys.Left:
                Painter.StartPosition = new Point(offsetX, 0);
                Painter.DrawScene(colorNet, colorAxes, Scale);
                ViewPort = Painter.DrawCurve(penForCurve, Parser.GetValues(functionPostfix,
                                                                           Scale, Painter.CoordinatePlaneLocation.leftEdge, Painter.CoordinatePlaneLocation.rightEdge));
                buffer             = new Bitmap(ViewPort);
                segmentXLabel.Text = $"Segment X: [{Painter.CoordinatePlaneLocation.leftEdge/Scale};{Painter.CoordinatePlaneLocation.rightEdge/Scale}]";
                segmentYLabel.Text = $"Segment Y: [{Painter.CoordinatePlaneLocation.bottomEdge / Scale};{Painter.CoordinatePlaneLocation.topEdge / Scale}]";
                break;

            case Keys.Right:
                Painter.StartPosition = new Point(-offsetX, 0);
                Painter.DrawScene(colorNet, colorAxes, Scale);
                ViewPort = Painter.DrawCurve(penForCurve, Parser.GetValues(functionPostfix,
                                                                           Scale, Painter.CoordinatePlaneLocation.leftEdge, Painter.CoordinatePlaneLocation.rightEdge));
                buffer             = new Bitmap(ViewPort);
                segmentXLabel.Text = $"Segment X: [{Painter.CoordinatePlaneLocation.leftEdge / Scale};{Painter.CoordinatePlaneLocation.rightEdge / Scale}]";
                segmentYLabel.Text = $"Segment Y: [{Painter.CoordinatePlaneLocation.bottomEdge / Scale};{Painter.CoordinatePlaneLocation.topEdge / Scale}]";
                break;

            case Keys.Up:
                Painter.StartPosition = new Point(0, offsetY);
                Painter.DrawScene(colorNet, colorAxes, Scale);
                ViewPort = Painter.DrawCurve(penForCurve, Parser.GetValues(functionPostfix,
                                                                           Scale, Painter.CoordinatePlaneLocation.leftEdge, Painter.CoordinatePlaneLocation.rightEdge));
                buffer             = new Bitmap(ViewPort);
                segmentXLabel.Text = $"Segment X: [{Painter.CoordinatePlaneLocation.leftEdge / Scale};{Painter.CoordinatePlaneLocation.rightEdge / Scale}]";
                segmentYLabel.Text = $"Segment Y: [{Painter.CoordinatePlaneLocation.bottomEdge / Scale};{Painter.CoordinatePlaneLocation.topEdge / Scale}]";
                break;

            case Keys.Down:
                Painter.StartPosition = new Point(0, -offsetY);
                Painter.DrawScene(colorNet, colorAxes, Scale);
                ViewPort = Painter.DrawCurve(penForCurve, Parser.GetValues(functionPostfix,
                                                                           Scale, Painter.CoordinatePlaneLocation.leftEdge, Painter.CoordinatePlaneLocation.rightEdge));
                buffer             = new Bitmap(ViewPort);
                segmentXLabel.Text = $"Segment X: [{Painter.CoordinatePlaneLocation.leftEdge / Scale};{Painter.CoordinatePlaneLocation.rightEdge / Scale}]";
                segmentYLabel.Text = $"Segment Y: [{Painter.CoordinatePlaneLocation.bottomEdge / Scale};{Painter.CoordinatePlaneLocation.topEdge / Scale}]";
                break;
            }
        }
Exemple #3
0
        private void TrapezoidsCount_ValueChanged(object sender, EventArgs e)
        {
            if (trapezoidsCount.Value < 500 && trapezoidsCount.Value >= 100)
            {
                trapezoidsCount.Increment = 10;
            }
            else if (trapezoidsCount.Value < 100)
            {
                trapezoidsCount.Increment = 1;
            }
            if (trapezoidsCount.Value >= 500)
            {
                trapezoidsCount.Increment = 50;
            }

            try
            {
                if (TM)
                {
                    depiction.DrawScene(colorNet, colorAxes, Scale);
                    ViewPort = depiction.DrawCurve(Pens.Red, Parser.GetValues(selectedfunction_Postfix,
                                                                              Scale, depiction.CoordinatePlaneLocation.leftEdge, depiction.CoordinatePlaneLocation.rightEdge));
                    ViewPort = depiction.DrawVerticalLine((float)x1NUD.Value * Scale);
                    ViewPort = depiction.DrawVerticalLine((float)x2NUD.Value * Scale);

                    GetValueByTrapezoidRule();
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public TracingDataForm(IMainForm View, int scale, ListView.ListViewItemCollection items)
        {
            InitializeComponent();
            ///Add all available explicit functions to the list
            foreach (ListViewItem item in items)
            {
                if (!item.Text.Contains("["))
                {
                    comboBoxForFunctions.Items.Add(item.Text);
                }
            }
            if (comboBoxForFunctions.Items.Count != 0)
            {
                this.comboBoxForFunctions.SelectedItem = comboBoxForFunctions.Items[0];
            }
            ///Set colors for pens
            penForCurve           = new Pen(Color.Blue, 2);
            penForCross           = new Pen(Color.Red, 2);
            penForCross.DashStyle = DashStyle.Dash;
            ///Set the scale
            Scale = scale;

            this.View = View;
            ///Choose the first function in the list
            functionInfix   = comboBoxForFunctions.Items[0].ToString();
            functionPostfix = Parser.ConvertToPostfix(functionInfix);

            offset = 0;

            functionLabel.Text = $"f(x) = {functionInfix}";

            Painter = new Depiction(scene.Width, scene.Height);

            Painter.DrawScene(colorNet, colorAxes, scale);

            ViewPort = Painter.DrawCurve(penForCurve, Parser.GetValues(functionPostfix,
                                                                       scale, Painter.CoordinatePlaneLocation.leftEdge, Painter.CoordinatePlaneLocation.rightEdge));

            buffer = new Bitmap(ViewPort);

            this.DoneButton.Click += DoneButton_Click;

            this.comboBoxForFunctions.SelectedIndexChanged += ComboBoxForFunctions_SelectedIndexChanged;

            penForDerivativeCurve           = new Pen(Color.CadetBlue, 2);
            penForDerivativeCurve.DashStyle = DashStyle.Dash;


            comboBoxForFunctions.LostFocus += ComboBoxForFunctions_LostFocus;
            // this.KeyPreview = true;

            ///Prohibit to edit the text
            comboBoxForFunctions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            incrementValueBox.ReadOnly         = true;

            incrementValueBox.ValueChanged += IncrementValueBox_ValueChanged;

            segmentXLabel.Text = $"Segment X: [{Painter.CoordinatePlaneLocation.leftEdge / Scale};{Painter.CoordinatePlaneLocation.rightEdge / Scale}]";
            segmentYLabel.Text = $"Segment Y: [{Painter.CoordinatePlaneLocation.bottomEdge / Scale};{Painter.CoordinatePlaneLocation.topEdge / Scale}]";
        }
Exemple #5
0
        public AreaForm(IMainForm View, int Scale, ListView.ListViewItemCollection items)
        {
            InitializeComponent();
            this.View  = View;
            this.Scale = Scale;

            foreach (ListViewItem item in items)
            {
                functionComboBox.Items.Add(item.Text);
            }
            this.functionComboBox.SelectedItem = functionComboBox.Items[0];
            selectedfunction_Infix             = functionComboBox.SelectedItem.ToString();
            selectedfunction_Postfix           = Parser.ConvertToPostfix(selectedfunction_Infix);

            analyzeButton.Click += AnalyzeButton_Click;
            exitButton.Click    += ExitButton_Click;
            this.KeyDown        += AreaForm_KeyDown;

            functionComboBox.SelectedIndexChanged += FunctionComboBox_SelectedIndexChanged;

            depiction = new Depiction(viewPort.Width, viewPort.Height);
            ViewPort  = depiction.DrawScene(colorNet, colorAxes, Scale);
            ViewPort  = depiction.DrawCurve(Pens.Red, Parser.GetValues(selectedfunction_Postfix, Scale,
                                                                       depiction.CoordinatePlaneLocation.leftEdge, depiction.CoordinatePlaneLocation.rightEdge));


            ShowVisibleSegments();
            functionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            rectanglesCount.ReadOnly       = true;
            iterationsCount.ReadOnly       = true;

            this.DoneButton.Click        += DoneButton_Click;
            rectanglesCount.ValueChanged += NumericUpDown_ValueChanged;
            trapezoidsCount.ValueChanged += TrapezoidsCount_ValueChanged;
        }
        private void ComboBoxForFunctions_SelectedIndexChanged(object sender, EventArgs e)
        {
            Painter = new Depiction(scene.Width, scene.Height);

            Painter.DrawScene(colorNet, colorAxes, Scale);
            functionInfix      = comboBoxForFunctions.SelectedItem.ToString();
            functionLabel.Text = $"f(x) = {functionInfix}";
            functionPostfix    = Parser.ConvertToPostfix(functionInfix);
            ViewPort           = Painter.DrawCurve(penForCurve, Parser.GetValues(functionPostfix,
                                                                                 Scale, Painter.CoordinatePlaneLocation.leftEdge, Painter.CoordinatePlaneLocation.rightEdge));

            buffer = new Bitmap(ViewPort);
        }