Пример #1
0
        private void Awake()
        {
            var verticalLayout = new VerticalLayout().AddTo(this);

            new LabelView("功能名:")
            .FontBold()
            .TextMiddleCenter()
            .FontSize(15)
            .AddTo(verticalLayout);

            nameInputView = new TextFieldView(string.Empty).FontSize(20).AddTo(verticalLayout);

            new SpaceView(8f).AddTo(verticalLayout);

            new LabelView("描述:")
            .FontBold()
            .TextMiddleCenter()
            .FontSize(15)
            .AddTo(verticalLayout);

            descInputView = new TextFieldView(string.Empty).FontSize(20).AddTo(verticalLayout);

            new SpaceView(8f).AddTo(verticalLayout);

            saveCreateBtn = new ButtonView("保存", SaveOrCreateEvent, true).AddTo(verticalLayout);
        }
Пример #2
0
        /// <summary>
        /// 通过菜单的 名称 和 组件 获取按钮
        /// </summary>
        /// <param name="name">菜单名称</param>
        /// <param name="component">组件</param>
        /// <returns></returns>
        public List <ButtonView> LoadByMenuName(string name, string component)
        {
            //var result = from d in UnitWork.Find<Button>(null) select d;
            var listButton = UnitWork.SqlQuery <Button>(
                "select b.* From Menus m left join MenuButton mb on m.id = mb.MenuId left join Buttons b on mb.ButtonId  = b.Id where b.id is not null " +
                "and m.id in (select Id from Menus where isAble = 0 and isDel=0 and Component like @Component and Name like @Name) " +
                "order by b.Sort desc,id desc"
                , new object[]
            {
                new SqlParameter()
                {
                    ParameterName = "@Name",
                    Value         = "%" + name + "%",
                    DbType        = DbType.String
                },
                new SqlParameter()
                {
                    ParameterName = "@Component",
                    Value         = "%" + component + "%",
                    DbType        = DbType.String
                }
            }).ToList();

            var listButtonView = new List <ButtonView>();

            foreach (var b in listButton)
            {
                ButtonView bv = b;
                bv.Label = b.Name;
                listButtonView.Add(bv);
            }

            return(listButtonView);
        }
Пример #3
0
        /// <summary>Attaches this presenter to a view.</summary>
        /// <param name="model"></param>
        /// <param name="viewBase"></param>
        /// <param name="parentPresenter"></param>
        public void Attach(object model, object viewBase, ExplorerPresenter parentPresenter)
        {
            presenter  = parentPresenter;
            view       = (ViewBase)viewBase;
            modelToRun = (IModel)model;

            nameOfJobEdit          = view.GetControl <EditView>("nameOfJobEdit");
            numberCPUCombobox      = view.GetControl <DropDownView>("numberCPUCombobox");
            apsimTypeToRunCombobox = view.GetControl <DropDownView>("apsimTypeToRunCombobox");
            directoryLabel         = view.GetControl <LabelView>("directoryLabel");
            directoryEdit          = view.GetControl <EditView>("directoryEdit");
            browseButton           = view.GetControl <ButtonView>("browseButton");
            versionLabel           = view.GetControl <LabelView>("versionLabel");
            versionCombobox        = view.GetControl <DropDownView>("versionCombobox");
            submitButton           = view.GetControl <ButtonView>("submitButton");
            statusLabel            = view.GetControl <LabelView>("statusLabel");
            lowPriorityCheckBox    = view.GetControl <CheckBoxView>("lowPriorityCheckBox");

            nameOfJobEdit.Text              = modelToRun.Name + DateTime.Now.ToString("yyyy-MM-dd HH.mm");
            numberCPUCombobox.Values        = new string[] { "16", "32", "48", "64", "80", "96", "112", "128", "256" };
            numberCPUCombobox.SelectedValue = ApsimNG.Cloud.Azure.AzureSettings.Default.NumCPUCores;

            apsimTypeToRunCombobox.Values = new string[] { "A released version", "A directory", "A zip file" };
            if (!string.IsNullOrEmpty(ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMVersion))
            {
                apsimTypeToRunCombobox.SelectedValue = "A released version";
            }
            else if (!string.IsNullOrEmpty(ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMDirectory))
            {
                apsimTypeToRunCombobox.SelectedValue = "A directory";
            }
            else if (!string.IsNullOrEmpty(ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMZipFile))
            {
                apsimTypeToRunCombobox.SelectedValue = "A zip file";
            }
            else
            {
                apsimTypeToRunCombobox.SelectedValue = "A released version";
            }

            SetupWidgets();

            if (!string.IsNullOrEmpty(ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMVersion))
            {
                versionCombobox.SelectedValue = ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMVersion;
            }
            else if (!string.IsNullOrEmpty(ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMDirectory))
            {
                directoryEdit.Text = ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMDirectory;
            }
            else if (!string.IsNullOrEmpty(ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMZipFile))
            {
                directoryEdit.Text = ApsimNG.Cloud.Azure.AzureSettings.Default.APSIMZipFile;
            }
            lowPriorityCheckBox.Checked = ApsimNG.Cloud.Azure.AzureSettings.Default.LowPriority;

            apsimTypeToRunCombobox.Changed += OnVersionComboboxChanged;
            browseButton.Clicked           += OnBrowseButtonClicked;
            submitButton.Clicked           += OnSubmitJobClicked;
        }
