using
System; using
System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using Microsoft.VisualBasic;
namespace Picture_Show_VCSNet
{
///
<summary>
///
Summary description for Form1.
///
</summary>
public
class PictureForm :
System.Windows.Forms.Form
{
private
System.Windows.Forms.Panel panel2;
private
System.Windows.Forms.TabControl tabControl1;
private
System.Windows.Forms.TabPage tabPage1;
private
System.Windows.Forms.ComboBox CmbFolder;
private
System.Windows.Forms.ToolBar ToolBar1;
private
System.Windows.Forms.ToolBarButton toolBarButton7;
private
System.Windows.Forms.ToolBarButton toolBarButton8;
private
System.Windows.Forms.ToolBarButton toolBarButton9;
private
System.Windows.Forms.Panel panel1;
private
System.Windows.Forms.TreeView treeView1;
private
System.Windows.Forms.ListBox listArray;
private
System.Windows.Forms.ImageList imageList1;
private
System.Windows.Forms.Panel panel1_P1;
private
System.Windows.Forms.Panel panel1_P11;
private
System.Windows.Forms.Label lfolder;
private
System.Windows.Forms.ImageList imageList2;
private
Microsoft.VisualBasic.Compatibility.VB6.DirListBox dir1;
private
Microsoft.VisualBasic.Compatibility.VB6.DirListBox dir2;
private
Microsoft.VisualBasic.Compatibility.VB6.FileListBox file1;
private
System.Windows.Forms.ImageList imageList3;
private
System.Windows.Forms.Panel panel_Tab;
private
System.Windows.Forms.Panel panel_TabP3;
private
System.Windows.Forms.Panel panel_PictueBox_1;
private
System.Windows.Forms.VScrollBar VScrollBar_1;
private
System.Windows.Forms.HScrollBar HScrollBar_1;
private
System.Windows.Forms.PictureBox PictureBox_1;
private
System.Windows.Forms.Panel panel_TabP2;
private
System.Windows.Forms.ToolBar toolBar_zoom;
private
System.Windows.Forms.ToolBar toolBar_navigation;
private
System.Windows.Forms.ToolBarButton toolBarButton1;
private
System.Windows.Forms.ToolBarButton toolBarButton2;
private
System.Windows.Forms.ToolBarButton toolBarButton3;
private
System.Windows.Forms.ToolBarButton toolBarButton4;
private
System.Windows.Forms.ToolBarButton toolBarButton5;
private
System.Windows.Forms.ToolBarButton toolBarButton6;
private
System.Windows.Forms.Panel panel_TabP1;
private
System.Windows.Forms.HScrollBar HScrollBar_panel_Tab1;
private
System.Windows.Forms.Panel VPanel3;
private
System.Windows.Forms.Label lbvpic3;
private
System.Windows.Forms.PictureBox vPic3;
private
System.Windows.Forms.Panel VPanel2;
private
System.Windows.Forms.Label lbvpic2;
private
System.Windows.Forms.PictureBox vPic2;
private
System.Windows.Forms.Panel VPanel1;
private
System.Windows.Forms.Label lbvpic1;
private
System.Windows.Forms.PictureBox vPic1;
private
System.Windows.Forms.Panel VPanel0;
private
System.Windows.Forms.PictureBox vPic0;
private
System.Windows.Forms.Label lbvpic0;
private
System.Windows.Forms.PictureBox pictureBox_P1;
private
System.Windows.Forms.ToolTip toolTip1;
private
System.Windows.Forms.ListView listView1;
private
System.Windows.Forms.Panel panel_TabP4;
private
System.Windows.Forms.ImageList imageList4;
private
System.Windows.Forms.ToolBarButton toolBarButton10;
private
System.Windows.Forms.ToolBarButton toolBarButton11;
private
System.ComponentModel.IContainer components;
// Variables
int Varzoom = 2;
int VVorder=0;
int
VPicture_width=0;
bool
combo_permission=false;
//static extern
public
static
string
currentfolder;
public
static
string
currentPicture;
public
const
string
PictureShow = "no_Picture_Show_C.bmp";
public
PictureForm()...
protected void
Dispose(boolean disposing)
...
Windows Form Designer generated
code |
static
void
Main()
{
Application.Run( new
PictureForm());
}
private
void
PictureForm_Load(object
sender, System.EventArgs e)
{
int
Me_Width;
// Resize
Me_Width = ((this.Width
/ 10) * 10);
VPicture_width = (Me_Width * 14 / 100);
// Panel controls
this.panel1.Top =
5;
this.panel1.Left
= 5;
this.panel1.Height
= this.Height - (5 +
60);
this.panel2.Top =
this.panel1.Top;
this.panel2.Height
= this.ToolBar1.Height;
// Tabcontrol control
this.tabControl1.Top
= this.panel2.Top +
this.panel2.Height +
5;
this.tabControl1.Height
= this.panel1.Height
- (this.panel2.Height
+ 5);
this.tabControl1.Width
= 4 * VPicture_width + 15;
this.panel1.Width
= Me_Width - (15 + this.tabControl1.Width);
this.panel2.Left
= this.panel1.Left +
this.panel1.Width +
5;
this.panel2.Width
= this.tabControl1.Width;
this.tabControl1.Left
= this.panel2.Left;
// Label control
this.lfolder.Top=5;
this.lfolder.Left=5;
// Panel control
this.panel1_P1.Width
= this.panel1.Width;
this.panel1_P1.Height
= this.panel1.Width;
this.panel1_P1.Left=0;
this.panel1_P1.Top
= this.panel1.Height-this.panel1_P1.Height;
// ToolBar control
this.ToolBar1.Left
= this.panel2.Width
- (this.ToolBar1.Width
+ 15);
this.ToolBar1.Top
= (this.panel2.Height
- this.ToolBar1.Height)
/ 2;
// ComboBox control
this.CmbFolder.Left
= 15;
this.CmbFolder.Top
= (this.panel2.Height
- this.CmbFolder.Height)
/ 2;
// Panel controls
this.panel_Tab.Height=this.tabPage1.Height;
this.panel_Tab.Width=this.tabPage1.Width;
this.panel_Tab.Top=0;
this.panel_Tab.Left=0;
this.panel_TabP1.Height
= VPicture_width + this.lbvpic0.Height
+ 5 + this.HScrollBar_panel_Tab1.Height
;
this.panel_TabP1.Width
= this.tabPage1.Width
;
this.panel_TabP1.Left
= 0;
this.panel_TabP1.Top
= 0;
// ScrollBar controls
this.HScrollBar_panel_Tab1.Width=this.panel_TabP1.Width;
this.HScrollBar_panel_Tab1.Left=0;
this.HScrollBar_panel_Tab1.Top=(this.panel_TabP1.Height-this.HScrollBar_panel_Tab1.Height);
// Panel controls
this.panel_TabP2.Height
= this.toolBar_navigation.Height
;
this.panel_TabP2.Width
= this.tabPage1.Width
;
this.panel_TabP2.Left
= 0;
this.panel_TabP2.Top
= this.panel_TabP1.Top+this.panel_TabP1.Height+2;
this.toolBar_navigation.Left=
35;
this.toolBar_navigation.Top=0;
this.toolBar_zoom.Left=this.panel_TabP2.Width-(this.toolBar_zoom.Width+35);
this.toolBar_zoom.Top=0;
this.panel_TabP3.Height
= this.tabPage1.Height
-(this.panel_TabP2.Top+this.panel_TabP2.Height
+ this.listView1.Height
+ 5);
this.panel_TabP3.Width
= this.tabPage1.Width
;
this.panel_TabP3.Left
= 0;
this.panel_TabP3.Top
= this.panel_TabP3.Top
+ this.panel_TabP3.Height;
// Panel control
this.panel_PictueBox_1.Height
= this.panel_TabP3.Height;
this.panel_PictueBox_1.Width
= this.panel_TabP3.Width;
this.panel_PictueBox_1.Top
= 0;
this.panel_PictueBox_1.Left
= 0;
// Panel control
this.panel_TabP4.Height
= this.listView1.Height
+ 5;
this.panel_TabP4.Width
= this.tabPage1.Width
;
this.panel_TabP4.Left
= 0;
this.panel_TabP4.Top
= this.panel_TabP3.Top
+ this.panel_TabP3.Height;
// Listview control
this.listView1.Width=
this.panel_TabP4.Width;
this.listView1.Left=0;
this.listView1.Top=5;
// TreeView control
this.treeView1.Left
= 0;
this.treeView1.Top
= lfolder.Top + lfolder.Height + 5;
this.treeView1.Width
= this.panel1.Width;
this.treeView1.Height
= this.panel1.Height
- (this.panel1_P1.Height
+this.treeView1.Top
+ 7);
// Load initial data
LoadData();
}
// Initial data, Load &
display
private
void LoadData()
{
int j;
int k;
TreeNode rootNode;
TreeNode childNode;
TreeNode childNode1;
bool FirstFlag =
true;
string[]drives =
Directory.GetLogicalDrives();
string
First_drive = "";
// Clear TreeView
this.treeView1.Nodes.Clear();
// display all Logical
drives & directories corresponding ...
foreach(string
drive in drives)
{
// Drive is ready
if (Directory.Exists(drive))
{
// Root nodes, Name of
drives & Picture
rootNode = new
TreeNode(drive.Substring(0,2),0,0);
rootNode.Tag = drive;
this.treeView1.Nodes.Add(rootNode);
// Add 1st child Nodes ,
subdirectories corresponding ...
this.dir1.Path =
drive;
if (this.dir1.DirListCount
> 0)
{
for (j = 0; j <=
this.dir1.DirListCount
- 1; j++)
{
childNode = new
TreeNode(Path.GetFileName(this.dir1.get_DirList(j)),1,2);
childNode.Tag = this.dir1.get_DirList(j);
rootNode.Nodes.Add(childNode);
// 1st item of root
nodes, value & expand
if (FirstFlag)
{
rootNode.Expand();
First_drive = drive.ToString();
FirstFlag=false;
}
// Add 2nd child Nodes,
, subdirectories corresponding ...
this.dir2.Path =
this.dir1.get_DirList(j);
if (this.dir2.DirListCount
> 0)
{
for (k = 0; k <=
this.dir2.DirListCount
- 1; k++)
{
childNode1 = new
TreeNode(Path.GetFileName(this.dir2.get_DirList(k)),1,2);
childNode1.Tag = this.dir2.get_DirList(k);
childNode.Nodes.Add(childNode1);
}
}
}
}
}
}
// Current Folder =
value of 1st item of root nodes
currentfolder = First_drive;
// Load & display the
JPG,GIF and BMP Picture Files ...
View_Sub();
}
// Load & display the
JPG,GIF and BMP Picture Files ...
private
void View_Sub()
{
// Number of pictures in
the list
const
int NewLargeChange=
4;
// ListBox control,
store All Picture File names corresponding ...
treeViewSelected();
// Display Pictures
corresponding ...
if (this.listArray.Items.Count
> 0)
{
// resize ...
// Values of
'panel_TabP1.Top, panel_TabP2.Top & panel_TabP3.Top
panel_TabP_Top_Sub();
this.panel_TabP1.Visible
= true;
this.panel_TabP3.Visible
= true;
this.panel_TabP4.Visible
= true;
VVorder = 0;
// ListBox control,
items include > 5
if (this.listArray.Items.Count
> 5)
{
// Diplay list of
pictures
for (int
k =0; k<= 3; k++)
ViewList(k, VVorder);
// HScrollBar control,
List of values corresponding
this.HScrollBar_panel_Tab1.Maximum
= ((this.listArray.Items.Count
- 1) / 4) + this.HScrollBar_panel_Tab1.LargeChange
- 1;
this.HScrollBar_panel_Tab1.Maximum
= this.HScrollBar_panel_Tab1.Maximum
+ NewLargeChange - this.HScrollBar_panel_Tab1.LargeChange;
this.HScrollBar_panel_Tab1.LargeChange
= NewLargeChange;
this.HScrollBar_panel_Tab1.SmallChange
= NewLargeChange;
this.HScrollBar_panel_Tab1.Value
= 0;
// Toolbar control
this.toolBarButton6.ImageIndex
= 2;
}
// ListBox control,
items include < 5
else
{
// Display Pictures
for (int
k =0; k<= this.listArray.Items.Count-1;
k++)
ViewList(k, VVorder);
// Hide other panels
empty
for (int
k =this.listArray.Items.Count;
k<= 3; k++)
vPanel_visible(k, false);
// HScrollBar control,
List of values corresponding
this.HScrollBar_panel_Tab1.Maximum
= 0;
this.HScrollBar_panel_Tab1.LargeChange
= 1;
this.HScrollBar_panel_Tab1.SmallChange
= 1;
this.toolBarButton6.ImageIndex
= 3;
}
// 1st item of pictures
List
TabPage_Select_Picture(0);
// 1st item to Focus, no
select
this.lbvpic0.BackColor
= System.Drawing.Color.Gray;
// Toolbar ...
this.toolBarButton3.ImageIndex
= 6;
}
// ListBox control is
empty, (no pictures include)
else
{
//if (this.listArray.Items.Count
== 0)
NoPicture_TabPage1();
}
}
// ListBox control,
store All Picture Files corresponding ...
private
void
treeViewSelected()
{
bool VarFlag =
false;
int
VarSelectedIndex = 0;
// Flag Permission for
use combobox - CmbFolder
combo_permission=false;
// ListBox control,
clear
this.listArray.Items.Clear();
this.file1.Path =
currentfolder;
if (this.file1.Items.Count>0)
{
// Add only File type :
jpg, gif and bmp
for (int
k =0; k< this.file1.Items.Count;
k++)
{
if
((Path.GetExtension(this.file1.get_Items(k))==
".jpg") || (Path.GetExtension(this.file1.get_Items(k))
== ".gif") || (Path.GetExtension(this.file1.get_Items(k))
== ".bmp"))
this.listArray.Items.Add(this.file1.get_Items(k));
}
// Add item to CmbFolder
available
if (this.listArray.Items.Count>
0)
{
if (this.CmbFolder.Items.Count
== 0)
{
// Add new Folder name
to CmbFolder
this.CmbFolder.Items.Add(currentfolder);
// Value of index
selected of CmbFolder
VarSelectedIndex = this.CmbFolder.Items.Count
- 1;
}
else
{
if (this.CmbFolder.Items.Count
> 0)
{
// Test if this Folder
name include in CmbFolder
for (int
k =0; k<= this.CmbFolder.Items.Count
- 1; k++)
{
this.CmbFolder.SelectedIndex
= k;
if (this.CmbFolder.SelectedItem.ToString()
== currentfolder)
{
// Item exist (Value of
index selected of CmbFolder)
VarSelectedIndex= k;
VarFlag = true;
goto Pt;
}
else
// New Item
VarFlag = false;
}
// Add new Folder name
to CmbFolder
if (VarFlag ==
false)
{
this.CmbFolder.Items.Add(currentfolder);
// Value of index
selected of CmbFolder
VarSelectedIndex=this.CmbFolder.Items.Count
- 1;
}
}
}
}
else
{
// No item to be added
to CmbFolder(Value of index selected of CmbFolder)
VarSelectedIndex = -1;
}
}
else
{
// No item to be added
to CmbFolder(Value of index selected of CmbFolder)
VarSelectedIndex = -1;
}
Pt:
// index Selected of
CmbFolder
this.CmbFolder.SelectedIndex
= VarSelectedIndex;
combo_permission=true;
}
// Values of
'panel_TabP1.Top, panel_TabP2.Top & panel_TabP3.Top
private
void
panel_TabP_Top_Sub()
{
this.panel_TabP1.Top
= 0;
this.panel_TabP2.Top
= this.panel_TabP1.Top
+ this.panel_TabP1.Height+2;
this.panel_TabP3.Top
= this.panel_TabP2.Top
+ this.panel_TabP2.Height;
this.panel_TabP4.Top
= this.panel_TabP3.Top
+ this.panel_TabP3.Height;
}
// List of Pictures,
resize Panel controls & Display ...
private
void ViewList(int
indexx, int Vorder1)
{
switch(indexx)
{
case 0:
VPanel0.Width = VPicture_width;
VPanel0.Height = VPicture_width + lbvpic0.Height;
vPic0.Left = 0;
vPic0.Top = 0;
vPic0.Height = VPicture_width;
vPic0.Width = VPicture_width;
lbvpic0.Left = 0;
lbvpic0.Top = VPicture_width;
lbvpic0.Width = VPicture_width;
VPanel0.Top = 5;
VPanel0.Left = 0;
break;
case 1:
VPanel1.Width = VPicture_width;
VPanel1.Height = VPicture_width + lbvpic0.Height;
vPic1.Left = 0;
vPic1.Top = 0;
vPic1.Height = VPicture_width;
vPic1.Width = VPicture_width;
lbvpic1.Left = 0;
lbvpic1.Top = VPicture_width;
lbvpic1.Width = VPicture_width;
VPanel1.Top = 5;
VPanel1.Left = VPanel0.Left + VPicture_width + 5;
break;
case 2:
VPanel2.Width = VPicture_width;
VPanel2.Height = VPicture_width + lbvpic0.Height;
vPic2.Left = 0;
vPic2.Top = 0;
vPic2.Height = VPicture_width;
vPic2.Width = VPicture_width;
lbvpic2.Left = 0;
lbvpic2.Top = VPicture_width;
lbvpic2.Width = VPicture_width;
VPanel2.Top = 5;
VPanel2.Left = VPanel1.Left + VPicture_width + 5;
break;
case 3:
VPanel3.Width = VPicture_width;
VPanel3.Height = VPicture_width + lbvpic0.Height;
vPic3.Left = 0;
vPic3.Top = 0;
vPic3.Height = VPicture_width;
vPic3.Width = VPicture_width;
lbvpic3.Left = 0;
lbvpic3.Top = VPicture_width;
lbvpic3.Width = VPicture_width;
VPanel3.Top = 5;
VPanel3.Left = VPanel2.Left + VPicture_width + 5;
break;
}
// Display the list of
pictures
this.listArray.SelectedIndex
= Vorder1 * 4 + indexx;
Display_Picture2(indexx,
this.listArray.SelectedItem.ToString());
}
private
void vPanel_visible(int
position, bool bval)
{
switch(position)
{
case 0:
this.VPanel0.Visible
= bval;
break;
case 1:
this.VPanel1.Visible
= bval;
break;
case 2:
this.VPanel2.Visible
= bval;
break;
case 3:
this.VPanel3.Visible
= bval;
break;
}
}
// Load the Picture
correspondig (with zoom)
private
void
DisplayPicture_View(string
FileName)
{
// Panel control
this.panel1_P11.Height
= this.panel1_P1.Width
* Varzoom / 5;
this.panel1_P11.Width
= this.panel1_P1.Width
* Varzoom / 5;
this.panel1_P11.Left
= (this.panel1_P1.Width
- this.panel1_P11.Width)
/ 2;
this.panel1_P11.Top
= (this.panel1_P1.Height
- this.panel1_P11.Height)
/ 2;
// Load pictureBox
this.pictureBox_P1.Image
= System.Drawing.Image.FromFile(currentfolder +
Path.DirectorySeparatorChar.ToString() + FileName);
if (this.pictureBox_P1.Image.Height
> this.pictureBox_P1.Image.Width)
{
this.pictureBox_P1.Height
= this.panel1_P11.Height;
this.pictureBox_P1.Width
= (this.panel1_P11.Width
* this.pictureBox_P1.Image.Width
/ this.pictureBox_P1.Image.Height);
}
else
{
if (this.pictureBox_P1.Image.Width
> this.pictureBox_P1.Image.Height)
{
this.pictureBox_P1.Height
= (this.panel1_P11.Height
* this.pictureBox_P1.Image.Height
/ this.pictureBox_P1.Image.Width);
this.pictureBox_P1.Width
= this.panel1_P11.Width;
}
else
{
if (this.pictureBox_P1.Image.Width
== this.pictureBox_P1.Image.Height)
{
this.pictureBox_P1.Height
= this.panel1_P11.Height;
this.pictureBox_P1.Width
= this.panel1_P11.Width;
}
}
}
this.pictureBox_P1.Left
= (this.panel1_P11.Width
- this.pictureBox_P1.Width)
/ 2;
this.pictureBox_P1.Top
= (this.panel1_P11.Height
- this.pictureBox_P1.Height)
/ 2;
// ToolBar control
if (Varzoom <= 2)
{
if (this.toolBarButton1.ImageIndex
== 4)
this.toolBarButton1.ImageIndex
= 5;
if (this.toolBarButton3.ImageIndex
== 7)
this.toolBarButton3.ImageIndex
= 6;
}
else
{
if ((Varzoom > 2)
|| (Varzoom < 5))
{
if (this.toolBarButton1.ImageIndex
== 5)
this.toolBarButton1.ImageIndex
= 4;
if (this.toolBarButton3.ImageIndex
== 7)
this.toolBarButton3.ImageIndex
= 6;
}
}
}
// display picture
with Scroll Bars
private
void Picture_scroll(string
FileName)
{
int
NewLargeChange =0;
// PictureBox control,
Size Mode
this.PictureBox_1.Image
= System.Drawing.Image.FromFile(currentfolder +
Path.DirectorySeparatorChar.ToString() + FileName);
// Check to see if
scroll bars are needed.
this.VScrollBar_1.Visible
= this.panel_PictueBox_1.Height
< this.PictureBox_1.Height;
this.HScrollBar_1.Visible
= this.panel_PictueBox_1.Width
< this.PictureBox_1.Width;
// Poaitions
if (this.PictureBox_1.Image.Height
<= this.panel_PictueBox_1.Height)
this.PictureBox_1.Top
= (this.panel_PictueBox_1.Height
- this.PictureBox_1.Image.Height)
/ 2;
else
this.PictureBox_1.Top
= 0;
if (this.PictureBox_1.Image.Width
<= this.panel_PictueBox_1.Width)
this.PictureBox_1.Left
= (this.panel_PictueBox_1.Width
- this.PictureBox_1.Image.Width)
/ 2;
else
this.PictureBox_1.Left
= 0;
// HScrollBar coordinate
if (this.HScrollBar_1.Visible)
{
this.HScrollBar_1.Top
= this.panel_PictueBox_1.Height
- this.HScrollBar_1.Height;
this.HScrollBar_1.Left
= 0;
this.HScrollBar_1.Width
= this.panel_PictueBox_1.Width;
}
// VScrollBar coordinate
if (this.VScrollBar_1.Visible)
{
this.VScrollBar_1.Top
= 0;
this.VScrollBar_1.Left
= this.panel_PictueBox_1.Width
- this.VScrollBar_1.Width;
this.VScrollBar_1.Height
= this.panel_PictueBox_1.Height
- this.HScrollBar_1.Height;
}
// image Is large,
Height
if (this.PictureBox_1.Image.Height
> this.panel_PictueBox_1.Height)
{
NewLargeChange = (this.PictureBox_1.Image.Height
/ this.panel_PictueBox_1.Height)
* 10;
this.VScrollBar_1.LargeChange
= NewLargeChange;
this.VScrollBar_1.SmallChange
= VScrollBar_1.LargeChange;
this.VScrollBar_1.Maximum
= System.Math.Abs(PictureBox_1.Height -
this.panel_PictueBox_1.Height);
}
// image Is large, Width
if (this.PictureBox_1.Image.Width
> this.panel_PictueBox_1.Width)
{
NewLargeChange = (this.PictureBox_1.Image.Width
/ this.panel_PictueBox_1.Width)
* 10;
this.HScrollBar_1.LargeChange
= NewLargeChange;
this.HScrollBar_1.SmallChange
= this.HScrollBar_1.LargeChange;
this.HScrollBar_1.Maximum
= System.Math.Abs(this.PictureBox_1.Width
- this.panel_PictueBox_1.Width);
}
}
// VScrollBar control
private
void
VScrollBar_1_Scroll(object
sender, System.Windows.Forms.ScrollEventArgs e)
{
VScroll_1_Change(e.NewValue);
}
private
void
VScroll_1_Change(int
newScrollValue)
{
this.PictureBox_1.Top
= -newScrollValue;
}
// HScrollBar control
private
void
HScrollBar_1_Scroll(object
sender, System.Windows.Forms.ScrollEventArgs e)
{
HScroll_1_Change(e.NewValue);
}
private
void
HScroll_1_Change(int
newScrollValue )
{
this.PictureBox_1.Left
= -newScrollValue;
}
// No picture to be
display
private
void
NoPicture_TabPage1()
{
// Listarray is empty
if (this.listArray.Items.Count
> 0)
this.listArray.Items.Clear();
this.panel_TabP1.Visible
= false;
this.panel_TabP3.Visible
= false;
this.panel_TabP4.Visible
= false;
this.panel_Tab.BackColor
= System.Drawing.Color.Gray;
this.panel_TabP2.Visible
= true;
this.panel_TabP2.Top
= 0;
currentfolder =
Path.GetDirectoryName(Directory.GetCurrentDirectory());
currentPicture = PictureShow;
DisplayPicture_View(currentPicture);
if (this.toolBarButton4.ImageIndex
== 0)
this.toolBarButton4.ImageIndex
= 1;
if (this.toolBarButton6.ImageIndex
== 2)
this.toolBarButton6.ImageIndex
= 3;
}
//Load the Picture
correspondig to the Record item and Tooltip corresponding
...
private
void
Display_Picture2(int
Index, string
PictureName)
{
if ((Index <= (this.listArray.Items.Count
- 1)) && (PictureName.Length > 0))
{
vPanel_visible(Index,
true);
vpic_sub(Index, PictureName);
ToolTip_sub2(Index);
}
else
vPanel_visible(Index,
false);
}
private
void vpic_sub(int
indexx, string
PictureNamex)
{
switch(indexx)
{
case 0:
this.vPic0.Image
= System.Drawing.Image.FromFile(currentfolder +
Path.DirectorySeparatorChar.ToString() + PictureNamex);
if (this.vPic0.Image.Height
> this.vPic0.Image.Width)
{
this.vPic0.Height
= this.VPanel0.Height
- this.lbvpic0.Height;
this.vPic0.Width
= this.VPanel0.Width
* this.vPic0.Image.Width
/ this.vPic0.Image.Height;
}
else
{
if (this.vPic0.Image.Width
> this.vPic0.Image.Height)
{
this.vPic0.Height
= (this.VPanel0.Height
- this.lbvpic0.Height)
* this.vPic0.Image.Height
/ this.vPic0.Image.Width;
this.vPic0.Width
= this.VPanel0.Width;
}
else
{
if (this.vPic0.Image.Width
== this.vPic0.Image.Height)
{
this.vPic0.Height
= (this.VPanel0.Height
- this.lbvpic0.Height);
this.vPic0.Width
= this.VPanel0.Width;
}
}
}
this.vPic0.Top =
((this.VPanel0.Height
- this.lbvpic0.Height)
- this.vPic0.Height)
/ 2;
this.vPic0.Left =
(this.VPanel0.Width
- this.vPic0.Width)
/ 2;
this.lbvpic0.Text
= PictureNamex;
break;
case 1:
this.vPic1.Image
= System.Drawing.Image.FromFile(currentfolder +
Path.DirectorySeparatorChar.ToString() + PictureNamex);
if (this.vPic1.Image.Height
> this.vPic1.Image.Width)
{
this.vPic1.Height
= this.VPanel1.Height
- this.lbvpic1.Height;
this.vPic1.Width
= this.VPanel1.Width
* this.vPic1.Image.Width
/ this.vPic1.Image.Height;
}
else
{
if (this.vPic1.Image.Width
> this.vPic1.Image.Height)
{
this.vPic1.Height
= (this.VPanel1.Height
- this.lbvpic1.Height)
* this.vPic1.Image.Height
/ this.vPic1.Image.Width;
this.vPic1.Width
= this.VPanel1.Width;
}
else
{
if (this.vPic1.Image.Width
== this.vPic1.Image.Height)
{
this.vPic1.Height
= (this.VPanel1.Height
- this.lbvpic1.Height);
this.vPic1.Width
= this.VPanel1.Width;
}
}
}
this.vPic1.Top =
((this.VPanel1.Height
- this.lbvpic1.Height)
- this.vPic1.Height)
/ 2;
this.vPic1.Left =
(this.VPanel1.Width
- this.vPic1.Width)
/ 2;
this.lbvpic1.Text
= PictureNamex;
break;
case 2:
this.vPic2.Image
= System.Drawing.Image.FromFile(currentfolder +
Path.DirectorySeparatorChar.ToString() + PictureNamex);
if (this.vPic2.Image.Height
> this.vPic2.Image.Width)
{
this.vPic2.Height
= this.VPanel2.Height
- this.lbvpic2.Height;
this.vPic2.Width
= this.VPanel2.Width
* this.vPic2.Image.Width
/ this.vPic2.Image.Height;
}
else
{
if (this.vPic2.Image.Width
> this.vPic2.Image.Height)
{
this.vPic2.Height
= (this.VPanel2.Height
- this.lbvpic2.Height)
* this.vPic2.Image.Height
/ this.vPic2.Image.Width;
this.vPic2.Width
= this.VPanel2.Width;
}
else
{
if (this.vPic2.Image.Width
== this.vPic2.Image.Height)
{
this.vPic2.Height
= (this.VPanel2.Height
- this.lbvpic2.Height);
this.vPic2.Width
= this.VPanel2.Width;
}
}
}
this.vPic2.Top =
((this.VPanel2.Height
- this.lbvpic2.Height)
- this.vPic2.Height)
/ 2;
this.vPic2.Left =
(this.VPanel2.Width
- this.vPic2.Width)
/ 2;
this.lbvpic2.Text
= PictureNamex;
break;
case 3:
this.vPic3.Image
= System.Drawing.Image.FromFile(currentfolder +
Path.DirectorySeparatorChar.ToString() + PictureNamex);
if (this.vPic3.Image.Height
> this.vPic3.Image.Width)
{
this.vPic3.Height
= this.VPanel3.Height
- this.lbvpic3.Height;
this.vPic3.Width
= this.VPanel3.Width
* this.vPic3.Image.Width
/ this.vPic3.Image.Height;
}
else
{
if (this.vPic3.Image.Width
> this.vPic3.Image.Height)
{
this.vPic3.Height
= (this.VPanel3.Height
- this.lbvpic3.Height)
* this.vPic3.Image.Height
/ this.vPic3.Image.Width;
this.vPic3.Width
= this.VPanel3.Width;
}
else
{
if (this.vPic3.Image.Width
== this.vPic3.Image.Height)
{
this.vPic3.Height
= (this.VPanel3.Height
- this.lbvpic3.Height);
this.vPic3.Width
= this.VPanel3.Width;
}
}
}
this.vPic3.Top =
((this.VPanel3.Height
- this.lbvpic3.Height)
- this.vPic3.Height)
/ 2;
this.vPic3.Left =
(this.VPanel3.Width
- this.vPic3.Width)
/ 2;
this.lbvpic3.Text
= PictureNamex;
break;
}
}
private
void ToolTip_sub2(int
indexx)
{
switch(indexx)
{
case 0:
this.toolTip1.SetToolTip(this.lbvpic0,
this.vPic0.Height.ToString()
+ " x " + this.vPic0.Width.ToString()
+ " - Twip");
break;
case 1:
this.toolTip1.SetToolTip(this.lbvpic1,
this.vPic1.Height.ToString()
+ " x " + this.vPic1.Width.ToString()
+ " - Twip");
break;
case 2:
this.toolTip1.SetToolTip(this.lbvpic2,
this.vPic2.Height.ToString()
+ " x " + this.vPic2.Width.ToString()
+ " - Twip");
break;
case 3:
this.toolTip1.SetToolTip(this.lbvpic3,
this.vPic3.Height.ToString()
+ " x " + this.vPic3.Width.ToString()
+ " - Twip");
break;
}
}
// TreeView control,
Select
private
void
treeView1_AfterSelect(object
sender, System.Windows.Forms.TreeViewEventArgs e)
{
TreeNode childNode;
switch(e.Node.ImageIndex)
{
case 0:
e.Node.Expand();
currentfolder= e.Node.Tag.ToString();
View_Sub();
break;
case 1:
if (e.Node.IsSelected)
e.Node.Collapse();
this.dir2.Path =
e.Node.Tag.ToString();
if (this.dir2.DirListCount
> 0)
{
for (int
k = 0; k<= this.dir2.DirListCount
- 1; k++)
{
//''''''''''''''''''
TreeView '''''''''
// First selection
if (e.Node.GetNodeCount(true)
== 0)
{
// Add a Sub Nodes
this.dir1.Path =
e.Node.Tag.ToString();
if (this.dir1.DirListCount
> 0)
{
for (int
j = 0; j<= this.dir1.DirListCount
- 1; j++)
{
childNode = new
TreeNode(Path.GetFileName(this.dir1.get_DirList(j)),1,2);
childNode.Tag = this.dir1.get_DirList(j);
e.Node.Nodes.Add(childNode);
}
}
}
e.Node.Expand();
}
}
currentfolder = e.Node.Tag.ToString();
View_Sub();
break;
}
}
// Show About.cs,
Show.cs and unload application
private
void
ToolBar1_ButtonClick(object
sender, System.Windows.Forms.ToolBarButtonClickEventArgs
e)
{
if (e.Button.ImageIndex
== 1)
{
About Fabout = new
About();
Fabout.Show();
}
else
{
if (e.Button.ImageIndex
== 4)
{
ShowForm Fshow = new
ShowForm();
Fshow.Show();
}
else
{
if (e.Button.ImageIndex
== 2)
{
Application.Exit();
}
}
}
}
// Navigation
operation using Toolbar
private
void
toolBar_navigation_ButtonClick(object
sender, System.Windows.Forms.ToolBarButtonClickEventArgs
e)
{
if (e.Button.ImageIndex
== 0)
{
VVorder = VVorder - 1;
// Pictures Show
for (int
i = 0; i<= 3; i++)
ViewList(i, VVorder);
if (VVorder == 0)
e.Button.ImageIndex = 1;
this.toolBarButton6.ImageIndex
= 2;
}
else
{
if (e.Button.ImageIndex
== 2)
{
VVorder = VVorder + 1;
navigate_sub(VVorder);
if (this.toolBarButton4.ImageIndex
== 1)
this.toolBarButton4.ImageIndex
= 0;
}
}
this.HScrollBar_panel_Tab1.Value
= VVorder;
navigate_Picture(VVorder);
}
private
void navigate_sub(int
VVorder1)
{
int i;
this.toolBarButton4.ImageIndex=0;
this.toolBarButton6.ImageIndex=2;
if (VVorder1 ==
0)
this.toolBarButton4.ImageIndex
= 1;
if (((VVorder1 +
1) * 4 - 1) < (this.listArray.Items.Count
- 1))
{
for (i = 0; i<=
3; i++)
ViewList(i, VVorder1);
}
else
{
if (((VVorder1 +
1) * 4 - 1) > (this.listArray.Items.Count
- 1))
{
for ( i = 0; i<=(this.listArray.Items.Count
- 1) - ((VVorder1 * 4) - 1) - 1; i++)
ViewList(i, VVorder1);
for (i = (this.listArray.Items.Count
- 1) - ((VVorder1 * 4) - 1); i<= 3; i++)
vPanel_visible(i, false);
this.toolBarButton6.ImageIndex=
3;
}
else
{
if (((VVorder1 +
1) * 4 - 1) == (this.listArray.Items.Count
- 1))
{
ViewList(0, VVorder1);
for (i = 1; i<=3;i++)
vPanel_visible(i, false);
this.toolBarButton6.ImageIndex=
3;
}
}
}
}
private
void
navigate_Picture(int
VVorder1)
{
TabPage_Select_Picture(0);
// 1st item to Focus
this.lbvpic0.BackColor
= System.Drawing.Color.Gray;
}
// Navigation
operation using HScrollBar
private
void
HScrollBar_panel_Tab1_Scroll(object
sender, System.Windows.Forms.ScrollEventArgs e)
{
VVorder = this.HScrollBar_panel_Tab1.Value;
navigate_sub(VVorder);
navigate_Picture(VVorder);
}
// Zoom operation
private
void
toolBar_zoom_ButtonClick(object
sender, System.Windows.Forms.ToolBarButtonClickEventArgs
e)
{
if (e.Button.ImageIndex
== 4)
{
Varzoom = Varzoom - 1;
switch(Varzoom)
{
case 2:
e.Button.ImageIndex = 5;
DisplayPicture_View(currentPicture);
break;
case 3:
DisplayPicture_View(currentPicture);
break;
case 4:
DisplayPicture_View(currentPicture);
break;
case 5:
DisplayPicture_View(currentPicture);
break;
}
}
else
{
if (e.Button.ImageIndex
== 6)
{
Varzoom = Varzoom + 1;
if (Varzoom <= 2)
{
Varzoom = 2;
this.toolBarButton1.ImageIndex
= 5;
DisplayPicture_View(currentPicture);
}
else
{
if (Varzoom >=3
&& Varzoom <= 5)
{
this.toolBarButton1.ImageIndex
= 4;
DisplayPicture_View(currentPicture);
}
else
{
Varzoom = 5;
Picture_Show_VCSNet.Large_Picture FLarge_Picture =
new Large_Picture();
FLarge_Picture.Show();
}
}
}
}
}
private
void
TabPage_Select_Picture(int
index)
{
switch(index)
{
case 0:
// Selected items, Focus
this.lbvpic0.BackColor
= System.Drawing.Color.LightSteelBlue;
this.lbvpic1.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic2.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic3.BackColor
= System.Drawing.Color.LemonChiffon;
break;
case 1:
// Selected items, Focus
this.lbvpic0.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic1.BackColor
= System.Drawing.Color.LightSteelBlue;
this.lbvpic2.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic3.BackColor
= System.Drawing.Color.LemonChiffon;
break;
case 2:
// Selected items, Focus
this.lbvpic0.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic1.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic2.BackColor
= System.Drawing.Color.LightSteelBlue;
this.lbvpic3.BackColor
= System.Drawing.Color.LemonChiffon;
break;
case 3:
// Selected items, Focus
this.lbvpic0.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic1.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic2.BackColor
= System.Drawing.Color.LemonChiffon;
this.lbvpic3.BackColor
= System.Drawing.Color.LightSteelBlue;
break;
}
this.listArray.SelectedIndex
= VVorder * 4 + index;
currentPicture = this.listArray.SelectedItem.ToString();
// Display Picture Zoom
DisplayPicture_View(currentPicture);
// Display Picture with
Scroll
Picture_scroll(currentPicture);
ListView_sub(currentPicture);
}
private
void ListView_sub(string
currentPicturex)
{
FileInfo fi1 = new
FileInfo(currentfolder +
Path.DirectorySeparatorChar.ToString() + currentPicturex);
ListViewItem item1;
int colwidth;
// Header ListView
colwidth = (this.listView1.Width
/ 4) - 3;
this.listView1.Columns.Clear();
this.listView1.Columns.Add("Name",
colwidth, HorizontalAlignment.Left);
this.listView1.Columns.Add("Size",
colwidth, HorizontalAlignment.Left);
this.listView1.Columns.Add("File
Extension", colwidth, HorizontalAlignment.Left);
this.listView1.Columns.Add("Modified
date", colwidth, HorizontalAlignment.Left);
// Clear
this.listView1.Items.Clear();
// ListView control, Add
info
item1 = new
ListViewItem(currentPicturex, 0);
item1.SubItems.Add(fi1.Length.ToString() + " Bytes");
item1.SubItems.Add(fi1.Extension);
item1.SubItems.Add(fi1.LastWriteTime.ToString());
//Add the items to the
ListView.
this.listView1.Items.AddRange(new
ListViewItem[] {item1});
}
private
void
CmbFolder_SelectedIndexChanged(object
sender, System.EventArgs e)
{
// Flag Permission for
use combobox - CmbFolder
if (combo_permission)
{
if ((this.CmbFolder.Items.Count
> 0) && (this.CmbFolder.Text.Length
> 0))
{
currentfolder = this.CmbFolder.Text;
View_Sub();
}
}
}
private
void vPic0_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(0);
}
private
void VPanel0_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(0);
}
private
void lbvpic0_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(0);
}
private
void vPic1_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(1);
}
private
void VPanel1_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(1);
}
private
void lbvpic1_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(1);
}
private
void vPic2_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(2);
}
private
void VPanel2_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(2);
}
private
void lbvpic2_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(2);
}
private
void vPic3_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(3);
}
private
void VPanel3_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(3);
}
private
void lbvpic3_Click(object
sender, System.EventArgs e)
{
TabPage_Select_Picture(3);
}
}
} |