public override void Save(OpenedFile file, Stream stream) { SD.AnalyticsMonitor.TrackFeature(typeof(HexEditView), "Save"); this.hexEditContainer.SaveFile(file, stream); this.TitleName = Path.GetFileName(file.FileName); this.TabPageText = this.TitleName; }
public AvalonEditViewContent(OpenedFile file, Encoding fixedEncodingForLoading = null) { // Use common service container for view content and primary text editor. // This makes all text editor services available as view content services and vice versa. // (with the exception of the interfaces implemented directly by this class, // those are available as view-content services only) this.Services = codeEditor.PrimaryTextEditor.GetRequiredService<IServiceContainer>(); if (fixedEncodingForLoading != null) { codeEditor.UseFixedEncoding = true; codeEditor.PrimaryTextEditor.Encoding = fixedEncodingForLoading; } this.TabPageText = "${res:FormsDesigner.DesignTabPages.SourceTabPage}"; if (file.FileName != null) { string filetype = Path.GetExtension(file.FileName); if (!IsKnownFileExtension(filetype)) filetype = ".?"; trackedFeature = SD.AnalyticsMonitor.TrackFeature(typeof(AvalonEditViewContent), "open" + filetype.ToLowerInvariant()); } this.Files.Add(file); file.ForceInitializeView(this); file.IsDirtyChanged += PrimaryFile_IsDirtyChanged; codeEditor.Document.UndoStack.PropertyChanged += codeEditor_Document_UndoStack_PropertyChanged; }
public ResourceEditWrapper(OpenedFile file) { this.TabPageText = "Resource editor"; base.UserContent = resourceEditor; resourceEditor.ResourceList.Changed += new EventHandler(SetDirty); this.Files.Add(file); }
public void AddProjectDlls(OpenedFile file) { var compilation = SD.ParserService.GetCompilationForFile(file.FileName); foreach (var reference in compilation.ReferencedAssemblies) { string f = reference.GetReferenceAssemblyLocation(); if (f != null && !addedAssemblys.Contains(f)) { try { var assembly = Assembly.LoadFrom(f); SideTab sideTab = new SideTab(sideBar, assembly.FullName.Split(new[] {','})[0]); sideTab.DisplayName = StringParser.Parse(sideTab.Name); sideTab.CanBeDeleted = false; sideTab.ChoosedItemChanged += OnChoosedItemChanged; sideTab.Items.Add(new WpfSideTabItem()); foreach (var t in assembly.GetExportedTypes()) { if (IsControl(t)) { sideTab.Items.Add(new WpfSideTabItem(t)); } } if (sideTab.Items.Count > 1) sideBar.Tabs.Add(sideTab); addedAssemblys.Add(f); } catch (Exception ex) { WpfViewContent.DllLoadErrors.Add(new SDTask(new BuildError(f, ex.Message))); } } } }
protected override void LoadInternal(OpenedFile file, Stream stream) { if (file == this.PrimaryFile) { // The FormsDesignerViewContent normally operates independently of any // text editor. The following statements connect the forms designer // directly to the underlying XML text editor so that the caret positioning // and text selection operations done by the WiX designer actually // become visible in the text editor. if (!this.SourceCodeStorage.ContainsFile(file)) { ITextEditor editor = this.PrimaryViewContent.GetService<ITextEditor>(); this.SourceCodeStorage.AddFile(file, editor.Document, SD.FileService.DefaultFileEncoding, true); } try { if (!ignoreDialogIdSelectedInTextEditor) { string dialogId = GetDialogIdSelectedInTextEditor(); if (dialogId == null) { dialogId = GetFirstDialogIdInTextEditor(); JumpToDialogElement(dialogId); } DialogId = dialogId; } wixProject = GetProject(); } catch (XmlException ex) { // Let the Wix designer loader try to load the XML and generate // an error message. DialogId = "InvalidXML"; AddToErrorList(ex); } } base.LoadInternal(file, stream); }
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 override void Save(OpenedFile file, Stream stream) { if (file != this.PrimaryFile) throw new ArgumentException("file must be the primary file of the primary view content, override Save() to handle other files"); SaveToPrimary(); primaryViewContent.Save(file, stream); }
void IViewContent.Save(OpenedFile file, Stream stream) { if (document != null) document.Save(stream, SaveOptions.DisableFormatting); else if (fileData != null) stream.Write(fileData, 0, fileData.Length); }
public override void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { if (file == this.PrimaryFile && oldView != this) { primaryViewContent.SwitchToThisWithoutSaveLoad(file, oldView); LoadFromPrimary(); } }
public IViewContent CreateContentForFile(OpenedFile file) { try { return new EDMDesignerViewContent(file); } catch (WizardCancelledException) { return null; } }
/* public static ReportDesignerView SetupDesigner () { throw new NotImplementedException("SetupDesigner"); ReportModel model = ReportModel.Create(); var reportStructure = new ReportStructure() { ReportLayout = GlobalEnums.ReportLayout.ListLayout; } IReportGenerator generator = new GeneratePlainReport(model,reportStructure); generator.GenerateReport(); // OpenedFile file = FileService.CreateUntitledOpenedFile(GlobalValues.PlainFileName,new byte[0]); // file.SetData(generator.Generated.ToArray()); // return SetupDesigner(file); return SetupDesigner(null); } */ public static ReportDesignerView SetupDesigner (OpenedFile file) { if (file == null) { throw new ArgumentNullException("file"); } IDesignerGenerator generator = new ReportDesignerGenerator(); return new ReportDesignerView(file, generator); }
public ResourceEditWrapper(OpenedFile file) { this.TabPageText = "Resource editor"; UserContent = resourceEditor; resourceEditor.ResourceList.Changed += SetDirty; resourceEditor.ResourceList.ItemSelectionChanged += (sender, e) => SD.WinForms.InvalidateCommands(); this.Files.Add(file); }
public WpfViewContent(OpenedFile file) : base(file) { SharpDevelopTranslations.Init(); BasicMetadata.Register(); this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; }
protected AbstractSecondaryViewContent(IViewContent primaryViewContent) { if (primaryViewContent == null) throw new ArgumentNullException("primaryViewContent"); if (primaryViewContent.PrimaryFile == null) throw new ArgumentException("primaryViewContent.PrimaryFile must not be null"); this.primaryViewContent = primaryViewContent; primaryFile = primaryViewContent.PrimaryFile; this.Files.Add(primaryFile); }
public HexEditView(OpenedFile file) { hexEditContainer = new HexEditContainer(); hexEditContainer.hexEditControl.DocumentChanged += new EventHandler(DocumentChanged); this.Files.Add(file); file.ForceInitializeView(this); SD.AnalyticsMonitor.TrackFeature(typeof(HexEditView)); }
public IViewContent CreateContentForFile(OpenedFile file) { string fileName = file.FileName; BrowserPane browserPane = new BrowserPane(); if (fileName.StartsWith("browser://")) { browserPane.Navigate(fileName.Substring("browser://".Length)); } else { browserPane.Navigate(fileName); } return browserPane; }
public WpfViewContent(OpenedFile file) : base(file) { SharpDevelopTranslations.Init(); BasicMetadata.Register(); this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; var compilation = SD.ParserService.GetCompilationForFile(file.FileName); _path = Path.GetDirectoryName(compilation.MainAssembly.UnresolvedAssembly.Location); AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; }
public IViewContent CreateContentForFile(OpenedFile file) { if (file.IsDirty) { ReportWizardCommand cmd = new ReportWizardCommand(file); cmd.Run(); if (cmd.Canceled) { return null; } file.SetData(cmd.GeneratedReport.ToArray()); } ReportDesignerView view = ICSharpCode.Reports.Addin.Commands.StartViewCommand.SetupDesigner(file); return view; }
public WpfViewContent(OpenedFile file) : base(file) { SharpDevelopTranslations.Init(); BasicMetadata.Register(); WpfToolbox.Instance.AddProjectDlls(file); ProjectService.ProjectItemAdded += ProjectService_ProjectItemAdded; this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}"; this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; }
protected override void LoadInternal(OpenedFile file, System.IO.Stream stream) { wasChangedInDesigner = false; Debug.Assert(file == this.PrimaryFile); SD.AnalyticsMonitor.TrackFeature(typeof(WpfViewContent), "Load"); _stream = new MemoryStream(); stream.CopyTo(_stream); stream.Position = 0; if (designer == null) { // initialize designer on first load designer = new DesignSurface(); this.UserContent = designer; InitPropertyEditor(); InitWpfToolbox(); } this.UserContent = designer; if (outline != null) { outline.Root = null; } using (XmlTextReader r = new XmlTextReader(stream)) { XamlLoadSettings settings = new XamlLoadSettings(); settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly); settings.CustomServiceRegisterFunctions.Add( delegate(XamlDesignContext context) { context.Services.AddService(typeof(IUriContext), new FileUriContext(this.PrimaryFile)); context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile)); context.Services.AddService(typeof(IEventHandlerService), new SharpDevelopEventHandlerService(this)); context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService()); context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService()); }); settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile); try { settings.ReportErrors = UpdateTasks; designer.LoadDesigner(r, settings); designer.ContextMenuOpening += (sender, e) => MenuService.ShowContextMenu(e.OriginalSource as UIElement, designer, "/AddIns/WpfDesign/Designer/ContextMenu"); if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) { outline.Root = OutlineNode.Create(designer.DesignContext.RootItem); } propertyGridView.PropertyGrid.SelectedItems = null; designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged; designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged; } catch (Exception e) { this.UserContent = new WpfDocumentError(e); } } }
// private TestWPFReportPreview testView; #region Constructor /// <summary> /// Creates a new ReportDesignerView object /// </summary> public ReportDesignerView(OpenedFile openedFile, IDesignerGenerator generator):base (openedFile) { if (openedFile == null) { throw new ArgumentNullException("opendFile"); } if (generator == null) { throw new ArgumentNullException("generator"); } Console.WriteLine("ReportDesignerView"); this.generator = generator; this.generator.Attach(this); base.TabPageText = ResourceService.GetString("SharpReport.Design"); ReportingSideTabProvider.AddViewContent(this); }
public IViewContent CreateContentForFile(OpenedFile file) { if (file.IsDirty) { var cmd = new ReportWizardCommand(file); cmd.Run(); if (cmd.Canceled) { return null; } file.SetData(cmd.GeneratedReport.ToArray()); } var viewCmd = new CreateDesignViewCommand(file); viewCmd.Run(); return viewCmd.DesignerView; }
public override void Load(OpenedFile file, Stream stream) { try { editor.ShowFile(new IconFile(stream)); } catch (InvalidIconException ex) { // call with a delay to work around a re-entrancy bug // when closing a workbench window while it is getting activated SD.MainThread.InvokeAsyncAndForget(delegate { MessageService.ShowHandledException(ex); if (WorkbenchWindow != null) { WorkbenchWindow.CloseWindow(true); } }); } }
public IViewContent CreateContentForFile(OpenedFile file) { ChooseEncodingDialog dlg = new ChooseEncodingDialog(); dlg.Owner = SD.Workbench.MainWindow; using (Stream stream = file.OpenRead()) { using (StreamReader reader = FileReader.OpenStream(stream, SD.FileService.DefaultFileEncoding)) { reader.Peek(); // force reader to auto-detect encoding dlg.Encoding = reader.CurrentEncoding; } } if (dlg.ShowDialog() == true) { return new AvalonEditViewContent(file, dlg.Encoding); } else { return null; } }
public static MyTypeFinder Create(OpenedFile file) { MyTypeFinder f = new MyTypeFinder(); f.file = file; f.ImportFrom(CreateWpfTypeFinder()); var compilation = SD.ParserService.GetCompilationForFile(file.FileName); foreach (var referencedAssembly in compilation.ReferencedAssemblies) { try { var assembly = Assembly.LoadFrom(referencedAssembly.GetReferenceAssemblyLocation()); f.RegisterAssembly(assembly); } catch (Exception ex) { ICSharpCode.Core.LoggingService.Warn("Error loading Assembly : " + referencedAssembly.FullAssemblyName, ex); } } return f; }
/// <summary> /// Creates a new WpfViewer object /// </summary> public WpfViewer(OpenedFile file, ProfilingDataSQLiteProvider provider) { // HACK : OpenedFile architecture does not allow to keep files open // but it is necessary for the ProfilerView to keep the session file open. // We don't want to load all session data into memory. // this.Files.Add(file); this.file = file; this.provider = provider; this.TabPageText = Path.GetFileName(file.FileName); this.TitleName = this.TabPageText; dataView = new ProfilerView(this.provider); // HACK : The file is not recognised by the FileService for closing if it is deleted while open. // (reason see above comment) FileService.FileRemoving += FileServiceFileRemoving; }
/// <summary> /// Retrieves additional data for a XML file. /// </summary> /// <param name="file">The file to retrieve the data for.</param> /// <returns>null if the file is not a valid XML file, otherwise a XmlView instance with additional data used by the XML editor.</returns> public static XmlView ForFile(OpenedFile file) { if (file == null) { return null; } if (!XmlDisplayBinding.IsFileNameHandled(file.FileName)) { return null; } XmlView instance; if (!mapping.TryGetValue(file, out instance)) { file.FileClosed += new EventHandler(FileClosedHandler); instance = new XmlView() { File = file }; mapping.Add(file, instance); } return instance; }
void TryOpenAppConfig(bool createIfNotExists) { if (appConfigFile != null) // already open return; if (ProjectService.OpenSolution == null) return; IProject p = SD.ProjectService.FindProjectContainingFile(this.PrimaryFileName); if (p == null) return; FileName appConfigFileName = CompilableProject.GetAppConfigFile(p, createIfNotExists); if (appConfigFileName != null) { appConfigFile = SD.FileService.GetOrCreateOpenedFile(appConfigFileName); this.Files.Add(appConfigFile); if (createIfNotExists) appConfigFile.MakeDirty(); appConfigFile.ForceInitializeView(this); } }
public virtual IViewContent CreateContentForFile(OpenedFile file) { TextEditorDisplayBindingWrapper b2 = CreateWrapper(file); file.ForceInitializeView(b2); // load file to initialize folding etc. b2.textEditorControl.Dock = DockStyle.Fill; try { b2.textEditorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategyForFile(file.FileName); b2.textEditorControl.InitializeAdvancedHighlighter(); } catch (HighlightingDefinitionInvalidException ex) { b2.textEditorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy(); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } b2.textEditorControl.InitializeFormatter(); b2.textEditorControl.ActivateQuickClassBrowserOnDemand(); return b2; }
public IViewContent CreateContentForFile(OpenedFile file) { return(new ResourceEditWrapper(file)); }
/// <summary> /// Executes an action before switching from this view content to the new view content. /// </summary> public virtual void SwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) { }
/// <summary> /// Gets switching without a Save/Load cycle for <paramref name="file"/> is supported /// when switching from this view content to <paramref name="newView"/>. /// </summary> public virtual bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) { return(newView == this); }
public IEnumerable <OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile) { designerCodeFile = viewContent.PrimaryFile; return(new [] { designerCodeFile }); }
public IDocument GetDocumentForFile(OpenedFile file) { throw new NotImplementedException(); }
public virtual void Save(OpenedFile file, Stream stream) { }
public System.Collections.Generic.IEnumerable <OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile) { throw new NotImplementedException(); }
public IconViewContent(OpenedFile file) : base(file) { editor.IconWasEdited += editor_IconWasEdited; }
public override void Save(OpenedFile file, Stream stream) { editor.SaveIcon(stream); }
void IViewContent.SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { throw new NotImplementedException(); }
bool IViewContent.SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { return(false); }
public virtual void Load(OpenedFile file, Stream stream) { }
public override void Save(OpenedFile file, Stream stream) { }
public virtual ICSharpCode.SharpDevelop.Editor.IDocument GetDocumentForFile(OpenedFile file) { return(null); }
public static DockContent GetContentByFile(this DockPanel dockPanel, OpenedFile file) { return(GetContent(dockPanel, x => x.Tag is LiteDocumentContent && (x.Tag as LiteDocumentContent).AssociatedFile.FilePath == file.FilePath)); }
/// <summary> /// Is called when the file name of a file opened in this view content changes. /// </summary> protected virtual void OnFileNameChanged(OpenedFile file) { }
public IReadOnlyList <OpenedFile> GetSourceFiles(FormsDesignerViewContent viewContent, out OpenedFile designerCodeFile) { // get new initialize components var parsedFile = SD.ParserService.ParseFile(viewContent.PrimaryFileName, viewContent.PrimaryFileContent); var compilation = SD.ParserService.GetCompilationForFile(viewContent.PrimaryFileName); foreach (var utd in parsedFile.TopLevelTypeDefinitions) { var td = utd.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly)).GetDefinition(); if (FormsDesignerSecondaryDisplayBinding.IsDesignable(td)) { var initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(td); if (initializeComponents != null) { string designerFileName = initializeComponents.Region.FileName; if (designerFileName != null) { designerCodeFile = SD.FileService.GetOrCreateOpenedFile(designerFileName); return(td.Parts .Select(p => SD.FileService.GetOrCreateOpenedFile(p.UnresolvedFile.FileName)) .Distinct().ToList()); } } } } throw new FormsDesignerLoadException("Could not find InitializeComponent method in any part of the open class."); }
public IViewContent CreateContentForFile(OpenedFile file) { return(new AvalonEditViewContent(file)); }
/// <summary> /// Executes an action before switching from the old view content to this view content. /// </summary> public virtual void SwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { }
public IconViewContent(OpenedFile file) : base(file) { }
/// <summary> /// Gets switching without a Save/Load cycle for <paramref name="file"/> is supported /// when switching from <paramref name="oldView"/> to this view content. /// </summary> public virtual bool SupportsSwitchToThisWithoutSaveLoad(OpenedFile file, IViewContent oldView) { return(oldView == this); }
public override void Load(OpenedFile file, Stream stream) { editor.ShowFile(new IconFile(stream)); }
protected override void SaveInternal(OpenedFile file, Stream stream) { resourceEditor.ResourceList.SaveFile(file.FileName, stream); }
public IViewContent CreateContentForFile(OpenedFile file) { return(new IconViewContent(file)); }
public void Save(OpenedFile file, Stream stream) { resourceByFile[file].Save(stream, this); }
public IViewContent CreateContentForFile(OpenedFile file) { ImageViewContent vc = new ImageViewContent(file); return(vc); }
public void Load(OpenedFile file, Stream stream) { resourceByFile[file].Load(stream); }
/// <summary> /// This constructor allows running in unit test mode with a mock file. Get it from Matt Ward /// </summary> public ReportDesignerView(IViewContent primaryViewContent, OpenedFile mockFile) // : this(primaryViewContent) { // this.sourceCodeStorage.AddFile(mockFile, Encoding.UTF8); // this.sourceCodeStorage.DesignerCodeFile = mockFile; }
public override bool SupportsSwitchFromThisWithoutSaveLoad(OpenedFile file, IViewContent newView) { return(false); }
public override void Load(OpenedFile file, Stream stream) { }