• 大小: 0.12M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-10
  • 语言: 其他
  • 标签: 其他  

资源简介

ConsuleUI.zip

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
namespace ConsoleUI
{
    public class ConsoleTextBox : RichTextBox
    {
        public ConsoleTextBox()
        {
            this.KeyDown += new KeyEventHandler(ConsoleTextBox_KeyDown);
            this.LanguageOption = RichTextBoxLanguageOptions.UIFonts;
            this.WordWrap = false;
        }




        //防闪操作
        [DllImport(“user32.dll“)]
        private static extern int SendMessage(IntPtr hwnd int wMsg int wParam IntPtr lParam);
        private const int WM_SETREDRAW = 0xB;

        internal string _headText = ““;
        string CommandStr = ““;//获取的命令
        List commandList = new List();

        #region 属性与事件
        /// 
        /// 用于表示命令行前缀
        /// 

        public string HeadText { get { return _headText; } set { _headText = value; } }
        /// 
        /// 当前可以输入命令的行号
        /// 

        public int InputLineNum { get; private set; }

        /// 
        /// 发送数据的事件
        /// 

        public event OnMessageArrivalHandler ReadCommandtEvent;

        #endregion

        /// 
        /// 用于插入头部数据配合HeadText使用
        /// 

        private void InsertHeadText()
        {
            this.AppendText(HeadText);
        }
        /// 
        /// 增加命了前置
        /// 

        internal void AddNewLine()
        {
            //命令为空
            CommandStr = string.Empty;
            //加入新的行
            this.AppendText(“\n“);
            InsertHeadText();
            InputLineNum = this.Lines.Length - 1;
            this.Focus();

        }
        //输出数据触发器
        private void ReadCommadeText()
        {
            if (ReadCommandtEvent != null)
            {
                if (!string.IsNullOrEmpty(CommandStr) && !commandList.Contains(CommandStr))
                {
                    commandList.Add(CommandStr);
                    ItemIndex++;
                }
                ReadCommandtEvent(this ConsoleEditEventArgs.CreatEventArgs(CommandStr));
            }
        }


        private void UpdateLog(bool isUp)
        {
            if (commandList.Count == 0)
                return;
            string tmpStr = this.Text;
            int offset = tmpStr.LastIndexOf(HeadText);
            offset += HeadText.Length;
            SendMessage(this.Handle WM_SETREDRAW 0 IntPtr.Zero);
            if (offset == tmpStr.Length)
            {
                this.Text = tmpStr + GetItemStr(isUp);
            }
            else
            {
                tmpStr = tmpStr.Remove(offset);
                this.Text = tmpStr + GetItemStr(isUp);
            }
            SendMessage(this.Handle WM_SETREDRAW 1 IntPtr.Zero);
            this

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-04-19 14:14  ConsuleUI\
     目录           0  2013-04-19 14:11  ConsuleUI\ConsoleUI\
     文件       15844  2013-04-19 14:11  ConsuleUI\ConsoleUI.png
     文件        2539  2013-03-28 10:39  ConsuleUI\ConsoleUI.sln
     文件       40960  2013-04-19 14:11  ConsuleUI\ConsoleUI.suo
     目录           0  2013-04-19 14:11  ConsuleUI\ConsoleUI\bin\
     目录           0  2013-04-19 14:11  ConsuleUI\ConsoleUI\bin\Debug\
     文件       13824  2013-04-19 14:06  ConsuleUI\ConsoleUI\bin\Debug\ConsoleUI.dll
     文件       32256  2013-04-19 14:06  ConsuleUI\ConsoleUI\bin\Debug\ConsoleUI.pdb
     目录           0  2013-03-27 00:26  ConsuleUI\ConsoleUI\bin\Release\
     文件        6532  2013-04-19 13:44  ConsuleUI\ConsoleUI\ConsoleTextBox.cs
     文件        2959  2013-04-19 11:03  ConsuleUI\ConsoleUI\ConsoleUI.csproj
     文件        6458  2013-04-19 13:43  ConsuleUI\ConsoleUI\NumberedConsoleTextBox.cs
     文件        5292  2013-04-19 13:36  ConsuleUI\ConsoleUI\NumberedConsoleTextBox.Designer.cs
     文件        6535  2013-04-19 13:34  ConsuleUI\ConsoleUI\NumberedConsoleTextBox.resx
     目录           0  2013-04-19 14:11  ConsuleUI\ConsoleUI\obj\
     目录           0  2013-04-19 14:11  ConsuleUI\ConsoleUI\obj\Debug\
     文件         836  2013-04-19 13:35  ConsuleUI\ConsoleUI\obj\Debug\ConsoleUI.csproj.FileListAbsolute.txt
     文件       13824  2013-04-19 14:06  ConsuleUI\ConsoleUI\obj\Debug\ConsoleUI.dll
     文件         180  2013-04-19 13:34  ConsuleUI\ConsoleUI\obj\Debug\ConsoleUI.NumberedConsoleTextBox.resources
     文件       32256  2013-04-19 14:06  ConsuleUI\ConsoleUI\obj\Debug\ConsoleUI.pdb
     文件         529  2013-03-27 00:15  ConsuleUI\ConsoleUI\obj\Debug\ConsuleUI.csproj.FileListAbsolute.txt
     文件        4508  2013-04-19 12:20  ConsuleUI\ConsoleUI\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        5872  2013-04-19 14:11  ConsuleUI\ConsoleUI\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件        3814  2013-04-19 13:34  ConsuleUI\ConsoleUI\obj\Debug\GenerateResource-ResGen.read.1.tlog
     文件         294  2013-04-19 13:34  ConsuleUI\ConsoleUI\obj\Debug\GenerateResource-ResGen.write.1.tlog
     目录           0  2013-03-26 12:29  ConsuleUI\ConsoleUI\obj\Debug\TempPE\
     文件         517  2013-03-27 12:04  ConsuleUI\ConsoleUI\OnMessageArrivalHandler.cs
     目录           0  2013-04-19 14:11  ConsuleUI\ConsoleUI\Properties\
     文件        1416  2013-04-19 14:06  ConsuleUI\ConsoleUI\Properties\AssemblyInfo.cs
     文件       38912  2013-03-28 10:38  ConsuleUI\ConsuleUI.suo
............此处省略35个文件信息

评论

共有 条评论