//=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="project">The current project</param>
        /// <param name="configuration">The current configuration element</param>
        public VersionBuilderConfigDlg(SandcastleProject project, XElement configuration)
        {
            InitializeComponent();

            this.project       = project ?? throw new ArgumentNullException(nameof(project));
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            if (!configuration.IsEmpty)
            {
                var currentProject = configuration.Element("currentProject");

                if (currentProject != null)
                {
                    txtLabel.Text           = currentProject.Attribute("label").Value;
                    txtVersion.Text         = currentProject.Attribute("version").Value;
                    chkRipOldAPIs.IsChecked = (bool)currentProject.Attribute("ripOldApis");
                }

                // Load the current settings
                foreach (var reference in configuration.Descendants("version"))
                {
                    lbVersionInfo.Items.Add(VersionSettings.FromXml(project, reference));
                }
            }

            btnDeleteProject.IsEnabled = grpVersionInfoProps.IsEnabled = lbVersionInfo.Items.Count != 0;

            if (lbVersionInfo.Items.Count != 0)
            {
                lbVersionInfo.SelectedIndex = 0;
            }
        }
        private async Task <string> DownloadAndExtractArchive(VersionSettings version)
        {
            var versionsDirectory = Directory.CreateDirectory(settings.VersionsDirectory);
            var archivesDirectory = Directory.CreateDirectory($"{versionsDirectory}\\{settings.ArchivesDirectory}");

            var archive = $"{archivesDirectory}\\{version.ArchiveName}";

            if (!File.Exists(archive))
            {
                await httpClient.DownloadFile(version.DownloadLink, archive, referer : "https://pcsx2.net");
            }

            using var extractor = new SevenZipExtractor(archive);
            var rootStructure = extractor.ArchiveFileNames.Where(x => !string.IsNullOrEmpty(x) && !x.Contains("\\"));

            var targetPath = $"{versionsDirectory}\\{version.Directory}";

            if (rootStructure.Count() == 1)
            {
                await extractor.ExtractArchiveAsync($"{versionsDirectory}");

                var extractedPath = $"{versionsDirectory}\\{rootStructure.First()}";

                if (Directory.Exists(extractedPath) && extractedPath != targetPath)
                {
                    Directory.Move(extractedPath, targetPath);
                }
            }
            else
            {
                await extractor.ExtractArchiveAsync(targetPath);
            }

            return(targetPath);
        }
        /// <summary>
        /// Add a new version info project
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnAddProject_Click(object sender, RoutedEventArgs e)
        {
            using (var dlg = new System.Windows.Forms.OpenFileDialog())
            {
                dlg.Title  = "Select the help file builder project(s)";
                dlg.Filter = "Sandcastle Help File Builder Project Files " +
                             "(*.shfbproj)|*.shfbproj|All Files (*.*)|*.*";
                dlg.InitialDirectory = Directory.GetCurrentDirectory();
                dlg.DefaultExt       = "shfbproj";
                dlg.Multiselect      = true;

                // If selected, add the file(s)
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    foreach (string file in dlg.FileNames)
                    {
                        var newItem = new VersionSettings(project)
                        {
                            HelpFileProject = new FilePath(file, project),
                            FrameworkLabel  = txtLabel.Text,
                            Version         = "1.0"
                        };

                        // It will end up on the last one added
                        lbVersionInfo.SelectedIndex = lbVersionInfo.Items.Add(newItem);
                    }

                    btnDeleteProject.IsEnabled = grpVersionInfoProps.IsEnabled = true;
                }
            }
        }
Exemple #4
0
 public ConfigSettings (   )
 {
     LawSet  = new LawSettings();
     VersionSet = new VersionSettings();
     SystemStatusSet = new SystemStatusSettings();
     CreditsPolicySet = new CreditsPolicySettings();
     CustomerServicesSet = new CustomerServicesSettings();
     InviteSet = new InviteSettings();
 }
    public override bool Equals(object obj)
    {
        VersionSettings other = obj as VersionSettings;

        if (other == null)
        {
            return(false);
        }
        return(Culture == other.Culture);
    }
 private static void ResetVersion(VersionSettings settings)
 {
     settings.AllocatedMemory   = DefaultSettings.VERSION_ALLOCATED_MEMORY;
     settings.UseLicence        = DefaultSettings.VERSION_USE_LICENCE;
     settings.ShowConsole       = DefaultSettings.VERSION_SHOW_CONSOLE;
     settings.AutoCloseConsole  = DefaultSettings.VERSION_AUTO_CLOSE_CONSOLE;
     settings.AutoCloseLauncher = DefaultSettings.VERSION_AUTO_CLOSE_LAUNCHER;
     settings.FindJava          = DefaultSettings.VERSION_FIND_JAVA;
     settings.UseOptimization   = DefaultSettings.VERSION_USE_OPTIMIZATION;
     settings.Use64Bit          = DefaultSettings.VERSION_USE_64_BIT;
 }
        public async Task InstallVersion(VersionSettings version)
        {
            var installPath = await DownloadAndExtractArchive(version);

            ConfigureBiosDirectory(installPath, version.InisDirectory);

            appSettings.Versions.Add(version.Name, $"{Path.GetFullPath(installPath)}\\{version.Executable}");
            await appSettings.UpdateVersions();

            Process.Start($"{installPath}/{version.Executable}");
        }
            public static void ResetCurrentVersionSettings()
            {
                if (!string.IsNullOrWhiteSpace(CurrentVersion))
                {
                    if (!xmlVersionsSettings.VersionsSettings.ContainsKey(CurrentVersion))
                    {
                        VersionSettings settings = new VersionSettings();
                        ResetVersion(settings);

                        xmlVersionsSettings.VersionsSettings.Add(CurrentVersion, settings);
                    }
                    else
                    {
                        ResetVersion(xmlVersionsSettings.VersionsSettings[CurrentVersion]);
                    }
                }
            }
        private async Task <List <VersionSettings> > GetDevVersions()
        {
            var uri          = new Uri(settings.DevVersions);
            var htmlDocument = await new HtmlWeb().LoadFromWebAsync(uri.AbsoluteUri);
            var versions     = new List <VersionSettings>();

            var tableNodes = htmlDocument.DocumentNode.SelectNodes("//table[@class='listing']/tr");

            foreach (var node in tableNodes.Where(node => node.Descendants().Any(x => x.Name == "td")))
            {
                var cells = node.Descendants().Where(x => x.Name == "td");
                var name  = cells.First().InnerText;
                var query = HttpUtility.HtmlDecode(cells.ElementAt(3).FirstChild.GetAttributeValue("href", string.Empty));

                if (string.IsNullOrWhiteSpace(query))
                {
                    continue;
                }

                var commitRefIndex = name.LastIndexOf("-g");
                var version        = new VersionSettings
                {
                    Name         = name.Substring(0, commitRefIndex < 0 ? name.Length : commitRefIndex),
                    DownloadLink = $"{uri.Scheme}://{uri.Host}{query}",
                    IsDevBuild   = true
                };

                var headResponse = await httpClient.SendAsync(new HttpRequestMessage
                {
                    Method     = HttpMethod.Head,
                    RequestUri = new Uri(version.DownloadLink),
                });

                headResponse.EnsureSuccessStatusCode();

                version.Directory = "PCSX2 " + new StringBuilder(version.Name)
                {
                    [version.Name.LastIndexOf('-')] = ' '
                }.ToString().Substring(1);
                version.ArchiveName = headResponse.Content.Headers.ContentDisposition.FileName.Replace("\"", "");

                versions.Add(version);
            }

            return(versions);
        }
