Пример #1
0
 public void PutText(ITestTextBox textBox, String[] lines, int selectionStart)
 {
     if(textBox == null)
     {
         textBox = this.textBox;
     }
     textBox.Lines = lines;
     textBox.SelectionStart = selectionStart;
     textBox.ScrollToCaret();
 }
Пример #2
0
        public XMLNotepad()
        {
            Text = "XML Notepad";
            textBox = new TestableTextBox();
            textBox.Parent = this;
            textBox.Dock = DockStyle.Fill;
            textBox.BorderStyle = BorderStyle.None;
            textBox.Multiline = true;
            textBox.ScrollBars = ScrollBars.Both;
            textBox.AcceptsTab = true;

            insertPre = new MenuItem("Insert &Pre", new EventHandler(MenuInsertPre));
            insertSection = new MenuItem("Insert &Section", new EventHandler(MenuInsertSection));

            MenuItem fileMenu = new MenuItem("&File");
            MenuItem newFile = new MenuItem("&New");
            newFile.Click += new EventHandler(MenuFileNewOnClick);
            newFile.Shortcut = Shortcut.CtrlN;
            fileMenu.MenuItems.Add(newFile);

            openFile = new MenuItem("&Open...");
            openFile.Click += new EventHandler(MenuFileOpenOnClick);
            openFile.Shortcut = Shortcut.CtrlO;
            fileMenu.MenuItems.Add(openFile);

            saveFile = new MenuItem("&Save");
            saveFile.Click += new EventHandler(MenuFileSaveOnClick);
            saveFile.Shortcut = Shortcut.CtrlS;
            fileMenu.MenuItems.Add(saveFile);

            MenuItem saveAsFile = new MenuItem("Save &As...");
            saveAsFile.Click += new EventHandler(MenuFileSaveAsOnClick);
            saveAsFile.Shortcut = Shortcut.CtrlA;
            fileMenu.MenuItems.Add(saveAsFile);

            insertUnorderedList = new MenuItem("Insert &UL", new EventHandler(MenuInsertUnorderedList));

            this.Menu = new MainMenu(new MenuItem[] {fileMenu, insertPre, insertSection, insertUnorderedList});
            textBox.KeyDown += new KeyEventHandler(textBox_KeyDown);
            textBox.KeyPress += new KeyPressEventHandler(textBox_KeyPress);
            model = new TextModel();
            InitializeDelegates(model);
        }