using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleSample
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello and welcome to the new Console in Visual Studio 2005");
Console.WriteLine();
# region Title
Console.WriteLine("The default title of the Console window is the path to this executable");
Console.Write("Please enter the new Title for the Console Window:");
Console.Title = Console.ReadLine();
Console.WriteLine();
Console.WriteLine();
# endregion Title
# region Size
Console.WriteLine("You can now change the size of the Window");
Console.WriteLine();
int newHeight;
int newWidth;
Console.Write("Enter the Height in Pixels(40 is a good value):");
try
{
newHeight = Int32.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the height to 40 for you");
newHeight = 40;
}
Console.WriteLine();
Console.Write("Enter the Width in Pixels (100 is a good value):");
try
{
newWidth = Int32.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the width to 100 for you");
newWidth = 100;
}
// Make sure the window is not set larger than possible
if (newHeight > Console.LargestWindowHeight)
newHeight = Console.LargestWindowHeight;
if (newWidth > Console.LargestWindowWidth)
newWidth = Console.LargestWindowWidth;
Console.WindowHeight = newHeight;
Console.WindowWidth = newWidth;
Console.Write("New window size is: " + Console.WindowHeight + " x " + Console.WindowWidth);
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.Clear();
# endregion Size
# region Color
Console.WriteLine("You can also change the Background and Foreground colors of the Console using one of the following color values:");
Console.WriteLine();
foreach (string colorName in Enum.GetNames(typeof(ConsoleColor)))
{
Console.Write(colorName + ", ");
}
Console.WriteLine();
Console.Write("Enter the new Background Color:");
try
{
string newBackgroundColor = Console.ReadLine();
Console.BackgroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), newBackgroundColor, true);
}
catch
{
Console.Write("You entered an incorrect color choice. I will set the background to Green for you");
Console.BackgroundColor = ConsoleColor.Green;
}
Console.Write("Enter the new Foreground Color:");
try
{
string newForegroundColor = Console.ReadLine();
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), newForegroundColor, true);
}
catch
{
Console.Write("You entered an incorrect color choice. I will set the foregound to Yellow for you");
Console.ForegroundColor = ConsoleColor.Yellow;
}
Console.Clear();
Console.WriteLine("You can see how the new colors are applied");
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
Console.Clear();
# endregion Color
# region Buffer
Console.WriteLine("In addition to the Window size you can also change the buffer size");
Console.WriteLine("The buffer size can not be smaller than the window size");
int newBufferWidth;
int newBufferHeight;
Console.Write("Enter the new buffer height: ");
try
{
newBufferHeight = Int16.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the buffer height to 50 for you");
newBufferHeight = 50;
}
Console.Write("Enter the new buffer width: ");
try
{
newBufferWidth = Int16.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the buffer width to 120 for you");
newBufferWidth = 120;
}
if (newBufferWidth < Console.WindowWidth)
newBufferWidth = Console.WindowWidth;
if (newBufferHeight < Console.WindowHeight)
newBufferHeight = Console.WindowHeight;
Console.SetBufferSize(newBufferWidth, newBufferHeight);
Console.Write("New Buffer size is: " + Console.BufferWidth + " x " + Console.BufferHeight);
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.Clear();
Console.WindowWidth = 120;
Console.WindowHeight = 40;
Console.BufferWidth = 120;
Console.BufferHeight = 40;
Console.WriteLine("@@@@@@@@@@");
Console.WriteLine("@@@@@@@@@@");
Console.WriteLine("@@@@@@@@@@");
Console.WriteLine("@@@@@@@@@@");
Console.WriteLine("@@@@@@@@@@");
Console.WriteLine("You can also move part of the buffer");
Console.WriteLine("The area above is a 10 x 5 matrix");
Console.WriteLine("We will move it from the top left to the bottom right");
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.MoveBufferArea(0, 0, 10, 5, Console.BufferWidth - 10, Console.BufferHeight - 5);
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.Clear();
# endregion Buffer
# region Cursor
Console.SetWindowSize(120, 40);
Console.WriteLine("With the new Console class you can also change the cursor postions, size and make the cursor invisible");
Console.WriteLine();
Console.WriteLine("The beginning of this line is at Left = " + Console.CursorLeft + " Top = " + Console.CursorTop);
Console.WriteLine();
Console.WriteLine("Press Enter to move the cursor to Left = 20, top = 20");
Console.ReadLine();
Console.CursorLeft = 20;
Console.CursorTop = 20;
Console.Write("The beginning of this line is at Left = " + Console.CursorLeft + " Top = " + Console.CursorTop);
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.Clear();
Console.WriteLine("Adjusting the Cursor size and visibility");
Console.WriteLine();
Console.WriteLine("The cursor size is now = " + Console.CursorSize);
Console.WriteLine();
int newCursorSize;
Console.Write("Enter the new cursor size: ");
try
{
newCursorSize = Int32.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the cursor size to 60 for you");
newCursorSize = 60;
}
if (newCursorSize <= 0 | newCursorSize > 100)
{
Console.WriteLine("The cursor size must be between 1 and 100. I will set the cursor size to 50 for you");
newCursorSize = 50;
}
Console.CursorSize = newCursorSize;
Console.WriteLine();
Console.WriteLine("The cursor size is now = " + Console.CursorSize);
Console.WriteLine();
Console.Clear();
Console.WriteLine("The cursor can be made invisible");
Console.CursorVisible = false;
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.WriteLine("And visible again");
Console.CursorVisible = true;
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.Clear();
Console.Clear();
# endregion Cursor
# region Beep
Console.WriteLine("Adjusting the Beep frequency and duration");
Console.WriteLine();
int frequency;
int duration;
Console.Write("Enter a frequency value between 37 and 32767: ");
try
{
frequency = Int32.Parse(Console.ReadLine());
if (frequency < 37 | frequency > 32767)
{
Console.WriteLine("You entered an incorrect value. I will set the frequency to 1000 for you");
frequency = 1000;
}
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the frequency to 1000 for you");
frequency = 1000;
}
Console.WriteLine();
Console.Write("Enter a duration in milliseconds (1000 = 1 second): ");
try
{
duration = Int32.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You entered an incorrect value. I will set the duration to 500 for you");
duration = 500;
}
Console.Beep(frequency, duration);
Console.WriteLine();
Console.WriteLine("Press Enter to continue");
Console.ReadLine();
Console.Clear();
# endregion Beep
Console.WriteLine();
Console.WriteLine("Press Enter to end this demo");
Console.ReadLine();
}
static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
{
Console.WriteLine("Now CTRL+C is used as the cancel key");
Console.ReadLine();
e.Cancel = true;
}
}
}
2008年8月14日星期四
Bookmarks
-
个性网站
- Defrag Magazine
- Greetings from MIX.COM !!
- MIX MIX Online
- [ City Corner - 都市的角落裡... ]
- 个性网站 - Google 搜索
- Greetings from MIX.COM !!
-
丽水
-
免费域名
-
my
- 2008万网CN英文域名免费注册体验活动-优惠促销-中国万网(www.net.cn)
- www.1a.cn
- www.5944.net
- www.gnway.com
- www.oray.cn
- 以勒科技(www.yileidc.com)---电信IDC数据中心 服务器租用,主机托管,整机租用,域名注册,虚拟主机,软件开发,网站推广,电子商务信息服务平台,上海网站制作,上海服务器托管,上海服务器租用
- 欢迎访问备案网站管理系统
- www.1a.cn
-
基金
-
娱乐
-
学校
-
广告联盟系统
-
新闻报纸
-
游戏网游
- 17173.com网络游戏第一门户站
- 52pk游戏网
- CEG电子竞技中文门户
- Gamesh.com 上游游戏中心
- VS竞技游戏平台
- 亿赛网
- 太平洋游戏网
- 新浪游戏
- 浩方对战平台
- 游戏_天极Yesky
- 网易游戏频道
- 联众世界-快乐每一天!
- 腾讯游戏频道
- 雅虎游戏
- 52pk游戏网
-
爱国者安全
- 2008年3月14,15日本周五,六VIP授课通知(密码1415)[爱国者安全论坛]
- dvd论坛
- Foundstone - A division of McAfee
- mail
- 新手
- 爱国者安全网-会员800G资源下载中心
- 短训班
- 首页
- dvd论坛
-
电脑网络
-
免费邮箱
-
博客空间
-
电脑教程
- eNet网络学院
- ezIT学院频道
- goEway.com
- 中华网--科技频道--网络教室
- 天极网---软件频道
- 巧巧读书-电脑教程
- 洪恩在线 - 电脑乐园
- 电脑爱好者之家
- 科技时代首页
- 网易学院
- 网狐学园-搜狐IT
- 豆豆技术网-
- ezIT学院频道
-
电脑硬件
-
系统光盘
- 17173.com网络游戏第一门户站
- CBINEWS-电脑商情在线
- eNet硅谷动力
- IT 数 码
- ZDNet China Home Page
- 中国IT权威门户-赛迪网(ccidnet.com)
- 互联网实验室(chinalabs.com)
- 天极ChinaByte_中国的中文电脑科技资讯网
- 天极Yesky_全球中文IT第一门户
- 太平洋电脑网 PConline.com.cn-IT世界 由此精彩
- 泡泡网_PCPOP.COM_帮你正确购买和使用IT产品
- 电脑之家 PChome 科技引领生活
- 计世网--专业价值 行业网群--首页
- CBINEWS-电脑商情在线
-
论坛系列
- BT之家
- Discuz! Board PHPBBS论坛
- PCPChina 先锋网
- [THEMEX.NET 极限主题] - powered by vBulletin
- [THEMEX.NET 极限主题]
- ≡ 拂晓雅阁 ≡
- 姑苏生活论坛
- 安兴论坛
- 手机论坛
- 无忧团购网-篱笆论坛
- 星星精品论坛
- 汉化新世纪论坛
- 深度技术论坛
- 狂人论坛
- 番茄花园论坛
- 穆族社区
- 索迪论坛
- 胡同口 - 西祠胡同
- 落伍者 im286.com
- 赢征天下论坛
- 雷傲超级论坛
- 霏凡论坛
- 龙族联盟论坛
- Discuz! Board PHPBBS论坛
-
银行网站
-
门户
- 20Click
- 51web
- MENSTYLE
- Mofile网络硬盘
- MyBtDB.com
- oBlog--后台管理
- Oblog官方中文网—中国最专业的博客系统提供商
- PC蛋蛋
- PC蛋蛋幸运28每日数据分析图
- Uspace官方站点 ---- 全球第一套Web2.0全面解决方案
- VeryCD
- vgimm.com
- www.shedewang.cn
- 一呼百应 更懂商机——专业供求信息搜索引擎
- 丁香鱼工作室——瑞星
- 世界编程大赛头名程序-太平洋电脑网Pconline-[其它平台]
- 世纪东方--虚拟主机全国9强!
- 中国站长论坛
- 天眼通官方网 - 远程视频强制监控连接...... QQ暴力强制视频.远程视频强制监控连接..免费视频远程嗅探强制连接
- 好空间虚拟主机运营网
- 开复学生网
- 快门
- 我的图书馆登录
- 方乾坤Blog
- 李开复给中国学生的六封信_网易教育
- 电子样本
- 舍得网
- 返利网
- 连线速度
- 金山爱词霸在线翻译
- 51web
订阅:
博文 (Atom)