Exemple #10
0
        public async Task InstallVersion(VersionSettings version, bool shouldOpen)
        {
            var installPath = await DownloadAndExtractArchive(version);

            ConfigureBiosDirectory(installPath, version.InisDirectory);

            var fullExectuablePath = $"{Path.GetFullPath(installPath)}\\{version.Executable}";

            if (!appSettings.Versions.ContainsKey(version.Name))
            {
                appSettings.Versions.Add(version.Name, fullExectuablePath);
            }
            else if (appSettings.Versions[version.Name] != fullExectuablePath)
            {
                appSettings.Versions[version.Name] = fullExectuablePath;
            }
            await appSettings.UpdateVersions();

            WriteVersionNumber(installPath, version.Number ?? version.Name);
            if (shouldOpen)
            {
                Process.Start($"{installPath}/{version.Executable}");
            }
        }
        /// <summary>
        /// This method will configure the default ItemVersionSettings for an article, it is called from the Create method on article so that users of the API do not have to pass in itemversionsettings.
        /// </summary>
        private void SetDefaultItemVersionSettings()
        {
            //Printer Friendly
            string  hostPrinterFriendlySetting = HostController.Instance.GetString(Utility.PublishDefaultPrinterFriendly + PortalId.ToString(CultureInfo.InvariantCulture));
            Setting setting = Setting.PrinterFriendly;

            setting.PropertyValue = Convert.ToBoolean(hostPrinterFriendlySetting, CultureInfo.InvariantCulture).ToString();
            var itemVersionSetting = new ItemVersionSetting(setting);

            VersionSettings.Add(itemVersionSetting);

            //Email A Friend
            string hostEmailFriendSetting = HostController.Instance.GetString(Utility.PublishDefaultEmailAFriend + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.EmailAFriend;
            setting.PropertyValue = Convert.ToBoolean(hostEmailFriendSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //ratings
            string hostRatingSetting = HostController.Instance.GetString(Utility.PublishDefaultRatings + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.Rating;
            setting.PropertyValue = Convert.ToBoolean(hostRatingSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //comments
            string hostCommentSetting = HostController.Instance.GetString(Utility.PublishDefaultComments + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.Comments;
            setting.PropertyValue = Convert.ToBoolean(hostCommentSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            if (ModuleBase.IsPublishCommentTypeForPortal(PortalId))
            {
                //forum comments
                setting = Setting.ForumComments;
                setting.PropertyValue = Convert.ToBoolean(hostCommentSetting, CultureInfo.InvariantCulture).ToString();
                itemVersionSetting    = new ItemVersionSetting(setting);
                VersionSettings.Add(itemVersionSetting);
            }

            //include all articles from the parent category
            setting = Setting.ArticleSettingIncludeCategories;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //display on current page option
            setting = Setting.ArticleSettingCurrentDisplay;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //force display on specific page
            setting = Setting.ArticleSettingForceDisplay;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //display return to list
            setting = Setting.ArticleSettingReturnToList;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //show author
            string hostAuthorSetting = HostController.Instance.GetString(Utility.PublishDefaultShowAuthor + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.Author;
            setting.PropertyValue = Convert.ToBoolean(hostAuthorSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //show tags
            string hostTagsSetting = HostController.Instance.GetString(Utility.PublishDefaultShowTags + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.ShowTags;
            setting.PropertyValue = Convert.ToBoolean(hostTagsSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);


            //use approvals
            string hostUseApprovalsSetting = HostController.Instance.GetString(Utility.PublishUseApprovals + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.UseApprovals;
            setting.PropertyValue = Convert.ToBoolean(hostUseApprovalsSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);
        }