예제 #1
0
		/// <summary>
		/// Renders the overlay (the drawing that designates selected rectangles, handles and so on) immediately in the current thread.
		/// Attention: if there is no cached bitmap, a new bitmap is created, but this must be done in the Gui context, so this can lead to deadlocks.
		/// </summary>
		private static ImageSource GetImageSourceByRenderingOverlay(GraphControllerWpf controller, GdiToWpfBitmap bmp, CachedGraphImage cachedGraphImage)
		{
			if (controller.IsOverlayPaintingRequired)
			{
				using (var grfx = GetGraphicsContextFromWpfGdiBitmap(bmp))
				{
					controller.DoPaintOverlay(grfx, cachedGraphImage.ZoomFactor, cachedGraphImage.ViewPortsUpperLeftCornerInGraphCoordinates);
					return bmp.WpfBitmapSource;
				}
			}
			else
			{
				return null;
			}
		}
예제 #2
0
		/// <summary>
		/// Restores the state of the main window from a zipped Altaxo project file.
		/// </summary>
		/// <param name="zipFile">The zip file where the state file can be found into.</param>
		/// <param name="info">The deserialization info used to retrieve the data.</param>
		/// <param name="restoredDoc">The previously (also from the zip file!) restored Altaxo document.</param>
		public void RestoreWindowStateFromZippedFile(ZipFile zipFile, Altaxo.Serialization.Xml.XmlStreamDeserializationInfo info, AltaxoDocument restoredDoc)
		{
			System.Collections.ArrayList restoredControllers = new System.Collections.ArrayList();
			foreach (ZipEntry zipEntry in zipFile)
			{
				if (!zipEntry.IsDirectory && zipEntry.Name.StartsWith("Workbench/Views/"))
				{
					System.IO.Stream zipinpstream = zipFile.GetInputStream(zipEntry);
					info.BeginReading(zipinpstream);
					object readedobject = info.GetValue("Table", null);
					if (readedobject is ICSharpCode.SharpDevelop.Gui.IViewContent)
						restoredControllers.Add(readedobject);
					else if (readedobject is GraphViewLayout)
						restoredControllers.Add(readedobject);
					else if (readedobject is Altaxo.Graph.Graph3D.GuiModels.GraphViewOptions)
						restoredControllers.Add(readedobject);
					else if (readedobject is Altaxo.Worksheet.WorksheetViewLayout)
						restoredControllers.Add(readedobject);
					info.EndReading();
				}
			}

			info.AnnounceDeserializationEnd(restoredDoc, false);
			info.AnnounceDeserializationEnd(restoredDoc, false);

			// now give all restored controllers a view and show them in the Main view

			foreach (object o in restoredControllers)
			{
				if (o is GraphViewLayout)
				{
					var ctrl = new GraphControllerWpf();
					ctrl.InitializeDocument(o as GraphViewLayout);
					Current.Gui.FindAndAttachControlTo(ctrl);
					Current.Workbench.ShowView(new Altaxo.Gui.SharpDevelop.SDGraphViewContent(ctrl));
				}
				else if (o is Altaxo.Graph.Graph3D.GuiModels.GraphViewOptions)
				{
					var so = (o as Altaxo.Graph.Graph3D.GuiModels.GraphViewOptions);
					if (so.GraphDocument != null)
					{
						var viewContent = this.OpenOrCreateViewContentForDocument(so.GraphDocument) as IMVCANController;
						if (null != viewContent)
							viewContent.InitializeDocument(so);
					}
				}
				else if (o is Altaxo.Worksheet.WorksheetViewLayout)
				{
					var wksViewLayout = (Altaxo.Worksheet.WorksheetViewLayout)o;
					if (null != wksViewLayout.WorksheetLayout && null != wksViewLayout.WorksheetLayout.DataTable)
					{
						var ctrl = new Altaxo.Gui.Worksheet.Viewing.WorksheetControllerWpf();
						ctrl.InitializeDocument(wksViewLayout);
						Current.Gui.FindAndAttachControlTo(ctrl);
						Current.Workbench.ShowView(new Altaxo.Gui.SharpDevelop.SDWorksheetViewContent(ctrl));
					}
				}
				else if (o is IViewContent)
				{
					var viewcontent = o as IViewContent;
					IMVCControllerWrapper wrapper = viewcontent as IMVCControllerWrapper;
					if (wrapper != null && wrapper.MVCController.ViewObject == null)
						Current.Gui.FindAndAttachControlTo(wrapper.MVCController);

					if (viewcontent.Control != null)
					{
						Current.Workbench.ShowView(viewcontent);
					}
				}
			}
		}