Esempio n. 1
0
        // return true if really something is dropped, otherwise, false.
        bool DoAutoWrapDrop(InsertionPosition insertionPos, IEnumerable <object> droppedObjects)
        {
            List <Activity> activityList = ObjectList2ActivityList(droppedObjects);

            if (activityList.Count == 0)
            {
                return(false);
            }

            AutoWrapEventArgs args = new AutoWrapEventArgs()
            {
                InsertionPosition      = insertionPos,
                ExistingActivity       = this.MyActivity,
                ActivitiesToBeInserted = activityList
            };

            using (ModelEditingScope scope = this.Context.Services.GetService <ModelService>().Root.BeginEdit(SR.WrapInSequenceDescription))
            {
                ModelItem sequenceActivity = WorkflowItemPresenter.AutoWrapInSequenceHandler(this.Context, args);
                if (this.UpdateItem(sequenceActivity, true))
                {
                    scope.Complete();
                    return(true);
                }
                else
                {
                    scope.Revert();
                    return(false);
                }
            }
        }
Esempio n. 2
0
 public bool InsertMarkup(ElementReference parentElement, string?value, InsertionPosition position, MarkupType type)
 {
     return(_jsInProcessObjectRef !.Invoke <bool>(
                "insertMarkup",
                parentElement,
                value,
                MapInsertionPosition(position),
                MapMarkupType(type)));
 }
Esempio n. 3
0
        public bool InsertMarkup(string parentSelector, string?value, InsertionPosition position, MarkupType type)
        {
            _ = parentSelector ?? throw new ArgumentNullException(nameof(parentSelector));

            return(_jsInProcessObjectRef !.Invoke <bool>(
                       "insertMarkup",
                       parentSelector,
                       value,
                       MapInsertionPosition(position),
                       MapMarkupType(type)));
        }
Esempio n. 4
0
            void OnPlaceholderDrop(object sender, DragEventArgs e)
            {
                if (!this.AllowDropOnSpacer(e))
                {
                    return;
                }
                InsertionPosition insertionPos = (sender == this.BottomSpacerWrapper.Placeholder)
                    ? InsertionPosition.After : InsertionPosition.Before;

                ModelItemHelper.TryCreateImmediateEditingScopeAndExecute(this.wfItemPresenter.Context, SR.WrapInSequenceDescription, (es) =>
                {
                    if (this.wfItemPresenter.DoAutoWrapDrop(insertionPos, e))
                    {
                        // auto wrap is successful
                        if (es != null)
                        {
                            // if we created an immediate editing scope, try to complete it.
                            es.Complete();
                        }
                    }
                });
            }
        bool DoAutoWrapDrop(InsertionPosition insertionPos, DragEventArgs e, IList<object> droppedObjects = null)
        {
            if (droppedObjects == null)
            {
                ModelTreeManager manager = this.Context.Services.GetRequiredService<ModelTreeManager>();
                EditingScope editingScope = null;

                try
                {
                    editingScope = ModelItemHelper.TryCreateImmediateEditingScope(manager, SR.WrapInSequenceDescription);

                    droppedObjects = this.GetSortedObjectList(e);

                    if (!this.DoAutoWrapDrop(insertionPos, droppedObjects))
                    {
                        return false;
                    }

                    if (editingScope != null)
                    {
                        editingScope.Complete();
                    }
                }
                finally
                {
                    if (editingScope != null)
                    {
                        editingScope.Dispose();
                        editingScope = null;
                    }
                }
            }
            else
            {
                if (!this.DoAutoWrapDrop(insertionPos, droppedObjects))
                {
                    return false;
                }
            }

            if (!DragDropHelper.IsDraggingFromToolbox(e))
            {
                List<WorkflowViewElement> movedViewElements = ObjectList2WorkflowViewElementList(droppedObjects);
                DragDropHelper.SetDragDropMovedViewElements(e, movedViewElements);

                //Backward compatibility for 4.0
                if (droppedObjects.Count == 1 && movedViewElements.Count == 1)
                {
                    #pragma warning disable 618
                    DragDropHelper.SetDragDropCompletedEffects(e, DragDropEffects.Move);
                    #pragma warning restore 618
                }
            }
            else
            {
                Fx.Assert(droppedObjects.Count == 1, "Dropping from Toolbox with count != 1");

                // Set focus if it is dropping from ToolBox.
                // In common drag/drop, the selection setting is done at the end of
                // StartDragging().
                if (this.Item == null)
                {
                    return true;
                }
                
                Fx.Assert(typeof(Sequence).IsAssignableFrom(this.Item.ItemType), 
                    "Auto Wrap didn't add a sequence. Is Item.Properties[\"Activities\"] still correct?");
                foreach (ModelItem item in this.Item.Properties["Activities"].Collection)
                {
                    // Find the ModelItem whose value is an activity from Toolbox.
                    if (item.GetCurrentValue() == droppedObjects[0])
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                        {
                            item.Focus();
                        }));
                        break;
                    }
                }
            }

            return true;
        }
        // return true if really something is dropped, otherwise, false.
        bool DoAutoWrapDrop(InsertionPosition insertionPos, IEnumerable<object> droppedObjects)
        {
            List<Activity> activityList = ObjectList2ActivityList(droppedObjects);
            if (activityList.Count == 0)
            {
                return false;
            }

            AutoWrapEventArgs args = new AutoWrapEventArgs()
            {
                InsertionPosition = insertionPos,
                ExistingActivity = this.MyActivity,
                ActivitiesToBeInserted = activityList
            };

            using (ModelEditingScope scope = this.Context.Services.GetService<ModelService>().Root.BeginEdit(SR.WrapInSequenceDescription))
            {
                ModelItem sequenceActivity = WorkflowItemPresenter.AutoWrapInSequenceHandler(this.Context, args);
                if (this.UpdateItem(sequenceActivity, true))
                {
                    scope.Complete();
                    return true;
                }
                else
                {
                    scope.Revert();
                    return false;
                }
            }
        }
