コード例 #1
0
 private void ListView1_ItemActivate(object sender, EventArgs e)
 {
     if (FileDisplay == null || FileDisplay.IsDisposed)
     {
         FileDisplay = new FileDisplay(PackageView.Items[PackageView.SelectedIndices[0]].SubItems[2].Text.Replace("\n ", "\n"));
     }
     FileDisplay.Show();
     FileDisplay.Activate();
 }
コード例 #2
0
        private int CheckPackages(Package install, out Package data)
        {
            data = null;
            DirectoryInfo PackagesFolder = GetCurrentDrive().GetDirectory("FM").GetDirectory("Packages");

            if (PackagesFolder.Exists)
            {
                Package Outdated = Packages.Keys.SingleOrDefault(p => p.name.ToLower() == install.name.ToLower());

                if (Outdated != null)
                {
                    if (Outdated.packageVersion != install.packageVersion || !Outdated.files.SequenceEqual(install.files) || install.created != Outdated.created)
                    {
                        if (MessageBox.Show("The package you are trying to install is different from one already installed, would you like to use the new package?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            data = Outdated;
                            return(1);
                        }
                        else
                        {
                            return(-1);
                        }
                    }
                    else
                    {
                        MessageBox.Show("The package you are trying to install is already installed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(-1);
                    }
                }

                List <string> Conflicting = new List <string>();
                foreach (string[] Files in Packages.Keys.Select(p => p.files))
                {
                    foreach (string file in install.files)
                    {
                        if (Files.Contains(file))
                        {
                            Conflicting.Add(file);
                        }
                    }
                }

                if (Conflicting.Count != 0)
                {
                    using (FileDisplay display = new FileDisplay($"{string.Join("\n", Conflicting)}", "Conflicting Files"))
                    {
                        display.Show();
                    }
                    return(1);
                }
            }
            return(0);
        }