예제 #1
0
        //NameList
        private void NameList_Item_Click(object sender, RoutedEventArgs e)
        {
            if (effectContainerFile == null)
            {
                return;
            }

            try
            {
                MenuItem selectedMenuItem = e.OriginalSource as MenuItem;

                if (selectedMenuItem != null)
                {
                    NameList.NameListFile nameList = selectedMenuItem.DataContext as NameList.NameListFile;

                    if (nameList != null)
                    {
                        eepkEditor.nameListManager.ApplyNameList(effectContainerFile.Effects, nameList.GetNameList());
                    }
                }
            }
            catch (Exception ex)
            {
                SaveExceptionLog(ex.ToString());
                MessageBox.Show(String.Format("Failed to apply the name list.\n\nDetails: {0}\n\nA log containing more details about the error was saved at \"{1}\".", ex.Message, SettingsManager.Instance.GetErrorLogPath()), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #2
0
        public void SaveNameList(IList <Effect> effects)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();

            saveDialog.Title            = "Save Name List";
            saveDialog.Filter           = "XML file | *.xml";
            saveDialog.InitialDirectory = Path.GetFullPath(NameListDir);
            saveDialog.AddExtension     = true;
            saveDialog.ShowDialog();

            if (!String.IsNullOrWhiteSpace(saveDialog.FileName))
            {
                string selectedDir = Path.GetDirectoryName(saveDialog.FileName);

                //Create the Name List
                NameList nameList = new NameList();
                nameList.Names = new List <NameListEntry>();

                foreach (var effect in effects)
                {
                    if (effect.NameList != null)
                    {
                        nameList.Names.Add(new NameListEntry()
                        {
                            EffectID    = effect.IndexNum,
                            Description = effect.NameList
                        });
                    }
                }

                //Save Name List
                nameList.Save(saveDialog.FileName);

                //Add Name List to current list
                if (selectedDir == Path.GetFullPath(NameListDir))
                {
                    NameListFile nameListFile = new NameListFile();
                    nameListFile.Name = Path.GetFileNameWithoutExtension(saveDialog.FileName);
                    nameListFile.path = saveDialog.FileName;
                    nameListFile.File = nameList;
                    LoadedNameLists.Add(nameListFile);
                }

                MessageBox.Show("The name list was saved.", "Save Name List", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show("The entered path was invalid.", "Save Name List", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }