public override bool TryMorphExpression(ActivityWithResult expression, bool isLocationExpression, Type newType, 
            EditingContext context, out ActivityWithResult newExpression)
        {
            Fx.Assert(expression != null, "Original expression shouldn't be null in morph helper");
            Fx.Assert(context != null, "EditingContext shouldn't be null in morph helper");
            newExpression = null;
            if (expression.ResultType == newType && 
                (ExpressionHelper.IsGenericLocationExpressionType(expression) == isLocationExpression))
            {
                newExpression = expression;
                return true;
            }

            if (context != null)
            {
                string expressionEditor = ExpressionHelper.GetRootEditorSetting(context.Services.GetService<ModelTreeManager>(), WorkflowDesigner.GetTargetFramework(context));
                ParserContext parserContext = new ParserContext();
                string expressionText = ExpressionHelper.GetExpressionString(expression, parserContext);
                if (!string.IsNullOrEmpty(expressionEditor))
                {
                    return ExpressionTextBox.TryConvertFromString(expressionEditor, expressionText, isLocationExpression, newType, out newExpression);
                }
            }

            return false;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new model item by creating a deep copy of the isntance provided.
        /// </summary>
        /// <param name="context">
        /// The designer's editing context.
        /// </param>
        /// <param name="item">
        /// The item to clone.
        /// </param>
        /// <returns>
        /// The newly created item.
        /// </returns>
        public static ModelItem CreateItem(EditingContext context, object item) {
            if (context == null) throw FxTrace.Exception.ArgumentNull("context");
            if (item == null) throw FxTrace.Exception.ArgumentNull("item");

            ModelService ms = context.Services.GetRequiredService<ModelService>();
            return ms.InvokeCreateItem(item);
        }
 public override bool TryMorphExpression(ActivityWithResult expression, bool isLocationExpression, Type newType, 
     EditingContext context, out ActivityWithResult newExpression)
 {
     string expressionText = ExpressionHelper.GetExpressionString(expression);            
     newExpression = VisualBasicEditor.CreateExpressionFromString(newType, expressionText, isLocationExpression, new ParserContext());
     return true;
 }
Exemplo n.º 4
0
 public UndoEngine(EditingContext context)
 {
     this.context = context;
     undoBuffer = new List<UndoUnit>(capacity);
     redoBuffer = new List<UndoUnit>(capacity);
     this.undoEngineImpl = this;
 }
 public override void Initialize(EditingContext context, Type modelType)
 {
     Fx.Assert(context != null, "Context should not be null.");
     Fx.Assert(modelType != null, "modelType should not be null.");
     ValidationService validationService = context.Services.GetRequiredService<ValidationService>();
     validationService.RegisterValidationErrorSourceLocator(modelType, this.ValidationErrorSourceLocator);
 }
        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); 
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new item for the given item type.
        /// </summary>
        /// <param name="context">
        /// The designer's editing context.
        /// </param>
        /// <param name="itemType">
        /// The type of item to create.
        /// </param>
        /// <param name="options">
        /// A set of create options to use when creating the item.  The default value is CreateOptions.None.
        /// </param>
        /// <param name="arguments">
        /// An optional array of arguments that should be passed to the constructor of the item.
        /// </param>
        /// <returns>
        /// The newly created item type.
        /// </returns>
        /// <exception cref="ArgumentNullException">if itemType or context is null.</exception>
        /// <exception cref="InvalidOperationException">if there is no editing model in the context that can create new items.</exception>
        public static ModelItem CreateItem(EditingContext context, Type itemType, CreateOptions options, params object[] arguments) {
            if (context == null) throw FxTrace.Exception.ArgumentNull("context");
            if (itemType == null) throw FxTrace.Exception.ArgumentNull("itemType");
            if (!EnumValidator.IsValid(options)) throw FxTrace.Exception.AsError(new ArgumentOutOfRangeException("options"));

            ModelService ms = context.Services.GetRequiredService<ModelService>();
            return ms.InvokeCreateItem(itemType, options, arguments);
        }
