Ejemplo n.º 1
0
        private EventElement CreateEventGUI(VisualElement root, EventRow @event)
        {
            var eventElem = new EventElement {
                text = @event.Id
            };

            var stagesContainer = new StagesContainer();

            eventElem.Content.Add(new InvokeTypeElement {
                value = @event.InvokeType.ToKeyword()
            });
            eventElem.Content.Add(stagesContainer);

            foreach (var stage in @event.Stages)
            {
                var stageContainer = new StageContainer();
                stagesContainer.Add(stageContainer);

                stageContainer.Add(new StageElement {
                    value = $"{stage.Index}"
                });

                if (stage.MaxConstraint >= 0)
                {
                    stageContainer.Add(new StageElement {
                        value = $"<{stage.MaxConstraint}>"
                    });
                }

                var commandContainer = new CommandContainer();
                stageContainer.Add(commandContainer);

                foreach (var command in stage.Commands)
                {
                    commandContainer.Add(new CommandElement {
                        value = command.Id
                    });
                }
            }

            root.Add(eventElem);
            return(eventElem);
        }
Ejemplo n.º 2
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; };
        }