Giter VIP home page Giter VIP logo

simple.wpf.terminal's Introduction

Simple.Wpf.Terminal

NuGet Build status

Supported versions:

.NET Framework 4.7 and higher,
.Net Core 3.1 and higher,
.Net 5.0 and higher

A simple console\terminal window for use in a WPF application, this is a user control that will allow the user to enter a line of text (script\command) and\or display a list of items in a console\terminal style.

This user control does NOT actually do anything more than display data - the user control is the View (UI) in a MVVM implementation, the ViewModel would be responsible for the actual behaviour & contents of the console\terminal window. The user control is designed to use XAML binding for all UI properties the user can configure.

The control supports theming and there are a couple of example themes supplied in the Simple.Wpf.Terminal.Themes project.

For more information about the releases see [Release Info] (https://github.com/oriches/Simple.Wpf.Terminal/wiki/Release-Info).

For more information about the styling the control see [Style Info] (https://github.com/oriches/Simple.Wpf.Terminal/wiki/Style-Info).

Currently we support the following .Net versions:

This library is available as a nuget [package] (https://www.nuget.org/packages/Simple.Wpf.Terminal/).

Examples of usage:

Custom F# Interactive window in a WPF application

alt text

The XAML is shown below:

<t:Terminal x:Name="TerminalOutput"
            IsReadOnlyCaretVisible="False"
            VerticalScrollBarVisibility="Visible"
            Style="{DynamicResource ReplTerminalStyle}"
            IsReadOnly="{Binding Path=IsReadOnly, Mode=OneWay}"
            Prompt="{Binding Path=Prompt, Mode=OneWay}"
            ItemsSource="{Binding Path=Output, Mode=OneWay}"
            ItemDisplayPath="Value">

        <t:Terminal.InputBindings>
            <KeyBinding Command="{Binding Path=ClearCommand, Mode=OneWay}"
                        Gesture="CTRL+E" />
            <KeyBinding Command="{Binding Path=ResetCommand, Mode=OneWay}"
                        Gesture="CTRL+R" />
            <KeyBinding Command="{x:Null}"
                        Gesture="CTRL+L" />
        </t:Terminal.InputBindings>

        <t:Terminal.ContextMenu>
            <ContextMenu>
                <MenuItem Header="Clear"
                          InputGestureText="Ctrl+E"
                          Command="{Binding Path=ClearCommand, Mode=OneWay}" />
                <MenuItem Header="Reset"
                          InputGestureText="Ctrl+R"
                          Command="{Binding Path=ResetCommand, Mode=OneWay}" />
                <Separator />
                <MenuItem Header="Copy"
                          InputGestureText="Ctrl+C"
                          Command="ApplicationCommands.Copy" />
                <MenuItem Header="Paste"
                          InputGestureText="Ctrl+V"
                          Command="ApplicationCommands.Paste" />
                <Separator />
                <MenuItem Header="Open Working Folder"
                          Command="{Binding Path=OpenWorkingFolderCommand, Mode=OneWay}" />
           </ContextMenu>
        </t:Terminal.ContextMenu>

        <i:Interaction.Triggers>
            <i:EventTrigger EventName="LineEntered">
                <i:InvokeCommandAction Command="{Binding Path=ExecuteCommand, Mode=OneWay}"
                                       CommandParameter="{Binding Path=Line, Mode=OneWay, ElementName=TerminalOutput}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

</t:Terminal>

An example of the Terminal Style (ReplTerminalStyle) is shown below and is available at the link below the example:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:terminal="clr-namespace:Simple.Wpf.Terminal;assembly=Simple.Wpf.Terminal"
                    xmlns:ui="clr-namespace:Simple.Wpf.FSharp.Repl.UI;assembly=Simple.Wpf.FSharp.Repl">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Simple.Wpf.FSharp.Repl;component/UI/DefaultTheme.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <ui:LineColorConverter x:Key="LineColorConverter"
                           Normal="DeepSkyBlue"
                           Error="Red"/>

    <Style x:Key="ReplTerminalStyle"
           TargetType="{x:Type terminal:Terminal}"
           BasedOn="{x:Null}">
        <Setter Property="BorderThickness"
                Value="0" />
        <Setter Property="Background"
                Value="Black" />
        <Setter Property="Foreground"
                Value="DeepSkyBlue" />
        <Setter Property="LineColorConverter"
                Value="{StaticResource LineColorConverter}" />
        <Setter Property="ItemsMargin"
                Value="5" />
        <Setter Property="ItemHeight"
                Value="10" />
    </Style>

</ResourceDictionary>

The code for this is available here - https://github.com/oriches/Simple.Wpf.FSharp.Repl

In-app Log viewer in a WPF application

alt text

The XAML is shown below:

<ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Simple.Wpf.Terminal.Themes;component/BlueTheme.xaml" />
</ResourceDictionary.MergedDictionaries>
    
<terminal:Terminal x:Name="LoggingTerminal"
		   Margin="5"
		   IsReadOnly="True"
		   VerticalScrollBarVisibility="Visible"
		   Prompt="{Binding Path=Prompt, Mode=OneTime}"
		   ItemsSource="{Binding Path=Entries, Mode=OneWay}"/>

The code for this is available here - https://github.com/oriches/Simple.Wpf.Composition

I'd be interested to hear about other uses :)

simple.wpf.terminal's People

Contributors

oriches avatar aleladestudio avatar carlprentice avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.