zoukankan      html  css  js  c++  java
  • WPF命令提示符

    Sample Image - maximum width is 600 pixels 介绍 WPF命令提示符是一个命令行控制台,附带了许多功能,包括: 保存/加载不同的控制台设置(或使用内部默认值)保存/加载不同的命令historiesSave /负载风格主题(或者使用内部默认值)消息区域背景颜色、字体、字体大小、字体颜色、边框大小/颜色和填充大小手动或使用themesCommand提示背景颜色、字体、字体大小、字体颜色、边框大小/颜色和填充大小手动或使用themesInternal或外部命令parsingCommand历史功能 基本布局在用户控件中有一个消息区(RichTextBox)和一个命令提示区(TextBox)。我保持命令提示符在窗口的底部,因为有一个调整大小的问题,我还没有解决。但是,在使用了一段时间之后,我发现我还是更喜欢窗口底部的命令提示符。提示文本(例如:"C: MyStuff>")在命令提示符区域中被保护,以供最终用户更改或删除。 Sample Image - maximum width is 600 pixels 消息区包括两个区域,消息提示区和消息文本区: Sample Image - maximum width is 600 pixels 消息提示区域包含从命令提示符输入的文本。消息文本包含写入控制台的文本。 为简洁起见,这里并没有显示所有的属性/方法。WPFCommandPrompt的完整MSDN风格文档可以在http://cgdn.blogdns.net:8080/找到。有关大部分功能的示例,请参阅项目演示。这个项目也可以从我的网站http://codegravy.dyndns.org:8080/下载。 背景 WPF命令提示符是我几个月前开始的一个项目的最终结果,当时我需要一个控制台应用程序,我正在进行的一个项目。 使用的代码 创建一个新的命令提示符非常简单: 隐藏,复制Code

    using WPFCommandPrompt;
    
    WPFPrompt commandPrompt = new WPFPrompt();
    commandPrompt.ReadLine += new ReadLineEventHandler(ProcessCommand);
    commandPrompt.Show();
    
    private void ProcessCommand(object sender, ConsoleReadLineEventArgs e)
    {
        // Process commands sent from the console here
    }
    
    public void WriteLine(string output)
    {
        commandPrompt.WriteLine(output);
    }

    有两个构造函数可供选择: 隐藏,复制Code

    public WPFPrompt() 	// Uses default style theme: styleThemeIndex = 0
    public WPFPrompt(int styleThemeIndex) // The index of the style theme to use

    写入到控制台: 隐藏,复制Code

    // Sends a string to the console.
    public void WriteLine(string output)
    
    // Sends a string with specified brush color to the console.
    public void WriteLine(string output, Brush foreground)
    
    // Sends a FlowDocument paragraph to the console.
    public void WriteLine(Paragraph paragraph)
    
    // Sends a ConsoleWriteLineEventArgs object to the console.
    public void WriteLine(object sender, ConsoleWriteLineEventArgs e)

    以下基本属性可以在不创建控制台窗口的情况下设置,如果不设置或使用默认值,可以从磁盘保存/加载: 隐藏,收缩,复制Code

    // Allow an empty command to be written to the message area. (Default: false).
    public bool AllowEmptyCommand
    
    // The window title
    public string ConsoleTitle 
    
    // The assembly version of the console
    public string ConsoleVersion 
    
    // Gets or sets the default console height
    public double DefaultConsoleHeight 
    
    // Gets or sets the default console width
    public double DefaultConsoleWidth
    
    // Gets or sets the default prompt string (Default: >)
    public string DefaultPrompt
    
    // Gets or sets the delimiter regular expression string. 
    // Default: ((""((?<token>.*?)"")|(?<token>[w]+))(s)*)
    public string Delimiters
    
    // Enable or disable the command history (Default: true = enabled)
    public bool EnableCommandHistory
    
    // Automatically try to load the style themes on console startup
    public bool EnableLoadStyleThemes
    
    // Is the command history managed by the console(auto) 
    // or by the user(manual) (Default: false = auto) 
    public bool ManualCommandHistory
    
    // Gets or sets the maximum console height. Default is 0, no max size.
    public double MaxConsoleHeight
    
    // Gets or sets the maximum console width. Default is 0, no max size.
    public double MaxConsoleWidth
    
    // Gets or sets the maximum allowed font size of the console.
    public double MaxFontSize
    
    // Gets or sets the minimum console height. Default is 400.
    public double MinConsoleHeight
    
    // Gets or sets the minimum console width. Default is 600.
    public double MinConsoleWidth
    
    // Gets or sets the minimum allowed font size of the console.
    
    // Gets or sets the current prompt string
    public string Prompt
    
    // Gets or sets the default style theme index number.
    public int StyleThemeIndex
    
    // Gets or sets the welcome message. Displayed upon console startup.
    public string WelcomeMessage
    
    // Should the console parse commands internally. Default: true.
    // If false, the user is responsible for parsing the returned command string.
    public bool UserInternalCommandParsing

    风格主题-任何改变的主题不会改变原来的主题。调用UpdateStyleTheme()将当前主题的任何更改复制到原始主题,或者调用CurrentThemeToNew()从当前主题和所有更改中创建一个新主题。在调用UpdateStyleTheme()或CurrentThemeToNew()后,调用SaveStyleThemes()来保存到磁盘。请注意,所提供的样式主题看起来不错,但还远远不够好,因为我在UI功能方面做得比在美观方面做得好得多。如果有人创造了一些好看的主题,请在这里与大家分享! 的兴趣点 尽管我认为在某些类中有太多的代码,但它工作得很好。我以后会考虑重新做这件事:)。 历史 当前版本1.0 本文转载于:http://www.diyabc.com/frontweb/news5394.html

  • 相关阅读:
    Java笔记(一)Eclipse 操作MySQL数据库的效率问题
    C# 笔记(六)关于switch 语句
    C# 笔记(五)关于static
    arcgis server 9.3初步
    C# 笔记(三)关于结构体变量
    OpenBSD随笔(一)
    Windows 脚本WSH
    Java笔记(二)Eclipse 连接SQlServer
    ArcGIS Server 9.3 JavaScript API实战(二)一个具体的小系统示例介绍
    C#笔记(二)类型转换
  • 原文地址:https://www.cnblogs.com/Dincat/p/13462883.html
Copyright © 2011-2022 走看看