Esempio n. 1
1
 public MWindow()
 {
     try
     {
         InitializeComponent();
         Closing += new CancelEventHandler(MWindow_Closing);
         worker.DoWork += new DoWorkEventHandler(worker_DoWork);
         worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
         dt.Interval = TimeSpan.FromSeconds(1);
         dt.Tick += new EventHandler(dt_Tick);
         foldingManager = FoldingManager.Install(textEditor.TextArea);
         foldingStrategy = new XmlFoldingStrategy();
         textEditor.TextChanged += new EventHandler(textEditor_TextChanged);
         if (App.StartUpCommand != "" && App.StartUpCommand != null)
         {
             openFile(App.StartUpCommand);
         }
         KeyGesture renderKeyGesture = new KeyGesture(Key.F5);
         KeyBinding renderCmdKeybinding = new KeyBinding(Commands.Render, renderKeyGesture);
         this.InputBindings.Add(renderCmdKeybinding);
         status.Text = "Ready!";
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Esempio n. 2
0
        public XamlPage()
        {
            InitializeComponent();

            textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML");
            TextEditorOptions options = textEditor.Options;
            if (options != null)
            {
                //options.AllowScrollBelowDocument = true;
                options.EnableHyperlinks = true;
                options.EnableEmailHyperlinks = true;
                //options.ShowSpaces = true;
                //options.ShowTabs = true;
                //options.ShowEndOfLine = true;
            }
            textEditor.ShowLineNumbers = true;

            _foldingManager  = FoldingManager.Install(textEditor.TextArea);
            _foldingStrategy = new XmlFoldingStrategy();

            textEditor.CommandBindings.Add(new CommandBinding(
                ApplicationCommands.Print, OnPrint, OnCanExecuteTextEditorCommand));
            textEditor.CommandBindings.Add(new CommandBinding(
                ApplicationCommands.PrintPreview, OnPrintPreview, OnCanExecuteTextEditorCommand));

            _searchHandler = new SearchInputHandler(textEditor.TextArea);
            textEditor.TextArea.DefaultInputHandler.NestedInputHandlers.Add(_searchHandler);
        }
 public void Dispose()
 {
     if (foldingManager != null) {
         FoldingManager.Uninstall(foldingManager);
         foldingManager = null;
     }
 }
Esempio n. 4
0
        public MainForm() {
            InitializeComponent();

            // 初始化编辑器。
            codeEditor = new ICSharpCode.AvalonEdit.TextEditor();
            codeEditorHost.Child = codeEditor;

            codeEditor.FontFamily = new System.Windows.Media.FontFamily("Consolas");
            codeEditor.FontSize = 14;
            codeEditor.ShowLineNumbers = true;
            codeEditor.SyntaxHighlighting = syntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".js");
            codeEditor.WordWrap = true;

            foldingManager = FoldingManager.Install(codeEditor.TextArea);
            codeEditor.TextChanged += codeEditor_TextChanged;

            //codeEditor.TextArea.AddHandler(System.Windows.DataObject.PastingEvent, new System.Windows.DataObjectPastingEventHandler(codeEditor_Paste));

            textMarkerService = new TextMarkerService(codeEditor);
            TextView textView = codeEditor.TextArea.TextView;
            textView.BackgroundRenderers.Add(textMarkerService);
            textView.LineTransformers.Add(textMarkerService);
            textView.Services.AddService(typeof(TextMarkerService), textMarkerService);
            textView.MouseHover += MouseHover;
            textView.MouseHoverStopped += codeEditorMouseHoverStopped;

            textView.MouseHover += MouseHover;
            textView.MouseHoverStopped += codeEditorMouseHoverStopped;
            textView.VisualLinesChanged += VisualLinesChanged;

        }
Esempio n. 5
0
		/// <summary>
		/// Initializes a new instance of the <see cref="AvalonEditor"/> class.
		/// </summary>
		/// <exception cref="System.InvalidOperationException">Failed to load syntax definition</exception>
		public AvalonEditor()
		{
			_foldingManager = FoldingManager.Install(TextArea);
			_folding = new XmlFoldingStrategy();

			_htmlIndent = new HtmlIndentationStrategy();
			_defaultIndent = new DefaultIndentationStrategy();

			AutoIndent = true;
			AutoIndentAmount = 1;

			ShowLineNumbers = true;

			// Load our HTML highlighting
			using (var s = typeof(AvalonEditor).Assembly.GetManifestResourceStream(typeof(AvalonEditor), "HtmlHighlighting.xml"))
			{
				if (s == null)
					throw new InvalidOperationException("Failed to load syntax definition");
				using (var r = XmlReader.Create(s))
				{
					var highlightingDefinition = HighlightingLoader.Load(r, HighlightingManager.Instance);

					SyntaxHighlighting = highlightingDefinition;
				}
			}

            IsDirty = false;

            Task.Factory.StartNew(FoldingUpdateLoop);
		}
 public FoldingManagerAdapter(ITextEditor textEditor)
 {
     AvalonEditTextEditorAdapter adaptor = textEditor as AvalonEditTextEditorAdapter;
     if (adaptor != null) {
         this.foldingManager = FoldingManager.Install(adaptor.TextEditor.TextArea);
     }
 }
 public void ResetFoldingManager()
 {
   if (_foldingManager != null)
     FoldingManager.Uninstall(_foldingManager);
   _foldingManager = FoldingManager.Install(this.editor.TextArea);
   UpdateFoldings();
 }
		public void InstallFoldingManager()
		{
			var textEditorAdapter = textEditor as AvalonEditTextEditorAdapter;
			if (textEditorAdapter != null) {
				foldingManager = FoldingManager.Install(textEditorAdapter.TextEditor.TextArea);
			}
		}
Esempio n. 9
0
 internal FoldingSection(FoldingManager manager, int startOffset, int endOffset)
 {
     Debug.Assert(manager != null);
     this.manager = manager;
     this.StartOffset = startOffset;
     this.Length = endOffset - startOffset;
 }
 public XmlMessageView()
 {
     InitializeComponent();
     foldingManager = FoldingManager.Install(document.TextArea);
     foldingStrategy = new XmlFoldingStrategy();
     SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
     document.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
 }
 public JsonMessageView()
 {
     InitializeComponent();
     foldingManager = FoldingManager.Install(document.TextArea);
     foldingStrategy = new BraceFoldingStrategy();
     SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
     document.TextArea.IndentationStrategy = new DefaultIndentationStrategy();
 }
 public DocumentDialog(string value)
 {
     InitializeComponent();
     this.jsonEditor.Text = value;
     this.jsonEditor.TextChanged += Te_TextChanged;
     foldingManager = FoldingManager.Install(this.jsonEditor.TextArea);
     foldingStrategy = new BraceFoldingStrategy();
     foldingStrategy.UpdateFoldings(foldingManager, jsonEditor.Document);
 }
Esempio n. 13
0
        public void UpdateFoldings(FoldingManager manager, ITextSource document)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");

            int firstErrorOffset;
            IEnumerable<NewFolding> newFoldings = CreateNewFoldings(document, out firstErrorOffset);
            manager.UpdateFoldings(newFoldings, firstErrorOffset);
        }