Пример #4
0
    private void SetUpButtons()
    {
        if (m_previousButtonView != null)
        {
            m_previousButtonView.Detach();
        }

        if (m_nextButtonView != null)
        {
            m_nextButtonView.Detach();
        }

        m_previousButton     = new ButtonModel();
        m_nextButton         = new ButtonModel();
        m_previousButtonView = ButtonView.Attach <ButtonView>(PreviousButtonPrefabPath, m_previousButtonRoot);
        m_previousButtonView.SetModel <ButtonModel>(m_previousButton);
        m_nextButtonView = ButtonView.Attach <ButtonView>(NextButtonPrefabPath, m_nextButtonRoot);
        m_nextButtonView.SetModel <ButtonModel>(m_nextButton);

        m_previousButton.OnClicked += () =>
        {
            OnClickPreviousButton();
        };
        m_nextButton.OnClicked += () =>
        {
            OnClickNextButton();
        };

        // TODO : 演出を入れるならその場所に移動
        m_previousButton.Appear();
        m_previousButton.SkipAppearing();
        m_nextButton.Appear();
        m_nextButton.SkipAppearing();
    }
        private void Awake()
        {
            var verticalLayout = new VerticalLayout("box").AddTo(this);

            new SpaceView(4).AddTo(verticalLayout);

            new LabelView("名字").FontSize(15).AddTo(verticalLayout);

            string itemName = string.Empty;

            //加.BackgroundColor(Color.white)  的原因
            //因为按钮事件的时候 background 还是在被更改的期间
            //所以 需要一个颜色 来显示自己的颜色
            //不过后面用cmdQueue延迟加载了所以无所谓
            textAreaView = new TextAreaView(itemName, (s) => itemName = s)
                           .AddTo(verticalLayout);

            new LabelView("颜色").FontSize(15).AddTo(verticalLayout);

            Color itemColor = Color.black;

            colorView = new ColorView(itemColor, (c) => itemColor = c)
                        .AddTo(verticalLayout);

            changeButton = new ButtonView("添加", () => { }, true)
                           .AddTo(verticalLayout);

            new ButtonView("关闭", Close, true)
            .AddTo(verticalLayout);
        }
Пример #6
0
        /// <summary>Attach the specified Model and View.</summary>
        /// <param name="model">The axis model</param>
        /// <param name="view">The axis view</param>
        /// <param name="explorerPresenter">The parent explorer presenter</param>
        public void Attach(object model, object view, ExplorerPresenter explorerPresenter)
        {
            this.model             = model as IModel;
            this.view              = view as ViewBase;
            this.explorerPresenter = explorerPresenter;

            storage = this.model.FindInScope <DataStore>();

            checkpointList = this.view.GetControl <TreeView>("CheckpointList");
            addButton      = this.view.GetControl <ButtonView>("AddButton");
            deleteButton   = this.view.GetControl <ButtonView>("DeleteButton");

            popupMenu = new MenuDescriptionArgs()
            {
                Name = "Show on graphs?",
                ResourceNameForImage = "empty"
            };
            popupMenu.OnClick         += OnCheckpointTicked;
            checkpointList.ContextMenu = new MenuView();
            checkpointList.ContextMenu.Populate(new List <MenuDescriptionArgs>()
            {
                popupMenu
            });

            PopulateList();

            addButton.Clicked    += OnAddButtonClicked;
            deleteButton.Clicked += OnDeleteButtonClicked;
        }
Пример #7
0
 public void Dedicated(ButtonView buttonView)
 {
     buttonView.Circle.enabled    = true;
     buttonView.MenuButton.sprite = buttonView.State[1];
     buttonView.ButtonName.color  = new Color(255, 0, 122);
     buttonView.GamePanel.SetActive(true);
 }
Пример #8
0
        /// <summary>
        /// 执行绑定过程
        /// </summary>
        protected override void Awake()
        {
            //搜索View组件

            //结果输入
            resultInputField = GameObject.Find("Canvas/Panel/ResultInputField").GetComponent <InputFieldView>();
            //分数
            gradeText = GameObject.Find("Canvas/Panel/GradeText").GetComponent <TextView>();

            //确认按钮
            sureButton = GameObject.Find("Canvas/Panel/SureButton").GetComponent <ButtonView>();

            //题目内容
            questionText = GameObject.Find("Canvas/Panel/ItemText").GetComponent <TextView>();

            //题目数量
            numText = GameObject.Find("Canvas/Panel/NumText").GetComponent <TextView>();

            //下拉列表
            dropdown = GameObject.Find("Canvas/Panel/Dropdown").GetComponent <DropdownView>();

            //滑动列表
            scrollbar = GameObject.Find("Canvas/Panel/Scrollbar").GetComponent <ScrollbarView>();

            //实例化DataEntity
            this.DataEntity = new SimpleTestEntity();

            //在父类的Awake函数中执行绑定过程
            base.Awake();
        }
