public EttOutputWindow(List <ConnectionUnion> unions, string type, Window parentwindow) { _codeclosing = false; _parentWindow = parentwindow; Unions = unions; if (type == "Common") { result = new EttOutputCommon(Unions); } if (type == "Oleg") { result = new EttOutputOlegStyle(Unions); } var doc = new TextDocument { Text = result.Container, FileName = result.Name }; InitializeComponent(); Title = ApplicationSettings.Name; Editor.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("CustomSyntaxDefinitionCpp.xshd"); Editor.Document = doc; Editor.ShowLineNumbers = true; var foldingManager = FoldingManager.Install(Editor.TextArea); var foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, Editor.Document); }
void InitFolding() { if (txtResult.SyntaxHighlighting == null) { foldingStrategyA = null; } else { foldingStrategyA = new BraceFoldingStrategy(); } if (foldingStrategyA != null) { if (foldingManagerA == null) { foldingManagerA = FoldingManager.Install(txtResult.TextArea); } foldingStrategyA.UpdateFoldings(foldingManagerA, textEditorA.Document); } else { if (foldingManagerA != null) { FoldingManager.Uninstall(foldingManagerA); foldingManagerA = null; } } }
private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) { this.textModeControl.TextChanged += Te_TextChanged; foldingManager = FoldingManager.Install(this.textModeControl.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, textModeControl.Document); }
public DocumentJsonView() { InitializeComponent(); jsonEditor.ShowLineNumbers = true; jsonEditor.Encoding = Encoding.UTF8; jsonEditor.Options.EnableEmailHyperlinks = false; jsonEditor.Options.EnableHyperlinks = false; _foldingManager = FoldingManager.Install(jsonEditor.TextArea); _foldingStrategy = new BraceFoldingStrategy(); _searchReplacePanel = SearchReplacePanel.Install(jsonEditor); _searchReplacePanel.IsFindOnly = true; jsonEditor.TextArea.MaxWidth = SystemParameters.VirtualScreenWidth; jsonEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); jsonEditor.TextArea.TextView.ElementGenerators.Add(new TruncateLongLines(LineMaxLength)); CommandBindings.Add(new CommandBinding(Commands.FindNext, (sender, e) => _searchReplacePanel.FindNext(), CanExecuteWithOpenSearchPanel)); CommandBindings.Add(new CommandBinding(Commands.FindPrevious, (sender, e) => _searchReplacePanel.FindPrevious(), CanExecuteWithOpenSearchPanel)); SetTheme(); Loaded += (sender, args) => ThemeManager.CurrentThemeChanged += ThemeManagerOnCurrentThemeChanged; Unloaded += (sender, args) => ThemeManager.CurrentThemeChanged -= ThemeManagerOnCurrentThemeChanged; }
/// <summary> /// plugin window constuctor /// </summary> public PluginWindow() { InitializeComponent(); this.DataContext = this; EditTimePluginTextEditor.TextArea.TextEntering += TextEditor_TextEntering; EditTimePluginTextEditor.TextArea.TextEntered += EditTimePluginTextEditor_TextEntered; RunTimePluginTextEditor.TextArea.TextEntering += TextEditor_TextEntering; RunTimePluginTextEditor.TextArea.TextEntered += RunTimePluginTextEditor_TextEntered; EditTimePluginTextEditor.Options.EnableHyperlinks = false; EditTimePluginTextEditor.Options.EnableEmailHyperlinks = false; RunTimePluginTextEditor.Options.EnableHyperlinks = false; RunTimePluginTextEditor.Options.EnableEmailHyperlinks = false; folding = new BraceFoldingStrategy(); edittimeFoldingManager = FoldingManager.Install(EditTimePluginTextEditor.TextArea); runtimeFoldingManager = FoldingManager.Install(RunTimePluginTextEditor.TextArea); folding.UpdateFoldings(edittimeFoldingManager, EditTimePluginTextEditor.Document); folding.UpdateFoldings(runtimeFoldingManager, RunTimePluginTextEditor.Document); //setip ctrl-f to single page code find edittimePanel = SearchPanel.Install(EditTimePluginTextEditor); runtimePanel = SearchPanel.Install(RunTimePluginTextEditor); }
internal void InitFolding() { foldingUpdateTimer.Stop(); if (textEditor.SyntaxHighlighting == null) { foldingStrategy = null; } else { foldingStrategy = new BraceFoldingStrategy(); foldingUpdateTimer.Start(); } 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> /// expression window constructor /// </summary> public ExpressionWindow() { InitializeComponent(); CodeTextEditor.TextArea.TextEntering += TextEditor_TextEntering; CodeTextEditor.TextArea.TextEntered += CodeTextEditor_TextEntered; AceTextEditor.TextArea.TextEntering += TextEditor_TextEntering; AceTextEditor.TextArea.TextEntered += AceTextEditor_TextEntered; LanguageTextEditor.TextArea.TextEntering += TextEditor_TextEntering; LanguageTextEditor.TextArea.TextEntered += LanguageTextEditor_TextEntered; AceTextEditor.Options.EnableEmailHyperlinks = false; AceTextEditor.Options.EnableHyperlinks = false; CodeTextEditor.Options.EnableEmailHyperlinks = false; CodeTextEditor.Options.EnableHyperlinks = false; LanguageTextEditor.Options.EnableEmailHyperlinks = false; LanguageTextEditor.Options.EnableHyperlinks = false; folding = new BraceFoldingStrategy(); aceFoldingManager = FoldingManager.Install(CodeTextEditor.TextArea); folding.UpdateFoldings(aceFoldingManager, CodeTextEditor.Document); //setip ctrl-f to single page code find codePanel = SearchPanel.Install(CodeTextEditor); langPanel = SearchPanel.Install(LanguageTextEditor); acePanel = SearchPanel.Install(AceTextEditor); //setup ace view when find local acePanel.GotFocus += AceView_OnClick; langPanel.GotFocus += LangView_OnClick; codePanel.GotFocus += CodeView_OnClick; }
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); } } }
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); }
private void ConfigureEditor() { foldingManager = FoldingManager.Install(avalon_txt.TextArea); foldingStrategy = new BraceFoldingStrategy(); UpdateTextView(avalon_txt.Document.Text); avalon_txt.Options.EnableHyperlinks = true; avalon_txt.TextArea.IndentationStrategy = new CSharpIndentationStrategy(); }
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; }
public override IEnumerable <NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset) { // clear existing foldings BraceFoldingStrategy bfs = new BraceFoldingStrategy(); List <NewFolding> newFoldings = new List <NewFolding>(bfs.CreateNewFoldings(document, out firstErrorOffset)); newFoldings = GetFoldingRanges(document, newFoldings); firstErrorOffset = lastDetectedError; return(newFoldings); }
private void ConfigureEditor() { foldingManager = FoldingManager.Install(editor.TextArea); foldingStrategy = new BraceFoldingStrategy(); UpdateTextView(editor.Document.Text); editor.Options.EnableHyperlinks = true; editor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(); InitializeTextMarkerService(); }
public override IEnumerable <NewFolding> CreateNewFoldings(TextDocument document, out int firstErrorOffset) { Logger.LogM("CSharpPragmaRegionFoldingStrategy", ".CreateNewFoldings(TextDocument,out int)"); // clear existing foldings BraceFoldingStrategy bfs = new BraceFoldingStrategy(); List <NewFolding> newFoldings = new List <NewFolding>(bfs.CreateNewFoldings(document, out firstErrorOffset)); GetFoldingRanges(document, newFoldings); firstErrorOffset = lastDetectedError; return(newFoldings); }
static ModuleDocument() { try { BraceFoldingStrategy = new BraceFoldingStrategy(); } catch (Exception error) { Framework.EventBus.Publish(error); } }
public MainWindow() { InitializeComponent(); MainWindowViewModel.TempDir = Path.Combine(Path.GetTempPath(), "SharpNative"); if (!Directory.Exists(MainWindowViewModel.TempDir)) { Directory.CreateDirectory(MainWindowViewModel.TempDir); } // Dispatcher.Invoke(() => Console.SetOut(new ControlWriter(Errors))); CompilerUtils.DeleteFilesByWildcards("Test*.exe", MainWindowViewModel.TempDir); ViewModel.Window = this; TextEditor.Text = ViewModel.SourceCode; TextEditor.TextArea.TextEntering += textEditor_TextArea_TextEntering; TextEditor.TextArea.TextEntered += textEditor_TextArea_TextEntered; TextEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(TextEditor.Options); foldingStrategy = new BraceFoldingStrategy(); DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += foldingUpdateTimer_Tick; foldingUpdateTimer.Start(); if (foldingManager == null) foldingManager = FoldingManager.Install(TextEditor.TextArea); foldingStrategy.CreateNewFoldings(TextEditor.Document); TextEditor.Text = VisualCompilerConstants.InitialCode; CppFileList.SelectionChanged += (sender, args) => { var list = (ListBox) sender; if (list.SelectedItem == null) return; var fileItem = (FileItem) list.SelectedItem; Output.Text = FileExtensions.ReadFile(fileItem.Location); }; }
private static void JsonTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { if (d is TextEditor textEditor) { if (!_editorToFoldingLookup.ContainsKey(textEditor)) { _editorToFoldingLookup.Add(textEditor, FoldingManager.Install(textEditor.TextArea)); } textEditor.Text = (string)e.NewValue; var foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(_editorToFoldingLookup[textEditor], textEditor.Document); } }
public C2RuntimeWindow() { InitializeComponent(); C2RuntimeTextEditor.TextArea.TextEntered += C2RuntimeTextEditor_TextEntered; C2RuntimeTextEditor.Options.EnableHyperlinks = false; C2RuntimeTextEditor.Options.EnableEmailHyperlinks = false; folding = new BraceFoldingStrategy(); c2FoldingManager = FoldingManager.Install(C2RuntimeTextEditor.TextArea); folding.UpdateFoldings(c2FoldingManager, C2RuntimeTextEditor.Document); //setip ctrl-f to single page code find runtimePanel = SearchPanel.Install(C2RuntimeTextEditor); }
public DocumentJsonView() { InitializeComponent(); jsonEditor.ShowLineNumbers = true; jsonEditor.Encoding = Encoding.UTF8; SetSyntaxHighlightingTheme(); _foldingManager = FoldingManager.Install(jsonEditor.TextArea); _foldingStrategy = new BraceFoldingStrategy(); jsonEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); ThemeManager.CurrentThemeChanged += (sender, args) => { SetSyntaxHighlightingTheme(); }; }
private void Document_Loaded(object sender, RoutedEventArgs e) { //using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("a7DocumentDbStudio.Resources.avalonEditJson.xshd")) //{ // using (var reader = new System.Xml.XmlTextReader(stream)) // { // this.jsonEditor.SyntaxHighlighting = // ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load(reader, // ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance); // } //} this.jsonEditor.TextChanged += Te_TextChanged; foldingManager = FoldingManager.Install(this.jsonEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, jsonEditor.Document); }
public DocumentJsonView() { InitializeComponent(); jsonEditor.ShowLineNumbers = true; jsonEditor.Encoding = Encoding.UTF8; _foldingManager = FoldingManager.Install(jsonEditor.TextArea); _foldingStrategy = new BraceFoldingStrategy(); _searchReplacePanel = SearchReplacePanel.Install(jsonEditor); _searchReplacePanel.IsFindOnly = true; jsonEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); SetTheme(); ThemeManager.CurrentThemeChanged += (sender, args) => { SetTheme(); }; }
/// <summary> /// Initializes a new instance of the <see cref="TextEditorView"/> class. /// </summary> public TextEditorView() { #region Highlighting definition // Load our custom highlighting definition var type = typeof(TextEditorView); var fullName = "Orchestra.Modules.TextEditor.Helpers.CustomHighlighting.xshd"; // Get Names of All Embeded Resources //var something = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames(); IHighlightingDefinition customHighlighting; using (Stream s = type.Assembly.GetManifestResourceStream(fullName)) { if (s == null) { throw new InvalidOperationException("Could not find embedded resource"); } using (XmlReader reader = new XmlTextReader(s)) { customHighlighting = HighlightingLoader.Load(reader, HighlightingManager.Instance); } } // and register it in the HighlightingManager HighlightingManager.Instance.RegisterHighlighting("Custom Highlighting", new string[] { ".cool" }, customHighlighting); #endregion InitializeComponent(); _colorizerCollection = new List <LineColorizer>(); #region Folding Init _foldingStrategy = new BraceFoldingStrategy(); textEditor.TextArea.TextEntering += TextArea_TextEntering; textEditor.TextArea.TextEntered += TextArea_TextEntered; DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += FoldingUpdateTimer_Tick; foldingUpdateTimer.Start(); #endregion }
public PyScriptControl() { LoadIPyHighlighting(); InitializeComponent(); IsDebug = true; CurrentFile = new ScriptFile(); TextEditor.TextChanged += TextEditor_TextChanged; TextEditor.TextArea.TextEntering += TextArea_TextEntering; TextEditor.TextArea.TextEntered += TextArea_TextEntered; TextEditor.MouseWheel += TextEditor_PreviewMouseWheel; TextEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(); TextEditor.Options.ConvertTabsToSpaces = true; foldingManager = FoldingManager.Install(TextEditor.TextArea); foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, TextEditor.Document); pythonAutoCompletionHelper = new PythonAutoCompletionHelper(); }
private void IndentLines() { foldingStrategy = new BraceFoldingStrategy(); 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; } } }
public CodeEditorView() { InitializeComponent(); Loaded += (s, e) => { if (foldingManager == null) { foldingManager = FoldingManager.Install(textEditor.TextArea); } braceStrategy = new BraceFoldingStrategy(); regionStrategy = new RegionFoldingStrategy(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); DispatcherTimer foldingUpdateTimer = new DispatcherTimer(); foldingUpdateTimer.Interval = TimeSpan.FromSeconds(2); foldingUpdateTimer.Tick += FoldingUpdateTimer_Tick; foldingUpdateTimer.Start(); }; }
public CodeEditor(FileData aModelData) { InitializeComponent(); aModelData.AttachEditor(editor); this.data = aModelData; editor.ShowLineNumbers = true; editor.Options.ConvertTabsToSpaces = true; editor.Options.IndentationSize = 4; editor.Foreground = new SolidColorBrush(Colors.White); editor.SyntaxHighlighting = AvalonExtensions.LoadHighlightingDefinition("Debugger.Resources.Angelscript.xshd"); editor.Text = data.Code; editor.FontFamily = new FontFamily("Consolas"); editor.TextArea.TextView.CurrentLineBackground = new SolidColorBrush(Colors.LightGray); editor.TextArea.TextView.BackgroundRenderers.Add(new LineHighlighter()); editor.TextArea.LeftMargins.Insert(0, bpMargin = new BreakpointMargin(aModelData)); SearchPanel panel = SearchPanel.Install(editor.TextArea); aModelData.PropertyChanged += aModelData_PropertyChanged; foldingManager = FoldingManager.Install(editor.TextArea); codeFolding = new BraceFoldingStrategy(); UpdateFolding(); // If using IDE data then give ourselves an IntellisenseSource if (Debug.SessionData.inst().Settings.UseIDEData) intelSource = IDE.Intellisense.Sources.SourceBuilder.GetSourceForExtension(System.IO.Path.GetExtension(aModelData.SectionName)); depthScanner = new IDE.Intellisense.DepthScanner(); depthScanner.Process(editor.Text); editor.MouseHover += editor_MouseHover; editor.TextArea.MouseWheel += editor_MouseWheel; editor.KeyUp += editor_KeyUp; editor.TextChanged += editor_TextChanged; t = new System.Timers.Timer(); t.Interval = 175; t.Elapsed += t_Elapsed; t.Start(); }
public DocumentJsonView() { InitializeComponent(); jsonEditor.ShowLineNumbers = true; jsonEditor.Encoding = Encoding.UTF8; jsonEditor.Options.EnableEmailHyperlinks = false; jsonEditor.Options.EnableHyperlinks = false; _foldingManager = FoldingManager.Install(jsonEditor.TextArea); _foldingStrategy = new BraceFoldingStrategy(); _searchReplacePanel = SearchReplacePanel.Install(jsonEditor); _searchReplacePanel.IsFindOnly = true; jsonEditor.TextArea.MaxWidth = 1024; jsonEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); jsonEditor.TextArea.TextView.ElementGenerators.Add(new TruncateLongLines(LineMaxLength)); SetTheme(); ThemeManager.CurrentThemeChanged += (sender, args) => { SetTheme(); }; }
public F2KOutputWindow(List <ConnectionUnion> unions, Window parentwindow, string pcbinfo) { _codeclosing = false; _parentWindow = parentwindow; Unions = unions.OrderBy(x => x.Name, new AlphanumComparatorFast()).ToList(); Result = ConvertToResult(Unions); var doc = new TextDocument { Text = Result, FileName = pcbinfo }; InitializeComponent(); Title = ApplicationSettings.Name; Editor.SyntaxHighlighting = ResourceLoader.LoadHighlightingDefinition("CustomSyntaxDefinitionCpp.xshd"); Editor.Document = doc; Editor.ShowLineNumbers = true; var foldingManager = FoldingManager.Install(Editor.TextArea); var foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, Editor.Document); }
protected void updateFoldings() { if (foldingManager == null) { Log.Debug("foldingManager is null"); return; } switch (schema) { case ColorSchema.MSBuildTargets: { if (xmlFoldingStrategy == null) { xmlFoldingStrategy = new XmlFoldingStrategy(); } xmlFoldingStrategy.UpdateFoldings(foldingManager, _.Document); return; } case ColorSchema.InterpreterMode: case ColorSchema.ScriptMode: case ColorSchema.SBEScripts: case ColorSchema.CppLang: case ColorSchema.CSharpLang: { if (braceFoldingStrategy == null) { braceFoldingStrategy = new BraceFoldingStrategy(); } braceFoldingStrategy.UpdateFoldings(foldingManager, _.Document); return; } } foldingManager.Clear(); }
private void IndentLines() { foldingStrategy = new BraceFoldingStrategy(); 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; } } }
private async void files_SelectionChanged(object sender, SelectionChangedEventArgs e) { //files.IsEnabled = false; e.Handled = true; try { var entry = files.SelectedItem as BarEntry; if (entry == null) { ImageViewer.Visibility = Visibility.Collapsed; XMLViewer.Visibility = Visibility.Collapsed; //files.IsEnabled = true; return; } var entries = files.SelectedItems.Cast <BarEntry>().ToList(); SelectedSize = entries.Sum(x => (long)x.FileSize2); await file.readFile(entry); if (outputDevice != null) { outputDevice.Dispose(); outputDevice = null; } if (mp3File != null) { mp3File.Dispose(); mp3File = null; } if (waveFile != null) { waveFile.Dispose(); waveFile = null; } point = new Point(); validPoint = false; ImagePreview.RenderTransform = new TranslateTransform(); if (file.Preview != null) { XMLViewer.Text = file.Preview.Text; if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } foldingManager = FoldingManager.Install(XMLViewer.TextArea); if (entry.Extension == ".XMB" || entry.Extension == ".XML" || entry.Extension == ".SHP" || entry.Extension == ".LGT" || entry.Extension == ".TXT" || entry.Extension == ".CFG" || entry.Extension == ".XAML" || entry.Extension == ".PY") { var foldingStrategy = new XmlFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, XMLViewer.Document); } else if (entry.Extension == ".XS") { var foldingStrategy = new BraceFoldingStrategy(); foldingStrategy.UpdateFoldings(foldingManager, XMLViewer.Document); } } if (entry.Extension == ".WAV") { using (outputDevice = new WaveOutEvent()) using (waveFile = new WaveFileReader(file.audio)) { outputDevice.Init(waveFile); outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { await Task.Delay(500); } } ImageViewer.Visibility = Visibility.Collapsed; XMLViewer.Visibility = Visibility.Collapsed; } if (entry.Extension == ".MP3") { //var w = new WaveFormat(new BinaryReader(file.audio)); //MessageBox.Show(w.Encoding.ToString()); using (outputDevice = new WaveOutEvent()) using (mp3File = new Mp3FileReader(file.audio)) { outputDevice.Init(mp3File); outputDevice.Play(); while (outputDevice.PlaybackState == PlaybackState.Playing) { await Task.Delay(500); } } ImageViewer.Visibility = Visibility.Collapsed; XMLViewer.Visibility = Visibility.Collapsed; } else if (entry.Extension == ".DDT") { ImagePreview.Source = file.PreviewDdt.Bitmap; XMLViewer.Visibility = Visibility.Collapsed; ImageViewer.Visibility = Visibility.Visible; } else if (entry.Extension == ".TGA" || entry.Extension == ".BMP" || entry.Extension == ".PNG" || entry.Extension == ".CUR" || entry.Extension == ".JPG") { ImagePreview.Source = file.PreviewImage; XMLViewer.Visibility = Visibility.Collapsed; ImageViewer.Visibility = Visibility.Visible; } else if (entry.Extension == ".XMB" || entry.Extension == ".XML" || entry.Extension == ".SHP" || entry.Extension == ".LGT" || entry.Extension == ".XS" || entry.Extension == ".TXT" || entry.Extension == ".CFG" || entry.Extension == ".XAML" || entry.Extension == ".PY") { ImageViewer.Visibility = Visibility.Collapsed; XMLViewer.Visibility = Visibility.Visible; } else { ImageViewer.Visibility = Visibility.Collapsed; XMLViewer.Visibility = Visibility.Collapsed; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } //files.IsEnabled = true; }
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); UpdateFoldings(); } else { if (foldingManager != null) { FoldingManager.Uninstall(foldingManager); foldingManager = null; } } }
private void UpdateFoldingStrategy(TextEditor editor, BraceFoldingStrategy foldingStrategy) { var foldingManager = (editor.TextArea.GetService(typeof(FoldingManager)) as FoldingManager) ?? FoldingManager.Install(editor.TextArea); foldingStrategy.UpdateFoldings(foldingManager, editor.Document); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <returns>true when a new tab is created</returns> public bool OpenScript(string path) { int srcFileOpen = FileIsOpen(path); if (srcFileOpen == -1) // not found { FoldingManager foldingManager; AbstractFoldingStrategy foldingStrategy; foldingStrategy = new BraceFoldingStrategy(); TextEditor textEditor = new TextEditor(); textEditor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(textEditor.Options); textEditor.Foreground = FindResource("ForegroundGray") as Brush; textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); textEditor.ScrollToEnd(); textEditor.FontFamily = new FontFamily("Consolas"); textEditor.FontSize = 11; textEditor.ShowLineNumbers = true; textEditor.Text = File.ReadAllText(path, Encoding.UTF8); textEditor.Tag = path; // stores the file path in memory textEditor.TextChanged += textEditor_TextChanged; textEditor.HorizontalScrollBarVisibility = ScrollBarVisibility.Auto; textEditor.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; foldingManager = FoldingManager.Install(textEditor.TextArea); foldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); TabItem tabItem = new TabItem(); tabItem.Style = FindResource("TabItemStyle") as Style; tabItem.Foreground = FindResource("ForegroundGray") as Brush; tabItem.Header = System.IO.Path.GetFileNameWithoutExtension(path); tabItem.Content = textEditor; tabItem.Tag = path; // stores the file path in memory tabItem.Loaded += tabItem_Loaded; tabControl.Items.Add(tabItem); tabControl.SelectedIndex = tabControl.Items.Count - 1; return true; } else { tabControl.SelectedIndex = srcFileOpen; this.Activate(); FLASHWINFO pf = new FLASHWINFO(); pf.cbSize = Convert.ToUInt32(Marshal.SizeOf(pf)); pf.hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle; pf.dwFlags = FLASHW_TIMER | FLASHW_TRAY; // (or FLASHW_ALL to flash and if it is not minimized) pf.uCount = 8; pf.dwTimeout = 75; FlashWindowEx(ref pf); return false; } }
private 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 DefaultIndentationStrategy(); break; case "C#": case "C++": case "PHP": case "Java": TextEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(TextEditor.Options); foldingStrategy = new BraceFoldingStrategy(); break; default: TextEditor.TextArea.IndentationStrategy = new DefaultIndentationStrategy(); foldingStrategy = null; break; } } if (foldingStrategy != null) { if (foldingManager == null) foldingManager = FoldingManager.Install(TextEditor.TextArea); UpdateFoldings(); } else { if (foldingManager == null) return; FoldingManager.Uninstall(foldingManager); foldingManager = null; } }
private void CreateEditor() { Editor = new ICSharpCode.AvalonEdit.TextEditor(); Editor.TextArea.TextEntering += TextArea_TextEntering; Editor.TextArea.TextEntered += TextArea_TextEntered; //Editor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#"); Editor.ShowLineNumbers = true; using (StreamReader s = new StreamReader(AdmiralEnvironment.ApplicationPath + @"\\VSCSharp.xshd")) { using (XmlTextReader reader = new XmlTextReader(s)) { Editor.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.Xshd.HighlightingLoader.Load( reader, HighlightingManager.Instance); } } Editor.FontFamily = new System.Windows.Media.FontFamily("Consolas"); Editor.FontSize = 12; //Editor.SyntaxHighlighting.MainRuleSet.Rules Editor.TextArea.IndentationStrategy = new ICSharpCode.AvalonEdit.Indentation.CSharp.CSharpIndentationStrategy(Editor.Options); var foldingManager = FoldingManager.Install(Editor.TextArea); var foldingStrategy = new BraceFoldingStrategy(); this.elementHost1.Child = Editor; }
protected override void InitEditor() { m_view.TextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(".json"); m_errorMargin = new ErrorMargin { TextView = m_view.TextEditor.TextArea.TextView, HasSchema = m_schema != null, Errors = m_allErrors, JsonException = m_jsonException }; m_errorMargin.PropertyChanged += ErrorMarginOnPropertyChanged; m_view.TextEditor.TextArea.LeftMargins.Add(m_errorMargin); m_view.TextEditor.TextArea.TextEntered += TextAreaOnTextEntered; m_view.TextEditor.TextArea.TextEntering += TextAreaOnTextEntering; m_foldingManager = FoldingManager.Install(m_view.TextEditor.TextArea); m_foldingStrategy = new BraceFoldingStrategy(); m_foldingStrategy.UpdateFoldings(m_foldingManager, m_textDocument); }
protected void updateFoldings() { if(foldingManager == null) { Log.Debug("foldingManager is null"); return; } switch(schema) { case ColorSchema.MSBuildTargets: { if(xmlFoldingStrategy == null) { xmlFoldingStrategy = new XmlFoldingStrategy(); } xmlFoldingStrategy.UpdateFoldings(foldingManager, _.Document); return; } case ColorSchema.InterpreterMode: case ColorSchema.ScriptMode: case ColorSchema.SBEScript: case ColorSchema.CSharpLang: { if(braceFoldingStrategy == null) { braceFoldingStrategy = new BraceFoldingStrategy(); } braceFoldingStrategy.UpdateFoldings(foldingManager, _.Document); return; } } foldingManager.Clear(); }
public JsonFoldingStrategies(TextEditor avalonEditor) { _foldingManager = FoldingManager.Install(avalonEditor.TextArea); _strategy = new BraceFoldingStrategy(avalonEditor); }