/// <summary> /// 研究速度補正の値変更時の処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnModifierTextBoxValidated(object sender, EventArgs e) { // 変更後の文字列を数値に変換できなければ値を戻す double modifier; if (!DoubleHelper.TryParse(modifierTextBox.Text, out modifier)) { modifierTextBox.Text = DoubleHelper.ToString(Researches.Modifier); return; } // 0以下の値だとまともに計算できなくなるので保険 if (modifier <= 0.00005) { modifierTextBox.Text = DoubleHelper.ToString(Researches.Modifier); return; } // 値に変化がなければ何もしない if (DoubleHelper.IsEqual(modifier, Researches.Modifier)) { return; } // 値を更新する Researches.Modifier = modifier; // 研究機関リストを更新する UpdateTeamList(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is double || value is double?) { return(DoubleHelper.ToString((double)value)); } return(DependencyProperty.UnsetValue); }
/// <summary> /// オプション項目を初期化する /// </summary> private void InitOptionItems() { if (Researches.DateMode == ResearchDateMode.Historical) { historicalRadioButton.Checked = true; yearNumericUpDown.Enabled = false; monthNumericUpDown.Enabled = false; dayNumericUpDown.Enabled = false; } else { specifiedRadioButton.Checked = true; yearNumericUpDown.Enabled = true; monthNumericUpDown.Enabled = true; dayNumericUpDown.Enabled = true; } yearNumericUpDown.Value = Researches.SpecifiedDate.Year; monthNumericUpDown.Value = Researches.SpecifiedDate.Month; dayNumericUpDown.Value = Researches.SpecifiedDate.Day; rocketNumericUpDown.Value = Researches.RocketTestingSites; nuclearNumericUpDown.Value = Researches.NuclearReactors; blueprintCheckBox.Checked = Researches.Blueprint; modifierTextBox.Text = DoubleHelper.ToString(Researches.Modifier); }
private static string GetTextData() { using (var dataService = new DataService()) { #region [ Load Data & ViewModels ] var credits = dataService.GetAllCredits(withEnabledOnly: true); var creditsViewModel = new CreditsViewModel(); var debits = dataService.GetAllDebits(withEnabledOnly: true); var debitsViewModel = new DebitsViewModel(); var categories = dataService.GetAllCategories(); var summaryViewModel = new SummaryViewModel(); var statsViewModel = new StatsViewModel(); debitsViewModel.Update(debits); creditsViewModel.Update(credits); summaryViewModel.Update(credits, debits); statsViewModel.Update(categories, debits); #endregion var sbOutput = new StringBuilder(10 * 1024); const string separator = "------------------\r\n\r\n"; sbOutput.AppendFormat("{0}: {1}\r\n", AppResources.Credit, DoubleHelper.ToString(summaryViewModel.TotalCredits)); sbOutput.AppendFormat("{0}: {1}\r\n", AppResources.Debit, DoubleHelper.ToString(summaryViewModel.TotalDebits)); sbOutput.AppendFormat("{0}: {1}\r\n", AppResources.Cash, DoubleHelper.ToString(summaryViewModel.Cash)); sbOutput.AppendFormat("\r\n{0}\r\n", AppResources.Credits); sbOutput.AppendFormat(separator); foreach (var item in creditsViewModel.Credits) { sbOutput.AppendFormat("{0} -> {1} {2}\r\n", DoubleHelper.ToString(item.CurrentValue), item.Caption, item.IsMonthly ? string.Empty : string.Format("({0})", item.Date.ToString("yyyy-MM-dd"))); } sbOutput.AppendFormat("\r\n{0}\r\n", AppResources.Debits); sbOutput.AppendFormat(separator); foreach (var item in debitsViewModel.Debits) { sbOutput.AppendFormat("{0} -> {1} {2}\r\n", DoubleHelper.ToString(item.CurrentValue), item.Caption, item.IsMonthly ? string.Empty : string.Format("({0})", item.Date.ToString("yyyy-MM-dd"))); } sbOutput.AppendFormat("\r\n{0}\r\n", AppResources.Categories); sbOutput.AppendFormat(separator); double debitsSum = debitsViewModel.Debits.Sum(j => j.CurrentValue); foreach (var category in statsViewModel.Categories.Where(i => i.TotalValue > 0)) { sbOutput.AppendFormat("{0} -> {1} ({2}%)\r\n", category.Caption, category.TotalValue, category.GetPercentageDistribution(debitsSum)); } return(sbOutput.ToString()); } }