public SearchToolTipAdorner(UIElement adornedElement, DesignerView designerView, string text)
     : base(adornedElement)
 {
     this.scrollViewerToScreenDistance = designerView.ScrollViewer.PointToScreen(new Point(0, 0)).Y;;
     tooltip = new Border
     {
         Background = new SolidColorBrush(WorkflowDesignerColors.DesignerViewBackgroundColor),
         BorderBrush = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementBorderColor),
         BorderThickness = new Thickness(1),
         CornerRadius = new CornerRadius(4),
         Margin = new Thickness(10),
         Child = new TextBlock
         {
             Foreground = new SolidColorBrush(WorkflowDesignerColors.WorkflowViewElementCaptionColor),
             Margin = new Thickness(4, 0, 4, 0),
             MaxWidth = 300,
             Text = text,
             TextWrapping = TextWrapping.Wrap,
             TextTrimming = TextTrimming.CharacterEllipsis
         },
         Effect = new DropShadowEffect
         {
             Color = Colors.Black,
             BlurRadius = 4,
             Opacity = 0.5
         },
     };
     tooltip.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
 }
        public override void Initialize(EditingContext context)
        {
            this.context = context;
            AttachedPropertiesService propertiesService = this.context.Services.GetService<AttachedPropertiesService>();
            helpService = this.context.Services.GetService<IIntegratedHelpService>();

            oldSelection = this.context.Items.GetValue<Selection>();
            isPrimarySelectionProperty = new AttachedProperty<bool>()
                {
                    Getter = (modelItem) => (this.context.Items.GetValue<Selection>().PrimarySelection == modelItem),
                    Name = "IsPrimarySelection",
                    OwnerType = typeof(Object)
                };

            isSelectionProperty = new AttachedProperty<bool>()
            {
                Getter = (modelItem) => (((IList)this.context.Items.GetValue<Selection>().SelectedObjects).Contains(modelItem)),
                Name = "IsSelection",
                OwnerType = typeof(Object)
            };


            propertiesService.AddProperty(isPrimarySelectionProperty);
            propertiesService.AddProperty(isSelectionProperty);
            



            if (this.context.Services.GetService<ViewService>() == null)
            {
                view = new System.Activities.Presentation.View.DesignerView(this.context);
                WorkflowViewService viewService = new WorkflowViewService(context);
                WorkflowViewStateService viewStateService = new WorkflowViewStateService(context);
                this.context.Services.Publish<ViewService>(viewService);
                this.context.Services.Publish<VirtualizedContainerService>(new VirtualizedContainerService(this.context));
                this.context.Services.Publish<ViewStateService>(viewStateService);
                this.context.Services.Publish<DesignerView>(view);

                WorkflowAnnotationAdornerService annotationService = new WorkflowAnnotationAdornerService();
                annotationService.Initialize(this.context, view.scrollViewer);
                this.context.Services.Publish<AnnotationAdornerService>(annotationService);

                this.context.Services.Subscribe<ModelService>(delegate(ModelService modelService)
                {
                    this.modelService = modelService;
                    if (modelService.Root != null)
                    {
                        view.MakeRootDesigner(modelService.Root);
                    }
                    view.RestoreDesignerStates();
                    this.context.Items.Subscribe<Selection>(new SubscribeContextCallback<Selection>(OnItemSelected));
                });
            }

            if (helpService != null)
            {
                helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword); 
            }
        }
