Exemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataContext = Tools.Global.setting;

            //重写关闭响应代码
            this.Closing += SettingWindow_Closing;

            //置顶显示以免被挡住
            this.Topmost = true;

            //初始化下拉框参数
            dataBitsComboBox.SelectedIndex  = Tools.Global.setting.dataBits - 5;
            stopBitComboBox.SelectedIndex   = Tools.Global.setting.stopBit - 1;
            dataCheckComboBox.SelectedIndex = Tools.Global.setting.parity;

            //快速搜索
            textEditor.TextArea.DefaultInputHandler.NestedInputHandlers.Add(
                new SearchInputHandler(textEditor.TextArea));
            string name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Lua.xshd";

            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            using (System.IO.Stream s = assembly.GetManifestResourceStream(name))
            {
                using (XmlTextReader reader = new XmlTextReader(s))
                {
                    var xshd = HighlightingLoader.LoadXshd(reader);
                    textEditor.SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                }
            }
            //加载上次打开的文件
            loadLuaFile(Tools.Global.setting.sendScript);
        }
Exemplo n.º 2
0
        private void SetUpUi()
        {
            Formatter.InitFormatter();

            // enable folding in code text box
            _foldingManager  = FoldingManager.Install(codeTextBox.TextArea);
            _foldingStrategy = new BraceFoldingStrategy();
            codeTextBox.TextArea.SelectionChanged += CodeTextBoxSelectionChanged;

            // enable syntax highlighting
            using (Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(Properties.Resources.CSharpSyntaxHighlighting ?? "")))
                using (XmlTextReader reader = new XmlTextReader(stream))
                    codeTextBox.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);

            // disable pasting in spreadsheet
            spreadsheet.HistoryManager.Enabled = false;
            spreadsheet.CopyPaste.Pasting     += (sender, e) => e.Cancel = true;

            diagram.Tool = Tool.ZoomPan | Tool.MultipleSelect;
            ((IGraphInfo)diagram.Info).AnnotationChanged += DiagramAnnotationChanged;
            ((IGraphInfo)diagram.Info).ItemTappedEvent   += DiagramItemClicked;

            // improve diagram loading performance by virtualization
            diagram.Constraints |= GraphConstraints.Virtualize;
        }
Exemplo n.º 3
0
        internal void Initialize(Guid workspaceGuid, Guid nodeGuid, string propName, string propValue)
        {
            boundWorkspaceId = workspaceGuid;
            boundNodeId      = nodeGuid;
            propertyName     = propName;

            // Register auto-completion callbacks
            editText.TextArea.TextEntering += OnTextAreaTextEntering;
            editText.TextArea.TextEntered  += OnTextAreaTextEntered;

            // Initialize editor with global settings for show/hide tabs and spaces
            editText.Options = dynamoViewModel.PythonScriptEditorTextOptions.GetTextOptions();

            // Set options to reflect global settings when python script editor in initialized for the first time.
            editText.Options.ShowSpaces = dynamoViewModel.ShowTabsAndSpacesInScriptEditor;
            editText.Options.ShowTabs   = dynamoViewModel.ShowTabsAndSpacesInScriptEditor;

            const string highlighting = "ICSharpCode.PythonBinding.Resources.Python.xshd";
            var          elem         = GetType().Assembly.GetManifestResourceStream(
                "PythonNodeModelsWpf.Resources." + highlighting);

            editText.SyntaxHighlighting = HighlightingLoader.Load(
                new XmlTextReader(elem), HighlightingManager.Instance);

            editText.Text  = propValue;
            originalScript = propValue;
            CachedEngine   = nodeModel.Engine;
            EngineSelectorComboBox.SelectedItem = CachedEngine;
        }
Exemplo n.º 4
0
        static AvalonLoader()
        {
            string[] syntaxes =
            {
                "Custom Highlighting", "SDE.Core.Avalon.Syntax.CustomHighlighting.xshd",
                "Lua",                 "SDE.Core.Avalon.Syntax.Lua.xshd",
                "Imf",                 "SDE.Core.Avalon.Syntax.Imf.xshd",
                "Python",              "SDE.Core.Avalon.Syntax.Python.xshd",
                "DebugDb",             "SDE.Core.Avalon.Syntax.DebugDb.xshd",
            };

            for (int i = 0; i < syntaxes.Length; i += 2)
            {
                IHighlightingDefinition customHighlighting;

                using (Stream s = typeof(App).Assembly.GetManifestResourceStream(syntaxes[i + 1])) {
                    if (s == null)
                    {
                        throw new InvalidOperationException("Could not find embedded resource");
                    }
                    using (XmlReader reader = new XmlTextReader(s)) {
                        customHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    }
                }

                HighlightingManager.Instance.RegisterHighlighting(syntaxes[i], new[] { ".cool" }, customHighlighting);
            }
        }
Exemplo n.º 5
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            base.Loaded             += OnLoaded;
            base.Unloaded           += OnUnloaded;
            TextArea.TextEntering   += textEditor_TextArea_TextEntering;
            TextArea.TextEntered    += textEditor_TextArea_TextEntered;
            TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;

            TextArea.Caret.PositionChanged += Caret_PositionChanged;
            this.TextChanged += TextArea_TextChanged;

            System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetAssembly(GetType());
            using (var s = myAssembly.GetManifestResourceStream("DAXEditor.Resources.DAX.xshd"))
            {
                using (var reader = new XmlTextReader(s))
                {
                    SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }

            //TODO - hardcoded for v1 - should be moved to a settings dialog
            this.FontFamily      = new System.Windows.Media.FontFamily("Lucida Console");
            this.DefaultFontSize = 11.0;
            this.FontSize        = DefaultFontSize;
            this.ShowLineNumbers = true;
        }
        private void SetDiffCodeHightlighter(bool force = false)
        {
            if (!_diffHightlighted || force)
            {
                var defaultBackground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);
                var defaultForeground = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowTextColorKey);

                var theme    = ThemeHelper.GetCurrentTheme();
                var filename = "GitScc.Resources.Patch-Mode-Blue.xshd";

                DiffEditor.Background = defaultBackground.ToBrush();
                DiffEditor.Foreground = defaultForeground.ToBrush();

                if (theme == VsTheme.Dark)
                {
                    filename = "GitScc.Resources.Patch-Mode-Dark.xshd";
                }
                var assembly = Assembly.GetExecutingAssembly();

                using (Stream s = assembly.GetManifestResourceStream(filename))
                {
                    using (XmlTextReader reader = new XmlTextReader(s))
                    {
                        DiffEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    }
                }
                _diffHightlighted = true;
            }
        }
Exemplo n.º 7
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            SearchPanel.Install(TextEditor.TextArea);
            //设置语法规则
            var name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Util.Cmm.xshd";

            var assembly = System.Reflection.Assembly.GetExecutingAssembly();

            foldingManager  = FoldingManager.Install(TextEditor.TextArea);
            foldingStrategy = new BraceFoldingStrategy();
            //foldingStrategy.UpdateFoldings(foldingManager, TextEditor.Document);
            TextEditor.TextArea.TextEntering += TextEditor_TextArea_TextEntering;
            TextEditor.TextArea.TextEntered  += TextEditor_TextArea_TextEntered;


            //TextEditor.Text = DispContentValue;
            //foldingStrategy.UpdateFoldings(foldingManager, TextEditor.Document);
            using (var s = assembly.GetManifestResourceStream(name))
            {
                using (var reader = new XmlTextReader(s))
                {
                    var xshd = HighlightingLoader.LoadXshd(reader);
                    TextEditor.SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                }
            }
        }
Exemplo n.º 8
0
 private void LoadJsonSyntaxHighlighting()
 {
     using (var xmlReader = new System.Xml.XmlTextReader("SyntaxHighlighting\\JSON.xml"))
     {
         textBox.SyntaxHighlighting = HighlightingLoader.Load(xmlReader, HighlightingManager.Instance);
     }
 }
Exemplo n.º 9
0
        public MainWindow()
        {
            InitializeComponent();
            var xshdAsString = ManifestResource.Load("RavenQuery.SyntaxTester.RQLSyntaxHighlighting.xshd");

            using (var reader = new XmlTextReader(new StringReader(xshdAsString)))
            {
                var editorSyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                HighlightingManager.Instance.RegisterHighlighting("RQL", new[] { ".rql" }, editorSyntaxHighlighting);
            }

            CodeEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("RQL");
            _lexer               = new QueryLexer(null);
            _parser              = new QueryParser(null);
            _errorStrategy       = new UserFriendlyErrorStrategy();
            _parser.ErrorHandler = _errorStrategy;
            _parser.AddErrorListener(_errorListener);

            Observable.FromEventPattern(
                ev => CodeEditor.TextChanged += ev,
                ev => CodeEditor.TextChanged -= ev)
            .Throttle(TimeSpan.FromMilliseconds(750))
            .Subscribe(_ => Dispatcher.InvokeAsync(ParseRQL));
            InitializeTextMarkerService();
        }
Exemplo n.º 10
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (File.Exists(@"./bin/lua.xshd"))
            {
                Stream        xshd_stream = File.OpenRead(@"./bin/lua.xshd");
                XmlTextReader reader      = new XmlTextReader(xshd_stream);
                textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
            }
            else
            {
                using (WebClient wc = new WebClient())
                {
                    wc.DownloadFile(new Uri("https://fluxteam.xyz/external-files/lua.xshd"), @"./bin/lua.xshd");
                    wc.Dispose();
                }
                Stream        xshd_stream = File.OpenRead(@"./bin/lua.xshd");
                XmlTextReader reader      = new XmlTextReader(xshd_stream);
                textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
            }
            headerBar.Opacity  = 0;
            bottomBar.Opacity  = 0;
            textEditor.Opacity = 0;
            Animate(
                circle1,
                "Width",
                0,
                this.Width + 300,
                0.1,
                new Duration(new TimeSpan(TimeSpan.TicksPerSecond)));
            Animate(
                circle1,
                "Height",
                0,
                this.Width + 300,
                0.1,
                new Duration(new TimeSpan(TimeSpan.TicksPerSecond)));
            await Task.Delay(1000);

            Animate(
                headerBar,
                "Opacity",
                0,
                1,
                0.1,
                new Duration(new TimeSpan(TimeSpan.TicksPerSecond)));
            Animate(
                bottomBar,
                "Opacity",
                0,
                1,
                0.1,
                new Duration(new TimeSpan(TimeSpan.TicksPerSecond)));
            Animate(
                textEditor,
                "Opacity",
                0,
                1,
                0.1,
                new Duration(new TimeSpan(TimeSpan.TicksPerSecond)));
        }
Exemplo n.º 11
0
        public TextEditor(string path = "")
        {
            InitializeComponent();

            editor     = new Editor();
            host.Child = editor;

            editor.FontFamily = new System.Windows.Media.FontFamily("Consolas");
            editor.FontSize   = 12;
            if (Config.HighlightingDefinition != null)
            {
                editor.SyntaxHighlighting = HighlightingLoader.Load(
                    Config.HighlightingDefinition, HighlightingManager.Instance);
            }

            editor.Options.IndentationSize       = 8;
            editor.Options.ConvertTabsToSpaces   = false;
            editor.ShowLineNumbers               = true;
            editor.HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto;
            editor.VerticalScrollBarVisibility   = System.Windows.Controls.ScrollBarVisibility.Auto;

            if (!string.IsNullOrWhiteSpace(path))
            {
                Open(path);
            }

            editor.TextArea.TextEntering += editor_TextArea_TextEntering;
            editor.TextArea.TextEntered  += editor_TextArea_TextEntered;
        }
