Exemplo n.º 1
0
        public IEndNodeImplementor Attribute(string name)
        {
            var attr = _elem.Attribute(name);

            var endNode = new EndNode {Name = name, Parent = this, Value = attr.Value};
            var stringProvider = (IAccessor<string>)new Accessor<string> {Value = attr.Value};
            endNode.Register(stringProvider);
            return endNode;
        }
Exemplo n.º 2
0
        public void SimpleProcess()
        {
            var startNode = new StartNode("1. Submit claim");
            var n2 = new Activity("2. Middle");
            var endNode = new EndNode("3. Closed");
            var t12 = new SequenceFlow(startNode, n2);
            var t23 = new SequenceFlow(n2, endNode);

            this.process = new Process(startNode);
        }
Exemplo n.º 3
0
        public void ImplicitGatewayProcess()
        {
            var startNode = new StartNode("0. Start");
            var n1 = new Activity("1. Submit claim");
            var n2 = new Activity("2. Child A");
            var n3 = new Activity("3. Child B");
            var endNode = new EndNode("4. Closed");

            var ts1 = new SequenceFlow(startNode, n1);
            var t12 = new SequenceFlow(n1, n2);
            var t13 = new SequenceFlow(n1, n3);
            var t2e = new SequenceFlow(n2, endNode);
            var t3e = new SequenceFlow(n3, endNode);

            this.process = new Process(startNode);
        }