Exemplo n.º 8
0
 protected UndoUnit(EditingContext context)
 {
     if (context == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("context"));
     }
     this.context = context;
 }
 public override void Initialize(EditingContext context, Type modelType)
 {
     if (context.Services.GetService<DesignerConfigurationService>().TargetFrameworkName.IsLessThan45())
     {
         AttributeTableBuilder builder = new AttributeTableBuilder();
         builder.AddCustomAttributes(typeof(FlowSwitchDefaultLink<>), "DefaultCaseDisplayName", BrowsableAttribute.No);
         MetadataStore.AddAttributeTable(builder.CreateTable());
     }
 }
 public WorkflowDesignerXamlSchemaContext(string localAssembly, EditingContext editingContext)
 {
     if (!string.IsNullOrEmpty(localAssembly))
     {
         this.localAssemblyNsPostfix = XamlNamespaceHelper.ClrNamespaceAssemblyField + localAssembly;
         this.localAssemblyNsPostfixNoLeadingSemicolon = localAssemblyNsPostfix.Substring(1);
     }
     this.editingContext = editingContext;
 }
Exemplo n.º 11
0
        public BookmarkUndoUnit(EditingContext context, ModelTreeManager modelTreeManager)
            : base(context)
        {
            Fx.Assert(modelTreeManager != null, "modelTreeManager cannot be null");

            this.modelTreeManager = modelTreeManager;
            this.DoList = new List<UndoUnit>();
            this.RedoList = new List<UndoUnit>();
        }
Exemplo n.º 12
0
        public static ModelItem CreateModelItem(object objectToMakeModelItem)
        {
            EditingContext ec = new EditingContext();
            ModelTreeManager mtm = new ModelTreeManager(ec);

            mtm.Load(objectToMakeModelItem);

            return mtm.Root;
        }
 public override void Initialize(EditingContext context, Type modelType)
 {
     GenericArgumentUpdater genericArgumentUpdater = context.Services.GetService<GenericArgumentUpdater>();
     if (genericArgumentUpdater == null)
     {
         genericArgumentUpdater = new GenericArgumentUpdater(context);
         context.Services.Publish<GenericArgumentUpdater>(genericArgumentUpdater);
     }
     genericArgumentUpdater.AddSupportForUpdatingTypeArgument(modelType);
 }
