Beispiel #1
0
		public TableView()
        {
			SuppressSelectionChangedEvent = false;
			InitializeComponent();

            // if we allow the framework to generate columns, there seems to be a bug with 
            // setting the minimum column width > 100 pixels
            // therefore, turn off the auto-generate and create the columns ourselves
            _dataGridView.AutoGenerateColumns = false;

            _rowHeight = this.DataGridView.RowTemplate.Height;
            this.DataGridView.RowPrePaint += SetCustomBackground;
            this.DataGridView.RowPostPaint += DisplayCellSubRows;
            this.DataGridView.RowPostPaint += OutlineCell;
            this.DataGridView.RowPostPaint += SetLinkColor;

			// System.Component.DesignMode does not work in control constructors
			if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
			{
				// Use a DelayedEventPublisher to make fixes for bugs 386 and 8032 a little clearer.  Previously used a Timer directly
				// to delay the events
				_delayedSelectionChangedPublisher = new DelayedEventPublisher((sender, args) => NotifySelectionChanged(), 50);
			}

			try
			{
				var resolver = new ResourceResolver(typeof (TableView), false);
				using (var s = resolver.OpenResource("checkmark.png"))
				{
					_checkmarkBitmap = new Bitmap(s);
				}
			}
			catch (Exception) {}
        }
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_parentForm != null)
				{
					_parentForm.Move -= OnParentMoved;
					_parentForm = null;
				}

				if (_component != null)
				{
					_component.Closing -= OnComponentClosing;
					_component = null;
				}

				if (_delayedEventPublisher != null)
				{
					_delayedEventPublisher.Dispose();
					_delayedEventPublisher = null;
				}

				if (_physicalWorkspace != null)
				{
					_physicalWorkspace.Drawing -= OnPhysicalWorkspaceDrawing;
					_physicalWorkspace.LayoutCompleted -= OnLayoutCompleted;
					_physicalWorkspace.ScreenRectangleChanged -= OnScreenRectangleChanged;

					_physicalWorkspace = null;
				}
			}

			base.Dispose(disposing);
		}
		public override void Initialize()
		{
			base.Initialize();

			ImageViewer.EventBroker.ImageDrawing += OnImageDrawing;
			ImageViewer.EventBroker.DisplaySetChanged += OnDisplaySetChanged;

			_publisher = new DelayedEventPublisher((o, args) => UpdateFusion((IPresentationImage)o));
			_synchronizationContext = SynchronizationContext.Current;
		}
		protected override void Dispose(bool disposing)
		{
			_synchronizationContext = null;

			if (_publisher != null)
			{
				_publisher.Dispose();
				_publisher = null;
			}

			ImageViewer.EventBroker.DisplaySetChanged -= OnDisplaySetChanged;
			ImageViewer.EventBroker.ImageDrawing -= OnImageDrawing;

			base.Dispose(disposing);
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				var asyncFrame = Frame;
				asyncFrame.AsyncProgressChanged -= OnAsyncProgressChanged;

				if (_delayedEventPublisher != null)
				{
					_delayedEventPublisher.Dispose();
					_delayedEventPublisher = null;
				}
			}
			base.Dispose(disposing);
		}
		internal ImageViewerControl(ImageViewerComponent component)
		{
			_component = component;
			_physicalWorkspace = _component.PhysicalWorkspace as PhysicalWorkspace;
			InitializeComponent();

			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);

			this.BackColor = Color.Black;

			_component.Closing += new EventHandler(OnComponentClosing);
			_physicalWorkspace.Drawing += new EventHandler(OnPhysicalWorkspaceDrawing);
			_physicalWorkspace.LayoutCompleted += new EventHandler(OnLayoutCompleted);
			_physicalWorkspace.ScreenRectangleChanged += new EventHandler(OnScreenRectangleChanged);

			_delayedEventPublisher = new DelayedEventPublisher(OnRecalculateImageBoxes, 50);
		}
		internal ImageViewerControl(ImageViewerComponent component)
		{
			_component = component;
			_physicalWorkspace = (PhysicalWorkspace) _component.PhysicalWorkspace;

			SuspendLayout();
			Name = "ImageViewerControl";
			ResumeLayout(false);
			SetStyle(ControlStyles.AllPaintingInWmPaint, true);

			base.BackColor = Color.Black;

			_component.Closing += OnComponentClosing;
			_physicalWorkspace.Drawing += OnPhysicalWorkspaceDrawing;
			_physicalWorkspace.LayoutCompleted += OnLayoutCompleted;
			_physicalWorkspace.ScreenRectangleChanged += OnScreenRectangleChanged;

			_delayedEventPublisher = new DelayedEventPublisher(OnRecalculateImageBoxes, 50);
		}
