for Push.
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using KssSmaPlaLib.Ini;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KssSmaPlaLib.Forms.ContextMenuFunction
|
||||
{
|
||||
public static class FontUxer
|
||||
{
|
||||
/// <summary>
|
||||
/// フォント選択
|
||||
/// </summary>
|
||||
/// <param name="form"></param>
|
||||
/// <param name="section"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultFont"></param>
|
||||
/// <param name="resultFont"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SelectFont(Form form, string section, string key, Font defaultFont, out Font resultFont)
|
||||
{
|
||||
// デフォルト値
|
||||
resultFont = new Font(defaultFont, defaultFont.Style);
|
||||
|
||||
using (var dlg = new FontDialog())
|
||||
{
|
||||
var defaultFontCsv =
|
||||
defaultFont.Name + "," +
|
||||
defaultFont.Size.ToString() + "," +
|
||||
defaultFont.Bold.ToString();
|
||||
var iniFontCsv = IniHelper.ReadValue(null, section, key, defaultFontCsv);
|
||||
var fontItems = iniFontCsv.Split(',');
|
||||
if (fontItems.Length != 3) fontItems = defaultFontCsv.Split(',');
|
||||
if (float.TryParse(fontItems[1], out var size) == false) size = defaultFont.Size;
|
||||
if (bool.TryParse(fontItems[2], out var bold) == false) bold = defaultFont.Bold;
|
||||
|
||||
dlg.Font = new Font(fontItems[0], size, bold ? FontStyle.Bold : FontStyle.Regular);
|
||||
dlg.AllowVerticalFonts = false;
|
||||
// 文字飾り(取り消し線と下線)を表示させない
|
||||
dlg.ShowEffects = false;
|
||||
var result = dlg.ShowDialog(form);
|
||||
if (result == DialogResult.Cancel) return false;
|
||||
|
||||
// INI保存
|
||||
var fontCsv =
|
||||
dlg.Font.Name + "," +
|
||||
dlg.Font.Size.ToString() + "," +
|
||||
dlg.Font.Bold.ToString();
|
||||
IniHelper.WriteValue(null, section, key, fontCsv);
|
||||
|
||||
// 出力
|
||||
resultFont = new Font(dlg.Font, dlg.Font.Style);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static Font GetFont(string section, string key, Font defaultFont)
|
||||
{
|
||||
var defaultFontCsv =
|
||||
defaultFont.Name + "," +
|
||||
defaultFont.Size.ToString() + "," +
|
||||
defaultFont.Bold.ToString();
|
||||
|
||||
var iniFontCsv = IniHelper.ReadValue(null, section, key, defaultFontCsv);
|
||||
var fontItems = iniFontCsv.Split(',');
|
||||
if (fontItems.Length != 3) fontItems = defaultFontCsv.Split(',');
|
||||
if (float.TryParse(fontItems[1], out var size) == false) size = defaultFont.Size;
|
||||
if (bool.TryParse(fontItems[2], out var bold) == false) bold = defaultFont.Bold;
|
||||
return new Font(fontItems[0], size, bold ? FontStyle.Bold : FontStyle.Regular);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
namespace KssSmaPlaLib.Forms.ContextMenuFunction.Gamen
|
||||
{
|
||||
partial class DgvColumnEditorForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.ColumnDgv = new System.Windows.Forms.DataGridView();
|
||||
this.CancelButton2 = new System.Windows.Forms.Button();
|
||||
this.OkButton = new System.Windows.Forms.Button();
|
||||
this.colPropertyName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colDefaultDisplayName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colDisplayName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.UpButton = new System.Windows.Forms.Button();
|
||||
this.DownButton = new System.Windows.Forms.Button();
|
||||
this.PopupMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.EditDisplayNameMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.VisibleMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ColumnDgv)).BeginInit();
|
||||
this.PopupMenu.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ColumnDgv
|
||||
//
|
||||
this.ColumnDgv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ColumnDgv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.ColumnDgv.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.colPropertyName,
|
||||
this.colDefaultDisplayName,
|
||||
this.colDisplayName});
|
||||
this.ColumnDgv.Location = new System.Drawing.Point(15, 16);
|
||||
this.ColumnDgv.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7);
|
||||
this.ColumnDgv.Name = "ColumnDgv";
|
||||
this.ColumnDgv.RowHeadersWidth = 62;
|
||||
this.ColumnDgv.RowTemplate.Height = 27;
|
||||
this.ColumnDgv.Size = new System.Drawing.Size(505, 429);
|
||||
this.ColumnDgv.TabIndex = 0;
|
||||
this.ColumnDgv.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ColumnDgv_KeyDown);
|
||||
//
|
||||
// CancelButton2
|
||||
//
|
||||
this.CancelButton2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.CancelButton2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.CancelButton2.Location = new System.Drawing.Point(346, 455);
|
||||
this.CancelButton2.Name = "CancelButton2";
|
||||
this.CancelButton2.Size = new System.Drawing.Size(177, 58);
|
||||
this.CancelButton2.TabIndex = 1;
|
||||
this.CancelButton2.Text = "キャンセル";
|
||||
this.CancelButton2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// OkButton
|
||||
//
|
||||
this.OkButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.OkButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.OkButton.Location = new System.Drawing.Point(163, 455);
|
||||
this.OkButton.Name = "OkButton";
|
||||
this.OkButton.Size = new System.Drawing.Size(177, 58);
|
||||
this.OkButton.TabIndex = 2;
|
||||
this.OkButton.Text = "OK";
|
||||
this.OkButton.UseVisualStyleBackColor = true;
|
||||
this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
|
||||
//
|
||||
// colPropertyName
|
||||
//
|
||||
this.colPropertyName.HeaderText = "識別名";
|
||||
this.colPropertyName.MinimumWidth = 8;
|
||||
this.colPropertyName.Name = "colPropertyName";
|
||||
this.colPropertyName.Width = 150;
|
||||
//
|
||||
// colDefaultDisplayName
|
||||
//
|
||||
this.colDefaultDisplayName.HeaderText = "デフォ表示名";
|
||||
this.colDefaultDisplayName.MinimumWidth = 8;
|
||||
this.colDefaultDisplayName.Name = "colDefaultDisplayName";
|
||||
this.colDefaultDisplayName.Width = 150;
|
||||
//
|
||||
// colDisplayName
|
||||
//
|
||||
this.colDisplayName.HeaderText = "表示名";
|
||||
this.colDisplayName.MinimumWidth = 8;
|
||||
this.colDisplayName.Name = "colDisplayName";
|
||||
this.colDisplayName.Width = 150;
|
||||
//
|
||||
// UpButton
|
||||
//
|
||||
this.UpButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.UpButton.Location = new System.Drawing.Point(15, 455);
|
||||
this.UpButton.Name = "UpButton";
|
||||
this.UpButton.Size = new System.Drawing.Size(59, 58);
|
||||
this.UpButton.TabIndex = 3;
|
||||
this.UpButton.Text = "👆";
|
||||
this.UpButton.UseVisualStyleBackColor = true;
|
||||
this.UpButton.Click += new System.EventHandler(this.UpButton_Click);
|
||||
//
|
||||
// DownButton
|
||||
//
|
||||
this.DownButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.DownButton.Location = new System.Drawing.Point(80, 455);
|
||||
this.DownButton.Name = "DownButton";
|
||||
this.DownButton.Size = new System.Drawing.Size(59, 58);
|
||||
this.DownButton.TabIndex = 4;
|
||||
this.DownButton.Text = "👇";
|
||||
this.DownButton.UseVisualStyleBackColor = true;
|
||||
this.DownButton.Click += new System.EventHandler(this.DownButton_Click);
|
||||
//
|
||||
// PopupMenu
|
||||
//
|
||||
this.PopupMenu.Font = new System.Drawing.Font("メイリオ", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
|
||||
this.PopupMenu.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.PopupMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.EditDisplayNameMenu,
|
||||
this.VisibleMenu});
|
||||
this.PopupMenu.Name = "PopupMenu";
|
||||
this.PopupMenu.Size = new System.Drawing.Size(394, 133);
|
||||
//
|
||||
// EditDisplayNameMenu
|
||||
//
|
||||
this.EditDisplayNameMenu.Name = "EditDisplayNameMenu";
|
||||
this.EditDisplayNameMenu.Size = new System.Drawing.Size(393, 48);
|
||||
this.EditDisplayNameMenu.Text = "表示名の編集...";
|
||||
this.EditDisplayNameMenu.Click += new System.EventHandler(this.EditDisplayNameMenu_Click);
|
||||
//
|
||||
// VisibleMenu
|
||||
//
|
||||
this.VisibleMenu.Name = "VisibleMenu";
|
||||
this.VisibleMenu.Size = new System.Drawing.Size(393, 48);
|
||||
this.VisibleMenu.Text = "表示/非表示の切り替え";
|
||||
this.VisibleMenu.Click += new System.EventHandler(this.VisibleMenu_Click);
|
||||
//
|
||||
// DgvColumnEditorForm
|
||||
//
|
||||
this.AcceptButton = this.OkButton;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(19F, 42F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.CancelButton = this.CancelButton2;
|
||||
this.ClientSize = new System.Drawing.Size(535, 525);
|
||||
this.ContextMenuStrip = this.PopupMenu;
|
||||
this.Controls.Add(this.DownButton);
|
||||
this.Controls.Add(this.UpButton);
|
||||
this.Controls.Add(this.OkButton);
|
||||
this.Controls.Add(this.CancelButton2);
|
||||
this.Controls.Add(this.ColumnDgv);
|
||||
this.Font = new System.Drawing.Font("メイリオ", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(128)));
|
||||
this.Margin = new System.Windows.Forms.Padding(6, 7, 6, 7);
|
||||
this.Name = "DgvColumnEditorForm";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "列一覧💖";
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.DgvColumnEditorForm_FormClosing);
|
||||
this.Load += new System.EventHandler(this.DgvColumnEditorForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.ColumnDgv)).EndInit();
|
||||
this.PopupMenu.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.DataGridView ColumnDgv;
|
||||
private System.Windows.Forms.Button CancelButton2;
|
||||
private System.Windows.Forms.Button OkButton;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colPropertyName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colDefaultDisplayName;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colDisplayName;
|
||||
private System.Windows.Forms.Button UpButton;
|
||||
private System.Windows.Forms.Button DownButton;
|
||||
private System.Windows.Forms.ContextMenuStrip PopupMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem EditDisplayNameMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem VisibleMenu;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
using KssSmaPlaLib.Commons;
|
||||
using KssSmaPlaLib.Forms;
|
||||
using KssSmaPlaLib.Ini;
|
||||
using KssSmaPlaLib.Input.Gamen;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace KssSmaPlaLib.Forms.ContextMenuFunction.Gamen
|
||||
{
|
||||
public partial class DgvColumnEditorForm : Form
|
||||
{
|
||||
private const string COL_NAME_PROPERTY_NAME = "colPropertyName";
|
||||
private const string COL_NAME_DEFAULT_DISPLAY_NAME = "colDefaultDisplayName";
|
||||
private const string COL_NAME_DISPLAY_NAME = "colDisplayName";
|
||||
|
||||
/// <summary>
|
||||
/// 対象のDGV
|
||||
/// </summary>
|
||||
private DataGridView _targetDgv = null;
|
||||
|
||||
/// <summary>
|
||||
/// 対象DGVの列名から列インデックスを取得する辞書
|
||||
/// (後ほど列インデックスが全てゼロになる事象が起きるため)
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, int> _colNameToRowIndexDic = null;
|
||||
|
||||
/// <summary>
|
||||
/// コンストラクタ
|
||||
/// </summary>
|
||||
/// <param name="dgv"></param>
|
||||
public DgvColumnEditorForm(DataGridView dgv)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_targetDgv = dgv;
|
||||
|
||||
// 列名から列インデックスを取得する辞書の作成(後ほど列インデックスが全てゼロになる事象が起きるため)
|
||||
_colNameToRowIndexDic = new Dictionary<string, int>();
|
||||
foreach (DataGridViewColumn col in _targetDgv.Columns) _colNameToRowIndexDic.Add(col.Name, col.Index);
|
||||
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
|
||||
DgvHelper.Initialize(ColumnDgv);
|
||||
|
||||
ColumnDgv.Rows.Clear();
|
||||
|
||||
// 編集した表示名
|
||||
var csv = IniHelper.ReadValue(null, _targetDgv.Parent.Name + "." + _targetDgv.Name, KEY_NAME_DISPLAY_NAME_CSV);
|
||||
|
||||
// 表示順のリストを作る
|
||||
var cols = new DataGridViewColumn[_targetDgv.Columns.Count];
|
||||
_targetDgv.Columns.CopyTo(cols, 0);
|
||||
Array.Sort(cols, (a, b) => a.DisplayIndex.CompareTo(b.DisplayIndex));
|
||||
|
||||
foreach (var col in cols)
|
||||
{
|
||||
var index = ColumnDgv.Rows.Add();
|
||||
string propertyName = string.Empty;
|
||||
string defaultDisplayName = string.Empty;
|
||||
bool visible = true;
|
||||
var colIndex = col.Index;
|
||||
var displayIndex = col.DisplayIndex;
|
||||
if (col.Tag == null || !(col.Tag is PropertyDescriptor))
|
||||
{
|
||||
propertyName = col.Name;
|
||||
defaultDisplayName = propertyName;
|
||||
}
|
||||
else
|
||||
{
|
||||
PropertyDescriptor pd = col.Tag as PropertyDescriptor;
|
||||
propertyName = pd.Name;
|
||||
defaultDisplayName = pd.DisplayName;
|
||||
var browsableAttr = pd.Attributes.OfType<BrowsableAttribute>().FirstOrDefault();
|
||||
if (browsableAttr != null && !browsableAttr.Browsable)
|
||||
{
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
//string displayName = col.HeaderText;
|
||||
string displayName =
|
||||
StringUxer.GetStringByIndexFormCsv(csv, colIndex, string.Empty)
|
||||
.Replace("@@@COMMA@@@", ",");
|
||||
|
||||
ColumnDgv.Rows[index].Tag = col;
|
||||
ColumnDgv.Rows[index].Cells[COL_NAME_PROPERTY_NAME].Value = (!visible ? "【非】" : "") + propertyName;
|
||||
ColumnDgv.Rows[index].Cells[COL_NAME_DEFAULT_DISPLAY_NAME].Value = defaultDisplayName;
|
||||
ColumnDgv.Rows[index].Cells[COL_NAME_DISPLAY_NAME].Value = displayName == defaultDisplayName ? "" : displayName;
|
||||
|
||||
SetVisible(index, col.Visible);
|
||||
}
|
||||
|
||||
//// タグに入れておく(PropertyDescriptor型)
|
||||
//col.Tag = pd;
|
||||
|
||||
//// 列ヘッダーを [DisplayName] に
|
||||
//col.HeaderText = pd.DisplayName;
|
||||
|
||||
//// [Browsable(false)] の列は非表示(AutoGenerateでも列が立つ場合の保険)
|
||||
//var browsableAttr = pd.Attributes.OfType<BrowsableAttribute>().FirstOrDefault();
|
||||
//if (browsableAttr != null && !browsableAttr.Browsable)
|
||||
//{
|
||||
// col.Visible = false;
|
||||
// continue;
|
||||
//}
|
||||
|
||||
// DGV列幅復元
|
||||
DgvHelper.DgvLoadColWidth(ColumnDgv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// フォームロード
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DgvColumnEditorForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
// バウンズ復元
|
||||
FormHelper.LoadFormBounds(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 👆ボタンクリック時
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void UpButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 対象外状況判断
|
||||
if (ColumnDgv.SelectedRows.Count < 1) return;
|
||||
if (ColumnDgv.SelectedRows[0].Index == 0) return;
|
||||
|
||||
// 事前取得
|
||||
var row = ColumnDgv.SelectedRows[0];
|
||||
var index = row.Index; // Removeしたら-1になるからその前に取得しておく
|
||||
|
||||
// 行移動の実行
|
||||
ColumnDgv.Rows.Remove(row);
|
||||
ColumnDgv.Rows.Insert(index - 1, row);
|
||||
|
||||
// 行選択
|
||||
ColumnDgv.ClearSelection();
|
||||
ColumnDgv.Rows[index - 1].Selected = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 👇ボタンクリック時
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DownButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 対象外状況判断
|
||||
if (ColumnDgv.SelectedRows.Count < 1) return;
|
||||
if (ColumnDgv.SelectedRows[0].Index == ColumnDgv.RowCount - 1) return;
|
||||
|
||||
// 事前取得
|
||||
var row = ColumnDgv.SelectedRows[0];
|
||||
var index = row.Index; // Removeしたら-1になるからその前に取得しておく
|
||||
|
||||
// 行移動の実行
|
||||
ColumnDgv.Rows.Remove(row);
|
||||
ColumnDgv.Rows.Insert(index + 1, row);
|
||||
|
||||
// 行選択
|
||||
ColumnDgv.ClearSelection();
|
||||
ColumnDgv.Rows[index + 1].Selected = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DGVキー押下イベント
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ColumnDgv_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Alt && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down))
|
||||
{
|
||||
if (e.KeyCode == Keys.Up)
|
||||
{
|
||||
UpButton_Click(sender, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
DownButton_Click(sender, e);
|
||||
}
|
||||
|
||||
// 既定動作抑止(メニュー呼び/ビープを止める)
|
||||
e.Handled = true;
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
private const string KEY_NAME_DISPLAY_INDEX_CSV = "DisplayIndexCsv";
|
||||
private const string KEY_NAME_COLUMN_VISIBLE_CSV = "ColumnVisibleCsv";
|
||||
private const string KEY_NAME_DISPLAY_NAME_CSV = "DisplayNameCsv";
|
||||
|
||||
/// <summary>
|
||||
/// OKボタンクリック時
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OkButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
//List<int> indexList = new List<int>();
|
||||
//foreach (DataGridViewRow row in ColumnDgv.Rows) indexList.Add(((DataGridViewColumn)row.Tag).Index);
|
||||
////MessageBox.Show(string.Join(" ", indexList));
|
||||
//if (indexList.Max() != ColumnDgv.Rows.Count - 1)
|
||||
if (_colNameToRowIndexDic.Values.Max() != ColumnDgv.Rows.Count - 1)
|
||||
{
|
||||
MessageBox.Show(this, $"_colNameToRowIndexDicがおかしい![_colNameToRowIndexDicのMax:{_colNameToRowIndexDic.Values.Max()},グリッド行数:{ColumnDgv.Rows.Count}]");
|
||||
this.DialogResult = DialogResult.None;
|
||||
return;
|
||||
}
|
||||
|
||||
// 表示順
|
||||
int[] displayIndexArray = new int[ColumnDgv.Rows.Count];
|
||||
foreach (DataGridViewRow row in ColumnDgv.Rows)
|
||||
displayIndexArray[_colNameToRowIndexDic[((DataGridViewRow)row).Cells[0].Value.ToString()]]
|
||||
= ((DataGridViewRow)row).Index;
|
||||
// INI書き込み
|
||||
IniHelper.WriteValue(null, _targetDgv.Parent.Name + "." + _targetDgv.Name, KEY_NAME_DISPLAY_INDEX_CSV, string.Join(",", displayIndexArray));
|
||||
|
||||
// 表示非表示
|
||||
bool[] visibleArray = new bool[ColumnDgv.Rows.Count];
|
||||
foreach (DataGridViewRow row in ColumnDgv.Rows)
|
||||
visibleArray[_colNameToRowIndexDic[((DataGridViewRow)row).Cells[0].Value.ToString()]]
|
||||
= IsVisible(((DataGridViewRow)row).Index);
|
||||
// INI書き込み
|
||||
IniHelper.WriteValue(null, _targetDgv.Parent.Name + "." + _targetDgv.Name, KEY_NAME_COLUMN_VISIBLE_CSV, string.Join(",", visibleArray));
|
||||
|
||||
// 表示名称
|
||||
string[] nameArray = new string[ColumnDgv.Rows.Count];
|
||||
foreach (DataGridViewRow row in ColumnDgv.Rows)
|
||||
{
|
||||
var name = string.Empty;
|
||||
if (row.Cells[COL_NAME_DISPLAY_NAME].Value.ToString() != row.Cells[COL_NAME_DEFAULT_DISPLAY_NAME].Value.ToString())
|
||||
{
|
||||
name = row.Cells[COL_NAME_DISPLAY_NAME]
|
||||
.Value
|
||||
.ToString()
|
||||
.Replace(",", "@@@COMMA@@@");
|
||||
}
|
||||
nameArray[_colNameToRowIndexDic[((DataGridViewRow)row).Cells[0].Value.ToString()]] = name;
|
||||
}
|
||||
// INI書き込み
|
||||
IniHelper.WriteValue(null, _targetDgv.Parent.Name + "." + _targetDgv.Name, KEY_NAME_DISPLAY_NAME_CSV, string.Join(",", nameArray));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// フォーム閉じるとき
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DgvColumnEditorForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
// バウンズの保存
|
||||
FormHelper.SaveFormBounds(this);
|
||||
|
||||
// DGV列幅保存
|
||||
DgvHelper.DgvSaveColWidth(ColumnDgv);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 表示名の編集メニュークリック
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void EditDisplayNameMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ColumnDgv.SelectedRows.Count < 1) return;
|
||||
var rowIndex = ColumnDgv.SelectedRows[0].Index;
|
||||
var text = ColumnDgv[COL_NAME_DISPLAY_NAME,rowIndex].Value.ToString();
|
||||
var defaultText= ColumnDgv[COL_NAME_DEFAULT_DISPLAY_NAME, rowIndex].Value.ToString();
|
||||
if (string.IsNullOrEmpty(text)) text = defaultText;
|
||||
using (var form = new TextInputForm(text))
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.Cancel) return;
|
||||
|
||||
ColumnDgv[COL_NAME_DISPLAY_NAME, rowIndex].Value = form.EditedText == defaultText ? "" : form.EditedText;
|
||||
}
|
||||
}
|
||||
|
||||
private void VisibleMenu_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ColumnDgv.SelectedRows.Count < 1) return;
|
||||
var rowIndex = ColumnDgv.SelectedRows[0].Index;
|
||||
SetVisible(rowIndex, !IsVisible(rowIndex));
|
||||
}
|
||||
|
||||
private bool IsVisible(int rowIndex)
|
||||
{
|
||||
if (rowIndex < 0 || rowIndex >= ColumnDgv.Rows.Count) return true;
|
||||
if (ColumnDgv.Rows[rowIndex].DefaultCellStyle == null) return true;
|
||||
if (ColumnDgv.Rows[rowIndex].DefaultCellStyle.Font == null) return true;
|
||||
var style = ColumnDgv.Rows[rowIndex].DefaultCellStyle.Font.Style;
|
||||
return !((style & FontStyle.Strikeout) == FontStyle.Strikeout);
|
||||
}
|
||||
private void SetVisible(int rowIndex, bool visible)
|
||||
{
|
||||
if (rowIndex < 0 || rowIndex >= ColumnDgv.Rows.Count) return;
|
||||
if (ColumnDgv.Rows[rowIndex].DefaultCellStyle == null) return;
|
||||
Font font;
|
||||
if (ColumnDgv.Rows[rowIndex].DefaultCellStyle.Font != null)
|
||||
{
|
||||
font = ColumnDgv.Rows[rowIndex].DefaultCellStyle.Font;
|
||||
}
|
||||
else
|
||||
{
|
||||
font = ColumnDgv.DefaultCellStyle.Font;
|
||||
}
|
||||
var style = font.Style;
|
||||
if (visible)
|
||||
{
|
||||
style &= ~FontStyle.Strikeout;
|
||||
}
|
||||
else
|
||||
{
|
||||
style |= FontStyle.Strikeout;
|
||||
}
|
||||
ColumnDgv.Rows[rowIndex].DefaultCellStyle.Font = new Font(font, style);
|
||||
|
||||
// 背景色
|
||||
ColumnDgv.Rows[rowIndex].DefaultCellStyle.BackColor = visible ? Color.Empty : Color.DarkGray;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="colPropertyName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colDefaultDisplayName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="colDisplayName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="PopupMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
Reference in New Issue
Block a user