using System;
using System.Diagnostics;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace Slimzhao
{
/// <summary>
/// Summary description for MergeHelpString.
/// </summary>
public class MergeHelpString : System.Windows.Forms.Form
{
private System.Windows.Forms.Button m_btn_ok;
private System.Windows.Forms.Button m_btn_cancel;
private System.Windows.Forms.ListView m_lstview_help_str;
private System.Windows.Forms.Label m_lab_assembly;
private System.Windows.Forms.ComboBox m_combox_assembly;
private System.Windows.Forms.Label m_lab_Form;
private System.Windows.Forms.ComboBox m_combox_Form;
private System.Windows.Forms.TextBox m_txtbox_ori;
private System.Windows.Forms.RadioButton m_radio_all_use_mine;
private System.Windows.Forms.RadioButton m_radio_all_use_others;
private System.Windows.Forms.Label m_lab_my_help_str;
private System.Windows.Forms.Label m_lab_others_help_str;
private System.Windows.Forms.TextBox m_txtbox_conflict;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public MergeHelpString()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
m_lstview_help_str.Columns.Add("Assembly Name", 20, HorizontalAlignment.Left);
m_lstview_help_str.Columns.Add("Form Name", 20, HorizontalAlignment.Left);
m_lstview_help_str.Columns.Add("Control Name", 20, HorizontalAlignment.Left);
m_lstview_help_str.Columns.Add("Language", 20, HorizontalAlignment.Left);
m_lstview_help_str.Columns.Add("Use", 20, HorizontalAlignment.Left);
m_ori_use_me_col = m_lstview_help_str.Columns[m_lstview_help_str.Columns.Count - 1];
m_lstview_help_str.Columns.Add("Mine", 20, HorizontalAlignment.Left);
m_lstview_help_str.Columns.Add("Use", 20, HorizontalAlignment.Left);
m_con_use_me_col = m_lstview_help_str.Columns[m_lstview_help_str.Columns.Count - 1];
m_lstview_help_str.Columns.Add("Others", 20, HorizontalAlignment.Left);
foreach(ColumnHeader col in m_lstview_help_str.Columns)
{
//ref: http://www.dotnet247.com/247reference/msgs/11/57142.aspx
col.Width = -2;
}
}
/// <summary>
///
/// </summary>
/// <param name="origin_help">Readonly original help</param>
/// <param name="conflict"></param>
internal void set_conflict(Hashtable origin_help, Hashtable conflict)
{
Debug.Assert(origin_help != null, "set_conflict: origin_help is null");
Debug.Assert(conflict != null, "set_conflict: conflict is null");
m_origin_help = duplicate_hash(origin_help);
m_conflict = conflict;
m_combox_assembly.BeginUpdate();
m_combox_assembly.Items.Clear();
try
{
Assembly_Item item = new Assembly_Item(true, null );
m_combox_assembly.Items.Add(item);
foreach (DictionaryEntry entry in conflict)
{
item = new Assembly_Item(false, entry.Key as string );
m_combox_assembly.Items.Add(item);
}
}
finally
{
m_combox_assembly.EndUpdate();
}
if( m_combox_assembly.Items.Count > 0 )
{
m_combox_assembly.SelectedIndex = 0;
}
EasyHelpString.InitSingleComboBoxDropDownWidth( m_combox_assembly );
}
private static Hashtable duplicate_hash(Hashtable origin_help)
{
Hashtable val = new Hashtable();
foreach(string assem_name in origin_help.Keys)
{
ArrayList new_arr = new ArrayList();
val[assem_name] = new_arr;
foreach(FormControl ori_fc in origin_help[assem_name] as ArrayList)
{
FormControl new_fc = new FormControl(ori_fc.FullFormName);
foreach(DictionaryEntry entry in ori_fc.ControlName_VS_Lang_Help)
{
Hashtable new_lang_2_help = new Hashtable();
foreach(DictionaryEntry ori_lang_2_help in entry.Value as Hashtable)
{
new_lang_2_help[ori_lang_2_help.Key] = ori_lang_2_help.Value;
}
new_fc.ControlName_VS_Lang_Help[entry.Key] = new_lang_2_help;
}
new_arr.Add(new_fc);
}
}
return val;
}
class Assembly_Item
{
private string m_fs_assem_fname;
private bool m_is_all;
private static ArrayList s_arrList_assem_fnames = new ArrayList();
/// <summary>
/// File name only, case-sensitive
/// </summary>
internal string Assembly_Name
{
get { return m_fs_assem_fname; }
}
internal bool IsAll
{
get { return m_is_all; }
}
static Assembly_Item()
{
foreach(Assembly a in AppDomain.CurrentDomain.GetAssemblies() )
{
s_arrList_assem_fnames.Add(Path.GetFileName(a.Location));
}
s_arrList_assem_fnames.Sort(CaseInsensitiveComparer.Default);
}
internal Assembly_Item(bool is_all, string lower_assem_fname_only)
{
m_is_all = is_all;
if( is_all ) return;
int idx = s_arrList_assem_fnames.BinarySearch(lower_assem_fname_only,
CaseInsensitiveComparer.Default) ;
Debug.Assert( idx > -1, string.Format(
"Failed to find assembly {0}", lower_assem_fname_only) );
m_fs_assem_fname = s_arrList_assem_fnames[idx] as string;
}
public override string ToString()
{
return (m_is_all) ? "All" : m_fs_assem_fname;
}
public static string GetFileName(string assem_lcase_name)
{
int idx = s_arrList_assem_fnames.BinarySearch(assem_lcase_name,
CaseInsensitiveComparer.Default) ;
Debug.Assert( idx > -1, string.Format(
"Failed to find assembly {0}", assem_lcase_name) );
return s_arrList_assem_fnames[idx] as string;
}
}
private Hashtable m_origin_help;
private Hashtable m_conflict;
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(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.m_btn_ok = new System.Windows.Forms.Button();
this.m_btn_cancel = new System.Windows.Forms.Button();
this.m_lstview_help_str = new System.Windows.Forms.ListView();
this.m_lab_assembly = new System.Windows.Forms.Label();
this.m_combox_assembly = new System.Windows.Forms.ComboBox();
this.m_lab_Form = new System.Windows.Forms.Label();
this.m_combox_Form = new System.Windows.Forms.ComboBox();
this.m_txtbox_ori = new System.Windows.Forms.TextBox();
this.m_txtbox_conflict = new System.Windows.Forms.TextBox();
this.m_lab_my_help_str = new System.Windows.Forms.Label();
this.m_lab_others_help_str = new System.Windows.Forms.Label();
this.m_radio_all_use_mine = new System.Windows.Forms.RadioButton();
this.m_radio_all_use_others = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
//
// m_btn_ok
//
this.m_btn_ok.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.m_btn_ok.DialogResult = System.Windows.Forms.DialogResult.OK;
this.m_btn_ok.Location = new System.Drawing.Point(720, 482);
this.m_btn_ok.Name = "m_btn_ok";
this.m_btn_ok.TabIndex = 0;
this.m_btn_ok.Text = "&OK";
this.m_btn_ok.Click += new System.EventHandler(this.m_btn_ok_Click);
//
// m_btn_cancel
//
this.m_btn_cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.m_btn_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.m_btn_cancel.Location = new System.Drawing.Point(800, 482);
this.m_btn_cancel.Name = "m_btn_cancel";
this.m_btn_cancel.TabIndex = 0;
this.m_btn_cancel.Text = "&Cancel";
//
// m_lstview_help_str
//
this.m_lstview_help_str.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.m_lstview_help_str.FullRowSelect = true;
this.m_lstview_help_str.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.m_lstview_help_str.HideSelection = false;
this.m_lstview_help_str.Location = new System.Drawing.Point(8, 40);
this.m_lstview_help_str.MultiSelect = false;
this.m_lstview_help_str.Name = "m_lstview_help_str";
this.m_lstview_help_str.Size = new System.Drawing.Size(864, 288);
this.m_lstview_help_str.TabIndex = 1;
this.m_lstview_help_str.View = System.Windows.Forms.View.Details;
this.m_lstview_help_str.Click += new System.EventHandler(this.m_lstview_help_str_Click);
this.m_lstview_help_str.SelectedIndexChanged += new System.EventHandler(this.m_lstview_help_str_SelectedIndexChanged);
//
// m_lab_assembly
//
this.m_lab_assembly.Location = new System.Drawing.Point(8, 8);
this.m_lab_assembly.Name = "m_lab_assembly";
this.m_lab_assembly.Size = new System.Drawing.Size(80, 23);
this.m_lab_assembly.TabIndex = 2;
this.m_lab_assembly.Text = "Assembly:";
this.m_lab_assembly.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// m_combox_assembly
//
this.m_combox_assembly.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.m_combox_assembly.Location = new System.Drawing.Point(104, 9);
this.m_combox_assembly.Name = "m_combox_assembly";
this.m_combox_assembly.Size = new System.Drawing.Size(121, 20);
this.m_combox_assembly.TabIndex = 3;
this.m_combox_assembly.SelectedIndexChanged += new System.EventHandler(this.m_combox_assembly_SelectedIndexChanged);
//
// m_lab_Form
//
this.m_lab_Form.Location = new System.Drawing.Point(240, 8);
this.m_lab_Form.Name = "m_lab_Form";
this.m_lab_Form.Size = new System.Drawing.Size(48, 23);
this.m_lab_Form.TabIndex = 2;
this.m_lab_Form.Text = "Forms:";
this.m_lab_Form.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// m_combox_Form
//
this.m_combox_Form.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.m_combox_Form.Location = new System.Drawing.Point(296, 8);
this.m_combox_Form.Name = "m_combox_Form";
this.m_combox_Form.Size = new System.Drawing.Size(121, 20);
this.m_combox_Form.TabIndex = 3;
this.m_combox_Form.SelectedIndexChanged += new System.EventHandler(this.m_combox_Form_SelectedIndexChanged);
//
// m_txtbox_ori
//
this.m_txtbox_ori.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.m_txtbox_ori.Location = new System.Drawing.Point(16, 360);
this.m_txtbox_ori.Multiline = true;
this.m_txtbox_ori.Name = "m_txtbox_ori";
this.m_txtbox_ori.Size = new System.Drawing.Size(408, 112);
this.m_txtbox_ori.TabIndex = 4;
this.m_txtbox_ori.Text = "";
this.m_txtbox_ori.TextChanged += new System.EventHandler(this.m_txtbox_ori_TextChanged);
//
// m_txtbox_conflict
//
this.m_txtbox_conflict.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.m_txtbox_conflict.Location = new System.Drawing.Point(464, 360);
this.m_txtbox_conflict.Multiline = true;
this.m_txtbox_conflict.Name = "m_txtbox_conflict";
this.m_txtbox_conflict.Size = new System.Drawing.Size(408, 112);
this.m_txtbox_conflict.TabIndex = 4;
this.m_txtbox_conflict.Text = "";
this.m_txtbox_conflict.TextChanged += new System.EventHandler(this.m_txtbox_ori_TextChanged);
//
// m_lab_my_help_str
//
this.m_lab_my_help_str.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.m_lab_my_help_str.Location = new System.Drawing.Point(16, 336);
this.m_lab_my_help_str.Name = "m_lab_my_help_str";
this.m_lab_my_help_str.Size = new System.Drawing.Size(88, 23);
this.m_lab_my_help_str.TabIndex = 2;
this.m_lab_my_help_str.Text = "My Help str:";
this.m_lab_my_help_str.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// m_lab_others_help_str
//
this.m_lab_others_help_str.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.m_lab_others_help_str.Location = new System.Drawing.Point(464, 336);
this.m_lab_others_help_str.Name = "m_lab_others_help_str";
this.m_lab_others_help_str.Size = new System.Drawing.Size(128, 23);
this.m_lab_others_help_str.TabIndex = 2;
this.m_lab_others_help_str.Text = "Help str from others";
this.m_lab_others_help_str.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// m_radio_all_use_mine
//
this.m_radio_all_use_mine.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.m_radio_all_use_mine.Location = new System.Drawing.Point(120, 336);
this.m_radio_all_use_mine.Name = "m_radio_all_use_mine";
this.m_radio_all_use_mine.TabIndex = 5;
this.m_radio_all_use_mine.Text = "All use mine";
this.m_radio_all_use_mine.CheckedChanged += new System.EventHandler(this.m_radio_all_use_mine_CheckedChanged);
//
// m_radio_all_use_others
//
this.m_radio_all_use_others.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.m_radio_all_use_others.Checked = true;
this.m_radio_all_use_others.Location = new System.Drawing.Point(600, 336);
this.m_radio_all_use_others.Name = "m_radio_all_use_others";
this.m_radio_all_use_others.Size = new System.Drawing.Size(112, 24);
this.m_radio_all_use_others.TabIndex = 5;
this.m_radio_all_use_others.TabStop = true;
this.m_radio_all_use_others.Text = "All use others";
this.m_radio_all_use_others.CheckedChanged += new System.EventHandler(this.m_radio_all_use_mine_CheckedChanged);
//
// MergeHelpString
//
this.AcceptButton = this.m_btn_ok;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.CancelButton = this.m_btn_cancel;
this.ClientSize = new System.Drawing.Size(888, 509);
this.ControlBox = false;
this.Controls.Add(this.m_radio_all_use_mine);
this.Controls.Add(this.m_txtbox_ori);
this.Controls.Add(this.m_txtbox_conflict);
this.Controls.Add(this.m_combox_assembly);
this.Controls.Add(this.m_lab_assembly);
this.Controls.Add(this.m_lstview_help_str);
this.Controls.Add(this.m_btn_ok);
this.Controls.Add(this.m_btn_cancel);
this.Controls.Add(this.m_lab_Form);
this.Controls.Add(this.m_combox_Form);
this.Controls.Add(this.m_lab_my_help_str);
this.Controls.Add(this.m_lab_others_help_str);
this.Controls.Add(this.m_radio_all_use_others);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MergeHelpString";
this.ShowInTaskbar = false;
this.Text = "MergeHelpString";
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.MergeHelpString_MouseMove);
this.ResumeLayout(false);
}
#endregion
private void MergeHelpString_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if( e.Button == MouseButtons.Left )
{
Native.ReleaseCapture();
Native.SendMessage(this.Handle, Native.WM_NCLBUTTONDOWN, Native.HTCAPTION, 0);
}
}
private void m_combox_assembly_SelectedIndexChanged(object sender, System.EventArgs e)
{
Assembly_Item item = m_combox_assembly.SelectedItem as Assembly_Item;
Debug.Assert(item != null, "");
m_combox_Form.Items.Clear();
if( item.IsAll )
{
m_combox_Form.Enabled = false;
m_combox_Form_SelectedIndexChanged(m_combox_Form, EventArgs.Empty);
return;
}
m_combox_Form.Enabled = true;
ArrayList arr = m_conflict[ item.Assembly_Name.ToLower() ] as ArrayList;
Debug.Assert( arr != null, "");
m_combox_Form.BeginUpdate();
try
{
foreach(FormControl fc in arr)
{
m_combox_Form.Items.Add(fc);
}
}
finally
{
m_combox_Form.EndUpdate();
}
if( m_combox_Form.Items.Count > 0 )
{
m_combox_Form.SelectedIndex = 0;
}
EasyHelpString.InitSingleComboBoxDropDownWidth( m_combox_Form );
}
const string c_checked_symbol = "��";
private void m_combox_Form_SelectedIndexChanged(object sender, System.EventArgs e)
{
Assembly_Item assem_item = m_combox_assembly.SelectedItem as Assembly_Item;
Hashtable hashtable = new Hashtable();
if( assem_item.IsAll )
{
hashtable = m_conflict;
}
else
{
ArrayList arr_FormControl = new ArrayList();
arr_FormControl.Add(m_combox_Form.SelectedItem );
hashtable[assem_item.Assembly_Name.ToLower()] = arr_FormControl;
}
m_lstview_help_str.BeginUpdate();
m_lstview_help_str.Items.Clear();
try
{
foreach(DictionaryEntry assem_2_arr_FormControl in hashtable)
{
string assem_lcase_name = assem_2_arr_FormControl.Key as string;
foreach(FormControl form_control in (assem_2_arr_FormControl.Value as ArrayList) )
{
FormControl ori_form_control = form_control.find_name_matched(
m_origin_help[assem_lcase_name] as ArrayList);
Debug.Assert( ori_form_control != null, "Not found counter part");
Hashtable ctrl_name_VS_lang_help = form_control.ControlName_VS_Lang_Help;
Hashtable ori_ctrl_name_VS_lang_help = ori_form_control.ControlName_VS_Lang_Help;
foreach(DictionaryEntry entry in ctrl_name_VS_lang_help)
{
Hashtable lang_VS_help = entry.Value as Hashtable;
Hashtable ori_lang_VS_help = ori_ctrl_name_VS_lang_help[ entry.Key] as Hashtable;
foreach(DictionaryEntry lang_D_help in lang_VS_help)
{
string lang = lang_D_help.Key as string;
ListViewItem item = new ListViewItem(new string[]
{
Assembly_Item.GetFileName(assem_lcase_name ),
form_control.FullFormName,
entry.Key as string, lang, "", ori_lang_VS_help[lang] as string,
c_checked_symbol, lang_D_help.Value as string }
);
item.Tag = form_control;
m_lstview_help_str.Items.Add(item);
}
}
}
}
}
finally
{
m_lstview_help_str.EndUpdate();
}
if( m_lstview_help_str.Items.Count > 0)
{
m_lstview_help_str.Items[0].Selected = true;
}
}
private void m_lstview_help_str_SelectedIndexChanged(object sender, System.EventArgs e)
{
b_click_use_ori_col_before_change_idx = false;
b_click_use_con_col_before_change_idx = false;
if( m_lstview_help_str.SelectedItems.Count < 1 )
{
set_text_withoug_TextChanged(m_txtbox_conflict, string.Empty);
set_text_withoug_TextChanged(m_txtbox_ori, string.Empty);
m_txtbox_conflict.Enabled = m_txtbox_ori.Enabled = false;
return;
}
m_txtbox_conflict.Enabled = m_txtbox_ori.Enabled = true;
ListViewItem item = m_lstview_help_str.SelectedItems[0];
Debug.Assert( item != null, "");
set_text_withoug_TextChanged(m_txtbox_ori, string.Empty);
string lang_name = item.SubItems[ col_idx_lang ] .Text;
Debug.Assert(lang_name != null && lang_name.Length > 0, "");
string ctrl_name = item.SubItems[col_idx_ctrl_name].Text;
//Original
string assem_name = item.SubItems[col_idx_assem_name].Text.ToLower();
FormControl con_fc = item.Tag as FormControl;
FormControl ori_fc = con_fc.find_name_matched(m_origin_help[assem_name] as ArrayList);
Hashtable con_lang_2_help = con_fc.ControlName_VS_Lang_Help[ctrl_name ] as Hashtable;
Hashtable ori_lang_2_help = ori_fc.ControlName_VS_Lang_Help[ ctrl_name] as Hashtable;
set_text_withoug_TextChanged(m_txtbox_conflict, con_lang_2_help[ lang_name ] as string);
set_text_withoug_TextChanged(m_txtbox_ori, ori_lang_2_help[ lang_name ] as string);
}
private void set_text_withoug_TextChanged(TextBox txtbox, string text)
{
try
{
change_by_lst_view = true;
txtbox.Text = text;
}
finally
{
change_by_lst_view = false;
}
}
private static int col_idx_assem_name = 0;
private static int col_idx_form_name = 1;
private static int col_idx_ctrl_name = 2;
private static int col_idx_lang = 3;
private static int col_idx_use_mine = 4;
private static int col_idx_help_mine = 5;
private static int col_idx_use_others = 6;
private static int col_idx_help_others = 7;
private bool b_click_use_ori_col_before_change_idx = false;
private bool b_click_use_con_col_before_change_idx = false;
private void m_lstview_help_str_Click(object sender, System.EventArgs e)
{
Point pt = m_lstview_help_str.PointToClient(MousePosition);
ListViewItem item = m_lstview_help_str.GetItemAt(pt.X, pt.Y);
if( item == null )
return;
ListViewItem selected_item = null;
if( m_lstview_help_str.SelectedItems.Count > 0)
selected_item = m_lstview_help_str.SelectedItems[0];
//Get the start and end position of Original use and Conflict use
int start_x = 0;
int ori_start_x = 0, ori_end_x = 0, con_start_x = 0, con_end_x = 0;
foreach(ColumnHeader col in m_lstview_help_str.Columns)
{
if( col == m_ori_use_me_col)
{
ori_start_x = start_x;
ori_end_x = start_x + col.Width;
}
if( col == m_con_use_me_col)
{
con_start_x = start_x;
con_end_x = start_x + col.Width;
}
start_x += col.Width;
}
b_click_use_ori_col_before_change_idx = ( ori_start_x <= pt.X && ori_end_x >= pt.X );
b_click_use_con_col_before_change_idx = ( con_start_x <= pt.X && con_end_x >= pt.X );
if( selected_item != item )
{
return;
}
//Check on/off Use mine help str
ListViewItem.ListViewSubItem use_mine = item.SubItems[col_idx_use_mine];
ListViewItem.ListViewSubItem use_others = item.SubItems[col_idx_use_others];
if( b_click_use_ori_col_before_change_idx )
{
use_mine.Text = c_checked_symbol;
use_others.Text = string.Empty;
}
if( b_click_use_con_col_before_change_idx )
{
use_others.Text = string.Empty;
use_mine.Text = c_checked_symbol;
}
}
private ColumnHeader m_ori_use_me_col = null;
private ColumnHeader m_con_use_me_col = null;
private void m_btn_ok_Click(object sender, System.EventArgs e)
{
//Save to conflict
foreach(ListViewItem item in m_lstview_help_str.Items)
{
ListViewItem.ListViewSubItem use_mine = item.SubItems[col_idx_use_mine];
bool b_use_mine = (use_mine.Text != "");
if( b_use_mine )
{
FormControl con_fc = item.Tag as FormControl;
string con_assem_name = item.SubItems[col_idx_assem_name].Text.ToLower();
string con_ctrl_name = item.SubItems[col_idx_ctrl_name].Text.ToLower();
string con_lang_str = item.SubItems[col_idx_lang].Text.ToLower();
FormControl ori_fc = con_fc.find_name_matched(m_origin_help[ con_assem_name.ToLower() ] as ArrayList );
Debug.Assert( ori_fc != null, "Not found ");
Hashtable ori_lang_help = ori_fc.ControlName_VS_Lang_Help[con_ctrl_name] as Hashtable;
Hashtable con_lang_help = con_fc.ControlName_VS_Lang_Help[con_ctrl_name] as Hashtable;
con_lang_help[con_lang_str] = ori_lang_help[con_lang_str];
}
}
}
private void m_radio_all_use_mine_CheckedChanged(object sender, System.EventArgs e)
{
RadioButton r = sender as RadioButton;
if( r.Checked == false )
return;
bool all_mine = (sender == m_radio_all_use_mine);
foreach(ListViewItem item in m_lstview_help_str.Items)
{
ListViewItem.ListViewSubItem use_mine = item.SubItems[col_idx_use_mine];
ListViewItem.ListViewSubItem use_others = item.SubItems[col_idx_use_others];
use_mine.Text = (all_mine)? c_checked_symbol: "";
use_others.Text = (all_mine == false )? c_checked_symbol: "";
}
}
private bool change_by_lst_view = false;
private void m_txtbox_ori_TextChanged(object sender, System.EventArgs e)
{
if( change_by_lst_view )
return;
bool change_mine = (sender == m_txtbox_ori);
Debug.Assert( m_lstview_help_str.Items.Count > 0);
ListViewItem sele_item = m_lstview_help_str.SelectedItems[0];
FormControl con_fc = sele_item.Tag as FormControl;
string con_assem_name = sele_item.SubItems[col_idx_assem_name].Text.ToLower();
string con_ctrl_name = sele_item.SubItems[col_idx_ctrl_name].Text.ToLower();
string con_lang_str = sele_item.SubItems[col_idx_lang].Text.ToLower();
string new_text = (sender as TextBox).Text;
Hashtable lang_2_help = null;
if( change_mine )
{
FormControl ori_fc = con_fc.find_name_matched(m_origin_help[ con_assem_name.ToLower() ] as ArrayList );
lang_2_help = ori_fc.ControlName_VS_Lang_Help[con_ctrl_name] as Hashtable;
//Update UI text
sele_item.SubItems[col_idx_help_mine].Text = new_text;
}
else
{
lang_2_help = con_fc.ControlName_VS_Lang_Help[con_ctrl_name] as Hashtable;
sele_item.SubItems[col_idx_help_others ].Text = new_text;
}
lang_2_help[con_lang_str] = new_text;
}
}
}