Esempio n. 14
0
        public TextEditorControl(string name, int index)
        {
            InitializeComponent();

            FileName = name;
            FileIndex = index;

            var foldingUpdateTimer = new DispatcherTimer {Interval = TimeSpan.FromSeconds(2)};
            foldingUpdateTimer.Tick += FoldingUpdateTimerTick;
            foldingUpdateTimer.Start();

            if (File.Exists(@"Highlighter\CustomHighlighting.xshd"))
            {
                var fileStream = new FileStream(@"Highlighter\CustomHighlighting.xshd", FileMode.Open, FileAccess.Read);
                using (var reader = new XmlTextReader(fileStream))
                {
                    textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
                fileStream.Close();
            }

            textEditor.TextArea.IndentationStrategy =
                new CSharpIndentationStrategy(textEditor.Options);
            _foldingStrategy = new BEFoldingStrategy();

            if (_foldingStrategy != null)
            {
                if (_foldingManager == null)
                    _foldingManager = FoldingManager.Install(textEditor.TextArea);
                _foldingStrategy.UpdateFoldings(_foldingManager, textEditor.Document);
            }
            else
            {
                if (_foldingManager != null)
                {
                    FoldingManager.Uninstall(_foldingManager);
                    _foldingManager = null;
                }
            }

            textEditor.Text = "# Welcome to lpSolver (Linear Programming Solver)!" + Environment.NewLine;
            textEditor.Text += "lpmodel ModelName" + FileIndex.ToString() + " \n{" + Environment.NewLine;
            textEditor.Text += string.Format("\t# TODO : Objectives {0}{0}", Environment.NewLine + "\t");

            textEditor.Text += "min 10*x + 20*y" + Environment.NewLine;
            textEditor.Text += "\tsubject to:" + Environment.NewLine;
            textEditor.Text += "\tx + y > 10;" + Environment.NewLine;
            textEditor.Text += "\t0<x;" + Environment.NewLine;
            textEditor.Text += "\t0<y;" + Environment.NewLine;
            textEditor.Text += Environment.NewLine + "\t";
            textEditor.Text += Environment.NewLine;
            textEditor.Text += "};" + Environment.NewLine;
            textEditor.Text += "# __EOF" + Environment.NewLine;

            textEditor.ShowLineNumbers = true;
            FileUrl = string.Empty;
        }
        /// <summary>
        /// Determine whether or not highlighting can be
        /// suppported by a particular folding strategy.
        /// </summary>
        /// <param name="syntaxHighlighting"></param>
        public void SetFolding(IHighlightingDefinition syntaxHighlighting)
        {
            if (syntaxHighlighting == null)
              {
            this.mFoldingStrategy = null;
              }
              else
              {
            switch (syntaxHighlighting.Name)
            {
              case "XML":
              case "HTML":
            mFoldingStrategy = new XmlFoldingStrategy() { ShowAttributesWhenFolded = true };
            this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
            break;
              case "C#":
            this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options);
            mFoldingStrategy = new CSharpBraceFoldingStrategy();
            break;
              case "C++":
              case "PHP":
              case "Java":
            this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options);
            mFoldingStrategy = new CSharpBraceFoldingStrategy();
            break;
              case "VBNET":
            this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(this.Options);
            mFoldingStrategy = new VBNetFoldingStrategy();
            break;
              default:
            this.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
            mFoldingStrategy = null;
            break;
            }

            if (mFoldingStrategy != null)
            {
              if (this.Document != null)
              {
            if (mFoldingManager == null)
              mFoldingManager = FoldingManager.Install(this.TextArea);

            this.mFoldingStrategy.UpdateFoldings(mFoldingManager, this.Document);
              }
              else
            this.mInstallFoldingManager = true;
            }
            else
            {
              if (mFoldingManager != null)
              {
            FoldingManager.Uninstall(mFoldingManager);
            mFoldingManager = null;
              }
            }
              }
        }
