internal void AddStateCategoryClick()
        {
            if (SelectedState.Self.SelectedElement == null)
            {
                MessageBox.Show("You must first select an element to add a state category");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter new category name:";

                if (tiw.ShowDialog() == DialogResult.OK)
                {
                    string name = tiw.Result;

                    StateSaveCategory category = ElementCommands.Self.AddCategory(
                        SelectedState.Self.SelectedElement, name);

                    RefreshUI(SelectedState.Self.SelectedElement);

                    SelectedState.Self.SelectedStateCategorySave = category;

                    GumCommands.Self.FileCommands.TryAutoSaveCurrentElement();
                }
            }
        }
Пример #2
0
        private void HandleExposeEventClick(object sender, System.Windows.RoutedEventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();

            InstanceMember instanceMember = ((System.Windows.Controls.MenuItem)sender).Tag as InstanceMember;

            tiw.Message = "Enter name to expose as:";

            tiw.Result = SelectedState.Self.SelectedInstance.Name + instanceMember.DisplayName;

            var dialogResult = tiw.ShowDialog();

            if (dialogResult == System.Windows.Forms.DialogResult.OK)
            {
                string nameWithDot = SelectedState.Self.SelectedInstance.Name + "." + instanceMember.DisplayName;

                EventSave eventSave = SelectedState.Self.SelectedElement.Events.FirstOrDefault(item => item.Name == nameWithDot);

                if (eventSave == null)
                {
                    eventSave = new EventSave();
                    eventSave.Name = nameWithDot;

                    SelectedState.Self.SelectedElement.Events.Add(eventSave);
                }
                eventSave.ExposedAsName = tiw.Result;

                if (SelectedState.Self.SelectedElement != null)
                {
                    GumCommands.Self.FileCommands.TryAutoSaveCurrentElement();

                    GumCommands.Self.GuiCommands.RefreshPropertyGrid(true);
                }
            }
        }
Пример #3
0
        public void AddState()
        {
            if (SelectedState.Self.SelectedElement == null)
            {
                MessageBox.Show("You must first select an element to add a state");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter new state name:";

                if (tiw.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string name = tiw.Result;

                    StateSave stateSave = ElementCommands.Self.AddState(
                        SelectedState.Self.SelectedElement, SelectedState.Self.SelectedStateCategorySave, name);

                    StateTreeViewManager.Self.RefreshUI(SelectedState.Self.SelectedElement);

                    SelectedState.Self.SelectedStateSave = stateSave;

                    GumCommands.Self.FileCommands.TryAutoSaveCurrentElement();
                }
            }
        }
        public void AddComponentClick(object sender, EventArgs e)
        {
            if (ObjectFinder.Self.GumProjectSave == null || string.IsNullOrEmpty(ProjectManager.Self.GumProjectSave.FullFileName))
            {
                MessageBox.Show("You must first save the project before adding a new component");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter new Component name:";

                if (tiw.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string name = tiw.Result;

                    string whyNotValid;

                    if (!NameVerifier.Self.IsComponentNameValid(name, null, out whyNotValid))
                    {
                        MessageBox.Show(whyNotValid);
                    }
                    else
                    {
                        TreeNode nodeToAddTo = ElementTreeViewManager.Self.SelectedNode;

                        while (nodeToAddTo != null && nodeToAddTo.Tag is ComponentSave && nodeToAddTo.Parent != null)
                        {
                            nodeToAddTo = nodeToAddTo.Parent;
                        }

                        if (nodeToAddTo == null || !nodeToAddTo.IsPartOfComponentsFolderStructure())
                        {
                            nodeToAddTo = RootComponentsTreeNode;
                        }

                        string path = nodeToAddTo.GetFullFilePath();

                        string relativeToComponents = FileManager.MakeRelative(path,
                            FileLocations.Self.ComponentsFolder);

                        ComponentSave componentSave = ProjectCommands.Self.AddComponent(relativeToComponents + name);

                        GumCommands.Self.GuiCommands.RefreshElementTreeView();

                        SelectedState.Self.SelectedComponent = componentSave;

                        GumCommands.Self.FileCommands.TryAutoSaveProject();
                        GumCommands.Self.FileCommands.TryAutoSaveElement(componentSave);
                    }
                }
            }
        }
