Пример #1
0
        private void TxtBoxInput_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                txtBoxOutput.Clear();

                string output = GetHistoryCode();

                output += txtBoxInput.Text + "\n"; //Add new command to other commands
                output += "END.";
                try
                {
                    MyCanvas.Children.Clear();
                    DrawingService drawingService = new DrawingService(MyCanvas);
                    txtBoxOutput.Text = LanguageExecutor.Compile(output, drawingService); //If compiled succesfuly
                    listViewHistory.Items.Add(txtBoxInput.Text);
                    txtBoxInput.Clear();
                    txtBoxInput.Focus();
                }
                catch (Exception ex) //Best if own exceptions, but i am lazy
                {
                    txtBoxOutput.Text = "Compiler error: " + ex.Message;
                }
            }
        }
Пример #2
0
 private void btnCompile_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ImageViewCanvas img = new ImageViewCanvas();
         img.Show();
         LanguageExecutor.Compile(txtBox_Code.Text, new DrawingService(img.ImgCanvas));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Compilation fail", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }