コード例 #1
0
        public BindableAvalonEditor() : base()
        {
            if (ViewModelBase.IsInDesignModeStatic)
            {
                return;
            }

            this.TextArea.KeyDown        += TextArea_KeyDown;
            this.TextArea.PreviewKeyDown += TextArea_PreviewKeyDown;

            XshdSyntaxDefinition xshd;

            using (XmlTextReader reader = new XmlTextReader("ControllerHighlight.xml"))
            {
                xshd = HighlightingLoader.LoadXshd(reader);
            }
            var functions = SimpleIoc.Default.GetInstance <MainViewModel>().Functions;
            var regex     = @"\b(";

            foreach (var item in functions)
            {
                if (!item.IsGroup)
                {
                    regex += item.Function + "|";
                }
            }
            regex = regex.Trim('|') + @")\b";
            var def = HighlightingLoader.Load(xshd, null);

            def.MainRuleSet.Rules[0].Regex = new Regex(regex);
            SyntaxHighlighting             = def;
        }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: mzomparelli/QuickLook
        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);
                        }
                    }
            }
        }
コード例 #3
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);
                }
            }
        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: wilsoc5/tikzedt
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            cmbFontStyle.ItemsSource  = new FontStyle[] { FontStyles.Italic, FontStyles.Normal, FontStyles.Oblique };
            cmbFontWeight.ItemsSource = new FontWeight[] { FontWeights.Black, FontWeights.Bold, FontWeights.DemiBold, FontWeights.ExtraBlack, FontWeights.ExtraBold, FontWeights.ExtraLight, FontWeights.Heavy,
                                                           FontWeights.Light, FontWeights.Medium, FontWeights.Normal, FontWeights.Regular, FontWeights.SemiBold, FontWeights.Thin, FontWeights.UltraBlack,
                                                           FontWeights.UltraBold, FontWeights.UltraLight };


            try
            {
                using (XmlTextReader reader = new XmlTextReader(App.XSHDFile))
                {
                    xshd = HighlightingLoader.LoadXshd(reader);
                    //XshdColor x;
                }
                colors = xshd.Elements.OfType <XshdColor>().ToList();

                /*using (XmlTextWriter writer = new XmlTextWriter("output.xshd", System.Text.Encoding.UTF8))
                 * {
                 *  writer.Formatting = Formatting.Indented;
                 *  new SaveXshdVisitor(writer).WriteDefinition(xshd);
                 * }*/
            }
            catch (Exception)
            {
                MessageBox.Show("Error: Couldn't load syntax definition file." + Environment.NewLine + "Usage: XSHDEditor myfile.xshd", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #5
0
 public void HighlightingDefinitionCanBeLoadedFromXmlViaMemoryStream()
 {
     using (XmlTextReader reader = new XmlTextReader(predefinedManifestResourceStream)) {
         XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader);
         Assert.AreEqual("BAT", xshd.Name);
     }
 }
コード例 #6
0
        private void Options_Load(object sender, EventArgs e)
        {
            try
            {
                #region 载入语法高亮解决方案容器
                getPath();
                eleHighligh.Child = CodeHL;
                SearchPanel.Install(CodeHL.TextArea);
                string   name     = Assembly.GetExecutingAssembly().GetName().Name + ".Python.xshd";
                Assembly assembly = Assembly.GetExecutingAssembly();
                using (Stream s = assembly.GetManifestResourceStream(name))
                {
                    using (XmlTextReader reader = new XmlTextReader(s))
                    {
                        var xshd = HighlightingLoader.LoadXshd(reader);
                        CodeHL.SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                    }
                }
                #endregion


                // tabcontrol 被选择下标为 0
                mtab.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                PyCodeConfig.Config.writeConfiguration(LogPath, DateTime.Now.Date.ToString(), DateTime.Now.TimeOfDay.ToString(), ex.Message.ToString());
            }
        }
コード例 #7
0
ファイル: SettingWindow.xaml.cs プロジェクト: xubingyue/llcom
        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);
        }
