private void AddWrapperDataToUIAndCopyFiles(string nextFileName, List <string> unloadedFiles, ComboBox searchTreeLoadedFilesComboBox, ComboBox newObjectViewLoadedFilesComboBox, ComboBox currentGameFilesCenterViewComboBox)
        {
            XmlObjectsListWrapper wrapper = LoadWrapperFromFile(nextFileName);
            string parentPath             = wrapper.XmlFile.ParentPath ?? "";
            string loadedFilePathToFile   = Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName);

            if (wrapper == null)
            {
                unloadedFiles.Add(nextFileName);
            }
            else if (File.Exists(loadedFilePathToFile))
            {
                OverwriteFilePrompt(loadedFilePathToFile, nextFileName);
            }
            else
            {
                File.Copy(nextFileName, Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName));
            }

            if (wrapper != null)
            {
                string wrapperDictionaryKey = wrapper.GenerateDictionaryKey();
                UpdateWrapperInDictionary(wrapperDictionaryKey, wrapper);
                searchTreeLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                newObjectViewLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                currentGameFilesCenterViewComboBox.AddUniqueValueTo(wrapperDictionaryKey);
            }
        }
        private void SetCustomTagWrapper(string[] modOutputFiles, string nextModTag, ComboBox currentModLoadedFilesCenterViewComboBox)
        {
            foreach (string nextModFile in modOutputFiles)
            {
                string newOutputLocation      = Path.Combine(XmlFileManager.LoadedFilesPath, nextModTag);
                XmlObjectsListWrapper wrapper = LoadWrapperFromFile(nextModFile);
                if (wrapper != null)
                {
                    string wrapperDictionaryKey = nextModTag + "_" + wrapper.GenerateDictionaryKey();

                    UpdateWrapperInDictionary(wrapperDictionaryKey, wrapper);
                    if (nextModTag.Equals(Properties.Settings.Default.ModTagSetting))
                    {
                        currentModLoadedFilesCenterViewComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                    }
                    if (!Directory.Exists(newOutputLocation))
                    {
                        Directory.CreateDirectory(newOutputLocation);
                    }
                    string parentPath = wrapper.XmlFile.ParentPath ?? "";
                    if (!File.Exists(Path.Combine(newOutputLocation, parentPath, wrapper.XmlFile.FileName)))
                    {
                        Directory.CreateDirectory(Path.Combine(newOutputLocation, parentPath));
                        File.Copy(nextModFile, Path.Combine(newOutputLocation, parentPath, wrapper.XmlFile.FileName));
                    }
                }
            }
        }
        private static void AddAttributesFromWrapper(XmlObjectsListWrapper wrapper, IList <ICompletionData> data, bool excludeQuotes = false)
        {
            foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys)
            {
                //Get an attribute dictionary for a tag
                Dictionary <string, List <string> > attributeDictinaryForTag = wrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault(nextKey);
                if (attributeDictinaryForTag != null)
                {
                    foreach (string attributeKey in attributeDictinaryForTag.Keys)
                    {
                        List <string>      allAttributesForTag = attributeDictinaryForTag.GetValueOrDefault(attributeKey);
                        SortedSet <string> allKeysToAdd        = new SortedSet <string> ();
                        allKeysToAdd.UnionWith(allAttributesForTag);

                        foreach (string nextAttribute in allKeysToAdd)
                        {
                            MatchCollection matches = IsStringNumberRegex.Matches(nextAttribute);
                            //If there are matches that means it is a number, and we want to filter those out
                            if (matches.Count < 1)
                            {
                                MyCompletionData attributeCompletionDataNoQuotes = new MyCompletionData(nextAttribute, "Xml Node Attribute value: ");
                                data.Add(attributeCompletionDataNoQuotes);
                                if (!excludeQuotes)
                                {
                                    MyCompletionData attributeCompletionDataJustEndQuote = new MyCompletionData(nextAttribute + "\" ", "Xml Node Attribute value: ");
                                    data.Add(attributeCompletionDataJustEndQuote);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
 private static void AddAttributesFromWrapper(XmlObjectsListWrapper wrapper, IList <ICompletionData> data, bool excludeQuotes = false)
 {
     foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys)
     {
         //Get an attribute dictionary for a tag
         Dictionary <string, List <string> > attributeDictinaryForTag = wrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault(nextKey);
         if (attributeDictinaryForTag != null)
         {
             foreach (string attributeKey in attributeDictinaryForTag.Keys)
             {
                 List <string>      allAttributesForTag = attributeDictinaryForTag.GetValueOrDefault(attributeKey);
                 SortedSet <string> allKeysToAdd        = new SortedSet <string> ();
                 allKeysToAdd.UnionWith(allAttributesForTag);
                 foreach (string nextAttribute in allKeysToAdd)
                 {
                     MyCompletionData attributeCompletionDataNoQuotes = new MyCompletionData(nextAttribute, "Xml Node Attribute value: ");
                     data.Add(attributeCompletionDataNoQuotes);
                     if (!excludeQuotes)
                     {
                         MyCompletionData attributeCompletionDataJustEndQuote = new MyCompletionData(nextAttribute + "\" ", "Xml Node Attribute value: ");
                         data.Add(attributeCompletionDataJustEndQuote);
                     }
                 }
             }
         }
     }
 }
        private void OpenDirectEditGameXmlViewButton_Click(object sender, RoutedEventArgs e)
        {
            string selectedObject = CurrentGameFilesCenterViewComboBox.Text;

            if (String.IsNullOrEmpty(selectedObject))
            {
                return;
            }
            //Try to grab the default wrapper
            XmlObjectsListWrapper selectedWrapper = MainWindowFileController.LoadedListWrappers.GetValueOrDefault(selectedObject);

            //If it is still null there is an issue with the file and the file has not been loaded.
            if (selectedWrapper == null)
            {
                selectedWrapper = MainWindowFileController.LoadedListWrappers.GetValueOrDefault(Properties.Settings.Default.ModTagSetting + "_" + selectedObject);
                if (selectedWrapper == null)
                {
                    MessageBox.Show(
                        "The was an error opening the selected file.\n\n" +
                        "There are a couple of possible issues:\n" +
                        "One issue can be invalid xml for the file you are trying to open. You can validate the xml using the \"File Menu Option and fix any errors in an external editor. " +
                        "Note, after fixing any errors in the xml be sure to run the xml validation in the file menu to refresh the loaded objects.\n\n" +
                        "Another way to fix this issue is load the game xml file for the file you are trying to load. " +
                        "For example, if you are trying to open the recipes xml file for a mod, load the game recipes xml file and this will work, even with invalid xml.",
                        "File Loading Error!",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
            }
            DirectEditView directEdit = new DirectEditView(selectedWrapper, true, fileLocationPath: XmlFileManager.LoadedFilesPath);

            directEdit.Closed += DirectEdit_Closed;
            directEdit.Show();
        }
        private XmlObjectsListWrapper LoadWrapperFromFile(string fileName)
        {
            long fileSize = new System.IO.FileInfo(fileName).Length;

            if (fileSize < 1)
            {
                return(null);
            }

            XmlObjectsListWrapper wrapper = null;

            if (fileName.EndsWith(".xml"))
            {
                try
                {
                    wrapper = new XmlObjectsListWrapper(new XmlFileObject(fileName));
                }
                catch (Exception exception)
                {
                    XmlFileManager.WriteStringToLog("Failed to load file with exception:\n" + exception);
                    wrapper = null;
                }
            }
            return(wrapper);
        }
        private void AddEmptyRow_Click(object sender, RoutedEventArgs e)
        {
            //Hard code the wrapper to the items.xml for the mod
            XmlObjectsListWrapper selectedModItemsWrapper = LoadedListWrappers.GetValueOrDefault(ModSelectionComboBox.SelectedItem.ToString() + "_items");
            //Hard code the wrapper to the blocks.xml for the mod
            XmlObjectsListWrapper selectedModBlocksWrapper = LoadedListWrappers.GetValueOrDefault(ModSelectionComboBox.SelectedItem.ToString() + "_blocks");

            ModLocalizationGridUserControl.AddEmptyRow(selectedModItemsWrapper, selectedModBlocksWrapper, GameLocalizationFile);
        }
Пример #8
0
        private void AddWrapperToList(string hardcodedXmlWrapperToUse, List <XmlObjectsListWrapper> wrappersWithKeysToUse)
        {
            XmlObjectsListWrapper loadedModFileWrapper = LoadedListWrappers.GetValueOrDefault(ModSelectionComboBox.SelectedItem.ToString() + hardcodedXmlWrapperToUse);

            if (loadedModFileWrapper != null)
            {
                wrappersWithKeysToUse.Add(loadedModFileWrapper);
            }
        }
Пример #9
0
        public void AddObjectTree(string newObjectViewLoadedFilesComboBoxText)
        {
            if (String.IsNullOrEmpty(newObjectViewLoadedFilesComboBoxText))
            {
                return;
            }
            XmlObjectsListWrapper selectedWrapper = LoadedListWrappers.GetValueOrDefault(newObjectViewLoadedFilesComboBoxText);

            TreeViewGenerator.CreateEmptyNewObjectFormTree(selectedWrapper, newObjectViewLoadedFilesComboBoxText);
        }
        //Gets the wrapper by checking the keys and if the value has the key within
        public static XmlObjectsListWrapper GetWrapperFromDictionary(this Dictionary <string, XmlObjectsListWrapper> dictionaryToCheck, string value)
        {
            XmlObjectsListWrapper wrapperToReturn = null;

            foreach (string key in dictionaryToCheck.Keys)
            {
                if (value.Contains(key))
                {
                    wrapperToReturn = dictionaryToCheck.GetValueOrDefault(key);
                }
            }
            return(wrapperToReturn);
        }
Пример #11
0
        public void AddSearchTree(MyStackPanel searchTreeFormsPanel, ComboBox searchTreeLoadedFilesComboBox, bool isGameFileTree = true, bool includeChildrenInOnHover = false, bool includeComments = false)
        {
            string selectedObject = searchTreeLoadedFilesComboBox.Text;

            if (String.IsNullOrEmpty(selectedObject))
            {
                return;
            }
            XmlObjectsListWrapper selectedWrapper = LoadedListWrappers.GetWrapperFromDictionary(selectedObject);

            if (selectedObject.Split("_").Length > 1)
            {
                selectedWrapper = LoadedListWrappers.GetValueOrDefault(selectedObject);
                if (selectedWrapper == null)
                {
                    MessageBox.Show(
                        "The was an error in the file for " + selectedObject + ".\n\n" +
                        "It is probably malformed xml, to check this, switch to the mod, open the \"File\" menu and click \"Validate Mod files\".",
                        "File Loading Error!",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
            }
            XmlObjectsListWrapper leftObjectWrapper = searchTreeFormsPanel.StackPanelLoadedListWrappers.GetValueOrDefault(selectedObject);
            string gameWrapperKey = selectedWrapper.GenerateDictionaryKey();

            if (leftObjectWrapper == null || leftObjectWrapper.XmlFile.FileSize < this.FILE_SIZE_THRESHOLD)
            {
                TreeViewItem nextTreeView = TreeViewGenerator.GetSearchTreeViewRecursive(selectedWrapper, gameWrapperKey, isGameTree: isGameFileTree, includeChildrenInOnHover: includeChildrenInOnHover, includeComments: includeComments);
                nextTreeView.Header = selectedObject;
                searchTreeFormsPanel.Children.Add(nextTreeView);
            }
            else
            {
                MessageBoxResult result = MessageBox.Show(
                    "That is a large file and consumes a considerable amount of resources, you already have one of those objects in the view. Are you sure you want another? ",
                    "Add Another Large Search Tree",
                    MessageBoxButton.YesNo,
                    MessageBoxImage.Exclamation);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    TreeViewItem nextTreeView = TreeViewGenerator.GetSearchTreeViewRecursive(selectedWrapper, gameWrapperKey, isGameTree: isGameFileTree, includeChildrenInOnHover: includeChildrenInOnHover, includeComments: includeComments);
                    nextTreeView.Header = selectedObject;
                    searchTreeFormsPanel.Children.Add(nextTreeView);
                    break;
                }
            }
        }
        private void OpenDirectEditModXmlViewButton_Click(object sender, RoutedEventArgs e)
        {
            string selectedObject = CurrentModFilesCenterViewComboBox.Text;

            if (String.IsNullOrEmpty(selectedObject))
            {
                return;
            }
            string defaultWrapperKey = selectedObject.Replace(Properties.Settings.Default.ModTagSetting + "_", "");
            //Try to grab the default wrapper
            XmlObjectsListWrapper selectedWrapper = MainWindowFileController.LoadedListWrappers.GetValueOrDefault(defaultWrapperKey);

            if (selectedWrapper == null)
            {
                //Try to load the wrapper from the selected object.
                selectedWrapper = MainWindowFileController.LoadedListWrappers.GetValueOrDefault(selectedObject);
                //If it is still null there is an xml issue
                if (selectedWrapper == null)
                {
                    MessageBox.Show(
                        "The was an error opening the selected file.\n\n" +
                        "There are a couple of possible issues:\n" +
                        "One issue can be invalid xml for the file you are trying to open. You can validate the xml using the \"File Menu Option and fix any errors in an external editor. " +
                        "Note, after fixing any errors in the xml be sure to run the xml validation in the file menu to refresh the loaded objects.\n\n" +
                        "Another way to fix this issue is load the game xml file for the file you are trying to load. " +
                        "For example, if you are trying to open the recipes xml file for a mod, load the game recipes xml file and this will work, even with invalid xml.",
                        "File Loading Error!",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
                else
                {
                    MessageBox.Show("Missing game file " + defaultWrapperKey + ".xml. In order to use all direct edit functions, you must load this file and reopen the file in a new direct edit window.",
                                    "Missing Game File", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            DirectEditView directEdit = new DirectEditView(selectedWrapper, false, fileLocationPath: XmlFileManager.ModConfigOutputPath);

            directEdit.Closed += DirectEdit_Closed;
            directEdit.Show();
        }
        private void LoadFilesPathWrappers(string[] files, ComboBox searchTreeLoadedFilesComboBox, ComboBox newObjectViewLoadedFilesComboBox, ComboBox currentGameFilesCenterViewComboBox)
        {
            foreach (string file in files)
            {
                XmlObjectsListWrapper wrapper = LoadWrapperFromFile(file);
                string parentPath             = wrapper.XmlFile.ParentPath ?? "";
                if (wrapper != null && !File.Exists(Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName)))
                {
                    File.Copy(file, Path.Combine(XmlFileManager.LoadedFilesPath, parentPath, wrapper.XmlFile.FileName));
                }
                if (wrapper != null)
                {
                    string wrapperDictionaryKey = wrapper.GenerateDictionaryKey();

                    UpdateWrapperInDictionary(wrapperDictionaryKey, wrapper);
                    searchTreeLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                    newObjectViewLoadedFilesComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                    currentGameFilesCenterViewComboBox.AddUniqueValueTo(wrapperDictionaryKey);
                }
            }
        }
        private Control AddModKeysColumn(int lastRowPlusOne, int columnCount, XmlObjectsListWrapper selectedModItemsWrapper, XmlObjectsListWrapper selectedModBlocksWrapper)
        {
            topGrid.ColumnDefinitions.Add(new ColumnDefinition());
            ComboBox newCommonValuesBox = new ComboBox
            {
                FontSize   = 18,
                IsEditable = true,
                Background = BackgroundColorController.GetBackgroundColor()
            };

            newCommonValuesBox.Resources.Add(SystemColors.WindowBrushKey, BackgroundColorController.GetBackgroundColor());
            newCommonValuesBox.AddToolTip("key");
            newCommonValuesBox.DropDownClosed += NewCommonValuesBox_DropDownClosed;
            newCommonValuesBox.LostFocus      += NewCommonValuesBox_LostFocus;
            if (selectedModItemsWrapper != null)
            {
                Dictionary <string, List <string> > attributeDictinaryForItems = selectedModItemsWrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault("item");
                if (attributeDictinaryForItems != null)
                {
                    List <string> commonAttributes = attributeDictinaryForItems.GetValueOrDefault("name");
                    commonAttributes.Insert(0, "");
                    newCommonValuesBox.SetComboBox(commonAttributes);
                }
            }
            if (selectedModBlocksWrapper != null)
            {
                Dictionary <string, List <string> > attributeDictinaryForBlocks = selectedModBlocksWrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault("block");
                if (attributeDictinaryForBlocks != null)
                {
                    List <string> commonAttributes = attributeDictinaryForBlocks.GetValueOrDefault("name");
                    newCommonValuesBox.SetComboBox(commonAttributes);
                }
            }
            Grid.SetRow(newCommonValuesBox, lastRowPlusOne);
            Grid.SetColumn(newCommonValuesBox, columnCount);
            topGrid.Children.Add(newCommonValuesBox);
            return(newCommonValuesBox);
        }
        public void AddEmptyRow(XmlObjectsListWrapper selectedModItemsWrapper, XmlObjectsListWrapper selectedModBlocksWrapper, LocalizationFileObject gameLocalizationFile)
        {
            int            lastRowPlusOne     = TextBoxRowDictionary.Keys.Count + 1;
            List <Control> controlsAddedInRow = new List <Control>();
            RowDefinition  rowDefinition      = new RowDefinition();

            topGrid.RowDefinitions.Add(rowDefinition);
            int columnCount = 0;

            AddNumberColumn(lastRowPlusOne, columnCount);
            columnCount++;
            AddClearButton(lastRowPlusOne, columnCount);
            columnCount++;
            AddModKeysColumn(lastRowPlusOne, columnCount, selectedModItemsWrapper, selectedModBlocksWrapper);
            columnCount++;
            //In the game file it is file, in the mod file it is source
            string headerKey = "file";

            controlsAddedInRow.Add(AddGameFileColumn(lastRowPlusOne, columnCount, headerKey, gameLocalizationFile));
            columnCount++;
            headerKey = "type";
            controlsAddedInRow.Add(AddGameFileColumn(lastRowPlusOne, columnCount, headerKey, gameLocalizationFile));
            columnCount++;
            controlsAddedInRow.Add(AddChangesColumn(lastRowPlusOne, columnCount));
            columnCount++;
            List <string> emptyRecord = new List <string>();

            for (int textBoxCount = 0; textBoxCount < LocalizationFileObject.HeaderKeyToCommonValuesMap.Keys.Count; textBoxCount++)
            {
                //This means there was not a row to mimic, increase the count by one to avoid that.
                emptyRecord.Add("");
            }
            int skipHeadersCount = 4;

            AddFieldColumns(lastRowPlusOne, columnCount, emptyRecord, controlsAddedInRow, skipHeadersCount);
        }
        private void CurrentModFilesCenterViewComboBox_DropDownClosed(object sender, EventArgs e)
        {
            ComboBox senderAsBox = sender as ComboBox;
            string   wrapperKey  = senderAsBox.Text;

            if (!String.IsNullOrEmpty(wrapperKey))
            {
                XmlObjectsListWrapper xmlObjectsListWrapper = this.MainWindowFileController.LoadedListWrappers.GetValueOrDefault(wrapperKey);
                xmlObjectsListWrapper ??= this.MainWindowFileController.LoadedListWrappers.GetValueOrDefault(Properties.Settings.Default.ModTagSetting + "_" + wrapperKey);
                if (xmlObjectsListWrapper == null)
                {
                    MessageBox.Show(
                        "The was an error in the file for " + Properties.Settings.Default.ModTagSetting + "_" + wrapperKey + ".\n\n" +
                        "It is probably malformed xml, to check this, switch to the mod, open the \"File\" menu and click \"Validate Mod files\".",
                        "File Loading Error!",
                        MessageBoxButton.OK,
                        MessageBoxImage.Error);
                    return;
                }
                string parentPath = xmlObjectsListWrapper.XmlFile.ParentPath ?? "";

                this.XmlOutputBox.Text = XmlFileManager.ReadExistingFile(Path.Combine(parentPath, xmlObjectsListWrapper.XmlFile.FileName));
            }
        }
Пример #17
0
        internal static IList <ICompletionData> GenerateAttributeList(CompletionWindow completionWindow, XmlObjectsListWrapper gameFileWrapper, XmlObjectsListWrapper currentFileWrapper)
        {
            IList <ICompletionData> data = completionWindow.CompletionList.CompletionData;

            AddAttributesFromWrapper(gameFileWrapper, data);
            AddAttributesFromWrapper(currentFileWrapper, data);

            return(data);
        }
Пример #18
0
        internal static IList <ICompletionData> GenerateTagList(CompletionWindow completionWindow, XmlObjectsListWrapper wrapper)
        {
            IList <ICompletionData> data = completionWindow.CompletionList.CompletionData;

            data.Add(new MyCompletionData("!-- -->", "Xml Comment: "));
            data.Add(new MyCompletionData("!-- \n\n -->", "Xml Comment on multiple lines: "));
            AddXpathCommands(data);
            foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys)
            {
                string justTag = nextKey;
                data.Add(new MyCompletionData(justTag, "Xml Node: "));
                string tagAndClosingTag = nextKey + "></" + nextKey + ">";
                data.Add(new MyCompletionData(tagAndClosingTag, "Xml Node Open and Closing tags: "));
            }
            return(data);
        }
Пример #19
0
        internal static IList <ICompletionData> GenerateCommonAttributesList(CompletionWindow completionWindow, XmlObjectsListWrapper gameFileWrapper, XmlObjectsListWrapper currentFileWrapper)
        {
            IList <ICompletionData> data         = completionWindow.CompletionList.CompletionData;
            SortedSet <string>      allKeysToAdd = new SortedSet <string>();

            foreach (string nextKey in gameFileWrapper.ObjectNameToAttributeValuesMap.Keys)
            {
                Dictionary <string, List <string> > attributeDictinaryForTag = gameFileWrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault(nextKey);
                if (attributeDictinaryForTag != null)
                {
                    foreach (string attributeKey in attributeDictinaryForTag.Keys)
                    {
                        allKeysToAdd.Add(attributeKey);
                    }
                }
            }
            foreach (string nextKeyToAdd in allKeysToAdd)
            {
                data.Add(new MyCompletionData(nextKeyToAdd, "Xml Node Attribute: "));
            }
            AddAttributesFromWrapper(gameFileWrapper, data, true);
            AddAttributesFromWrapper(currentFileWrapper, data, true);
            return(data);
        }
        //NEED TO MAKE THIS WORK FOR /
        internal static IList <ICompletionData> GenerateEndTagListAfterSlash(CompletionWindow completionWindow, XmlObjectsListWrapper wrapper)
        {
            IList <ICompletionData> data = completionWindow.CompletionList.CompletionData;

            foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys)
            {
                string justClosingTag = nextKey + ">";
                data.Add(new MyCompletionData(justClosingTag, "Xml Node Closing tag: "));
            }
            foreach (string nextCommand in AllXpathComands)
            {
                string justClosingTag = nextCommand + ">";
                data.Add(new MyCompletionData(justClosingTag, "Xml Node Xpath Command Closin tag: "));
            }
            data.Add(new MyCompletionData(">", "Single Line Close"));

            return(data);
        }
        public DirectEditView(XmlObjectsListWrapper wrapperToUse, string dictionaryKey, bool isGameFile, bool isFirstWindowOpen = true, string title = null, string contentsForXmlOutputBox = null, string fileLocationPath = "", string unchangedStartingFileContents = null)
        {
            InitializeComponent();
            this.Wrapper           = wrapperToUse;
            this.IsGameFile        = isGameFile;
            this.FileLocationPath  = fileLocationPath;
            this.DictionaryKey     = dictionaryKey;
            this.IsFirstWindowOpen = isFirstWindowOpen;
            if (contentsForXmlOutputBox == null)
            {
                string parentString = Wrapper.XmlFile.ParentPath ?? "";
                XmlOutputBox.Text = XmlFileManager.GetFileContents(Path.Combine(this.FileLocationPath, parentString), Wrapper.XmlFile.FileName);
            }
            else
            {
                XmlOutputBox.Text = contentsForXmlOutputBox;
            }
            this.StartingFileContents          = XmlOutputBox.Text;
            this.UnchangedStartingFileContents = unchangedStartingFileContents ?? XmlOutputBox.Text;

            string labelContents = isGameFile
                ? "Game File: " + wrapperToUse.XmlFile.FileName + "\n"
                : "Mod: " + Properties.Settings.Default.ModTagSetting + "\n" + "File: " + wrapperToUse.XmlFile.FileName + "\n";

            this.StartingTitle = isGameFile
                ? "Game File: " + wrapperToUse.XmlFile.FileName
                : wrapperToUse.XmlFile.GetFileNameWithoutExtension() + " : " + Properties.Settings.Default.ModTagSetting;

            this.Title = StartingTitle;

            this.SaveXmlButton.AddToolTip("Click to save all changes");
            this.ReloadFileXmlButton.AddToolTip("Click here to reload the file from disk");
            this.CloseButton.AddToolTip("Click here to close the window");
            this.ValidateXmlButton.AddToolTip("Click here to validate the xml");
            this.UndoAllChangesXmlButton.AddToolTip("Click here to undo any changes made since opening the window");
            this.CodeCompletionKeysHelpButton.AddToolTip("Click here to see the keys used for\nAuto Complete within this window");
            this.CombineTagsXmlButton.AddToolTip("Click here to combine all top level APPEND tags, into a single APPEND tag.\n" +
                                                 "EX: In the file there are completly new RECIPES under seperate APPEND tags that can be combined.");

            SearchPanel.Install(XmlOutputBox);

            FoldingManager  = FoldingManager.Install(this.XmlOutputBox.TextArea);
            FoldingStrategy = new XmlFoldingStrategy
            {
                ShowAttributesWhenFolded = true
            };
            FoldingStrategy.UpdateFoldings(FoldingManager, this.XmlOutputBox.Document);

            TextEditorOptions newOptions = new TextEditorOptions
            {
                EnableRectangularSelection = true,
                EnableTextDragDrop         = true,
                HighlightCurrentLine       = true,
                ShowTabs = true
            };

            this.XmlOutputBox.TextArea.Options = newOptions;

            this.XmlOutputBox.ShowLineNumbers = true;

            this.XmlOutputBox.AddContextMenu(CollapseAllContextMenu_Clicked,
                                             "Collapse All",
                                             "Click here to collapse all nodes in the document.");
            this.XmlOutputBox.AddContextMenu(ExpandAllContextMenu_Clicked,
                                             "Expand All",
                                             "Click here to expand all nodes in the document.");

            this.XmlOutputBox.GotMouseCapture       += XmlOutputBox_GotMouseCapture;
            this.XmlOutputBox.PreviewMouseWheel     += XmlOutputBox_PreviewMouseWheel;
            this.XmlOutputBox.TextChanged           += XmlOutputBox_TextChanged;
            this.XmlOutputBox.TextArea.TextEntering += TextArea_TextEntering;
            this.XmlOutputBox.TextArea.TextEntered  += TextArea_TextEntered;
            this.XmlOutputBox.Focus();
            SetBackgroundColor();
            Closing += new CancelEventHandler(DirectEditView_Closing);
        }
Пример #22
0
        internal static IList <ICompletionData> GenerateEndTagList(CompletionWindow completionWindow, XmlObjectsListWrapper wrapper)
        {
            IList <ICompletionData> data = completionWindow.CompletionList.CompletionData;

            foreach (string nextKey in wrapper.ObjectNameToAttributeValuesMap.Keys)
            {
                string justClosingTag = "</" + nextKey + ">";
                data.Add(new MyCompletionData(justClosingTag, "Xml Node Closing tag: "));
            }
            return(data);
        }
        // Type: ctrl-space
        internal static IList <ICompletionData> GenerateCommonAttributesList(CompletionWindow completionWindow, XmlObjectsListWrapper gameFileWrapper, XmlObjectsListWrapper currentFileWrapper)
        {
            IList <ICompletionData> data         = completionWindow.CompletionList.CompletionData;
            SortedSet <string>      allKeysToAdd = new SortedSet <string>();

            foreach (string nextKey in gameFileWrapper.ObjectNameToAttributeValuesMap.Keys)
            {
                Dictionary <string, List <string> > attributeDictinaryForTag = gameFileWrapper.ObjectNameToAttributeValuesMap.GetValueOrDefault(nextKey);
                if (attributeDictinaryForTag != null)
                {
                    foreach (string attributeKey in attributeDictinaryForTag.Keys)
                    {
                        MatchCollection matches = IsStringNumberRegex.Matches(attributeKey);
                        //If there are matches that means it is a number, and we want to filter those out
                        if (matches.Count < 1)
                        {
                            allKeysToAdd.Add(attributeKey);
                        }
                    }
                }
            }
            foreach (string nextKeyToAdd in allKeysToAdd)
            {
                data.Add(new MyCompletionData(nextKeyToAdd, "Xml Node Attribute: "));
            }
            AddAttributesFromWrapper(gameFileWrapper, data, true);
            AddAttributesFromWrapper(currentFileWrapper, data, true);
            return(data);
        }
 private void UpdateWrapperInDictionary(string key, XmlObjectsListWrapper updatedWrapper)
 {
     this.LoadedListWrappers.Remove(key);
     this.LoadedListWrappers.Add(key, updatedWrapper);
 }