コード例 #1
0
        public RakunModuleViewModel(RakunNodeBase Module, RakunViewerUserControl _View, ModuleView _Root)
        {
            ModuleInfo = Module.Clone() as RakunNodeBase;
            Parent     = _View;
            Root       = _Root;
            if (Module.NodeType == RakunNodeBase.RakunNodeType.For)
            {
                _ModuleValues.Add(new RakunValueNodeViewModel(new RakunNode()
                {
                    NodeName = "index", type = RakunType.ValueName
                }, Root, _View, this));
            }

            if (Module.NodeType == RakunNodeBase.RakunNodeType.If)
            {
                //_ModuleValues.Add(new RakunValueNodeViewModel(new RakunNode() { NodeName = "Condition", type = RakunType.ValueName }, Root, _View, this));
            }

            if (ModuleInfo.rootNode != null)
            {
                foreach (RakunNode node in ModuleInfo.rootNode.Rakunlist)
                {
                    _ModuleValues.Add(new RakunValueNodeViewModel(node, Root, _View, this));
                }
            }
        }
コード例 #2
0
        public static RakunNodeBase SumbNode(RakunNodeBase c1original, RakunModuleViewModel c2mother)
        {
            if (c2mother == null)
            {
                return(c1original.Clone() as RakunNodeBase);
            }

            RakunNodeBase c1 = c1original.Clone() as RakunNodeBase;

            RakunNodeBase c2 = c2mother.ModuleInfo.Clone() as RakunNodeBase;

            //값 대입하기
            addbefore(ref c2mother, ref c1);

            //합성하기
            //근데 IF노드일경우 조금 다름
            if (c2mother.ModuleInfo.NodeType == RakunNodeBase.RakunNodeType.If)
            {
                RakunNodeBase TResualt = new RakunNodeBase();
                {
                    //True일경우
                    RakunModuleViewModel itorNode = c2mother.TrueNode;


                    //연결된  시퀀스가 있으면
                    while (itorNode != null)
                    {
                        addbefore(ref itorNode, ref TResualt);
                        //다더함
                        TResualt = (TResualt + itorNode.ModuleInfo).Clone() as RakunNodeBase;
                        addAfter(ref itorNode, ref TResualt);
                        itorNode = itorNode.Next;
                    }
                }

                RakunNodeBase FResualt = new RakunNodeBase();
                {
                    RakunModuleViewModel itorNode = c2mother.FalseNode;

                    //연결된  시퀀스가 있으면
                    while (itorNode != null)
                    {
                        addbefore(ref itorNode, ref FResualt);
                        //다더함
                        FResualt = (FResualt + itorNode.ModuleInfo).Clone() as RakunNodeBase;
                        addAfter(ref itorNode, ref FResualt);
                        itorNode = itorNode.Next;
                    }
                }

                RakunNodeIf ifnode = c2 as RakunNodeIf;
                ifnode.AddIfTrue(TResualt, FResualt);
            }

            //값 대입하기
            addAfter(ref c2mother, ref c2);

            return(c1 + c2);
        }
コード例 #3
0
        public RakunModuleViewModel AddModule(RakunNodeBase Module)
        {
            ModuleView           myButton = new ModuleView();
            RakunModuleViewModel NewVM    = new RakunModuleViewModel(Module, View, myButton);

            NewVM.SetMother(NewVM);
            _Modules.Add(NewVM);
            View.AddRakunNode(NewVM);
            NewVM.name = NewVM.ModuleInfo.ModuleName + "_" + _Modules.Count + "_";
            return(NewVM);
            //Workspace.This.StatusString = ModuleName + " Module Added";
        }
コード例 #4
0
        public string BuildArduino()
        {
            RakunModuleViewModel itorNode = startingNode;
            RakunNodeBase        Resualt  = new RakunNodeBase();

            while (itorNode != null)
            {
                Resualt  = RakunModuleViewModel.SumbNode(Resualt, itorNode).Clone() as RakunNodeBase;
                itorNode = itorNode.Next;
            }

            return(Resualt.Gen_C_Code());
        }