コード例 #8
0
        private void LoadConfig(Config config)
        {
            string               xshdString = config.ToXshdString();
            TextReader           tr         = new StringReader(xshdString);
            XshdSyntaxDefinition syntaxDefinition;

            using (XmlTextReader reader = new XmlTextReader(tr))
            {
                syntaxDefinition = HighlightingLoader.LoadXshd(reader);
            }
            HighlightingManager     manager = HighlightingManager.Instance;
            IHighlightingDefinition def     = HighlightingLoader.Load(syntaxDefinition, manager);

            ui_editor.SyntaxHighlighting = def;

            ui_editor.FontFamily = new FontFamily(Configure.TextFont);
            ui_editor.FontSize   = Configure.TextSize;
            ui_editor.FontStyle  = Configure.TextStyle;
            ui_editor.FontWeight = Configure.TextWeight;
            ui_editor.Foreground = new SolidColorBrush(Configure.TextColor);

            ui_editor.Background        = new SolidColorBrush(Configure.BackGroundColor);
            m_caretLineRenderer.BgColor = Configure.CurrentLineColor;
            m_errorColor = Configure.ErrorLineColor;
            m_pauseColor = Configure.PauseLineColor;
            m_breakPointMargin.BreakPointBrush
                = new SolidColorBrush(Configure.BreakpointColor);
            m_breakPointMargin.PausingArrowBrush
                = new SolidColorBrush(Configure.PauseArrowColor);

            ui_editor.LineNumbersForeground
                = new SolidColorBrush(Configure.LineNumberColor);
            ui_editor.ShowLineNumbers         = Configure.ShowLineNumber;
            ui_editor.Options.IndentationSize = Configure.IndentionSize;
        }
コード例 #9
0
 XshdSyntaxDefinition LoadBuiltinXshd(string name)
 {
     using (Stream s = typeof(HighlightingManager).Assembly.GetManifestResourceStream(name)) {
         using (XmlTextReader reader = new XmlTextReader(s)) {
             return(HighlightingLoader.LoadXshd(reader));
         }
     }
 }
コード例 #10
0
        /// <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));
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        /// <summary>
        /// Registers the specified syntax highlighting definition (.XSHD file).
        /// </summary>
        /// <param name="file">The file including path.</param>
        /// <param name="theme">The theme. (Can be <see langword="null"/>.)</param>
        private void Register(string file, string theme)
        {
            // Quickly inspect the file to get name of language and supported file extensions.
            string name, extensionsString;

            if (InspectHighlightingDefinition(file, out name, out extensionsString))
            {
                Logger.Debug(
                    "Registering syntax highlighting definition (file = \"{0}\", name = \"{1}\", extensions = \"{2}\".",
                    file, name, extensionsString);

                // Use the file name if no name is defined in the highlighting definition.
                if (string.IsNullOrWhiteSpace(name))
                {
                    name = Path.GetFileNameWithoutExtension(file);
                }

                Debug.Assert(name != null, "Sanity check.");

                // Register highlighting definition in list and lookup tables.
                ThemeAwareHighlightingDefinition highlightingDefinition;
                if (!_definitionsByName.TryGetValue(name, out highlightingDefinition))
                {
                    highlightingDefinition = new ThemeAwareHighlightingDefinition(name, _themeService);
                    _definitions.Add(highlightingDefinition);

                    // Register language name.
                    _definitionsByName.Add(name, highlightingDefinition);

                    // Register supported file extensions.
                    if (extensionsString != null)
                    {
                        var extensions = extensionsString.Split(';')
                                         .Select(extension => extension.Trim())
                                         .Where(extension => extension.Length > 0);
                        foreach (var extension in extensions)
                        {
                            _definitionsByExtension[extension] = highlightingDefinition;
                        }
                    }
                }

                // Register function for deferred loading of highlighting definition.
                Func <IHighlightingDefinition> loadDefinition = () =>
                {
                    XshdSyntaxDefinition xshd;
                    using (var reader = XmlReader.Create(file))
                        xshd = HighlightingLoader.LoadXshd(reader);

                    return(HighlightingLoader.Load(xshd, this));
                };
                highlightingDefinition.Register(theme, loadDefinition);
            }
        }
コード例 #13
0
        //鼠标右键菜单
        /* -----------------------------------------------------------------------------------------*/
        /* -----------------------------------------------------------------------------------------*/
        //窗口第一次显示时执行
        private void Form1_Shown(object sender, EventArgs e)
        {
            //全屏
            // this.WindowState = FormWindowState.Maximized;
            //Lua语法高亮
            System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("AndLuaPlus.Resources.Lua.xshd"));
            var xshd = HighlightingLoader.LoadXshd(reader);

            LuaEditor.SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
            //加载Lua文件
            LuaEditor.Text = andlua.readFile(NowLuaFile);
        }
コード例 #14
0
        public ShaderView()
        {
            InitializeComponent();

            using (FileStream s = new FileStream("glsl.xshd", FileMode.Open))
            {
                using (XmlTextReader reader = new XmlTextReader(s))
                {
                    var xshd = HighlightingLoader.LoadXshd(reader);
                    avalonEdit.SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                }
            }
        }