Esempio n. 16
0
        public APITestDialog()
        {
            InitializeComponent();

             foldingManager = FoldingManager.Install(xmlViewer.TextArea);
             foldingStrategy = new XmlFoldingStrategy();

             LoadAPICalls();
        }
Esempio n. 17
0
        public GeneratedCodeView()
        {

            // Load our custom highlighting definition
            IHighlightingDefinition customHighlighting;
            using (Stream s = typeof(GeneratedCodeView).Assembly.GetManifestResourceStream("CinchCodeGen.UserControls.CustomHighlighting.xshd"))
            {
                if (s == null)
                    throw new InvalidOperationException("Could not find embedded resource");
                using (XmlReader reader = new XmlTextReader(s))
                {
                    customHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                        HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            // and register it in the HighlightingManager
            HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting);



            InitializeComponent();

            txtCode.SyntaxHighlighting = customHighlighting;

            if (txtCode.SyntaxHighlighting == null)
            {
                foldingStrategy = null;
            }
            else
            {
                foldingStrategy = new BraceFoldingStrategy();
            }

            if (foldingStrategy != null)
            {
                if (foldingManager == null)
                    foldingManager = FoldingManager.Install(txtCode.TextArea);
                foldingStrategy.UpdateFoldings(foldingManager, txtCode.Document);
            }
            else
            {
                if (foldingManager != null)
                {
                    FoldingManager.Uninstall(foldingManager);
                    foldingManager = null;
                }
            }

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();
            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();


            this.DataContextChanged += GeneratedCodeView_DataContextChanged;
        }
        public SagaContentViewer()
        {
            InitializeComponent();

            foldingManager = FoldingManager.Install(document.TextArea);
            foldingStrategy = new BraceFoldingStrategy();
            SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
            document.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
            document.TextChanged += DocumentOnTextChanged;
        }
Esempio n. 19
0
        public void UpdateFoldings(FoldingManager foldingManager, TextDocument textDocument)
        {
            // Clear foldings if the list isn't empty.
            if (this.foldings.Foldings.Count > 0)
            {
                this.foldings.Foldings.Clear();
            }

            CreateNewFoldings(textDocument);
            foldingManager.UpdateFoldings(this.foldings.Foldings, this.foldings.FirstErrorOffset);
        }
        //BraceFoldingStrategy foldingStrategy;
        public TextEditor()
        {
            InitializeComponent();

              // CodeLanguage = NServiceBus.Profiler.Common.CodeParser.CodeLanguage.Plain;

              // -- AvalonEdit
              foldingManager = FoldingManager.Install(doc.TextArea);
              //foldingStrategy = new BraceFoldingStrategy();
              SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Display);
              doc.TextArea.IndentationStrategy = new DefaultIndentationStrategy();
        }
        private void SetUpTextEditor()
        {
            _editor = new TextEditor { SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"), ShowLineNumbers = true, VerticalScrollBarVisibility = ScrollBarVisibility.Auto, HorizontalScrollBarVisibility = ScrollBarVisibility.Auto };
            _editor.SetValue(AutomationProperties.AutomationIdProperty, "UI_XMLEditor_AutoID");

            _foldingStrategy = new XmlFoldingStrategy();
            _foldingManager = FoldingManager.Install(_editor.TextArea);
            _editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();

            _foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
            _foldingUpdateTimer.Tick += OnFoldingUpdateTimerOnTick;
            _foldingUpdateTimer.Start();
        }
Esempio n. 22
0
    public ExtendedEditor()
    {
      InitializeComponent();

      _foldingManager = FoldingManager.Install(this.editor.TextArea);
      UpdateFoldings();

      _foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
      _foldingUpdateTimer.Tick += delegate { UpdateFoldings(); };
      _foldingUpdateTimer.Start();

      this.editor.TextArea.MouseRightButtonDown += TextArea_MouseRightButtonDown;
    }
Esempio n. 23
0
 public RenderToy()
 {
     InitializeComponent();
     Loaded += new RoutedEventHandler(RenderToy_Loaded);
     gscreen = new GameScreen(screen.Handle);
     dt.Interval = TimeSpan.FromSeconds(1);
     dt.Start();
     dt.Tick += new EventHandler(dt_Tick);
     status.Text = Variables.StatusString + Variables.LoadingString;
     foldingManager = FoldingManager.Install(textEditor.TextArea);
     foldingStrategy = new XmlFoldingStrategy();
     textEditor.TextChanged += new EventHandler(textEditor_TextChanged);
     screen.SizeChanged += new SizeChangedEventHandler(screen_SizeChanged);
 }
        public ExtendedEditor()
        {
            InitializeComponent();

              _foldingManager = FoldingManager.Install(this.editor.TextArea);
              _foldingStrategy.ShowAttributesWhenFolded = true;
              UpdateFoldings();

              var foldingUpdateTimer = new DispatcherTimer();
              foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
              foldingUpdateTimer.Tick += delegate { UpdateFoldings(); };
              foldingUpdateTimer.Start();

              this.editor.TextArea.MouseRightButtonDown += TextArea_MouseRightButtonDown;
        }
Esempio n. 25
0
        public Details()
        {
            InitializeComponent();
            this.Reset();
            this.treeviewTargets.ItemsSource = this.TargetsToBuild;

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
            foldingUpdateTimer.Tick += this.foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();

            this.foldingStrategy = new XmlFoldingStrategy();
            this.textBoxXml.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();

            this.foldingManager = FoldingManager.Install(this.textBoxXml.TextArea);
            this.foldingStrategy.UpdateFoldings(this.foldingManager, this.textBoxXml.Document);
        }
        /// <summary>
        /// Create a new interface document.
        /// </summary>
        /// <param name="game">A game object used for graphical components.</param>
        /// <param name="directory">Path to the directory the interface resides in.</param>
        public EqInterfaceContent(Game game, string directory)
            : base()
        {
            m_interface = EqInterface.LoadInterface(game, directory);
            m_files = new EqFileCollection();

            TextEditorSettings settings = TextEditorSettings.Default;
            settings.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(TextEditorSettingsChanged);

            // create the text editor
            m_textEditor = new TextEditor();
            m_textEditor.Foreground = new SolidColorBrush(settings.Color_XML_Text);
            m_textEditor.Background = new SolidColorBrush(settings.Color_XML_Background);
            m_textEditor.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            m_textEditor.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            m_textEditor.WordWrap = TextEditorSettings.Default.WordWrap;
            m_textEditor.ShowLineNumbers = TextEditorSettings.Default.ShowLineNumbers;
            m_textEditor.TextChanged += new EventHandler(TextEditor_TextChanged);
            m_textEditor.TextArea.TextEntered += new TextCompositionEventHandler(TextArea_TextEntered);

            // load syntax highlighting ruleset
            using (Stream stream = new MemoryStream(EQXResources.equi_xml))
            {
                using (XmlReader reader = new XmlTextReader(stream))
                {
                    m_textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }

            // install the folding manager
            m_foldingManager = FoldingManager.Install(m_textEditor.TextArea);
            m_foldingStrategy = new XmlFoldingStrategy();

            m_treeViewRoot = new TreeViewItem();
            m_treeViewRoot.Header = m_interface.Directory.Name;
            m_treeViewRoot.Tag = this;

            foreach (EqFile file in m_interface.Files)
            {
                EqFileContent fileContent = new EqFileContent(file);
                m_treeViewRoot.Items.Add(fileContent.TreeViewRoot);
            }

            // embed the text editor
            Content = m_textEditor;
        }
Esempio n. 27
0
        public MainWindow()
        {
            IHighlightingDefinition coolHighlighting;
            using (System.IO.Stream s = typeof(MainWindow).Assembly.GetManifestResourceStream("CoolCompiler.CoolHighlighting.xshd"))
            {
                if (s == null)
                    throw new InvalidOperationException("Could not find embedded resource");
                using (XmlReader reader = new XmlTextReader(s))
                {
                    coolHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.
                        HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }
            HighlightingManager.Instance.RegisterHighlighting("Cool Highlighting", new string[] { ".cool" }, coolHighlighting);

            InitializeComponent();

            foldingStrategy = new CoolFoldingStrategy();
            foldingManager = FoldingManager.Install(tbEditor.TextArea);

            tbEditor.ShowLineNumbers = true;

            tbEditor.TextArea.TextEntering += tbEditor_TextArea_TextEntering;
            tbEditor.TextArea.TextEntered += tbEditor_TextArea_TextEntered;

            DispatcherTimer foldingUpdateTimer = new DispatcherTimer();
            foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2);
            foldingUpdateTimer.Tick += foldingUpdateTimer_Tick;
            foldingUpdateTimer.Start();

            if (Settings.Default.WindowLeft != 0)
                Left = Settings.Default.WindowLeft;
            if (Settings.Default.WindowTop != 0)
                Top = Settings.Default.WindowTop;
            if (Settings.Default.WindowWidth != 0)
                Width = Settings.Default.WindowWidth;
            if (Settings.Default.WindowTop != 0)
                Height = Settings.Default.WindowHeight;

            if (!string.IsNullOrEmpty(Settings.Default.FileName))
                LoadFile(Settings.Default.FileName);

            Log = new StringBuilder();
            CoolTokens.Load("../../output/CoolGrammar.tokens");
        }
Esempio n. 28
0
 void HighlightingComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (textEditor.SyntaxHighlighting == null)
     {
         foldingStrategy = null;
     }
     else
     {
         switch (textEditor.SyntaxHighlighting.Name)
         {
             case "XML":
                 foldingStrategy = new XmlFoldingStrategy();
                 textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                 break;
             case "C#":
             case "C++":
             case "PHP":
             case "Java":
                 textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options);
                 foldingStrategy = new BraceFoldingStrategy();
                 break;
             default:
                 textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.DefaultIndentationStrategy();
                 foldingStrategy = null;
                 break;
         }
     }
     if (foldingStrategy != null)
     {
         if (foldingManager == null)
             foldingManager = FoldingManager.Install(textEditor.TextArea);
         foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
     }
     else
     {
         if (foldingManager != null)
         {
             FoldingManager.Uninstall(foldingManager);
             foldingManager = null;
         }
     }
 }
        /// <summary>
        /// Create a new file document.
        /// </summary>
        public EqFileContent(EqFile file)
            : base()
        {
            m_file = file;

            // create the text editor
            m_textEditor = new TextEditor();
            m_textEditor.Foreground = Brushes.White;
            m_textEditor.Background = new SolidColorBrush(new System.Windows.Media.Color() { R = 0x20, G = 0x20, B = 0x20, A = 0xFF });
            m_textEditor.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            m_textEditor.VerticalAlignment = System.Windows.VerticalAlignment.Stretch;
            m_textEditor.WordWrap = TextEditorSettings.Default.WordWrap;
            m_textEditor.ShowLineNumbers = TextEditorSettings.Default.ShowLineNumbers;
            m_textEditor.TextChanged += new EventHandler(TextEditor_TextChanged);
            m_textEditor.TextArea.TextEntered += new TextCompositionEventHandler(TextArea_TextEntered);

            // load syntax highlighting ruleset
            using (Stream stream = new MemoryStream(EQXResources.equi_xml))
            {
                using (XmlReader reader = new XmlTextReader(stream))
                {
                    m_textEditor.SyntaxHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance);
                }
            }

            // install the folding manager
            m_foldingManager = FoldingManager.Install(m_textEditor.TextArea);
            m_foldingStrategy = new XmlFoldingStrategy();

            m_treeViewRoot = new TreeViewItem();
            m_treeViewRoot.Header = m_file.Filename;
            m_treeViewRoot.Tag = this;

            foreach (EqElement element in m_file.Elements)
            {

            }

            // embed the text editor
            Content = m_textEditor;
        }
        public void UpdateFoldings(FoldingManager fm, IEnumerable<String> linesadded)
        {

            var last = fm.GetNextFolding(lastfold.StartOffset);
            foreach (var line in linesadded)
            {
                 var M = r.Match(line);
                 if (M.Success)
                 {
                     endfold = n + line.Length;
                     if (!prev)
                     {
                         prev = true;
                         startfold = n;
                         lastfold = new NewFolding(startfold, endfold);
                         fm.CreateFolding(startfold, endfold).Title = "FileSync Complete";
                     }
                     else
                     {
                         last.EndOffset = endfold;
                     }
                    
                     
                 }
                 else
                 {
                     if (prev)
                     {
                       
                             lastfold = new NewFolding(startfold, endfold);
                             fm.CreateFolding(startfold, endfold).Title = "FileSync Complete";
                         
                     }
                         
                     prev = false;
                 }

                 linenr++;
                 n += line.Length+1;
            }
        }
