Пример #1
0
        private void AskToStartTest()
        {
            var result = MessageBox.Show("Would you like to start this test?", "Start test", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                var textInputWindow = new TextInputWindow("Enter your name");
                textInputWindow.ShowDialog();

                if (textInputWindow.DialogResult == true)
                {
                    var studentName = textInputWindow.EnteredText;

                    var testPath      = filePaths[PathsList.SelectedIndex];
                    var testDirectory = testPath.Substring(0, testPath.LastIndexOf('\\'));

                    var passingWindow = new PassingWindow(testPath, $"{testDirectory}\\Results\\{studentName}.tmr", false, studentName);

                    if (passingWindow.IsLoadedProperly)
                    {
                        passingWindow.Show();
                        Close();
                    }
                }
            }
        }
        private void HandleRenameAnimation(object sender, RoutedEventArgs e)
        {
            TextInputWindow tiw = new TextInputWindow();

            tiw.Message = "Enter new animation name:";
            tiw.Result  = SelectedAnimation.Name;

            var dialogResult = tiw.ShowDialog();

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

                    StateAnimationPlugin.Managers.RenameManager.Self.HandleRename(
                        SelectedAnimation,
                        oldAnimationName, Animations, Element);
                }
            }
        }
Пример #3
0
        internal void Sprite()
        {
            if (ArrowState.Self.CurrentArrowElementSave != null)
            {
                TextInputWindow tiw = new TextInputWindow();

                tiw.Text   = "Enter new Sprite name:";
                tiw.Result = "Sprite";
                var result = tiw.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    bool isInvalid = CheckAndShowMessageIfInvalid(tiw.Result);

                    if (!isInvalid)
                    {
                        SpriteSave spriteSave = new SpriteSave();
                        spriteSave.ScaleX         = 16;
                        spriteSave.ScaleY         = 16;
                        spriteSave.Name           = tiw.Result;
                        spriteSave.ColorOperation = "Color";

                        spriteSave.TintRed   = 255;
                        spriteSave.TintGreen = 255;

                        ArrowState.Self.CurrentArrowElementSave.Sprites.Add(spriteSave);

                        AfterAddLogic(ArrowState.Self.CurrentArrowElementSave, spriteSave);
                    }
                }
            }
        }
Пример #4
0
        internal void Rectangle()
        {
            if (ArrowState.Self.CurrentArrowElementSave != null)
            {
                TextInputWindow tiw = new TextInputWindow();

                tiw.Text   = "Enter new Rectangle name:";
                tiw.Result = "Rectangle";
                var result = tiw.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    bool isInvalid = CheckAndShowMessageIfInvalid(tiw.Result);

                    if (!isInvalid)
                    {
                        AxisAlignedRectangleSave rectangleSave = new AxisAlignedRectangleSave();
                        rectangleSave.ScaleX = 16;
                        rectangleSave.ScaleY = 16;
                        rectangleSave.Name   = tiw.Result;

                        ArrowState.Self.CurrentArrowElementSave.Rectangles.Add(rectangleSave);

                        AfterAddLogic(ArrowState.Self.CurrentArrowElementSave, rectangleSave);
                    }
                }
            }
        }
Пример #5
0
        private void AddNamedEventButton_Click(object sender, RoutedEventArgs e)
        {
            var textInputWindow = new TextInputWindow();

            textInputWindow.Message = "Enter new event name";
            var result = textInputWindow.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                AnimatedKeyframeViewModel newVm = new AnimatedKeyframeViewModel();

                newVm.EventName = textInputWindow.Result;

                if (ViewModel.SelectedAnimation.SelectedKeyframe != null)
                {
                    // put this after the current animation
                    newVm.Time = ViewModel.SelectedAnimation.SelectedKeyframe.Time + 1f;
                }
                else if (ViewModel.SelectedAnimation.Keyframes.Count != 0)
                {
                    newVm.Time = ViewModel.SelectedAnimation.Keyframes.Last().Time + 1f;
                }


                ViewModel.SelectedAnimation.Keyframes.Add(newVm);

                ViewModel.SelectedAnimation.Keyframes.BubbleSort();
            }
        }