Пример #9
0
    private void SetUpButtons()
    {
        m_nextButton   = new ButtonModel();
        m_returnButton = new ButtonModel();

        ButtonView
        .Attach <ButtonView>(NextButtonPrefabPath, m_nextButtonRoot)
        .SetModel <ButtonModel>(m_nextButton);
        ButtonView
        .Attach <ButtonView>(ReturnButtonPrefabPath, m_returnButtonRoot)
        .SetModel <ButtonModel>(m_returnButton);


        m_nextButton.OnClicked += () =>
        {
            OnClickNextButton();
        };
        m_returnButton.OnClicked += () =>
        {
            OnClickReturnButton();
        };

        // TODO : 演出を入れるならその場所に移動
        m_nextButton.Appear();
        m_nextButton.SkipAppearing();
        m_returnButton.Appear();
        m_returnButton.SkipAppearing();
    }
Пример #10
0
        public BetRangePresenter(BetRangeView view)
        {
            this.view       = view;
            this.buttonView = this.view.gameObject.GetComponent <ButtonView>();
            manager         = GameManager.Instance;
            gameEvent       = GameEvent.Instance;

            this.view.OnMaxButtonClicked.Where(_ => editable).Subscribe(x => {
                this.view.scrollBar.value = 1;
            });

            this.view.OnMinButtonClicked.Where(_ => editable).Subscribe(x => {
                this.view.scrollBar.value = 0;
            });

            this.view.OnPlusButtonClicked.Where(_ => editable).Subscribe(x => {
                this.view.scrollBar.value += 0.1f;
            });

            this.view.OnMinusButtonClicked.Where(_ => editable).Subscribe(x => {
                this.view.scrollBar.value -= 0.1f;
            });

            this.view.OnScrollBarChanged.Where(_ => editable).Subscribe(x => {
                OnChangeBetRange(x);
            });

            gameEvent.AddPlayerTurnEvent(OnUpdatePlayerEvent);
            gameEvent.AddClearEvent(OnClearAll);
        }
Пример #11
0
        void ReleaseDesignerOutlets()
        {
            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

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

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

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

            if (UrlLabel != null)
            {
                UrlLabel.Dispose();
                UrlLabel = null;
            }
        }
Пример #12
0
    void SetUpButtons()
    {
        var executeButtonModel = new ButtonModel();
        var returnButtonModel  = new ButtonModel();

        ButtonView
        .Attach <ButtonView>(ExecuteButtonPrefabPath, m_executeButtonRoot)
        .SetModel <ButtonModel>(executeButtonModel);

        executeButtonModel.OnClicked += () =>
        {
            OnClickExecButton();
        };

        ButtonView
        .Attach <ButtonView>(ReturnButtonPrefabPath, m_returnButtonRoot)
        .SetModel <ButtonModel>(returnButtonModel);

        returnButtonModel.OnClicked += () =>
        {
            OnClickReturnButton();
        };

        // TODO : 演出を入れるならそこに移動
        executeButtonModel.Appear();
        executeButtonModel.SkipAppearing();
        returnButtonModel.Appear();
        returnButtonModel.SkipAppearing();
    }
Пример #13
0
        private void DrawMenu()
        {
            // Create the Grid
            myGrid = new Grid
            {
                ShowGridLines = true
            };

            // show menuGrid lines
            //menuGrid.ShowGridLines = true;

            // Define all rows for mainGrid
            DefineRowMyGrid();
            //Create the staves
            pv = new PianoView(myGrid, mPc);

            sv      = new StaveView(myGrid, mPc);
            Content = pv.myGrid;


            //Draw the notes
            nv = new NoteView(sv);
            nv.DrawNotes();

            bv = new ButtonView(myGrid, sv, nv);
            bv.pianoStateChanged += pianoStateChanged;

            metronome = bv.metronome;
            metronome.countdownFinished    += countdownFinished;
            metronome.countDownTickElapsed += CountDownTickElapsed;
        }
Пример #14
0
        /// <summary>
        /// Конструктор
        /// </summary>
        /// <param name="parPlatform">Платформа</param>
        /// <param name="parButton">Объект кнопки</param>
        public ButtonController(Platform parPlatform, Button parButton)
        {
            _button = parButton;
            View    = new ButtonView(parPlatform, _button);

            parPlatform.Click += OnClick;
        }
Пример #15
0
        public Part1()
        {
            UIRect          = UICreator.MainRect;
            BackgroundColor = Color.grey;

            ButtonView                 = new ButtonView(this);
            ButtonView.UIRect          = new UIRect(20, 20, 300, 50);
            ButtonView.BackgroundColor = Color.black;
            ButtonView.FontSize        = 25;
            ButtonView.Title           = "Button(Make Toast)";
            ButtonView.OnClickListener.AddListener(MakeToast);

            TextView           = new TextView(this);
            TextView.UIRect    = new UIRect(20, 90, 300, 50);
            TextView.FontSize  = 25;
            TextView.Text      = "Text View";
            TextView.Alignment = TextAnchor.MiddleCenter;

            TextField                 = new TextField(this);
            TextField.UIRect          = new UIRect(20, 160, 300, 50);
            TextField.BackgroundColor = Color.black;
            TextField.FontSize        = 25;
            TextField.PlaceHolder     = "Input";
            TextField.Aligment        = TextAnchor.MiddleLeft;
        }
