private void b_src_change_file_Click(object sender, EventArgs e) { if ((null != m_sel_header) && (1 == m_sel_items.Count)) { ListViewItem li = m_sel_items[0]; conv_core.cImageFile img = li.Tag as conv_core.cImageFile; conv_core.cFormat fmt = conv_core.workbench.file_format(img.path); string all_files_format = ""; string file_formats = ""; for (int sd = 0; conv_core.workbench.formats.count > sd; sd++) { if (conv_core.workbench.formats[sd].has_reader) { all_files_format += ((0 == sd)? "" : ";") + "*." + conv_core.workbench.formats[sd].ext; file_formats += "|" + conv_core.workbench.formats[sd].desc + "|*." + conv_core.workbench.formats[sd].ext; } ; } ; dw_save.Title = "Change file location"; dw_save.InitialDirectory = Path.GetDirectoryName(img.path); dw_save.Filter = ((0 < all_files_format.Length)? "all supported formats|" + all_files_format : "") + ((0 < file_formats.Length)? file_formats + "|" : "") + "any file|*.*"; dw_save.FileName = Path.GetFileName(img.path); dw_save.OverwritePrompt = false; switch (dw_save.ShowDialog(this)) { case DialogResult.OK: if (dw_save.FileName != li.ToolTipText) { img.path = dw_save.FileName; li.Text = Path.GetFileName(img.path); li.ToolTipText = img.path; if (fmt != conv_core.workbench.file_format(img.path)) { img.options = null; } ; t_mod.Enabled = true; m_sel_header.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } ; break; } ; } ; }
private void b_src_enabled_Click(object sender, EventArgs e) { if ((null != m_sel_header) && (0 < m_sel_items.Count)) { foreach (ListViewItem li in m_sel_items) { conv_core.cImageFile fd = li.Tag as conv_core.cImageFile; fd.enabled = b_src_enabled.Checked; li.ForeColor = (fd.enabled)? cell_font_normal : cell_font_disabled; } ; t_mod.Enabled = true; } ; }
bool load_images(string[] files) { if (ConvertProcessor.in_process) { return(false); } ; int included_count = 0; foreach (string file in files) { if (conv_core.workbench.valid_file(file) && !source_file_exists(file.ToLower())) { ListViewItem li = lv_files.Items.Add(""); li.Name = Path.GetFileNameWithoutExtension(file).ToLower(); li.Text = Path.GetFileName(file).ToLower(); li.ToolTipText = file; conv_core.cImageFile img = new conv_core.cImageFile(file); li.Tag = img; li.UseItemStyleForSubItems = false; img.new_crc = img.crc = conv_core.workbench.file_crc(file); foreach (ColumnHeader hdr in m_formats) { conv_core.cFormat fmt = hdr.Tag as conv_core.cFormat; ListViewItem.ListViewSubItem lsi = li.SubItems.Add(li.Name + "." + fmt.ext); lsi.Tag = new conv_core.cImageFile(t_base_dir.Text + "\\" + lsi.Text); hdr.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } ; included_count++; } ; } ; t_mod.Enabled |= 0 < included_count; return(0 < included_count); }
private bool build_image(conv_core.cImageFile img, conv_core.cFormat format, ToolStripButton button) { Bitmap bmp = new Bitmap(img.width, img.height, PixelFormat.Format32bppArgb); button.Tag = bmp; Rectangle r = new Rectangle(0, 0, img.width, img.height); BitmapData bd = bmp.LockBits(r, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); int[] img_row = new int[r.Width]; unsafe { byte *bstr = (byte *)bd.Scan0.ToPointer(); int row = 0; while (r.Height > row) { img.get_row(row, img_row); int *pix = (int *)bstr; foreach (int pixel in img_row) { byte *ch = (byte *)pix; * pix++ = pixel; byte c = ch[0]; ch[0] = ch[2]; ch[2] = c; } ; bstr += bd.Stride; row++; } ; }; bmp.UnlockBits(bd); return(true); }
public static bool load( string path, MainForm form ) { try{ XmlDocument file = new XmlDocument(); file.Load( path ); form.t_base_dir.Text = file["project"].Attributes["destination"].Value.ToLower(); if( '\\' == form.t_base_dir.Text.Last() ){ form.t_base_dir.Text = form.t_base_dir.Text.Remove( form.t_base_dir.Text.Length - 1 ); }; XmlElement formats = file["project"]["formats"]; XmlElement files = file["project"]["files"]; foreach( XmlElement fmt in formats.ChildNodes ){ form.add_format( fmt.Attributes["name"].Value ); }; foreach( XmlElement fd in files.ChildNodes ){ if( conv_core.workbench.valid_file( fd.Attributes["file.path"].Value ) ){ bool check_crc = fd.HasAttribute( "file.crc" ); ListViewItem li = form.lv_files.Items.Add( "" ); conv_core.cImageFile fid = new conv_core.cImageFile( fd.Attributes["file.path"].Value ); li.ToolTipText = fid.path.ToLower(); li.Name = Path.GetFileNameWithoutExtension( li.ToolTipText ).ToLower(); li.Text = Path.GetFileName( li.ToolTipText ).ToLower(); li.Tag = fid; fid.enabled = Convert.ToBoolean( fd.Attributes["file.enabled"].Value ); fid.crc = ( check_crc )? Convert.ToUInt32( fd.Attributes["file.crc"].Value ) : conv_core.workbench.file_crc( fid.path ); li.ForeColor = ( fid.enabled )? MainForm.cell_font_normal : MainForm.cell_font_disabled; li.UseItemStyleForSubItems = false; if( ( null != fd.Attributes["file.format"] ) && Convert.ToBoolean( fd.Attributes["file.format"].Value ) ){ //fid.options = }; if( check_crc ){ fid.new_crc = conv_core.workbench.file_crc( fid.path ); if( fid.crc != fid.new_crc ){ li.BackColor = MainForm.cell_back_modified; }; }else{ fid.new_crc = fid.crc; form.t_mod.Enabled = true; }; foreach( ColumnHeader hdr in form.m_formats ){ XmlElement convert = null; foreach( XmlElement cvt in fd.ChildNodes ){ if( hdr.Text == cvt.Attributes["format"].Value ){ convert = cvt; break; }; }; conv_core.cFormat fmt = hdr.Tag as conv_core.cFormat; if( null == convert ){ ListViewItem.ListViewSubItem lsi = li.SubItems.Add( li.Name + "." + fmt.ext ); lsi.Tag = new conv_core.cImageFile( form.t_base_dir.Text + "\\" + lsi.Text ); }else{ string conv_name = convert.Attributes["destination"].Value; if( '\\' == conv_name[0] ){ conv_name = conv_name.Remove( 0, 1 ); }; ListViewItem.ListViewSubItem lsi = li.SubItems.Add( conv_name ); conv_core.cImageFile img = new conv_core.cImageFile( form.t_base_dir.Text + "\\" + lsi.Text ); lsi.Tag = img; img.enabled = Convert.ToBoolean( convert.Attributes["enabled"].Value ); lsi.ForeColor = Color.FromArgb( (int)( ( img.enabled )? 0xFF000000 : 0xFF666666 ) ); if( 0 < convert.ChildNodes.Count ){ img.options = fmt.writer_options_desc.create_options(); foreach( XmlElement prop in convert.ChildNodes ){ if( "property" != prop.Name ){ continue; }; string op_name = prop.Attributes["name"].Value; if( null != img.options[ op_name ] ){ conv_core.cOption opt = img.options[ op_name ]; switch( img.options.desc[ op_name ].type ){ case conv_core.OptionType.STRING: opt.value_str = prop.Attributes["value"].Value; break; default: opt.value = Convert.ToInt32( prop.Attributes["value"].Value ); break; }; }; }; }; }; }; }; }; foreach( ColumnHeader hdr in form.m_formats ){ hdr.AutoResize( ColumnHeaderAutoResizeStyle.ColumnContent ); }; }catch( Exception ){ return false; }; return true; }
private void b_format_change_file_Click(object sender, EventArgs e) { if ((null != m_sel_header) && (0 < m_sel_subitems.Count)) { if (2 > m_sel_subitems.Count) { ListViewItem.ListViewSubItem lsi = m_sel_subitems[0]; conv_core.cFormat fmt = m_sel_header.Tag as conv_core.cFormat; conv_core.cImageFile img = lsi.Tag as conv_core.cImageFile; dw_save.Title = "Change file location"; dw_save.InitialDirectory = Path.GetDirectoryName(img.path); dw_save.Filter = fmt.desc + "|*." + fmt.ext; dw_save.FileName = Path.GetFileName(img.path); switch (dw_save.ShowDialog(this)) { case DialogResult.OK: string new_path = conv_core.workbench.relative_path(t_base_dir.Text, dw_save.FileName); if ((0 < new_path.Length) && (new_path != lsi.Text)) { img.path = dw_save.FileName.ToLower(); lsi.Text = new_path; t_mod.Enabled = true; m_sel_header.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } ; break; } ; } else { dw_dir.Description = "Select new files location."; dw_dir.SelectedPath = Path.GetDirectoryName((m_sel_subitems[0].Tag as conv_core.cImageFile).path); switch (dw_dir.ShowDialog(this)) { case DialogResult.OK: foreach (ListViewItem.ListViewSubItem lsi in m_sel_subitems) { conv_core.cImageFile img = lsi.Tag as conv_core.cImageFile; string file_name = Path.GetFileName(img.path); string new_path = conv_core.workbench.relative_path(t_base_dir.Text, dw_dir.SelectedPath + "\\" + file_name); if ((0 < new_path.Length) && (new_path != lsi.Text)) { img.path = dw_dir.SelectedPath.ToLower() + "\\" + file_name; lsi.Text = new_path; } ; } ; t_mod.Enabled = true; m_sel_header.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); break; } ; }; } ; }
bool load_images( string[] files ) { if( ConvertProcessor.in_process ){ return false; }; int included_count = 0; foreach( string file in files ){ if( conv_core.workbench.valid_file( file ) && !source_file_exists( file.ToLower() ) ){ ListViewItem li = lv_files.Items.Add( "" ); li.Name = Path.GetFileNameWithoutExtension( file ).ToLower(); li.Text = Path.GetFileName( file ).ToLower(); li.ToolTipText = file; conv_core.cImageFile img = new conv_core.cImageFile( file ); li.Tag = img; li.UseItemStyleForSubItems = false; img.new_crc = img.crc = conv_core.workbench.file_crc( file ); foreach( ColumnHeader hdr in m_formats ){ conv_core.cFormat fmt = hdr.Tag as conv_core.cFormat; ListViewItem.ListViewSubItem lsi = li.SubItems.Add( li.Name + "." + fmt.ext ); lsi.Tag = new conv_core.cImageFile( t_base_dir.Text + "\\" + lsi.Text ); hdr.AutoResize( ColumnHeaderAutoResizeStyle.ColumnContent ); }; included_count++; }; }; t_mod.Enabled |= 0 < included_count; return 0 < included_count; }
private static void watchdog_routine() { bool do_watch = false; bool watching = true; m_active = true; while (watching) { lock ( m_form ){ do_watch = m_do_watch; watching = m_watching; }; if (!watching) { break; } ; if (!do_watch) { lock ( m_monitor ){ Monitor.Wait(m_monitor); }; continue; } ; m_items.Clear(); m_process = true; m_form.Invoke(new Action(() => { m_form.pb_progress.Visible = true; m_form.pb_progress.Value = 0; m_form.pb_progress.Maximum = m_form.lv_files.Items.Count; foreach (ListViewItem li in m_form.lv_files.Items) { m_items.Add(li); } ; })); foreach (ListViewItem li in m_items) { conv_core.cImageFile img = li.Tag as conv_core.cImageFile; if (img.crc == img.new_crc) { img.new_crc = conv_core.workbench.file_crc(img.path); if (img.crc != img.new_crc) { li.BackColor = MainForm.cell_back_modified; } ; m_form.Invoke(new Action(() => { m_form.pb_progress.PerformStep(); })); } ; } ; m_form.Invoke(new Action(() => { m_form.pb_progress.Visible = false; })); m_process = false; lock ( m_form ){ m_do_watch = false; }; } ; lock ( m_exit_watch ){ m_active = false; Monitor.PulseAll(m_exit_watch); }; }
private static void thread_routine(object reference) { List <ListViewItem> pool = reference as List <ListViewItem>; bool do_cancel = false; lock ( m_form ){ do_cancel = m_cancel; }; while (!do_cancel && (0 < pool.Count)) { bool mod_flag = true; bool do_mod = false; ListViewItem li = pool.First(); conv_core.cImageFile src_img = li.Tag as conv_core.cImageFile; if (src_img.enabled) { int coverted = 0; foreach (ColumnHeader hdr in m_form.m_formats) { if (!(li.SubItems[hdr.Index].Tag as conv_core.cImageFile).enabled) { li.SubItems[hdr.Index].BackColor = MainForm.cell_back_disabled; coverted++; continue; } ; conv_core.cFormat fmt = hdr.Tag as conv_core.cFormat; ListViewItem.ListViewSubItem lsi = li.SubItems[hdr.Index]; if (fmt.convert(src_img, lsi.Tag as conv_core.cImageFile)) { lsi.BackColor = Color.LightGreen; coverted++; } else { lsi.BackColor = Color.LightPink; }; } ; if (m_form.m_formats.Count == coverted) { li.BackColor = MainForm.cell_back_done; if (mod_flag && (src_img.crc != src_img.new_crc)) { do_mod = true; } ; src_img.crc = src_img.new_crc; } else if (src_img.crc == src_img.new_crc) { li.BackColor = MainForm.cell_back_error; } ; src_img.close(); } ; pool.RemoveAt(0); lock ( m_form ){ m_form.Invoke(new Action(() => { m_form.pb_progress.PerformStep(); })); if (mod_flag && do_mod) { m_form.Invoke(new Action(() => { m_form.t_mod.Enabled = true; })); mod_flag = false; } ; do_cancel = m_cancel; }; } ; }
private static void thread_factory() { m_process = true; int items_count = 0; int threads_count = Environment.ProcessorCount / 2; m_form.Invoke(new Action(() => { m_form.b_process.Enabled = false; m_form.b_progress_cancel.Enabled = true; items_count = (null == m_elements)? m_form.lv_files.Items.Count : m_elements.Count; })); if ((2 > (items_count / Environment.ProcessorCount)) || (1 > threads_count)) { threads_count = 1; } ; for (int proc_id = 0; threads_count > proc_id; proc_id++) { m_threads.Add(new Thread(thread_routine)); m_routines.Add(new List <ListViewItem>()); } ; int pool = 0; items_count = 0; m_form.Invoke(new Action(() => { m_form.lv_files.BeginUpdate(); if (null == m_elements) { foreach (ListViewItem li in m_form.lv_files.Items) { conv_core.cImageFile img = li.Tag as conv_core.cImageFile; if (img.enabled) { img.new_crc = conv_core.workbench.file_crc(img.path); li.BackColor = (img.crc == img.new_crc)? MainForm.cell_back_normal : MainForm.cell_back_modified; foreach (ListViewItem.ListViewSubItem lsi in li.SubItems) { lsi.BackColor = MainForm.cell_back_normal; } ; m_routines[pool++].Add(li); if (m_routines.Count <= pool) { pool = 0; } ; items_count++; } ; } ; } else { foreach (ListViewItem li in m_elements) { conv_core.cImageFile img = li.Tag as conv_core.cImageFile; if (img.enabled) { li.BackColor = (img.crc == img.new_crc)? MainForm.cell_back_normal : MainForm.cell_back_modified; foreach (ListViewItem.ListViewSubItem lsi in li.SubItems) { lsi.BackColor = MainForm.cell_back_normal; } ; m_routines[pool++].Add(li); if (m_routines.Count <= pool) { pool = 0; } ; items_count++; } ; } ; }; m_form.lv_files.EndUpdate(); })); m_cancel = false; for (int id = 0; m_threads.Count > id; id++) { m_threads[id].Start(m_routines[id]); } ; Thread.Sleep(0); m_form.Invoke(new Action(() => { m_form.pb_progress.Visible = true; m_form.pb_progress.Value = 0; m_form.pb_progress.Maximum = items_count; })); while (!m_cancel) { int score = 0; foreach (List <ListViewItem> fd in m_routines) { score += fd.Count; } ; if (0 == score) { break; } ; Thread.Sleep(10); } ; m_cancel = true; m_form.Invoke(new Action(() => { m_form.pb_progress.Visible = false; })); for (int id = 0; m_threads.Count > id; id++) { m_threads[id].Join(); m_routines[id].Clear(); } ; m_routines.Clear(); m_threads.Clear(); m_form.Invoke(new Action(() => { m_form.b_process.Enabled = true; m_form.b_progress_cancel.Enabled = false; })); m_process = false; m_form = null; }
public static bool save(string path, MainForm form) { try{ XmlDocument file = new XmlDocument(); string base_dir = form.t_base_dir.Text; if ('\\' == base_dir.Last()) { base_dir = base_dir.Remove(base_dir.Length - 1); } ; XmlElement prj = file.AppendChild(file.CreateElement("project")) as XmlElement; prj.SetAttribute("destination", base_dir); base_dir += '\\'; XmlElement formats = prj.AppendChild(file.CreateElement("formats")) as XmlElement; foreach (ColumnHeader hdr in form.m_formats) { XmlElement format = formats.AppendChild(file.CreateElement("format")) as XmlElement; format.SetAttribute("name", hdr.Text); } ; XmlElement files = prj.AppendChild(file.CreateElement("files")) as XmlElement; foreach (ListViewItem li in form.lv_files.Items) { conv_core.cImageFile fid = li.Tag as conv_core.cImageFile; XmlElement fd = files.AppendChild(file.CreateElement("file")) as XmlElement; fd.SetAttribute("file.path", fid.path); fd.SetAttribute("file.enabled", Convert.ToString(fid.enabled)); fd.SetAttribute("file.format", Convert.ToString(null != fid.options)); fd.SetAttribute("file.crc", Convert.ToString(fid.crc)); if (null != fid.options) { for (int op_id = 0; fid.options.desc.count > op_id; op_id++) { conv_core.cOptionDesc desc = fid.options.desc[op_id]; switch (desc.type) { case conv_core.OptionType.STRING: fd.SetAttribute("format." + desc.name, fid.options[desc.id].value_str); break; default: fd.SetAttribute("format." + desc.name, Convert.ToString(fid.options[desc.id].value)); break; } ; } ; } ; foreach (ColumnHeader hdr in form.m_formats) { ListViewItem.ListViewSubItem lsi = li.SubItems[hdr.Index]; conv_core.cImageFile img = lsi.Tag as conv_core.cImageFile; XmlElement conv = fd.AppendChild(file.CreateElement("convert")) as XmlElement; string conv_name = conv_core.workbench.relative_path(base_dir, img.path); while (('.' == conv_name[0]) || ('\\' == conv_name[0])) { conv_name = conv_name.Remove(0, 1); } ; conv.SetAttribute("format", hdr.Text); conv.SetAttribute("destination", conv_name); conv.SetAttribute("enabled", Convert.ToString(img.enabled)); if (null != img.options) { for (int op_id = 0; img.options.desc.count > op_id; op_id++) { conv_core.cOptionDesc desc = img.options.desc[op_id]; string op_name = desc.name; XmlElement opt = conv.AppendChild(file.CreateElement("property")) as XmlElement; opt.SetAttribute("name", op_name); switch (desc.type) { case conv_core.OptionType.STRING: opt.SetAttribute("value", img.options[op_name].value_str); break; default: opt.SetAttribute("value", Convert.ToString(img.options[op_name].value)); break; } ; } ; } ; } ; } ; file.Save(path); }catch (Exception) { return(false); }; return(true); }
public static bool load(string path, MainForm form) { try{ XmlDocument file = new XmlDocument(); file.Load(path); form.t_base_dir.Text = file["project"].Attributes["destination"].Value.ToLower(); if ('\\' == form.t_base_dir.Text.Last()) { form.t_base_dir.Text = form.t_base_dir.Text.Remove(form.t_base_dir.Text.Length - 1); } ; XmlElement formats = file["project"]["formats"]; XmlElement files = file["project"]["files"]; foreach (XmlElement fmt in formats.ChildNodes) { form.add_format(fmt.Attributes["name"].Value); } ; foreach (XmlElement fd in files.ChildNodes) { if (conv_core.workbench.valid_file(fd.Attributes["file.path"].Value)) { bool check_crc = fd.HasAttribute("file.crc"); ListViewItem li = form.lv_files.Items.Add(""); conv_core.cImageFile fid = new conv_core.cImageFile(fd.Attributes["file.path"].Value); li.ToolTipText = fid.path.ToLower(); li.Name = Path.GetFileNameWithoutExtension(li.ToolTipText).ToLower(); li.Text = Path.GetFileName(li.ToolTipText).ToLower(); li.Tag = fid; fid.enabled = Convert.ToBoolean(fd.Attributes["file.enabled"].Value); fid.crc = (check_crc)? Convert.ToUInt32(fd.Attributes["file.crc"].Value) : conv_core.workbench.file_crc(fid.path); li.ForeColor = (fid.enabled)? MainForm.cell_font_normal : MainForm.cell_font_disabled; li.UseItemStyleForSubItems = false; if ((null != fd.Attributes["file.format"]) && Convert.ToBoolean(fd.Attributes["file.format"].Value)) { //fid.options = } ; if (check_crc) { fid.new_crc = conv_core.workbench.file_crc(fid.path); if (fid.crc != fid.new_crc) { li.BackColor = MainForm.cell_back_modified; } ; } else { fid.new_crc = fid.crc; form.t_mod.Enabled = true; }; foreach (ColumnHeader hdr in form.m_formats) { XmlElement convert = null; foreach (XmlElement cvt in fd.ChildNodes) { if (hdr.Text == cvt.Attributes["format"].Value) { convert = cvt; break; } ; } ; conv_core.cFormat fmt = hdr.Tag as conv_core.cFormat; if (null == convert) { ListViewItem.ListViewSubItem lsi = li.SubItems.Add(li.Name + "." + fmt.ext); lsi.Tag = new conv_core.cImageFile(form.t_base_dir.Text + "\\" + lsi.Text); } else { string conv_name = convert.Attributes["destination"].Value; if ('\\' == conv_name[0]) { conv_name = conv_name.Remove(0, 1); } ; ListViewItem.ListViewSubItem lsi = li.SubItems.Add(conv_name); conv_core.cImageFile img = new conv_core.cImageFile(form.t_base_dir.Text + "\\" + lsi.Text); lsi.Tag = img; img.enabled = Convert.ToBoolean(convert.Attributes["enabled"].Value); lsi.ForeColor = Color.FromArgb((int)((img.enabled)? 0xFF000000 : 0xFF666666)); if (0 < convert.ChildNodes.Count) { img.options = fmt.writer_options_desc.create_options(); foreach (XmlElement prop in convert.ChildNodes) { if ("property" != prop.Name) { continue; } ; string op_name = prop.Attributes["name"].Value; if (null != img.options[op_name]) { conv_core.cOption opt = img.options[op_name]; switch (img.options.desc[op_name].type) { case conv_core.OptionType.STRING: opt.value_str = prop.Attributes["value"].Value; break; default: opt.value = Convert.ToInt32(prop.Attributes["value"].Value); break; } ; } ; } ; } ; }; } ; } ; } ; foreach (ColumnHeader hdr in form.m_formats) { hdr.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); } ; }catch (Exception) { return(false); }; return(true); }
public void set_imagelist(ListViewItem li) { conv_core.cImageFile src_img = li.Tag as conv_core.cImageFile; conv_core.cFormat src_fmt = conv_core.workbench.file_format(src_img.path); if (!src_img.open()) { return; } ; ToolStripButton img_btn = new ToolStripButton(src_fmt.name, null, null, src_fmt.name); ToolStripButton diff_btn = new ToolStripButton(src_fmt.name, null, null, src_fmt.name); diff_btn.Width = img_btn.Width = 23; diff_btn.Height = img_btn.Height = 22; diff_btn.DisplayStyle = img_btn.DisplayStyle = ToolStripItemDisplayStyle.Text; diff_btn.CheckOnClick = img_btn.CheckOnClick = true; img_btn.Click += views_handler; diff_btn.Click += diffs_handler; build_image(src_img, src_fmt, img_btn); diff_btn.Tag = img_btn.Tag; ts_views.Items.Add(img_btn); ts_diffs.Items.Add(diff_btn); for (int id = 1; li.SubItems.Count > id; id++) { conv_core.cImageFile img = li.SubItems[id].Tag as conv_core.cImageFile; conv_core.cFormat fmt = conv_core.workbench.file_format(img.path); img_btn = new ToolStripButton(fmt.name, null, null, fmt.name); diff_btn = new ToolStripButton(fmt.name, null, null, fmt.name); diff_btn.Width = img_btn.Width = 23; diff_btn.Height = img_btn.Height = 22; diff_btn.DisplayStyle = img_btn.DisplayStyle = ToolStripItemDisplayStyle.Text; diff_btn.CheckOnClick = img_btn.CheckOnClick = true; img_btn.Click += views_handler; diff_btn.Click += diffs_handler; if (!img.open()) { if (fmt.convert(src_img, img)) { img.open(); } else { break; }; } ; build_image(img, fmt, img_btn); diff_btn.Tag = img_btn.Tag; img.close(); ts_views.Items.Add(img_btn); ts_diffs.Items.Add(diff_btn); } ; m_view = new Bitmap(src_img.width, src_img.height, PixelFormat.Format32bppArgb); src_img.close(); Graphics gr = Graphics.FromImage(m_view); gr.Clear(Color.FromArgb(0x00FF, 0, 0, 0)); gr.Dispose(); img_view.Width = m_view.Width; img_view.Height = m_view.Height; m_current_diff = ts_diffs.Items[0].Tag as Bitmap; m_current_view = ts_views.Items[0].Tag as Bitmap; (ts_views.Items[0] as ToolStripButton).Checked = true; (ts_diffs.Items[0] as ToolStripButton).Checked = true; }