コード例 #5
0
        void RakunViewerUserControl_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers == ModifierKeys.Control)
            {
                if (e.Key == Key.C)
                {
                    if (CurrentSelect is ModuleView && CurrentSelect != null)
                    {
                        clip = (CurrentSelect.DataContext as RakunModuleViewModel)._ModuleInfo.Clone() as RakunNodeBase;
                    }
                }
                if (e.Key == Key.X)
                {
                    if (CurrentSelect is ModuleView && CurrentSelect != null)
                    {
                        clip = (CurrentSelect.DataContext as RakunModuleViewModel)._ModuleInfo.Clone() as RakunNodeBase;
                    }

                    if (CurrentSelect is ModuleView && CurrentSelect != null)
                    {
                        LayoutRoot.Children.Remove(CurrentSelect);
                        CurrentSelect = null;
                        CurrentSelectPosition.Visibility = System.Windows.Visibility.Hidden;
                    }
                }
                if (e.Key == Key.V)
                {
                    if (clip != null)
                    {
                        clip.OnAdd(null);
                    }
                }
                if (e.Key == Key.S)
                {
                    Workspace.This.ActiveDocument.OnSave(null);
                }
            }

            if (e.Key == Key.Delete)
            {
                if (CurrentSelect is ModuleView && CurrentSelect != null)
                {
                    LayoutRoot.Children.Remove(CurrentSelect);
                    CurrentSelect = null;
                    CurrentSelectPosition.Visibility = System.Windows.Visibility.Hidden;
                }
            }
        }
コード例 #6
0
        public static void addbefore(ref RakunModuleViewModel c2mother, ref RakunNodeBase c1)
        {
            foreach (RakunValueNodeViewModel node in c2mother.ModuleValues)
            {
                if (node.Input == null)
                {
                    continue;
                }

                if (node.Input.BeforePoint == null)
                {
                    continue;
                }

                RakunValueNodeViewModel ParentNode = node.Input.BeforePoint.ParentVM;

                if (ParentNode == null)
                {
                    if (node.Input.BeforePoint != null)
                    {
                        RakunModuleViewModel ParentNodeVM = node.Input.BeforePoint.ModuleVM;

                        RakunNodeInput inputf = Workspace.This.RakunManager.inputNode.Clone() as RakunNodeInput;

                        inputf.rootNode.replace(inputf.rootNode.loopfunction, "NUMBER", ParentNodeVM.input);
                        inputf.rootNode.replace(inputf.rootNode.loopfunction, "INPUTVALUE", node.ChangedName);
                        c1 = c1 + inputf;

                        //node.Input.BeforePoint.
                    }
                    continue;
                }


                RakunNodeInput input = Workspace.This.RakunManager.inputNode.Clone() as RakunNodeInput;
                input.rootNode.replace(input.rootNode.loopfunction, "NUMBER", ParentNode.ChangedName);
                input.rootNode.replace(input.rootNode.loopfunction, "INPUTVALUE", node.ChangedName);
                c1 = c1 + input;
            }
        }
コード例 #7
0
ファイル: RakunNodeIf.cs プロジェクト: gtpk/RakunStudio
        public RakunNodeBase AddIfTrue(RakunNodeBase truenode, RakunNodeBase falsenode)
        {
            RakunNodeBase output = this as RakunNodeBase;

            if (truenode.rootNode != null)
            {
                //foreach (RakunNode RNode in truenode._rootNode.Rakunlist)
                //{
                //    RakunNode.addFunctionDcelear(ref c1._rootNode.declaration_list, RNode.ValueDeclear, true, true);
                //    //break
                //}

                foreach (RakunNode RNode in truenode.rootNode.Rakunlist)
                {
                    RakunNode.addFunctionDcelear(ref output.rootNode.declaration_list, RNode.ValueDeclear, true, true);
                }
            }

            if (falsenode.rootNode != null)
            {
                foreach (RakunNode RNode in falsenode.rootNode.Rakunlist)
                {
                    RakunNode.addFunctionDcelear(ref output.rootNode.declaration_list, RNode.ValueDeclear, true, true);
                }
            }

            if (truenode.rootNode != null)
            {
                RakunNode.addForceFunctionDcelear(ref output.rootNode.setupfunction, truenode.rootNode.setupfunction);
                RakunNode.addForceFunctionDcelear(ref output.rootNode.IFTrueDeclear, truenode.rootNode.loopfunction);
            }

            if (falsenode.rootNode != null)
            {
                RakunNode.addForceFunctionDcelear(ref output.rootNode.setupfunction, falsenode.rootNode.setupfunction);
                RakunNode.addForceFunctionDcelear(ref output.rootNode.IFFalseDeclear, falsenode.rootNode.loopfunction);
            }

            return(output);//this.Append(this, output);
        }
コード例 #8
0
ファイル: RakunNodeStarting.cs プロジェクト: gtpk/RakunStudio
        public override RakunNodeBase Append(RakunNodeBase c1, RakunNodeBase c2)
        {
            RakunNodeBase output = (RakunNodeBase)c2.Clone();

            return(output);
        }