Exemplo n.º 14
0
        public static void Delete(EditingContext context)
        {
            if (context == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("context"));
            }
            Selection selection = context.Items.GetValue<Selection>();
            if (null != selection)
            {
                bool selectRoot = false;

                DesignerView designerView = context.Services.GetService<DesignerView>();
                var toDelete = selection.SelectedObjects.Where(p => null != p.View && p.View is WorkflowViewElement && !p.View.Equals(designerView.RootDesigner));
                if (toDelete.Count() > 0)
                {
                    using (EditingScope es = (EditingScope)toDelete.FirstOrDefault().BeginEdit(SR.DeleteOperationEditingScopeDescription))
                    {
                        Dictionary<ICompositeView, List<ModelItem>> containerToModelItemsDict = new Dictionary<ICompositeView, List<ModelItem>>();
                        List<ModelItem> modelItemsPerContainer;
                        foreach (var item in toDelete)
                        {
                            ICompositeView container = (ICompositeView)DragDropHelper.GetCompositeView((WorkflowViewElement)item.View);
                            if (null != container)
                            {
                                if (!containerToModelItemsDict.TryGetValue(container, out modelItemsPerContainer))
                                {
                                    modelItemsPerContainer = new List<ModelItem>();
                                    containerToModelItemsDict.Add(container, modelItemsPerContainer);
                                }
                                modelItemsPerContainer.Add(item);
                            }
                        }
                        foreach (ICompositeView container in containerToModelItemsDict.Keys)
                        {
                            container.OnItemsDelete(containerToModelItemsDict[container]);
                            selectRoot = true;
                        }

                        if (selectRoot)
                        {
                            DesignerView view = context.Services.GetService<DesignerView>();
                            if (null != view)
                            {
                                WorkflowViewElement rootView = view.RootDesigner as WorkflowViewElement;
                                if (rootView != null)
                                {
                                    Selection.SelectOnly(context, rootView.ModelItem);
                                }
                            }
                        }
                        es.Complete();
                    }
                }
            }
        }
        private static void ConvertNamespaces(object root, EditingContext context)
        {
            VisualBasicSettings settings = VisualBasic.GetSettings(root);
            IList<AssemblyReference> references;
            IList<string> importedNamespaces = NamespaceHelper.GetTextExpressionNamespaces(root, out references);
            FrameworkName targetFramework = WorkflowDesigner.GetTargetFramework(context);
            if (targetFramework.IsLessThan45())
            {
                if (settings == null)
                {
                    if ((importedNamespaces != null) && (importedNamespaces.Count > 0))
                    {
                        NamespaceHelper.ConvertToVBSettings(
                            importedNamespaces,
                            references,
                            context,
                            out settings);
                    }
                    else
                    {
                        settings = new VisualBasicSettings();
                    }

                    NamespaceHelper.SetVisualBasicSettings(root, settings);
                    NamespaceHelper.SetTextExpressionNamespaces(root, null, null);
                }

                IDebuggableWorkflowTree debuggableWorkflowTree = root as IDebuggableWorkflowTree;
                if (debuggableWorkflowTree != null)
                {
                    Activity rootActivity = debuggableWorkflowTree.GetWorkflowRoot();
                    if (rootActivity != null)
                    {
                        NamespaceHelper.SetVisualBasicSettings(rootActivity, settings);
                        NamespaceHelper.SetTextExpressionNamespaces(rootActivity, null, null);
                    }                 
                }
            }
            else
            {
                if ((importedNamespaces == null) || (importedNamespaces.Count == 0))
                {
                    if (settings != null)
                    {
                        NamespaceHelper.ConvertToTextExpressionImports(settings, out importedNamespaces, out references);
                        NamespaceHelper.SetTextExpressionNamespaces(root, importedNamespaces, references);
                        NamespaceHelper.SetVisualBasicSettings(root, null);
                    }
                    else
                    {
                        NamespaceHelper.SetTextExpressionNamespaces(root, new Collection<string>(), new Collection<AssemblyReference>());
                    }
                }
            }
        }
        /// <summary>
        /// This interface is used by visual studio integration to acquire a AppDomain serialization friendly reference to an object.
        /// </summary>
        /// <param name="context">The EditingContext of the current WorkflowDesigner.</param>
        public ObjectReferenceService(EditingContext context)
        {
            if (context == null)
            {
                throw FxTrace.Exception.AsError(new ArgumentNullException("context"));
            }

            this.context = context;
            this.context.Services.Subscribe<ModelSearchService>(new SubscribeServiceCallback<ModelSearchService>(this.OnModelSearchServiceAvailable));
            this.context.Services.Subscribe<ModelTreeManager>(new SubscribeServiceCallback<ModelTreeManager>(this.OnModelTreeManagerAvailable));
        }
        public static bool IsBackgroundValidationEnabled(EditingContext editingContext)
        {
            Fx.Assert(editingContext != null, "editingContext should not be null");
            DesignerConfigurationService config = editingContext.Services.GetService<DesignerConfigurationService>();

            if (config != null)
            {
                return config.BackgroundValidationEnabled;
            }

            return false;
        }
        public static void OnDeleteAnnotationCommandCanExecute(CanExecuteRoutedEventArgs e, EditingContext editingContext, ModelItem modelItem)
        {
            e.Handled = true;

            if (modelItem == null || !DesignerConfigurationServiceUtilities.IsAnnotationEnabled(editingContext) || EditingContextUtilities.IsReadOnly(editingContext))
            {
                e.CanExecute = false;
                return;
            }

            e.CanExecute = modelItem.HasAnnotation();
        }
 public static StartSymbol CreateStartSymbol(EditingContext context)
 {
     StartSymbol start = new StartSymbol();
     FakeRoot fakeRoot = new FakeRoot { StartNode = new StartNode() };
     ModelTreeManager manager = context.Services.GetService<ModelTreeManager>();
     start.ModelItem = new FakeModelItemImpl(manager, typeof(FakeRoot), fakeRoot, null).Properties["StartNode"].Value;
     start.Name = "StartSymbol";
     start.Focusable = true;
     start.Context = context;
     start.DataContext = start;
     return start;
 }
 ReceiveContentDialog(ModelItem activity, EditingContext context, DependencyObject owner)
     : this()
 {
     this.ModelItem = activity;
     this.Context = context;
     this.HelpKeyword = HelpKeywords.MessageContentDialog;
     this.Owner = owner;
     this.ViewModel = new ContentDialogViewModel<ReceiveMessageContent, ReceiveParametersContent>(this.ModelItem);
     if (!this.Context.Items.GetValue<ReadOnlyState>().IsReadOnly)
     {
         this.OnOk = this.ViewModel.OnOk;
     }
 }
        static internal FrameworkName GetTargetFramework(EditingContext context)
        {
            if (context != null)
            {
                DesignerConfigurationService designerConfigurationService = context.Services.GetService<DesignerConfigurationService>();
                if (designerConfigurationService != null)
                {
                    return designerConfigurationService.TargetFrameworkName;
                }
            }

            return DesignerConfigurationService.DefaultTargetFrameworkName;
        }
        public static void OnDeleteAllAnnotationCommandCanExecute(CanExecuteRoutedEventArgs e, EditingContext editingContext)
        {
            e.Handled = true;

            if (!DesignerConfigurationServiceUtilities.IsAnnotationEnabled(editingContext) || EditingContextUtilities.IsReadOnly(editingContext))
            {
                e.CanExecute = false;
            }
            else
            {
                e.CanExecute = true;
            }
        }
        public FlowSwitchCaseEditorDialog(ModelItem activity, EditingContext context, DependencyObject owner, string title, Type genericType)
        {
            this.WindowSizeToContent = SizeToContent.Manual;
            this.ModelItem = activity;
            this.Context = context;
            this.Owner = owner;
            this.Title = title;
            this.genericType = genericType;
            this.WindowResizeMode = ResizeMode.NoResize;
            this.MinWidth = 300;
            this.MaxWidth = 300;
            this.MinHeight = 120;
            this.MaxHeight = 120;

            caseKeyBox = new CaseKeyBox()
            {
                DisplayHintText = true,
                Visibility = Visibility.Visible,
                ValueType = genericType,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center,
                Width = Double.NaN,
                CommitExplicitly = true,
                LabelText = StringResourceDictionary.Instance.GetString("addCaseLabel"),
            };
            caseKeyBox.ViewModel.DataTemplateName = CaseKeyBoxViewModel.BoxesTemplate;
            caseKeyBox.ViewModel.IsBoxOnly = true;
            caseKeyBox.SetBinding(CaseKeyBox.ValueProperty, new Binding()
            {
                Source = this,
                Path = new PropertyPath(FlowSwitchCaseEditorDialog.caseProperty),
                Mode = BindingMode.TwoWay
            });
            caseKeyBox.CaseKeyValidationCallback = this.ValidateCaseKey;
            caseKeyBox.ValueCommitted += (sender, e) =>
                {
                    this.CloseDialog(true);
                };
            caseKeyBox.EditCancelled += (sender, e) =>
                {
                    this.CloseDialog(false);
                };

            this.Content = caseKeyBox;

            this.OnOk = () =>
                {
                    caseKeyBox.CommitChanges();
                    return false; // ValueCommitted event handler will handle CloseDialog
                };
        }
        public static ModelItem GetSingleSelectedModelItem(EditingContext editingContext)
        {
            Fx.Assert(editingContext != null, "editingContext should not be null");

            Selection selection = editingContext.Items.GetValue<Selection>();
            if (selection.SelectionCount == 1)
            {
                return selection.PrimarySelection;
            }
            else
            {
                return null;
            }
        }
        public EditingScopeUndoUnit(EditingContext context, ModelTreeManager modelTreeManager, EditingScope editingScope)
            : base(context)
        {
            Fx.Assert(context != null, "context cannot be null");
            Fx.Assert(modelTreeManager != null, "modelTreeManager cannot be null");
            Fx.Assert(editingScope != null, "editingScope cannot be null");

            this.context = context;
            this.modelTreeManager = modelTreeManager;
            this.editingScope = editingScope;
            this.Description = this.editingScope.Description;

            SaveGlobalState();
        }
 /// <summary>
 /// Launch the user interface for developer to pick a contract type.
 /// </summary>
 /// <param name="localAssemblyName">The local assembly name.</param>
 /// <param name="referencedAssemblies">The list of referenced assembly names.</param>
 /// <param name="editingContext">The editing context.</param>
 /// <returns>The contract type selected by user or null if user cancels.</returns>
 public static Type SelectContractType(AssemblyName localAssemblyName, IList<AssemblyName> referencedAssemblies, EditingContext editingContext)
 {
     AssemblyContextControlItem assemblyContextControlItem = new AssemblyContextControlItem { LocalAssemblyName = localAssemblyName, ReferencedAssemblyNames = referencedAssemblies };
     TypeBrowser typeBrowser = new TypeBrowser(assemblyContextControlItem, editingContext, FilterFunction);
     bool? dialogResult = typeBrowser.ShowDialog(/* owner = */ null);
     if (dialogResult.HasValue && dialogResult.Value)
     {
         return typeBrowser.ConcreteType;
     }
     else
     {
         return null;
     }
 }
        public override void Initialize(EditingContext context, Type modelType)
        {
            if (modelType != this.ApplyTo)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException (
                    string.Format(CultureInfo.CurrentCulture, SR.DesignTimeValidationFeatureOnlyAppliesToType, this.GetType(), this.ApplyTo, modelType)));
            }

            ValidationService validationService = context.Services.GetService<ValidationService>();
            if (validationService != null)
            {
                validationService.Settings.AdditionalConstraints.Add(this.ApplyTo, this.DesignTimeConstraints);
            }
        }
