Ceasar code (Caesar code)

Saturday, 17 January 2009
source code programe
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CeasarCode
{
class Program
{
static void Main(string[] args)
{
int choice = 0;
while (choice != 3)
{
Menu();
Console.Write("\nChoose Menu mode\n=> ");
choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1: Encode(); break;
case 2: Decode(); break;
case 3: Console.WriteLine("\n\nThank You..............\n\nBy PINYA SITTHIWONG");
DelayT(45); break;
default: break;
}

}

}
public static void Menu()
{
Console.WriteLine("\n\nCeasar Code Menu ");
Console.WriteLine("1.Encode ");
Console.WriteLine("2.Decode ");
Console.WriteLine("3.Exit ");
}
public static void Encode()
{
Console.WriteLine("\n\nCeasar EnCoder Mode\n");
Console.Write("Enter your Data for Encode\n=> ");
string strEn = Console.ReadLine();
Console.Write("Enter your hashing nuber\n=> ");
int hash = int.Parse(Console.ReadLine());
hash = hash % 26;
int len = strEn.Length;
char[] chE = new char[len];
chE = strEn.ToCharArray();
int count, temp, detected, diff;
for (count = 0; count < len; count++)
{
detected = chE[count];
temp = detected + hash;
if ((detected >= 65) && (detected <= 90))
{
if (temp > 90)
{
diff = temp - 90;
temp = 64 + diff;
}
chE[count] = Convert.ToChar(temp);
}
else if ((detected >= 97) && (detected <= 122))
{
if (temp > 122)
{
diff = temp - 122;
temp = 96 + diff;
}
chE[count] = Convert.ToChar(temp);
}

}
Console.Write("After Encoder \n=> ");
for (count = 0; count < len; count++)
{
Console.Write(chE[count]);
}
DelayT(38);
}
public static void Decode()
{
Console.WriteLine("\n\nCeasar Decoder Mode");
Console.Write("Enter your data for Decode\n=> ");
string strDe = Console.ReadLine();
Console.Write("\nEnter your hashing number\n=> ");
int hash = int.Parse(Console.ReadLine());
hash = hash % 26;
int len = strDe.Length;
char[] chD = new char[len];
chD = strDe.ToCharArray();
int count, temp, detected, diff;

for (count = 0; count < len; count++)
{
detected = chD[count];
temp = detected - hash;

if ((detected >= 65) && (detected <= 90))
{
if (temp < 65)
{
diff = 65 - temp;
temp = 91 - diff;
}
chD[count] = Convert.ToChar(temp);
}
else if ((detected >= 97) && (detected <= 122))
{
if (temp < 97)
{
diff = 97 - temp;
temp = 123 - diff;
}
chD[count] = Convert.ToChar(temp);
}

}

Console.WriteLine("After Decoder\n=> ");
for (count = 0; count < len; count++)
{
Console.Write(chD[count]);
}
DelayT(38);
}
public static void DelayT(int del)
{
int countD;
for (countD = 0; countD < del; countD++)
{
for (countD = 0; countD < del; countD++)
{
System.Threading.Thread.Sleep(del);
}
}
}
}
}
//end Ceasar code Example

Progressbar C#

Thursday, 15 January 2009
The ProgressBar control that is included with Microsoft Visual C# supports only the standard setting.

The sample code in this article illustrates how to create a control that supports the following properties:
• Minimum. This property obtains or sets the lower value for the range of valid values for progress. The default value of this property is zero (0); you cannot set this property to a negative value.
• Maximum. This property obtains or sets the upper value for the range of valid values for progress. The default value of this property is 100.
• Value. This property obtains or sets the current level of progress. The value must be in the range that the Minimum and the Maximum properties define.
• ProgressBarColor. This property obtains or sets the color of the progress bar.
For example Progressbar in C#

Source Code
----------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace PNbrowser
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
{

}

private void buttonGo_Click(object sender, EventArgs e)
{
if (!textBoxAddress.Text.Equals(""))
webBrowser1.Navigate(textBoxAddress.Text);

}

private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.GoHome();
}

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
this.Text ="PNbrowser "+ webBrowser1.DocumentTitle;
}

private void buttonHome_Click(object sender, EventArgs e)
{
webBrowser1.GoHome();
// textBoxAddress.Text=webBrowser1.
}

private void buttonBack_Click(object sender, EventArgs e)
{
webBrowser1.GoBack();
}

private void buttonNext_Click(object sender, EventArgs e)
{
webBrowser1.GoForward();
}

private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
toolStripStatusLabelStatus.Text = webBrowser1.StatusText;
int process=(int)(e.CurrentProgress * 100 / e.MaximumProgress);
if (process >0)
{
if (process > 100)
process =99;
toolStripProgressBar.Visible = true;
toolStripStatusLabelProcessing.Text = "processing = " + (process) + "%";
toolStripProgressBar.Value = process;

}
if ((process >=100)||(process<0))
{


toolStripProgressBar.Visible = false;
toolStripStatusLabelProcessing.Text = "";

}

}

private void internetOptionToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("inetcpl.cpl");
}

private void buttonSearch_Click(object sender, EventArgs e)
{ if(!textBoxSearch.Text.Equals(""))
webBrowser1.Navigate("http://www.google.co.th/search?hl=th&q=" + textBoxSearch.Text);
}

private void timeDateToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start("timedate.cpl");
}
}
}
End Source code
End Progressbar C#

get C# (get c# reference)

"get" is a keyword that defines an accessor method in a property or indexer that retrieves the value of the property or the indexer element.

For example : get C#
This is an example of a get accessor in a property name balance:

class BankAccount
{
private double balance;
public double Balance
{
get { return balance; }
set { balance=value; }
}
} // end get C# example