예제 #1
0
        protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            //2012.10.01: massimo.guerrera - Added for the click through on the dependency viewer
            if (e.ClickCount == 2)
            {
                ReleaseMouseCapture();
                FrameworkElement        fe  = e.OriginalSource as FrameworkElement;
                FrameworkContentElement fce = e.OriginalSource as FrameworkContentElement;
                object dataContext          = null;

                if (fe != null)
                {
                    dataContext = fe.DataContext;
                }
                else if (fce != null)
                {
                    dataContext = fce.DataContext;
                }

                string resourceName = dataContext as string;

                if (string.IsNullOrEmpty(resourceName) && dataContext is Node)
                {
                    resourceName = (dataContext as Node).ID;
                }

                if (!string.IsNullOrEmpty(resourceName))
                {
                    var vm = DataContext as DependencyVisualiserViewModel;
                    if (vm != null)
                    {
                        IResourceModel resource = vm.ResourceModel.Environment
                                                  .ResourceRepository.FindSingle(
                            c => c.ResourceName == resourceName);
                        if (resource != null)
                        {
                            WorkflowDesignerUtils.EditResource(resource, _eventPublisher);
                        }
                    }
                }
            }

            e.GetPosition(this);
            _scrollStartOffset.X = myScrollViewer.HorizontalOffset;
            _scrollStartOffset.Y = myScrollViewer.VerticalOffset;

            // Update the cursor if scrolling is possible
            Cursor = (myScrollViewer.ExtentWidth > myScrollViewer.ViewportWidth) ||
                     (myScrollViewer.ExtentHeight > myScrollViewer.ViewportHeight) ?
                     Cursors.ScrollAll : Cursors.Arrow;

            CaptureMouse();
            base.OnPreviewMouseDown(e);
        }
예제 #2
0
        public void EditResource_UnitTest_EditResourceWhereNullEventAggregator_ExpectException()
        {
            //------------Setup for test--------------------------
            var mockResourceModel = new Mock <IResourceModel>();

            mockResourceModel.Setup(model => model.ResourceType).Returns(ResourceType.Service);
            var eventAggregator = new EventAggregator();
            var handleMessages  = new TestHandleMessages();

            eventAggregator.Subscribe(handleMessages);
            //------------Execute Test---------------------------
            WorkflowDesignerUtils.EditResource(mockResourceModel.Object, null);
            //------------Assert Results-------------------------
        }
예제 #3
0
        public void EditResource_UnitTest_EditResourceWhereWorkflow_ExpectAddWorksurfaceMessageHandled()
        {
            //------------Setup for test--------------------------
            var mockResourceModel = new Mock <IResourceModel>();

            mockResourceModel.Setup(model => model.ResourceType).Returns(ResourceType.WorkflowService);
            var eventAggregator = new EventAggregator();
            var handleMessages  = new TestHandleMessages();

            eventAggregator.Subscribe(handleMessages);
            //------------Execute Test---------------------------
            WorkflowDesignerUtils.EditResource(mockResourceModel.Object, eventAggregator);
            //------------Assert Results-------------------------
            Assert.IsTrue(handleMessages.WorkSurfaceMessageCalled);
            Assert.IsFalse(handleMessages.EditResourceMessageCalled);
        }