Exemplo n.º 12
0
 public void Register(HighlightingManager manager)
 {
     manager.RegisterHighlighting(
         this.Name, this.Extensions, delegate {
         return(HighlightingLoader.Load(LoadXshd(), manager));
     });
 }
Exemplo n.º 13
0
 /// <summary>
 /// Loads the highligting definition.
 /// </summary>
 private void LoadHighligtingDefinition()
 {
     if (IsHighlightingEnabled)
     {
         var filePath = Session.Instance.Highlighting.FilePath;
         using (var reader = new XmlTextReader(filePath))
         {
             try
             {
                 var definition = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                 SyntaxHighlighting = definition;
             }
             catch (FileNotFoundException)
             {
                 MissingFileManager.CreateHighlightingDefinitionFile();
                 Session.Instance.SubmitHighlighting(MissingFileManager.DEFAULT_HIGHLIGHTING_PATH);
                 Session.Instance.Highlighting.Import(MissingFileManager.DEFAULT_HIGHLIGHTING_PATH);
                 Session.Instance.Highlighting.Apply(Session.Instance.Highlighting.Colors);
             }
         }
     }
     else
     {
         SyntaxHighlighting = null;
     }
 }
Exemplo n.º 14
0
        public CodeCommandView()
        {
            InitializeComponent();

            using (var stringReader = new StringReader(Properties.Resources.BatchSyntax))
                using (var xmlReader = new XmlTextReader(stringReader))
                    BatchTextEditor.SyntaxHighlighting = HighlightingLoader.Load(xmlReader, HighlightingManager.Instance);

            using (var stringReader = new StringReader(Properties.Resources.CSharpSyntax))
                using (var xmlReader = new XmlTextReader(stringReader))
                    CsharpTextEditor.SyntaxHighlighting = HighlightingLoader.Load(xmlReader, HighlightingManager.Instance);

            using (var stringReader = new StringReader(Properties.Resources.VisualBasicSyntax))
                using (var xmlReader = new XmlTextReader(stringReader))
                    VisualBasicTextEditor.SyntaxHighlighting = HighlightingLoader.Load(xmlReader, HighlightingManager.Instance);

            BatchTextEditor.Text = Properties.Resources.BatchSample;

            CsharpTextEditor.TextArea.SetResourceReference(TextArea.SelectionBrushProperty, "AccentColorBrush2");
            VisualBasicTextEditor.TextArea.SetResourceReference(TextArea.SelectionBrushProperty, "AccentColorBrush2");
            BatchTextEditor.TextArea.SetResourceReference(TextArea.SelectionBrushProperty, "AccentColorBrush2");

            CsharpTextEditor.TextArea.SelectionCornerRadius      = 0;
            VisualBasicTextEditor.TextArea.SelectionCornerRadius = 0;
            BatchTextEditor.TextArea.SelectionCornerRadius       = 0;

            var pen = new Pen((SolidColorBrush)Application.Current.Resources["AccentColorBrush2"], 1);

            CsharpTextEditor.TextArea.SelectionBorder      = pen;
            VisualBasicTextEditor.TextArea.SelectionBorder = pen;
            BatchTextEditor.TextArea.SelectionBorder       = pen;
        }
Exemplo n.º 15
0
        void editWindowItem_Click(object sender, RoutedEventArgs e)
        {
            if (!initWindow)
            {
                editWindow = new dynScriptEditWindow();
                // callbacks for autocompletion
                editWindow.editText.TextArea.TextEntering += textEditor_TextArea_TextEntering;
                editWindow.editText.TextArea.TextEntered  += textEditor_TextArea_TextEntered;

                const string pythonHighlighting = "ICSharpCode.PythonBinding.Resources.Python.xshd";
                var          elem = GetType().Assembly.GetManifestResourceStream("DynamoPython.Resources." + pythonHighlighting);

                editWindow.editText.SyntaxHighlighting =
                    HighlightingLoader.Load(new XmlTextReader(elem),
                                            HighlightingManager.Instance);
            }

            //set the text of the edit window to begin
            editWindow.editText.Text = script;

            if (editWindow.ShowDialog() != true)
            {
                return;
            }

            //set the value from the text in the box
            script = editWindow.editText.Text;

            this.dirty = true;
        }
