コード例 #1
0
        private void PasteCode_Loaded(object sender, RoutedEventArgs e)
        {
            ComboBackground = TextCodeLanguage.Background;

            DataContext = this;
            WebBrowserCode.Focus();


            editor = new MarkdownEditorSimple(WebBrowserCode, Code, CodeLanguage);
            editor.IsDirtyAction = () =>
            {
                Code = editor.GetMarkdown();
                return(true);
            };

            Dispatcher.InvokeAsync(() =>
            {
                if (!string.IsNullOrEmpty(Code))
                {
                    TextCodeLanguage.Focus();
                    TextCodeLanguage.Background = Brushes.SlateGray;

                    var sb = Resources["StoryboardLanguageCombo"] as Storyboard;
                    sb.Begin();
                }
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }
コード例 #2
0
        private void PasteCode_Loaded(object sender, RoutedEventArgs e)
        {
            Gist.filename = "file." + Gist.language;

            if (string.IsNullOrEmpty(PasteCodeAsGistConfiguration.Current.GithubUsername))
            {
                CheckAnonymous.Visibility = Visibility.Collapsed;
                Gist.isAnonymous          = true;
            }

            DataContext = this;

            editor = new MarkdownEditorSimple(WebBrowserCode, Gist.code, "csharp");

            editor.IsDirtyAction = () =>
            {
                Gist.code = editor.GetMarkdown();
                return(true);
            };

            if (!string.IsNullOrEmpty(Gist.code))
            {
                Dispatcher.InvokeAsync(() =>
                {
                    TextFilename.SelectAll();
                    TextFilename.Focus();
                }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
            }
        }
コード例 #3
0
        private void SnippetsWindow_Loaded(object sender, RoutedEventArgs e)
        {
            string initialValue = null;

            if (Model.Configuration.Snippets.Count > 0)
            {
                ListSnippets.SelectedItem = Model.Configuration.Snippets[0];
                initialValue = Model.Configuration.Snippets[0].SnippetText;
            }

            editor = new MarkdownEditorSimple(WebBrowserSnippet, initialValue);
            editor.IsDirtyAction = () =>
            {
                string val = editor.GetMarkdown();
                if (val != null && Model.ActiveSnippet != null)
                {
                    Model.ActiveSnippet.SnippetText = val;
                }

                return(true);
            };

            Dispatcher.InvokeAsync(() =>
            {
                ListSnippets.Focus();
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }
コード例 #4
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;
        }
        private async void CommandsWindow_Loaded(object sender, RoutedEventArgs e)
        {
            await Task.Delay(1);

            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, "csharp");
            editor.ShowLineNumbers = true;
            editor.IsDirtyAction   = (isDirty, newText, oldText) =>
            {
                if (newText != null && Model.ActiveCommand != null)
                {
                    Model.ActiveCommand.CommandText = newText;
                }

                return(newText != oldText);
            };

            Dispatcher.Invoke(() => ListCommands.Focus(), DispatcherPriority.ApplicationIdle);

            pageLoaded = true;
        }
コード例 #6
0
        private void PasteCode_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = this;
            WebBrowserCode.Focus();

            editor = new MarkdownEditorSimple(WebBrowserCode, Code, CodeLanguage);
            editor.IsDirtyAction = () =>
            {
                Code = editor.GetMarkdown();
                return(true);
            };

            Dispatcher.InvokeAsync(() =>
            {
                if (!string.IsNullOrEmpty(Code))
                {
                    TextCodeLanguage.Focus();
                }
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }
コード例 #7
0
        private void SnippetsWindow_Loaded(object sender, RoutedEventArgs e)
        {
            var winPos = SnippetsAddinConfiguration.Current.WindowPosition;

            if (!winPos.CenterInMainWindow && winPos.Height != 0 && winPos.Width != 0)
            {
                Top    = winPos.Top;
                Left   = winPos.Left;
                Height = winPos.Height;
                Width  = winPos.Width;
                WindowUtilities.EnsureWindowIsVisible(this);
            }

            string initialValue = null;

            if (Model.Configuration.Snippets.Count > 0)
            {
                ListSnippets.SelectedItem = Model.Configuration.Snippets[0];
                initialValue = Model.Configuration.Snippets[0].SnippetText;
            }

            editor = new MarkdownEditorSimple(WebBrowserSnippet, initialValue);
            editor.IsDirtyAction = () =>
            {
                string val = editor.GetMarkdown();
                if (val != null && Model.ActiveSnippet != null)
                {
                    Model.ActiveSnippet.SnippetText = val;
                }

                return(true);
            };

            Dispatcher.InvokeAsync(() =>
            {
                ListSnippets.Focus();
            }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
        }