using System.Linq;
using System.Reflection;
using System.Text;
+ using System.Threading;
using System.Windows.Forms;
using Honememo.Utilities;
using Honememo.Wptscs.Models;
// 全部成功なら画面を閉じる
// ※ エラーの場合、どうしても駄目ならキャンセルボタンで閉じてもらう
- this.Close();
+ this.DialogResult = DialogResult.OK;
}
catch (Exception ex)
{
// 空または日付として認識可能な値の場合OK
string value = e.FormattedValue.ToString();
DateTime dummy;
- if (String.IsNullOrWhiteSpace(value) || DateTime.TryParse(value, out dummy))
+ if (string.IsNullOrWhiteSpace(value) || DateTime.TryParse(value, out dummy))
{
return;
}
// ※ 他の列で消さないのは、エラーを出しているのがRowValidatingの場合もあるから
if (this.dataGridViewItems.Columns[e.ColumnIndex].Name == "ColumnTimestamp")
{
- this.dataGridViewItems.Rows[e.RowIndex].ErrorText = String.Empty;
+ this.dataGridViewItems.Rows[e.RowIndex].ErrorText = string.Empty;
}
}
if (e.RowIndex >= 0)
{
DataGridViewRow row = this.dataGridViewItems.Rows[e.RowIndex];
- if (String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnTimestamp"]))
+ if (string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnTimestamp"]))
&& !this.IsEmptyDataGridViewItemsRow(row))
{
// 背景色を変更
// 翻訳元、記事名、翻訳先が未入力の場合、バリデートNGメッセージを表示
// ※ ただし全列が空(新規行など)の場合は無視
DataGridViewRow row = this.dataGridViewItems.Rows[e.RowIndex];
- if ((String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromCode"]))
- || String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnToCode"]))
- || String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromTitle"])))
+ if ((string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromCode"]))
+ || string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnToCode"]))
+ || string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromTitle"])))
&& !this.IsEmptyDataGridViewItemsRow(row))
{
row.ErrorText = Resources.WarningMessageEmptyTranslationDictionary;
};
string timestamp = FormUtils.ToString(row.Cells["ColumnTimestamp"]);
- if (!String.IsNullOrWhiteSpace(timestamp))
+ if (!string.IsNullOrWhiteSpace(timestamp))
{
item.Timestamp = DateTime.Parse(timestamp);
/// <returns>空の場合<c>true</c>。</returns>
private bool IsEmptyDataGridViewItemsRow(DataGridViewRow row)
{
- return String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromCode"]))
- && String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromTitle"]))
- && String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnAlias"]))
- && String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnToCode"]))
- && String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnToTitle"]))
- && String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnTimestamp"]));
+ return string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromCode"]))
+ && string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnFromTitle"]))
+ && string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnAlias"]))
+ && string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnToCode"]))
+ && string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnToTitle"]))
+ && string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnTimestamp"]));
}
#endregion
}
// 各行にデータを取り込み
- foreach (IDictionary<string, string> record in table)
+ foreach (IDictionary<string, string[]> record in table)
{
// 行を追加しその行を取得
DataGridViewRow row = view.Rows[view.Rows.Add()];
- foreach (KeyValuePair<string, string> cell in record)
+ foreach (KeyValuePair<string, string[]> cell in record)
{
// 上で登録した列では足りなかった場合、その都度生成する
if (!view.Columns.Contains(cell.Key))
this.AddTranslationTableColumn(view.Columns, cell.Key, cell.Key);
}
- row.Cells[cell.Key].Value = cell.Value;
+ // 改行区切りで表示
+ row.Cells[cell.Key].Value = string.Join("\n", cell.Value);
}
}
// 可能であれば現在表示中の言語の列の昇順でソートする
// ※ 無ければenで試みる
- string code = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
+ string code = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
if (view.Columns.Contains(code))
{
view.Sort(view.Columns[code], ListSortDirection.Ascending);
{
view.Sort(view.Columns["en"], ListSortDirection.Ascending);
}
-
- // 列幅をデータ長に応じて自動調整
- // ※ 常に行ってしまうと、読み込みに時間がかかるため
- view.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
/// <summary>
TranslationTable table = new TranslationTable();
foreach (DataGridViewRow row in view.Rows)
{
- IDictionary<string, string> record = new SortedDictionary<string, string>();
+ IDictionary<string, string[]> record = new SortedDictionary<string, string[]>();
foreach (DataGridViewCell cell in row.Cells)
{
// 空のセルは格納しない、該当の組み合わせは消える
string value = FormUtils.ToString(cell);
- if (!String.IsNullOrWhiteSpace(value))
+ if (!string.IsNullOrWhiteSpace(value))
{
- record[cell.OwningColumn.Name] = value;
+ // 改行区切りの配列で格納
+ record[cell.OwningColumn.Name] = CollectionUtils.Trim(value.Split('\n'));
}
}
{
Language.LanguageName name;
if (lang.Names.TryGetValue(
- System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName, out name))
+ Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName, out name))
{
- if (!String.IsNullOrEmpty(name.Name))
+ if (!string.IsNullOrEmpty(name.Name))
{
- return String.Format(Resources.HeadingViewHeaderText, name.Name, lang.Code);
+ return string.Format(Resources.HeadingViewHeaderText, name.Name, lang.Code);
}
}
try
{
// 変更前の設定を保存
- if (!String.IsNullOrEmpty(this.comboBoxLanguageSelectedText))
+ if (!string.IsNullOrEmpty(this.comboBoxLanguageSelectedText))
{
// 設定が存在しなければ自動生成される
this.SaveChangedValue(this.GetMediaWikiNeedCreate(this.config.Websites, this.comboBoxLanguageSelectedText));
}
// 変更後の値に応じて、画面表示を更新
- if (!String.IsNullOrEmpty(this.comboBoxLanguage.Text))
+ if (!string.IsNullOrEmpty(this.comboBoxLanguage.Text))
{
// 設定が存在しなければ基本的に自動生成されるのでそのまま使用
this.LoadCurrentValue(this.GetMediaWikiNeedCreate(this.config.Websites, this.comboBoxLanguage.Text));
this.groupBoxLanguage.Enabled = false;
// 現在の選択値を更新
- this.comboBoxLanguageSelectedText = String.Empty;
+ this.comboBoxLanguageSelectedText = string.Empty;
}
}
catch (Exception ex)
/// <param name="e">発生したイベント。</param>
private void ButtonLunguageAdd_Click(object sender, EventArgs e)
{
- // 言語追加用ダイアログを表示
- InputLanguageCodeDialog form = new InputLanguageCodeDialog(this.config);
- form.ShowDialog();
-
- // 値が登録された場合
- if (!String.IsNullOrWhiteSpace(form.LanguageCode))
+ // 言語追加用ダイアログで言語コードを入力
+ using (AddLanguageDialog form = new AddLanguageDialog(this.config))
{
- // 値を一覧・見出しの対訳表に追加、登録した値を選択状態に変更
- this.comboBoxLanguage.Items.Add(form.LanguageCode);
- this.dataGridViewHeading.Columns.Add(form.LanguageCode, form.LanguageCode);
- this.comboBoxLanguage.SelectedItem = form.LanguageCode;
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ // 値をコンボボックスと見出しの対訳表に追加、登録した値を選択状態に変更
+ this.comboBoxLanguage.Items.Add(form.LanguageCode);
+ this.dataGridViewHeading.Columns.Add(form.LanguageCode, form.LanguageCode);
+ this.comboBoxLanguage.SelectedItem = form.LanguageCode;
+ }
}
}
}
}
- // コンボボックスからも削除し、表示を更新する
+ // 値を見出しの対訳表とコンボボックスからも削除し、表示を更新する
this.comboBoxLanguageSelectedText = null;
+ this.dataGridViewHeading.Columns.Remove(this.comboBoxLanguage.Text);
this.comboBoxLanguage.Items.Remove(this.comboBoxLanguage.Text);
this.ComboBoxLanguuage_SelectedIndexChanged(sender, e);
}
TextBox box = (TextBox)sender;
box.Text = StringUtils.DefaultString(box.Text).Trim();
int value;
- if (!String.IsNullOrEmpty(box.Text) && !int.TryParse(box.Text, out value))
+ if (!string.IsNullOrEmpty(box.Text) && !int.TryParse(box.Text, out value))
{
this.errorProvider.SetError(box, Resources.WarningMessageIgnoreNumericNamespace);
e.Cancel = true;
{
// 空か$1が含まれる文字列のみ許可
TextBox box = (TextBox)sender;
- if (!String.IsNullOrEmpty(box.Text) && !box.Text.Contains("$1"))
+ if (!string.IsNullOrEmpty(box.Text) && !box.Text.Contains("$1"))
{
this.errorProvider.SetError(box, Resources.WarningMessageUnformatedBracket);
e.Cancel = true;
// 言語コードは必須、またトリムして小文字に変換
string code = FormUtils.ToString(row.Cells["ColumnCode"]).Trim().ToLower();
row.Cells["ColumnCode"].Value = code;
- if (String.IsNullOrEmpty(code))
+ if (string.IsNullOrEmpty(code))
{
row.ErrorText = Resources.WarningMessageEmptyCodeColumn;
e.Cancel = true;
}
// 略称を設定する場合、呼称を必須とする
- if (!String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnShortName"]))
- && String.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnName"])))
+ if (!string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnShortName"]))
+ && string.IsNullOrWhiteSpace(FormUtils.ToString(row.Cells["ColumnName"])))
{
row.ErrorText = Resources.WarningMessageShortNameColumnOnly;
e.Cancel = true;
this.textBoxDocumentationTemplateDefaultPage.Text = StringUtils.DefaultString(site.DocumentationTemplateDefaultPage);
this.textBoxLinkInterwikiFormat.Text = StringUtils.DefaultString(site.LinkInterwikiFormat);
this.textBoxLangFormat.Text = StringUtils.DefaultString(site.LangFormat);
+ this.checkBoxHasLanguagePage.Checked = site.HasLanguagePage;
}
/// <summary>
{
// 値が入ってないとかはガードしているはずだが、一応チェック
string code = FormUtils.ToString(this.dataGridViewLanguageName["ColumnCode", y]).Trim();
- if (!String.IsNullOrEmpty(code))
+ if (!string.IsNullOrEmpty(code))
{
Language.LanguageName name = new Language.LanguageName();
name.Name = FormUtils.ToString(this.dataGridViewLanguageName["ColumnName", y]).Trim();
site.DocumentationTemplates.Clear();
foreach (string s in StringUtils.DefaultString(this.textBoxDocumentationTemplate.Text).Split('\n'))
{
- if (!String.IsNullOrWhiteSpace(s))
+ if (!string.IsNullOrWhiteSpace(s))
{
site.DocumentationTemplates.Add(s.Trim());
}
site.LangFormat = str;
}
+ site.HasLanguagePage = this.checkBoxHasLanguagePage.Checked;
+
// 以下、数値へのparseは事前にチェックしてあるので、ここではチェックしない
- if (!String.IsNullOrWhiteSpace(this.textBoxTemplateNamespace.Text))
+ if (!string.IsNullOrWhiteSpace(this.textBoxTemplateNamespace.Text))
{
int num = int.Parse(this.textBoxTemplateNamespace.Text);
if (site.TemplateNamespace != num)
}
}
- if (!String.IsNullOrWhiteSpace(this.textBoxCategoryNamespace.Text))
+ if (!string.IsNullOrWhiteSpace(this.textBoxCategoryNamespace.Text))
{
int num = int.Parse(this.textBoxCategoryNamespace.Text);
if (site.CategoryNamespace != num)
}
}
- if (!String.IsNullOrWhiteSpace(this.textBoxFileNamespace.Text))
+ if (!string.IsNullOrWhiteSpace(this.textBoxFileNamespace.Text))
{
int num = int.Parse(this.textBoxFileNamespace.Text);
if (site.FileNamespace != num)
/// <param name="e">発生したイベント。</param>
private void ResetErrorText_RowValidated(object sender, DataGridViewCellEventArgs e)
{
- ((DataGridView)sender).Rows[e.RowIndex].ErrorText = String.Empty;
+ ((DataGridView)sender).Rows[e.RowIndex].ErrorText = string.Empty;
}
/// <summary>
// 全行のエラーメッセージを解除
foreach (DataGridViewRow row in ((DataGridView)sender).Rows)
{
- row.ErrorText = String.Empty;
+ row.ErrorText = string.Empty;
}
}
/// <summary>
/// 取得日時が同じ場合にソートに用いる列名。
/// </summary>
- private static readonly string[] sortOrder = new string[] { "ColumnFromCode", "ColumnToCode", "ColumnFromTitle" };
+ private static readonly string[] SortOrder = new string[] { "ColumnFromCode", "ColumnToCode", "ColumnFromTitle" };
/// <summary>
/// 2行を比較し、一方が他方より小さいか、等しいか、大きいかを示す値を返します。
}
// 取得日時列が同じ場合、残りの列の昇順でソート
- foreach (string column in sortOrder)
+ foreach (string column in SortOrder)
{
- compare = String.Compare(
+ compare = string.Compare(
FormUtils.ToString(xrow.Cells[column]),
FormUtils.ToString(yrow.Cells[column]));
if (compare != 0)