Esempio n. 1
0
        private void WirteModFile(PdxMod pdxMod)
        {
            var filePath = ModGlobalData.MOD_PATH_ROOT + pdxMod.Directory + ".mod";

            File.WriteAllText(filePath, pdxMod.ToString());

            var descriptorMod = pdxMod.Clone();

            descriptorMod.Directory = "";
            var descriptorPath = ModGlobalData.MOD_PATH_ROOT + pdxMod.Directory + @"\descriptor.mod";

            File.WriteAllText(descriptorPath, descriptorMod.ToString());

            ListBoxItem      listBoxItem      = (ListBoxItem)(listView.ItemContainerGenerator.ContainerFromIndex(listView.SelectedIndex));
            ContentPresenter contentPresenter = FindVisualChild <ContentPresenter>(listBoxItem);
            DataTemplate     dataTemplate     = contentPresenter.ContentTemplate;
            Image            target           = (Image)dataTemplate.FindName("listImageView", contentPresenter);

            target.GetBindingExpression(Image.SourceProperty).UpdateTarget();

            if (!Directory.Exists(ModGlobalData.MOD_PATH_ROOT + CurrentMod.Directory))
            {
                Directory.CreateDirectory(ModGlobalData.MOD_PATH_ROOT + CurrentMod.Directory);
            }
            if (!CurrentMod.Picture.Equals("thumbnail.png"))
            {
                File.Copy(CurrentMod.Picture, ModGlobalData.MOD_PATH_ROOT + CurrentMod.Directory + "\\thumbnail.png", true);
            }
        }
Esempio n. 2
0
        private void SaveModFile(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(pathView.Text))
            {
                MessageBox.Show("路径不能为空");
            }
            else if (String.IsNullOrWhiteSpace(versionView.Text))
            {
                MessageBox.Show("Mod版本号不能为空");
            }
            else if (String.IsNullOrWhiteSpace(supportedVersionView.Text))
            {
                MessageBox.Show("群星版本号不能为空");
            }
            else if (String.IsNullOrWhiteSpace(tagsdView.Text))
            {
                MessageBox.Show("标签不能为空");
            }
            else if (String.IsNullOrEmpty(CurrentMod.Picture))
            {
                MessageBox.Show("还未选择封面图", "错误");
            }
            else
            {
                if (!CurrentMod.IsModData)
                {
                    WirteModFile(CurrentMod);
                }
                else
                {
                    var mod = CurrentMod.Clone();
                    mod.IsModData = false;
                    WirteModFile(mod);
                    ModGlobalData.CreateExampleModProject();
                    listView.ItemsSource = null;
                    listView.ItemsSource = ModGlobalData.ModProjects;
                    CurrentMod           = ModGlobalData.ModProjects.First();
                }

                MessageBox.Show("已保存");
            }
        }