Esempio n. 7
0
 public CompileResult(string code, InsertionPosition insertionPosition)
 {
     this.code = code;
     this.insertionPosition = insertionPosition;
 }
Esempio n. 8
0
 public CompileResult(string code, InsertionPosition insertionPosition)
 {
     this.code = code;
     this.insertionPosition = insertionPosition;
 }
Esempio n. 9
0
        bool DoAutoWrapDrop(InsertionPosition insertionPos, DragEventArgs e, IList <object> droppedObjects = null)
        {
            if (droppedObjects == null)
            {
                ModelTreeManager manager      = this.Context.Services.GetRequiredService <ModelTreeManager>();
                EditingScope     editingScope = null;

                try
                {
                    editingScope = ModelItemHelper.TryCreateImmediateEditingScope(manager, SR.WrapInSequenceDescription);

                    droppedObjects = this.GetSortedObjectList(e);

                    if (!this.DoAutoWrapDrop(insertionPos, droppedObjects))
                    {
                        return(false);
                    }

                    if (editingScope != null)
                    {
                        editingScope.Complete();
                    }
                }
                finally
                {
                    if (editingScope != null)
                    {
                        editingScope.Dispose();
                        editingScope = null;
                    }
                }
            }
            else
            {
                if (!this.DoAutoWrapDrop(insertionPos, droppedObjects))
                {
                    return(false);
                }
            }

            if (!DragDropHelper.IsDraggingFromToolbox(e))
            {
                List <WorkflowViewElement> movedViewElements = ObjectList2WorkflowViewElementList(droppedObjects);
                DragDropHelper.SetDragDropMovedViewElements(e, movedViewElements);

                //Backward compatibility for 4.0
                if (droppedObjects.Count == 1 && movedViewElements.Count == 1)
                {
                    #pragma warning disable 618
                    DragDropHelper.SetDragDropCompletedEffects(e, DragDropEffects.Move);
                    #pragma warning restore 618
                }
            }
            else
            {
                Fx.Assert(droppedObjects.Count == 1, "Dropping from Toolbox with count != 1");

                // Set focus if it is dropping from ToolBox.
                // In common drag/drop, the selection setting is done at the end of
                // StartDragging().
                if (this.Item == null)
                {
                    return(true);
                }

                Fx.Assert(typeof(Sequence).IsAssignableFrom(this.Item.ItemType),
                          "Auto Wrap didn't add a sequence. Is Item.Properties[\"Activities\"] still correct?");
                foreach (ModelItem item in this.Item.Properties["Activities"].Collection)
                {
                    // Find the ModelItem whose value is an activity from Toolbox.
                    if (item.GetCurrentValue() == droppedObjects[0])
                    {
                        this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                        {
                            item.Focus();
                        }));
                        break;
                    }
                }
            }

            return(true);
        }
Esempio n. 10
0
        public async ValueTask <bool> InsertMarkupAsync(ElementReference parentElement, string?value, InsertionPosition position, MarkupType type)
        {
            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            return(await module.InvokeAsync <bool>(
                       "insertMarkup",
                       parentElement,
                       value,
                       MapInsertionPosition(position),
                       MapMarkupType(type)));
        }
Esempio n. 11
0
        public async ValueTask <bool> InsertMarkupAsync(string parentSelector, string?value, InsertionPosition position, MarkupType type)
        {
            _ = parentSelector ?? throw new ArgumentNullException(nameof(parentSelector));

            var module = await _jsRuntime
                         .ImportOrGetModuleAsync(ModulePath, ModuleKey, _jsRefStore);

            return(await module.InvokeAsync <bool>(
                       "insertMarkup",
                       parentSelector,
                       value,
                       MapInsertionPosition(position),
                       MapMarkupType(type)));
        }