Example #1
0
        private void Plot_button_click(object sender, RoutedEventArgs e)
        {
            string expression = Screen.Text.Trim();
            int    sizeX      = (int)Canvas.Width;
            int    sizeY      = (int)Canvas.Height;
            double minX       = graph.getXLowerBound();
            double maxX       = graph.getXUpperBound();
            double minY       = graph.getYLowerBound();
            double maxY       = graph.getYUpperBound();

            System.Drawing.Point currentPoint  = new System.Drawing.Point();
            System.Drawing.Point previousPoint = new System.Drawing.Point();
            for (double x = minX; x < maxX; x += (maxX - minX) / sizeX)
            {
                Line line = new Line();
                line.Stroke = System.Windows.Media.Brushes.Black;
                double y = graph.getY(expression, x);
                currentPoint.X = (int)(x / ((maxX - minX) / sizeX) - minX / ((maxX - minX) / (double)sizeX));
                currentPoint.Y = (int)(sizeY - (y / ((maxY - minY) / sizeY) - minY / ((maxY - minY) / (double)sizeY)));

                line.X1 = previousPoint.X;
                line.Y1 = previousPoint.Y;
                line.X2 = currentPoint.X;
                line.Y2 = currentPoint.Y;
                Canvas.Children.Add(line);
                Console.WriteLine(line.X1 + ", " + line.Y1);
                Console.WriteLine(line.X2 + ", " + line.Y2);


                previousPoint = currentPoint;
            }
            TextBlock.AppendText(Screen.Text.Trim() + " is plotted\n");
        }
Example #2
0
        private void equals_button_Click(object sender, RoutedEventArgs e)
        {
            //trim imput, send into parser
            //get answer from parser, display on screen
            double ans = parser.Parse(Screen.Text.Trim(), isRadians);

            //add input and answer to history
            TextBlock.AppendText(Screen.Text.Trim() + " = " + ans.ToString() + "\n");
            TextBlock.ScrollToEnd();

            //clear screen
            Screen.Text = ButtonControl.ClearButtonPress(Screen.Text);
        }
        private void Print()
        {
            string new_text = Data.deta_time;

            string fontName = (string)ComboBoxFont.SelectedItem;
            double size     = Convert.ToDouble(ComboBoxSize.SelectedItem) * 92.0 / 72.0;

            TextBlock.Selection.ApplyPropertyValue(System.Windows.Controls.RichTextBox.FontSizeProperty, size);
            TextBlock.Selection.ApplyPropertyValue(System.Windows.Controls.RichTextBox.FontFamilyProperty, fontName);

            TextBlock.AppendText(new_text);
            TextBlock.Focus();
        }