コード例 #1
0
ファイル: Presenter.cs プロジェクト: MathMark/MathAnalyser
        bool CN = true;  //coordinate net

        public Presenter(IMainForm View)
        {
            this.View = View;

            View.EnterPressed     += View_EnterPressed;
            View.SheetSizeChanged += View_SheetSizeChanged;
            View.SheetMouseWheel  += View_SheetMouseWheel;
            View.SetColor         += View_SetColor;
            View.SetDashStyle     += View_SetDashStyle;


            View.MoveGraph    += View_MoveGraph;
            View.FinishMoving += View_FinishMoving;

            View.DeleteFunctionsButtonPressed += View_DeleteFunctionsButtonPressed;

            View.DeleteFunctionButtonPressed     += View_DeleteFunctionButtonPressed;
            View.ChangeColorButtonPressed        += View_ChangeColorButtonPressed;
            View.ParametricFunctionFormOkPressed += View_ParametricFunctionFormOkPressed;
            View.OnOffNumericLinesButtonClick    += View_OnOffNumericLinesButtonClick;
            View.ChangeBackroundButtonPressed    += View_ChangeBackroundButtonPressed;
            View.OnOffCoordinateNetButtonPressed += View_OnOffCoordinateNetButtonPressed;

            FunctionsToDraw = new List <Curve>();
            depiction       = new Depiction(View.SheetWidth, View.SheetHeight);
            pen             = new Pen(Color.YellowGreen, 2);
            colordialog     = new ColorDialog();

            View.CenterButtonClick     += View_CenterButtonClick;
            View.SaveButtonPressed     += View_SaveButtonPressed;
            colorIsSet                  = false;
            View.PenWidthButtonPressed += View_PenWidthButtonPressed;

            RefreshScene(0, 0);
        }
コード例 #2
0
        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}]";
        }
コード例 #3
0
ファイル: AreaForm.cs プロジェクト: MathMark/MathAnalyser
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: Depiction.cs プロジェクト: MathMark/MathAnalyser
        public Bitmap DrawDots(Depiction p, Bitmap buffer, int size, Color color, PointF[] locations)
        {
            Pen      pen = new Pen(Color.Yellow);
            Graphics s   = Graphics.FromImage(buffer);

            s.TranslateTransform(p.CoordinatePlaneLocation.transform.OffsetX,
                                 p.CoordinatePlaneLocation.transform.OffsetY);
            foreach (PointF location in locations)
            {
                RectangleF positionRectangle = new RectangleF(location.X - size / 2, location.Y - size / 2, size, size);
                s.DrawEllipse(pen, positionRectangle);
            }
            return(buffer);
        }
コード例 #6
0
ファイル: Presenter.cs プロジェクト: MathMark/MathAnalyser
 private void View_SheetSizeChanged(object sender, EventArgs e)
 {
     depiction = new Depiction(View.SheetWidth, View.SheetHeight);
     RefreshScene(0, 0);
     DrawFunctionsInList();
 }
コード例 #7
0
ファイル: Presenter.cs プロジェクト: MathMark/MathAnalyser
 private void View_CenterButtonClick(object sender, EventArgs e)
 {
     depiction = new Depiction(View.SheetWidth, View.SheetHeight);
     RefreshScene(0, 0);
     DrawFunctionsInList();
 }