Exemplo n.º 28
0
        public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
        {
            var source = (ILocalAssemblySource) value;
            var item = new AssemblyContextControlItem()
            {
                LocalAssemblyName = source.LocalAssemblyName,
                ReferencedAssemblyNames = source.LocalAssemblyReferences.ToList()
            };
            var context = new EditingContext();

            context.Services.Publish( () => new WindowHelperService( IntPtr.Zero ) );
            context.Services.Publish( () => (IMultiTargetingSupportService) new MultiTargetingSupportService( source ) );
            context.Items.SetValue( item );

            return context;
        }
Exemplo n.º 29
0
 public static bool CanDelete(EditingContext context)
 {
     if (context == null)
     {
         throw FxTrace.Exception.AsError(new ArgumentNullException("context"));
     }
     bool canExecute = false;
     Selection selection = context.Items.GetValue<Selection>();
     if (null != selection && selection.SelectionCount > 0)
     {
         DesignerView designerView = context.Services.GetService<DesignerView>();
         canExecute = selection.SelectedObjects.All(
             p => (null != p.View && p.View is WorkflowViewElement && !p.View.Equals(designerView.RootDesigner)));
     }
     return canExecute;
 }
 public EditorWindow(ModelItem activity, EditingContext context)
 {
     this.ModelItem = activity;
     this.Context = context;
     this.Owner = activity.View;
     this.EnableMaximizeButton = false;
     this.EnableMinimizeButton = false;
     this.MinWidth = 450;
     this.MinHeight = 250; 
     this.WindowResizeMode = ResizeMode.CanResize;
     this.WindowSizeToContent = SizeToContent.Manual;
     var content = new CorrelationInitializerDesigner() { Activity = activity };
     this.Title = (string)content.Resources["controlTitle"];
     this.Content = content;
     this.HelpKeyword = HelpKeywords.AddCorrelationInitializersDialog;
 }
        internal static object GetDroppedObjectInstance(DependencyObject dropTarget, EditingContext context, Type type, IDataObject dataObject)
        {
            if (type != null)
            {
                //check if type is generic
                if (type.IsGenericTypeDefinition)
                {
                    type = ResolveGenericParameters(dropTarget, context, type);
                }
            }

            object droppedObject = null;

            if (null != type)
            {
                try
                {
                    droppedObject = Activator.CreateInstance(type);

                    if (type.IsActivityTemplateFactory() && type.IsClass)
                    {
                        //find parent WorkflowViewElement - in case of mouse drop, current drop target most likely is ISourceContainer
                        if (!(dropTarget is WorkflowViewElement))
                        {
                            dropTarget = VisualTreeUtils.FindVisualAncestor <WorkflowViewElement>(dropTarget);
                        }

                        Type templateFactoryInterface2 = type.GetInterface(typeof(IActivityTemplateFactory <>).FullName);
                        if (templateFactoryInterface2 != null)
                        {
                            droppedObject = templateFactoryInterface2.InvokeMember("Create", BindingFlags.InvokeMethod, null, droppedObject, new object[] { dropTarget, dataObject }, CultureInfo.InvariantCulture);
                        }
                        else if (droppedObject is IActivityTemplateFactory)
                        {
                            droppedObject = ((IActivityTemplateFactory)droppedObject).Create(dropTarget);
                        }
                    }

                    // SQM: Log activity usage count
                    ActivityUsageCounter.ReportUsage(context.Services.GetService <IVSSqmService>(), type);
                }
                catch (Exception ex)
                {
                    if (Fx.IsFatal(ex))
                    {
                        throw;
                    }

                    string details = ex.Message;
                    if (ex is TargetInvocationException && ex.InnerException != null)
                    {
                        details = ex.InnerException.Message;
                    }


                    ErrorReporting.ShowErrorMessage(string.Format(CultureInfo.CurrentUICulture, SR.CannotCreateInstance, TypeNameHelper.GetDisplayName(type, false)), details);
                }
            }

            return(droppedObject);
        }
