示例#1
0
        private void MouseMove(RoutedEventArgs args)
        {
            if (DisplayedImage == null)
            {
                return;
            }
            if (!_escapeClicked)
            {
                if (_isDragged)
                {
                    switch (ToolType)
                    {
                    case Tools.None:
                        break;

                    case Tools.RegionSelection:
                    {
                        RegionWidth = _mouseX - (int)_mouseClickPosition.X;
                        int x = (int)RegionLocation.Left, y = (int)RegionLocation.Top;
                        if (RegionWidth < 0)
                        {
                            RegionWidth = Math.Abs(RegionWidth);
                            x           = _mouseX;
                        }
                        RegionHeight = _mouseY - (int)_mouseClickPosition.Y;
                        if (RegionHeight < 0)
                        {
                            RegionHeight = Math.Abs(RegionHeight);
                            y            = _mouseY;
                        }
                        RegionLocation = new Thickness(x, y, 0, 0);
                        if (IsSynchronized)
                        {
                            SynchronizeRegions sr = new SynchronizeRegions();
                            sr.PresenterID  = ViewModelID;
                            sr.Position     = RegionLocation;
                            sr.Width        = RegionWidth;
                            sr.Height       = RegionHeight;
                            sr.DoProcessing = false;
                            _aggregator.GetEvent <SynchronizeRegions>().Publish(sr);
                        }
                    }
                    break;

                    case Tools.PixelInformations:
                        break;

                    case Tools.RegionTransformation:
                        break;

                    case Tools.ImagePan:
                    {
                        App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                Dictionary <String, Object> parameters = new Dictionary <string, object>();
                                parameters.Add("MouseClickPosition", _mouseClickPosition);
                                parameters.Add("MouseX", MouseX);
                                parameters.Add("MouseY", MouseY);
                                parameters.Add("MouseXDelta", _mouseXDelta);
                                parameters.Add("MouseYDelta", _mouseYDelta);
                                parameters.Add("DisplayedImage", DisplayedImage);
                                parameters.Add("Position", ImagePosition);
                                parameters.Add("PresenterID", ViewModelID);
                                parameters.Add("IsSynchronized", IsSynchronized);
                                parameters.Add("DoProcessing", false);
                                Tool.AffectImage(parameters);
                                _mouseXDelta = _mouseX - (int)_mouseClickPosition.X;
                                _mouseYDelta = _mouseY - (int)_mouseClickPosition.Y;
                                _isDragged   = true;
                            }
                                                                 ));
                    }
                    break;

                    default:
                        break;
                    }
                }
            }
        }