Пример #16
0
        /// <summary>
        /// Attach the view to this presenter.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="viewBase"></param>
        /// <param name="explorerPresenter"></param>
        public void Attach(object model, object viewBase, ExplorerPresenter explorerPresenter)
        {
            view                   = (ViewBase)viewBase;
            jobListView            = view.GetControl <ListView>("jobListView");
            refreshButton          = view.GetControl <ButtonView>("refreshButton");
            downloadButton         = view.GetControl <ButtonView>("downloadButton");
            stopButton             = view.GetControl <ButtonView>("stopButton");
            deleteButton           = view.GetControl <ButtonView>("deleteButton");
            credentialsButton      = view.GetControl <ButtonView>("credentialsButton");
            showMyJobsOnlyCheckbox = view.GetControl <CheckBoxView>("showMyJobsCheckbox");
            progressBar            = view.GetControl <ProgressBarView>("progressBar");

            jobListView.SortColumn    = "Start time";
            jobListView.SortAscending = false;

            jobListView.AddColumn("Name");
            jobListView.AddColumn("Owner");
            jobListView.AddColumn("State");
            jobListView.AddColumn("# Sims");
            jobListView.AddColumn("Progress");
            jobListView.AddColumn("Start time");
            jobListView.AddColumn("End time");
            jobListView.AddColumn("Duration");
            jobListView.AddColumn("CPU time");

            refreshButton.Clicked          += OnRefreshClicked;
            downloadButton.Clicked         += OnDownloadClicked;
            stopButton.Clicked             += OnStopClicked;
            deleteButton.Clicked           += OnDeleteClicked;
            credentialsButton.Clicked      += OnCredentialsClicked;
            showMyJobsOnlyCheckbox.Changed += OnShowMyJobsChanged;
        }
Пример #17
0
    private void SetUpButtons()
    {
        var sortButtonModel = new ButtonModel();

        m_SortButton = ButtonView.Attach <FriendListSortButton>(SortButtonPrefabPath, m_sortButtonRoot);
        m_SortButton.SetModel <ButtonModel>(sortButtonModel);
        sortButtonModel.OnClicked += () =>
        {
            OnClickSortButton();
        };

        // TODO : 演出を入れるならその場所に移動
        sortButtonModel.Appear();
        sortButtonModel.SkipAppearing();

        var reloadButtonModel = new ButtonModel();

        m_ReloadButton = ButtonView.Attach <FriendReloadButton>(ReloadButtonPrefabPath, m_reloadButtonRoot);
        m_ReloadButton.SetReloadButtonModel(reloadButtonModel);
        reloadButtonModel.isEnabled  = MainMenuParam.m_IsEnableQuestFriendReload;
        reloadButtonModel.OnClicked += () =>
        {
            OnClickReloadButton();
        };
        reloadButtonModel.Appear();
        reloadButtonModel.SkipAppearing();
    }
Пример #18
0
    private void SetUpButtons()
    {
        var decisionButtonModel = new ButtonModel();

        ButtonView
        .Attach <ButtonView>(DecisionButtonPrefabPath, m_decisionButtonRoot)
        .SetModel <ButtonModel>(decisionButtonModel);
        decisionButtonModel.OnClicked += () =>
        {
            OnSelectSearchButton();
        };

        var searchButtonModel = new ButtonModel();

        ButtonView
        .Attach <ButtonView>(SearchButtonPrefabPath, m_searchButtonRoot)
        .SetModel <ButtonModel>(searchButtonModel);
        searchButtonModel.OnClicked += () =>
        {
            OnSelectSearchButton();
        };


        // TODO : 演出を入れるならその場所に移動
        decisionButtonModel.Appear();
        decisionButtonModel.SkipAppearing();
        searchButtonModel.Appear();
        searchButtonModel.SkipAppearing();
    }
Пример #19
0
        public LoginView()
        {
            var usernameLine = new HorizontalLayout().AddTo(this);

            new LabelView("username:"******"").AddTo(usernameLine);

            var passwordLine = new HorizontalLayout().AddTo(this);

            new LabelView("password:"******"").PasswordMode().AddTo(passwordLine);

            var loginBtn    = new ButtonView("登录").AddTo(this);
            var registerBtn = new ButtonView("注册").AddTo(this);

            loginBtn.OnClick.AddListener(() =>
            {
                PackageKitLoginApp.Send(new LoginCommand(username.Content.Value, password.Content.Value));
            });

            registerBtn.OnClick.AddListener(() =>
            {
                PackageKitLoginApp.Send <OpenRegisterWebsiteCommand>();
            });
        }
