예제 #1
0
        private void NewClick(object sender, RoutedEventArgs e)
        {
            Console.WriteLine("[INFO] Creating new package!");
            CreatePackage newPackage = new CreatePackage(null);

            newPackage.ShowDialog();
            if (newPackage.metadata != null)
            {
                string path;
                if (newPackage.metadata.version != null && newPackage.metadata.version.Length > 0)
                {
                    path = $@"Packages\{newPackage.metadata.name} {newPackage.metadata.version}";
                }
                else
                {
                    path = $@"Packages\{newPackage.metadata.name}";
                }
                if (!Directory.Exists(path))
                {
                    try
                    {
                        Directory.CreateDirectory(path);
                        using (FileStream streamWriter = File.Create($@"{path}\Package.xml"))
                        {
                            xsp.Serialize(streamWriter, newPackage.metadata);
                        }
                        if (File.Exists(newPackage.thumbnailPath))
                        {
                            File.Copy(newPackage.thumbnailPath, $@"{path}\Preview.png", true);
                        }
                        Refresh();
                        updateConfig();
                        ProcessStartInfo StartInformation = new ProcessStartInfo();
                        StartInformation.FileName = path;
                        Process process = Process.Start(StartInformation);
                        Console.WriteLine("[INFO] Opened new package folder.");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"[ERROR] Couldn't create directory/Package.xml. ({ex.Message})");
                    }
                }
                else
                {
                    Console.WriteLine($"[ERROR] {newPackage.metadata.name} already exists, not creating new package.");
                }
            }
        }
예제 #2
0
        private void EditItem_Click(object sender, RoutedEventArgs e)
        {
            DisplayedMetadata row = (DisplayedMetadata)ModGrid.SelectedItem;

            if (row != null && File.Exists($@"Packages\{row.path}\Package.xml"))
            {
                Metadata m = new Metadata();
                m.name        = row.name;
                m.author      = row.author;
                m.id          = row.id;
                m.version     = row.version;
                m.link        = row.link;
                m.description = row.description;
                CreatePackage createPackage = new CreatePackage(m);
                createPackage.ShowDialog();
                if (createPackage.metadata != null)
                {
                    try
                    {
                        using (FileStream streamWriter = File.Create($@"Packages\{row.path}\Package.xml"))
                        {
                            xsp.Serialize(streamWriter, createPackage.metadata);
                        }
                        if (File.Exists(createPackage.thumbnailPath))
                        {
                            File.Copy(createPackage.thumbnailPath, $@"Packages\{row.path}\Preview.png", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"[ERROR] {ex.Message}");
                    }
                    Refresh();
                    updateConfig();
                }
            }
        }