Exemplo n.º 16
0
        public LinedTextBox_UC()
        {
            InitializeComponent();

            AutosaveTimerStart    += LinedTextBox_UC_AutosaveTimerStart;
            AutosaveTimerFinished += LinedTextBox_UC_AutosaveTimerFinished;

            if (!IsAnalyzerResult)
            {
                SaveFile           += LinedTextBox_UC_SaveFile;
                SaveAllOpenedFiles += LinedTextBox_UC_SaveAllOpenedFiles;
            }

            if (OpenedFiles == null)
            {
                OpenedFiles = new List <LinedTextBox_UC>();
            }

            OpenedFiles.Add(this);

            string json = Properties.Resources.BJson;

            using (Stream s = GenerateStreamFromString(json))
            {
                using (XmlTextReader reader = new XmlTextReader(s))
                {
                    TextEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
        }
Exemplo n.º 17
0
        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;
                    }

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

            CodeTextEditor.TextArea.TextEntered += OnTextEntered;
            SearchPanel.Install(CodeTextEditor);
        }
Exemplo n.º 18
0
        private void DocumentViewLoaded(object sender, RoutedEventArgs e)
        {
            using (var stream = Assembly.GetEntryAssembly().GetManifestResourceStream("MarkPad.Syntax.Markdown.xshd"))
                using (var reader = new XmlTextReader(stream))
                {
                    Editor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }

            documentScrollViewer = Editor.FindVisualChild <ScrollViewer>();

            if (documentScrollViewer != null)
            {
                documentScrollViewer.ScrollChanged += (i, j) => wb.ExecuteJavascript("window.scrollTo(0," + j.VerticalOffset + ");");
                var x = ((DocumentViewModel)DataContext);
                x.Document.TextChanged += (i, j) =>
                {
                    wb.LoadCompleted += (k, l) => wb.ExecuteJavascript("window.scrollTo(0," + documentScrollViewer.VerticalOffset + ");");
                };
            }

            //  AvalonEdit hijacks Ctrl+I. We need to free that mutha up
            var editCommandBindings = Editor.TextArea.DefaultInputHandler.Editing.CommandBindings;

            editCommandBindings
            .FirstOrDefault(b => b.Command == ICSharpCode.AvalonEdit.AvalonEditCommands.IndentSelection)
            .ExecuteSafely(b => editCommandBindings.Remove(b));
        }
Exemplo n.º 19
0
        private void ApplySettings()
        {
            dotEditor.FontSize   = 14.0;
            dotEditor.FontFamily = new System.Windows.Media.FontFamily("Consolas");
            dotEditor.FontWeight = System.Windows.FontWeights.Bold;

            dotEditor.ShowLineNumbers = true;

            var opts = new TextEditorOptions();

            opts.HighlightCurrentLine = true;
            opts.ConvertTabsToSpaces  = false;
            //opts.ShowColumnRuler = true;
            opts.ShowBoxForControlCharacters = true;
            dotEditor.Options = opts;

            using (Stream s = Utils.GetFileStream("dot.xshd"))
            {
                if (s != null)
                {
                    using (XmlTextReader reader = new XmlTextReader(s))
                    {
                        dotEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    }
                }
            }
        }
Exemplo n.º 20
0
 private void ShowFile(string fileName)
 {
     try
     {
         var ext = Path.GetExtension(fileName);
         if (ext == ".diff")
         {
             var assembly = Assembly.GetExecutingAssembly();
             using (Stream s = assembly.GetManifestResourceStream("GitUI.Resources.Patch-Mode.xshd"))
             {
                 using (XmlTextReader reader = new XmlTextReader(s))
                 {
                     DiffEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                 }
             }
         }
         else
         {
             this.DiffEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(
                 ext);
         }
         this.DiffEditor.ShowLineNumbers = true;
         this.DiffEditor.Load(fileName);
     }
     finally
     {
         File.Delete(fileName);
     }
 }