Пример #20
0
 public void UnDedicated(ButtonView buttonView)
 {
     buttonView.Circle.enabled    = false;
     buttonView.MenuButton.sprite = buttonView.State[0];
     buttonView.ButtonName.color  = new Color(0, 0, 0);
     buttonView.GamePanel.SetActive(false);
 }
 void AddButtonToList(ButtonView button)
 {
     if (button != null)
     {
         columnButtons.Add(button);
     }
 }
 void Sort_OnChange(SortType type, ButtonView button)
 {
     if (OnSortChange != null)
     {
         OnSortChange(type, button);
     }
 }
Пример #23
0
 void OnToggleShadow(object sender, EventArgs ev)
 {
     _isShadowOn = !_isShadowOn;
     ExampleBoxView.ToggleShadow(_isShadowOn);
     ButtonView.ToggleShadow(_isShadowOn);
     LabelView.ToggleShadow(_isShadowOn);
     ExampleImageview.ToggleShadow(_isShadowOn);
 }
Пример #24
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            _gestureRecognizer = new UITapGestureRecognizer();
            _gestureRecognizer.AddTarget(() => OpenWebPageBtnTapped(_gestureRecognizer));
            ButtonView.AddGestureRecognizer(_gestureRecognizer);
        }
Пример #25
0
 public ShellExecuteControl() : base()
 {
     View = new ButtonView($"Execute", ExecuteCommand);
     AddConfigParameter(new StringConfigParameter(_ConfigExecutable, string.Empty, ".*"));
     AddConfigParameter(new StringConfigParameter(_ConfigArguments, string.Empty, ".*"));
     AddConfigParameter(new BoolConfigParameter(_ConfigWaitForExit, false));
     //AddConfigParameter(new BoolConfigParameter(_ConfigCommand, false));
 }
        /// <summary>
        /// 执行绑定过程
        /// </summary>
        protected override void Awake()
        {
            close = transform.Find("Title/Close").GetComponent <ButtonView>();
            //实例化DataEntity
            this.DataEntity = new UIBEntityScript();

            //在父类的Awake函数中执行绑定过程
            base.Awake();
        }
Пример #27
0
    public void ListenerOnClick(ButtonView buttonView)
    {
        _listenersDownPanel.Sort();
        int index = _listenersDownPanel.BinarySearch(buttonView);

        Debug.Log(index);
        UnDedicatedState?.Invoke();
        _listenersDownPanel[index].Dedicated();
    }
Пример #28
0
 public ViewInitializer(BonusView bonusView, ButtonView buttonView, HealthView healthView, KeyView keyView,
                        EndGameView endGameView)
 {
     _bonusView   = bonusView;
     _buttonView  = buttonView;
     _healthView  = healthView;
     _keyView     = keyView;
     _endGameView = endGameView;
 }
Пример #29
0
 private void Bind(Keys keyCode, ButtonView button, Key key)
 {
     keyMap[keyCode]   = key;
     button.Key        = key;
     button.MouseDown += (sender, e) => key.HandleKeyDown();
     button.MouseUp   += (sender, e) => key.HandleKeyUp();
     key.KeyDown      += button.Invalidate;
     key.KeyUp        += button.Invalidate;
 }
Пример #30
0
        void ReleaseDesignerOutlets()
        {
            if (BackgroundButton != null)
            {
                BackgroundButton.Dispose();
                BackgroundButton = null;
            }

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

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

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

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

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

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

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

            if (TitleView != null)
            {
                TitleView.Dispose();
                TitleView = null;
            }
        }
 public LevelCompleteView(
     ContentManager content, 
     SpriteBatch spriteBatch, 
     LevelCompleteViewModel viewModel, 
     LevelView levelView, 
     IInputManager input)
 {
     this.content = content;
     this.levelView = levelView;
     this.viewModel = viewModel;
     this.spriteBatch = spriteBatch;
     this.nextLevelButton = new ButtonView(input, "Images/LevelComplete/NextLevelButton", new Vector2(328, 342));
     this.nextLevelButton.Command = this.viewModel.NextLevelCommand;
 }
Пример #32
0
 public GameOverView(
     ContentManager content, 
     GameOverViewModel viewModel,
     SpriteBatch spriteBatch,
     LevelView levelView,
     IInputManager input)
 {
     this.content = content;
     this.viewModel = viewModel;
     this.spriteBatch = spriteBatch;
     this.levelView = levelView;
     this.input = input;
     this.restartLevelButton = new ButtonView(input, "Images/GameOver/RestartLevelButton", new Vector2(328, 342));
     this.restartLevelButton.Command = this.viewModel.NewGameCommand;
 }
Пример #33
0
 public TitleView(
     ContentManager content,
     TitleViewModel viewModel,
     SpriteBatch spriteBatch,
     LevelView levelView,
     IInputManager input)
 {
     this.content = content;
     this.viewModel = viewModel;
     this.spriteBatch = spriteBatch;
     this.levelView = levelView;
     this.input = input;
     this.creditsButton = new ButtonView(input, "Images/Title/CreditsButton", new Vector2(388, 273));
     this.creditsButton.Command = this.viewModel.ShowCreditsCommand;
     this.playButton = new ButtonView(input, "Images/Title/PlayButton", new Vector2(406, 344));
     this.playButton.Command = this.viewModel.StartGameCommand;
 }
