ã³ã³ãœãŒã«ã®è±å¯ãªæžåŒèšå®ããŒã«ãç¥ã£ãŠããŸãïŒã¹ããŒã¹ãšã®æŽåãããã¹ããšèæ¯ã®çŸåšã®è²ã®å€æŽã æ°è¡ãå°å·ãããå Žåã¯ãããã§ååã§ãããã ããã¹ããŒã¹ã«ãããã€ãããŒã·ã§ã³ã®æ¬ åŠã¯æã«ã¯é¢åã§ãã ããŒãã«ã衚瀺ããå¿ èŠãããå Žåã¯ãåã®å¹ ãæåã§èšç®ããå¿ èŠããããå€ãã®å Žåãå¹ ãããŒãã³ãŒãããã ãã§ãã åºåãè²ä»ãããå¿ èŠãããå Žåã¯ãç¡éã®åãæ¿ããšè²å埩ã䜿çšããŠããã¹ãåºåãã¹ããªãŒã¯ããå¿ èŠããããŸãã ãã€ãããŒã·ã§ã³ã䜿çšããŠããã¹ãã衚瀺ããããäžèšã®ãã¹ãŠãçµã¿åãããå¿ èŠãããå Žå...
ã³ãŒãã¯ããã«å€èªäžèœãªæ··ä¹±ã«å€ãããŸãããããã¯ããããŸãããã©ãã«ããžãã¯ããããã©ãã«ããã¹ãããããã©ãã«ãã©ãŒãããããããŸãã ããã¯ã²ã©ãã§ãïŒ GUIãäœæãããšããMV *ãã¿ãŒã³ããã€ã³ãã£ã³ã°ããã®ä»ã®ã¯ãŒã«ãªãã®ãªã©ãã¢ãã³ãã¶ã€ã³ã®é åãèªç±ã«äœ¿çšã§ããŸãã GUIã䜿çšããåŸãã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ã®äœæã¯ãç³åšæ代ã«æ»ãããšã«äŒŒãŠããŸãã
CsConsoleFormatãå©ãã«ãªããŸãïŒ
ç¹åŸŽ
- HTMLã®èŠçŽ ïŒæ®µèœãã¹ãã³ãè¡šããªã¹ããå¢çç·ãåºåãæåã
- ã¬ã€ã¢ãŠã ïŒããŒãã«ïŒã°ãªããïŒããã€ã«ïŒã¹ã¿ãã¯ïŒããã«ã¯ãïŒããã¯ïŒããã€ãããŒã·ã§ã³ïŒã©ããïŒãã¢ããœãªã¥ãŒãïŒãã£ã³ãã¹ïŒã
- ããã¹ãã®æžåŒèšå® ïŒããã¹ããšèæ¯è²ããã€ãããŒã·ã§ã³ãã¯ãŒãã©ããã³ã° ã
- Unicodeæåãã©ãŒããã ïŒãã€ãã³ããœãããã€ãã³ãæ¹è¡ãªããã€ãã³ãã¹ããŒã¹ãæ¹è¡ãªãã¹ããŒã¹ãå¹ ãŒãã®ã¹ããŒã¹ã
- ããã€ãã®æ§æ ïŒä»¥äžãåç
§ïŒïŒ
- WPFã®ããã« ïŒããããã£ãã§ãŒã³ïŒ1åéãã®ãã€ã³ãã£ã³ã°ïŒããªãœãŒã¹ãã³ã³ããŒã¿ãŒãæ·»ä»ããããã£ã®å€ãååŸããXAMLããªãœãŒã¹ããããã¥ã¡ã³ããèªã¿èŸŒãã
- LINQ to XMLã®ããã« ïŒCïŒãªããžã§ã¯ãåæååãæ¡åŒµã¡ãœãããŸãã¯ã€ã³ãã¯ãµãŒã«ããæ·»ä»ããããã£ã®èšå®ãèŠçŽ ã®ãªã¹ããæãããã¿ããªããžã§ã¯ããæååã«å€æããŠãµãèŠçŽ ãè¿œå ããŸãã
- æç» ïŒæ¬äŒŒã°ã©ãã£ãã¯ã·ã³ãã«ãè²å€æïŒããæãããããæãïŒãããã¹ãåºåã«åºã¥ã幟äœåŠçããªããã£ãïŒç·ãé·æ¹åœ¢ïŒã
- åœéå ïŒæåã¯ãä»»æã®èŠçŽ ã®ã¬ãã«ã§åå®çŸ©ã§ããŸãã
- å€ãã®åœ¢åŒã«ãšã¯ã¹ããŒã ïŒãšã¹ã±ãŒãã·ãŒã±ã³ã¹ãå«ãããã¹ããæžåŒãªãããã¹ããHTMLã RTFãXPFãWPF FixedDocumentãWPF FlowDocumentïŒWPFãå¿ èŠïŒã
- JetBrains RïŒæ³šé ïŒCanBeNullãNotNullãValueProviderãªã©ã
- WPF ïŒããã¥ã¡ã³ããããã¥ã¡ã³ãã³ã³ããŒã¿ãŒãã€ã¡ãŒãžã€ã³ããŒãã衚瀺ããããã®ã³ã³ãããŒã«ã
䜿ãæ £ããã¯ã©ã¹OrderãOrderItemãCustomerããããšããŸãã 泚æã詳现ã«è¡šç€ºããããã¥ã¡ã³ããäœæããŸãããã 䜿çšå¯èœãªæ§æã¯2ã€ãããããããã䜿çšããããšããçµã¿åãããããšãã§ããŸãã
XAML ïŒa la WPFïŒïŒ
<Document xmlns="urn:alba:cs-console-format" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Span Background="Yellow" Text="Order #"/> <Span Text="{Get OrderId}"/> <Br/> <Span Background="Yellow" Text="Customer: "/> <Span Text="{Get Customer.Name}"/> <Grid Color="Gray"> <Grid.Columns> <Column Width="Auto"/> <Column Width="*"/> <Column Width="Auto"/> </Grid.Columns> <Cell Stroke="Single Wide" Color="White">Id</Cell> <Cell Stroke="Single Wide" Color="White">Name</Cell> <Cell Stroke="Single Wide" Color="White">Count</Cell> <Repeater Items="{Get OrderItems}"> <Cell> <Span Text="{Get Id}"/> </Cell> <Cell> <Span Text="{Get Name}"/> </Cell> <Cell Align="Right"> <Span Text="{Get Count}"/> </Cell> </Repeater> </Grid> </Document>
CïŒ ïŒa LINQ to XMLïŒïŒ
using static System.ConsoleColor; var headerThickness = new LineThickness(LineWidth.Single, LineWidth.Wide); var doc = new Document() .AddChildren( new Span("Order #") { Color = Yellow }, Order.Id, "\n", new Span("Customer: ") { Color = Yellow }, Order.Customer.Name, new Grid { Color = Gray } .AddColumns( new Column { Width = GridLength.Auto }, new Column { Width = GridLength.Star(1) }, new Column { Width = GridLength.Auto } ) .AddChildren( new Cell { Stroke = headerThickness } .AddChildren("Id"), new Cell { Stroke = headerThickness } .AddChildren("Name"), new Cell { Stroke = headerThickness } .AddChildren("Count"), Order.OrderItems.Select(item => new[] { new Cell() .AddChildren(item.Id), new Cell() .AddChildren(item.Name), new Cell { Align = HorizontalAlignment.Right } .AddChildren(item.Count), }) ) );
æ§æéžæ
XAML ïŒa WPFïŒã¯ãã¢ãã«ãšãã¥ãŒãåé¢ããããšãæ確ã«ããŸããããã¯çŸåŸ³ãšèŠãªãããšãã§ããŸãã ãã ããXAMLã¯å³å¯ã«åæå®ãŸãã¯ã³ã³ãã€ã«ãããŠããªããããå®è¡æãšã©ãŒãçºçããå¯èœæ§ããããŸãã æ§æã¯ãããŸãã§ããäžæ¹ã§ãXMLã¯åé·ïŒ <Grid><Grid.Columns><Column/></Grid.Columns></Grid>
ïŒã§ãããäžæ¹ã§ãåæã¬ã³ãŒãïŒ Color="White"
ïŒã§ä¿åã§ããŸããã³ã³ããŒã¿ãŒã䜿çšããŸãïŒ Stroke="Single Wide"
ïŒã
Monoã®XAMLã©ã€ãã©ãªã¯ãããŸãã§å¶éãããŠããŸãã ã¯ãã¹ãã©ãããã©ãŒã ã¢ããªã±ãŒã·ã§ã³ãå¿ èŠãªå ŽåãXAMLã䜿çšãããšåé¡ãçºçããå¯èœæ§ããããŸãã ãã ããWPFã«ç²ŸéããŠããŠãWindowsãµããŒãã®ã¿ãå¿ èŠãªå Žåã¯ãXAMLã¯èªç¶ãªã¯ãã§ãã .NET Standardã®ããŒãžã§ã³ã§ã¯ãPortable.Xamlã©ã€ãã©ãªã䜿çšããŠããŸããããã¯ãããã«åªããŠããã¯ãã§ããããããŸã§ã®ãšãããæŠéç¶æ ã§ååã«ãã¹ããããŠããŸããã
äžè¬çã«ãXAMLã¯Visual StudioãšReSharperã§ã®ã¿éå®çã«ãµããŒããããŠããŸããæ§æã®åŒ·èª¿è¡šç€ºãšã³ãŒãè£å®ã¯éåžžæ©èœããŸããããã€ã³ãã£ã³ã°ãã¹ã®å®äºã¯èæ ®ããããšã©ãŒã匷調衚瀺ãããªãå ŽåããããŸãã ãã ããXAMLã«ç²ŸéããŠãã人ã«ãšã£ãŠã¯ãããã¯æ°ããããšã§ã¯ãããŸããã
CïŒ ïŒa LINQ to XMLïŒã䜿çšãããšããµãèŠçŽ ãè¿œå ãããšãã«LINQãšæãããã¿ãªã¹ãã«ãããã³ãŒãå
ã§ããŸããŸãªå€æãçŽæ¥å®è¡ã§ããŸãã using static
ããµããŒããusing static
CïŒ6 using static
ãusing static
å Žåãããã€ãã®åæãæžããããšãã§ããŸãã 匱ãåä»ããæã€å¯äžã®å Žæã¯ã AddChildren(params object[])
æ¡åŒµAddChildren(params object[])
ïŒãã®äœ¿çšã¯ãªãã·ã§ã³ã§ãïŒã
ã³ãŒãã§ã®ããã¥ã¡ã³ãã®äœæã¯ãã©ã®éçºç°å¢ã§ãå®å šã«ãµããŒããããŠããŸãããReSharperã䜿çšãããšãå€ãã®ããŒãžã§1ã€ã®åŒã§å·šå€§ãªããã¥ã¡ã³ããäœæããããšãããšãã¬ãŒããããããŸãïŒ9çªç®ã®ããŒãžã§ã³ã§ã¯ãã¹ã¿ãžãªããã³ã°ã¢ããããããšããããŸãããããããä»ã§ã¯é¢ä¿ãããŸããïŒã
å®éã®äŸ
Githubãªããžããªã«ã¯ãã·ã¹ãã å ã®çŸåšã®ããã»ã¹ã衚瀺ããæ°ããããã»ã¹ãèµ·åããããã®ãµã³ãã«ã³ã³ãœãŒã«ã¢ããªã±ãŒã·ã§ã³ããããŸãã 次ã®ããã«ãªããŸãã
ãã¹ãŠã®ãã©ãŒãããã¯ã1ã€ã®å°ãããŠã¯ãªã¢ãªãã¡ã€ã«ã«åãŸããŸãã ããã§ã¯ãå¯èœãªãã¹ãŠã®æ¹æ³ã§ãã¡ãã»ãŒãžåºåããšã©ãŒåºåãããã»ã¹ããŒãã«ã®ãã©ãŒããããããã³ãã«ãåºåã確èªã§ããŸãã
ã³ãã³ãã©ã€ã³ãåŠçããã«ã¯ã人æ°ã®ããCommandLineParserã©ã€ãã©ãªãããããã®BaseOptionAttribute
ã¯ã©ã¹ã䜿çšããã1ã€ã®ã³ãã³ããŸãã¯ãã©ã¡ãŒã¿ãŒã«é¢ããæ
å ±ãå«ãŸããŸãã ããã§ã¯CïŒ6ã®ããã€ãã®æ©èœã䜿çšãããŠããŸãããæ®ãã®ã³ãŒãã«ã€ããŠã¯ç¹å¥ãªèª¬æã¯å¿
èŠãªããšæããŸãã
using System.Collections.Generic; using System.Diagnostics; using System.Linq; using CommandLine; using static System.ConsoleColor; internal class View { private static readonly LineThickness StrokeHeader = new LineThickness(LineWidth.None, LineWidth.Wide); private static readonly LineThickness StrokeRight = new LineThickness(LineWidth.None, LineWidth.None, LineWidth.Single, LineWidth.None); public Document Error (string message, string extra = null) => new Document { Background = Black, Color = Gray } .AddChildren( new Span("Error\n") { Color = Red }, new Span(message) { Color = White }, extra != null ? $"\n\n{extra}" : null ); public Document Info (string message) => new Document { Background = Black, Color = Gray } .AddChildren(message); public Document ProcessList (IEnumerable<Process> processes) => new Document { Background = Black, Color = Gray } .AddChildren( new Grid { Stroke = StrokeHeader, StrokeColor = DarkGray } .AddColumns( new Column { Width = GridLength.Auto }, new Column { Width = GridLength.Auto, MaxWidth = 20 }, new Column { Width = GridLength.Star(1) }, new Column { Width = GridLength.Auto } ) .AddChildren( new Cell { Stroke = StrokeHeader, Color = White } .AddChildren("Id"), new Cell { Stroke = StrokeHeader, Color = White } .AddChildren("Name"), new Cell { Stroke = StrokeHeader, Color = White } .AddChildren("Main Window Title"), new Cell { Stroke = StrokeHeader, Color = White } .AddChildren("Private Memory"), processes.Select(process => new[] { new Cell { Stroke = StrokeRight } .AddChildren(process.Id), new Cell { Stroke = StrokeRight, Color = Yellow, TextWrap = TextWrapping.NoWrap } .AddChildren(process.ProcessName), new Cell { Stroke = StrokeRight, Color = White, TextWrap = TextWrapping.NoWrap } .AddChildren(process.MainWindowTitle), new Cell { Stroke = LineThickness.None, Align = HorizontalAlignment.Right } .AddChildren(process.PrivateMemorySize64.ToString("n0")), }) ) ); public Document HelpOptionsList (IEnumerable<BaseOptionAttribute> options, string instruction) => new Document { Background = Black, Color = Gray } .AddChildren( new Div { Color = White } .AddChildren(instruction), "", new Grid { Stroke = LineThickness.None } .AddColumns(GridLength.Auto, GridLength.Star(1)) .AddChildren(options.Select(OptionNameAndHelp)) ); public Document HelpAllOptionsList (ILookup<BaseOptionAttribute, BaseOptionAttribute> verbsWithOptions, string instruction) => new Document { Background = Black, Color = Gray } .AddChildren( new Span($"{instruction}\n") { Color = White }, new Grid { Stroke = LineThickness.None } .AddColumns(GridLength.Auto, GridLength.Star(1)) .AddChildren( verbsWithOptions.Select(verbWithOptions => new object[] { OptionNameAndHelp(verbWithOptions.Key), new Grid { Stroke = LineThickness.None, Margin = new Thickness(4, 0, 0, 0) } .Set(Grid.ColumnSpanProperty, 2) .AddColumns(GridLength.Auto, GridLength.Star(1)) .AddChildren(verbWithOptions.Select(OptionNameAndHelp)), }) ) ); private static object[] OptionNameAndHelp (BaseOptionAttribute option) => new[] { new Div { Margin = new Thickness(1, 0, 1, 1), Color = Yellow, MinWidth = 14 } .AddChildren(GetOptionSyntax(option)), new Div { Margin = new Thickness(1, 0, 1, 1) } .AddChildren(option.HelpText), }; private static object GetOptionSyntax (BaseOptionAttribute option) { if (option is VerbOptionAttribute) return option.LongName; else if (option.ShortName != null) { if (option.LongName != null) return $"--{option.LongName}, -{option.ShortName}"; else return $"-{option.ShortName}"; } else if (option.LongName != null) return $"--{option.LongName}"; else return ""; } }
éæ³
ãããã®èŠçŽ ã®ç©ã¿äžãã¯ã©ã®ããã«æ§ç¯ãããããã¥ã¡ã³ãã«ãªããŸããïŒ é³¥ç°å³ïŒ
- è«çããªãŒã®æ§ç¯ïŒLINQããXMLãžã®å€æã䜿çšããŠã
IEnumerable
ã¯AddChidlren
ããã³ãã®ä»ã®ãã©ã¡ãŒã¿ãŒã§AddChidlren
ãŸãã - ããžã¥ã¢ã«ããªãŒã®æ§ç¯ïŒåèŠçŽ ã¯ããšã³ãžã³ã«ãšã£ãŠäŸ¿å©ãªãã¥ãŒã«å€æãããŸãã
- èŠçŽ ã®ãµã€ãºã®èšç®ïŒåèŠçŽ ã¯ãå¿ èŠãªã¹ããŒã¹ãšåã«äžããã¹ããŒã¹ã決å®ããŸãã
- èŠçŽ ã®äœçœ®ã®èšç®ïŒèŠçŽ ã¯ãåãèªåã®äžã«é 眮ãã座æšã決å®ããŸãã
- ã³ã³ãœãŒã«ãã·ãã¥ã¬ãŒãããä»®æ³ãããã¡ãŒãžã®èŠçŽ ã®ã¬ã³ããªã³ã°ã
- ãããã¡ãŒãå®éã®ã³ã³ãœãŒã«ãŸãã¯ãã®ä»ã®åœ¢åŒã«ã¬ã³ããªã³ã°ããŸãã
ãããŠä»ãåã¢ã€ãã ã«ã€ããŠã®è©³çŽ°ã
è«çããªãŒ
XAMLã§ã®ããã¥ã¡ã³ãã®æ§ç¯ã¯ã {Binding Foo, Mode=OneTime}
代ããã«{Get Foo}
ãš{StaticResource Bar}
代ããã«{StaticResource Bar}
{Res Bar}
ã®ã¿ã䜿çšããŠãWPFã«äŒŒãŠããŸãã ããã®ã³ã³ããŒã¿ãŒã¯ã¯ã©ã¹ã§ã¯ãªãã {Call Baz}
ä»ããŠã¢ã¯ã»ã¹ã§ããåäžã®ã¡ãœããã§ãã WPFã®å Žåãšåæ§ã«ã1ã2ããŸãã¯4ã€ã®æ°åã®æååã䜿çšããŠãããŒãžã³ãšããã£ã³ã°ãèšå®ãããŸãã æ·»ä»ããããã£ã¯ã¯ã©ã¹åã§æå®ãããããããã£ã¯ãããã§æå®ãããŸãã èŠããã«ãWPFã«ç²ŸéããŠãã人ã«ãšã£ãŠã¯ããã¹ãŠã身è¿ã§æ確ã§ãªããã°ãªããŸããã
CïŒã§ã®ããã¥ã¡ã³ãã®æ§ç¯ã¯LINQ to XMLïŒSystem.Xml.LinqïŒã®ç²Ÿç¥ã§è¡ããã params object[]
åŒæ°ãæã€ã³ã³ã¹ãã©ã¯ã¿ãŒã®ä»£ããã«AddChildren
ã¡ãœããïŒããã³AddColumns
ïŒã®ã¿ã䜿çšãããŸãã å©çšå¯èœãªå€æã¯æ¬¡ã®ãšããã§ãã
-
null
èŠçŽ ã¯å®å šã«ç¡èŠãããŸãã ç¹ã«ãããã«ãããäžé æŒç®åã䜿çšããŠæ¡ä»¶ä»ãã§ããã€ãã®èŠçŽ ãå«ããããšãã§ããŸãã -
IEnumerable
ã·ãŒã±ã³ã¹ã¯å±éããããã®èŠçŽ ã代ããã«è¿œå ãããŸãã ã·ãŒã±ã³ã¹ã¯ãã¹ãã§ããŸãã ããšãã°ãããã«ãããAddChildren
1åã®åŒã³åºãã§Select
ã䜿çšããŠãããŒãã«AddChildren
ãšãã®ã³ã³ãã³ããäœæã§ããŸãã - èŠçŽ ã§ã¯ãªããªããžã§ã¯ãã¯æååã«å€æãããŸãã å¯èœã§ããã°ïŒ
IFormattable
ãµããŒãïŒãèŠçŽ ã®ãã±ãŒã«ãèæ ®ããŸãã
WPFã«äžæ
£ããªäººã«ãšã£ãŠã æ·»ä»ããããã£ã®æŠå¿µã¯ãªãã¿ããªããããããŸããã èå¿ãªã®ã¯ãèŠçŽ ã®æ¢åã®ããããã£ãè£å®ããå¿
èŠãããå Žåãããããšã§ããããšãã°ãCanvasã¯ç¬èªã®ããããã£ãšèŠçŽ ã®åº§æšããããã£ã®äž¡æ¹ãæã£ãŠããŸãã ãããã¯Setæ¡åŒµã¡ãœããã䜿çšããŠäŸ¿å©ã«èšå®ããnew Div(...).Set(Canvas.LeftProperty, 10)
ïŒ new Div(...).Set(Canvas.LeftProperty, 10)
ã
ããžã¥ã¢ã«ããªãŒ
èŠçŽ ã¯ãåæã®HTMLãšåæ§ã«ããããã¯ãšå°æåã®2ã€ã®å€§ããªã°ã«ãŒãã«åããããŸãã ãã¿ãŒã³ã«å¿ããŠäž¡æ¹ãšããŠæ©èœãããžã§ãã¬ãŒã¿ãŒèŠçŽ ïŒã€ãŸãã1ã€ã®èŠçŽ ïŒããããŸãã
å ã®èŠçŽ ã®ããªãŒã¯ãWPFã®èŠ³ç¹ããã¯è«ççã§ããã€ãŸããããã°ã©ããäœæãã圢åŒã§èŠçŽ ãå«ãŸããŠããŸãã ãããŠãããã¯åãè¿ãã®ã€ããªãã»ã©èŠèŠçãªãã®ã«å€ãããŸããã€ãŸãããšã³ãžã³ã«äŸ¿å©ãªåœ¢åŒã®èŠçŽ ãå«ãã§ããŸãïŒå€§ãŸãã«èšããšãé«ã¬ãã«ã®æœè±¡åã¯ãå®éã«èªåèªèº«ãè¡šçŸã§ããèŠçŽ ã«å€æãããŸãïŒã ãã®å€æã«ã¯ä»¥äžãå«ãŸããŸãã
- ã©ã®èŠçŽ ããã®å 容ãå®å šã«çœ®ãæããããšãã§ããŸãã ããšãã°ãRepeaterãžã§ãã¬ãŒã¿ãŒã¯ãã³ãã¬ãŒããè€è£œããããèªäœãé€å€ããªããæ°åç¹°ãè¿ããListãããã¯ã¯ã°ãªããå ã®ãµãèŠçŽ ãæºåããŸãã
- è€æ°ã®ã©ã€ã³èŠçŽ ã次ã ã«ç§»åããå Žåããããã¯1ã€ã®ãããã¯ïŒInlineContainerïŒã«çµåãããŸãã
- è€æ°ã®ãããã¯èŠçŽ ã次ã ã«ç§»åããå Žåããããã¯1ã€ã®ã¹ã¿ãã¯ïŒã¹ã¿ãã¯ïŒã«çµåãããŸãã
ãŸããäžéšã®èŠçŽ ã¯WPFãããæé»çãªå€æãå®è¡ã§ããããšã«æ³šæããŠãã ãããããšãã°ãã°ãªããã¯ããã©ã«ãã§ã»ã«ã®èªåé£ç¶é 眮ã䜿çšãããããããŒãã«è¡ã®äœæãšåã»ã«ã®åº§æšã®æå®ãäžèŠã«ãªããŸãã
èŠçŽ ãµã€ãºã®èšç®
ãã¹ãŠã®èŠçŽ ã«ã€ããŠãMeasureã¡ãœãããååž°çã«åŒã³åºãããŸãããã®ã¡ãœããã§ã¯ã芪ãåäŸã«ã©ã®ãããã®ç©ºãé åãå²ãåœãŠãããåäŸã«äŒããåäŸãæãéã«çããŸãã åäŸã¯ãææ¡ããã以äžã®æ°ãèŠæ±ããå ŽåããããŸãããããå€ããèŠæ±ããå Žåã芪ã¯å³ã衚瀺ããŸãã ç¡éã§ã¯ã芪ã¯æäŸãããŠããŠãã€ããžã¯ã衚瀺ããŸãã
åãé 眮ããããã®è€éãªããžãã¯ãæã€èŠçŽ ã¯ããã®ã¹ããŒãžã䜿çšããŠã»ãšãã©ã®äœæ¥ãå®è¡ããŸãïŒããšãã°ãå°æåã®èŠçŽ ã®ã³ã³ããã¯ããã€ãããŒã·ã§ã³ãšè²ã«åºã¥ããŠããã¹ãããã©ãŒãããããŸãïŒã
èŠçŽ ã®äœçœ®ã®èšç®
ãã¹ãŠã®èŠçŽ ã«ã€ããŠãArrangeã¯ååž°çã«åŒã³åºãããå芪ã¯åã®é 眮ã«é¢äžããŸãã
èŠçŽ ã®ã¬ã³ããªã³ã°
Renderã¯ãã¹ãŠã®èŠçŽ ã«å¯ŸããŠååž°çã«åŒã³åºãããåèŠçŽ ã¯ConsoleBufferä»®æ³ã³ã³ãœãŒã«ãããã¡ãŒã«è¡šç€ºãããŸãã ConsoleBufferã¯ã©ã¹ã¯ãHDCãSystem.Windows.Forms.GraphicsãGraphics.TCanvasãªã©ã«äŒŒãŠããŸãã ããã¹ããæç»ãªã©ã衚瀺ããããã®ã¡ãœãããå«ãŸããŠããŸãã
ãããã¡ã¯å©çšå¯èœãªé åãéããã䟿å©ãªåœ¢åŒã§åèŠçŽ ã«æäŸãããã®ã§ãæ°ã«ããããšãªã座æšïŒ0; 0ïŒ-ïŒå¹ ;é«ãïŒã§èªåãæãããšãã§ããŸãã
ãããã¡ã¬ã³ããªã³ã°
ãã®æ®µéã§ã¯ããããã¡ã¯ããã¹ããšè²ã®ä»ããé·æ¹åœ¢ã®é åã§ãã æå³ãããšããã«ã³ã³ãœãŒã«ã«è¡šç€ºããããHTMLã«å€æããããWPFãŠã£ã³ããŠã«è¡šç€ºãããããŠãä»ã®äœãã§äœæã§ããŸãã IRenderTargetãå®è£ ããã¯ã©ã¹ããããæ åœããŸãã
ãããŠãããã¯ã©ãã»ã©é£ããã§ããïŒ
ç°¡åã§ãã é£ããã®ã¯ãConsoleFrameworkãããã«ã¯Avaloniaã§ãã é害ãåæ¹åæ§ããããŸããã ææžãæžãã ãã§ãèŠçŽ ãæžãã ãã§ãã ãã¹ãŠã®æšã¯äœ¿ãæšãŠã§ãã
å®éã«ã¯ã AddChildren
ã䜿çšããæ¹æ³ïŒãããŠè©ŠããŠã¿ãæ¹æ³ïŒã ãã§ãªããåºæ¬èŠçŽ ãç¹ã«Grid
ã䜿çšããããã®ãã¿ãŒã³ãç¥ãã ãã§æžã¿ãŸãã ä»ã®ãã¹ãŠãå¿
èŠãªã®ã¯ãç¬èªã®èŠçŽ ãäœæããå Žåã®ã¿ã§ãã
ãŸããç¬èªã®èŠçŽ ãäœæããå Žåã§ããããšãã°ããªã¹ãã¯ã°ãªãããä»ããŠå®è£ ããããã¹ãŠã®ããžãã¯ã16è¡ã®1ã€ã®ç°¡åãªæ¹æ³ã«åãŸãããã«ãèªåèªèº«ã®è¡šç€ºæ¹æ³ãæ¢ã«ç¥ã£ãŠããèŠçŽ ãžã®åçŽãªå€æã«å¶éããããšãã§ããŸãã
åæ§ã«
ããã¯ãã¹ãŠã.NET 4.0 + ã. NET Standard 1.3+ã§æ©èœããŸãã çŽç²äž»çŸ©è ã®ããã«ãXAMLãµããŒãã®ãªãããŒãžã§ã³ããããŸãã .NET 3.5ã®ãµããŒããå«ãŸããŠãããããä¿å®çã§ãã
Colorful.Consoleã®FIGletãã©ã³ãããµããŒãããããã±ãŒãžããããŸãããColorful.Consoleã¯éåžžã®æ¹æ³ã§FIGletãå®è¡ããæ¹æ³ãç¥ããªãããããã®äŸåé¢ä¿ã¯èª€ãã§ããã åŸã§ãFiggleããã±ãŒãžã«åºã¥ããµããŒãããŸãã¯ç¬èªã®å®è£ ã®ãããããæäŸãããŸãã
ãªããžããªã«ã¯ãäžçšåºŠã®ã¹ã³ãŒã«ãã«ããŒãã2ã€ã®ãµã³ãã«ãããžã§ã¯ããšãã¹ããå«ãŸããŠããŸãã
å èš±
Apache 2.0 ã³ãŒãã®äžéšã¯ãMITã©ã€ã»ã³ã¹ã®äžã§Igor Kostominã«ãã£ãŠæžãããConsoleFrameworkã©ã€ãã©ãªããåçšãããŠããŸãã
åç §è³æ
- guthubã®CsConsoleFormat-䞊ã¹æ¿ã
- NuGetã®CsConsoleFormat-ãã€ããª