Example #1
0
		/// <summary>
		/// Constructor
		/// </summary>
		public TileControl(Tile tile, Rectangle parentRectangle, int parentImageBoxInsetWidth)
		{
			_tile = tile;
			_tileController = new TileController(_tile, (_tile.ImageViewer as ImageViewerComponent).ShortcutManager);
			_inputTranslator = new TileInputTranslator(this);

			SetParentImageBoxRectangle(parentRectangle, parentImageBoxInsetWidth, true);
			InitializeComponent();

			this.BackColor = Color.Black;
			this.Dock = DockStyle.None;
			this.Anchor = AnchorStyles.None;
			this.AllowDrop = true;

			_tile.Drawing += new EventHandler(OnTileDrawing);
			_tile.RendererChanged += new EventHandler(OnRendererChanged);
			_tile.InformationBoxChanged += new EventHandler<InformationBoxChangedEventArgs>(OnInformationBoxChanged);
			_tile.EditBoxChanged += new EventHandler(OnEditBoxChanged);
			_tile.SelectionChanged += new EventHandler<ItemEventArgs<ITile>>(OnTileSelectionChanged);

			_contextMenuStrip.ImageScalingSize = new Size(24, 24);
			_contextMenuStrip.Opening += new CancelEventHandler(OnContextMenuStripOpening);

			_tileController.CursorTokenChanged += new EventHandler(OnCursorTokenChanged);
			_tileController.ContextMenuRequested += new EventHandler<ItemEventArgs<Point>>(OnContextMenuRequested);
			_tileController.CaptureChanging += new EventHandler<ItemEventArgs<IMouseButtonHandler>>(OnCaptureChanging);

			_editBoxControl = new EditBoxControl();
			this.Controls.Add(_editBoxControl);

			this.DoubleBuffered = false;
			this.SetStyle(ControlStyles.DoubleBuffer, false);
			this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
			this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
		}
Example #2
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);
			}
Example #3
0
			public IMouseWheelHandler GetCaptureHandler(TileController tileController)
			{
				if (_captureTileController == tileController)
					return _captureMouseWheelHandler;

				return null;
			}