Пример #34
0
        public PlayingView(
            SpriteBatch spriteBatch, 
            ContentManager content, 
            IInputManager inputManager,
            PlayingViewModel viewModel,
            ISoundManager soundManager)
        {
            this.spriteBatch = spriteBatch;
            this.content = content;
            this.viewModel = viewModel;
            this.doodadViews = new List<DoodadView>();
            this.rotateClockwiseButton = new ButtonView(
                inputManager,
                "Images/Playing/RotateClockwise",
                new Vector2(Constants.ScreenWidth - 127, 428),
                soundManager);
            this.rotateClockwiseButton.Command = new RelayCommand(() => this.viewModel.Rotate(true));

            this.rotateCounterClockwiseButton = new ButtonView(
                inputManager,
                "Images/Playing/RotateCounterClockwise",
                new Vector2(127, 428),
                soundManager);
            this.rotateCounterClockwiseButton.Command = new RelayCommand(() => this.viewModel.Rotate(false));

            this.translateOutTween = TweenFactory.Tween(0, Constants.ScreenHeight, TimeSpan.FromSeconds(0.75f));
            this.translateOutTween.IsPaused = true;

            this.translateInTween = TweenFactory.Tween(Constants.ScreenHeight, 0, TimeSpan.FromSeconds(0.75f));
            this.translateInTween.IsPaused = true;

            this.textTween = TweenFactory.Tween(0, 1, TimeSpan.FromSeconds(0.3f));
            this.textTween.Reverse();
            this.textTween.IsPaused = true;

            this.spottedZebraButton = new ButtonView(
                inputManager,
                "Images/Playing/SpottedZebraLogo",
                new Vector2(Constants.ScreenWidth - 78, 36),
                soundManager);
            this.spottedZebraButton.Command = this.viewModel.OpenCompanyUrlCommand;
        }
		void Initialize ()
		{
			button = new ButtonView ();
//			ContentView.BackgroundColor = UIColor.Red;
			button.Frame = ContentView.Bounds;
			button.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
//			button.SetTitle ("Support Calca Development", UIControlState.Normal);
			ContentView.AddSubview (button);
			ApplyTheme (DocumentAppDelegate.Shared.Theme);
		}
