Esempio n. 1
0
        public override bool InstallOrUninstall()
        {
            string oldCustom = Installed ? App.PathCustom : App.PathCustom_;
            string newCustom = Installed ? App.PathCustom_ : App.PathCustom;

            Dir oldDir = new Dir(oldCustom);
            Dir newDir = new Dir(newCustom);

            string tmp;

            List<string> files = new List<string>();

            var p = _Path.GetFileNameWithoutExtension(Path) + ".";

            string newPath = _Path.Combine(newCustom, _Path.GetFileName(Path));

            foreach (string s in oldDir.Files)
            {
                if (s.StartsWith(p, StringComparison.OrdinalIgnoreCase))
                {
                    if (newDir.TryGetFile(s, out tmp))
                        return false;

                    files.Add(s);
                }
            }

            if (files.Count == 0)
                return false;

            try
            {
                foreach (string s in files)
                    File.Move(_Path.Combine(oldCustom, s), _Path.Combine(newCustom, s));
                Path = newPath;
                Installed = !Installed;
                return true;
            }
            catch
            {

            }

            return false;
        }
Esempio n. 2
0
        public override bool Rename(string name)
        {
            string custom = Installed ? App.PathCustom : App.PathCustom_;

            Dir dir = new Dir(custom);
            string tmp;
            List<Tuple<string, string>> files = new List<Tuple<string, string>>();
            string p = Name + ".";

            foreach (string s in dir.Files)
            {
                if (s.StartsWith(p, StringComparison.OrdinalIgnoreCase))
                {
                    string newFile = name + "." + s.Substring(p.Length);

                    if (dir.TryGetFile(newFile, out tmp))
                        return false;

                    files.Add(Tuple.Create(_Path.Combine(custom, s), _Path.Combine(custom, newFile)));
                }
            }

            if (files.Count == 0)
                return false;

            try
            {
                foreach (var x in files)
                    File.Move(x.Item1, x.Item2);
                Name = name;
                lblName.Text = name + new string(' ', 30);
                return true;
            }
            catch
            {

            }

            return false;
        }
Esempio n. 3
0
        public override void Load()
        {
            Dir dir = new Dir(new FileInfo(Path).Directory.FullName);
            string tmp;

            if (dir.TryGetFile(_Path.GetFileNameWithoutExtension(Path) + ".plugin.xml", out tmp))
                LoadXml(tmp, false);
        }
Esempio n. 4
0
        public override void Load()
        {
            Dir dir = new Dir(Path);

            string tmp;
            if (dir.TryGetFile("thumbnail.png", out tmp) || dir.TryGetFile("thumbnail40.png", out tmp))
            {
                try
                {
                    pluginImage.Image = Image.FromFile(tmp);
                }
                catch { }
            }
            else
            {
                pluginImage.Image = noImage;
            }

            if (dir.TryGetFile("mod.xml", out tmp))
            {
                pluginDotXmlPath = "mod.xml";
                LoadXml(tmp);
            }
            else if (dir.TryGetFile("data.txt", out tmp))
            {
                ProcessDataTxt(File.ReadAllText(tmp));
            }

            if (dir.TryGetFile("readme.md", out tmp) || dir.TryGetFile("readme.txt", out tmp))
            {
                readmePath = tmp;
                btnReadme.Visible = true;
            }
            if (dir.TryGetFile("faq.md", out tmp) || dir.TryGetFile("faq.txt", out tmp))
            {
                faqPath = tmp;
                btnFaq.Visible = true;
            }
            if (dir.TryGetFile("changelog.md", out tmp) || dir.TryGetFile("changelog.txt", out tmp))
            {
                changelogPath = tmp;
                btnChangelog.Visible = true;
            }
        }