Exemple #1
0
        private IHighlightingDefinition LoadHighlightingDefinition(string resourceName)
        {
            var type     = typeof(PreviewControl);
            var fullName = type.Namespace + "." + resourceName;

            using (var stream = type.Assembly.GetManifestResourceStream(fullName))
                using (var reader = new XmlTextReader(stream))
                    return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
        }
 static DecompilerView()
 {
     // Load python syntax
     using (MemoryStream stream = new MemoryStream(Properties.Resources.python_xshd))
     {
         _pythonSyntax = HighlightingLoader.Load(new XmlTextReader(stream),
                                                 HighlightingManager.Instance);
     }
 }
		public DecompilerTextView()
		{
			HighlightingManager.Instance.RegisterHighlighting(
				"ILAsm", new string[] { ".il" },
				delegate {
					using (Stream s = typeof(DecompilerTextView).Assembly.GetManifestResourceStream(typeof(DecompilerTextView), "ILAsm-Mode.xshd")) {
						using (XmlTextReader reader = new XmlTextReader(s)) {
							return HighlightingLoader.Load(reader, HighlightingManager.Instance);
						}
					}
				});

			HighlightingManager.Instance.RegisterHighlighting(
				"C#", new string[] { ".cs" },
				delegate {
					using (Stream s = typeof(DecompilerTextView).Assembly.GetManifestResourceStream(typeof(DecompilerTextView), "CSharp-Mode.xshd")) {
						using (XmlTextReader reader = new XmlTextReader(s)) {
							return HighlightingLoader.Load(reader, HighlightingManager.Instance);
						}
					}
				});

			InitializeComponent();
			
			this.referenceElementGenerator = new ReferenceElementGenerator(this.JumpToReference, this.IsLink);
			textEditor.TextArea.TextView.ElementGenerators.Add(referenceElementGenerator);
			this.uiElementGenerator = new UIElementGenerator();
			textEditor.TextArea.TextView.ElementGenerators.Add(uiElementGenerator);
			textEditor.Options.RequireControlModifierForHyperlinkClick = false;
			textEditor.TextArea.TextView.MouseHover += TextViewMouseHover;
			textEditor.TextArea.TextView.MouseHoverStopped += TextViewMouseHoverStopped;
			textEditor.TextArea.PreviewMouseDown += TextAreaMouseDown;
			textEditor.TextArea.PreviewMouseUp += TextAreaMouseUp;
			textEditor.SetBinding(Control.FontFamilyProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFont") });
			textEditor.SetBinding(Control.FontSizeProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFontSize") });
			textEditor.SetBinding(TextEditor.WordWrapProperty, new Binding { Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("EnableWordWrap") });

			// disable Tab editing command (useless for read-only editor); allow using tab for focus navigation instead
			RemoveEditCommand(EditingCommands.TabForward);
			RemoveEditCommand(EditingCommands.TabBackward);
			
			textMarkerService = new TextMarkerService(textEditor.TextArea.TextView);
			textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
			textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
			textEditor.ShowLineNumbers = true;
			DisplaySettingsPanel.CurrentDisplaySettings.PropertyChanged += CurrentDisplaySettings_PropertyChanged;

			// SearchPanel
			SearchPanel.Install(textEditor.TextArea)
				.RegisterCommands(Application.Current.MainWindow.CommandBindings);
			
			ShowLineMargin();
			
			// add marker service & margin
			textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
			textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
		}
        /// <summary>
        /// Gets the highlighting definition.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>IHighlightingDefinition.</returns>
        protected virtual IHighlightingDefinition GetHighlightingDefinition(string path)
        {
            var bytes = ResourceReader.GetEmbeddedResource(path);
            var xml   = Encoding.UTF8.GetString(bytes, 0, bytes.Length);

            using var sr     = new StringReader(xml);
            using var reader = XmlReader.Create(sr);
            return(HighlightingLoader.Load(HighlightingLoader.LoadXshd(reader), HighlightingManager.Instance));
        }
        private void SetupSyntaxHighlighting()
        {
            var reader      = new XmlTextReader(new StringReader(Properties.Resources.markdown_xshd));
            var xshd        = HighlightingLoader.LoadXshd(reader);
            var highlighter = HighlightingLoader.Load(xshd, HighlightingManager.Instance);

            EditBox.SyntaxHighlighting = highlighter;
            reader.Close();
        }
 private static void RegisterDefinition(string fileName)
 {
     using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LogWatch." + fileName))
         if (stream != null)
         {
             var definition = HighlightingLoader.Load(new XmlTextReader(stream), HighlightingManager.Instance);
             HighlightingManager.Instance.RegisterHighlighting(definition.Name, new string[0], definition);
         }
 }
Exemple #7
0
 void InstallHighlighting()
 {
     using (XmlReader reader = new XmlTextReader(new StringReader(Properties.Resources.LUA)))
     {
         var luaHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
         HighlightingManager.Instance.RegisterHighlighting("Lua", new[] { ".lua" }, luaHighlighting);
         SyntaxHighlighting = luaHighlighting;
     }
 }
Exemple #8
0
 public static IHighlightingDefinition LoadSyntaxHighlightingFromResource(string resourceName)
 {
     // set view data (synatx highlighting, code, etc)
     using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
         using (XmlTextReader xshd_reader = new XmlTextReader(stream))
         {
             return(HighlightingLoader.Load(xshd_reader, HighlightingManager.Instance));
         }
 }
Exemple #9
0
        public static IHighlightingDefinition LoadHighlightingDefinition(string resourceName)
        {
            var type     = typeof(AutomationModule);
            var fullName = type.Namespace + "." + resourceName;

            using (var stream = type.Assembly.GetManifestResourceStream(fullName))
                using (var reader = new XmlTextReader(stream))
                    return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
        }
Exemple #10
0
        public DecompilerTextView()
        {
            HighlightingManager.Instance.RegisterHighlighting(
                "ILAsm", new string[] { ".il" },
                delegate
            {
                using (Stream s = typeof(DecompilerTextView).Assembly.GetManifestResourceStream(typeof(DecompilerTextView), "ILAsm-Mode.xshd"))
                {
                    using (XmlTextReader reader = new XmlTextReader(s))
                    {
                        return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
                    }
                }
            });

            this.Loaded += DecompilerTextView_Loaded;
            InitializeComponent();

            this.referenceElementGenerator = new ReferenceElementGenerator(this.JumpToReference, this.IsLink);
            textEditor.TextArea.TextView.ElementGenerators.Add(referenceElementGenerator);
            this.uiElementGenerator = new UIElementGenerator();
            textEditor.TextArea.TextView.ElementGenerators.Add(uiElementGenerator);
            textEditor.Options.RequireControlModifierForHyperlinkClick = false;
            textEditor.TextArea.TextView.MouseHover        += TextViewMouseHover;
            textEditor.TextArea.TextView.MouseHoverStopped += TextViewMouseHoverStopped;
            textEditor.SetBinding(Control.FontFamilyProperty, new Binding {
                Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFont")
            });
            textEditor.SetBinding(Control.FontSizeProperty, new Binding {
                Source = DisplaySettingsPanel.CurrentDisplaySettings, Path = new PropertyPath("SelectedFontSize")
            });

            // add marker service & margin
            iconMargin        = new IconBarMargin((manager = new IconBarManager()));
            textMarkerService = new TextMarkerService(textEditor);
            textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);
            textEditor.ShowLineNumbers = true;
            DisplaySettingsPanel.CurrentDisplaySettings.PropertyChanged += CurrentDisplaySettings_PropertyChanged;

            textEditor.TextArea.LeftMargins.Insert(0, iconMargin);
            textEditor.TextArea.TextView.VisualLinesChanged += delegate { iconMargin.InvalidateVisual(); };

            // Bookmarks context menu
            IconMarginActionsProvider.Add(iconMargin);
            // Bookmarks context menu
            textEditor.TextArea.DefaultInputHandler.NestedInputHandlers.Add(new SearchInputHandler(textEditor.TextArea));

            ShowLineMargin();

            // add marker service & margin
            textEditor.TextArea.TextView.BackgroundRenderers.Add(textMarkerService);
            textEditor.TextArea.TextView.LineTransformers.Add(textMarkerService);

            this.Loaded += DecompilerTextView_Loaded;
        }
Exemple #11
0
        private void LoadXshd()
        {
            var asm = Assembly.GetExecutingAssembly();

            using (var stream = asm.GetManifestResourceStream(resourceName))
                using (var reader = XmlReader.Create(stream))
                {
                    this.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
        }
Exemple #12
0
 public static IHighlightingDefinition LoadHighlightingDefinition(string resourceName)
 {
     using (Stream s = File.OpenRead(@"config/Syntax/LUA.xshd"))
     {
         using (XmlTextReader reader = new XmlTextReader(s))
         {
             return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
         }
     }
 }
Exemple #13
0
        private void LoadSyntaxHighlight()
        {
            var asm = Assembly.GetExecutingAssembly();

            using (var stream = asm.GetManifestResourceStream(SyntaxDefinition) ?? Stream.Null)
                using (var reader = XmlReader.Create(stream))
                {
                    this.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
        }
Exemple #14
0
 private void ApplySQLHighlighting()
 {
     using (Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Twenty57.Linx.Components.Database.Resources.SQLHighlightingDefinition.xshd"))
     {
         using (XmlTextReader reader = new XmlTextReader(resourceStream))
         {
             this.sqlEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
         }
     }
 }
Exemple #15
0
        public ScriptEditorWindow()
        {
            InitializeComponent();

            using (var fileStream = new FileStream(Path.Combine("Resources", "Ruby.xshd"), FileMode.Open, FileAccess.Read))
            {
                XmlReader def = XmlReader.Create(fileStream);
                _textEditor.SyntaxHighlighting = HighlightingLoader.Load(def, null);
            }
        }
Exemple #16
0
 private static IHighlightingDefinition CreateCSharpHighlightingDefinition()
 {
     using (Stream stream = Application.GetResourceStream(new Uri("/Resources/Highlighting/CSharp-Mode.xshd", UriKind.Relative)).Stream)
     {
         using (XmlReader reader = new XmlTextReader(stream))
         {
             return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
         }
     }
 }
 private void SetHighlighting(CodeInspectorViewModel data)
 {
     using (var s = GetHightlightResourceStream(data.SourceType))
     {
         using (var reader = new XmlTextReader(s))
         {
             Editor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
         }
     }
 }
Exemple #18
0
 public BindableAvalonEditor()
 {
     using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SqlCommandVisualizer.Resources.sql.xshd"))
     {
         using (var reader = new XmlTextReader(stream))
         {
             SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
         }
     }
 }
Exemple #19
0
 public static IHighlightingDefinition LoadAsmHighlightingDefinition()
 {
     using (var stream = GetStreamForProjectFile("AsmHighlighting.xshd"))
     {
         using (var reader = new XmlTextReader(stream))
         {
             return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
         }
     }
 }
Exemple #20
0
        private static void RegisterHighlight(DialectType dialect, Byte[] ashx)
        {
            IHighlightingDefinition definition;

            using (Stream stream = new MemoryStream(ashx))
                using (XmlReader reader = XmlReader.Create(stream))
                    definition = HighlightingLoader.Load(reader, HighlightingManager.Instance);

            HighlightingManager.Instance.RegisterHighlighting(dialect.ToString(), new String[] { }, definition);
        }
        public EffectEditorWindow()
        {
            InitializeComponent();

            using (var s = Assembly.GetExecutingAssembly().GetManifestResourceStream("DeckBuilder.Resources.Lua.xshd"))
                using (var reader = new XmlTextReader(s))
                {
                    textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
        }
Exemple #22
0
 void ApplyXshd()
 {
     using (var sr = new StringReader(this.xsdEditor.Text))
         using (var reader = new XmlTextReader(sr)) {
             try {
                 this.textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
             } catch {
             }
         }
 }
 private void SelectToEntity_Loaded(object sender, RoutedEventArgs e)
 {
     using (Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("DTE.Resources.sql.xsd"))
     {
         using (XmlTextReader reader = new XmlTextReader(s))
         {
             HLeditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
         }
     }
 }
 public TextBoxHost()
 {
     InitializeComponent();
     using (XmlTextReader xts = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("GBRead.GB.xshd")))
     {
         mainTextBox.SyntaxHighlighting = HighlightingLoader.Load(xts, HighlightingManager.Instance);
     }
     mainTextBox.Options.ConvertTabsToSpaces = true;
     mainTextBox.Options.EnableTextDragDrop  = true;
 }
        // Notes:
        //  - All scripts are created with an associated file. New scripts start with a
        //    temporary script filepath and get saved to a new location by the user.
        //  - The Scenes collection view uses a wrapper around SceneUI because Combobox.ItemsSource
        //    treats the items as child controls and tried to become their parent.
        //  - Each ScriptUI is responsible for the objects it creates and the scenes those objects are
        //    added to. Closing a ScriptUI removes its objects from any associated scenes.
        //  - Watching for changed script files is independent of the Ldr sources CheckForChangedSources
        //    because a script is not necessarily rendered in the view and therefore not a source. Both
        //    file watching systems are needed, since assets need to update as well.

        static ScriptUI()
        {
            // Register the LdrScript syntax definitions
            var stream = typeof(ScriptUI).Assembly.GetManifestResourceStream("LDraw.res.LdrSyntaxRules.xshd");

            using var reader = new XmlTextReader(stream);
            var syntax_rules = HighlightingLoader.Load(reader, HighlightingManager.Instance);

            HighlightingManager.Instance.RegisterHighlighting("Ldr", new[] { ".ldr" }, syntax_rules);
        }
 public static IHighlightingDefinition LoadHighlightingFromAssembly(Assembly assembly, string name)
 {
     using (var s = assembly.GetManifestResourceStream(name))
     {
         using (var reader = new XmlTextReader(s))
         {
             return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
         }
     }
 }
Exemple #27
0
        private static IHighlightingDefinition GetDefaultHighlightingDefinition()
        {
            const string ilRes = "Msiler.Resources.IL.xshd";

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(ilRes)) {
                using (var reader = new System.Xml.XmlTextReader(stream)) {
                    return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
                }
            }
        }
 protected IHighlightingDefinition GetDefiniion(string xmlCSharpFile, Assembly assembly)
 {
     using (var stream = assembly.GetManifestResourceStream(xmlCSharpFile))
     {
         using (var reader = new XmlTextReader(stream))
         {
             return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
         }
     }
 }
        private void Grid_Initialized(object sender, EventArgs e)
        {
            CodeTextEditor.SyntaxHighlighting = HighlightingLoader.Load(
                new XmlTextReader(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                               "Python.Dark.xshd")), HighlightingManager.Instance);

            IEnumerable <Type> namespaces = Assembly.GetExecutingAssembly().GetTypes().Where(t =>
                                                                                             t.Namespace != null && t.IsPublic && t.IsClass && t.Namespace.EndsWith("Macros.Commands"));

            _completionData = new List <PythonCompletionData>();

            foreach (Type type in namespaces)
            {
                MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);

                foreach (MethodInfo methodInfo in methods)
                {
                    CommandsDisplayAttribute attr = methodInfo.GetCustomAttribute <CommandsDisplayAttribute>();

                    if (attr == null)
                    {
                        continue;
                    }

                    string fullName = $"{methodInfo.Name}(";
                    bool   first    = true;

                    foreach (ParameterInfo parameterInfo in methodInfo.GetParameters())
                    {
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            fullName += ", ";
                        }

                        bool optional = parameterInfo.RawDefaultValue == null ||
                                        parameterInfo.RawDefaultValue.GetType() != typeof(DBNull);

                        fullName +=
                            $"{( optional ? "[" : "" )}{parameterInfo.ParameterType.Name} {parameterInfo.Name}{( optional ? "]" : "" )}";
                    }

                    fullName += $"):{methodInfo.ReturnType.Name}";

                    _completionData.Add(new PythonCompletionData(methodInfo.Name, fullName, attr.Description,
                                                                 attr.InsertText));
                }
            }

            CodeTextEditor.TextArea.TextEntered += OnTextEntered;
            SearchPanel.Install(CodeTextEditor);
        }
Exemple #30
0
 static TextEditorControl()
 {
     HighlightingManager.Instance.RegisterHighlighting(
         "IL", new string[] { ".il" }, () => {
         using (var s = typeof(TextEditorControl).Assembly.GetManifestResourceStream(typeof(TextEditorControl), "IL.xshd")) {
             using (var reader = new XmlTextReader(s))
                 return(HighlightingLoader.Load(reader, HighlightingManager.Instance));
         }
     }
         );
 }