Exemplo n.º 32
0
 public static bool ShowDialog(ModelItem activity, ModelItem data, EditingContext context, DependencyObject owner, DynamicArgumentDesignerOptions options)
 {
     return(new DynamicArgumentDialog(activity, data, context, owner, options).ShowOkCancel());
 }
        public static object GetDroppedObject(DependencyObject dropTarget, DragEventArgs e, EditingContext context)
        {
            IEnumerable <object> droppedObjects = GetDroppedObjects(dropTarget, e, context);

            if (droppedObjects.Count() > 0)
            {
                return(droppedObjects.First());
            }
            return(null);
        }
Exemplo n.º 34
0
        public static void OnDeleteAllAnnotationCommandCanExecute(CanExecuteRoutedEventArgs e, EditingContext editingContext)
        {
            e.Handled = true;

            if (!DesignerConfigurationServiceUtilities.IsAnnotationEnabled(editingContext) || EditingContextUtilities.IsReadOnly(editingContext))
            {
                e.CanExecute = false;
            }
            else
            {
                e.CanExecute = true;
            }
        }
Exemplo n.º 35
0
 public static void OnDeleteAnnotationCommandCanExecute(CanExecuteRoutedEventArgs e, EditingContext editingContext, DataGrid dataGrid)
 {
     OnDeleteAnnotationCommandCanExecute(e, editingContext, DataGridHelper.GetSingleSelectedObject(dataGrid));
 }
