求使用C#控制台程序仿制windows多系统选择的界面的源代码!
就是可以多选一的界面,仿照windows多系统选择界面,选中行高亮。各行均为网址。选中行后输入回车或者使用鼠标点击某行后,调用Explorer显示网址内容。最好提供源代码...
就是可以多选一的界面,仿照windows多系统选择界面,选中行高亮。各行均为网址。选中行后输入回车或者使用鼠标点击某行后,调用Explorer显示网址内容。
最好提供源代码。
多谢!!! 展开
最好提供源代码。
多谢!!! 展开
1个回答
展开全部
using System;
using System.Collections.Generic;
using System.Text;
namespace TestConsoleMenu
{
class Program
{
static int iCurrent = 0;
static string[] strUrlArr = null;
static void Main(string[] args)
{
strUrlArr = new string[] {
"http://www.163.com",
"http://www.baidu.com",
"http://www.sohu.com"
};
Output();
bool blnSelectOK = false;
ConsoleKeyInfo ki = Console.ReadKey(true);
while (!blnSelectOK)
{
switch (ki.Key)
{
case ConsoleKey.NumPad1:
iCurrent = 1;
break;
case ConsoleKey.NumPad2:
iCurrent = 2;
break;
case ConsoleKey.NumPad3:
iCurrent = 3;
break;
case ConsoleKey.UpArrow:
iCurrent--;
if (iCurrent < 1) iCurrent += 3;
break;
case ConsoleKey.DownArrow:
iCurrent++;
if (iCurrent > 3) iCurrent -= 3;
break;
case ConsoleKey.Enter:
if (iCurrent == 0)
{
Console.Beep();
}
else
{
blnSelectOK = true;
LoadSelect();
}
break;
default:
Console.Beep();
break;
}
Output();
ki = Console.ReadKey(true);
}
}
static void Output()
{
Console.Clear();
Console.WriteLine("Please Select Menu:");
Console.WriteLine("");
for (int i = 0; i < strUrlArr.Length; i++)
{
if (i + 1 == iCurrent)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Gray;
}
Console.WriteLine(" {0}. {1}", i + 1, strUrlArr[i]);
Console.ResetColor();
}
Console.WriteLine("");
Console.WriteLine("Please Press 1-3 or UP DOWN key to select");
}
static void LoadSelect()
{
Console.WriteLine("");
Console.WriteLine("Loading url {0} ....", strUrlArr[iCurrent - 1]);
Console.ReadKey();
}
}
}
自己再进一步完善吧。
using System.Collections.Generic;
using System.Text;
namespace TestConsoleMenu
{
class Program
{
static int iCurrent = 0;
static string[] strUrlArr = null;
static void Main(string[] args)
{
strUrlArr = new string[] {
"http://www.163.com",
"http://www.baidu.com",
"http://www.sohu.com"
};
Output();
bool blnSelectOK = false;
ConsoleKeyInfo ki = Console.ReadKey(true);
while (!blnSelectOK)
{
switch (ki.Key)
{
case ConsoleKey.NumPad1:
iCurrent = 1;
break;
case ConsoleKey.NumPad2:
iCurrent = 2;
break;
case ConsoleKey.NumPad3:
iCurrent = 3;
break;
case ConsoleKey.UpArrow:
iCurrent--;
if (iCurrent < 1) iCurrent += 3;
break;
case ConsoleKey.DownArrow:
iCurrent++;
if (iCurrent > 3) iCurrent -= 3;
break;
case ConsoleKey.Enter:
if (iCurrent == 0)
{
Console.Beep();
}
else
{
blnSelectOK = true;
LoadSelect();
}
break;
default:
Console.Beep();
break;
}
Output();
ki = Console.ReadKey(true);
}
}
static void Output()
{
Console.Clear();
Console.WriteLine("Please Select Menu:");
Console.WriteLine("");
for (int i = 0; i < strUrlArr.Length; i++)
{
if (i + 1 == iCurrent)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.BackgroundColor = ConsoleColor.Gray;
}
Console.WriteLine(" {0}. {1}", i + 1, strUrlArr[i]);
Console.ResetColor();
}
Console.WriteLine("");
Console.WriteLine("Please Press 1-3 or UP DOWN key to select");
}
static void LoadSelect()
{
Console.WriteLine("");
Console.WriteLine("Loading url {0} ....", strUrlArr[iCurrent - 1]);
Console.ReadKey();
}
}
}
自己再进一步完善吧。
参考资料: 个人经验
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询