Beispiel #8
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public TileController(Tile tile, IViewerShortcutManager shortcutManager)
		{
			Platform.CheckForNullReference(tile, "tile");
			Platform.CheckForNullReference(shortcutManager, "shortcutManager");

			_tile = tile;
            _tile.ContextMenuRequested += ProcessExplicitContextMenuRequest;

            _selectedOnThisClick = false;
			_capturedOnThisClick = false;
			_shortcutManager = shortcutManager;
			_delayedContextMenuRequestPublisher = new DelayedEventPublisher(ProcessDelayedContextMenuRequest, InputManagementSettings.Default.ContextMenuDelay);
		}
Beispiel #9
0
			public void SetCaptureHandler(TileController tileController, IMouseWheelHandler captureMouseWheelHandler)
			{
                if (_captureTileController == tileController && _captureMouseWheelHandler == captureMouseWheelHandler)
					return;

				if (_captureMouseWheelHandler != null)
				{
                    if (_delayedStop != null)
                    {
                        _delayedStop.Dispose();
                        _delayedStop = null;
                    }

                    EventsHelper.Fire(tileController._wheelCaptureChangingEvent, tileController, new ItemEventArgs<IMouseWheelHandler>(null));
                    _captureMouseWheelHandler.StopWheel();
                    _captureTileController._tile.ImageViewer.EventBroker.OnMouseWheelCaptureChanged(new MouseWheelCaptureChangedEventArgs(_captureTileController._tile, false));
				}

			    _captureTileController = tileController;
				_captureMouseWheelHandler = captureMouseWheelHandler;
                
				if (_captureMouseWheelHandler == null)
				{
                    if (_delayedStop != null)
                    {
                        _delayedStop.Dispose();
                        _delayedStop = null;
                    }
                    return;
				}

                _delayedStop = new DelayedEventPublisher((s, e) => SetCaptureHandler(tileController, null), WheelStopDelayMilliseconds);

                EventsHelper.Fire(tileController._wheelCaptureChangingEvent, tileController, new ItemEventArgs<IMouseWheelHandler>(_captureMouseWheelHandler));
                _captureMouseWheelHandler.StartWheel();
                _captureTileController._tile.ImageViewer.EventBroker.OnMouseWheelCaptureChanged(new MouseWheelCaptureChangedEventArgs(_captureTileController._tile, true));

                _delayedStop.Publish(this, EventArgs.Empty);
			}
		public Win32VtkRenderingSurface(IntPtr windowId, bool offscreen)
		{
			_imageBuffer = new BitmapBuffer(PixelFormat.Format32bppRgb);
			_overlayBuffer = new BitmapBuffer(PixelFormat.Format32bppArgb);
			_finalBuffer = new BackBuffer();

			_vtkRenderer = new vtkRenderer();
			_vtkRenderer.SetBackground(0.0f, 0.0f, 0.0f);

			_vtkRenderWindow = new vtkWin32OpenGLRenderWindow();
			_vtkRenderWindow.OffScreenRenderingOn();
			_vtkRenderWindow.DoubleBufferOff();
			_vtkRenderWindow.EraseOn();
			_vtkRenderWindow.SwapBuffersOff();
			_vtkRenderWindow.SetDesiredUpdateRate(_dynamicFrameRate);
			_vtkRenderWindow.AddRenderer(_vtkRenderer);

			var delayTime = Math.Min(10000, Math.Max(100, Settings.Default.RendererRefinementDelayMs));
			_dynamicFrameRate = Math.Min(1000, Math.Max(1, Settings.Default.RendererDynamicFps));
			_dynamicRenderEventPublisher = !offscreen ? new DelayedEventPublisher((s, e) => Render(true, null), delayTime) : null;

			WindowID = windowId;
		}
		protected virtual void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_dynamicRenderEventPublisher != null)
				{
					_dynamicRenderEventPublisher.Cancel();
					_dynamicRenderEventPublisher.Dispose();
					_dynamicRenderEventPublisher = null;
				}

				if (_vtkRenderWindow != null)
				{
					_vtkRenderWindow.Dispose();
					_vtkRenderWindow = null;
				}

				if (_vtkRenderer != null)
				{
					_vtkRenderer.Dispose();
					_vtkRenderer = null;
				}

				if (_sceneGraphRoot != null)
				{
					_sceneGraphRoot.Dispose();
					_sceneGraphRoot = null;
				}

				if (_imageBuffer != null)
				{
					_imageBuffer.Dispose();
					_imageBuffer = null;
				}

				if (_overlayBuffer != null)
				{
					_overlayBuffer.Dispose();
					_overlayBuffer = null;
				}

				if (_finalBuffer != null)
				{
					_finalBuffer.Dispose();
					_finalBuffer = null;
				}
			}
		}
		public void Dispose()
		{
            if (_delayedContextMenuRequestPublisher == null)
                return;

		    ReleaseCapture(true);
		    this.CaptureMouseWheelHandler = null;

			_delayedContextMenuRequestPublisher.Dispose();
		    _tile.ContextMenuRequested -= ProcessExplicitContextMenuRequest;

		    _delayedContextMenuRequestPublisher = null;
		}
		public override void Draw(DrawArgs drawArgs)
		{
			if (_delayedEventPublisher == null && SynchronizationContext.Current != null)
				_delayedEventPublisher = new DelayedEventPublisher(OnDelayedProgressChanged, 1000, DelayedEventPublisherTriggerMode.Periodic);

			var asyncFrame = Frame;
			using (asyncFrame.AcquireLock())
			{
				if (!asyncFrame.IsAsyncLoaded)
				{
					if (!Visible) // if this is an off-screen draw, wait for data to be loaded
					{
						lock (_waitPixelData)
						{
							if (!asyncFrame.IsAsyncLoaded)
							{
								var completionHandler = new EventHandler((s, e) =>
								                                         	{
								                                         		lock (_waitPixelData)
								                                         		{
								                                         			Monitor.Pulse(_waitPixelData);
								                                         		}
								                                         	});
								var onFrameAsyncLoaded = new AsyncPixelDataEventHandler(completionHandler);
								var onFrameAsyncFaulted = new AsyncPixelDataFaultEventHandler(completionHandler);

								asyncFrame.AsyncLoaded += onFrameAsyncLoaded;
								asyncFrame.AsyncFaulted += onFrameAsyncFaulted;
								asyncFrame.GetNormalizedPixelData();

								// check the flag again, in case the event actually fired before we hooked up the handler
								if (!asyncFrame.IsAsyncLoaded)
									Monitor.Wait(_waitPixelData);

								asyncFrame.AsyncLoaded -= onFrameAsyncLoaded;
								asyncFrame.AsyncFaulted -= onFrameAsyncFaulted;
							}
						}
					}
					else if (!ApplicationGraphics.OfType<ProgressGraphic>().Any())
					{
						ProgressGraphic.Show(this, ApplicationGraphics, true, ProgressBarGraphicStyle.Continuous, false);
					}
				}

				base.Draw(drawArgs);
			}
		}