Exemplo n.º 1
0
        private void CommandsWindow_Loaded(object sender, RoutedEventArgs e)
        {
            string initialValue = null;

            if (Model.AddinConfiguration.Commands.Count > 0)
            {
                CommanderCommand selectedItem = null;
                if (!string.IsNullOrEmpty(CommanderAddinConfiguration.Current.LastCommand))
                {
                    selectedItem =
                        Model.AddinConfiguration.Commands.FirstOrDefault(
                            cmd => cmd.Name == Model.AddinConfiguration.LastCommand);
                }
                else
                {
                    selectedItem = Model.AddinConfiguration.Commands[0];
                }

                ListCommands.SelectedItem = selectedItem;
                if (selectedItem != null)
                {
                    initialValue = selectedItem.CommandText;
                }
            }

            editor = new MarkdownEditorSimple(WebBrowserCommand, initialValue);
            editor.IsDirtyAction = () =>
            {
                string val = editor.GetMarkdown();
                if (val != null && Model.ActiveCommand != null)
                {
                    Model.ActiveCommand.CommandText = val;
                }

                return(true);
            };

            Dispatcher.InvokeAsync(() =>
            {
                ListCommands.Focus();
                editor.SetEditorSyntax("csharp");
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);

            pageLoaded = true;
        }
Exemplo n.º 2
0
        private void TextFilename_TextChanged(object sender, TextChangedEventArgs e)
        {
            string filename = TextFilename.Text;

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }

            var ext = System.IO.Path.GetExtension(filename.ToLower());

            string syntax = editor.FindSyntaxFromFileType(filename);

            if (string.IsNullOrEmpty(syntax))
            {
                return;
            }

            editor.SetEditorSyntax(syntax);
        }
Exemplo n.º 3
0
 private void TextCodeLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     editor?.SetEditorSyntax(CodeLanguage);
 }