using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using Photo_Album_Structure;
using SteepValley.Windows.Forms;
namespace Photo_Album
{
/// <summary>
/// Summary description for ViewPane.
/// </summary>
public class ViewPane : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Splitter Splitter;
private XPExplorerBar.XPTextBox xpTextBox1;
private System.Windows.Forms.Panel panel1;
private XPExplorerBar.TaskPane taskPane1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.TreeView DirectoryTreeView;
private SteepValley.Windows.Forms.XPListView PhotoItemListView;
private System.Windows.Forms.ImageList PhotoItemImageList;
private System.ComponentModel.IContainer components;
public ViewPane()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitializeComponent call
PhotoItemImageList.TransparentColor = Photo_Album_Structure.Settings.TransparentColor;
}
/// <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 Component 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.DirectoryTreeView = new System.Windows.Forms.TreeView();
this.Splitter = new System.Windows.Forms.Splitter();
this.PhotoItemListView = new SteepValley.Windows.Forms.XPListView(this.components);
this.xpTextBox1 = new XPExplorerBar.XPTextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.taskPane1 = new XPExplorerBar.TaskPane();
this.panel2 = new System.Windows.Forms.Panel();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.label4 = new System.Windows.Forms.Label();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.PhotoItemImageList = new System.Windows.Forms.ImageList(this.components);
((System.ComponentModel.ISupportInitialize)(this.taskPane1)).BeginInit();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// DirectoryTreeView
//
this.DirectoryTreeView.Dock = System.Windows.Forms.DockStyle.Left;
this.DirectoryTreeView.ImageIndex = -1;
this.DirectoryTreeView.Location = new System.Drawing.Point(0, 0);
this.DirectoryTreeView.Name = "DirectoryTreeView";
this.DirectoryTreeView.SelectedImageIndex = -1;
this.DirectoryTreeView.Size = new System.Drawing.Size(232, 488);
this.DirectoryTreeView.TabIndex = 1;
this.DirectoryTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.DirectoryTreeView_AfterSelect);
//
// Splitter
//
this.Splitter.Location = new System.Drawing.Point(232, 0);
this.Splitter.Name = "Splitter";
this.Splitter.Size = new System.Drawing.Size(3, 488);
this.Splitter.TabIndex = 2;
this.Splitter.TabStop = false;
//
// PhotoItemListView
//
this.PhotoItemListView.Dock = System.Windows.Forms.DockStyle.Bottom;
this.PhotoItemListView.LargeImageList = this.PhotoItemImageList;
this.PhotoItemListView.Location = new System.Drawing.Point(235, 376);
this.PhotoItemListView.Name = "PhotoItemListView";
this.PhotoItemListView.Size = new System.Drawing.Size(509, 112);
this.PhotoItemListView.TabIndex = 3;
this.PhotoItemListView.TileColumns = new int[] {
0,
1,
2};
this.PhotoItemListView.View = SteepValley.Windows.Forms.ExtendedView.LargeIcon;
//
// xpTextBox1
//
this.xpTextBox1.Font = new System.Drawing.Font("Tahoma", 8.25F);
this.xpTextBox1.Location = new System.Drawing.Point(16, 96);
this.xpTextBox1.Multiline = true;
this.xpTextBox1.Name = "xpTextBox1";
this.xpTextBox1.Size = new System.Drawing.Size(152, 88);
this.xpTextBox1.TabIndex = 1;
this.xpTextBox1.Text = "";
//
// panel1
//
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(235, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(509, 216);
this.panel1.TabIndex = 6;
//
// taskPane1
//
this.taskPane1.AutoScrollMargin = new System.Drawing.Size(12, 12);
this.taskPane1.CustomSettings.GradientEndColor = System.Drawing.Color.Empty;
this.taskPane1.CustomSettings.GradientStartColor = System.Drawing.Color.Empty;
this.taskPane1.Dock = System.Windows.Forms.DockStyle.Right;
this.taskPane1.Location = new System.Drawing.Point(744, 0);
this.taskPane1.Name = "taskPane1";
this.taskPane1.Size = new System.Drawing.Size(192, 488);
this.taskPane1.TabIndex = 4;
this.taskPane1.Text = "taskPane1";
//
// panel2
//
this.panel2.Controls.Add(this.linkLabel1);
this.panel2.Controls.Add(this.label4);
this.panel2.Controls.Add(this.textBox3);
this.panel2.Controls.Add(this.textBox2);
this.panel2.Controls.Add(this.button2);
this.panel2.Controls.Add(this.button1);
this.panel2.Controls.Add(this.label3);
this.panel2.Controls.Add(this.listBox1);
this.panel2.Controls.Add(this.label2);
this.panel2.Controls.Add(this.label1);
this.panel2.Controls.Add(this.textBox1);
this.panel2.Controls.Add(this.dateTimePicker1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel2.Location = new System.Drawing.Point(235, 216);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(509, 160);
this.panel2.TabIndex = 7;
//
// linkLabel1
//
this.linkLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.linkLabel1.AutoSize = true;
this.linkLabel1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.linkLabel1.Location = new System.Drawing.Point(424, 32);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(78, 16);
this.linkLabel1.TabIndex = 11;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "Edit \"Subjects\"";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(224, 32);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(97, 16);
this.label4.TabIndex = 10;
this.label4.Text = "People (Subjects):";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(232, 128);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(272, 20);
this.textBox3.TabIndex = 9;
this.textBox3.Text = "textBox3";
//
// textBox2
//
this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox2.Location = new System.Drawing.Point(232, 48);
this.textBox2.Multiline = true;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(272, 80);
this.textBox2.TabIndex = 8;
this.textBox2.Text = "Should be a people textbox";
//
// button2
//
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button2.Location = new System.Drawing.Point(9, 104);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(54, 18);
this.button2.TabIndex = 7;
this.button2.Text = "Remove";
//
// button1
//
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.button1.Location = new System.Drawing.Point(9, 80);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(54, 18);
this.button1.TabIndex = 6;
this.button1.Text = "Add";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 58);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(57, 16);
this.label3.TabIndex = 5;
this.label3.Text = "Keywords:";
//
// listBox1
//
this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.listBox1.Location = new System.Drawing.Point(64, 56);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(152, 95);
this.listBox1.TabIndex = 4;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 34);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(31, 16);
this.label2.TabIndex = 3;
this.label2.Text = "Date:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(29, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Title:";
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(64, 8);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(440, 20);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
//
// dateTimePicker1
//
this.dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss tt";
this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.Location = new System.Drawing.Point(64, 32);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(152, 20);
this.dateTimePicker1.TabIndex = 0;
//
// PhotoItemImageList
//
this.PhotoItemImageList.ImageSize = new System.Drawing.Size(16, 16);
this.PhotoItemImageList.TransparentColor = System.Drawing.Color.Transparent;
//
// ViewPane
//
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.PhotoItemListView);
this.Controls.Add(this.taskPane1);
this.Controls.Add(this.Splitter);
this.Controls.Add(this.DirectoryTreeView);
this.Name = "ViewPane";
this.Size = new System.Drawing.Size(936, 488);
((System.ComponentModel.ISupportInitialize)(this.taskPane1)).EndInit();
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Album RootAlbum;
private TreeNode RootTreeNode;
private Album SelectedAlbumInTreeView;
private PhotoItem SelectedPhotoItemInListView;
public void SetAlbum(Album album)
{
if(this.RootAlbum != null)
{
// unwire events
}
this.RootAlbum = album;
this.RootTreeNode = CreateTreeNodeFromPhotoItem(this.RootAlbum, true);
DirectoryTreeView.Nodes.Clear();
DirectoryTreeView.Nodes.Add(this.RootTreeNode);
this.RootTreeNode.Expand();
DirectoryTreeView.SelectedNode = this.RootTreeNode;
//wire up events
}
private void SetSelectedAlbumInTreeView(Album album)
{
if(this.SelectedAlbumInTreeView != null)
{
// un-wire events
}
this.SelectedAlbumInTreeView = album;
this.PhotoItemListView.Items.Clear();
this.PhotoItemListView.Items.AddRange(
CreateListViewItemsFromAlbum(album));
this.PhotoItemListView.RedrawItems();
if(album.AlbumType == AlbumType.Album)
{
PhotoItemImageList.Images.Clear();
PhotoItemListView.View = ExtendedView.Tile;
PhotoItemListView.SelectionStyle = SelectionStyles.Regular;
}
else
{
PhotoItemImageList.Images.Clear();
PhotoItemImageList.ImageSize =
new Size(Photo_Album_Structure.Settings.MaxThumbnailSize,
Photo_Album_Structure.Settings.MaxThumbnailSize);
PhotoItemListView.View = ExtendedView.LargeIcon;
PhotoItemListView.SelectionStyle = SelectionStyles.BorderSelect;
for(int i=0;i<album.Count;i++)
{
PhotoItemImageList.Images.Add(((Photo)album[i]).ThumbnailImage);
}
}
}
#region "TreeNode functions"
private TreeNode GetLinkedToTreeNode(PhotoItem pi)
{
ArrayList PhotoItemPos = new ArrayList();
PhotoItem t = pi;
while(t.Parent != null)
{
PhotoItemPos.Add(t.ChildIndex);
t = t.Parent;
}
TreeNode Node = this.RootTreeNode;
for(int i=PhotoItemPos.Count-1;i>=0;i--)
{
Node = Node.Nodes[(int)PhotoItemPos[i]];
}
return Node;
}
private PhotoItem GetPhotoItemFromTreeNode(TreeNode tn)
{
ArrayList TreeNodePos = new ArrayList();
//TreeNode tn = tn;
while(tn.Parent != null)
{
TreeNodePos.Add(tn.Index);
tn = tn.Parent;
}
PhotoItem pi = this.RootAlbum;
for(int i=TreeNodePos.Count-1;i>=0;i--)
{
pi = ((Album)pi)[(int)TreeNodePos[i]];
}
return pi;
}
private TreeNode CreateTreeNodeFromPhotoItem(
PhotoItem pi, bool onlyAlbums)
{
if(onlyAlbums && !(pi is Album))
return null;
TreeNode tn = new TreeNode();
tn.Text = pi.ToString();
if(pi is Album)
{
Album album = (Album) pi;
TreeNode tn2;
for(int i=0;i<album.Count;i++)
{
tn2 = CreateTreeNodeFromPhotoItem(album[i], onlyAlbums);
if(tn2 != null)
tn.Nodes.Add(tn2);
}
}
return tn;
}
#endregion
#region "ListItem functions"
/*private TreeNode GetLinkedToTreeNode(PhotoItem pi)
{
ArrayList PhotoItemPos = new ArrayList();
PhotoItem t = pi;
while(t.Parent != null)
{
PhotoItemPos.Add(t.ChildIndex);
t = t.Parent;
}
TreeNode Node = this.RootTreeNode;
for(int i=PhotoItemPos.Count-1;i>=0;i--)
{
Node = Node.Nodes[(int)PhotoItemPos[i]];
}
return Node;
}//*/
private PhotoItem GetPhotoItemFromListViewItem(ListViewItem lvi)
{
// ArrayList TreeNodePos = new ArrayList();
// //TreeNode tn = tn;
// while(tn.Parent != null)
// {
// TreeNodePos.Add(tn.Index);
// tn = tn.Parent;
// }
// PhotoItem pi = this.RootAlbum;
// for(int i=TreeNodePos.Count-1;i>=0;i--)
// {
// pi = ((Album)pi)[(int)TreeNodePos[i]];
// }
//
// return pi;
return null;
}
private XPListViewItem [] CreateListViewItemsFromAlbum(
Album album)
{
XPListViewItem [] lvis = new XPListViewItem[album.Count];
XPListViewItem lvi;
for(int i=0;i<album.Count;i++)
{
lvi = new XPListViewItem();
if(album.AlbumType == AlbumType.Photo)
{
lvi.Text = album[i].BeginDate.ToString();
lvi.ImageIndex = i;
}
else
{
lvi.Text = System.IO.Path.GetFileName(album[i].Path);
lvi.SubItems.Add(album[i].BeginDate.ToString()
+ " - " + album[i].EndDate.ToString());
lvi.ImageIndex = 0;
}
lvis[i] = lvi;
}
return lvis;
}
#endregion
private void DirectoryTreeView_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
SetSelectedAlbumInTreeView(
(Album)GetPhotoItemFromTreeNode(e.Node));
}
}
}