Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            _saveFileDialog.Filter = _openFileDialog.Filter;
            _title = Text;

            NamedCommandTable commands = new NamedCommandTable();
            commands.FillStandardCommands();
            _commandProvider.CommandTable = commands;

            CommandContainer cc = new CommandContainer();

            cc.Add(new Command<TextBoxBase>(StandardCommands.Undo,
                delegate(TextBoxBase control) { control.Undo(); },
                delegate(TextBoxBase control) { return !control.ReadOnly && control.CanUndo; }));

            cc.Add(new Command<TextBoxBase>(StandardCommands.Copy,
                delegate(TextBoxBase control) { control.Copy(); },
                delegate(TextBoxBase control) { return control.SelectionLength > 0; }));
            cc.Add(new Command<TextBoxBase>(StandardCommands.Cut,
                delegate(TextBoxBase control) { control.Cut(); },
                delegate(TextBoxBase control) { return !control.ReadOnly && control.SelectionLength > 0; }));
            cc.Add(new Command<TextBoxBase>(StandardCommands.Paste,
                delegate(TextBoxBase control) { control.Paste(); },
                delegate(TextBoxBase control) { return !control.ReadOnly && Clipboard.ContainsText(); }));

            cc.Add(new Command<TextBoxBase>(StandardCommands.SelectAll,
                delegate(TextBoxBase control) { control.SelectAll(); }));

            _commandsByType = new Dictionary<Type, ICommandContainer>();
            _commandsByType.Add(typeof(TextBoxBase), cc);

            _focusWatchdog = new ControlFocusWatchdog();
            _focusWatchdog.Watch(_wikiBox, _htmlBox);

            switch (Settings.Default.NewLine.ToLowerInvariant())
            {
                case "mac":
                case "cr": _newLine = "\r"; break;
                case "windows":
                case "win":
                case "crlf": _newLine = "\r\n"; break;
                case "unix":
                case "lf": _newLine = "\n"; break;
                default: _newLine = Environment.NewLine; break;
            }

            _webBrowser.DocumentCompleted += delegate { _webBrowser.AllowNavigation = false; };
        }
            public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
            {
                if (_names == null)
                {
                    NamedCommandTable commands = new NamedCommandTable();
                    commands.FillStandardCommands();
                    string[] names = Enumerable.ToArray(commands.Names);
                    Array.Sort(names, StringComparer.InvariantCulture);
                    _names = names;
                }

                return new StandardValuesCollection(_names);
            }