Exemple #3
0
        public override void Initialize(EditingContext context)
        {
            this.context = context;
            AttachedPropertiesService propertiesService = this.context.Services.GetService <AttachedPropertiesService>();

            helpService = this.context.Services.GetService <IIntegratedHelpService>();

            oldSelection = this.context.Items.GetValue <Selection>();
            isPrimarySelectionProperty = new AttachedProperty <bool>()
            {
                Getter    = (modelItem) => (this.context.Items.GetValue <Selection>().PrimarySelection == modelItem),
                Name      = "IsPrimarySelection",
                OwnerType = typeof(Object)
            };

            isSelectionProperty = new AttachedProperty <bool>()
            {
                Getter    = (modelItem) => (((IList)this.context.Items.GetValue <Selection>().SelectedObjects).Contains(modelItem)),
                Name      = "IsSelection",
                OwnerType = typeof(Object)
            };


            propertiesService.AddProperty(isPrimarySelectionProperty);
            propertiesService.AddProperty(isSelectionProperty);



            if (this.context.Services.GetService <ViewService>() == null)
            {
                view = new System.Activities.Presentation.View.DesignerView(this.context);
                WorkflowViewService      viewService      = new WorkflowViewService(context);
                WorkflowViewStateService viewStateService = new WorkflowViewStateService(context);
                this.context.Services.Publish <ViewService>(viewService);
                this.context.Services.Publish <VirtualizedContainerService>(new VirtualizedContainerService(this.context));
                this.context.Services.Publish <ViewStateService>(viewStateService);
                this.context.Services.Publish <DesignerView>(view);

                WorkflowAnnotationAdornerService annotationService = new WorkflowAnnotationAdornerService();
                annotationService.Initialize(this.context, view.scrollViewer);
                this.context.Services.Publish <AnnotationAdornerService>(annotationService);

                this.context.Services.Subscribe <ModelService>(delegate(ModelService modelService)
                {
                    this.modelService = modelService;
                    if (modelService.Root != null)
                    {
                        view.MakeRootDesigner(modelService.Root);
                    }
                    view.RestoreDesignerStates();
                    this.context.Items.Subscribe <Selection>(new SubscribeContextCallback <Selection>(OnItemSelected));
                });
            }

            if (helpService != null)
            {
                helpService.AddContextAttribute(string.Empty, KeywordForWorkflowDesignerHomePage, HelpKeywordType.F1Keyword);
            }
        }
    private void AssignDelegates()
    {
        designerView = workflowDesigner.Context.Services.GetService<DesignerView>();
        modelService = workflowDesigner.Context.Services.GetService<ModelService>();

        //Handle Flow Diagram
        designerView.PreviewMouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(designerView_PreviewMouseDoubleClick);
    }
 public void TestHandleMouseClick(DependencyObject dp, DesignerView dv)
 {
     HandleMouseClick(MouseButtonState.Pressed, 2, dp, dv);
 }
        //加载流程
        void loadWorkflowFromFile(string workflowFilePathName)
        {
            desienerPanel.Content = null;
            propertyPanel.Content = null;

            designer = new WorkflowDesigner();

            try
            {
                designer.Load(workflowFilePathName);

                modelService = designer.Context.Services.GetService<ModelService>();

                rootModelItem = modelService.Root;

                undoEngine = designer.Context.Services.GetService<UndoEngine>();

                undoEngine.UndoUnitAdded += delegate(object ss, UndoUnitEventArgs ee)
                                           {
                                               designer.Flush(); //调用Flush使designer.Text得到数据
                                               desigeerActionList.Items.Add(string.Format("{0}  ,   {1}", DateTime.Now.ToString(), ee.UndoUnit.Description));
                                           };

                designerView = designer.Context.Services.GetService<DesignerView>();

                designerView.WorkflowShellBarItemVisibility = ShellBarItemVisibility.Arguments    //如果不使用Activity做根,无法出现参数选项
                                                              | ShellBarItemVisibility.Imports
                                                              | ShellBarItemVisibility.MiniMap
                                                              | ShellBarItemVisibility.Variables
                                                               | ShellBarItemVisibility.Zoom
                                                              ;

                desienerPanel.Content = designer.View;

                propertyPanel.Content = designer.PropertyInspectorView;

            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private static bool Load(FrameworkElement element)
        {
            workflowItem = LoadWorkflowItem(element);
            designerView = LoadDeignerView(element);

            AdornerDecorator decorator = LoadAdornerDecorator(element);
            workflowView  = LoadWorkflowView(decorator);
            RegisterWorkflowViewEvents(workflowView);

            scrollViewer = LoadScrollViewer(decorator);
            RegisterScrollViewChanged(scrollViewer);

            workflowViewMask = CreateWorkflowViewMask(workflowView);
            closeButton = CreateCloseButton(workflowView);
            rootActivityDesigner = LoadRootActivityDesigner(workflowView);

            if (rootActivityDesigner == null)
            {
                AddInMessageBoxService.PrintNoneActivityMessage();
                ExitPrint();
                return false;
            }

            return true;
        }
 private void OnDesignerViewAvailable(DesignerView designerView)
 {
     designerView.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(this.OnDesignerSurfaceMouseLeftButtonDown), true);
 }
 public DesignerViewProxy(DesignerView designerView)
 {
     this.reference = new WeakReference(designerView);
 }
            internal ZoomToTicksConverter(DesignerView designer, Slider zoomSlider, ComboBox zoomPicker)
            {
                this.view = designer;
                this.zoomFitToScreenLabel = (this.view.TryFindResource("zoomFitToScreenLabel") as string) ?? "Fit to screen";
                //this.baseConverter = new ZoomPercentageConverter();
                //right now, we want to use our custom ZoomToPercantageConverter due to localization issues with WPF one
                this.baseConverter = new CustomZoomPercentageConverter();

                //initialize zoom slider
                zoomSlider.Minimum = 0;
                zoomSlider.Maximum = 50;
                zoomSlider.Ticks = new DoubleCollection(new double[] { 0, 10, 20, 30, 40, 50 });

                //set initial value - initially, zoom is set to 100%
                zoomSlider.Value = (double)this.ConvertBack(
                    this.baseConverter.Convert(100.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture);

                //insert predefined values to zoomPicker - i use converter to percantage, to ensure text will be formated accordingly to user settings
                zoomPicker.ItemsSource = new object[]
                    {
                        this.baseConverter.Convert(25.0, typeof(string), null, CultureInfo.InvariantCulture),
                        this.baseConverter.Convert(50.0, typeof(string), null, CultureInfo.InvariantCulture),
                        this.baseConverter.Convert(100.0, typeof(string), null, CultureInfo.InvariantCulture),
                        this.baseConverter.Convert(200.0, typeof(string), null, CultureInfo.InvariantCulture),
                        this.baseConverter.Convert(400.0, typeof(string), null, CultureInfo.InvariantCulture)
                    };

                //setup bindings
                zoomPicker.SetBinding(ComboBox.SelectedItemProperty, new Binding()
                {
                    Source = zoomSlider,
                    Path = new PropertyPath(Slider.ValueProperty),
                    Converter = this
                });

                zoomPicker.SetBinding(ComboBox.TextProperty, new Binding()
                {
                    Source = zoomSlider,
                    Path = new PropertyPath(Slider.ValueProperty),
                    Converter = this
                });

                this.keyboardZoomTicks = new double[]
                {
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(25.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(37.5, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(50.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(75.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(100.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(150.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(200.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(300.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),
                    (double)this.ConvertBack(
                        this.baseConverter.Convert(400.0, typeof(string), null, CultureInfo.InvariantCulture), typeof(double), null, CultureInfo.InvariantCulture),

                };

                this.view.zoomPicker.LostFocus += (s, e) =>
                {
                    string text = this.Convert(this.view.zoomSlider.Value, typeof(string), null, CultureInfo.InvariantCulture) as string;
                    if (null != text)
                    {
                        this.view.zoomPicker.Text = string.Empty;
                        this.view.zoomPicker.Text = text;
                    }
                };

            }
 public ContextMenuItemStyleSelector(DesignerView owner)
 {
     this.owner = owner;
 }