Exemple #1
0
		public static MyTypeFinder Create(OpenedFile file)
		{
			MyTypeFinder f = new MyTypeFinder();
			f.file = file;
			f.ImportFrom(CreateWpfTypeFinder());
			return f;
		}
		public override void Load(OpenedFile file, Stream stream)
		{
			XmlDocument doc = new XmlDocument();
			doc.Load(stream);
			projectContent = ParserService.GetProjectContent(ProjectService.CurrentProject);
			canvas.LoadFromXml(doc, projectContent);
		}
		public WpfViewContent(OpenedFile file) : base(file)
		{
			BasicMetadata.Register();
			
			this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}";
			this.IsActiveViewContentChanged += OnIsActiveViewContentChanged;
		}
		public ResourceEditWrapper(OpenedFile file)
		{
			this.TabPageText = "Resource editor";
			base.UserControl = resourceEditor;
			resourceEditor.ResourceList.Changed += new EventHandler(SetDirty);
			this.Files.Add(file);
		}
		public IViewContent CreateContentForFile(OpenedFile file)
		{
			var codons = DisplayBindingService.GetCodonsPerFileName(file.FileName);
			DisplayBindingDescriptor bestMatch = null;
			double max = double.NegativeInfinity;
			const int BUFFER_LENGTH = 4 * 1024;
			
			using (var stream = file.OpenRead()) {
				string mime = "text/plain";
				if (stream.Length > 0) {
					stream.Position = 0;
					mime = MimeTypeDetection.FindMimeType(new BinaryReader(stream).ReadBytes(BUFFER_LENGTH));
				}
				foreach (var codon in codons) {
					stream.Position = 0;
					double value = codon.Binding.AutoDetectFileContent(file.FileName, stream, mime);
					if (value > max) {
						max = value;
						bestMatch = codon;
					}
				}
			}
			
			if (bestMatch == null)
				throw new InvalidOperationException();
			
			return bestMatch.Binding.CreateContentForFile(file);
		}
		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)) {
					TextEditorControl editor = ((ITextEditorControlProvider)this.PrimaryViewContent).TextEditorControl;
					this.SourceCodeStorage.AddFile(file, editor.Document, editor.Encoding ?? ParserService.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 TagListViewContent(OpenedFile file)
		{
			Files.Add(file);
			OnFileNameChanged(file);
			file.ForceInitializeView(this);
			TabPageText = "Design";
		}
		public IEnumerable<OpenedFile> GetSourceFiles(out OpenedFile designerCodeFile)
		{
			// get new initialize components
			ParseInformation info = ParserService.ParseFile(this.viewContent.PrimaryFileName, this.viewContent.PrimaryFileContent);
			ICompilationUnit cu = info.CompilationUnit;
			foreach (IClass c in cu.Classes) {
				if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
					this.currentClassPart = c;
					this.initializeComponents = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
					if (this.initializeComponents != null) {
						string designerFileName = this.initializeComponents.DeclaringType.CompilationUnit.FileName;
						if (designerFileName != null) {
							
							designerCodeFile = FileService.GetOrCreateOpenedFile(designerFileName);
							
							CompoundClass compound = c.GetCompoundClass() as CompoundClass;
							if (compound == null) {
								return new [] {designerCodeFile};
							} else {
								return compound.Parts
									.Select(cl => FileService.GetOrCreateOpenedFile(cl.CompilationUnit.FileName))
									.Distinct();
							}
							
						}
					}
				}
			}
			
			throw new FormsDesignerLoadException("Could not find InitializeComponent method in any part of the open class.");
		}
Exemple #9
0
		public static MyTypeFinder Create(OpenedFile file)
		{
			MyTypeFinder f = new MyTypeFinder();
			f.file = file;
			f.ImportFrom(CreateWpfTypeFinder());
			
			var pc = MyTypeFinder.GetProjectContent(file);
			foreach (var referencedProjectContent in pc.ThreadSafeGetReferencedContents()) {
				string fileName = null;
				try{
					if (referencedProjectContent is ParseProjectContent)
					{
						var prj = ((ParseProjectContent)referencedProjectContent).Project as AbstractProject;
						if (prj != null)
							fileName = prj.OutputAssemblyFullPath;
					}
					else if (referencedProjectContent is ReflectionProjectContent)
					{
						fileName = ((ReflectionProjectContent) referencedProjectContent).AssemblyLocation;
					}
					var assembly = Assembly.LoadFrom(fileName);
					f.RegisterAssembly(assembly);
				}
				catch (Exception ex) {
					ICSharpCode.Core.LoggingService.Warn("Error loading Assembly : "+ (fileName ?? ""), ex);
				}
			}
			return f;
		}
Exemple #10
0
		public override void Save(OpenedFile file, Stream stream)
		{
			AnalyticsMonitorService.TrackFeature(typeof(HexEditView), "Save");
			this.hexEditContainer.SaveFile(file, stream);
			this.TitleName = Path.GetFileName(file.FileName);
			this.TabPageText = this.TitleName;
		}
		void AssertAreEqual(OpenedFile expectedOpenedFile, OpenedFile actualOpenedFile)
		{	
			string fileName = actualOpenedFile.FileName.ToString();
			string expectedFileName = expectedOpenedFile.FileName.ToString();
			
			Assert.AreEqual(expectedFileName, fileName);
		}
		public override void Load(OpenedFile file, Stream stream)
		{
			_file = file;
			TitleName = Path.GetFileName(file.FileName);
			
			_control.Load(stream);
			_control.DataChanged += new EventHandler(DataChanged);
		}
		public AppConfigViewContent(OpenedFile file)
		{
			TabPageText = "Design";

			Files.Add(file);
			OnFileNameChanged(file);
			file.ForceInitializeView(this);
		}
		public IViewContent CreateContentForFile(OpenedFile file)
		{
			try {
				return new EDMDesignerViewContent(file);
			} catch (WizardCancelledException) {
				return null;
			}
		}
		public static ReportDesignerView SetupDesigner (OpenedFile file)
		{
			if (file == null) {
				throw new ArgumentNullException("file");
			}
			IDesignerGenerator generator = new ReportDesignerGenerator();
			return new ReportDesignerView(file, generator);
		}
Exemple #16
0
 /// <summary>
 /// Default ctor
 /// </summary>
 internal XmlEditorView(OpenedFile file, XmlViewModel viewModel, IDesignerControl control)
 {
     this.viewModel = viewModel;
     this.control = control;
     Files.Add(file);
     file.ForceInitializeView(this);
     ComponentDispatcher.ThreadIdle += OnIdle;
 }
		public HexEditView(OpenedFile file)
		{
			hexEditContainer = new HexEditContainer();
			hexEditContainer.hexEditControl.DocumentChanged += new EventHandler(DocumentChanged);
			
			this.Files.Add(file);
			
			file.ForceInitializeView(this);
		}
Exemple #18
0
		public Editor(OpenedFile file)
		{			
			Files.Add(file);
			OnFileNameChanged(file);
			file.ForceInitializeView(this);

			rtb.Dock = DockStyle.Fill;
			rtb.TextChanged += TextChanged;			
		}
		public SettingsViewContent(OpenedFile file) : base(file)
		{
			view.SelectionChanged += delegate {
				propertyContainer.SelectedObjects = view.GetSelectedEntriesForPropertyGrid().ToArray();
			};
			view.SettingsChanged += delegate {
				this.PrimaryFile.MakeDirty();
			};
		}
		public override void Load(OpenedFile file, Stream stream)
		{
			_file = file;
			_control.Load(stream);
			TitleName = Path.GetFileName(file.FileName);

			BindingSource bs = _control.dataGridViewTags.DataSource as BindingSource;
			bs.ListChanged += _control_dataGridViewTags_CurrentCellDirtyStateChanged;
		}
		public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(OpenedFile file)
		{
			try {
				return new WpfViewer(file);
			} catch (IncompatibleDatabaseException e) {
				MessageService.ShowErrorFormatted("${res:AddIns.Profiler.DatabaseTooNewError}", e.ActualVersion.ToString(), e.ExpectedVersion.ToString());
				return null;
			}
		}
        public EDMDesignerViewContent(OpenedFile primaryFile)
            : base(primaryFile)
		{           
            if (primaryFile == null)
				throw new ArgumentNullException("primaryFile");
			
			primaryFile.ForceInitializeView(this); // call Load()

            EDMDesignerChangeWatcher.AddEDMDesignerViewContent(this);
        }
Exemple #23
0
        public XmlView(OpenedFile file)
            : this()
        {
            this.Files.Add(file);
            OnFileNameChanged(file);
            file.ForceInitializeView(this);

            xmlTreeView = new XmlTreeView(this);
            SecondaryViewContents.Add(xmlTreeView);
        }
		public DriverViewContent(OpenedFile file)
		{			
			_control = new DriverUserControl(this);
			
			Files.Add(file);
			OnFileNameChanged(file);
			file.ForceInitializeView(this);
			
			TabPageText = "Design";
		}
Exemple #25
0
		internal static IProjectContent GetProjectContent(OpenedFile file)
		{
			if (ProjectService.OpenSolution != null && file != null) {
				IProject p = ProjectService.OpenSolution.FindProjectContainingFile(file.FileName);
				if (p != null) {
					return ParserService.GetProjectContent(p);
				}
			}
			return ParserService.DefaultProjectContent;
		}
		public FileChangeWatcher(OpenedFile file)
		{
			if (file == null)
				throw new ArgumentNullException("file");
			this.file = file;
			WorkbenchSingleton.MainWindow.Activated += MainForm_Activated;
			file.FileNameChanged += file_FileNameChanged;
			activeWatchers.Add(this);
			SetWatcher();
		}
		public override void Save(OpenedFile file, Stream stream)
		{
			XmlWriterSettings settings = new XmlWriterSettings();
			settings.Indent = true;
			settings.Encoding = System.Text.Encoding.UTF8;
			
			XmlWriter xw = XmlWriter.Create(stream, settings);
			canvas.WriteToXml().WriteTo(xw);
			xw.Close();
		}
		/// <summary>
		/// The load method takes a copy of the image and saves the
		/// image format so the image can be saved later without throwing
		/// a GDI+ exception. This is because the stream is disposed during
		/// the lifetime of the image:
		/// 
		/// http://support.microsoft.com/?id=814675
		/// </summary>
		public override void Load(OpenedFile file, Stream stream)
		{
			Image image = Image.FromStream(stream);
			format = image.RawFormat;
			
			box.SizeMode = PictureBoxSizeMode.Zoom;
			box.Image = new Bitmap(image.Width, image.Height);
			using (Graphics graphics = Graphics.FromImage(box.Image)) {
				graphics.DrawImage(image, 0, 0);
			}
		}
Exemple #29
0
		public HexEditView(OpenedFile file)
		{
			hexEditContainer = new HexEditContainer();
			hexEditContainer.hexEditControl.DocumentChanged += new EventHandler(DocumentChanged);
			
			this.Files.Add(file);
			
			file.ForceInitializeView(this);
			
			AnalyticsMonitorService.TrackFeature(typeof(HexEditView));
		}
		public override void Load(OpenedFile file, Stream stream)
		{
			if (file == PrimaryFile) {
				InitializeDesigner();
				using (StreamReader r = new StreamReader(stream)) {
					designer.Context.Items.SetValue(new WorkflowFileItem() { LoadedFile = file.FileName });
					designer.Text = r.ReadToEnd();
					designer.Load();
				}
			}
		}