UserInterface.ProgWin.loadProgram C# (CSharp) Method

loadProgram() public method

public loadProgram ( int read, int write, string text ) : void
read int
write int
text string
return void
            public void loadProgram(int read, int write, string text)
            {
                TextPointer tp = rtbInput.CaretPosition.GetPositionAtOffset(0, LogicalDirection.Forward);
                rtbInput.CaretPosition.InsertTextInRun(text);
                //rtbChat.CaretPosition.InsertParagraphBreak();
                rtbInput.CaretPosition = tp;
            }

Usage Example

Beispiel #1
0
      /// <summary>
      /// This will load the file and pass the text to the editor.
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void submnuLoad_Click(object sender, RoutedEventArgs e)
      {
          Stream myStream = null;
          OpenFileDialog openFileDialog1 = new OpenFileDialog();

          openFileDialog1.InitialDirectory = "c:\\";
          openFileDialog1.Filter = "ssf files (*.ssf)|*.ssf|All files (*.*)|*.*";
          openFileDialog1.FilterIndex = 1;
          openFileDialog1.RestoreDirectory = true;
          String text = "";

          if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
          {
              try
              {
                  if ((myStream = openFileDialog1.OpenFile()) != null)
                  {
                      StreamReader sr = new StreamReader(openFileDialog1.FileName);
                      using(sr)
                      {
                          string line;
                          while ((line = sr.ReadLine()) != null)
                              text = text + line + "\n";
                      }
                  }
                  ProgWin editor = new ProgWin(ProgWin.editorType.owner);
                  editor.Show();
                  editor.loadProgram(0, 0, text);
                  editor.setUserList(userList);
              }
              catch (Exception ex)
              {
                  System.Windows.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
              }
          }

      }