private void GotoPage(nint page)
        {
            if (page < Controllers.Count)
            {
                var frame = Scrollview.Frame;

                frame.X = page * frame.Size.Width;

                Scrollview.ScrollRectToVisible(frame, true);
            }
        }
        public void AddViewController(UIViewController vc)
        {
            Controllers.Add(vc);

            // Setup the viewController view
            vc.View.TranslatesAutoresizingMaskIntoConstraints = false;
            Scrollview.AddSubview(vc.View);

            var metridDict = new NSDictionary("w", vc.View.Bounds.Size.Width, "h", vc.View.Bounds.Size.Height);
            var viewDict   = new NSDictionary("view", vc.View);

            // Constraints

            // - Generic cnst
            vc.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[view(h)]", 0, metridDict, viewDict));
            vc.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[view(w)]", 0, metridDict, viewDict));
            Scrollview.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|-0-[view]|", 0, null, viewDict));

            // cnst for position: 1st element
            if (Controllers.Count == 1)
            {
                Scrollview.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|-0-[view]", 0, null, viewDict));
            }
            else
            {
                var previousVC   = Controllers[Controllers.Count - 2];
                var previousView = previousVC?.View;

                if (previousView != null)
                {
                    var prevDict = new NSDictionary("previousView", previousView, "view", vc.View);
                    Scrollview.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[previousView]-0-[view]", 0, null, prevDict));

                    if (lastViewConstraint != null)
                    {
                        Scrollview.RemoveConstraints(lastViewConstraint);
                    }

                    lastViewConstraint = NSLayoutConstraint.FromVisualFormat("H:[view]-0-|", 0, null, viewDict);
                    Scrollview.AddConstraints(lastViewConstraint);
                }
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (Delete_button != null)
            {
                Delete_button.Dispose();
                Delete_button = null;
            }

            if (Description_text != null)
            {
                Description_text.Dispose();
                Description_text = null;
            }

            if (loader != null)
            {
                loader.Dispose();
                loader = null;
            }

            if (MainUIView != null)
            {
                MainUIView.Dispose();
                MainUIView = null;
            }

            if (netWork_label != null)
            {
                netWork_label.Dispose();
                netWork_label = null;
            }

            if (Play != null)
            {
                Play.Dispose();
                Play = null;
            }

            if (recording != null)
            {
                recording.Dispose();
                recording = null;
            }

            if (Save_button != null)
            {
                Save_button.Dispose();
                Save_button = null;
            }

            if (saveLoader != null)
            {
                saveLoader.Dispose();
                saveLoader = null;
            }

            if (Scrollview != null)
            {
                Scrollview.Dispose();
                Scrollview = null;
            }

            if (Status_switch1 != null)
            {
                Status_switch1.Dispose();
                Status_switch1 = null;
            }

            if (Title_text != null)
            {
                Title_text.Dispose();
                Title_text = null;
            }
        }
Пример #4
0
        private void _initGUI()
        {
            this._scrollView             = new Scrollview(this, new Rect(10, 10, Screen.width - 20, Screen.height - 20), root, new Rect(0, 0, 4000, 4000));
            this._controllList           = new Scrollview(this, new Rect(0, 0, 100, Screen.height - 20), root, new Rect(0, 100, 100, 800));
            this._controllList.textureBg = null;
            root.AddChild(this._controllList);
            root.AddChild(this._scrollView);

            //btn save
            Vector2 ptStart = new Vector2(10, 10);
            Button  btnSave = new Button("保存", this, new Rect(ptStart.x, ptStart.y, 70, 32), this.root);

            btnSave.OnClick = new Button.ButtonDelegate(OnBtnSaveClick);
            root.AddChild(btnSave);

            //btn create
            Button btnCreate = new Button("新建", this, new Rect(ptStart.x + 100, ptStart.y, 70, 32), this.root);

            btnCreate.OnClick = new Button.ButtonDelegate(OnBtnCreateClick);
            root.AddChild(btnCreate);
            ptStart.y += 32 + 15;


            //ddl projects
            string[] directoryEntries = System.IO.Directory.GetFileSystemEntries("Assets/Editor/BTEditor/Projects");
            foreach (string str in directoryEntries)
            {
                if (str.EndsWith(".json"))
                {
                    this._lstProjects.Add(str);
                }
            }

            if (this._lstProjects.Count > 0)
            {
                Rect rcDDL = new Rect(ptStart.x, ptStart.y, 180, 20);
                DropdownList <string> ddlProj = new DropdownList <string>(this, rcDDL, root, this._lstProjects, 0);
                ddlProj.OnSelectChange = new DropdownList <string> .DropDownListDelegate(OnSelProjChange);

                root.AddChild(ddlProj);
                ptStart.y += 20 + 2;
            }


            //file name
            Rect rcLable = new Rect(ptStart.x, ptStart.y, 50, 20);

            root.AddChild(new Label("文件名:", this, rcLable, root));

            Rect rcFileName = new Rect(ptStart.x + 50, ptStart.y, 130, 20);

            this._tfFileName = new Textfield("", this, rcFileName, root);
            root.AddChild(this._tfFileName);
            ptStart.y += 20 + 5;

            //agent category
            Rect rcAgent = new Rect(ptStart.x, ptStart.y, 50, 20);

            root.AddChild(new Label("Agent:", this, rcAgent, root));

            Rect rcDDLAgent = new Rect(ptStart.x + 50, ptStart.y, 100, 20);

            this.DDLAgent = new DropdownList <string>(this, rcDDLAgent, root, this._lstAgents, 0);
            root.AddChild(this.DDLAgent);
            ptStart.y += 20 + 15;

            //load firest proj
            if (this._lstProjects.Count > 0)
            {
                string firstCfg = this._lstProjects[0];
                this._loadProject(firstCfg);
            }

            //entry
            Button btnEntry = new Button("入口节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnEntry.OnClick = new Button.ButtonDelegate(OnBtnEntryClick);
            _controllList.AddChild(btnEntry);
            ptStart.y += 22 + 5;


            _controllList.AddChild(new Label("动作节点:", this, new Rect(ptStart.x, ptStart.y, 150, 22), this.root));
            ptStart.y += 20;

            //task
            Button btnTask = new Button("任务节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnTask.OnClick = new Button.ButtonDelegate(OnBtnTaskClick);
            _controllList.AddChild(btnTask);
            ptStart.y += 22 + 5;


            _controllList.AddChild(new Label("组合节点:", this, new Rect(ptStart.x, ptStart.y, 150, 22), this.root));
            ptStart.y += 20;

            //sequenct
            Button btnSequence = new Button("顺序节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnSequence.OnClick = new Button.ButtonDelegate(OnBtnSequenceClick);
            _controllList.AddChild(btnSequence);
            ptStart.y += 22 + 5;

            //randomsequence
            Button btnRandonSequence = new Button("随机序列", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnRandonSequence.OnClick = new Button.ButtonDelegate(OnBtnRandomSequenceClick);
            _controllList.AddChild(btnRandonSequence);
            ptStart.y += 22 + 5;

            //priority
            Button btnPriority = new Button("优先节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnPriority.OnClick = new Button.ButtonDelegate(OnBtnPriorityClick);
            _controllList.AddChild(btnPriority);
            ptStart.y += 22 + 5;

            //parallel
            Button btnParallel = new Button("并行节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnParallel.OnClick = new Button.ButtonDelegate(OnBtnParallelClick);
            _controllList.AddChild(btnParallel);
            ptStart.y += 22 + 5;

            //randomselector
            Button btnRandom = new Button("随机节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnRandom.OnClick = new Button.ButtonDelegate(OnBtnRandomClick);
            _controllList.AddChild(btnRandom);
            ptStart.y += 22 + 5;

            //weightselector
            Button btnWeight = new Button("权重节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnWeight.OnClick = new Button.ButtonDelegate(OnBtnWeightClick);
            _controllList.AddChild(btnWeight);
            ptStart.y += 22 + 5;

            //conditionselector
            Button btnCondition = new Button("条件节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnCondition.OnClick = new Button.ButtonDelegate(OnBtnConditionClick);
            _controllList.AddChild(btnCondition);
            ptStart.y += 22 + 5;

            //logic
            Button btnLogic = new Button("逻辑节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnLogic.OnClick = new Button.ButtonDelegate(OnBtnLogicClick);
            _controllList.AddChild(btnLogic);
            ptStart.y += 22 + 5;

            //subtree
            Button btnTree = new Button("子树节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnTree.OnClick = new Button.ButtonDelegate(OnBtnSubTreeClick);
            _controllList.AddChild(btnTree);
            ptStart.y += 22 + 5;

            _controllList.AddChild(new Label("装饰:", this, new Rect(ptStart.x, ptStart.y, 150, 22), this.root));
            ptStart.y += 20;

            //loop
            Button btnLoop = new Button("循环节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnLoop.OnClick = new Button.ButtonDelegate(OnBtnLoopClick);
            _controllList.AddChild(btnLoop);
            ptStart.y += 22 + 5;

            //loopuntil
            Button btnLoopUtl = new Button("循环直到", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnLoopUtl.OnClick = new Button.ButtonDelegate(OnBtnLoopUntilClick);
            _controllList.AddChild(btnLoopUtl);
            ptStart.y += 22 + 5;

            //monitor
            Button btnMonitor = new Button("监控节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnMonitor.OnClick = new Button.ButtonDelegate(OnBtnMonitorClick);
            _controllList.AddChild(btnMonitor);
            ptStart.y += 22 + 5;

            //inverter
            Button btnInverter = new Button("取反节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnInverter.OnClick = new Button.ButtonDelegate(OnBtnInverterClick);
            _controllList.AddChild(btnInverter);
            ptStart.y += 22 + 5;

            //retfail
            Button btnFail = new Button("失败节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnFail.OnClick = new Button.ButtonDelegate(OnBtnFailClick);
            _controllList.AddChild(btnFail);
            ptStart.y += 22 + 5;

            //retsuccess
            Button btnSuccess = new Button("成功节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnSuccess.OnClick = new Button.ButtonDelegate(OnBtnSuccessClick);
            _controllList.AddChild(btnSuccess);
            ptStart.y += 22 + 5;

            //retrunning
            Button btnRetRunning = new Button("运行中节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnRetRunning.OnClick = new Button.ButtonDelegate(OnBtnRetrunningClick);
            _controllList.AddChild(btnRetRunning);
            ptStart.y += 22 + 5;

            //utlfail
            Button btnUtilFail = new Button("直到失败节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnUtilFail.OnClick = new Button.ButtonDelegate(OnBtnUtilFailClick);
            _controllList.AddChild(btnUtilFail);
            ptStart.y += 22 + 5;

            //utlsuccess
            Button btnUtilSuc = new Button("直到成功节点", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnUtilSuc.OnClick = new Button.ButtonDelegate(OnBtnUtilSucClick);
            _controllList.AddChild(btnUtilSuc);
            ptStart.y += 22 + 5;

            //persistwhile
            Button btnPersist = new Button("持续时间", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnPersist.OnClick = new Button.ButtonDelegate(OnBtnPersistWhileClick);
            _controllList.AddChild(btnPersist);
            ptStart.y += 22 + 5;

            //countlimit
            Button btnCountLimit = new Button("持续次数", this, new Rect(10, ptStart.y, 150, 22), this.root);

            btnCountLimit.OnClick = new Button.ButtonDelegate(OnBtnCountLimitClick);
            _controllList.AddChild(btnCountLimit);
            ptStart.y += 22 + 5;
        }