Esempio n. 1
0
        private async void ExportCharacter_Load(object sender, EventArgs e)
        {
            LanguageManager.PopulateSheetLanguageList(cboLanguage, GlobalSettings.DefaultCharacterSheet, _objCharacter.Yield(), _objExportCulture);
            cboXSLT.BeginUpdate();
            cboXSLT.Items.Add("Export JSON");
            // Populate the XSLT list with all of the XSL files found in the sheets directory.
            string exportDirectoryPath = Path.Combine(Utils.GetStartupPath, "export");

            foreach (string strFile in Directory.GetFiles(exportDirectoryPath))
            {
                // Only show files that end in .xsl. Do not include files that end in .xslt since they are used as "hidden" reference sheets (hidden because they are partial templates that cannot be used on their own).
                if (!strFile.EndsWith(".xslt", StringComparison.OrdinalIgnoreCase) && strFile.EndsWith(".xsl", StringComparison.OrdinalIgnoreCase))
                {
                    string strFileName = Path.GetFileNameWithoutExtension(strFile);
                    cboXSLT.Items.Add(strFileName);
                }
            }

            if (cboXSLT.Items.Count > 0)
            {
                cboXSLT.SelectedIndex = 0;
            }
            cboXSLT.EndUpdate();
            _blnLoading = false;
            await Task.WhenAll(this.DoThreadSafeAsync(() => Text = Text + LanguageManager.GetString("String_Space") + _objCharacter?.Name), DoLanguageUpdate().AsTask());
        }
Esempio n. 2
0
        /// <summary>
        /// Set List of Characters to print.
        /// </summary>
        public async ValueTask SetCharacters(params Character[] lstCharacters)
        {
            foreach (Character objCharacter in _lstCharacters)
            {
                objCharacter.PropertyChanged -= ObjCharacterOnPropertyChanged;
            }
            _lstCharacters.Clear();
            if (lstCharacters != null)
            {
                _lstCharacters.AddRange(lstCharacters);
            }
            foreach (Character objCharacter in _lstCharacters)
            {
                objCharacter.PropertyChanged += ObjCharacterOnPropertyChanged;
            }

            bool blnOldLoading = _blnLoading;

            try
            {
                _blnLoading = true;
                // Populate the XSLT list with all of the XSL files found in the sheets directory.
                LanguageManager.PopulateSheetLanguageList(cboLanguage, _strSelectedSheet, _lstCharacters);
                PopulateXsltList();
                await RefreshCharacters();
            }
            finally
            {
                _blnLoading = blnOldLoading;
            }
        }
Esempio n. 3
0
        private void frmExport_Load(object sender, EventArgs e)
        {
            LanguageManager.PopulateSheetLanguageList(cboLanguage, GlobalOptions.DefaultCharacterSheet, _objCharacter.Yield());
            cboXSLT.BeginUpdate();
            cboXSLT.Items.Add("Export JSON");
            // Populate the XSLT list with all of the XSL files found in the sheets directory.
            string exportDirectoryPath = Path.Combine(Utils.GetStartupPath, "export");

            foreach (string strFile in Directory.GetFiles(exportDirectoryPath))
            {
                // Only show files that end in .xsl. Do not include files that end in .xslt since they are used as "hidden" reference sheets (hidden because they are partial templates that cannot be used on their own).
                if (!strFile.EndsWith(".xslt", StringComparison.OrdinalIgnoreCase) && strFile.EndsWith(".xsl", StringComparison.OrdinalIgnoreCase))
                {
                    string strFileName = Path.GetFileNameWithoutExtension(strFile);
                    cboXSLT.Items.Add(strFileName);
                }
            }

            if (cboXSLT.Items.Count > 0)
            {
                cboXSLT.SelectedIndex = 0;
            }
            cboXSLT.EndUpdate();
            _blnLoading = false;
            cboLanguage_SelectedIndexChanged(sender, e);
        }
Esempio n. 4
0
        private void frmViewer_Load(object sender, EventArgs e)
        {
            _blnLoading = true;
            // Populate the XSLT list with all of the XSL files found in the sheets directory.
            LanguageManager.PopulateSheetLanguageList(cboLanguage, _strSelectedSheet, _lstCharacters);
            PopulateXsltList();

            cboXSLT.SelectedValue = _strSelectedSheet;
            // If the desired sheet was not found, fall back to the Shadowrun 5 sheet.
            if (cboXSLT.SelectedIndex == -1)
            {
                string strLanguage = cboLanguage.SelectedValue?.ToString();
                int    intNameIndex;
                if (string.IsNullOrEmpty(strLanguage) || strLanguage == GlobalOptions.DefaultLanguage)
                {
                    intNameIndex = cboXSLT.FindStringExact(GlobalOptions.DefaultCharacterSheet);
                }
                else
                {
                    intNameIndex = cboXSLT.FindStringExact(GlobalOptions.DefaultCharacterSheet.Substring(GlobalOptions.DefaultLanguage.LastIndexOf(Path.DirectorySeparatorChar) + 1));
                }
                if (intNameIndex != -1)
                {
                    cboXSLT.SelectedIndex = intNameIndex;
                }
                else if (cboXSLT.Items.Count > 0)
                {
                    if (string.IsNullOrEmpty(strLanguage) || strLanguage == GlobalOptions.DefaultLanguage)
                    {
                        _strSelectedSheet = GlobalOptions.DefaultCharacterSheetDefaultValue;
                    }
                    else
                    {
                        _strSelectedSheet = Path.Combine(strLanguage, GlobalOptions.DefaultCharacterSheetDefaultValue);
                    }
                    cboXSLT.SelectedValue = _strSelectedSheet;
                    if (cboXSLT.SelectedIndex == -1)
                    {
                        cboXSLT.SelectedIndex = 0;
                        _strSelectedSheet     = cboXSLT.SelectedValue?.ToString();
                    }
                }
            }
            _blnLoading = false;
            SetDocumentText(LanguageManager.GetString("String_Loading_Characters"));

            Application.Idle += RunQueuedWorkers;
        }