Click here to Skip to main content
15,896,557 members
Articles / Desktop Programming / Windows Forms

Controls Library: Extended ListView with Column Mapping

Rate me:
Please Sign up or sign in to vote.
4.86/5 (29 votes)
27 Mar 2014CPOL5 min read 83.2K   7.6K   110  
Docking windows container, extended listview, extended property editor.
using dwf.tool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Text;
using Gtk;

namespace dwf.gui
{
	public partial class LocalizeEditor : VBox, ILocalizable, IPicture
	{
		public LocalizeEditor ()
		{
			this.tools = new Toolbar ();
			this.toolImageLoad = new TagToolButton ();
			this.toolSave = new TagToolButton ();
			this.images = new dwf.gui.PList ();
			this.box = new HBox ();
			this.names = new dwf.gui.ListEditor ();
            
			this.tools.Add (this.toolSave);
			this.tools.Add (this.toolImageLoad);
			this.tools.ToolbarStyle = ToolbarStyle.BothHoriz;

			this.toolImageLoad.Name = "toolImages";
			this.toolImageLoad.Text = "Load Images";
			this.toolImageLoad.Clicked += this.ToolImageLoadClick;
            
			this.toolSave.Name = "toolSave";
			this.toolSave.Text = "Save";
			this.toolSave.Clicked += this.ToolSaveClick;
            
			this.images.AllowEditColumn = true;
			this.images.EditMode = dwf.tool.EditModes.None;
			this.images.EditState = dwf.tool.EditListState.Edit;
			this.images.GenerateColumns = false;
			this.images.GenerateToString = false;
			this.images.Grouping = false;
			this.images.Mode = dwf.tool.PListMode.List;
			this.images.Name = "images";
			this.images.ReadOnly = false;
            
			this.names.DataSource = null;
			this.names.Name = "listEditor1";
			this.names.ReadOnly = false;
            
			this.box.PackEnd (this.images, false, true, 5);
			this.box.PackEnd (this.names, true, true, 5);
            
			this.PackEnd (this.box);
			this.PackEnd (this.tools, false, false, 0);
			this.Name = "Localize Editor";
			this.ShowAll ();

			this.images.ListInfo.ColumnsVisible = false;
			this.images.ListInfo.HeaderVisible = false;
            
			PColumn column = images.ListInfo.Columns.Add ("ToString", 100);
            column.FillWidth = true;
			column.Height = 25;
            
			this.images.ListSource = Localize.Data.Images;
			this.names.DataSource = Localize.Data.Names;

			Localizing ();            
		}

		#region IPicture implementation
		public System.Drawing.Image Image {
			get {
				return Localize.GetImage ("LocalizeEditor", "Localize Editor");
			}
		}
		#endregion
		#region ILocalizable implementation
		public void Localizing ()
		{
			this.toolImageLoad.Text = Localize.Get ("LocalizeEditor", "Load Images");
			this.toolImageLoad.Image = GuiTool.GetImage (Localize.GetImageKey ("LocalizeEditor", "Load Images"));
			this.toolSave.Text = Localize.Get ("LocalizeEditor", "Save");
			this.toolSave.Image = GuiTool.GetImage (Localize.GetImageKey ("LocalizeEditor", "Save"));	
			this.Name = Localize.Get ("LocalizeEditor", "Localize Editor");	
			this.images.Localizing ();
			this.names.Localizing ();
		}
		#endregion

		private void ToolImageLoadClick (object sender, EventArgs e)
		{
			Gtk.FileChooserDialog ofd = new FileChooserDialog ("Select images", this.Toplevel as Window, FileChooserAction.Open, 
			                                                  "Cancel", ResponseType.Cancel, "Open", ResponseType.Accept);//new object[]{
			ofd.SelectMultiple = true;
			if (ofd.Run () == (int)ResponseType.Accept) {
				foreach (string name in ofd.Filenames) {
					LImage image = new LImage () { Data = File.ReadAllBytes(name), FileName = name };
					Localize.Data.Images.Add (image);
				}
				//ofd.Sh ();
			}
			ofd.Destroy();
		}

		private void ToolSaveClick (object sender, EventArgs e)
		{
			Localize.Save ();
		}

		private HBox box;
		private Toolbar tools;
		private TagToolButton toolImageLoad;
		private TagToolButton toolSave;
		private ListEditor names;
		private PList images;
        
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Kazakstan Kazakstan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions