private void ToAndroid_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                ModConfiguration config = btn.CommandParameter as ModConfiguration;
                if (config != null)
                {
                    Locations.MessageBoxShow(AMLResources.Properties.Resources.AttachAndroid,
                                             MessageBoxButton.OK, MessageBoxImage.Information);

                    System.Windows.Forms.FolderBrowserDialog diag = new System.Windows.Forms.FolderBrowserDialog();
                    diag.Description = AMLResources.Properties.Resources.BrowseToFolder;
                    if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        Locations.CopyFiles(new System.IO.DirectoryInfo(config.InstalledPath), diag.SelectedPath, "*.snt");
                        Locations.CopyFiles(new System.IO.DirectoryInfo(config.InstalledPath), diag.SelectedPath, "*.xml");
                        Locations.MessageBoxShow(
                            AMLResources.Properties.Resources.CopyComplete
                            + DataStrings.CRCR
                            + AMLResources.Properties.Resources.ApplyToAndroid,
                            MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
        }
Пример #2
0
        public void ActivateMod()
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
            }
            string targetRootPath = Locations.ArtemisCopyPath;
            List <KeyValuePair <string, string> > targetList = new List <KeyValuePair <string, string> >();

            if (string.IsNullOrEmpty(InstalledPath))
            {
                SetInstalledPath();
            }
            targetList.AddRange(Locations.CopyFiles(new DirectoryInfo(InstalledPath), targetRootPath));
            foreach (FileMap m in BaseFiles)
            {
                if (m.Source.Contains("*") || m.Source.Contains("?"))
                {
                    //more than one file, wildcarded.
                    string sourceFle = m.Source;

                    int i = sourceFle.LastIndexOf('\\');
                    sourceFle = sourceFle.Substring(0, i);
                    targetList.AddRange(Locations.CopyFiles(
                                            new DirectoryInfo(Path.Combine(InstalledPath, sourceFle)),
                                            Path.Combine(targetRootPath, m.Target)));
                }
                else
                {
                    FileInfo src  = new FileInfo(Path.Combine(InstalledPath, m.Source));
                    string   targ = Path.Combine(Locations.ArtemisCopyPath, m.Target);
                    Locations.DeleteFile(targ);
                    src.CopyTo(targ);
                    targetList.Add(new KeyValuePair <string, string>(src.FullName, targ));
                }
            }
            ActiveFiles = new ObservableCollection <FileMap>();
            foreach (KeyValuePair <string, string> targ in targetList)
            {
                ActiveFiles.Add(new FileMap(targ.Key, targ.Value));
            }
            IsActive = true;
            if (this.SubMods != null && this.SubMods.Count > 0)
            {
                this.ActivateSubMod(SubMods[0].Title);
            }
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
            }
        }
Пример #3
0
        public void InstallMod(string sourceRootPath)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
            }
            SetInstalledPath();

            Locations.CreatePath(InstalledPath);

            Locations.CopyFiles(new DirectoryInfo(sourceRootPath), InstalledPath);
            //Now update file that stores list of installed mods, storing "targetRootPath" location.
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
            }
        }
Пример #4
0
        public void ActivateSubMod(string SubModTitle)
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString());
            }
            if (string.IsNullOrEmpty(InstalledPath))
            {
                SetInstalledPath();
            }
            //Must first make sure the Mod itself is activated.
            string targetRootPath = Locations.ArtemisCopyPath;
            List <KeyValuePair <string, string> > targetList = new List <KeyValuePair <string, string> >();

            if (!string.IsNullOrEmpty(ActiveSubMod) && ActiveSubMod != SubModTitle)
            {
                DeactivateSubMod();
            }
            if (ActiveSubMod != SubModTitle)
            {
                foreach (SubMod sub in SubMods)
                {
                    if (sub.Title == SubModTitle)
                    {
                        foreach (FileMap m in sub.Files)
                        {
                            // <FileMap Source="Helm UI Mod\New UI Image Files\*" Target="dat"/>

                            if (m.Source.Contains("*") || m.Source.Contains("?"))
                            {
                                //more than one file, wildcarded.

                                string sourceFle = m.Source;

                                int i = sourceFle.LastIndexOf('\\');
                                sourceFle = sourceFle.Substring(0, i);
                                targetList.AddRange(Locations.CopyFiles(
                                                        new DirectoryInfo(Path.Combine(InstalledPath, sourceFle)),
                                                        Path.Combine(targetRootPath, m.Target)));
                            }
                            else
                            {
                                FileInfo src  = new FileInfo(Path.Combine(InstalledPath, m.Source));
                                string   targ = Path.Combine(Locations.ArtemisCopyPath, m.Target);
                                Locations.DeleteFile(targ);
                                src.CopyTo(targ);
                                targetList.Add(new KeyValuePair <string, string>(src.FullName, targ));
                            }
                        }
                        ActiveSubMod = sub.Title;
                        sub.IsActive = true;
                        break;
                    }
                }
            }

            foreach (KeyValuePair <string, string> targ in targetList)
            {
                ActiveFiles.Add(
                    new FileMap(targ.Key, targ.Value, true));
            }
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString());
            }
        }