public DiffPanel(IViewContent viewContent) { this.viewContent = viewContent; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); textEditor = new TextEditorControl(); textEditor.Dock = DockStyle.Fill; diffViewPanel.Controls.Add(textEditor); textEditor.TextEditorProperties = SharpDevelopTextEditorProperties.Instance; textEditor.Document.ReadOnly = true; textEditor.Enabled = false; textEditor.Document.HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("Patch"); ListViewItem newItem; newItem = new ListViewItem(new string[] { "Base", "", "", "" }); newItem.Tag = Revision.Base; leftListView.Items.Add(newItem); newItem.Selected = true; newItem = new ListViewItem(new string[] { "Work", "", "", "" }); newItem.Tag = Revision.Working; rightListView.Items.Add(newItem); }
public FakeXmlViewContent(string fileName) { this.PrimaryFile = SD.FileService.GetOrCreateOpenedFile(fileName); this.oldView = this.PrimaryFile.CurrentView; this.PrimaryFile.RegisterView(this); this.PrimaryFile.SwitchedToView(this); }
public static void SetPosition(IViewContent viewContent, int markerStartLine, int markerStartColumn, int markerEndLine, int markerEndColumn) { ITextEditorProvider tecp = viewContent as ITextEditorProvider; if (tecp != null) { SetPosition(tecp.TextEditor.FileName, tecp.TextEditor.Document, markerStartLine, markerStartColumn, markerEndLine, markerEndColumn); } }
public bool CanAttachTo(IViewContent viewContent) { if (viewContent is ITextEditorControlProvider) { ITextEditorControlProvider textAreaControlProvider = (ITextEditorControlProvider)viewContent; string fileExtension = String.Empty; string fileName = viewContent.PrimaryFileName; if (fileName == null) return false; fileExtension = Path.GetExtension(fileName).ToLowerInvariant(); switch (fileExtension) { case ".cs": case ".vb": ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false); if (IsDesignable(info)) return true; break; case ".xfrm": return true; } } return false; }
public override bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { if (file == this.PrimaryFile) return oldView.SupportsSwitchToThisWithoutSaveLoad(file, primaryViewContent); else return base.SupportsSwitchFromThisWithoutSaveLoad(file, oldView); }
public override void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) { if (file == this.PrimaryFile && this != newView) { SaveToPrimary(); primaryViewContent.SwitchFromThisWithoutSaveLoad(file, newView); } }
public static XmlView ForViewContent(IViewContent view) { if ((view == null) || (view.PrimaryFile == null)) { return null; } return ForFile(view.PrimaryFile); }
void Init(IViewContent view) { this.view = view; editable = view.GetService<IEditable>(); textEditor = view.GetService<ITextEditor>(); textEditorOptions = textEditor.Options; }
public override void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { if (file == this.PrimaryFile && oldView != this) { primaryViewContent.SwitchToThisWithoutSaveLoad(file, oldView); LoadFromPrimary(); } }
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent) { List<IViewContent> views = new List<IViewContent>(); XmlSchemaCompletion defaultSchema = XmlEditorService.XmlSchemaFileAssociations.GetSchemaCompletion(viewContent.PrimaryFileName); views.Add(new XmlTreeView(viewContent, XmlEditorService.RegisteredXmlSchemas.Schemas, defaultSchema)); return views.ToArray(); }
public WpfPreview(ReportDesignerLoader loader,IViewContent content) : base(content) { LoggingService.Info("Create WpfPreview"); this.designerLoader = loader; TabPageText = "WpfPreview"; }
public SdiWorkspaceWindow (DefaultWorkbench workbench, IViewContent content, Notebook tabControl, TabLabel tabLabel) : base () { this.workbench = workbench; this.tabControl = tabControl; this.content = content; this.tabLabel = tabLabel; this.tabPage = content.Control; content.WorkbenchWindow = this; content.ContentNameChanged += new EventHandler(SetTitleEvent); content.DirtyChanged += new EventHandler(SetTitleEvent); content.BeforeSave += new EventHandler(BeforeSave); content.ContentChanged += new EventHandler (OnContentChanged); ShadowType = ShadowType.None; box = new VBox (); box.PackStart (content.Control); Add (box); box.Show (); SetTitleEvent(null, null); commandHandler = new ViewCommandHandlers (this); Show (); }
public bool CanAttachTo (IViewContent content) { if (content.GetContent (typeof(MonoDevelop.Ide.Gui.Content.IEditableTextBuffer)) == null) return false; else return CodeBehind.IsDesigneable (content.Project.GetProjectFile (content.ContentName)); }
public DriverUserControl(IViewContent viewContent) { _viewContent = viewContent; InitializeComponent(); CreateDriverTab(); }
// IExportRunner exportRunner = new ExportRunner(); public TestWPFReportPreview(ReportDesignerLoader loader,IViewContent content):base(content) { this.designerLoader = loader; viewer = new ICSharpCode.Reporting.WpfReportViewer.WpfReportViewer(); base.TabPageText = "TestWpf View"; Pages = new Collection<Page>(); }
/// <summary> /// Wix dialog designer can attach to Wix source files (.wxs) and /// Wix include files (.wxi). /// </summary> public bool CanAttachTo(IViewContent view) { if (IsViewTextEditorProvider(view)) { return WixFileName.IsWixFileName(view.PrimaryFileName); } return false; }
public SdiWorkspaceWindow (DefaultWorkbench workbench, IViewContent content, Notebook tabControl, TabLabel tabLabel) : base () { this.workbench = workbench; this.tabControl = tabControl; this.content = content; this.tabLabel = tabLabel; this.tabPage = content.Control; ShadowType = ShadowType.None; box = new VBox (); Add (box); box.PackStart (content.Control); fileTypeCondition.SetFileName (content.ContentName ?? content.UntitledName); extensionContext = AddinManager.CreateExtensionContext (); extensionContext.RegisterCondition ("FileType", fileTypeCondition); content.WorkbenchWindow = this; content.ContentNameChanged += new EventHandler(SetTitleEvent); content.DirtyChanged += new EventHandler(SetTitleEvent); content.BeforeSave += new EventHandler(BeforeSave); content.ContentChanged += new EventHandler (OnContentChanged); box.Show (); SetTitleEvent(null, null); commandHandler = new ViewCommandHandlers (this); Show (); }
void Init(IViewContent view) { this.view = view; editable = view as IEditable; textEditorProvider = view as ITextEditorProvider; textEditor = textEditorProvider.TextEditor; textEditorOptions = textEditor.Options; }
public static void SetPosition(IViewContent viewContent, int makerStartLine, int makerStartColumn, int makerEndLine, int makerEndColumn) { ITextEditorControlProvider tecp = viewContent as ITextEditorControlProvider; if (tecp != null) SetPosition(tecp.TextEditorControl.FileName, tecp.TextEditorControl.Document, makerStartLine, makerStartColumn, makerEndLine, makerEndColumn); else Remove(); }
/// <summary> /// Creates a new ReportPreview object /// </summary> public ReportPreview(ReportDesignerLoader loader,IViewContent content):base(content) { if (loader == null) { throw new ArgumentNullException("loader"); } this.designerLoader = loader; base.TabPageText = ResourceService.GetString("SharpReport.Preview"); }
static bool IsUntitled(IViewContent viewContent) { OpenedFile file = viewContent.PrimaryFile; if (file == null) return false; else return file.IsUntitled; }
public bool CanAttachTo(IViewContent parent) { string filename = parent.ContentName; string mimetype = Gnome.Vfs.MimeType.GetMimeTypeForUri (filename); if (mimetype == "text/html") return true; return false; }
internal static Document FromWindow(IViewContent viewContent) { IEditable editable = viewContent as IEditable; if (editable != null) { return new Document(viewContent, editable); } else { return null; } }
internal static Document FromWindow(IViewContent viewContent) { ITextEditorProvider editable = viewContent as ITextEditorProvider; if (editable != null) { return new Document(viewContent, editable.TextEditor.PrimaryView.Document); } else { return null; } }
public static void SetPosition(IViewContent viewContent, int markerStartLine, int markerStartColumn, int markerEndLine, int markerEndColumn) { if (viewContent == null) return; ITextEditor editor = viewContent.GetService<ITextEditor>(); if (editor != null) { SetPosition(editor.FileName, editor.Document, markerStartLine, markerStartColumn, markerEndLine, markerEndColumn); } }
public override void ForceInitializeView(IViewContent view) { if (view == null) throw new ArgumentNullException("view"); if (!registeredViews.Contains(view)) throw new ArgumentException("registeredViews must contain view"); base.ForceInitializeView(view); }
/// <summary> /// Gets the WixDialogDesigner from the primary view. /// </summary> /// <returns>The wix dialog designer view that is attached as a /// secondary view; <see langword="null"/> if the primary view /// has no such designer attached.</returns> public static WixDialogDesigner GetDesigner(IViewContent view) { foreach (IViewContent secondaryView in view.SecondaryViewContents) { WixDialogDesigner designer = secondaryView as WixDialogDesigner; if (designer != null) { return designer; } } return null; }
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent) { if (viewContent.SecondaryViewContents.Any(c => c is FormsDesignerViewContent)) { return new IViewContent[0]; } IDesignerLoaderProvider loader = new BooDesignerLoaderProvider(); IDesignerGenerator generator = new BooDesignerGenerator(); return new IViewContent[] { new FormsDesignerViewContent(viewContent, loader, generator) }; }
internal static Document FromWindow(IViewContent viewContent) { if (viewContent == null) return null; ITextEditor editor = viewContent.GetService(typeof(ITextEditor)) as ITextEditor; if (editor != null) { return new Document(viewContent, editor.Document); } else { return null; } }
public bool CanAttachTo(IViewContent content) { ITextEditorProvider textEditorProvider = content as ITextEditorProvider; if (textEditorProvider != null) { if (IsRubyFile(content.PrimaryFileName)) { ParseInformation parseInfo = GetParseInfo(content.PrimaryFileName, textEditorProvider.TextEditor.Document); return IsDesignable(parseInfo); } } return false; }
void UpdateInfoTip() { IViewContent content = ActiveViewContent; if (content != null) { string newInfoTip = content.InfoTip; if (newInfoTip != this.InfoTip) { this.InfoTip = newInfoTip; if (DragEnabledArea != null) { DragEnabledArea.ToolTip = this.InfoTip; } OnInfoTipChanged(); } } }
public void CloseContent(IViewContent content) { if (PropertyService.Get("FanHai.Gui.Framework.LoadDocumentProperties", true) && content is IMementoCapable) { StoreMemento(content); } if (primaryViewContentCollection.Contains(content)) { primaryViewContentCollection.Remove(content); } OnViewClosed(new ViewContentEventArgs(content)); content.Dispose(); content = null; int i = primaryViewContentCollection.Count; if (i > 0) { primaryViewContentCollection[i - 1].WorkbenchWindow.SelectWindow(); } }
/// <summary> /// Stores the memento for the view content. /// Such mementos are automatically loaded in ShowView(). /// </summary> public void StoreMemento(IViewContent viewContent) { IMementoCapable mementoCapable = viewContent as IMementoCapable; if (mementoCapable != null && LoadDocumentProperties) { if (viewContent.PrimaryFileName == null) { return; } string key = GetMementoKeyName(viewContent); LoggingService.Debug("Saving memento of '" + viewContent.ToString() + "' to key '" + key + "'"); Properties memento = mementoCapable.CreateMemento(); Properties p = this.LoadOrCreateViewContentMementos(); p.Set(key, memento); FileUtility.ObservedSave(new NamedFileOperationDelegate(p.Save), this.ViewContentMementosFileName, FileErrorPolicy.Inform); } }
public CombinedDesignView(IViewContent content) { this.content = content; /* This code causes that chagnes in a version control view always select the source code view. * if (content is IEditableTextBuffer) { * ((IEditableTextBuffer)content).CaretPositionSet += delegate { * ShowPage (0); * }; * }*/ content.ContentChanged += new EventHandler(OnTextContentChanged); content.DirtyChanged += new EventHandler(OnTextDirtyChanged); CommandRouterContainer crc = new CommandRouterContainer(content.Control, content, true); crc.Show(); control = crc; IdeApp.Workbench.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged); }
void LoadViewContentMemento(IViewContent viewContent) { IMementoCapable mementoCapable = viewContent.GetService <IMementoCapable>(); if (mementoCapable != null && LoadDocumentProperties) { if (viewContent.PrimaryFileName == null) { return; } try { string key = GetMementoKeyName(viewContent); LoggingService.Debug("Trying to restore memento of '" + viewContent.ToString() + "' from key '" + key + "'"); mementoCapable.SetMemento(this.LoadOrCreateViewContentMementos().NestedProperties(key)); } catch (Exception e) { MessageService.ShowException(e, "Can't get/set memento"); } } }
public override void Run() { Workbench workbench = (Workbench)this.Owner; if (workbench.CloseCurrentContent()) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.CheckFileExists = true; dlg.DefaultExt = ".txt"; dlg.Filter = FileViewContent.GetFileFilter("/Workspace/FileFilter"); if (dlg.ShowDialog() == DialogResult.OK) { IViewContent content = DisplayBindingManager.CreateViewContent(dlg.FileName); if (content != null) { workbench.ShowContent(content); } } } } }
async Task TypeCode() { IViewContent vc = FileService.NewFile("stresstest.cs", ""); ITextEditor editor = vc.GetRequiredService <ITextEditor>(); TextArea textArea = editor.GetRequiredService <TextArea>(); string inputText = string.Join("\n", File.ReadAllLines(bigFile).Where(l => !string.IsNullOrWhiteSpace(l) && !l.StartsWith("//", StringComparison.Ordinal))); await Dispatcher.Yield(Idle); for (int i = 0; i < Math.Min(inputText.Length, Repetitions); i++) { textArea.PerformTextInput(inputText[i].ToString()); await Dispatcher.Yield(Idle); while (!textArea.StackedInputHandlers.IsEmpty) { textArea.PopStackedInputHandler(textArea.StackedInputHandlers.Peek()); } await Dispatcher.Yield(Idle); } vc.WorkbenchWindow.CloseWindow(true); }
public virtual void ShowView(IViewContent content) { System.Diagnostics.Debug.Assert(layout != null); ViewContentCollection.Add(content); if (PropertyService.Get("SharpDevelop.LoadDocumentProperties", true) && content is IMementoCapable) { try { Properties memento = GetStoredMemento(content); if (memento != null) { ((IMementoCapable)content).SetMemento(memento); } } catch (Exception e) { MessageService.ShowError(e, "Can't get/set memento"); } } layout.ShowView(content); content.WorkbenchWindow.SelectWindow(); OnViewOpened(new ViewContentEventArgs(content)); }
void ActiveViewContentChanged(object sender, EventArgs e) { IViewContent viewContent = SD.Workbench.ActiveViewContent; if (currentSolution == null || viewContent == null) { return; } FileName fileName = viewContent.PrimaryFileName; if (fileName == null) { return; } IProject project = FindProjectContainingFile(fileName); if (project != null) { CurrentProject = project; } }
public bool CloseCurrentContent() { IViewContent content = viewContent; if (content != null) { if (!content.Close()) { return(false); } viewContent = null; content.TitleChanged -= OnTitleChanged; OnTitleChanged(content, EventArgs.Empty); foreach (Control ctl in contentPanel.Controls) { ctl.Dispose(); } contentPanel.Controls.Clear(); } return(true); }
public override void Run() { IViewContent viewContent = WorkbenchSingleton.Workbench.ActiveViewContent; if (viewContent == null || !(viewContent is ITextEditorProvider)) { return; } ITextEditor textEditor = ((ITextEditorProvider)viewContent).TextEditor; if (textEditor == null) { return; } string newGuid = Guid.NewGuid().ToString().ToUpperInvariant(); textEditor.SelectedText = newGuid; textEditor.Select(textEditor.SelectionStart + textEditor.SelectionLength, 0); }
/// <inheritdoc/> public IViewContent JumpToFilePosition(FileName fileName, int line, int column) { LoggingService.InfoFormatted("FileService\n\tJumping to File Position: [{0} : {1}x{2}]", fileName, line, column); if (fileName == null) { return(null); } NavigationService.SuspendLogging(); bool loggingResumed = false; try { IViewContent content = OpenFile(fileName); IPositionable positionable = content != null?content.GetService <IPositionable>() : null; if (positionable != null) { content.WorkbenchWindow.ActiveViewContent = content; NavigationService.ResumeLogging(); loggingResumed = true; positionable.JumpTo(Math.Max(1, line), Math.Max(1, column)); } else { NavigationService.ResumeLogging(); loggingResumed = true; NavigationService.Log(content); } return(content); } finally { LoggingService.InfoFormatted("FileService\n\tJumped to File Position: [{0} : {1}x{2}]", fileName, line, column); if (!loggingResumed) { NavigationService.ResumeLogging(); } } }
FormsDesignerViewContent(IViewContent primaryViewContent) : base() { this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; if (!FormKeyHandler.inserted) { FormKeyHandler.Insert(); } this.primaryViewContent = primaryViewContent; this.UserContent = this.pleaseWaitLabel; this.sourceCodeStorage = new DesignerSourceCodeStorage(); this.resourceStore = new ResourceStore(this); this.IsActiveViewContentChanged += this.IsActiveViewContentChangedHandler; FileService.FileRemoving += this.FileServiceFileRemoving; ICSharpCode.SharpDevelop.Debugging.DebuggerService.DebugStarting += this.DebugStarting; }
static void GoToDefinition(DefinitionInfo definition) { if (!definition.HasFileName()) { return; } IViewContent view = FileService.OpenFile(definition.fileName); if (view == null) { return; } ITextEditor textEditor = view.GetService <ITextEditor>(); if (textEditor != null) { TextLocation location = textEditor.Document.GetLocation(definition.minChar); FileService.JumpToFilePosition(definition.fileName, location.Line, location.Column); } }
protected override void OnDestroyed() { if (present_timeout != 0) { GLib.Source.Remove(present_timeout); } base.OnDestroyed(); if (viewContents != null) { foreach (IAttachableViewContent sv in SubViewContents) { sv.Dispose(); } viewContents = null; } if (content != null) { content.ContentNameChanged -= new EventHandler(SetTitleEvent); content.DirtyChanged -= HandleDirtyChanged; content.BeforeSave -= new EventHandler(BeforeSave); content.ContentChanged -= new EventHandler(OnContentChanged); content.WorkbenchWindow = null; content.Dispose(); content = null; } if (subViewToolbar != null) { subViewToolbar.Dispose(); subViewToolbar = null; } DetachFromPathedDocument(); commandHandler = null; document = null; extensionContext = null; }
async Task TypeText(string theText) { const string csharpHeader = "using System;\n\nclass Test {\n\tpublic void M() {\n\t\t"; const string csharpFooter = "\n\t}\n}\n"; IViewContent vc = FileService.NewFile("stresstest.cs", ""); ITextEditor editor = vc.GetRequiredService <ITextEditor>(); editor.Document.Text = csharpHeader + csharpFooter; editor.Caret.Offset = csharpHeader.Length; TextArea textArea = (TextArea)editor.GetService(typeof(TextArea)); await Dispatcher.Yield(Idle); for (int i = 0; i < Repetitions; i++) { foreach (char c in "// " + theText + "\n") { textArea.PerformTextInput(c.ToString()); await Dispatcher.Yield(Idle); } } vc.WorkbenchWindow.CloseWindow(true); }
IEnumerable <DispatcherPriority> TypeCode() { IViewContent vc = FileService.NewFile("stresstest.cs", ""); ITextEditor editor = ((ITextEditorProvider)vc).TextEditor; TextArea textArea = (TextArea)editor.GetService(typeof(TextArea)); string inputText = string.Join("\n", File.ReadAllLines(bigFile).Where(l => !string.IsNullOrWhiteSpace(l) && !l.StartsWith("//", StringComparison.Ordinal))); yield return(DispatcherPriority.SystemIdle); for (int i = 0; i < Math.Min(inputText.Length, Repetitions); i++) { textArea.PerformTextInput(inputText[i].ToString()); yield return(DispatcherPriority.SystemIdle); while (!textArea.StackedInputHandlers.IsEmpty) { textArea.PopStackedInputHandler(textArea.StackedInputHandlers.Peek()); } yield return(DispatcherPriority.SystemIdle); } vc.WorkbenchWindow.CloseWindow(true); }
public override bool StorePanelContents() { ((IProperties)CustomizationObject).SetProperty("DoubleBuffer", ((CheckBox)ControlDictionary["enableDoublebufferingCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("UseAntiAliasFont", ((CheckBox)ControlDictionary["enableAAFontRenderingCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("MouseWheelTextZoom", ((CheckBox)ControlDictionary["mouseWheelZoomCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("EnableCodeCompletion", ((CheckBox)ControlDictionary["enableCodeCompletionCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("EnableFolding", ((CheckBox)ControlDictionary["enableFoldingCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("DefaultFont", CurrentFont.ToString()); ((IProperties)CustomizationObject).SetProperty("Encoding", CharacterEncodings.GetCodePageByIndex(((ComboBox)ControlDictionary["textEncodingComboBox"]).SelectedIndex)); ((IProperties)CustomizationObject).SetProperty("ShowQuickClassBrowserPanel", ((CheckBox)ControlDictionary["showQuickClassBrowserCheckBox"]).Checked); IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent; if (content != null && (content is TextEditorView)) { TextEditorControl textEditorContorl = content.Control as TextEditorControl; textEditorContorl.OptionsChanged(); } return(true); }
public bool CanAttachTo(IViewContent viewContent) { if (viewContent is ITextEditorControlProvider) { ITextEditorControlProvider textAreaControlProvider = (ITextEditorControlProvider)viewContent; string fileExtension = String.Empty; string fileName = viewContent.PrimaryFileName; if (fileName == null) { return(false); } if (Path.GetExtension(fileName).Equals(".boo", StringComparison.OrdinalIgnoreCase)) { ParseInformation info = ParserService.ParseFile(fileName, textAreaControlProvider.TextEditorControl.Document.TextContent, false); if (FormsDesignerSecondaryDisplayBinding.IsDesignable(info)) { return(true); } } } return(false); }
public static string GetParseableFileContent(string fileName) { IWorkbenchWindow window = FileService.GetOpenFile(fileName); if (window != null) { IViewContent viewContent = window.ViewContent; IEditable editable = viewContent as IEditable; if (editable != null) { return(editable.Text); } } //string res = project.GetParseableFileContent(fileName); //if (res != null) // return res; // load file Encoding tmp = DefaultFileEncoding; return(ICSharpCode.TextEditor.Util.FileReader.ReadFileContent(fileName, ref tmp, tmp)); }
/// <summary> /// Forces initialization of the specified view. /// </summary> public virtual void ForceInitializeView(IViewContent view) { if (view == null) { throw new ArgumentNullException("view"); } bool success = false; try { if (currentView != view) { if (currentView == null) { SwitchedToView(view); } else { try { inLoadOperation = true; using (Stream sourceStream = OpenRead()) { view.Load(this, sourceStream); } } finally { inLoadOperation = false; } } } success = true; } finally { // Only in case of exceptions: // (try-finally with bool is better than try-catch-rethrow because it causes the debugger to stop // at the original error location, not at the rethrow) if (!success) { view.Dispose(); } } }
public override void Run() { IViewContent vc = SD.Workbench.ActiveViewContent; if (vc == null) { return; } var codeEditor = vc.GetService <CodeEditor>(); if (codeEditor != null) { ChooseEncodingDialog dlg = new ChooseEncodingDialog(); dlg.Owner = SD.Workbench.MainWindow; dlg.Encoding = codeEditor.PrimaryTextEditor.Encoding; if (dlg.ShowDialog() == true) { codeEditor.PrimaryTextEditor.Encoding = dlg.Encoding; SharpDevelop.Commands.SaveFile.Save(vc.PrimaryFile); } } }
/// <summary> /// Begins parsing the specified view content. /// This method can only be called from the main thread. /// </summary> /// <remarks> /// EnqueueForParsing has been renamed to BeginParse and now provides a future (Task<ParseInformation>) /// to allow waiting for the result. However, to avoid deadlocks, this should not be done by any /// thread the parser might be waiting for (especially the main thread). /// /// Unlike BeginParse().Wait(), ParseFile() is safe to call from the main thread. /// </remarks> public static Task <ParseInformation> BeginParseViewContent(IViewContent viewContent) { if (viewContent == null) { throw new ArgumentNullException("viewContent"); } WorkbenchSingleton.AssertMainThread(); if (string.IsNullOrEmpty(viewContent.PrimaryFileName)) { return(NullTask()); } IEditable editable = viewContent as IEditable; if (editable != null) { return(BeginParse(viewContent.PrimaryFileName, editable.CreateSnapshot())); } else { return(BeginParse(viewContent.PrimaryFileName)); } }
/// <summary> /// Opens the specified file and jumps to the specified file position. /// Line and column start counting at 1. /// </summary> public static IViewContent JumpToFilePosition(string fileName, int line, int column) { LoggingService.InfoFormatted("FileService\n\tJumping to File Position: [{0} : {1}x{2}]", fileName, line, column); if (fileName == null || fileName.Length == 0) { return(null); } NavigationService.SuspendLogging(); bool loggingResumed = false; try { IViewContent content = OpenFile(fileName); if (content is IPositionable) { // TODO: enable jumping to a particular view content.WorkbenchWindow.ActiveViewContent = content; NavigationService.ResumeLogging(); loggingResumed = true; ((IPositionable)content).JumpTo(Math.Max(1, line), Math.Max(1, column)); } else { NavigationService.ResumeLogging(); loggingResumed = true; NavigationService.Log(content); } return(content); } finally { LoggingService.InfoFormatted("FileService\n\tJumped to File Position: [{0} : {1}x{2}]", fileName, line, column); if (!loggingResumed) { NavigationService.ResumeLogging(); } } }
public void StoreMemento(IViewContent content) { if (content.FileName == null) { return; } string directory = Path.Combine(PropertyService.ConfigDirectory, "temp"); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } Properties memento = ((IMementoCapable)content).CreateMemento(); string fullFileName = GetMementoFileName(content.FileName); if (FileUtility.IsValidFileName(fullFileName)) { FileUtility.ObservedSave(new NamedFileOperationDelegate(memento.Save), fullFileName, FileErrorPolicy.Inform); } }
public bool IsValid(object caller, Condition condition) { if (SD.Workbench == null) { return(false); } IViewContent viewContent = SD.Workbench.ActiveViewContent; if (viewContent == null || viewContent.PrimaryFile == null) { return(false); } if (!condition.Properties.Contains("activewindowuntitled")) { return(viewContent.PrimaryFile.IsUntitled); } bool activewindowuntitled = Boolean.Parse(condition.Properties["activewindowuntitled"]); return(viewContent.PrimaryFile.IsUntitled == activewindowuntitled); }
public void ShowView(IViewContent content, bool switchToOpenedView) { if (!_documentCollection.Contains(content)) { _documentCollection.Add(content); } LoadViewContentMemento(content); if (content.ViewObject == null) { Current.Gui.FindAndAttachControlTo(content); } if (switchToOpenedView) { ActiveViewContent = content; content.IsVisible = true; content.IsSelected = true; content.IsActive = true; } }
public IWorkbenchWindow ShowView(IViewContent content, bool switchToOpenedView) { if (content.WorkbenchWindow is SdiWorkspaceWindow) { SdiWorkspaceWindow oldSdiWindow = (SdiWorkspaceWindow)content.WorkbenchWindow; if (!oldSdiWindow.IsDisposed) { if (switchToOpenedView) { oldSdiWindow.Show(dockPanel); } else { this.AddWindowToDockPanelWithoutSwitching(oldSdiWindow); } return(oldSdiWindow); } } content.Control.Dock = DockStyle.Fill; SdiWorkspaceWindow sdiWorkspaceWindow = new SdiWorkspaceWindow(); sdiWorkspaceWindow.ViewContents.Add(content); sdiWorkspaceWindow.ViewContents.AddRange(content.SecondaryViewContents); sdiWorkspaceWindow.CloseEvent += new EventHandler(CloseWindowEvent); if (dockPanel != null) { if (switchToOpenedView) { sdiWorkspaceWindow.Show(dockPanel); } else { this.AddWindowToDockPanelWithoutSwitching(sdiWorkspaceWindow); } } return(sdiWorkspaceWindow); }
public override bool StorePanelContents() { ((IProperties)CustomizationObject).SetProperty("TabsToSpaces", ((CheckBox)ControlDictionary["convertTabsToSpacesCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("MouseWheelScrollDown", ((ComboBox)ControlDictionary["mouseWhellDirectionComboBox"]).SelectedIndex == 0); ((IProperties)CustomizationObject).SetProperty("AutoInsertCurlyBracket", ((CheckBox)ControlDictionary["autoinsertCurlyBraceCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("HideMouseCursor", ((CheckBox)ControlDictionary["hideMouseCursorCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("CursorBehindEOL", ((CheckBox)ControlDictionary["caretBehindEOLCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("AutoInsertTemplates", ((CheckBox)ControlDictionary["auotInsertTemplatesCheckBox"]).Checked); ((IProperties)CustomizationObject).SetProperty("IndentStyle", ((ComboBox)ControlDictionary["indentStyleComboBox"]).SelectedIndex); try { int tabSize = Int32.Parse(ControlDictionary["tabSizeTextBox"].Text); //这里要求tabSize>0 ,因为如果为零,就会出现被零除的异常,这没有意义。 if (tabSize > 0) { ((IProperties)CustomizationObject).SetProperty("TabIndent", tabSize); } } catch (Exception) { } try { ((IProperties)CustomizationObject).SetProperty("IndentationSize", Int32.Parse(ControlDictionary["indentSizeTextBox"].Text)); } catch (Exception) { } IViewContent content = WorkbenchSingleton.Workbench.ActiveViewContent; if (content != null && (content is TextEditorView)) { TextEditorControl textarea = content.Control as TextEditorControl; textarea.OptionsChanged(); } return(true); }
public void StoreMemento(IViewContent content) { if (content.ContentName == null) { return; } PropertyService propertyService = (PropertyService)ServiceManager.Services.GetService(typeof(PropertyService)); string directory = propertyService.ConfigDirectory + "temp"; if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } XmlDocument doc = new XmlDocument(); doc.LoadXml("<?xml version=\"1.0\"?>\n<Mementoable/>"); XmlAttribute fileAttribute = doc.CreateAttribute("file"); fileAttribute.InnerText = content.ContentName; doc.DocumentElement.Attributes.Append(fileAttribute); IXmlConvertable memento = ((IMementoCapable)content).CreateMemento(); doc.DocumentElement.AppendChild(memento.ToXmlElement(doc)); string fileName = content.ContentName.Substring(3).Replace('/', '.').Replace('\\', '.').Replace(Path.DirectorySeparatorChar, '.'); FileUtilityService fileUtilityService = (FileUtilityService)ServiceManager.Services.GetService(typeof(FileUtilityService)); // check the file name length because it could be more than the maximum length of a file name string fullFileName = directory + Path.DirectorySeparatorChar + fileName; if (fileUtilityService.IsValidFileName(fullFileName)) { fileUtilityService.ObservedSave(new NamedFileOperationDelegate(doc.Save), fullFileName, FileErrorPolicy.ProvideAlternative); } }