Exemplo n.º 4
0
        public void SplitGwProcess()
        {
            var startNode = new StartNode("1. Submit claim");
            var xorGw = new ParallelGateway("X. Split");
            var n2 = new Activity("2. Child A");
            var n3 = new Activity("3. Child B");
            var joinGw = new JoinGateway("X. Join");
            var endNode = new EndNode("4. Closed");

            var t1gw = new SequenceFlow(startNode, xorGw);
            var tgw2 = new SequenceFlow(xorGw, n2);
            var tgw3 = new SequenceFlow(xorGw, n3);
            var t2End = new SequenceFlow(n2, joinGw);
            var t3End = new SequenceFlow(n3, joinGw);
            var tJE = new SequenceFlow(joinGw, endNode);

            this.process = new Process(startNode);
        }
        /// <summary>
        /// Gets the internal force at <see cref="x" /> position.
        /// </summary>
        /// <param name="x">The position (from start point).</param>
        /// <param name="cmb">The <see cref="LoadCombination" />.</param>
        /// <returns></returns>
        /// <remarks>
        /// Will calculate the internal forces of member regarding the <see cref="cmb" /> <see cref="LoadCombination" />
        /// </remarks>
        public override Force GetInternalForceAt(double x, LoadCombination cmb)
        {
            var gStartDisp = StartNode.GetNodalDisplacement(cmb);
            var gEndDisp   = EndNode.GetNodalDisplacement(cmb);

            var lStartDisp = new Displacement(
                TransformGlobalToLocal(gStartDisp.Displacements),
                TransformGlobalToLocal(gStartDisp.Rotations));

            var lEndDisp = new Displacement(
                TransformGlobalToLocal(gEndDisp.Displacements),
                TransformGlobalToLocal(gEndDisp.Rotations));

            var displVector = new double[]
            {
                lStartDisp.DX, lStartDisp.DY, lStartDisp.DZ,
                lStartDisp.RX, lStartDisp.RY, lStartDisp.RZ,
                lEndDisp.DX, lEndDisp.DY, lEndDisp.DZ,
                lEndDisp.RX, lEndDisp.RY, lEndDisp.RZ
            };

            var lStartForces = Matrix.Multiply(GetLocalStiffnessMatrix(), displVector);

            var startForce = Force.FromVector(lStartForces, 0);

            var forceAtX = -startForce.Move(new Vector(x, 0, 0));

            foreach (var ld in loads)
            {
                if (!cmb.ContainsKey(ld.Case))
                {
                    continue;
                }

                var frc = ((Load1D)ld).GetInternalForceAt(this, x);

                forceAtX += cmb[ld.Case] * frc;
            }

            return(forceAtX);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Keep comparing original text from position i
        /// with what is in the edge
        /// </summary>
        /// <param name="i">Index of comparison start in the original text</param>
        /// <param name="activeLength"></param>
        /// <param name="minDistance"></param>
        /// <param name="activeNode"></param>
        /// <returns>(edge, index) - the edje the character in it where the walk ended</returns>
        internal Tuple <Edge, int> WalkTheEdge(int i, ref int activeLength, ref int minDistance, ref Node activeNode)
        {
            var text           = SuffixTree.Text;
            var skipCharacters = minDistance;
            var index          = i + activeLength;

            // we know we do not need any comparisons on this edge
            if (skipCharacters >= Route.Length)
            {
                var edge = EndNode.FindEdgeByChar(i + Route.Length);
                activeLength += Route.Length;
                minDistance  -= Route.Length;

                activeNode = EndNode;
                return(edge.WalkTheEdge(i, ref activeLength, ref minDistance, ref activeNode));
            }

            var j = Walk(text, index, skipCharacters);

            return(new Tuple <Edge, int>(this, j));
        }
            /// <summary>
            ///
            /// </summary>
            private void EvaluateTransitionNodes()
            {
                if (m_currentNode is PageNode)
                {
                    PageNode pageNode = m_currentNode as PageNode;
                    m_sceneManager.NewPage((pageNode).GetPageNumber());
                }
                else if (m_currentNode is EndNode)
                {
                    EndNode endNode = m_currentNode as EndNode;

                    if (endNode.GetNextScene() == null)
                    {
                        // -- place custom scene transition code here --
                    }
                    else
                    {
                        m_sceneManager.NewScene(endNode.GetNextScene());
                    }
                }
            }
Exemplo n.º 8
0
        public void SplitConditionalProcess()
        {
            var startNode = new StartNode("1. Submit claim");
            var xorGw = new SplitConditionalGateway<string>("X. Split", (e => transitionState));
            var n2 = new Activity("2. Child A");
            var n3 = new Activity("3. Child B");
            var n4 = new Activity("4. Child C");
            var joinGw = new JoinGateway("X. Join");
            var endNode = new EndNode("5. Closed");

            var t1gw = new SequenceFlow(startNode, xorGw);
            var tgw2 = new ConditionalFlow<string>(xorGw, n2, "a");
            var tgw3 = new ConditionalFlow<string>(xorGw, n3, "a");
            var tgw4 = new ConditionalFlow<string>(xorGw, n4, "b");
            var t2Join = new SequenceFlow(n2, joinGw);
            var t3Join = new SequenceFlow(n3, joinGw);
            var t4Join = new SequenceFlow(n4, joinGw);
            var tJE = new SequenceFlow(joinGw, endNode);

            this.process = new Process(startNode);
        }
Exemplo n.º 9
0
    IEnumerator ResetNodeBehaviour(GameObject button, float time)
    {
        //verificando se a saida do node atual chega em um node de tipo EndNode
        //ou seja, validando se a conversa acaba com resultado gravado
        //o yield break sai da funcao
        if (nodeAtual.GetOutputPort("Exit").Connection.node.GetType() == typeof(EndNode))
        {
            EndNode nodeFinal = (EndNode)nodeAtual.GetOutputPort("Exit").Connection.node;
            Parametros_globais.AddOrUpdateResultados(Conversation.name, nodeFinal.Resultado);
            Parametros_globais.DebugAllResultados();
            endConversation(nodeFinal);
            yield break;
        }
        //chegamos aqui se a conversa continua de alguma forma
        yield return(new WaitForSeconds(time));

        //reiniciar a situação toda após x tempo, geralmente dado pelo tamanho da ultima fala
        WaitingAnswer = false;
        //se o proximo node for uma decisao baseado em uma conversa anterior
        if (nodeAtual.GetOutputPort("Exit").Connection.node.GetType() == typeof(Decision_resultadoNode))
        {
            Decision_resultadoNode drn = (Decision_resultadoNode)nodeAtual.GetOutputPort("Exit").Connection.node;
            if (drn.GetBasedOnResult() == true)
            {
                nodeAtual = (Conversation_Node)drn.GetOutputPort("Exit_if_true").Connection.node;
            }
            else
            {
                nodeAtual = (Conversation_Node)drn.GetOutputPort("Exit_if_false").Connection.node;
            }
        }
        //se nao for end nem decision_resultado, só pode ser decisionNode
        else
        {
            DecisionNode dn = (DecisionNode)nodeAtual.GetOutputPort("Exit").Connection.node;
            //passa o nome da opcao escolhida para delimitar qual a saida certa do node de decisao
            nodeAtual = dn.GetNextNode(button.name);
        }
    }
    void EntityJobScheduling()
    {
        m_EntityCommandBuffer = m_EntityBufferSystem.CreateCommandBuffer();
        //Lambda doesnt run in normal C#, Unity converts it in a more performant job system construct and burst for better PC resource usage
        Entities.ForEach((Entity entity, in UserData userData, in UpdatedFFData updatedFFData) =>
        {
            m_EntityCommandBuffer.RemoveComponent <UpdatedFFData>(entity);
            DynamicBuffer <EBufferElement> eBuffer = updatedFFData.exists ? GetBuffer <EntityCommandBufferManagedComponentExtensions>(entity) : m_EntityCommandBuffer.AddBuffer <EBufferElement>(entity);
            DynamicBuffer <Entity> m_EntityBuffer  = eBuffer.Reinterpret <Entity>();

            InitGrid(updatedFFData);

            //From Elite framework
            IPoint2 idxInWorld = GetNodeIdxFromWorldPos(userData.GetClickedPos(), IPoint2(nrOfCols, nrOfRows), colSize, rowSize);
            EndNode endNode    = new EndNode(idxInWorld);
            if (!updatedFFData.exists)
            {
                m_EntityCommandBuffer.AddComponent <EndNode>(entity);
            }
            m_EntityCommandBuffer.SetComponent(entity, endNode);
            m_EntityCommandBuffer.AddComponent <TagObstacleCalc>(entity);
        }).Run();
Exemplo n.º 11
0
    public void Initiliaze(EditableLevel editableLevel)
    {
        Scripted      = editableLevel.Scripted;
        Name          = editableLevel.name;
        ExpectedTime  = editableLevel.ExpectedTime;
        ExpectedMoves = editableLevel.ExpectedMoves;

        gameObject.name = Name;

        LinkElements <Node, Path>();
        LinkElements <Path, Node>();

        StartNode.GetComponent <SpriteRenderer>().sprite = NodePrefab.GetComponent <Node>().StartSprite;
        EndNode.GetComponent <SpriteRenderer>().sprite   = NodePrefab.GetComponent <Node>().EndSprite;

        Instantiate(PlayerPrefab, StartNode.transform);

        if (Application.isPlaying && Scripted)
        {
            TraversalManager.Instance.SimulateTraversalPlanning(editableLevel.TraversalScript);
        }
    }
Exemplo n.º 12
0
 void endConversation(EndNode nodeFinal)
 {
     StartCoroutine(EndConversationDelay(CalculateTextTime(), nodeFinal));
 }
Exemplo n.º 13
0
        public void XorGwProcess()
        {
            var startNode = new StartNode("1. Submit claim");
            var xorGw = new ExclusiveGateway<string>("X. Decide", (e => transitionState));
            var n2 = new Activity("2. Alternative A");
            var n3 = new Activity("3. Alternative B");
            var n4 = new Activity("D. Default");
            var endNode = new EndNode("4. Closed");

            var t1gw = new SequenceFlow(startNode, xorGw);
            var tgw2 = new ConditionalFlow<string>(xorGw, n2, "a");
            var tgw3 = new ConditionalFlow<string>(xorGw, n3, "b");
            var tgw4 = new DefaultFlow(xorGw, n4);
            var t2End = new SequenceFlow(n2, endNode);
            var t3End = new SequenceFlow(n3, endNode);
            var t4End = new SequenceFlow(n4, endNode);

            this.process = new Process(startNode);
        }
Exemplo n.º 14
0
 public EndNodeInstance(EndNode endNd)
 {
     this.endNode = endNd;
     this.Volume  = this.endNode.EnteringTransitions.Count;
 }
Exemplo n.º 15
0
 public override string ToString()
 {
     return("Demand: \n Start Node: " + StartNode.ToString() + "\n End Node: " +
            EndNode.ToString() + "\n Volume: " + Volume.ToString() + "\n");
 }
Exemplo n.º 16
0
 /// <summary>
 /// Generates hashcode using <see cref="StartNode"/>, <see cref="EndNode"/>, <see cref="Distance"/> properties.
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return((StartNode?.GetHashCode() ?? 0)
            + (EndNode?.GetHashCode() ?? 0)
            + Distance.GetHashCode());
 }
Exemplo n.º 17
0
Arquivo: Arc.cs Projeto: Pogadi/viadf
 public override int GetHashCode()
 {
     return(StartNode.GetHashCode() + EndNode.GetHashCode());
 }
Exemplo n.º 18
0
        // Spawning nodes based on ScriptableObject data
        private void GenerateNodes(DialogueContainerSO dialogueContainer)
        {
            // StartNode
            foreach (StartNodeData node in dialogueContainer.StartNodeDatas)
            {
                StartNode tempNode = graphView.CreateStartNode(node.Position);
                tempNode.NodeGuid = node.NodeGuid;

                graphView.AddElement(tempNode);
            }

            // EndNode
            foreach (EndNodeData node in dialogueContainer.EndNodeDatas)
            {
                EndNode tempNode = graphView.CreateEndNode(node.Position);
                tempNode.NodeGuid    = node.NodeGuid;
                tempNode.EndNodeType = node.EndNodeType;

                tempNode.LoadValueInToField();  // Loading values into node fields
                graphView.AddElement(tempNode); // Adding node to graph view
            }

            // EventNode
            foreach (EventNodeData node in dialogueContainer.EventNodeDatas)
            {
                EventNode tempNode = graphView.CreateEventNode(node.Position);
                tempNode.NodeGuid      = node.NodeGuid;
                tempNode.DialogueEvent = node.DialogueEventSO;

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }

            // DialogueNode
            foreach (DialogueNodeData node in dialogueContainer.DialogueNodeDatas)
            {
                DialogueNode tempNode = graphView.CreateDialogueNode(node.Position);
                tempNode.NodeGuid        = node.NodeGuid;
                tempNode.NameText        = node.Name;
                tempNode.NpcFaceImage    = node.npcSprite;
                tempNode.PlayerFaceImage = node.playerSprite;

                // Matching language dialogue is set to
                foreach (LanguageGeneric <string> languageGeneric in node.TextLanguages)
                {
                    tempNode.Texts.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
                }

                // Matching voice clips language dialogue is set to
                foreach (LanguageGeneric <AudioClip> languageGeneric in node.AudioClips)
                {
                    tempNode.AudioClips.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
                }

                // Matching dialogue choice ports
                foreach (DialogueNodePort nodePort in node.DialogueNodePorts)
                {
                    tempNode.AddChoicePort(tempNode, nodePort);
                }

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }

            // StatCheckNode
            foreach (StatCheckNodeData node in dialogueContainer.StatCheckNodeDatas)
            {
                StatCheckNode tempNode = graphView.CreateStatCheckNode(node.Position);
                tempNode.NodeGuid       = node.NodeGuid;
                tempNode.StatCheckValue = node.StatCheckValue.ToString();
                tempNode.CheckType      = node.StatCheckType;

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }

            // ItemCheckNode
            foreach (ItemCheckNodeData node in dialogueContainer.ItemCheckNodeDatas)
            {
                ItemCheckNode tempNode = graphView.CreateItemCheckNode(node.Position);
                tempNode.NodeGuid          = node.NodeGuid;
                tempNode.ItemCheckValue    = node.ItemCheckValue.ToString();
                tempNode.ItemCheckNodeType = node.ItemCheckType;
                tempNode.NodeItem          = node.NodeItem;

                tempNode.LoadValueInToField();
                graphView.AddElement(tempNode);
            }
        }
Exemplo n.º 19
0
 public override string ToString()
 {
     return(StartNode.ToString() + EndNode.ToString());
 }
Exemplo n.º 20
0
        /// <summary>wangmj  初始化一个工作流网实例,将引擎的扩展属性,注入到对应的工作流元素中</summary>
        /// <param name="process"></param>
        /// <param name="kenelExtensions"></param>
        public NetInstance(WorkflowProcess process, Dictionary <String, List <IKernelExtension> > kenelExtensions)
        {
            this.workflowProcess = process;

            //开始节点
            StartNode startNode = workflowProcess.StartNode;

            StartNodeInstance = new StartNodeInstance(startNode);
            List <IKernelExtension> extensionList = kenelExtensions[StartNodeInstance.ExtensionTargetName];

            for (int i = 0; extensionList != null && i < extensionList.Count; i++)
            {
                IKernelExtension extension = extensionList[i];
                StartNodeInstance.registExtension(extension);
            }
            //this.StartNodeInstance = StartNodeInstance; 自身赋值自身没用。
            wfElementInstanceMap.Add(startNode.Id, StartNodeInstance);

            //活动节点activity
            List <Activity> activities = workflowProcess.Activities;

            for (int i = 0; i < activities.Count; i++)
            {
                Activity         activity         = (Activity)activities[i];
                ActivityInstance activityInstance = new ActivityInstance(activity);
                extensionList = kenelExtensions[activityInstance.ExtensionTargetName];
                for (int j = 0; extensionList != null && j < extensionList.Count; j++)
                {
                    IKernelExtension extension = extensionList[j];
                    activityInstance.registExtension(extension);
                }
                wfElementInstanceMap.Add(activity.Id, activityInstance);
            }

            //同步器节点
            List <Synchronizer> synchronizers = workflowProcess.Synchronizers;

            for (int i = 0; i < synchronizers.Count; i++)
            {
                Synchronizer         synchronizer         = (Synchronizer)synchronizers[i];
                SynchronizerInstance synchronizerInstance = new SynchronizerInstance(synchronizer);
                extensionList = kenelExtensions[synchronizerInstance.ExtensionTargetName];
                for (int j = 0; extensionList != null && j < extensionList.Count; j++)
                {
                    IKernelExtension extension = extensionList[j];
                    synchronizerInstance.registExtension(extension);
                }
                wfElementInstanceMap.Add(synchronizer.Id, synchronizerInstance);
            }

            //结束节点
            List <EndNode> endNodes = workflowProcess.EndNodes;

            //        List<EndNodeInstance> endNodeInstances = netInstance.getEndNodeInstances();
            for (int i = 0; i < endNodes.Count; i++)
            {
                EndNode         endNode         = endNodes[i];
                EndNodeInstance endNodeInstance = new EndNodeInstance(endNode);
                //            endNodeInstances.add(endNodeInstance);
                extensionList = kenelExtensions[endNodeInstance.ExtensionTargetName];
                for (int j = 0; extensionList != null && j < extensionList.Count; j++)
                {
                    IKernelExtension extension = extensionList[j];
                    endNodeInstance.registExtension(extension);
                }
                wfElementInstanceMap.Add(endNode.Id, endNodeInstance);
            }

            //转移线
            List <Transition> transitions = workflowProcess.Transitions;

            for (int i = 0; i < transitions.Count; i++)
            {
                Transition         transition         = (Transition)transitions[i];
                TransitionInstance transitionInstance = new TransitionInstance(transition);

                String fromNodeId = transition.FromNode.Id;
                if (fromNodeId != null)
                {
                    INodeInstance enteringNodeInstance = (INodeInstance)wfElementInstanceMap[fromNodeId];
                    if (enteringNodeInstance != null)
                    {
                        enteringNodeInstance.AddLeavingTransitionInstance(transitionInstance);
                        transitionInstance.EnteringNodeInstance = enteringNodeInstance;
                    }
                }

                String toNodeId = transition.ToNode.Id;
                if (toNodeId != null)
                {
                    INodeInstance leavingNodeInstance = (INodeInstance)wfElementInstanceMap[toNodeId];
                    if (leavingNodeInstance != null)
                    {
                        leavingNodeInstance.AddEnteringTransitionInstance(transitionInstance);
                        transitionInstance.LeavingNodeInstance = leavingNodeInstance;
                    }
                }
                extensionList = kenelExtensions[transitionInstance.ExtensionTargetName];
                for (int j = 0; extensionList != null && j < extensionList.Count; j++)
                {
                    IKernelExtension extension = extensionList[j];
                    transitionInstance.registExtension(extension);
                }
                wfElementInstanceMap.Add(transitionInstance.Id, transitionInstance);
            }

            //循环线
            List <Loop> loops = workflowProcess.Loops;

            for (int i = 0; i < loops.Count; i++)
            {
                Loop         loop         = (Loop)loops[i];
                LoopInstance loopInstance = new LoopInstance(loop);

                String fromNodeId = loop.FromNode.Id;
                if (fromNodeId != null)
                {
                    INodeInstance enteringNodeInstance = (INodeInstance)wfElementInstanceMap[fromNodeId];
                    if (enteringNodeInstance != null)
                    {
                        enteringNodeInstance.AddLeavingLoopInstance(loopInstance);
                        loopInstance.EnteringNodeInstance = enteringNodeInstance;
                    }
                }

                String toNodeId = loop.ToNode.Id;
                if (toNodeId != null)
                {
                    INodeInstance leavingNodeInstance = (INodeInstance)wfElementInstanceMap[toNodeId];
                    if (leavingNodeInstance != null)
                    {
                        leavingNodeInstance.AddEnteringLoopInstance(loopInstance);
                        loopInstance.LeavingNodeInstance = leavingNodeInstance;
                    }
                }
                extensionList = kenelExtensions[loopInstance.ExtensionTargetName];
                for (int j = 0; extensionList != null && j < extensionList.Count; j++)
                {
                    IKernelExtension extension = extensionList[j];
                    loopInstance.registExtension(extension);
                }
                wfElementInstanceMap.Add(loopInstance.Id, loopInstance);
            }
        }
Exemplo n.º 21
0
        /// <summary>通过ID查找该流程中的任意元素</summary>
        /// <param name="id">元素的Id</param>
        /// <returns>流程元素,如:Activity,Task,Synchronizer等等</returns>
        public IWFElement findWFElementById(String id)
        {
            if (this.Id.Equals(id))
            {
                return(this);
            }

            List <Task> tasksList = this.Tasks;

            for (int i = 0; i < tasksList.Count; i++)
            {
                Task task = (Task)tasksList[i];
                if (task.Id.Equals(id))
                {
                    return(task);
                }
            }

            List <Activity> activityList = this.Activities;

            for (int i = 0; i < activityList.Count; i++)
            {
                Activity activity = activityList[i];
                if (activity.Id.Equals(id))
                {
                    return(activity);
                }
                List <Task> taskList = activity.getTasks();
                for (int j = 0; j < taskList.Count; j++)
                {
                    Task task = taskList[j];
                    if (task.Id.Equals(id))
                    {
                        return(task);
                    }
                }
            }
            if (this.StartNode.Id.Equals(id))
            {
                return(this.StartNode);
            }
            List <Synchronizer> synchronizerList = this.Synchronizers;

            for (int i = 0; i < synchronizerList.Count; i++)
            {
                Synchronizer synchronizer = synchronizerList[i];
                if (synchronizer.Id.Equals(id))
                {
                    return(synchronizer);
                }
            }

            List <EndNode> endNodeList = this.EndNodes;

            for (int i = 0; i < endNodeList.Count; i++)
            {
                EndNode endNode = endNodeList[i];
                if (endNode.Id.Equals(id))
                {
                    return(endNode);
                }
            }

            List <Transition> transitionList = this.Transitions;

            for (int i = 0; i < transitionList.Count; i++)
            {
                Transition transition = transitionList[i];
                if (transition.Id.Equals(id))
                {
                    return(transition);
                }
            }

            List <DataField> dataFieldList = this.DataFields;

            for (int i = 0; i < dataFieldList.Count; i++)
            {
                DataField dataField = dataFieldList[i];
                if (dataField.Id.Equals(id))
                {
                    return(dataField);
                }
            }

            List <Loop> loopList = this.Loops;

            for (int i = 0; i < loopList.Count; i++)
            {
                Loop loop = loopList[i];
                if (loop.Id.Equals(id))
                {
                    return(loop);
                }
            }
            return(null);
        }
Exemplo n.º 22
0
        /// <summary>验证workflow process是否完整正确。</summary>
        /// <returns>null表示流程正确;否则表示流程错误,返回值是错误原因</returns>
        public String validate()
        {
            String errHead = "Workflow process is invalid:";

            if (this.StartNode == null)
            {
                return(errHead + "must have one start node");
            }
            if (this.StartNode.LeavingTransitions.Count == 0)
            {
                return(errHead + "start node must have leaving transitions.");
            }


            List <Activity> activities = this.Activities;

            for (int i = 0; i < activities.Count; i++)
            {
                Activity activity = activities[i];
                String   theName  = (String.IsNullOrEmpty(activity.DisplayName)) ? activity.Name : activity.DisplayName;
                if (activity.EnteringTransition == null)
                {
                    return(errHead + "activity[" + theName + "] must have entering transition.");
                }
                if (activity.LeavingTransition == null)
                {
                    return(errHead + "activity[" + theName + "] must have leaving transition.");
                }

                //check tasks
                List <Task> taskList = activity.getTasks();
                for (int j = 0; j < taskList.Count; j++)
                {
                    Task task = (Task)taskList[j];
                    if (task.TaskType == TaskTypeEnum.FORM)
                    {
                        FormTask formTask = (FormTask)task;
                        if (formTask.Performer == null)
                        {
                            return(errHead + "FORM-task[id=" + task.Id + "] must has a performer.");
                        }
                    }
                    else if (task.TaskType == TaskTypeEnum.TOOL)
                    {
                        ToolTask toolTask = (ToolTask)task;
                        if (toolTask.Application == null)
                        {
                            return(errHead + "TOOL-task[id=" + task.Id + "] must has a application.");
                        }
                    }
                    else if (task.TaskType == TaskTypeEnum.SUBFLOW)
                    {
                        SubflowTask subflowTask = (SubflowTask)task;
                        if (subflowTask.SubWorkflowProcess == null)
                        {
                            return(errHead + "SUBFLOW-task[id=" + task.Id + "] must has a subflow.");
                        }
                    }
                    else
                    {
                        return(errHead + " unknown task type of task[" + task.Id + "]");
                    }
                }
            }

            List <Synchronizer> synchronizers = this.Synchronizers;

            for (int i = 0; i < synchronizers.Count; i++)
            {
                Synchronizer synchronizer = synchronizers[i];
                String       theName      = (synchronizer.DisplayName == null || synchronizer.DisplayName.Equals("")) ? synchronizer.Name : synchronizer.DisplayName;
                if (synchronizer.EnteringTransitions.Count == 0)
                {
                    return(errHead + "synchronizer[" + theName + "] must have entering transition.");
                }
                if (synchronizer.LeavingTransitions.Count == 0)
                {
                    return(errHead + "synchronizer[" + theName + "] must have leaving transition.");
                }
            }

            List <EndNode> endnodes = this.EndNodes;

            for (int i = 0; i < endnodes.Count; i++)
            {
                EndNode endnode = endnodes[i];
                String  theName = (endnode.DisplayName == null || endnode.DisplayName.Equals("")) ? endnode.Name : endnode.DisplayName;
                if (endnode.EnteringTransitions.Count == 0)
                {
                    return(errHead + "end node[" + theName + "] must have entering transition.");
                }
            }

            List <Transition> transitions = this.Transitions;

            for (int i = 0; i < transitions.Count; i++)
            {
                Transition transition = transitions[i];
                String     theName    = (transition.DisplayName == null || transition.DisplayName.Equals("")) ? transition.Name : transition.DisplayName;
                if (transition.FromNode == null)
                {
                    return(errHead + "transition[" + theName + "] must have from node.");
                }
                if (transition.ToNode == null)
                {
                    return(errHead + "transition[" + theName + "] must have to node.");
                }
            }

            //check datafield 不再需要 DataType不肯能为空
            //List<DataField> dataFieldList = this.DataFields;
            //for (int i = 0; i < dataFieldList.Count; i++)
            //{
            //    DataField df = dataFieldList[i];
            //    if (df.DataType == DataTypeEnum. null)
            //    {
            //        return errHead + "unknown data type of datafield[" + df.Id + "]";
            //    }
            //}

            return(null);
        }
Exemplo n.º 23
0
 public string ToString()
 {
     Length = this.computeLength();
     return(String.Format("Edge {0}-{1} has {2} length", StartNode.ToString(), EndNode.ToString(), Length));
 }
Exemplo n.º 24
0
 public override string ToString()
 {
     return(String.Format("Beam StartNode=({0}), EndNode=({1})", StartNode.ToString(), EndNode.ToString()));
 }
Exemplo n.º 25
0
        public SampleDocumentApprovalWorkflow()
        {
            context = new SampleDocumentApprovalWorkflowContext();
            var startNode        = new StartNode(context, "BEGIN");
            var approvalNode     = new DoApprovalNode(context, "IN_APPROVAL");
            var postApprovalNode = new PostApprovalNode(context, "POST_APPROVAL");
            var finalNode        = new EndNode(context, "FINISHED");

            Initialize(startNode);

            AddTransition(startNode, approvalNode,
                          () =>
            {
                var currentContext = context as SampleDocumentApprovalWorkflowContext;
                if (currentContext == null)
                {
                    return(false);
                }

                return(currentContext.ApprovalState == APPROVAL_STATE.UNAPPROVED);
            },
                          () =>
            {
                Console.WriteLine("Going forward to approval state.");
                Console.WriteLine("Sent e-mail to manager.");

                context.SetValueForProperty <APPROVAL_STATE>("ApprovalState", APPROVAL_STATE.IN_PROGRESS);
            }
                          );

            AddTransition(approvalNode, postApprovalNode,
                          () =>
            {
                string decision = context.GetValueForProperty <string>("Decision");
                var state       = context.GetValueForProperty <APPROVAL_STATE>("ApprovalState");

                return(decision == "approve" && state == APPROVAL_STATE.IN_PROGRESS);
            },
                          () =>
            {
                Console.WriteLine("Finishing approval workflow.");
            }
                          );

            AddTransition(postApprovalNode, finalNode,
                          () => true,
                          () =>
            {
                context.SetValueForProperty <APPROVAL_STATE>("ApprovalState", APPROVAL_STATE.APPROVED);
            }
                          );

            AddTransition(approvalNode, startNode,
                          () =>
            {
                string decision = context.GetValueForProperty <string>("Decision");
                var state       = context.GetValueForProperty <APPROVAL_STATE>("ApprovalState");

                return(decision == "decline" && state == APPROVAL_STATE.IN_PROGRESS);
            },
                          () =>
            {
                context.SetValueForProperty <string>("Decision", null);
                context.SetValueForProperty <APPROVAL_STATE>("ApprovalState", APPROVAL_STATE.UNAPPROVED);

                Console.WriteLine("Moving back to initial state.");
            }
                          );
        }
Exemplo n.º 26
0
    public void ReloadConversation(Object dragged)
    {
        /*  BaseNode selNode = windows[0];
         * windows.RemoveAt(0);
         *
         * foreach (BaseNode n in windows)
         * {
         *    n.NodeDeleted(selNode);
         * }*/

        BaseScriptableObject dialogue = (BaseScriptableObject)dragged;
        BaseInputNode        lastDiag;

        Dialogue  start     = (Dialogue)dialogue;
        StartNode startNode = (StartNode)windows[0];

        startNode.windowRect = start.windowPos;
        lastDiag             = startNode;
        BaseScriptableObject lastDiagScriptObj = start;


        while (dialogue.next != null)
        {
            ScriptToDelete.Add(dialogue);

            if (dialogue is Dialogue)
            {
                Dialogue npcDialogue = (Dialogue)dialogue;

                if (!npcDialogue.start)
                {
                    DialogueNode newNode = new DialogueNode();
                    newNode.windowRect = npcDialogue.windowPos;
                    newNode.text       = npcDialogue.dialogue;
                    newNode.hasInput   = true;
                    newNode.input1     = lastDiag;
                    newNode.input1Rect = lastDiag.windowRect;
                    lastDiag           = newNode;
                    windows.Add(newNode);
                }

                // dialogue = dialogue.next;
            }
            else if (dialogue is EventDialogue)
            {
                EventDialogue npcDialogue = (EventDialogue)dialogue;
                EventNode     newNode     = new EventNode();
                newNode.windowRect = npcDialogue.windowPos;
                newNode.text       = npcDialogue.dialogue;
                newNode.reward     = npcDialogue.rewardToRecieve;
                if (newNode.reward == DialogueEventType.EventReward.gold)
                {
                    newNode.gold = npcDialogue.goldOrHp;
                }
                else if (newNode.reward == DialogueEventType.EventReward.life)
                {
                    newNode.healthPoints = npcDialogue.goldOrHp;
                }
                else
                {
                    newNode.itemId = npcDialogue.item;
                }

                newNode.hasInput   = true;
                newNode.input1     = lastDiag;
                newNode.input1Rect = lastDiag.windowRect;
                lastDiag           = newNode;
                windows.Add(newNode);
            }
            else if (dialogue is DiceDialogue)
            {
                DiceDialogue diceRoll = (DiceDialogue)dialogue;
                DiceRollNode newNode  = new DiceRollNode();
                newNode.windowRect = diceRoll.windowPos;
                newNode.rollType   = diceRoll.roll;
                newNode.difficulty = diceRoll.difficulty;
                newNode.hasInput   = true;
                newNode.input1     = lastDiag;
                newNode.input1Rect = lastDiag.windowRect;
                //BaseScriptableObject endObj = diceRoll.fail;
                EndNode newEnd = new EndNode();
                newEnd.windowRect    = diceRoll.fail.windowPos;
                newEnd.finished      = diceRoll.fail.dialogue;
                newEnd.hasInput      = true;
                newEnd.inputNode     = newNode;
                newEnd.inputNodeRect = newNode.windowRect;
                ScriptToDelete.Add(diceRoll.fail);
                lastDiag = newNode;
                windows.Add(newNode);
                windows.Add(newEnd);
            }

            lastDiagScriptObj = dialogue;
            Debug.Log("asdasd");
            dialogue = dialogue.next;
        }
        EndNode lastEnd = new EndNode();

        lastEnd.windowRect    = lastDiagScriptObj.next.windowPos;
        lastEnd.finished      = lastDiagScriptObj.next.dialogue;
        lastEnd.hasInput      = true;
        lastEnd.inputNode     = lastDiag;
        lastEnd.inputNodeRect = lastDiag.windowRect;
        ScriptToDelete.Add(lastDiagScriptObj.next);
        windows.Add(lastEnd);
        Debug.Log("ultimo alcanzado");
        Repaint();
    }
Exemplo n.º 27
0
    public EndNode CreateEndNode(Vector2 _pos)
    {
        EndNode tmp = new EndNode(_pos, dialogueGraph, this);

        return(tmp);
    }
Exemplo n.º 28
0
        public void TimerEventScenario(int s)
        {
            var startNode = new StartNode("1. Submit");
            var n2 = new TimerNode("2. Wait 2 seconds", new TimeSpan(0, 0, s));
            var endNode = new EndNode("3. Closed");
            var t12 = new SequenceFlow(startNode, n2);
            var t23 = new SequenceFlow(n2, endNode);

            this.process = new Process(startNode);
        }
Exemplo n.º 29
0
    //Dibuja los botones propios de la ventana del editor
    private void DrawButtons()
    {
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add Start"))
        {
            foreach (var item in windows)
            {
                //TIRA ERROR
                //if (item.GetType().Equals(typeof(StartNode))) {
                //    return;
                //}
                if (item.windowTittle == "Start")
                {
                    return;
                }
                StartNode startNode = new StartNode();
                startNode.windowRect = new Rect(50, 100, 200, 50);
                windows.Add(startNode);
            }
        }
        if (GUILayout.Button("Add Dialogue"))
        {
            DialogueNode dialogueNode = new DialogueNode();
            dialogueNode.windowRect = new Rect(200, 100, 200, 150);
            windows.Add(dialogueNode);
        }
        if (GUILayout.Button("Add Choice"))
        {
            ChoiceNode choiceNode = new ChoiceNode();
            choiceNode.windowRect = new Rect(400, 100, 200, 150);
            windows.Add(choiceNode);
        }
        if (GUILayout.Button("Add Roll"))
        {
            DiceRollNode diceRollNode = new DiceRollNode();
            diceRollNode.windowRect = new Rect(600, 100, 200, 150);
            windows.Add(diceRollNode);
        }
        if (GUILayout.Button("Add Event"))
        {
            EventNode eventNode = new EventNode();
            eventNode.windowRect = new Rect(800, 100, 200, 150);
            windows.Add(eventNode);
        }
        if (GUILayout.Button("Add End"))
        {
            EndNode endNode = new EndNode();
            endNode.windowRect = new Rect(1000, 100, 200, 50);
            windows.Add(endNode);
        }
        EditorGUILayout.EndHorizontal();

        if (GUILayout.Button("Generate Conversation"))
        {
            if (ScriptToDelete.Count > 0)
            {
                EraseScriptObj();
            }
            SaveConversation();
        }
    }
Exemplo n.º 30
0
    private void GenerateNodes(DialogueContainerSO _dialogueContainer)
    {
        // Start Node
        foreach (StartNodeData node in _dialogueContainer.StartNodeData)
        {
            StartNode tempNode = graphView.CreateStartNode(node.Position);
            tempNode.NodeGuid   = node.NodeGuid;
            tempNode.DialogueID = node.dialogueID;

            graphView.AddElement(tempNode);
        }

        // End Node
        foreach (EndNodeData node in _dialogueContainer.EndNodeData)
        {
            EndNode tempNode = graphView.CreateEndNode(node.Position);
            tempNode.NodeGuid    = node.NodeGuid;
            tempNode.EndNodeType = node.EndNodeType;

            graphView.AddElement(tempNode);
        }

        // Event Node
        foreach (EventNodeData node in _dialogueContainer.EventNodeData)
        {
            EventNode tempNode = graphView.CreateEventNode(node.Position);
            tempNode.NodeGuid      = node.NodeGuid;
            tempNode.DialogueEvent = node.DialogueEventSO;

            graphView.AddElement(tempNode);
        }

        // Dialogue Node
        foreach (DialogueNodeData node in _dialogueContainer.DialogueNodeData)
        {
            DialogueNode tempNode = graphView.CreateDialogueNode(node.Position);
            tempNode.NodeGuid = node.NodeGuid;
            tempNode.Name     = node.Name;
            //tempNode.Texts = node.TextType;
            tempNode.FaceImage     = node.Sprite;
            tempNode.BackGround    = node.Background;
            tempNode.FaceImageType = node.DialogueFaceImageType;
            //tempNode.AudioClips = node.AudioClips;

            foreach (LanguageGeneric <string> languageGeneric in node.TextType)
            {
                tempNode.Texts.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
            }

            foreach (LanguageGeneric <AudioClip> languageGeneric in node.AudioClips)
            {
                tempNode.AudioClips.Find(language => language.LanguageType == languageGeneric.LanguageType).LanguageGenericType = languageGeneric.LanguageGenericType;
            }

            foreach (DialogueNodePort nodePort in node.DialogueNodePorts)
            {
                tempNode.AddChoicePort(tempNode, nodePort);
            }

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }


        // Script Node
        foreach (ScriptNodeData node in _dialogueContainer.ScriptNodeData)
        {
            ScriptNode tempNode = graphView.CreateScriptNode(node.Position);
            tempNode.NodeGuid      = node.NodeGuid;
            tempNode.scriptType    = node.scriptNodeType;
            tempNode.reqScriptType = node.reqNodeType;

            foreach (ScriptNodePort scriptNodePort in node.scriptNodePorts)
            {
                tempNode.AddRequirement(tempNode, scriptNodePort);
                tempNode.ScriptText = node.scriptTexts;
                tempNode.ResultText = node.resultTexts;
            }

            tempNode.LoadValueInToField();
            graphView.AddElement(tempNode);
        }
    }
Exemplo n.º 31
0
    //Contiene las funciones para las opciones del menu contextual
    void ContextCallBack(object obj)
    {
        string clb = obj.ToString();

        if (clb.Equals("startNode"))
        {
            foreach (var item in windows)
            {
                //TIRA ERROR
                //if (item.GetType().Equals(typeof(StartNode))) {
                //    return;
                //}
                if (item.windowTittle == "Start")
                {
                    return;
                }
                StartNode startNode = new StartNode();
                startNode.windowRect = new Rect(mousePos.x, mousePos.y, 200, 50);
                windows.Add(startNode);
            }
        }
        if (clb.Equals("dialogueNode"))
        {
            DialogueNode dialogueNode = new DialogueNode();
            dialogueNode.windowRect = new Rect(mousePos.x, mousePos.y, 200, 150);
            windows.Add(dialogueNode);
        }
        if (clb.Equals("choiceNode"))
        {
            ChoiceNode choiceNode = new ChoiceNode();
            choiceNode.windowRect = new Rect(mousePos.x, mousePos.y, 200, 150);
            windows.Add(choiceNode);
        }
        if (clb.Equals("eventNode"))
        {
            EventNode eventNode = new EventNode();
            eventNode.windowRect = new Rect(mousePos.x, mousePos.y, 200, 150);
            windows.Add(eventNode);
        }
        if (clb.Equals("diceRollNode"))
        {
            DiceRollNode diceRollNode = new DiceRollNode();
            diceRollNode.windowRect = new Rect(mousePos.x, mousePos.y, 200, 150);
            windows.Add(diceRollNode);
        }
        if (clb.Equals("endNode"))
        {
            EndNode endNode = new EndNode();
            endNode.windowRect = new Rect(mousePos.x, mousePos.y, 200, 50);
            windows.Add(endNode);
        }
        else if (clb.Equals("makeTransition"))
        {
            bool clickedOnWindow = false;
            int  selectIndex     = -1;

            for (int i = 0; i < windows.Count; i++)
            {
                if (windows[i].windowRect.Contains(mousePos))
                {
                    selectIndex     = i;
                    clickedOnWindow = true;
                    break;
                }
            }
            if (clickedOnWindow)
            {
                selectedNode       = windows[selectIndex];
                makeTransitionMode = true;
            }
        }
        else if (clb.Equals("deleteNode"))
        {
            bool clickedOnWindow = false;
            int  selectIndex     = -1;

            for (int i = 0; i < windows.Count; i++)
            {
                if (windows[i].windowRect.Contains(mousePos))
                {
                    selectIndex     = i;
                    clickedOnWindow = true;
                    break;
                }
            }
            if (clickedOnWindow)
            {
                BaseNode selNode = windows[selectIndex];
                windows.RemoveAt(selectIndex);

                foreach (BaseNode n in windows)
                {
                    n.NodeDeleted(selNode);
                }
            }
        }
    }
Exemplo n.º 32
0
        // Spawning EndNode
        public EndNode CreateEndNode(Vector2 pos)
        {
            EndNode tmp = new EndNode(pos, editorWindow, this);

            return(tmp);
        }
Exemplo n.º 33
0
    private void SaveConversation()
    {
        BaseScriptableObject lastNode = null;

        for (int i = 0; i < windows.Count; i++)

        {
            if (windows[i] is StartNode)
            {
                StartNode nodeNew = (StartNode)windows[i];
                Dialogue  start   = ScriptableObjectUtility.CreateAsset <Dialogue>();
                //start.name = "Start";
                start.start     = true;
                start.windowPos = nodeNew.windowRect;
                lastNode        = start;
                ScriptToDelete.Add((BaseScriptableObject)start);
            }
            if (windows[i] is DialogueNode)
            {
                DialogueNode nodeNew     = (DialogueNode)windows[i];
                Dialogue     npcDialogue = ScriptableObjectUtility.CreateAsset <Dialogue>();
                npcDialogue.dialogue  = nodeNew.text;
                npcDialogue.windowPos = nodeNew.windowRect;
                if (lastNode != null)
                {
                    lastNode.next = npcDialogue;
                }
                lastNode = npcDialogue;
                ScriptToDelete.Add((BaseScriptableObject)npcDialogue);
            }
            if (windows[i] is EventNode)
            {
                EventNode     nodeNew     = (EventNode)windows[i];
                EventDialogue npcDialogue = ScriptableObjectUtility.CreateAsset <EventDialogue>();
                npcDialogue.dialogue        = nodeNew.text;
                npcDialogue.rewardToRecieve = nodeNew.reward;
                if (nodeNew.healthPoints != 0)
                {
                    npcDialogue.goldOrHp = nodeNew.healthPoints;
                }
                else if (nodeNew.gold != 0)
                {
                    npcDialogue.goldOrHp = nodeNew.gold;
                }
                else
                {
                    npcDialogue.item = nodeNew.itemId;
                }

                npcDialogue.windowPos = nodeNew.windowRect;

                if (lastNode != null)
                {
                    lastNode.next = npcDialogue;
                }
                lastNode = npcDialogue;

                ScriptToDelete.Add((BaseScriptableObject)npcDialogue);
            }
            if (windows[i] is EndNode)
            {
                EndNode endNode          = (EndNode)windows[i];
                BaseScriptableObject end = ScriptableObjectUtility.CreateAsset <BaseScriptableObject>();
                //end.name = "End";
                end.dialogue  = "Finished";
                end.windowPos = endNode.windowRect;
                lastNode.next = end;
                //lastNode = end;
                ScriptToDelete.Add((BaseScriptableObject)end);
            }
            if (windows[i] is DiceRollNode)
            {
                DiceRollNode nodeNew     = (DiceRollNode)windows[i];
                DiceDialogue npcDialogue = ScriptableObjectUtility.CreateAsset <DiceDialogue>();
                npcDialogue.roll       = nodeNew.rollType;
                npcDialogue.difficulty = nodeNew.difficulty;
                npcDialogue.windowPos  = nodeNew.windowRect;
                ScriptToDelete.Add((BaseScriptableObject)npcDialogue);
                if (lastNode != null)
                {
                    lastNode.next = npcDialogue;
                }
                i++;
                EndNode endNode          = (EndNode)windows[i];
                BaseScriptableObject end = ScriptableObjectUtility.CreateAsset <BaseScriptableObject>();
                //end.name = "End";
                end.dialogue     = endNode.finished;
                end.windowPos    = endNode.windowRect;
                npcDialogue.fail = end;
                lastNode         = npcDialogue;
                ScriptToDelete.Add((BaseScriptableObject)end);
            }
        }
    }
Exemplo n.º 34
0
 public override string ToString()
 {
     return(String.Format("\nEdge {0}({1}-{2}) has {3} length", ID, StartNode.getID(), EndNode.getID(), computeLength()));
 }
Exemplo n.º 35
0
        /// <summary>
        /// Adjusts the end points position to an optimal position
        /// (when their <see cref="DragThumb.Placement"/> is set
        /// to <see cref="EPlacementKind.ParentAutoPos"/>).
        /// </summary>
        public bool AdjustEndPoints()
        {
#if SILVERLIGHT
            if (StartNode != null && !sourceMeasureValid)
            {
                sourceMeasureValid = StartNode.GetBounds().Width != 0;
            }
            if (EndNode != null && !targetMeasureValid)
            {
                targetMeasureValid = EndNode.GetBounds().Width != 0;
            }
#endif
            // StartNode and EndNode now can be null to allow disconnected connector points
            if (StartNode != null && !StartNode.IsMeasureValid)
            {
                return(false);
            }
            if (EndNode != null && !EndNode.IsMeasureValid)
            {
                return(false);
            }

            if (StartPoint == null || EndPoint == null ||
                !targetMeasureValid || !sourceMeasureValid)
            {
                return(false);
            }

            #region set source junctionEnd position

            double angle = StartNode != null ? StartNode.BoundsAngle : 0;

            if (StartPoint.Placement == EPlacementKind.AbsoluteSubCanvas)
            {
                Point snappedStart = StartNode.GetBounds().Normalize().SnapPointToRectangle(StartPoint.Position);
                if (snappedStart != StartPoint.Position)
                {
                    StartPoint.SetPreferedPosition(snappedStart);
                }
            }

            if (AutoPosModeOnly && StartPoint.Placement != EPlacementKind.ParentAutoPos)
            {
                StartPoint.Placement = EPlacementKind.ParentAutoPos;
            }

            // Condition removed to allow disconnected connector points
            //if (StartNode.IsMeasureValid /*&& (viewHelperPointsCollection == null || Points.Count == viewHelperPointsCollection.Count)*/
            //    /*&& (StartPoint.Placement == EPlacementKind.ParentAutoPos || viewHelperPointsCollection == null || viewHelperPointsCollection.PointsInvalid)*/)
            {
                Rect r1 = GeometryHelper.GetFirstElementBounds(this);
                Rect r2 = GeometryHelper.GetFirstButOneElementBounds(this);

                Point p1 = GeometryHelper.RectangleRectangleCenterIntersection(r1, r2, true, angle);

                if (StartPoint.Placement != EPlacementKind.ParentAutoPos && StartPoint.Position.AlmostEqual(p1) && !((IDraggable)StartPoint).DragThumb.IsDragged)
                {
                    StartPoint.Placement = EPlacementKind.ParentAutoPos;
                }

                if (StartPoint.Placement == EPlacementKind.ParentAutoPos)
                { // simplified to this..
                    StartPoint.SetPreferedPosition(p1);
                }

                //if (viewHelperPointsCollection == null)
                //{
                //    StartPoint.SetPreferedPosition(p1);
                //}
                //else if (!viewHelperPointsCollection.First().AlmostEqual(p1))
                //{
                //    if (viewHelperPointsCollection.PointsInvalid)
                //    {
                //        viewHelperPointsCollection[0].Set(p1);
                //        StartPoint.SetPreferedPosition(p1);
                //        viewHelperPointsCollection.PointsInvalid = false;
                //    }
                //    else
                //    {
                //        if (!sourceMeasureValid)
                //        {
                //            if (p1 != StartPoint.Position)
                //            {
                //                if (!AutoPosModeOnly)
                //                {
                //                    StartPoint.Placement = EPlacementKind.AbsoluteSubCanvas;
                //                    Point snapped = r1.Normalize().SnapPointToRectangle(StartPoint.Position);
                //                    if (snapped != StartPoint.Position)
                //                        StartPoint.SetPreferedPosition(snapped);
                //                }
                //            }
                //        }
                //        else
                //        {
                //            viewHelperPointsCollection[0].Set(p1);
                //            StartPoint.SetPreferedPosition(p1);
                //        }
                //    }
                //}
                //else
                //{
                //    StartPoint.SetPreferedPosition(p1);
                //    StartPoint.Placement = EPlacementKind.ParentAutoPos;
                //}
                sourceMeasureValid = true;
            }

            #endregion

            #region set end junctionEnd position

            if (EndPoint.Placement == EPlacementKind.AbsoluteSubCanvas)
            {
                Point snappedEnd = EndNode.GetBounds().Normalize().SnapPointToRectangle(EndPoint.Position);
                if (snappedEnd != EndPoint.Position)
                {
                    EndPoint.SetPreferedPosition(snappedEnd);
                }
            }


            angle = EndNode != null ? EndNode.BoundsAngle : 0;
            if (AutoPosModeOnly && EndPoint.Placement != EPlacementKind.ParentAutoPos)
            {
                EndPoint.Placement = EPlacementKind.ParentAutoPos;
            }

            // Condition removed to allow disconnected connector points
            //if (EndNode.IsMeasureValid /*&& (viewHelperPointsCollection == null || Points.Count == viewHelperPointsCollection.Count)*/
            //    /*&& (EndPoint.Placement == EPlacementKind.ParentAutoPos || viewHelperPointsCollection == null || viewHelperPointsCollection.PointsInvalid)*/)
            {
                Rect r1 = GeometryHelper.GetLastElementBounds(this);
                Rect r2 = GeometryHelper.GetLastButOneElementBounds(this);

                Point p2 = GeometryHelper.RectangleRectangleCenterIntersection(r1, r2, true, angle);


                if (EndPoint.Placement != EPlacementKind.ParentAutoPos && EndPoint.Position.AlmostEqual(p2) && !((IDraggable)EndPoint).DragThumb.IsDragged)
                {
                    EndPoint.Placement = EPlacementKind.ParentAutoPos;
                }

                if (EndPoint.Placement == EPlacementKind.ParentAutoPos)
                { // simplified to this..
                    EndPoint.SetPreferedPosition(p2);
                }

                //if (viewHelperPointsCollection == null)
                //{
                //    EndPoint.SetPreferedPosition(p2);
                //}
                //else if (!viewHelperPointsCollection.Last().AlmostEqual(p2))
                //{
                //    if (viewHelperPointsCollection.PointsInvalid)
                //    {
                //        viewHelperPointsCollection.Last().Set(p2);
                //        EndPoint.SetPreferedPosition(p2);
                //        viewHelperPointsCollection.PointsInvalid = false;
                //    }
                //    else
                //    {
                //        if (!targetMeasureValid)
                //        {
                //            if (p2 != EndPoint.Position)
                //            {
                //                EndPoint.Placement = EPlacementKind.AbsoluteSubCanvas;
                //                Point snapped = r1.Normalize().SnapPointToRectangle(EndPoint.Position);
                //                if (snapped != EndPoint.Position)
                //                    EndPoint.SetPreferedPosition(snapped);
                //            }
                //        }
                //        else
                //        {
                //            viewHelperPointsCollection.Last().Set(p2);
                //            EndPoint.SetPreferedPosition(p2);
                //        }
                //    }
                //}
                //else
                //{
                //    EndPoint.SetPreferedPosition(p2);
                //    EndPoint.Placement = EPlacementKind.ParentAutoPos;
                //}
                targetMeasureValid = true;
            }

            #endregion

            return(true);
        }