예제 #1
0
        private void LoadSelectedAction()
        {
            if (ddlActions.SelectedItem == null || _currentOption == null || _currentScreen == null)
            {
                _currentAction = null;
                return;
            }
            _loadingScreen = true;
            ClearAction();

            var selectedAction = ddlActions.SelectedItem as ComboBoxItem;
            var actionId       = Convert.ToInt32(selectedAction.Tag);
            var action         = _currentOption.Actions.Single(x => x.Id == actionId);

            _currentAction = action;

            var actionType = (int)action.Type;

            if (actionType != 0)
            {
                ddlActionTypes.SelectedItem =
                    (from ComboBoxItem item in ddlActionTypes.Items
                     where item.Tag.ToString() == actionType.ToString()
                     select item)
                    .First();
            }
            txtActionParameter.Text = Convert.ToString(action.Parameter);
            _loadingScreen          = false;
        }
예제 #2
0
        private void SaveScreen()
        {
            if (_currentScreen == null || _loadingScreen)
            {
                return;
            }

            lblSaveSuccess.Visibility = Visibility.Collapsed;
            saveTimer.Stop();
            saveCounter = 0;

            var screen = Screens.Single(x => x.Id == _currentScreen.Id);

            screen.InternalName       = txtScreenName.Text;
            screen.ScreenIntroMessage = txtScreenIntro.Text;

            if (_currentOption != null)
            {
                var option = screen.Options.Single(x => x.Id == _currentOption.Id);
                option.Text = txtOptionText.Text;
                if (ddlOptionConditionType.SelectedItem != null)
                {
                    var selectedConditionType = ddlOptionConditionType.SelectedItem as ComboBoxItem;
                    var typeId = Convert.ToInt32(selectedConditionType.Tag);
                    if (typeId > 0)
                    {
                        option.ShowCondition.Type      = (ConditionType)typeId;
                        option.ShowCondition.Parameter = txtOptionConditionValue.Text;
                    }
                }

                if (_currentAction != null)
                {
                    var action = _currentOption.Actions.SingleOrDefault(x => x.Id == _currentAction.Id);
                    if (ddlActionTypes.SelectedItem != null && action != null)
                    {
                        var selectedActionType = ddlActionTypes.SelectedItem as ComboBoxItem;
                        var typeId             = Convert.ToInt32(selectedActionType.Tag);
                        if (typeId > 0)
                        {
                            action.Type      = (ActionType)typeId;
                            action.Parameter = txtActionParameter.Text;
                        }
                    }

                    _currentAction = action;
                }

                _currentOption = option;
            }

            _currentScreen = screen;

            lblSaveSuccess.Visibility = Visibility.Visible;
            saveTimer.Start();
            UpdateNames();
        }
예제 #3
0
        private void BtnDeleteAction_Click(object sender, RoutedEventArgs e)
        {
            if (_currentOption == null ||
                _currentAction == null ||
                ddlActions.SelectedItem == null ||
                !_currentOption.Actions.Any())
            {
                return;
            }

            _currentOption.Actions.RemoveAll(x => x.Id == _currentOption.Id);
            ddlActions.Items.Remove(ddlActions.SelectedItem);

            _currentAction = null;
            ClearAction();
            RenumberScreens();
        }
예제 #4
0
        private void BtnDeleteScreen_Click(object sender, RoutedEventArgs e)
        {
            if (_currentScreen == null ||
                listScreens.SelectedItem == null ||
                !Screens.Any())
            {
                return;
            }

            Screens.RemoveAll(x => x.Id == _currentScreen.Id);
            listScreens.Items.Remove(listScreens.SelectedItem);

            _currentScreen = null;
            _currentOption = null;
            _currentAction = null;
            ClearScreen();
            RenumberScreens();
        }
예제 #5
0
        private void NewAction()
        {
            if (_currentOption == null)
            {
                return;
            }

            var newAction = new TextAdventure.Core.Models.Action();

            newAction.Id = 1;
            if (_currentOption.Actions.Any())
            {
                newAction.Id = _currentOption.Actions.Max(x => x.Id) + 1;
            }

            _currentOption.Actions.Add(newAction);
            _currentAction = newAction;
            var newActionListItem = new ComboBoxItem
            {
                Tag     = newAction.Id,
                Content = "Action - " + newAction.Id
            };

            ddlActions.Items.Add(newActionListItem);
            foreach (ComboBoxItem item in ddlActions.Items)
            {
                var tag = (int)item.Tag;
                if (tag == newAction.Id)
                {
                    ddlActions.SelectedItem = item;
                }
            }

            LoadSelectedAction();
            SaveScreen();
        }