Пример #6
0
        internal void Circle()
        {
            if (ArrowState.Self.CurrentArrowElementSave != null)
            {
                TextInputWindow tiw = new TextInputWindow();

                tiw.Text   = "Enter new Circle name:";
                tiw.Result = "Circle";

                var result = tiw.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    bool isInvalid = CheckAndShowMessageIfInvalid(tiw.Result);

                    if (!isInvalid)
                    {
                        CircleSave circleSave = new CircleSave();
                        circleSave.Radius = 16;
                        circleSave.Name   = tiw.Result;

                        ArrowState.Self.CurrentArrowElementSave.Circles.Add(circleSave);

                        AfterAddLogic(ArrowState.Self.CurrentArrowElementSave, circleSave);
                    }
                }
            }
        }
Пример #7
0
        private void BtnRename_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (FilePanel.SelectedIndex < 0)
            {
                return;
            }
            TextInputWindow ti = new TextInputWindow();

            ti.Title = "Enter new file name:";
            if (ti.ShowDialog() == true)
            {
                string oldkey = GetKey(FilePanel.SelectedIndex);
                if (File.Exists(_dir + "\\" + oldkey))
                {
                    try
                    {
                        File.Move(_dir + "\\" + oldkey, _dir + "\\" + ti.InputText);
                    }
                    catch (IOException ex)
                    {
                        WpfHelpers.ExceptionDialog("Error renaming file: " + oldkey, ex);
                        return;
                    }
                }
                _files.Add(ti.InputText, _files[oldkey]);
                _files.Remove(oldkey);
            }
        }
Пример #8
0
        public void ScaleEmitterTimeClick(Window callingWindow)
        {
            TextInputWindow tiw = GuiManager.ShowTextInputWindow("Enter speed percentage.  Values over 100% will speed up the Emitter.", "Scale Emitter Speed");

            tiw.Text     = "100";
            tiw.OkClick += new GuiMessage(ScaleEmitterTimeOk);
        }
Пример #9
0
        private static NamedObjectSave HandleAddShape(string message, string sourceClassType)
        {
            NamedObjectSave toReturn = null;

            var tiw = new TextInputWindow();

            tiw.Message = message;
            var dialogResult = tiw.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                string whyItIsntValid;
                NameVerifier.IsNamedObjectNameValid(tiw.Result, out whyItIsntValid);

                if (!string.IsNullOrEmpty(whyItIsntValid))
                {
                    GlueCommands.Self.DialogCommands.ShowMessageBox(whyItIsntValid);
                }
                else
                {
                    var viewModel = new AddObjectViewModel();

                    viewModel.ObjectName      = tiw.Result;
                    viewModel.SourceType      = SaveClasses.SourceType.FlatRedBallType;
                    viewModel.SourceClassType = sourceClassType;

                    toReturn = GlueCommands.Self.GluxCommands.AddNewNamedObjectToSelectedElement(viewModel);

                    GlueState.Self.CurrentNamedObjectSave = toReturn;
                }
            }

            return(toReturn);
        }
        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();
                }
            }
        }
Пример #11
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();
                }
            }
        }
Пример #12
0
        //public Button AddKeyframeListButton
        //{
        //    get { return mAddKeyframeListButton; }
        //}


        #endregion

        #region Event Methods

        private void AddKeyframeListClick(Window callingWindow)
        {
            if (EditorData.EditorLogic.CurrentInstructionSet == null)
            {
                GuiManager.ShowMessageBox("Currently the InstructionEditor is under \"Current'\" editing mode." +
                                          "  To add an Animation, you must have a selected object first.", "Error");

                return;
            }

            TextInputWindow tiw = GuiManager.ShowTextInputWindow("Enter a name for the new Animation:", "Enter name");

            if (GuiData.TimeLineWindow.InstructionMode == InstructionMode.Current)
            {
                if (EditorData.EditorLogic.CurrentInstructionSet != null)
                {
                    tiw.Text = "Keyframe List " + EditorData.EditorLogic.CurrentInstructionSet.Count;
                }
                else
                {
                    tiw.Text = "Keyframe List " + 0;
                }
            }
            else
            {
                tiw.Text = "Animation " + EditorData.GlobalInstructionSets.Count;
            }

            tiw.OkClick += new GuiMessage(AddKeyframeListOk);
        }