Пример #5
0
        private void AddAnimationButton_Click(object sender, RoutedEventArgs e)
        {
            if (ViewModel == null)
            {
                throw new NullReferenceException("The ViewModel for this is invalid - set the DataContext on this view before showing it.");
            }

            string whyIsntValid = null;

            if(!string.IsNullOrEmpty(whyIsntValid))
            {
                MessageBox.Show(whyIsntValid);
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter new animation name:";

                var dialogResult = tiw.ShowDialog();

                if(dialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    string whyInvalid;
                    if (!NameValidator.IsAnimationNameValid(tiw.Result, out whyInvalid))
                    {
                        MessageBox.Show(whyInvalid);
                    }
                    else
                    {
                        var newAnimation = new AnimationViewModel() { Name = tiw.Result };

                        this.ViewModel.Animations.Add(newAnimation);

                        this.ViewModel.SelectedAnimation = newAnimation;
                    }
                }
            }
        }
        private static void RenameStateClick()
        {
            TextInputWindow tiw = new TextInputWindow();
            tiw.Message = "Enter new name";
            tiw.Result = SelectedState.Self.SelectedStateSave.Name;
            var result = tiw.ShowDialog();

            if (result == DialogResult.OK)
            {
                SelectedState.Self.SelectedStateSave.Name = tiw.Result;
                GumCommands.Self.GuiCommands.RefreshStateTreeView();
                // I don't think we need to save the project when renaming a state:
                //GumCommands.Self.FileCommands.TryAutoSaveProject();

                GumCommands.Self.FileCommands.TryAutoSaveCurrentElement();
            }
        }
        void AddFolderClick(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();
            tiw.Message = "Enter new folder name";

            DialogResult result = tiw.ShowDialog();

            if (result == DialogResult.OK)
            {
                string folderName = tiw.Result;

                string whyNotValid;

                if (!NameVerifier.Self.IsFolderNameValid(folderName, out whyNotValid))
                {
                    MessageBox.Show(whyNotValid);
                }
                else
                {
                    TreeNode parentTreeNode = SelectedNode;

                    string folder = parentTreeNode.GetFullFilePath() + folderName + "\\";

                    // If the path is relative
                    // that means that the root
                    // hasn't been set yet.
                    if (!FileManager.IsRelative(folder))
                    {
                        System.IO.Directory.CreateDirectory(folder);
                    }

                    GumCommands.Self.GuiCommands.RefreshElementTreeView();
                }
            }
        }
        public void AddInstanceClick(object sender, EventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();
            tiw.Message = "Enter new object name:";

            if (tiw.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string name = tiw.Result;
                string whyNotValid;

                if (!NameVerifier.Self.IsInstanceNameValid(name, null, SelectedState.Self.SelectedElement, out whyNotValid))
                {
                    MessageBox.Show(whyNotValid);
                }
                else
                {
                    AddInstance(name, StandardElementsManager.Self.DefaultType, SelectedState.Self.SelectedElement);
                }
            }
        }
Пример #9
0
        private void RefreshEventsForElement(ElementSave selectedElement)
        {
            EventsViewModel viewModel = new EventsViewModel();

            viewModel.InstanceSave = null;
            viewModel.ElementSave = selectedElement;

            mEventsDataGrid.Instance = viewModel;
            mEventsDataGrid.MembersToIgnore.Add("InstanceSave");
            mEventsDataGrid.MembersToIgnore.Add("ElementSave");
            mEventsDataGrid.Categories[0].Name = "Events on this";

            MemberCategory exposed = new MemberCategory();
            exposed.Name = "Exposed";

            var exposedEvents = SelectedState.Self.SelectedElement.Events.Where(item => !string.IsNullOrEmpty(item.ExposedAsName));

            foreach (var eventSave in exposedEvents)
            {
                EventInstanceMember instanceMember = new EventInstanceMember(
                    SelectedState.Self.SelectedElement,
                    SelectedState.Self.SelectedInstance,
                    eventSave);

                var local = eventSave;

                instanceMember.ContextMenuEvents.Add(
                    "Rename",
                    delegate
                    {
                        TextInputWindow tiw = new TextInputWindow();
                        tiw.Message = "Enter new name";
                        tiw.Result = local.ExposedAsName;

                        if (tiw.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            bool isValid = true;

                            // todo:
                            //string whyNotValid = null;
                            //isValid = NameVerifier.Self.IsEventNameValid(tiw.Result, out whyNotValid);

                            if (isValid)
                            {
                                string oldName = local.ExposedAsName;
                                local.ExposedAsName = tiw.Result;
                                RenameManager.Self.HandleRename(selectedElement, local, oldName);
                                GumCommands.Self.FileCommands.TryAutoSaveCurrentElement();
                                GumCommands.Self.GuiCommands.RefreshPropertyGrid();
                            }
                        }

                    });

                exposed.Members.Add(instanceMember);

            }

            mEventsDataGrid.Categories.Add(exposed);
        }
        private void HandleExposeVariableClick(object sender, System.Windows.RoutedEventArgs e)
        {
            InstanceSave instanceSave = SelectedState.Self.SelectedInstance;
            if (instanceSave == null)
            {
                MessageBox.Show("Cannot expose variables on components or screens, only on instances");
                return;
            }

            StateSave currentStateSave = SelectedState.Self.SelectedStateSave;
            VariableSave variableSave = this.VariableSave;
            bool tempVariable = false;

            if (variableSave == null)
            {
                // This variable hasn't been assigned yet.  Let's make a new variable with a null value

                string variableName = instanceSave.Name + "." + this.RootVariableName;
                string rawVariableName = this.RootVariableName;

                ElementSave elementForInstance = ObjectFinder.Self.GetElementSave(instanceSave.BaseType);

                var variableInDefault = elementForInstance.DefaultState.GetVariableSave(rawVariableName);

                if (variableInDefault != null)
                {
                    string variableType = variableInDefault.Type;

                    currentStateSave.SetValue(variableName, null, instanceSave, variableType);

                    // Now the variable should be created so we can access it
                    variableSave = VariableSave;
                    tempVariable = true;
                }
            }

            if (variableSave == null)
            {
                MessageBox.Show("This variable cannot be exposed.");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter variable name:";
                // We want to use the name without the dots.
                // So something like TextInstance.Text would be
                // TextInstanceText
                tiw.Result = variableSave.Name.Replace(".", "");

                DialogResult result = tiw.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string whyNot;
                    if (!NameVerifier.Self.IsExposedVariableNameValid(tiw.Result, SelectedState.Self.SelectedElement, out whyNot))
                    {
                        MessageBox.Show(whyNot);
                    }
                    else
                    {
                        variableSave.ExposedAsName = tiw.Result;
                        tempVariable = false;

                        GumCommands.Self.FileCommands.TryAutoSaveCurrentElement();
                        GumCommands.Self.GuiCommands.RefreshPropertyGrid(force: true);
                    }
                }
            }

            if (tempVariable)
                currentStateSave.Variables.Remove(variableSave);
        }