Exemple #1
0
        public WordPad(string file)
        {
            // Object setup
            changed = false;
            if (file != null)
            {
                filename = file;
            }
            else
            {
                filename = "Document";
            }
            filetype = RichTextBoxStreamType.RichText;

            // UI Setup
            toolbarpanel = new Panel();
            buttons      = new ToolBar();
            edit         = new RichTextBox();
            formatting   = new WordPadFormat(this);
            status       = new StatusBar();
            Configuration.Apply(this);                  // Call before creating the menu to have MRU loaded
            menu = new WordPadMenu(this, status);

            this.Menu = menu.MainMenu;

            status.TextChanged += new EventHandler(StatusTextChangedHandler);

            edit.HideSelection = false;

            buttons.Appearance = ToolBarAppearance.Flat;
            buttons.TextAlign  = ToolBarTextAlign.Right;
            buttons.ButtonSize = new Size(12, 12);
            buttons.Buttons.Add("New");
            buttons.Buttons.Add("Open");
            buttons.Buttons.Add("Save");
            buttons.Divider = false;

            buttons.Location    = new Point(0, 0);
            formatting.Location = new Point(0, buttons.Height);
            toolbarpanel.Height = buttons.Height + formatting.Height + 8;
            formatting.Dock     = DockStyle.Bottom;

            findbar         = new FindBar(edit);
            findbar.Visible = false;

            // Register all required events
            this.Closing     += new CancelEventHandler(WordPadClosing);
            edit.TextChanged += new EventHandler(DocumentChanged);

            // Layout
            toolbarpanel.Controls.Add(buttons);
            toolbarpanel.Controls.Add(formatting);

            // Edit must be first to be 'filled' properly
            this.Controls.Add(edit);
            this.Controls.Add(toolbarpanel);
            this.Controls.Add(findbar);
            this.Controls.Add(status);


            toolbarpanel.Dock = DockStyle.Top;
            status.Dock       = DockStyle.Bottom;
            findbar.Dock      = DockStyle.Bottom;
            edit.Dock         = DockStyle.Fill;

            // Load our file, if any
            if (file != null)
            {
                OpenFile(file, file.EndsWith("txt") ? RichTextBoxStreamType.PlainText : RichTextBoxStreamType.RichText);
            }
            UpdateTitle();
        }
Exemple #2
0
		public WordPad(string file) {
			// Object setup
			changed = false;
			if (file != null) {
				filename = file;
			} else {
				filename = "Document";
			}
			filetype = RichTextBoxStreamType.RichText;

			// UI Setup
			toolbarpanel = new Panel();
			buttons = new ToolBar();
			edit = new RichTextBox();
			formatting = new WordPadFormat(this);
			status = new StatusBar();
			Configuration.Apply(this);	// Call before creating the menu to have MRU loaded
			menu = new WordPadMenu(this, status);

			this.Menu = menu.MainMenu;

			status.TextChanged += new EventHandler (StatusTextChangedHandler);

			edit.HideSelection = false;

			buttons.Appearance = ToolBarAppearance.Flat;
			buttons.TextAlign = ToolBarTextAlign.Right;
			buttons.ButtonSize = new Size(12, 12);
			buttons.Buttons.Add("New");
			buttons.Buttons.Add("Open");
			buttons.Buttons.Add("Save");
			buttons.Divider = false;

			buttons.Location = new Point(0, 0);
			formatting.Location = new Point(0, buttons.Height);
			toolbarpanel.Height = buttons.Height + formatting.Height + 8;
			formatting.Dock = DockStyle.Bottom;

			findbar = new FindBar (edit);
			findbar.Visible = false;

			// Register all required events
			this.Closing += new CancelEventHandler(WordPadClosing);
			edit.TextChanged += new EventHandler(DocumentChanged);

			// Layout
			toolbarpanel.Controls.Add(buttons);
			toolbarpanel.Controls.Add(formatting);

			// Edit must be first to be 'filled' properly
			this.Controls.Add(edit);
			this.Controls.Add(toolbarpanel);
			this.Controls.Add (findbar);
			this.Controls.Add(status);
			
			
			toolbarpanel.Dock = DockStyle.Top;
			status.Dock = DockStyle.Bottom;
			findbar.Dock = DockStyle.Bottom;
			edit.Dock = DockStyle.Fill;

			// Load our file, if any
			if (file != null) {
				OpenFile(file, file.EndsWith("txt") ? RichTextBoxStreamType.PlainText : RichTextBoxStreamType.RichText);
			}
			UpdateTitle();
		}