Пример #13
0
        public bool Rename(RenameOptions renameOptions, out string newName)
        {
            if (renameOptions == null)
            {
                throw new ArgumentNullException(nameof(renameOptions));
            }

            newName = null;

            var inputWindow = new TextInputWindow(
                renameOptions.WindowTitle ?? "Rename",
                renameOptions.WindowPrompt ?? "Rename:",
                renameOptions.WindowDefaultValue,
                renameOptions.IsInputMandatory
                );

            if (inputWindow.ShowDialog() != true)
            {
                return(false);
            }

            if (inputWindow.Text == renameOptions.WindowDefaultValue)
            {
                return(false);
            }

            if (renameOptions.IsValid != null && renameOptions.IsValid(inputWindow.Text) == false)
            {
                MessageBox.Show($"Invalid name '{inputWindow.Text}'.", "Invalid name", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            newName = inputWindow.Text;
            return(true);
        }
Пример #14
0
        public void AskToAddComponent()
        {
            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;
                    TreeNode nodeToAddTo = ElementTreeViewManager.Self.SelectedNode;

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

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

                    FilePath path = nodeToAddTo.GetFullFilePath();

                    string relativeToComponents = FileManager.MakeRelative(path.StandardizedCaseSensitive,
                                                                           FileLocations.Self.ComponentsFolder, preserveCase: true);

                    AddComponent(name, relativeToComponents);
                }
            }
        }
Пример #15
0
        public void AddCategory()
        {
            var target = SelectedState.Self.SelectedStateContainer as IStateCategoryListContainer;

            if (target == null)
            {
                MessageBox.Show("You must first select an element or behavior 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(
                        target, name);

                    ElementTreeViewManager.Self.RefreshUi(SelectedState.Self.SelectedStateContainer);

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

                    SelectedState.Self.SelectedStateCategorySave = category;

                    GumCommands.Self.FileCommands.TryAutoSaveCurrentObject();
                }
            }
        }
Пример #16
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);
        }
Пример #17
0
        public void AddCategory()
        {
            var target = SelectedState.Self.SelectedStateContainer as IStateCategoryListContainer;

            if (target == null)
            {
                MessageBox.Show("You must first select an element or behavior to add a state category");
            }
            else
            {
                TextInputWindow tiw = new TextInputWindow();
                tiw.Message = "Enter new category name:";

                var canAdd = true;

                var result = tiw.ShowDialog();

                if (result != DialogResult.OK)
                {
                    canAdd = false;
                }

                string name = null;

                if (canAdd)
                {
                    name = tiw.Result;

                    // see if any base elements have thsi category
                    if (target is ElementSave element)
                    {
                        var existingCategory = element.GetStateSaveCategoryRecursively(name, out ElementSave categoryContainer);

                        if (existingCategory != null)
                        {
                            MessageBox.Show($"Cannot add category - a category with the name {name} is already defined in {categoryContainer}");
                            canAdd = false;
                        }
                    }
                }


                if (canAdd)
                {
                    StateSaveCategory category = ElementCommands.Self.AddCategory(
                        target, name);

                    ElementTreeViewManager.Self.RefreshUi(SelectedState.Self.SelectedStateContainer);

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

                    PluginManager.Self.CategoryAdd(category);

                    SelectedState.Self.SelectedStateCategorySave = category;

                    GumCommands.Self.FileCommands.TryAutoSaveCurrentObject();
                }
            }
        }
Пример #18
0
        void ScalePointTimeClick(Window callingWindow)
        {
            TextInputWindow tiw = GuiManager.ShowTextInputWindow("Enter amount to scale time by.  A value of 2 will double the length.", "Enter Scale");

            tiw.Format   = TextBox.FormatTypes.Decimal;
            tiw.Text     = "1";
            tiw.OkClick += ScalePointTimeOk;
        }