Пример #36
0
        // Also known as "closure hell"
        public static IView View()
        {
            ListSelectView<OrbitDriver> currentlyEditing = null;
            Action<OrbitDriver> onCurrentlyEditingChange = null;

            var setToCurrentOrbit = new ButtonView("Set to current orbit", "Sets all the fields of the editor to reflect the orbit of the currently selected vessel",
                () => onCurrentlyEditingChange(currentlyEditing.CurrentlySelected));

            var referenceSelector = new ListSelectView<CelestialBody>("Reference body", () => FlightGlobals.fetch == null ? null : FlightGlobals.fetch.bodies, null, Extensions.CbToString);

            #region Simple
            var simpleAltitude = new TextBoxView<double>("Altitude", "Altitude of circular orbit", 110000, Model.SiSuffix.TryParse);
            var simpleApply = new ConditionalView(() => simpleAltitude.Valid && referenceSelector.CurrentlySelected != null,
                                  new ButtonView("Apply", "Sets the orbit", () =>
                    {
                        Model.OrbitEditor.Simple(currentlyEditing.CurrentlySelected, simpleAltitude.Object, referenceSelector.CurrentlySelected);

                        currentlyEditing.ReInvokeOnSelect();
                    }));
            var simple = new VerticalView(new IView[]
                {
                    simpleAltitude,
                    referenceSelector,
                    simpleApply,
                    setToCurrentOrbit
                });
            #endregion

            #region Complex
            var complexInclination = new TextBoxView<double>("Inclination", "How close to the equator the orbit plane is", 0, double.TryParse);
            var complexEccentricity = new TextBoxView<double>("Eccentricity", "How circular the orbit is (0=circular, 0.5=elliptical, 1=parabolic)", 0, double.TryParse);
            var complexSemiMajorAxis = new TextBoxView<double>("Semi-major axis", "Mean radius of the orbit (ish)", 10000000, Model.SiSuffix.TryParse);
            var complexLongitudeAscendingNode = new TextBoxView<double>("Lon. of asc. node", "Longitude of the place where you cross the equator northwards", 0, double.TryParse);
            var complexArgumentOfPeriapsis = new TextBoxView<double>("Argument of periapsis", "Rotation of the orbit around the normal", 0, double.TryParse);
            var complexMeanAnomalyAtEpoch = new TextBoxView<double>("Mean anomaly at epoch", "Position along the orbit at the epoch", 0, double.TryParse);
            var complexEpoch = new TextBoxView<double>("Epoch", "Epoch at which mEp is measured", 0, Model.SiSuffix.TryParse);
            var complexEpochNow = new ButtonView("Set epoch to now", "Sets the Epoch field to the current time", () => complexEpoch.Object = Planetarium.GetUniversalTime());
            var complexApply = new ConditionalView(() => complexInclination.Valid &&
                                   complexEccentricity.Valid &&
                                   complexSemiMajorAxis.Valid &&
                                   complexLongitudeAscendingNode.Valid &&
                                   complexArgumentOfPeriapsis.Valid &&
                                   complexMeanAnomalyAtEpoch.Valid &&
                                   complexEpoch.Valid &&
                                   referenceSelector.CurrentlySelected != null,
                                   new ButtonView("Apply", "Sets the orbit", () =>
                    {
                        Model.OrbitEditor.Complex(currentlyEditing.CurrentlySelected,
                            complexInclination.Object,
                            complexEccentricity.Object,
                            complexSemiMajorAxis.Object,
                            complexLongitudeAscendingNode.Object,
                            complexArgumentOfPeriapsis.Object,
                            complexMeanAnomalyAtEpoch.Object,
                            complexEpoch.Object,
                            referenceSelector.CurrentlySelected);

                        currentlyEditing.ReInvokeOnSelect();
                    }));
            var complex = new VerticalView(new IView[]
                {
                    complexInclination,
                    complexEccentricity,
                    complexSemiMajorAxis,
                    complexLongitudeAscendingNode,
                    complexArgumentOfPeriapsis,
                    complexMeanAnomalyAtEpoch,
                    complexEpoch,
                    complexEpochNow,
                    referenceSelector,
                    complexApply,
                    setToCurrentOrbit
                });
            #endregion

            #region Graphical
            SliderView graphicalInclination = null;
            SliderView graphicalEccentricity = null;
            SliderView graphicalPeriapsis = null;
            SliderView graphicalLongitudeAscendingNode = null;
            SliderView graphicalArgumentOfPeriapsis = null;
            SliderView graphicalMeanAnomaly = null;
            double graphicalEpoch = 0;

            Action<double> graphicalOnChange = ignored =>
            {
                Model.OrbitEditor.Graphical(currentlyEditing.CurrentlySelected,
                    graphicalInclination.Value,
                    graphicalEccentricity.Value,
                    graphicalPeriapsis.Value,
                    graphicalLongitudeAscendingNode.Value,
                    graphicalArgumentOfPeriapsis.Value,
                    graphicalMeanAnomaly.Value,
                    graphicalEpoch);

                currentlyEditing.ReInvokeOnSelect();
            };

            graphicalInclination = new SliderView("Inclination", "How close to the equator the orbit plane is", graphicalOnChange);
            graphicalEccentricity = new SliderView("Eccentricity", "How circular the orbit is", graphicalOnChange);
            graphicalPeriapsis = new SliderView("Periapsis", "Lowest point in the orbit", graphicalOnChange);
            graphicalLongitudeAscendingNode = new SliderView("Lon. of asc. node", "Longitude of the place where you cross the equator northwards", graphicalOnChange);
            graphicalArgumentOfPeriapsis = new SliderView("Argument of periapsis", "Rotation of the orbit around the normal", graphicalOnChange);
            graphicalMeanAnomaly = new SliderView("Mean anomaly", "Position along the orbit", graphicalOnChange);

            var graphical = new VerticalView(new IView[]
                {
                    graphicalInclination,
                    graphicalEccentricity,
                    graphicalPeriapsis,
                    graphicalLongitudeAscendingNode,
                    graphicalArgumentOfPeriapsis,
                    graphicalMeanAnomaly,
                    setToCurrentOrbit
                });
            #endregion

            #region Velocity
            var velocitySpeed = new TextBoxView<double>("Speed", "dV to apply", 0, Model.SiSuffix.TryParse);
            var velocityDirection = new ListSelectView<Model.OrbitEditor.VelocityChangeDirection>("Direction", () => Model.OrbitEditor.AllVelocityChanges);
            var velocityApply = new ConditionalView(() => velocitySpeed.Valid,
                                    new ButtonView("Apply", "Adds the selected velocity to the orbit", () =>
                    {
                        Model.OrbitEditor.Velocity(currentlyEditing.CurrentlySelected, velocityDirection.CurrentlySelected, velocitySpeed.Object);
                    }));
            var velocity = new VerticalView(new IView[]
                {
                    velocitySpeed,
                    velocityDirection,
                    velocityApply
                });
            #endregion

            #region Rendezvous
            var rendezvousLeadTime = new TextBoxView<double>("Lead time", "How many seconds off to rendezvous at (zero = on top of each other, bad)", 1, Model.SiSuffix.TryParse);
            var rendezvousVessel = new ListSelectView<Vessel>("Target vessel", () => FlightGlobals.fetch == null ? null : FlightGlobals.fetch.vessels, null, Extensions.VesselToString);
            var rendezvousApply = new ConditionalView(() => rendezvousLeadTime.Valid && rendezvousVessel.CurrentlySelected != null,
                                      new ButtonView("Apply", "Rendezvous", () =>
                    {
                        Model.OrbitEditor.Rendezvous(currentlyEditing.CurrentlySelected, rendezvousLeadTime.Object, rendezvousVessel.CurrentlySelected);
                    }));
            // rendezvous gets special ConditionalView to force only editing of planets
            var rendezvous = new ConditionalView(() => currentlyEditing.CurrentlySelected != null && currentlyEditing.CurrentlySelected.vessel != null,
                                 new VerticalView(new IView[]
                    {
                        rendezvousLeadTime,
                        rendezvousVessel,
                        rendezvousApply
                    }));
            #endregion

            #region CurrentlyEditing
            onCurrentlyEditingChange = newEditing =>
            {
                if (newEditing == null)
                {
                    return;
                }
                {
                    double altitude;
                    CelestialBody body;
                    Model.OrbitEditor.GetSimple(newEditing, out altitude, out body);
                    simpleAltitude.Object = altitude;
                    referenceSelector.CurrentlySelected = body;
                }
                {
                    double inclination;
                    double eccentricity;
                    double semiMajorAxis;
                    double longitudeAscendingNode;
                    double argumentOfPeriapsis;
                    double meanAnomalyAtEpoch;
                    double epoch;
                    CelestialBody body;
                    Model.OrbitEditor.GetComplex(newEditing,
                        out inclination,
                        out eccentricity,
                        out semiMajorAxis,
                        out longitudeAscendingNode,
                        out argumentOfPeriapsis,
                        out meanAnomalyAtEpoch,
                        out epoch,
                        out body);
                    complexInclination.Object = inclination;
                    complexEccentricity.Object = eccentricity;
                    complexSemiMajorAxis.Object = semiMajorAxis;
                    complexLongitudeAscendingNode.Object = longitudeAscendingNode;
                    complexArgumentOfPeriapsis.Object = argumentOfPeriapsis;
                    complexMeanAnomalyAtEpoch.Object = meanAnomalyAtEpoch;
                    complexEpoch.Object = epoch;
                    referenceSelector.CurrentlySelected = body;
                }
                {
                    double inclination;
                    double eccentricity;
                    double periapsis;
                    double longitudeAscendingNode;
                    double argumentOfPeriapsis;
                    double meanAnomaly;
                    Model.OrbitEditor.GetGraphical(newEditing,
                        out inclination,
                        out eccentricity,
                        out periapsis,
                        out longitudeAscendingNode,
                        out argumentOfPeriapsis,
                        out meanAnomaly,
                        out graphicalEpoch);
                    graphicalInclination.Value = inclination;
                    graphicalEccentricity.Value = eccentricity;
                    graphicalPeriapsis.Value = periapsis;
                    graphicalLongitudeAscendingNode.Value = longitudeAscendingNode;
                    graphicalArgumentOfPeriapsis.Value = argumentOfPeriapsis;
                    graphicalMeanAnomaly.Value = meanAnomaly;
                }
                {
                    Model.OrbitEditor.VelocityChangeDirection direction;
                    double speed;
                    Model.OrbitEditor.GetVelocity(newEditing, out direction, out speed);
                    velocityDirection.CurrentlySelected = direction;
                    velocitySpeed.Object = speed;
                }
            };

            currentlyEditing = new ListSelectView<OrbitDriver>("Currently editing", Model.OrbitEditor.OrderedOrbits, onCurrentlyEditingChange, Extensions.OrbitDriverToString);

            if (FlightGlobals.fetch != null && FlightGlobals.fetch.activeVessel != null && FlightGlobals.fetch.activeVessel.orbitDriver != null)
            {
                currentlyEditing.CurrentlySelected = FlightGlobals.fetch.activeVessel.orbitDriver;
            }
            #endregion

            var savePlanet = new ButtonView("Save planet", "Saves the current orbit of the planet to a file, so it stays edited even after a restart. Delete the file named the planet's name in " + IoExt.GetPath(null) + " to undo.",
                                 () => Model.PlanetEditor.SavePlanet(currentlyEditing.CurrentlySelected.celestialBody));
            var resetPlanet = new ButtonView("Reset to defaults", "Reset the selected planet to defaults",
                                  () => Model.PlanetEditor.ResetToDefault(currentlyEditing.CurrentlySelected.celestialBody));

            var planetButtons = new ConditionalView(() => currentlyEditing.CurrentlySelected?.celestialBody != null,
                                    new VerticalView(new IView[]
                    {
                        savePlanet,
                        resetPlanet
                    }));

            var tabs = new TabView(new List<KeyValuePair<string, IView>>()
                {
                    new KeyValuePair<string, IView>("Simple", simple),
                    new KeyValuePair<string, IView>("Complex", complex),
                    new KeyValuePair<string, IView>("Graphical", graphical),
                    new KeyValuePair<string, IView>("Velocity", velocity),
                    new KeyValuePair<string, IView>("Rendezvous", rendezvous),
                });

            return new VerticalView(new IView[]
                {
                    currentlyEditing,
                    planetButtons,
                    new ConditionalView(() => currentlyEditing.CurrentlySelected != null, tabs)
                });
        }