Ejemplo n.º 1
0
 /// <summary>
 /// Invoke this method to apply a change of theme to the content of the document
 /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
 ///      WITH current text document loaded.)
 /// </summary>
 public void OnAppThemeChanged(IThemedHighlightingManager hlManager)
 {
     if (DiffCtrl != null)
     {
         DiffCtrl.OnAppThemeChanged(hlManager);
     }
 }
Ejemplo n.º 2
0
        private void UpdateUiResult(string result, bool isError)
        {
            OutputArea.Text = result;

            IThemedHighlightingManager hm = ThemedHighlightingManager.Instance;

            hm.SetCurrentTheme("VS2019_Dark");
            if (isError)
            {
                OutputArea.SyntaxHighlighting = hm.GetDefinitionByExtension(".txt");
            }
            else
            {
                OutputArea.SyntaxHighlighting = hm.GetDefinitionByExtension(".grazor");
            }


            if (!isError && settings.OpenFile)
            {
                string savedFilePath = Serializer.SaveTemporaryFile(result);
                System.Diagnostics.Process.Start(savedFilePath);
            }

            isLoading  = false;
            hasChanged = false;
            LoadingOverlay.Visibility = Visibility.Collapsed;
            oldText = result;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Invoke this method to apply a change of theme to the content of the document
 /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
 ///      WITH current text document loaded.)
 /// </summary>
 public void OnAppThemeChanged(IThemedHighlightingManager hlManager)
 {
     if (DocDiffDoc != null)
     {
         DocDiffDoc.OnAppThemeChanged(hlManager);
     }
 }
        public ChangeLogPage()
        {
            InitializeComponent();

            IThemedHighlightingManager hm = ThemedHighlightingManager.Instance;

            hm.SetCurrentTheme("VS2019_Dark");
            AdditionalDataField.SyntaxHighlighting = hm.GetDefinitionByExtension(".js");
        }
Ejemplo n.º 5
0
 public CodeEditorViewModel(IAppConfiguration config, Action <string> saveAction, string subTitle = "")
 {
     this.config     = config;
     this.saveAction = saveAction;
     this.subTitle   = subTitle;
     this.manager    = DefaultHighlightingManager.Instance;
     this.SetDisplayName();
     this.SaveCommand = new RelayCommand((_) => this.Save(), (_ => this.isDirty));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Invoke this method to apply a change of theme to the content of the document
 /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
 ///      WITH current text document loaded.)
 /// </summary>
 internal void OnAppThemeChanged(IThemedHighlightingManager hlManager)
 {
     foreach (var doc in _Documents)
     {
         var textDoc = doc as TextDocDifference;
         if (textDoc != null)
         {
             textDoc.OnAppThemeChanged(hlManager);
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Invoke this method to apply a change of theme to the content of the document
        /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
        ///      WITH current text document loaded.)
        /// </summary>
        public void OnAppThemeChanged(IThemedHighlightingManager hlManager)
        {
            if (_ViewA != null)
            {
                _ViewA.OnAppThemeChanged(hlManager);
            }

            if (_ViewB != null)
            {
                _ViewB.OnAppThemeChanged(hlManager);
            }
        }
        public VersionPage()
        {
            InitializeComponent();

            redColor   = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            whiteColor = new SolidColorBrush(Color.FromRgb(255, 255, 255));

            IThemedHighlightingManager hm = ThemedHighlightingManager.Instance;

            hm.SetCurrentTheme("VS2019_Dark");
            AdditionalDataField.SyntaxHighlighting = hm.GetDefinitionByExtension(".js");
        }
Ejemplo n.º 9
0
        private static void SetAvalonTheme(bool isDark)
        {
            IThemedHighlightingManager hm = ThemedHighlightingManager.Instance;

            hm.SetCurrentTheme(isDark ? "VS2019_Dark" : "Light");
            MainWindow window = (MainWindow)Application.Current.MainWindow;

            window.textEditor.SyntaxHighlighting          = hm.GetDefinitionByExtension(".js");
            window.textEditor.Background                  = new SolidColorBrush(isDark ? Color.FromRgb(30, 30, 30) : Color.FromRgb(255, 255, 255));
            window.textEditor.Foreground                  = new SolidColorBrush(isDark ? Color.FromRgb(255, 255, 255) : Color.FromRgb(0, 0, 0));
            window.textEditor.LineNumbersForeground       = new SolidColorBrush(isDark ? Color.FromRgb(190, 190, 190) : Color.FromRgb(60, 60, 60));
            window.textEditor.EditorCurrentLineBackground = new SolidColorBrush(isDark ? Color.FromRgb(37, 37, 37) : Color.FromRgb(245, 245, 245));
        }
Ejemplo n.º 10
0
        public MainWindow()
        {
            InitializeComponent();
            settings = Serializer.GetSettings();
            if (settings.FontSize < 1)
            {
                settings.FontSize = 20;
            }

            IThemedHighlightingManager hm = ThemedHighlightingManager.Instance;

            hm.SetCurrentTheme("VS2019_Dark");
            InputArea.SyntaxHighlighting  = hm.GetDefinitionByExtension(".grazor");
            OutputArea.SyntaxHighlighting = hm.GetDefinitionByExtension(".grazor");

            InputArea.FontSize  = settings.FontSize;
            OutputArea.FontSize = settings.FontSize;

            if (!settings.LineNumbers)
            {
                InputArea.ShowLineNumbers  = false;
                OutputArea.ShowLineNumbers = false;
            }
            else
            {
                InputArea.Loaded  += (object send, RoutedEventArgs e) => SetLineNumberMargin(InputArea);
                OutputArea.Loaded += (object send, RoutedEventArgs e) => SetLineNumberMargin(OutputArea);
            }

            InputArea.WordWrap  = settings.WordWrap;
            OutputArea.WordWrap = settings.WordWrap;

            InputArea.Loaded  += (object send, RoutedEventArgs e) => SetContextMenuIcons(InputArea);
            OutputArea.Loaded += (object send, RoutedEventArgs e) => SetContextMenuIcons(OutputArea);

            var heightDescriptor = DependencyPropertyDescriptor.FromProperty(RowDefinition.HeightProperty, typeof(ItemsControl));

            heightDescriptor.AddValueChanged(TopRow, SplitterHeightChanged);

            BuildExample(Serializer.GetExamples());
        }
Ejemplo n.º 11
0
        public ExCode(CodeControlModel codeModel, Settings appSettings)
        {
            InitializeComponent();
            model    = codeModel;
            settings = appSettings;
            if (settings.FontSize < 1)
            {
                settings.FontSize = 20;
            }

            Parent.Margin = new Thickness(0, model.MarginAbove, 0, model.MarginBelow);

            whiteBrush = new SolidColorBrush(Color.FromRgb(255, 255, 255));
            greenBrush = new SolidColorBrush(Color.FromRgb(129, 237, 104));

            CodeEditor.Loaded  += (object send, RoutedEventArgs e) => EditorLoadedEvent();
            CodeEditor.WordWrap = settings.WordWrap;

            // Set text area fields content type to use JSON (js) highlighting
            IThemedHighlightingManager hm = ThemedHighlightingManager.Instance;

            hm.SetCurrentTheme("VS2019_Dark");
            CodeEditor.SyntaxHighlighting = hm.GetDefinitionByExtension(".grazor");
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="hlManager"></param>
 public HighLightingManagerAdapter(IThemedHighlightingManager hlManager)
 {
     _hlManager = hlManager;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Invoke this method to apply a change of theme to the content of the document
        /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
        ///      WITH current text document loaded.)
        /// </summary>
        internal void OnAppThemeChanged(IThemedHighlightingManager hlManager)
        {
            if (hlManager == null)
            {
                return;
            }

            // Does this highlighting definition have an associated highlighting theme?
            if (hlManager.CurrentTheme.HlTheme != null)
            {
                // A highlighting theme with GlobalStyles?
                // Apply these styles to the resource keys of the editor
                foreach (var item in hlManager.CurrentTheme.HlTheme.GlobalStyles)
                {
                    switch (item.TypeName)
                    {
                    case "DefaultStyle":
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorBackground, item.backgroundcolor);
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorForeground, item.foregroundcolor);
                        break;

                    case "CurrentLineBackground":
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorCurrentLineBackgroundBrushKey, item.backgroundcolor);
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorCurrentLineBorderBrushKey, item.bordercolor);
                        break;

                    case "LineNumbersForeground":
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorLineNumbersForeground, item.foregroundcolor);
                        break;

                    case "Selection":
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorSelectionBrush, item.backgroundcolor);
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorSelectionBorder, item.bordercolor);
                        break;

                    case "Hyperlink":
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorLinkTextBackgroundBrush, item.backgroundcolor);
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorLinkTextForegroundBrush, item.foregroundcolor);
                        break;

                    case "NonPrintableCharacter":
                        ApplyToDynamicResource(AehnlichViewLib.Themes.ResourceKeys.EditorNonPrintableCharacterBrush, item.foregroundcolor);
                        break;

                    default:
                        throw new System.ArgumentOutOfRangeException("GlobalStyle named '{0}' is not supported.", item.TypeName);
                    }
                }
            }

            if (IsHighlightingDefinitionOff == true)
            {
                return;
            }

            // 1st try: Find highlighting based on currently selected highlighting
            // The highlighting name may be the same as before, but the highlighting theme has just changed
            if (HighlightingDefinition != null)
            {
                // Reset property for currently select highlighting definition
                HighlightingDefinition = hlManager.GetDefinition(HighlightingDefinition.Name);

                if (HighlightingDefinition != null)
                {
                    return;
                }
            }

            // 2nd try: Find highlighting based on extension of file currenlty being viewed
            if (string.IsNullOrEmpty(this.FileName))
            {
                return;
            }

            string extension = System.IO.Path.GetExtension(this.FileName);

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

            // Reset property for currently select highlighting definition
            HighlightingDefinition = hlManager.GetDefinitionByExtension(extension);
        }
        /// <summary>
        /// Invoke this method to apply a change of theme to the content of the document
        /// (eg: Adjust the highlighting colors when changing from "Dark" to "Light"
        ///      WITH current text document loaded.)
        /// </summary>
        internal void OnAppThemeChanged(IThemedHighlightingManager hlManager)
        {
            if (hlManager == null)
            {
                return;
            }

            // Does this highlighting definition have an associated highlighting theme?
            if (hlManager.CurrentTheme.HlTheme != null)
            {
                // A highlighting theme with GlobalStyles?
                // Apply these styles to the resource keys of the editor
                foreach (var item in hlManager.CurrentTheme.HlTheme.GlobalStyles)
                {
                    switch (item.TypeName)
                    {
                    case "DefaultStyle":
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorBackground, item.backgroundcolor);
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorForeground, item.foregroundcolor);
                        break;

                    case "CurrentLineBackground":
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorCurrentLineBackgroundBrushKey, item.backgroundcolor);
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorCurrentLineBorderBrushKey, item.bordercolor);
                        break;

                    case "LineNumbersForeground":
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorLineNumbersForeground, item.foregroundcolor);
                        break;