Пример #19
0
        private void AddKeyframe(Window callingWindow)
        {
            #region See if adding is allowed (Are there objects to record).  If not, show a message

            if (EditorData.CurrentSpriteMembersWatching.Count == 0 &&
                EditorData.CurrentSpriteFrameMembersWatching.Count == 0 &&
                EditorData.CurrentPositionedModelMembersWatching.Count == 0 &&
                EditorData.CurrentTextMembersWatching.Count == 0)
            {
                GuiManager.ShowMessageBox("There are no members being recorded.  Try opening the " +
                                          "\"used members\" window through Window->Used Members menu item.", "No members");
                return;
            }

            if (GuiData.TimeLineWindow.InstructionMode == InstructionMode.Current)
            {
                if (EditorData.EditorLogic.CurrentKeyframeList == null)
                {
                    GuiManager.ShowMessageBox("There is no Keyframe List currently selected", "Error");
                    return;
                }

                if (EditorData.EditorLogic.CurrentSprites.Count == 0 &&
                    EditorData.EditorLogic.CurrentSpriteFrames.Count == 0 &&
                    EditorData.EditorLogic.CurrentPositionedModels.Count == 0 &&
                    EditorData.EditorLogic.CurrentTexts.Count == 0)
                {
                    GuiManager.ShowMessageBox("No object is selected.  Select an object to record.", "No selected object.");
                    return;
                }
            }
            else if (GuiData.TimeLineWindow.InstructionMode == InstructionMode.All)
            {
                if (EditorData.EditorLogic.CurrentAnimationSequence == null)
                {
                    GuiManager.ShowMessageBox("There is no Animation currently selected", "Error");
                    return;
                }
            }
            #endregion

            if (GuiData.TimeLineWindow.InstructionMode == InstructionMode.All)
            {
                KeyframeListSelectionWindow klsw = new KeyframeListSelectionWindow(GuiManager.Cursor);
                GuiManager.AddWindow(klsw);
                klsw.PopulateComboBoxes(EditorData.BlockingScene, EditorData.ObjectInstructionSets);

                klsw.OkClick += AddKeyframeToGlobalInstrutionSet;
            }
            else
            {
                TextInputWindow tiw = GuiManager.ShowTextInputWindow("Enter a name for the new keyframe:", "Enter name");
                tiw.Text = "Keyframe " + EditorData.EditorLogic.CurrentKeyframeList.Count;

                tiw.OkClick += new GuiMessage(AddKeyframeOk);
            }
        }
Пример #20
0
        public void addEmitterClick(FlatRedBall.Gui.Window callingWindow)
        {
            TextInputWindow tempWindow = GuiManager.ShowTextInputWindow("Enter a name for the new Emitter", "Add Particle");

            tempWindow.Text = "Emitter" + NumberOfEmittersCreated;
            NumberOfEmittersCreated++;

            tempWindow.OkClick += new GuiMessage(addEmitterOkClick);
        }
Пример #21
0
        void ScalePositionAndScaleOnly(Window callingWindow)
        {
            TextInputWindow tiw = GuiManager.ShowTextInputWindow(
                "Enter scale amount.  Scale will be applied on X, Y, and Z", "Scale Scene");

            tiw.Text     = "1.0";
            tiw.Format   = TextBox.FormatTypes.Decimal;
            tiw.OkClick += ScalePositionsAndScaleOk;
        }
        private void ScaleEmitterClick(Window callingWindow)
        {
            TextInputWindow tiw = GuiManager.ShowTextInputWindow(
                "Enter amount to scale by", "Scale Emitter");

            tiw.Format = TextBox.FormatTypes.Decimal;

            tiw.OkClick += ScaleEmitterOk;
        }
Пример #23
0
        private void DownloadExecute()
        {
            string downloadExec = TextInputWindow.ShowWindow("Download and Execute", "URL to download:");

            if (!string.IsNullOrEmpty(downloadExec))
            {
                this.ClientSocket.SendObject(PacketId.DOWNLOAD_AND_EXECUTE, downloadExec);
            }
        }
Пример #24
0
        void ScalePointPositionClick(Window callingWindow)
        {
            TextInputWindow tiw = GuiManager.ShowTextInputWindow("Enter amount to scale position by.  Spline will scale relative to its first point.", "Enter Scale");

            tiw.Format = TextBox.FormatTypes.Decimal;
            tiw.Text   = "1";

            tiw.OkClick += ScalePointPositionOk;
        }