コード例 #15
0
        public void LoadSyntaxDefinitions(ISyntaxModeProvider provider)
        {
            var manager = HighlightingManager.Instance;

            foreach (var syntaxMode in provider.SyntaxModes)
            {
                using (var reader = provider.GetSyntaxModeFile(syntaxMode))
                {
                    var xshdSyntaxDefinition   = HighlightingLoader.LoadXshd(reader);
                    var highlightingDefinition = HighlightingLoader.Load(xshdSyntaxDefinition, manager);
                    manager.RegisterHighlighting(syntaxMode.Name, syntaxMode.Extensions, highlightingDefinition);
                }
            }
        }
コード例 #16
0
ファイル: MainViewModel.cs プロジェクト: hkedjour/sqlcequery
        public void LoadSqlSyntaxHighlighter()
        {
            const string name = "ChristianHelle.DatabaseTools.SqlCe.QueryAnalyzer.Resources.SQL-Mode.xshd";

            using (var stream = Assembly.GetAssembly(GetType()).GetManifestResourceStream(name))
                if (stream != null)
                {
                    using (var reader = new XmlTextReader(stream))
                    {
                        var xshd = HighlightingLoader.LoadXshd(reader);
                        SqlSyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                    }
                }
        }
コード例 #17
0
ファイル: Form1.cs プロジェクト: vogueme/PyCode
        /// <summary>
        /// 窗体载入3
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            Visible = true;

            eleCodeBox.Child = codebox;
            eleConsole.Child = console;

            // Fast search
            SearchPanel.Install(codebox.TextArea);
            SearchPanel.Install(console.TextArea);

            // Syntax rule
            int i = 1;

            while (i <= 2)
            {
                string   name     = Assembly.GetExecutingAssembly().GetName().Name + (i == 1 ? ".Python.xshd" : ".Console.xshd");
                Assembly assembly = Assembly.GetExecutingAssembly();
                using (Stream s = assembly.GetManifestResourceStream(name))
                {
                    using (XmlTextReader reader = new XmlTextReader(s))
                    {
                        var xshd = HighlightingLoader.LoadXshd(reader);
                        (i == 1 ? codebox : console).SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                    }
                }
                i++;
            }

            // 在构造函数中
            codebox.TextArea.TextEntering += codebox_TextArea_TextEntering;
            codebox.TextArea.TextEntered  += codebox_TextArea_TextEntered;

            foldingManager  = FoldingManager.Install(codebox.TextArea);
            foldingStrategy = new XmlFoldingStrategy();
            foldingStrategy.UpdateFoldings(foldingManager, codebox.Document);

            #region 多线程
            Thread ThreadTimingEvent = new Thread(timingEventEvent);
            ThreadTimingEvent.Start();
            ThreadTimingEvent.IsBackground = true;
            #endregion

            codebox.KeyUp += new System.Windows.Input.KeyEventHandler(run_KeyUp);
            console.KeyUp += new System.Windows.Input.KeyEventHandler(run_KeyUp);

            // 获取 python 编译环境地址, 缓存到 CommonSymbolSet 类的 PythonPyCodeTargetPath & PythonLocationTargetPath 变量
            PyCode.CommonSymbolSet.PythonPyCodeTargetPath   = PyCodeConfig.Config.readConfiguration(Application.StartupPath + @"\Important\Configuration\Preferences.ini", "path", "python-use-pycode");
            PyCode.CommonSymbolSet.PythonLocationTargetPath = PyCodeConfig.Config.readConfiguration(Application.StartupPath + @"\Important\Configuration\Preferences.ini", "path", "python-use-location");
        }
コード例 #18
0
ファイル: SettingWindow.xaml.cs プロジェクト: lrxiangyu/llcom
        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;

            //快速搜索
            SearchPanel.Install(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);

            //加载编码
            var el = Encoding.GetEncodings();
            List <EncodingInfo> encodingList = new List <EncodingInfo>(el);

            //先排个序,美观点
            encodingList.Sort((x, y) => x.CodePage - y.CodePage);
            foreach (var en in encodingList)
            {
                ComboBoxItem c = new ComboBoxItem();
                c.Content = $"[{en.CodePage}] {en.Name}";
                c.Tag     = en.CodePage;
                int index = encodingComboBox.Items.Add(c);
                if (Tools.Global.setting.encoding == en.CodePage)//现在用的编码
                {
                    encodingComboBox.SelectedIndex = index;
                }
            }
        }