Esempio n. 31
0
        void TextViewVisualLinesChanged(object sender, EventArgs e)
        {
            foreach (FoldingMarginMarker m in markers)
            {
                RemoveVisualChild(m);
            }
            markers.Clear();
            InvalidateVisual();
            if (TextView != null && FoldingManager != null && TextView.VisualLinesValid)
            {
                foreach (VisualLine line in TextView.VisualLines)
                {
                    FoldingSection fs = FoldingManager.GetNextFolding(line.FirstDocumentLine.Offset);
                    if (fs == null)
                    {
                        continue;
                    }
                    if (fs.StartOffset <= line.LastDocumentLine.Offset + line.LastDocumentLine.Length)
                    {
                        FoldingMarginMarker m = new FoldingMarginMarker {
                            IsExpanded     = !fs.IsFolded,
                            VisualLine     = line,
                            FoldingSection = fs
                        };

                        markers.Add(m);
                        AddVisualChild(m);

                        m.IsMouseDirectlyOverChanged += delegate { InvalidateVisual(); };

                        InvalidateMeasure();
                        continue;
                    }
                }
            }
        }
Esempio n. 32
0
 internal FoldingSection(FoldingManager manager, int startOffset, int endOffset)
 {
     this.manager     = manager;
     this.StartOffset = startOffset;
     this.Length      = endOffset - startOffset;
 }
Esempio n. 33
0
 internal void Removed()
 {
     manager = null;
 }