Пример #25
0
        void ScalePositionsAndScaleOk(Window callingWindow)
        {
            TextInputWindow window =
                callingWindow as TextInputWindow;

            float value = float.Parse(window.Text);

            Vector3 amountToShiftBy = new Vector3(value, value, value);


            Scene scene = GameData.Scene;

            for (int i = 0; i < scene.PositionedModels.Count; i++)
            {
                scene.PositionedModels[i].X *= amountToShiftBy.X;
                scene.PositionedModels[i].Y *= amountToShiftBy.Y;
                scene.PositionedModels[i].Z *= amountToShiftBy.Z;

                scene.PositionedModels[i].ScaleX *= amountToShiftBy.X;
                scene.PositionedModels[i].ScaleY *= amountToShiftBy.Y;
                scene.PositionedModels[i].ScaleZ *= amountToShiftBy.Z;
            }

            for (int i = 0; i < scene.SpriteFrames.Count; i++)
            {
                scene.SpriteFrames[i].X *= amountToShiftBy.X;
                scene.SpriteFrames[i].Y *= amountToShiftBy.Y;
                scene.SpriteFrames[i].Z *= amountToShiftBy.Z;

                scene.SpriteFrames[i].ScaleX *= amountToShiftBy.X;
                scene.SpriteFrames[i].ScaleY *= amountToShiftBy.Y;
            }

            for (int i = 0; i < scene.Sprites.Count; i++)
            {
                scene.Sprites[i].X *= amountToShiftBy.X;
                scene.Sprites[i].Y *= amountToShiftBy.Y;
                scene.Sprites[i].Z *= amountToShiftBy.Z;

                scene.Sprites[i].ScaleX *= amountToShiftBy.X;
                scene.Sprites[i].ScaleY *= amountToShiftBy.Y;
            }

            for (int i = 0; i < scene.Texts.Count; i++)
            {
                scene.Texts[i].X *= amountToShiftBy.X;
                scene.Texts[i].Y *= amountToShiftBy.Y;
                scene.Texts[i].Z *= amountToShiftBy.Z;

                scene.Texts[i].Scale           *= amountToShiftBy.X;
                scene.Texts[i].Spacing         *= amountToShiftBy.X;
                scene.Texts[i].NewLineDistance *= amountToShiftBy.X;
            }

            GuiManager.RemoveWindow(window);
        }
        void CreatePackFile()
        {
            TextInputWindow window = new TextInputWindow("New Packfile name", "");

            if (window.ShowDialog() == true)
            {
                var newPackFile = _packfileService.CreateNewPackFileContainer(window.TextValue, PackFileCAType.MOD);
                _packfileService.SetEditablePack(newPackFile);
            }
        }
        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);
                    }
                }
            }
        }
Пример #28
0
        private void HandlePublishAsInput(object sender, RoutedEventArgs e)
        {
            if (m_OperatorParts.Count == 0)
            {
                return;
            }

            var cgv = App.Current.MainWindow.CompositionView.CompositionGraphView;
            List <ISelectable> selectedElements = cgv.SelectedElements;

            if (cgv.CompositionOperator.Parent == null)
            {
                MessageBox.Show("You cannot publish a parameter to the home-operator. First, either combine some operators into a new Operator-Type or open another operator.",
                                "Sorry");
                return;
            }

            var baseName   = m_OperatorParts[0].Parent.GetMetaInput(m_OperatorParts[0]).Name.Split(new[] { '.' })[0];
            var parameters = (from opPart in m_OperatorParts
                              let splittedName = opPart.Parent.GetMetaInput(opPart).Name.Split(new[] { '.' })
                                                 select new { OpPart = opPart, SubName = splittedName.Count() > 1 ? splittedName.Last() : String.Empty }).ToList();

            var popup = new TextInputWindow();

            popup.XText.Text    = "Input parameter name?";
            popup.XTextBox.Text = baseName;
            popup.XTextBox.SelectAll();
            popup.XTextBox.Focus();
            popup.ShowDialog();
            if (popup.DialogResult == false)
            {
                return;
            }

            var commandList = new List <ICommand>();

            foreach (var p in parameters)
            {
                var name = popup.XTextBox.Text;
                if (p.SubName.Any())
                {
                    name += "." + p.SubName;
                }

                var publishCommand = new PublishAsInputCommand(p.OpPart, name);
                publishCommand.Do();
                commandList.Add(publishCommand);
            }
            App.Current.UndoRedoStack.Add(new MacroCommand("Publish as Inputs", commandList));

            if (m_OperatorParts.Count > 1)
            {
                cgv.SelectedElements = selectedElements;
            }
        }
        private static void AskToCreateEntity(out TextInputWindow tiw, out ControlForAddingCollision collisionControl, out DialogResult result)
        {
            tiw             = new TextInputWindow();
            tiw.DisplayText = "Enter entity name:";

            collisionControl = new ControlForAddingCollision();

            tiw.AddControl(collisionControl);

            result = tiw.ShowDialog();
        }
Пример #30
0
        public void AddDisplayRegion(Window callingWindow)
        {
            TextInputWindow textInputWindow = GuiManager.ShowTextInputWindow(
                "Enter name for new Display Region", "Enter Name");

            textInputWindow.Text =
                FileManager.RemovePath(GuiData.TextureCoordinatesSelectionWindow.DisplayedTexture.Name) +
                " Sub" + (GuiData.ListWindow.TextureListBox.GetItem(GuiData.TextureCoordinatesSelectionWindow.DisplayedTexture).Count + 1);

            textInputWindow.OkClick += AddDisplayRegionOk;
        }