コード例 #19
0
        // ReSharper disable once UnusedMember.Local
        private void SwitchOldXshdFile(string oldFile, string newFile)
        {
            XshdSyntaxDefinition xshd;

            using (var reader = new XmlTextReader(oldFile))
            {
                xshd = HighlightingLoader.LoadXshd(reader);
            }

            using (var writer = new XmlTextWriter(newFile, System.Text.Encoding.UTF8))
            {
                writer.Formatting = Formatting.Indented;
                new SaveXshdVisitor(writer).WriteDefinition(xshd);
            }
        }
コード例 #20
0
 public XshdSyntaxDefinition LoadXshd()
 {
     using (XmlReader reader = CreateXmlReader()) {
         XshdSyntaxDefinition xshd = HighlightingLoader.LoadXshd(reader);
         if (xshd.Name != this.Name)
         {
             throw new InvalidOperationException("Loaded XSHD has name '" + xshd.Name + "', but expected was '" + this.Name + "'.");
         }
         if (!Enumerable.SequenceEqual(xshd.Extensions, this.Extensions))
         {
             throw new InvalidOperationException("Loaded XSHD has extensions '" + string.Join(";", xshd.Extensions) + "', but expected was '" + string.Join(";", this.Extensions) + "'.");
         }
         return(xshd);
     }
 }
コード例 #21
0
        public void KeywordIsDetected()
        {
            XshdSyntaxDefinition syntax;

            // TODO: make this clearer
            using (Stream s = Assembly.GetAssembly(typeof(KeywordSeeker)).GetManifestResourceStream("LeekIDE.Syntax.LeekScript.xshd"))
            {
                using (XmlTextReader reader = new XmlTextReader(s))
                {
                    syntax = HighlightingLoader.LoadXshd(reader);
                }
            }
            var results = new KeywordSeeker().GetResults("f", syntax.Elements.First(e => e is XshdRuleSet) as XshdRuleSet);

            Assert.IsTrue(results.All(c => c.Text == "for" || c.Text == "function" || c.Text == "false"));
        }
コード例 #22
0
 public LeekBox()
 {
     using (Stream s = Assembly.GetAssembly(typeof(LeekBox)).GetManifestResourceStream("LeekIDE.Syntax.LeekScript.xshd"))
     {
         using (XmlTextReader reader = new XmlTextReader(s))
         {
             this.Xshd = HighlightingLoader.LoadXshd(reader);
             this.SyntaxHighlighting = HighlightingLoader.Load(Xshd, HighlightingManager.Instance);
         }
     }
     this.TextArea.TextEntered += TextArea_TextEntered;
     TextArea.TextEntering     += TextArea_TextEntering;
     this.ShowLineNumbers       = true;
     FontFamily = new FontFamily("Consolas");
     FontSize   = GlobalFontsize;
 }