Exemplo n.º 36
0
        public static void OnDeleteAnnotationCommandCanExecute(CanExecuteRoutedEventArgs e, EditingContext editingContext, ModelItem modelItem)
        {
            e.Handled = true;

            if (modelItem == null || !DesignerConfigurationServiceUtilities.IsAnnotationEnabled(editingContext) || EditingContextUtilities.IsReadOnly(editingContext))
            {
                e.CanExecute = false;
                return;
            }

            e.CanExecute = modelItem.HasAnnotation();
        }
        public static IEnumerable <object> GetDroppedObjects(DependencyObject dropTarget, DragEventArgs e, EditingContext context)
        {
            List <object> droppedObjects = new List <object>();

            if (e.Data.GetDataPresent(ModelItemsDataFormat))
            {
                IEnumerable <ModelItem> droppedModelItems = e.Data.GetData(ModelItemsDataFormat) as IEnumerable <ModelItem>;
                foreach (ModelItem modelItem in droppedModelItems)
                {
                    droppedObjects.Add(modelItem);
                }
            }
            else
            {
                object droppedObject = e.Data.GetData(ModelItemDataFormat) as ModelItem;
                // could have been dropped from toolbox.
                if (droppedObject == null)
                {
                    Type type = null;
                    if (e.Data.GetDataPresent(WorkflowItemTypeNameFormat))
                    {
                        string text = e.Data.GetData(WorkflowItemTypeNameFormat) as string;
                        if (!string.IsNullOrEmpty(text))
                        {
                            //try to use the text format to see if it holds a type name and  try to create an object out of it.
                            type = Type.GetType(text);
                        }
                    }
                    droppedObject = GetDroppedObjectInstance(dropTarget, context, type, e.Data);
                }
                if (droppedObject != null)
                {
                    droppedObjects.Add(droppedObject);
                }
            }
            e.Handled = true;
            context.Services.GetService <DesignerPerfEventProvider>().WorkflowDesignerDrop();

            Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                     new Action(() =>
            {
                context.Services.GetService <DesignerPerfEventProvider>().WorkflowDesignerIdleAfterDrop();
            }));
            return(droppedObjects);
        }
Exemplo n.º 38
0
 public static void OnDeleteAnnotationCommandCanExecute(CanExecuteRoutedEventArgs e, EditingContext editingContext)
 {
     OnDeleteAnnotationCommandCanExecute(e, editingContext, EditingContextUtilities.GetSingleSelectedModelItem(editingContext));
 }