Exemplo n.º 21
0
        public void Init()
        {
            var hlm = HighlightingManager.Instance;

            var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

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

            var syntaxPath = Path.Combine(assemblyPath, "Syntax");

            if (!Directory.Exists(syntaxPath))
            {
                return;
            }

            foreach (var file in Directory.EnumerateFiles(syntaxPath, "*.xshd"))
            {
                var ext = Path.GetFileNameWithoutExtension(file);
                using (Stream s = File.OpenRead(Path.GetFullPath(file)))
                    using (var reader = new XmlTextReader(s))
                    {
                        var xshd = HighlightingLoader.LoadXshd(reader);
                        var highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
                        if (xshd.Extensions.Count > 0)
                        {
                            hlm.RegisterHighlighting(ext, xshd.Extensions.ToArray(), highlightingDefinition);
                        }
                    }
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Attach_Events();

            //var resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ConsultaDirectaManager.Resources.sql.xshd"))
            {
                using (var reader = new System.Xml.XmlTextReader(stream))
                {
                    txtSQL.SyntaxHighlighting =
                        HighlightingLoader.Load(reader,
                                                HighlightingManager.Instance);
                }
            }
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ConsultaDirectaManager.Resources.ini.xshd"))
            {
                using (var reader = new System.Xml.XmlTextReader(stream))
                {
                    txtCfg.SyntaxHighlighting =
                        HighlightingLoader.Load(reader,
                                                HighlightingManager.Instance);
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Main Entry Point
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            // Load the syntax highlighting from our resource
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Cerberus.UI.Resources.GSC.xshd"))
            {
                using (XmlTextReader reader = new XmlTextReader(stream))
                {
                    Decompiler.SyntaxHighlighting  = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    Disassembly.SyntaxHighlighting = Decompiler.SyntaxHighlighting;
                }
            }

            // Check for Updates
            new Thread(() =>
            {
                if (HydraUpdater.CheckForUpdates(Assembly.GetExecutingAssembly().GetName().Version))
                {
                    var result = MessageBox.Show("A new version of Cerberus is available, do you want to download it now?", "Cerberus | Update Available", MessageBoxButton.YesNo, MessageBoxImage.Information);
                    if (result == MessageBoxResult.Yes)
                    {
                        Process.Start("https://github.com/Scobalula/Cerberus-Repo/releases");
                    }
                }
            }).Start();

            ScriptList.ItemsSource = ScriptFiles;
            LoadHashTables();
        }
Exemplo n.º 24
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            base.Loaded                    += OnLoaded;
            base.Unloaded                  += OnUnloaded;
            TextArea.TextEntering          += TextEditor_TextArea_TextEntering;
            TextArea.TextEntered           += TextEditor_TextArea_TextEntered;
            TextArea.PreviewKeyDown        += TextArea_PreviewKeyDown;
            TextArea.ContextMenuOpening    += TextArea_ContextMenuOpening;
            TextArea.Caret.PositionChanged += Caret_PositionChanged;
            this.TextChanged               += TextArea_TextChanged;

            System.Reflection.Assembly myAssembly = System.Reflection.Assembly.GetAssembly(GetType());
            using (var s = myAssembly.GetManifestResourceStream("DAXEditor.Resources.DAX.xshd"))
            {
                using (var reader = new XmlTextReader(s)
                {
                    XmlResolver = null,
                    DtdProcessing = DtdProcessing.Prohibit
                })
                {
                    SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }

            // default settings - can be overridden in the settings dialog
            this.FontFamily      = new FontFamily("Lucida Console");
            this.DefaultFontSize = 11.0;
            this.FontSize        = DefaultFontSize;
            this.ShowLineNumbers = true;
        }
Exemplo n.º 25
0
 private void HighlightSyntax()
 {
     using var reader          = XmlReader.Create("Highlighting/CSharp.xshd");
     editor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
     editor.TextArea.TextView.LinkTextForegroundBrush = new SolidColorBrush(Colors.DodgerBlue);
     editor.TextArea.TextView.LinkTextUnderline       = false;
 }
Exemplo n.º 26
0
        public BehaviorEditor(ElementVO elementVO, MethodVO methodVO, ElementForm elementForm)
        {
            InitializeComponent();

            try
            {
                using (var reader = new XmlTextReader("jbdl.xshd"))
                {
                    jpBehaviorEdit.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("XSHD読み込み処理でエラーが発生しました: " + ex.Message);
            }

            jpBehaviorEdit.ShowLineNumbers       = true;
            jpBehaviorEdit.Options.ShowEndOfLine = true;
            jpBehaviorEdit.Options.ShowSpaces    = true;

            //イベントハンドラを登録
            jpBehaviorEdit.TextArea.TextEntered  += TextArea_TextEntered;
            jpBehaviorEdit.TextArea.TextEntering += TextArea_TextEntering;

            // パラメータで取得した要素、メソッドを自オブジェクト内に保持
            element          = elementVO;
            method           = methodVO;
            oldBehaviorValue = methodVO.behavior;

            this.jpBehaviorEdit.Text = BehaviorPreparator.getParsedBehavior(methodVO.behavior);

//            this.jpBehaviorEdit.Text = methodVO.behavior;

            this.parentForm = elementForm;
        }
Exemplo n.º 27
0
 /// <summary>
 /// Enable highlight on load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="routedEventArgs"></param>
 private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
 {
     using (var reader = XmlReader.Create(new StringReader(Properties.Resources.SQLSyntaxHL)))
     {
         OutputTextBox.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
     }
 }
        /// <summary>
        /// Xshdファイルを画面のAvalonEditに適用させ、ハイライトを有効にします
        /// </summary>
        /// <returns>true:成功, false:失敗</returns>
        private bool SetXshdFile()
        {
            Logger.Info(CLASS_NAME, "SetXshdFile", "start");

            MainWindow mw = Model.Manager.WindowManager.GetMainWindow();

            ICSharpCode.AvalonEdit.TextEditor target = mw.TextEditor;
            if (target == null)
            {
                Logger.Fatal(CLASS_NAME, "SetXshdFile", "GetTextEditor TextEditor is null");
                return(false);
            }

            try
            {
                using (XmlReader reader = new XmlTextReader(_xshdFilePath))
                {
                    var definition = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                    target.SyntaxHighlighting = definition;
                    reader.Close();
                }
            }
            catch (Exception e)
            {
                Logger.Fatal(CLASS_NAME, "SetXshdFile", e.ToString());
                return(false);
            }

            return(true);
        }
Exemplo n.º 29
0
        public ConnectionTabControl()
        {
            InitializeComponent();

            // Apply the SQL syntax highlighting definition
            edSQL.SyntaxHighlighting = HighlightingLoader.Load(XmlReader.Create(Assembly.GetExecutingAssembly().GetManifestResourceStream("QueryDesk.Resources.SQL.xshd")), HighlightingManager.Instance);
        }
Exemplo n.º 30
0
        public DialogLSDoc()
        {
            InitializeComponent();

            contentDisplay.TextArea.Foreground = new SolidColorBrush(Colors.Gainsboro);

            using (XmlReader reader = XmlReader.Create("LSHighlighting.xshd"))
                contentDisplay.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);


            XmlDocument doc = new XmlDocument();

            try { doc.Load("LSDoc.xml"); } catch { MessageBox.Show("No documentation file found!"); return; }

            // Go to the doc node
            main = doc.DocumentElement.SelectSingleNode("/doc");

            // Add all sections to the ComboBox
            sectionComboBox.Items.Clear();
            sections = main.ChildNodes;
            foreach (XmlNode s in sections)
            {
                sectionComboBox.Items.Add(s.Attributes["name"].Value);
            }
            sectionComboBox.SelectedIndex = 0;

            // Set the 1st as current
            currentSection = sections[0];

            SwitchPage();
        }