コード例 #23
0
        void ReloadSyntaxHighlighting()
        {
            try {
                XshdSyntaxDefinition xshd;
                using (XmlTextReader reader = new XmlTextReader(SyntaxHighlightingFileName)) {
                    xshd = HighlightingLoader.LoadXshd(reader);
                }
                Highlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                HighlightingManager.Instance.RegisterHighlighting("VBNET/Razor", new string[] { ".ps1" }, Highlighting);
                SyntaxHighlightingName = "VBNET/Razor";

                OnPropertyChanged(null);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #24
0
        private IHighlightingDefinition LoadHighlighting(string resourceName)
        {
            XshdSyntaxDefinition xshd;

            var resourceInfo = Application.GetResourceStream(new Uri(resourceName, UriKind.Relative));

            using (var s = resourceInfo.Stream)
            {
                using (XmlTextReader reader = new XmlTextReader(s))
                {
                    // in release builds, skip validating the built-in highlightings
                    xshd = HighlightingLoader.LoadXshd(reader);
                }
            }
            return(HighlightingLoader.Load(xshd, this));
        }
コード例 #25
0
        public SettingsManager()
        {
            RootFolder = DesignerProperties.GetIsInDesignMode(new DependencyObject())
                ? ProjectRootFolder()
                : Directory.GetCurrentDirectory();
            Config = Toml.ReadFile <Config>($"{RootFolder}/{ConfigFile}");
            Keymap = Toml.ReadFile <Keymap>($"{RootFolder}/{KeymapFolder}/{Config.Keymap}.toml");
            Theme  = Toml.ReadFile <Theme>($"{RootFolder}/{ThemeFolder}/{Config.Theme}.toml");
            using (XmlTextReader reader = new XmlTextReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("FasmCode.Syntax.Fasm.xshd")))
            {
                XshdSyntaxDefinition syntax = HighlightingLoader.LoadXshd(reader);
                foreach (var element in syntax.Elements)
                {
                    if (element is XshdColor)
                    {
                        var xshdColor = element as XshdColor;
                        switch (xshdColor.Name)
                        {
                        case "Comment":
                            break;

                        case "String":
                            break;

                        case "Number":
                            break;

                        case "SizeOperator":
                            break;

                        case "Register":
                            /*var c = (Color)ColorConverter.ConvertFromString("#FFFFFF00");
                             * xshdColor.Background = new SimpleHighlightingBrush(c Color.FromScRgb(1.0f, 0.9f, 0.9f, 0.3f));*/
                            break;

                        case "Instruction":
                            break;

                        default:
                            break;
                        }
                    }
                }
                Highlighting = HighlightingLoader.Load(syntax, HighlightingManager.Instance);
            }
        }
コード例 #26
0
            private Func <IHighlightingDefinition> LoadHighlighting(string resourceName)
            {
                IHighlightingDefinition Func()
                {
                    XshdSyntaxDefinition xshd;

                    using (var s = Resources.OpenStream(resourceName))
                        using (var reader = XmlReader.Create(s))
                        {
                            // in release builds, skip validating the built-in highlightings
                            xshd = HighlightingLoader.LoadXshd(reader, true);
                        }
                    return(HighlightingLoader.Load(xshd, this));
                }

                return(Func);
            }
コード例 #27
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Authenticator.LoginViaHWIDAsync();
            // What directory are the files in?...

            ///		NewTab.Text = "--Theme made by Hawk#4872,The Tabsystem should be done soon, Will be adding a way to change the color of everything this may take awhile";



            ///		SearchPanel.Install(NewTab.TextArea);


            string name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".LuaMode.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);
                    ///		NewTab.SyntaxHighlighting = HighlightingLoader.Load(xshd, HighlightingManager.Instance);
                }
            }



            try
            {
                string[] luaf = Directory.GetFiles(Directory.GetParent(Directory.GetCurrentDirectory())?.ToString() + "/Scripts", "*.lua");
                string[] txtf = Directory.GetFiles(Directory.GetParent(Directory.GetCurrentDirectory())?.ToString() + "/Scripts", "*.txt");
                for (int j = 0; j < luaf.Length; j++)
                {
                    //		scripts.Items.Add(Path.GetFileName(luaf[j]));
                }
                for (int i = 0; i < txtf.Length; i++)
                {
                    //			scripts.Items.Add(Path.GetFileName(txtf[i]));
                }
                reset.Start();
            }
            catch

            {
            }
        }
コード例 #28
0
        private IHighlightingDefinition LoadHighlightingDefinition()
        {
            HighlightingManager highlightingManager = HighlightingManager.Instance;

            if (!string.IsNullOrEmpty(CustomSyntaxHighlightingFileName))
            {
                using var reader  = new XmlTextReader(OpenStream(CustomSyntaxHighlightingFileName));
                _syntaxDefinition = HighlightingLoader.LoadXshd(reader);
            }

            if (_syntaxDefinition != null)
            {
                var highlightingDefinition = HighlightingLoader.Load(_syntaxDefinition, highlightingManager);
                highlightingManager.RegisterHighlighting(_syntaxDefinition.Name, _syntaxDefinition.Extensions.ToArray(), highlightingDefinition);
            }

            return(highlightingManager.GetDefinition(Name));
        }
コード例 #29
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //初始化编辑器
            SearchPanel.Install(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);
                }
            }
            textEditor.Text               = Global.Settings.code;
            LuaEnv.LuaApi.PrintLuaLog    += LuaApi_PrintLuaLog;
            LuaEnv.LuaRunEnv.LuaRunError += LuaRunEnv_LuaRunError;
        }
コード例 #30
0
        private void CMM_Interpreter_Loaded(object sender, RoutedEventArgs e)
        {
            //快速搜索功能
            SearchPanel.Install(textEditor.TextArea);
            //设置语法规则
            string name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Cmm.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);
                }
            }


            //优先检测是否有之前的打开记录
            FileStream   myfile     = new FileStream("./path.data", FileMode.OpenOrCreate, FileAccess.Read);
            StreamReader sr         = new StreamReader(myfile, Encoding.UTF8);
            string       sourceCode = sr.ReadToEnd();

            oldPath = sourceCode;
            sr.Close();
            if (oldPath != "")
            {
                path = oldPath;
            }
            if (path != null && path != "")//未打开或者点击了取消
            {
                treeView.ItemsSource = null;
                List <FileTreeNode> itemList   = new List <FileTreeNode>();
                FileTreeNode        fatherNode = new FileTreeNode()
                {
                    fileName = path
                };
                itemList.Add(fatherNode);
                treeView.ItemsSource = itemList;//List绑定到TreeView
                File_Copy(path, itemList, fatherNode);
            }
        }