//// Not changing selection color here since this should be controlled by current AccentColor via BindToMLib
                    case "Selection":
////							ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorSelectionBrush, item.backgroundcolor);
////							ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorSelectionBorder, item.bordercolor);
                        break;

                    case "Hyperlink":
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorLinkTextBackgroundBrush, item.backgroundcolor);
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorLinkTextForegroundBrush, item.foregroundcolor);
                        break;

                    case "NonPrintableCharacter":
                        ApplyToDynamicResource(TextEditLib.Themes.ResourceKeys.EditorNonPrintableCharacterBrush, item.foregroundcolor);
                        break;

                    default:
                        throw new System.ArgumentOutOfRangeException("GlobalStyle named '{0}' is not supported.", item.TypeName);
                    }
                }
            }

            // 1st try: Find highlighting based on currently selected highlighting
            // The highlighting name may be the same as before, but the highlighting theme has just changed
            if (HighlightingDefinition != null)
            {
                // Reset property for currently select highlighting definition
                HighlightingDefinition = hlManager.GetDefinition(HighlightingDefinition.Name);
                NotifyPropertyChanged(() => this.HighlightingDefinitions);

                if (HighlightingDefinition != null)
                {
                    return;
                }
            }

            // 2nd try: Find highlighting based on extension of file currenlty being viewed
            if (string.IsNullOrEmpty(FilePath))
            {
                // No file path is available -> no default highlighting
                HighlightingDefinition = null;
                NotifyPropertyChanged(() => this.HighlightingDefinitions);
                return;
            }

            string extension = System.IO.Path.GetExtension(FilePath);

            if (string.IsNullOrEmpty(extension))
            {
                // File path is available but no extension to speak of -> no default highlighting
                HighlightingDefinition = null;
                NotifyPropertyChanged(() => this.HighlightingDefinitions);
                return;
            }

            // Reset property for currently select highlighting definition
            HighlightingDefinition = hlManager.GetDefinitionByExtension(extension);
            NotifyPropertyChanged(() => this.HighlightingDefinitions);
        }
 /// <summary>
 /// Class constructor
 /// </summary>
 public DocumentRootViewModel(IThemedHighlightingManager hlManager)
     : this()
 {
     _hlManager = hlManager;
 }