- Resume The operating system is about to resume from a suspended state.
- StatusChange A power mode status notification event has been raised by the operating system. This might indicate a weak or charging battery, a transition between AC power and battery, or another change in the status of the system power supply.
- Suspend The operating system is about to be suspended.
PowerModes in Microsoft.Win32
Microsoft.Win32 Namespace
The Microsoft. Win32 namespace provides two types of classes: those that handle events raised by the operating system and those that manipulate the system registry.
SystemEvent Class
Provides access to system event notifications. This class cannot be inherited.
- DisplaySettingsChanged Event
- DisplaySettingsChanging Event
- EventsThreadShutdown Event
- InstalledFontsChanged Event
- LowMemory Event
- PaletteChanged Event
- PowerModeChanged Event
- SessionEnded Event
- SessionEnding Event
- SessionSwitch Event
- TimeChanged Event
- TimerElapsed Event
- UserPreferenceChanged Event
- UserPreferenceChanging Event
Expose Keys in Registry
CurrentUser
Stores information about user preferences.
LocalMachine
Stores configuration information for the local machine.
ClassesRoot
Stores information about types (and classes) and their properties.
Users
Stores information about the default user configuration.
PerformanceData
Stores performance information for software components.
CurrentConfig
Stores non-user-specific hardware information.
DynData
Stores dynamic data.
Stores information about user preferences.
LocalMachine
Stores configuration information for the local machine.
ClassesRoot
Stores information about types (and classes) and their properties.
Users
Stores information about the default user configuration.
PerformanceData
Stores performance information for software components.
CurrentConfig
Stores non-user-specific hardware information.
DynData
Stores dynamic data.
Compress and Decompress in VB.Net
Thanks to MSDN
Namespace
Declare Variable
Namespace
Imports System.IO.Compression
Declare Variable
'Use GZipStream Class for Compress and Decompress Folder
Dim dirpath As String = "E:\TestCompress"
Dim dirpath As String = "E:\TestCompress"
Private Sub Compress(ByVal fi As FileInfo)
Using inFile As FileStream = fi.OpenRead()
If (File.GetAttributes(fi.FullName) And FileAttributes.Hidden) _
<> FileAttributes.Hidden And fi.Extension <> ".gz" Then
Using outFile As FileStream = File.Create(fi.FullName + ".gz")
Using Compress As GZipStream = New GZipStream(outFile, CompressionMode.Compress)
' Copy the source file into the compression stream.
Dim buffer As Byte() = New Byte(4096) {}
Dim numRead As Integer
numRead = inFile.Read(buffer, 0, buffer.Length)
Do While numRead <> 0
Compress.Write(buffer, 0, numRead)
numRead = inFile.Read(buffer, 0, buffer.Length)
Loop
Console.WriteLine("Compressed {0} from {1} to {2} bytes.", _
fi.Name, fi.Length.ToString(), outFile.Length.ToString())
End Using
End Using
End If
End Using
End Sub
Using inFile As FileStream = fi.OpenRead()
If (File.GetAttributes(fi.FullName) And FileAttributes.Hidden) _
<> FileAttributes.Hidden And fi.Extension <> ".gz" Then
Using outFile As FileStream = File.Create(fi.FullName + ".gz")
Using Compress As GZipStream = New GZipStream(outFile, CompressionMode.Compress)
' Copy the source file into the compression stream.
Dim buffer As Byte() = New Byte(4096) {}
Dim numRead As Integer
numRead = inFile.Read(buffer, 0, buffer.Length)
Do While numRead <> 0
Compress.Write(buffer, 0, numRead)
numRead = inFile.Read(buffer, 0, buffer.Length)
Loop
Console.WriteLine("Compressed {0} from {1} to {2} bytes.", _
fi.Name, fi.Length.ToString(), outFile.Length.ToString())
End Using
End Using
End If
End Using
End Sub
Private Sub Decompress(ByVal fi As FileInfo)
Using inFile As FileStream = fi.OpenRead()
Dim curFile As String = fi.FullName
Dim origName = curFile.Remove(curFile.Length - fi.Extension.Length)
Using outFile As FileStream = File.Create(origName)
Using Decompress As GZipStream = New GZipStream(inFile, CompressionMode.Decompress)
Dim buffer As Byte() = New Byte(4096) {}
Dim numRead As Integer
numRead = Decompress.Read(buffer, 0, buffer.Length)
Do While numRead <> 0
outFile.Write(buffer, 0, numRead)
numRead = Decompress.Read(buffer, 0, buffer.Length)
Loop
Console.WriteLine("Decompressed: {0}", fi.Name)
End Using
End Using
End Using
End Sub
Using inFile As FileStream = fi.OpenRead()
Dim curFile As String = fi.FullName
Dim origName = curFile.Remove(curFile.Length - fi.Extension.Length)
Using outFile As FileStream = File.Create(origName)
Using Decompress As GZipStream = New GZipStream(inFile, CompressionMode.Decompress)
Dim buffer As Byte() = New Byte(4096) {}
Dim numRead As Integer
numRead = Decompress.Read(buffer, 0, buffer.Length)
Do While numRead <> 0
outFile.Write(buffer, 0, numRead)
numRead = Decompress.Read(buffer, 0, buffer.Length)
Loop
Console.WriteLine("Decompressed: {0}", fi.Name)
End Using
End Using
End Using
End Sub
Private Sub CompressDeCompress(ByVal path As String, ByVal mode As CompressType)
Dim di As DirectoryInfo = New DirectoryInfo(path)
Select Case mode
Case CompressType.Compress
For Each fi As FileInfo In di.GetFiles()
Compress(fi)
Next
Case CompressType.Decompress
For Each fi As FileInfo In di.GetFiles("*.gz")
Decompress(fi)
Next
End Select
End Sub
Dim di As DirectoryInfo = New DirectoryInfo(path)
Select Case mode
Case CompressType.Compress
For Each fi As FileInfo In di.GetFiles()
Compress(fi)
Next
Case CompressType.Decompress
For Each fi As FileInfo In di.GetFiles("*.gz")
Decompress(fi)
Next
End Select
End Sub
Enum CompressType
Compress
Decompress
End Enum
Compress
Decompress
End Enum
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CompressDeCompress(dirpath, CompressType.Compress)
End Sub
CompressDeCompress(dirpath, CompressType.Compress)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CompressDeCompress(dirpath, CompressType.Decompress)
End Sub
CompressDeCompress(dirpath, CompressType.Decompress)
End Sub
Labels:
VB.Net
ZipFile.Open Method
This method is applicable in .NET FRAMEWORK 4.5
Open a Zip archive at the specified path and on the specified mode
Open a Zip archive at the specified path and on the specified mode
Dim zipPath As String = "c:\naraayanan\exampleuser\end.zip"
Dim extractPath As String = "c:\naraayanan\exampleuser\extract"
Dim newFile As String = "c:\naraayanan\exampleuser\NewFile.txt"
Using archive As ZipArchive = ZipFile.Open(zipPath, ZipArchiveMode.Update)
archive.CreateEntryFromFile(newFile, "NewEntry.txt", CompressionLevel.Fastest)
archive.ExtractToDirectory(extractPath)
End Using
Dim extractPath As String = "c:\naraayanan\exampleuser\extract"
Dim newFile As String = "c:\naraayanan\exampleuser\NewFile.txt"
Using archive As ZipArchive = ZipFile.Open(zipPath, ZipArchiveMode.Update)
archive.CreateEntryFromFile(newFile, "NewEntry.txt", CompressionLevel.Fastest)
archive.ExtractToDirectory(extractPath)
End Using
Labels:
C#.Net
AppNotifyIcon
InitializeComponent
namespace TestEasyCon
{
partial class AppNotifyIcon
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppNotifyIcon));
this.nfyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmRestore = new System.Windows.Forms.ToolStripMenuItem();
this.tsmExit = new System.Windows.Forms.ToolStripMenuItem();
this.tmrForNfy = new System.Windows.Forms.Timer(this.components);
this.contextMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// nfyIcon
//
this.nfyIcon.ContextMenuStrip = this.contextMenuStrip;
this.nfyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("nfyIcon.Icon")));
this.nfyIcon.Text = "EasyCon";
this.nfyIcon.Visible = true;
this.nfyIcon.BalloonTipShown += new System.EventHandler(this.notifyIcon1_BalloonTipShown);
//
// contextMenuStrip
//
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmRestore,
this.tsmExit});
this.contextMenuStrip.Name = "contextMenuStrip1";
this.contextMenuStrip.Size = new System.Drawing.Size(124, 48);
//
// tsmRestore
//
this.tsmRestore.Name = "tsmRestore";
this.tsmRestore.Size = new System.Drawing.Size(123, 22);
this.tsmRestore.Text = "Restore";
//
// tsmExit
//
this.tsmExit.Name = "tsmExit";
this.tsmExit.Size = new System.Drawing.Size(123, 22);
this.tsmExit.Text = "Exit";
//
// tmrForNfy
//
this.tmrForNfy.Tick += new System.EventHandler(this.tmrForNfy_Tick);
//
// AppNotifyIcon
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "AppNotifyIcon";
this.Size = new System.Drawing.Size(10, 10);
this.contextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.NotifyIcon nfyIcon;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem tsmRestore;
private System.Windows.Forms.ToolStripMenuItem tsmExit;
private System.Windows.Forms.Timer tmrForNfy;
}
}
Code Behind
{
partial class AppNotifyIcon
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AppNotifyIcon));
this.nfyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmRestore = new System.Windows.Forms.ToolStripMenuItem();
this.tsmExit = new System.Windows.Forms.ToolStripMenuItem();
this.tmrForNfy = new System.Windows.Forms.Timer(this.components);
this.contextMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// nfyIcon
//
this.nfyIcon.ContextMenuStrip = this.contextMenuStrip;
this.nfyIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("nfyIcon.Icon")));
this.nfyIcon.Text = "EasyCon";
this.nfyIcon.Visible = true;
this.nfyIcon.BalloonTipShown += new System.EventHandler(this.notifyIcon1_BalloonTipShown);
//
// contextMenuStrip
//
this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmRestore,
this.tsmExit});
this.contextMenuStrip.Name = "contextMenuStrip1";
this.contextMenuStrip.Size = new System.Drawing.Size(124, 48);
//
// tsmRestore
//
this.tsmRestore.Name = "tsmRestore";
this.tsmRestore.Size = new System.Drawing.Size(123, 22);
this.tsmRestore.Text = "Restore";
//
// tsmExit
//
this.tsmExit.Name = "tsmExit";
this.tsmExit.Size = new System.Drawing.Size(123, 22);
this.tsmExit.Text = "Exit";
//
// tmrForNfy
//
this.tmrForNfy.Tick += new System.EventHandler(this.tmrForNfy_Tick);
//
// AppNotifyIcon
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Name = "AppNotifyIcon";
this.Size = new System.Drawing.Size(10, 10);
this.contextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.NotifyIcon nfyIcon;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem tsmRestore;
private System.Windows.Forms.ToolStripMenuItem tsmExit;
private System.Windows.Forms.Timer tmrForNfy;
}
}
Code Behind
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestEasyCon
{
public partial class AppNotifyIcon : UserControl
{
public AppNotifyIcon()
{
InitializeComponent();
nfyIcon.DoubleClick += new EventHandler(OpenApp);
tsmRestore.Click += new EventHandler(OpenApp);
}
#region Declaration
bool FromTrayIconDoubleClick = false;
public delegate void RestoreClickedEventHandler(object sender, EventArgs e);
public event RestoreClickedEventHandler RestoreClicked;
#endregion
#region Functions
private void OpenApp(object sender, EventArgs e)
{
if (RestoreClicked != null)
RestoreClicked(this, e);
}
/// <summary>
/// To Restore Application
/// </summary>
/// <param name="frm">Pass Form Name</param>
public void RestoreApplicaiton(Form frm)
{
FromTrayIconDoubleClick = true;
frm.Show();
frm.WindowState = FormWindowState.Normal;
frm.Focus();
}
#endregion
private void notifyIcon1_BalloonTipShown(object sender, EventArgs e)
{
tmrForNfy.Enabled = true;
}
private void tmrForNfy_Tick(object sender, EventArgs e)
{
nfyIcon.Visible = false;
nfyIcon.Visible = true;
tmrForNfy.Enabled = false;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace TestEasyCon
{
public partial class AppNotifyIcon : UserControl
{
public AppNotifyIcon()
{
InitializeComponent();
nfyIcon.DoubleClick += new EventHandler(OpenApp);
tsmRestore.Click += new EventHandler(OpenApp);
}
#region Declaration
bool FromTrayIconDoubleClick = false;
public delegate void RestoreClickedEventHandler(object sender, EventArgs e);
public event RestoreClickedEventHandler RestoreClicked;
#endregion
#region Functions
private void OpenApp(object sender, EventArgs e)
{
if (RestoreClicked != null)
RestoreClicked(this, e);
}
/// <summary>
/// To Restore Application
/// </summary>
/// <param name="frm">Pass Form Name</param>
public void RestoreApplicaiton(Form frm)
{
FromTrayIconDoubleClick = true;
frm.Show();
frm.WindowState = FormWindowState.Normal;
frm.Focus();
}
#endregion
private void notifyIcon1_BalloonTipShown(object sender, EventArgs e)
{
tmrForNfy.Enabled = true;
}
private void tmrForNfy_Tick(object sender, EventArgs e)
{
nfyIcon.Visible = false;
nfyIcon.Visible = true;
tmrForNfy.Enabled = false;
}
}
}
Labels:
C#.Net,
User Control
ImageViewer in C#.Net
InitializeComponent
namespace TestEasyCon
{
partial class ImageViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageViewer));
this.panel1 = new System.Windows.Forms.Panel();
this.imageBox1 = new Cyotek.Windows.Forms.ImageBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.tsmClose = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTools = new System.Windows.Forms.ToolStripMenuItem();
this.tsmFit = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTZoomIn = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTZoomOut = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTRotateClockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTRotateAntiClockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmNormal = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoomIn = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoomOut = new System.Windows.Forms.ToolStripMenuItem();
this.tsmRotateclockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmRotateAntiClockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmPrint = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoom = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoomSize = new System.Windows.Forms.ToolStripComboBox();
this.tsmExit = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.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.panel1.Controls.Add(this.imageBox1);
this.panel1.Controls.Add(this.menuStrip1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(632, 752);
this.panel1.TabIndex = 0;
//
// imageBox1
//
this.imageBox1.AutoSize = false;
this.imageBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageBox1.Location = new System.Drawing.Point(0, 25);
this.imageBox1.Name = "imageBox1";
this.imageBox1.Size = new System.Drawing.Size(632, 727);
this.imageBox1.TabIndex = 1;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmClose,
this.tsmTools,
this.tsmNormal,
this.tsmZoomIn,
this.tsmZoomOut,
this.tsmRotateclockWise,
this.tsmRotateAntiClockWise,
this.tsmPrint,
this.tsmZoom,
this.tsmZoomSize,
this.tsmExit});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(632, 25);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// tsmClose
//
this.tsmClose.AutoToolTip = true;
this.tsmClose.Image = ((System.Drawing.Image)(resources.GetObject("tsmClose.Image")));
this.tsmClose.Name = "tsmClose";
this.tsmClose.Size = new System.Drawing.Size(61, 21);
this.tsmClose.Text = "Close";
this.tsmClose.ToolTipText = "Close ";
//
// tsmTools
//
this.tsmTools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmFit,
this.tsmTZoomIn,
this.tsmTZoomOut,
this.tsmTRotateClockWise,
this.tsmTRotateAntiClockWise});
this.tsmTools.Image = ((System.Drawing.Image)(resources.GetObject("tsmTools.Image")));
this.tsmTools.Name = "tsmTools";
this.tsmTools.Size = new System.Drawing.Size(60, 21);
this.tsmTools.Text = "Tools";
//
// tsmFit
//
this.tsmFit.AutoToolTip = true;
this.tsmFit.Image = ((System.Drawing.Image)(resources.GetObject("tsmFit.Image")));
this.tsmFit.Name = "tsmFit";
this.tsmFit.Size = new System.Drawing.Size(194, 22);
this.tsmFit.Text = "Fit";
this.tsmFit.ToolTipText = "Fit";
//
// tsmTZoomIn
//
this.tsmTZoomIn.Image = ((System.Drawing.Image)(resources.GetObject("tsmTZoomIn.Image")));
this.tsmTZoomIn.Name = "tsmTZoomIn";
this.tsmTZoomIn.Size = new System.Drawing.Size(194, 22);
this.tsmTZoomIn.Text = "Zoom In";
//
// tsmTZoomOut
//
this.tsmTZoomOut.AutoToolTip = true;
this.tsmTZoomOut.Image = ((System.Drawing.Image)(resources.GetObject("tsmTZoomOut.Image")));
this.tsmTZoomOut.Name = "tsmTZoomOut";
this.tsmTZoomOut.Size = new System.Drawing.Size(194, 22);
this.tsmTZoomOut.Text = "Zoom Out";
//
// tsmTRotateClockWise
//
this.tsmTRotateClockWise.AutoToolTip = true;
this.tsmTRotateClockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmTRotateClockWise.Image")));
this.tsmTRotateClockWise.Name = "tsmTRotateClockWise";
this.tsmTRotateClockWise.Size = new System.Drawing.Size(194, 22);
this.tsmTRotateClockWise.Text = "Rotate Clock Wise";
//
// tsmTRotateAntiClockWise
//
this.tsmTRotateAntiClockWise.AutoToolTip = true;
this.tsmTRotateAntiClockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmTRotateAntiClockWise.Image")));
this.tsmTRotateAntiClockWise.Name = "tsmTRotateAntiClockWise";
this.tsmTRotateAntiClockWise.Size = new System.Drawing.Size(194, 22);
this.tsmTRotateAntiClockWise.Text = "Rotate Anti Clock Wise";
//
// tsmNormal
//
this.tsmNormal.AutoToolTip = true;
this.tsmNormal.Image = ((System.Drawing.Image)(resources.GetObject("tsmNormal.Image")));
this.tsmNormal.Name = "tsmNormal";
this.tsmNormal.Size = new System.Drawing.Size(28, 21);
this.tsmNormal.ToolTipText = "Fit";
//
// tsmZoomIn
//
this.tsmZoomIn.AutoToolTip = true;
this.tsmZoomIn.Image = ((System.Drawing.Image)(resources.GetObject("tsmZoomIn.Image")));
this.tsmZoomIn.Name = "tsmZoomIn";
this.tsmZoomIn.Size = new System.Drawing.Size(28, 21);
this.tsmZoomIn.ToolTipText = "Zoom In";
//
// tsmZoomOut
//
this.tsmZoomOut.AutoToolTip = true;
this.tsmZoomOut.Image = ((System.Drawing.Image)(resources.GetObject("tsmZoomOut.Image")));
this.tsmZoomOut.Name = "tsmZoomOut";
this.tsmZoomOut.Size = new System.Drawing.Size(28, 21);
this.tsmZoomOut.ToolTipText = "Zoom Out";
//
// tsmRotateclockWise
//
this.tsmRotateclockWise.AutoToolTip = true;
this.tsmRotateclockWise.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmRotateclockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmRotateclockWise.Image")));
this.tsmRotateclockWise.Name = "tsmRotateclockWise";
this.tsmRotateclockWise.Size = new System.Drawing.Size(28, 21);
this.tsmRotateclockWise.Text = "Rotate Clock Wise";
//
// tsmRotateAntiClockWise
//
this.tsmRotateAntiClockWise.AutoToolTip = true;
this.tsmRotateAntiClockWise.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmRotateAntiClockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmRotateAntiClockWise.Image")));
this.tsmRotateAntiClockWise.Name = "tsmRotateAntiClockWise";
this.tsmRotateAntiClockWise.Size = new System.Drawing.Size(28, 21);
this.tsmRotateAntiClockWise.Text = "Rotate AntiClock Wise";
//
// tsmPrint
//
this.tsmPrint.AutoToolTip = true;
this.tsmPrint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmPrint.Image = ((System.Drawing.Image)(resources.GetObject("tsmPrint.Image")));
this.tsmPrint.Name = "tsmPrint";
this.tsmPrint.Size = new System.Drawing.Size(28, 21);
this.tsmPrint.Text = "Print";
//
// tsmZoom
//
this.tsmZoom.Name = "tsmZoom";
this.tsmZoom.Size = new System.Drawing.Size(49, 21);
this.tsmZoom.Text = "Zoom:";
//
// tsmZoomSize
//
this.tsmZoomSize.AutoToolTip = true;
this.tsmZoomSize.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
this.tsmZoomSize.Items.AddRange(new object[] {
"",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"400%",
"800%",
"1500%",
"Actual Size"});
this.tsmZoomSize.Name = "tsmZoomSize";
this.tsmZoomSize.Size = new System.Drawing.Size(121, 21);
this.tsmZoomSize.ToolTipText = "Zoom (%)";
//
// tsmExit
//
this.tsmExit.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsmExit.AutoToolTip = true;
this.tsmExit.Image = ((System.Drawing.Image)(resources.GetObject("tsmExit.Image")));
this.tsmExit.Name = "tsmExit";
this.tsmExit.Size = new System.Drawing.Size(28, 21);
this.tsmExit.ToolTipText = "Exit ";
//
// ImageViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "ImageViewer";
this.Size = new System.Drawing.Size(634, 747);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem tsmClose;
private System.Windows.Forms.ToolStripMenuItem tsmTools;
private System.Windows.Forms.ToolStripMenuItem tsmNormal;
private System.Windows.Forms.ToolStripMenuItem tsmZoomIn;
private System.Windows.Forms.ToolStripMenuItem tsmFit;
private System.Windows.Forms.ToolStripMenuItem tsmTZoomIn;
private System.Windows.Forms.ToolStripMenuItem tsmTZoomOut;
private System.Windows.Forms.ToolStripMenuItem tsmTRotateClockWise;
private System.Windows.Forms.ToolStripMenuItem tsmTRotateAntiClockWise;
private System.Windows.Forms.ToolStripMenuItem tsmZoomOut;
private System.Windows.Forms.ToolStripMenuItem tsmZoom;
private System.Windows.Forms.ToolStripComboBox tsmZoomSize;
private System.Windows.Forms.ToolStripMenuItem tsmExit;
private System.Windows.Forms.ToolStripMenuItem tsmRotateclockWise;
private System.Windows.Forms.ToolStripMenuItem tsmRotateAntiClockWise;
private Cyotek.Windows.Forms.ImageBox imageBox1;
private System.Windows.Forms.ToolStripMenuItem tsmPrint;
}
}
Code Behind{
partial class ImageViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageViewer));
this.panel1 = new System.Windows.Forms.Panel();
this.imageBox1 = new Cyotek.Windows.Forms.ImageBox();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.tsmClose = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTools = new System.Windows.Forms.ToolStripMenuItem();
this.tsmFit = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTZoomIn = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTZoomOut = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTRotateClockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmTRotateAntiClockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmNormal = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoomIn = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoomOut = new System.Windows.Forms.ToolStripMenuItem();
this.tsmRotateclockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmRotateAntiClockWise = new System.Windows.Forms.ToolStripMenuItem();
this.tsmPrint = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoom = new System.Windows.Forms.ToolStripMenuItem();
this.tsmZoomSize = new System.Windows.Forms.ToolStripComboBox();
this.tsmExit = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.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.panel1.Controls.Add(this.imageBox1);
this.panel1.Controls.Add(this.menuStrip1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(632, 752);
this.panel1.TabIndex = 0;
//
// imageBox1
//
this.imageBox1.AutoSize = false;
this.imageBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.imageBox1.Location = new System.Drawing.Point(0, 25);
this.imageBox1.Name = "imageBox1";
this.imageBox1.Size = new System.Drawing.Size(632, 727);
this.imageBox1.TabIndex = 1;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmClose,
this.tsmTools,
this.tsmNormal,
this.tsmZoomIn,
this.tsmZoomOut,
this.tsmRotateclockWise,
this.tsmRotateAntiClockWise,
this.tsmPrint,
this.tsmZoom,
this.tsmZoomSize,
this.tsmExit});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(632, 25);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// tsmClose
//
this.tsmClose.AutoToolTip = true;
this.tsmClose.Image = ((System.Drawing.Image)(resources.GetObject("tsmClose.Image")));
this.tsmClose.Name = "tsmClose";
this.tsmClose.Size = new System.Drawing.Size(61, 21);
this.tsmClose.Text = "Close";
this.tsmClose.ToolTipText = "Close ";
//
// tsmTools
//
this.tsmTools.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmFit,
this.tsmTZoomIn,
this.tsmTZoomOut,
this.tsmTRotateClockWise,
this.tsmTRotateAntiClockWise});
this.tsmTools.Image = ((System.Drawing.Image)(resources.GetObject("tsmTools.Image")));
this.tsmTools.Name = "tsmTools";
this.tsmTools.Size = new System.Drawing.Size(60, 21);
this.tsmTools.Text = "Tools";
//
// tsmFit
//
this.tsmFit.AutoToolTip = true;
this.tsmFit.Image = ((System.Drawing.Image)(resources.GetObject("tsmFit.Image")));
this.tsmFit.Name = "tsmFit";
this.tsmFit.Size = new System.Drawing.Size(194, 22);
this.tsmFit.Text = "Fit";
this.tsmFit.ToolTipText = "Fit";
//
// tsmTZoomIn
//
this.tsmTZoomIn.Image = ((System.Drawing.Image)(resources.GetObject("tsmTZoomIn.Image")));
this.tsmTZoomIn.Name = "tsmTZoomIn";
this.tsmTZoomIn.Size = new System.Drawing.Size(194, 22);
this.tsmTZoomIn.Text = "Zoom In";
//
// tsmTZoomOut
//
this.tsmTZoomOut.AutoToolTip = true;
this.tsmTZoomOut.Image = ((System.Drawing.Image)(resources.GetObject("tsmTZoomOut.Image")));
this.tsmTZoomOut.Name = "tsmTZoomOut";
this.tsmTZoomOut.Size = new System.Drawing.Size(194, 22);
this.tsmTZoomOut.Text = "Zoom Out";
//
// tsmTRotateClockWise
//
this.tsmTRotateClockWise.AutoToolTip = true;
this.tsmTRotateClockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmTRotateClockWise.Image")));
this.tsmTRotateClockWise.Name = "tsmTRotateClockWise";
this.tsmTRotateClockWise.Size = new System.Drawing.Size(194, 22);
this.tsmTRotateClockWise.Text = "Rotate Clock Wise";
//
// tsmTRotateAntiClockWise
//
this.tsmTRotateAntiClockWise.AutoToolTip = true;
this.tsmTRotateAntiClockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmTRotateAntiClockWise.Image")));
this.tsmTRotateAntiClockWise.Name = "tsmTRotateAntiClockWise";
this.tsmTRotateAntiClockWise.Size = new System.Drawing.Size(194, 22);
this.tsmTRotateAntiClockWise.Text = "Rotate Anti Clock Wise";
//
// tsmNormal
//
this.tsmNormal.AutoToolTip = true;
this.tsmNormal.Image = ((System.Drawing.Image)(resources.GetObject("tsmNormal.Image")));
this.tsmNormal.Name = "tsmNormal";
this.tsmNormal.Size = new System.Drawing.Size(28, 21);
this.tsmNormal.ToolTipText = "Fit";
//
// tsmZoomIn
//
this.tsmZoomIn.AutoToolTip = true;
this.tsmZoomIn.Image = ((System.Drawing.Image)(resources.GetObject("tsmZoomIn.Image")));
this.tsmZoomIn.Name = "tsmZoomIn";
this.tsmZoomIn.Size = new System.Drawing.Size(28, 21);
this.tsmZoomIn.ToolTipText = "Zoom In";
//
// tsmZoomOut
//
this.tsmZoomOut.AutoToolTip = true;
this.tsmZoomOut.Image = ((System.Drawing.Image)(resources.GetObject("tsmZoomOut.Image")));
this.tsmZoomOut.Name = "tsmZoomOut";
this.tsmZoomOut.Size = new System.Drawing.Size(28, 21);
this.tsmZoomOut.ToolTipText = "Zoom Out";
//
// tsmRotateclockWise
//
this.tsmRotateclockWise.AutoToolTip = true;
this.tsmRotateclockWise.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmRotateclockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmRotateclockWise.Image")));
this.tsmRotateclockWise.Name = "tsmRotateclockWise";
this.tsmRotateclockWise.Size = new System.Drawing.Size(28, 21);
this.tsmRotateclockWise.Text = "Rotate Clock Wise";
//
// tsmRotateAntiClockWise
//
this.tsmRotateAntiClockWise.AutoToolTip = true;
this.tsmRotateAntiClockWise.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmRotateAntiClockWise.Image = ((System.Drawing.Image)(resources.GetObject("tsmRotateAntiClockWise.Image")));
this.tsmRotateAntiClockWise.Name = "tsmRotateAntiClockWise";
this.tsmRotateAntiClockWise.Size = new System.Drawing.Size(28, 21);
this.tsmRotateAntiClockWise.Text = "Rotate AntiClock Wise";
//
// tsmPrint
//
this.tsmPrint.AutoToolTip = true;
this.tsmPrint.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmPrint.Image = ((System.Drawing.Image)(resources.GetObject("tsmPrint.Image")));
this.tsmPrint.Name = "tsmPrint";
this.tsmPrint.Size = new System.Drawing.Size(28, 21);
this.tsmPrint.Text = "Print";
//
// tsmZoom
//
this.tsmZoom.Name = "tsmZoom";
this.tsmZoom.Size = new System.Drawing.Size(49, 21);
this.tsmZoom.Text = "Zoom:";
//
// tsmZoomSize
//
this.tsmZoomSize.AutoToolTip = true;
this.tsmZoomSize.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
this.tsmZoomSize.Items.AddRange(new object[] {
"",
"10%",
"25%",
"50%",
"75%",
"100%",
"150%",
"200%",
"400%",
"800%",
"1500%",
"Actual Size"});
this.tsmZoomSize.Name = "tsmZoomSize";
this.tsmZoomSize.Size = new System.Drawing.Size(121, 21);
this.tsmZoomSize.ToolTipText = "Zoom (%)";
//
// tsmExit
//
this.tsmExit.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsmExit.AutoToolTip = true;
this.tsmExit.Image = ((System.Drawing.Image)(resources.GetObject("tsmExit.Image")));
this.tsmExit.Name = "tsmExit";
this.tsmExit.Size = new System.Drawing.Size(28, 21);
this.tsmExit.ToolTipText = "Exit ";
//
// ImageViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "ImageViewer";
this.Size = new System.Drawing.Size(634, 747);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem tsmClose;
private System.Windows.Forms.ToolStripMenuItem tsmTools;
private System.Windows.Forms.ToolStripMenuItem tsmNormal;
private System.Windows.Forms.ToolStripMenuItem tsmZoomIn;
private System.Windows.Forms.ToolStripMenuItem tsmFit;
private System.Windows.Forms.ToolStripMenuItem tsmTZoomIn;
private System.Windows.Forms.ToolStripMenuItem tsmTZoomOut;
private System.Windows.Forms.ToolStripMenuItem tsmTRotateClockWise;
private System.Windows.Forms.ToolStripMenuItem tsmTRotateAntiClockWise;
private System.Windows.Forms.ToolStripMenuItem tsmZoomOut;
private System.Windows.Forms.ToolStripMenuItem tsmZoom;
private System.Windows.Forms.ToolStripComboBox tsmZoomSize;
private System.Windows.Forms.ToolStripMenuItem tsmExit;
private System.Windows.Forms.ToolStripMenuItem tsmRotateclockWise;
private System.Windows.Forms.ToolStripMenuItem tsmRotateAntiClockWise;
private Cyotek.Windows.Forms.ImageBox imageBox1;
private System.Windows.Forms.ToolStripMenuItem tsmPrint;
}
}
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace TestEasyCon
{
public partial class ImageViewer : UserControl
{
public ImageViewer()
{
InitializeComponent();
tsmClose.Click += new EventHandler(CloseButtonClicked);
tsmExit.Click += new EventHandler(CloseButtonClicked);
}
#region Declaration
public delegate void CloseButtonEventHandler(object sender, EventArgs e);
public event CloseButtonEventHandler ClickCloseButton;
Image imgFile =null;
#endregion
#region Functions
private void CloseButtonClicked(object sender, EventArgs e)
{
if (ClickCloseButton != null)
ClickCloseButton(this, e);
}
/// <summary>
/// Image Processing
/// </summary>
/// <param name="mode">Pass Mode(Normal|ZoomIn|Zoom Out|rotate Clock Wise|Rotate AnitClockWise)</param>
private void ImageProcessing(string mode)
{
switch (mode)
{
case "Normal":
imageBox1.SizeToFit = true;
imageBox1.SizeToFit = false;
tsmZoomIn.Enabled = true;
tsmTZoomIn.Enabled = true;
tsmZoomSize.Text = imageBox1.Zoom.ToString() + "%";
break;
case "ZoomIn":
imageBox1.Zoom += 50;
tsmZoomSize.Text = imageBox1.Zoom.ToString() + "%";
break;
case "ZoomOut":
imageBox1.Zoom -= 50;
tsmZoomSize.Text = imageBox1.Zoom.ToString() + "%";
break;
case "RotateClockWise":
Image img = imageBox1.Image;
img.RotateFlip(RotateFlipType.Rotate270FlipXY);
Image imgtemp = img;
imageBox1.Image = imgtemp;
imageBox1.Refresh();
break;
case "RotateAntiClockWise":
Image img1 = imageBox1.Image;
img1.RotateFlip(RotateFlipType.Rotate90FlipXY);
Image imgtemp1 = img1;
imageBox1.Image = imgtemp1;
imageBox1.Refresh();
break;
}
}
/// <summary>
/// Print Image Document
/// </summary>
/// <param name="path">Pass Path</param>
public void PrintDocument(string path)
{
try
{
imgFile = Image.FromFile(path);
PrintDocument prntDoc = new PrintDocument();
PrintDialog prdDia = new PrintDialog();
prntDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
prdDia.AllowPrintToFile = true;
prdDia.AllowSelection = true;
prdDia.AllowSomePages = true;
prdDia.PrintToFile = true;
DialogResult dialogue = prdDia.ShowDialog();
if (dialogue == DialogResult.OK)
{
prntDoc.DocumentName = path;
prntDoc.Print();
}
prdDia.Dispose();
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
}
}
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
Point ulCorner = new Point(0, 0);
e.Graphics.DrawImage(imgFile, ulCorner);
}
#endregion
}
}
using System.Drawing;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace TestEasyCon
{
public partial class ImageViewer : UserControl
{
public ImageViewer()
{
InitializeComponent();
tsmClose.Click += new EventHandler(CloseButtonClicked);
tsmExit.Click += new EventHandler(CloseButtonClicked);
}
#region Declaration
public delegate void CloseButtonEventHandler(object sender, EventArgs e);
public event CloseButtonEventHandler ClickCloseButton;
Image imgFile =null;
#endregion
#region Functions
private void CloseButtonClicked(object sender, EventArgs e)
{
if (ClickCloseButton != null)
ClickCloseButton(this, e);
}
/// <summary>
/// Image Processing
/// </summary>
/// <param name="mode">Pass Mode(Normal|ZoomIn|Zoom Out|rotate Clock Wise|Rotate AnitClockWise)</param>
private void ImageProcessing(string mode)
{
switch (mode)
{
case "Normal":
imageBox1.SizeToFit = true;
imageBox1.SizeToFit = false;
tsmZoomIn.Enabled = true;
tsmTZoomIn.Enabled = true;
tsmZoomSize.Text = imageBox1.Zoom.ToString() + "%";
break;
case "ZoomIn":
imageBox1.Zoom += 50;
tsmZoomSize.Text = imageBox1.Zoom.ToString() + "%";
break;
case "ZoomOut":
imageBox1.Zoom -= 50;
tsmZoomSize.Text = imageBox1.Zoom.ToString() + "%";
break;
case "RotateClockWise":
Image img = imageBox1.Image;
img.RotateFlip(RotateFlipType.Rotate270FlipXY);
Image imgtemp = img;
imageBox1.Image = imgtemp;
imageBox1.Refresh();
break;
case "RotateAntiClockWise":
Image img1 = imageBox1.Image;
img1.RotateFlip(RotateFlipType.Rotate90FlipXY);
Image imgtemp1 = img1;
imageBox1.Image = imgtemp1;
imageBox1.Refresh();
break;
}
}
/// <summary>
/// Print Image Document
/// </summary>
/// <param name="path">Pass Path</param>
public void PrintDocument(string path)
{
try
{
imgFile = Image.FromFile(path);
PrintDocument prntDoc = new PrintDocument();
PrintDialog prdDia = new PrintDialog();
prntDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
prdDia.AllowPrintToFile = true;
prdDia.AllowSelection = true;
prdDia.AllowSomePages = true;
prdDia.PrintToFile = true;
DialogResult dialogue = prdDia.ShowDialog();
if (dialogue == DialogResult.OK)
{
prntDoc.DocumentName = path;
prntDoc.Print();
}
prdDia.Dispose();
}
catch (Exception ex)
{
Program.WriteLog(ex.Message, ex.StackTrace);
}
}
private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
Point ulCorner = new Point(0, 0);
e.Graphics.DrawImage(imgFile, ulCorner);
}
#endregion
}
}
Labels:
C#.Net,
User Control
PDFViewer in C#.Net
InitializeComponent
namespace TestEasyCon
{
partial class PDFViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PDFViewer));
this.panel1 = new System.Windows.Forms.Panel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF();
this.tsmClose = new System.Windows.Forms.ToolStripMenuItem();
this.tsmExit = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.axAcroPDF1);
this.panel1.Controls.Add(this.menuStrip1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(600, 680);
this.panel1.TabIndex = 0;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmClose,
this.tsmExit});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(600, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// axAcroPDF1
//
this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill;
this.axAcroPDF1.Enabled = true;
this.axAcroPDF1.Location = new System.Drawing.Point(0, 24);
this.axAcroPDF1.Name = "axAcroPDF1";
this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState")));
this.axAcroPDF1.Size = new System.Drawing.Size(600, 656);
this.axAcroPDF1.TabIndex = 1;
//
// tsmClose
//
this.tsmClose.AutoToolTip = true;
this.tsmClose.Image = ((System.Drawing.Image)(resources.GetObject("tsmClose.Image")));
this.tsmClose.Name = "tsmClose";
this.tsmClose.Size = new System.Drawing.Size(61, 20);
this.tsmClose.Text = "Close";
this.tsmClose.ToolTipText = "Close PDF File";
//
// tsmExit
//
this.tsmExit.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsmExit.AutoToolTip = true;
this.tsmExit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmExit.Image = ((System.Drawing.Image)(resources.GetObject("tsmExit.Image")));
this.tsmExit.Name = "tsmExit";
this.tsmExit.Size = new System.Drawing.Size(28, 20);
this.tsmExit.ToolTipText = "Close PDF File";
//
// PDFViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "PDFViewer";
this.Size = new System.Drawing.Size(603, 684);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private AxAcroPDFLib.AxAcroPDF axAcroPDF1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem tsmClose;
private System.Windows.Forms.ToolStripMenuItem tsmExit;
}
}
Code Behindnamespace TestEasyCon
{
partial class PDFViewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PDFViewer));
this.panel1 = new System.Windows.Forms.Panel();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.axAcroPDF1 = new AxAcroPDFLib.AxAcroPDF();
this.tsmClose = new System.Windows.Forms.ToolStripMenuItem();
this.tsmExit = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.axAcroPDF1);
this.panel1.Controls.Add(this.menuStrip1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(600, 680);
this.panel1.TabIndex = 0;
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmClose,
this.tsmExit});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(600, 24);
this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1";
//
// axAcroPDF1
//
this.axAcroPDF1.Dock = System.Windows.Forms.DockStyle.Fill;
this.axAcroPDF1.Enabled = true;
this.axAcroPDF1.Location = new System.Drawing.Point(0, 24);
this.axAcroPDF1.Name = "axAcroPDF1";
this.axAcroPDF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axAcroPDF1.OcxState")));
this.axAcroPDF1.Size = new System.Drawing.Size(600, 656);
this.axAcroPDF1.TabIndex = 1;
//
// tsmClose
//
this.tsmClose.AutoToolTip = true;
this.tsmClose.Image = ((System.Drawing.Image)(resources.GetObject("tsmClose.Image")));
this.tsmClose.Name = "tsmClose";
this.tsmClose.Size = new System.Drawing.Size(61, 20);
this.tsmClose.Text = "Close";
this.tsmClose.ToolTipText = "Close PDF File";
//
// tsmExit
//
this.tsmExit.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.tsmExit.AutoToolTip = true;
this.tsmExit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.tsmExit.Image = ((System.Drawing.Image)(resources.GetObject("tsmExit.Image")));
this.tsmExit.Name = "tsmExit";
this.tsmExit.Size = new System.Drawing.Size(28, 20);
this.tsmExit.ToolTipText = "Close PDF File";
//
// PDFViewer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.panel1);
this.Name = "PDFViewer";
this.Size = new System.Drawing.Size(603, 684);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.axAcroPDF1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
private AxAcroPDFLib.AxAcroPDF axAcroPDF1;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem tsmClose;
private System.Windows.Forms.ToolStripMenuItem tsmExit;
}
}
using System;
using System.Windows.Forms;
namespace TestEasyCon
{
public partial class PDFViewer : UserControl
{
public PDFViewer()
{
InitializeComponent();
tsmClose.Click += new EventHandler(CloseButtonClicked);
tsmExit.Click += new EventHandler(CloseButtonClicked);
}
#region Declaration
public delegate void CloseButtonEventHandler(object sender, EventArgs e);
public event CloseButtonEventHandler ClickCloseButton;
#endregion
#region Functions
private void CloseButtonClicked(object sender, EventArgs e)
{
if (ClickCloseButton != null)
ClickCloseButton(this, e);
}
/// <summary>
/// Display PDf File
/// </summary>
/// <param name="filePath">Pass File Path</param>
public void DisplayPDFFile(string filePath)
{
axAcroPDF1.src = filePath;
axAcroPDF1.setShowToolbar(true);
axAcroPDF1.Show();
}
#endregion
}
}
using System.Windows.Forms;
namespace TestEasyCon
{
public partial class PDFViewer : UserControl
{
public PDFViewer()
{
InitializeComponent();
tsmClose.Click += new EventHandler(CloseButtonClicked);
tsmExit.Click += new EventHandler(CloseButtonClicked);
}
#region Declaration
public delegate void CloseButtonEventHandler(object sender, EventArgs e);
public event CloseButtonEventHandler ClickCloseButton;
#endregion
#region Functions
private void CloseButtonClicked(object sender, EventArgs e)
{
if (ClickCloseButton != null)
ClickCloseButton(this, e);
}
/// <summary>
/// Display PDf File
/// </summary>
/// <param name="filePath">Pass File Path</param>
public void DisplayPDFFile(string filePath)
{
axAcroPDF1.src = filePath;
axAcroPDF1.setShowToolbar(true);
axAcroPDF1.Show();
}
#endregion
}
}
Labels:
C#.Net,
User Control
Get ODD Number using LINQ in C#.Net
static bool GetOdd(int number)
{
if (number % 2 != 0)
return true;
else
return false;
}
{
if (number % 2 != 0)
return true;
else
return false;
}
var result = from r in
Enumerable.Range(1, 50).Where(GetOdd)
select r;
foreach (var r in result)
Console.WriteLine(r);
Console.ReadKey(true);
Enumerable.Range(1, 50).Where(GetOdd)
select r;
foreach (var r in result)
Console.WriteLine(r);
Console.ReadKey(true);
Labels:
LINQ