diff --git a/Editor/App.config b/Editor/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/Editor/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Editor/ConsoleControl.cs b/Editor/ConsoleControl.cs
new file mode 100644
index 0000000..b36809f
--- /dev/null
+++ b/Editor/ConsoleControl.cs
@@ -0,0 +1,59 @@
+using KCore;
+using KCore.Graphics;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Editor
+{
+ public class ConsoleControl : Form
+ {
+ private object sync = new object();
+ public static ConsoleRequestPack ConsoleThreadRequest;
+ public static ConsoleRequestPack MainFormThreadRequest;
+ public static bool RequestSended;
+
+ public ConsoleControl() : base()
+ {
+ AllowedDashboard = false;
+ Bind(new DelegateRequest(this, form => true, form =>
+ {
+ Program.GetWindowRect(Program.ConsoleHandler, ref Program.ConsoleRect);
+ Program.MainForm.MoveRequest = true;
+ }));
+ Bind(new DelegateRequest(this, form => RequestSended, form =>
+ {
+ lock (sync) ConsoleThreadRequest = MainFormThreadRequest;
+ RequestSended = false;
+ }));
+ Bind(new DelegateRequest(this, form =>
+ {
+ lock (sync) return ConsoleThreadRequest != null;
+ }, form =>
+ {
+ lock (sync)
+ {
+ ConsoleThreadRequest.Invoke();
+ ConsoleThreadRequest = null;
+ }
+ }));
+ }
+
+ protected override void OnOpening()
+ {
+ while (Program.MainForm == null)
+ Thread.Sleep(100);
+ }
+
+ protected override void OnKeyDown(byte key)
+ {
+ if (key == 1)
+ if (Program.MainForm != null)
+ Program.MainForm.ClickRequest = true;
+ }
+ }
+}
diff --git a/Editor/ConsoleRequestPack.cs b/Editor/ConsoleRequestPack.cs
new file mode 100644
index 0000000..b4b9ae5
--- /dev/null
+++ b/Editor/ConsoleRequestPack.cs
@@ -0,0 +1,29 @@
+using KCore.Graphics.Widgets;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Editor
+{
+ public abstract class ConsoleRequestPack
+ {
+ public abstract void Invoke();
+ public void Send()
+ {
+ ConsoleControl.MainFormThreadRequest = this;
+ ConsoleControl.RequestSended = true;
+ }
+ }
+
+ public class SimpleRequest : ConsoleRequestPack
+ {
+ public SimpleRequest(Action action) => Action = action;
+ public Action Action { get; set; }
+ public override void Invoke()
+ {
+ Action.Invoke();
+ }
+ }
+}
diff --git a/Editor/Editor.csproj b/Editor/Editor.csproj
new file mode 100644
index 0000000..7d03507
--- /dev/null
+++ b/Editor/Editor.csproj
@@ -0,0 +1,97 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {7450C379-DD7C-410E-A122-A96EF8082F37}
+ Exe
+ Editor
+ Editor
+ v4.7.2
+ 512
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ ..\bin\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ ..\bin\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Form
+
+
+ MainForm.cs
+
+
+
+
+ MainForm.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+
+
+
+ {FE2FBEFB-28CC-4928-B11B-D22BD7DFE137}
+ KCore
+
+
+
+
+ ../building/IncEditorRevision.bat
+
+
\ No newline at end of file
diff --git a/Editor/MainForm.Designer.cs b/Editor/MainForm.Designer.cs
new file mode 100644
index 0000000..7dc0f87
--- /dev/null
+++ b/Editor/MainForm.Designer.cs
@@ -0,0 +1,138 @@
+namespace Editor
+{
+ partial class MainForm
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором форм Windows
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.CurrentPositionLabel = new System.Windows.Forms.Label();
+ this.RequestChecker = new System.Windows.Forms.Timer(this.components);
+ this.button2 = new System.Windows.Forms.Button();
+ this.button1 = new System.Windows.Forms.Button();
+ this.button3 = new System.Windows.Forms.Button();
+ this.button4 = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // CurrentPositionLabel
+ //
+ this.CurrentPositionLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.CurrentPositionLabel.Font = new System.Drawing.Font("Lucida Console", 20F);
+ this.CurrentPositionLabel.Location = new System.Drawing.Point(11, 9);
+ this.CurrentPositionLabel.Name = "CurrentPositionLabel";
+ this.CurrentPositionLabel.Size = new System.Drawing.Size(261, 31);
+ this.CurrentPositionLabel.TabIndex = 0;
+ this.CurrentPositionLabel.Text = "--- --";
+ this.CurrentPositionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
+ //
+ // RequestChecker
+ //
+ this.RequestChecker.Enabled = true;
+ this.RequestChecker.Interval = 16;
+ this.RequestChecker.Tick += new System.EventHandler(this.timer1_Tick);
+ //
+ // button2
+ //
+ this.button2.BackColor = System.Drawing.Color.Black;
+ this.button2.Cursor = System.Windows.Forms.Cursors.Hand;
+ this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.button2.Font = new System.Drawing.Font("Lucida Console", 20F);
+ this.button2.ForeColor = System.Drawing.Color.White;
+ this.button2.Location = new System.Drawing.Point(166, 443);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(50, 50);
+ this.button2.TabIndex = 2;
+ this.button2.TabStop = false;
+ this.button2.Text = "A";
+ this.button2.UseVisualStyleBackColor = false;
+ //
+ // button1
+ //
+ this.button1.BackColor = System.Drawing.Color.White;
+ this.button1.Cursor = System.Windows.Forms.Cursors.Hand;
+ this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
+ this.button1.Font = new System.Drawing.Font("Lucida Console", 20F);
+ this.button1.ForeColor = System.Drawing.Color.Black;
+ this.button1.Location = new System.Drawing.Point(222, 499);
+ this.button1.Name = "button1";
+ this.button1.Size = new System.Drawing.Size(50, 50);
+ this.button1.TabIndex = 3;
+ this.button1.TabStop = false;
+ this.button1.Text = "B";
+ this.button1.UseVisualStyleBackColor = false;
+ //
+ // button3
+ //
+ this.button3.Location = new System.Drawing.Point(182, 499);
+ this.button3.Name = "button3";
+ this.button3.Size = new System.Drawing.Size(34, 23);
+ this.button3.TabIndex = 4;
+ this.button3.Text = "dfl";
+ this.button3.UseVisualStyleBackColor = true;
+ //
+ // button4
+ //
+ this.button4.Location = new System.Drawing.Point(222, 470);
+ this.button4.Name = "button4";
+ this.button4.Size = new System.Drawing.Size(34, 23);
+ this.button4.TabIndex = 5;
+ this.button4.Text = "swp";
+ this.button4.UseVisualStyleBackColor = true;
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(284, 561);
+ this.ControlBox = false;
+ this.Controls.Add(this.button4);
+ this.Controls.Add(this.button3);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.button1);
+ this.Controls.Add(this.CurrentPositionLabel);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.MinimizeBox = false;
+ this.Name = "MainForm";
+ this.ShowIcon = false;
+ this.Text = "KCore Editor";
+ this.TopMost = true;
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label CurrentPositionLabel;
+ private System.Windows.Forms.Timer RequestChecker;
+ private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.Button button1;
+ private System.Windows.Forms.Button button3;
+ private System.Windows.Forms.Button button4;
+ }
+}
+
diff --git a/Editor/MainForm.cs b/Editor/MainForm.cs
new file mode 100644
index 0000000..293a1ea
--- /dev/null
+++ b/Editor/MainForm.cs
@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Editor
+{
+ public partial class MainForm : Form
+ {
+ public bool ClickRequest, MoveRequest;
+
+ public int GetTopWithout()
+ {
+ return Program.ConsoleRect.Bottom - KCore.Terminal.FixedWindowHeight * Program.PixelSize.Item2;
+ }
+ public bool In(Point pos, int top_without)
+ {
+ return pos.X >= Program.ConsoleRect.Left && pos.X <= Program.ConsoleRect.Right && pos.Y >= top_without && pos.Y <= Program.ConsoleRect.Bottom;
+ }
+ public (int, int) GetConsolePosition(Point pos, int top_without)
+ {
+ var left = (pos.X - Program.ConsoleRect.Left - Program.Offset.Item1) / Program.PixelSize.Item1;
+ var top = (pos.Y - top_without - Program.Offset.Item2) / Program.PixelSize.Item2;
+ return (left, top);
+ }
+
+ public void ConsoleMouseMoveHandler()
+ {
+ MoveRequest = false;
+ var pos = Cursor.Position;
+ var top_without = GetTopWithout();
+ if (In(pos, top_without))
+ {
+ var (left, top) = GetConsolePosition(pos, top_without);
+ CurrentPositionLabel.Text = $"{left,-3} {top}";
+ }
+ }
+ public void ConsoleMouseClickHandler()
+ {
+ ClickRequest = false;
+ var pos = Cursor.Position;
+ var top_without = GetTopWithout();
+
+ if (!In(pos, top_without))
+ {
+ return;
+ }
+ var (left, top) = GetConsolePosition(pos, top_without);
+ CurrentPositionLabel.Text = $"{left,-3} {top}";
+ new SimpleRequest(() =>
+ {
+ KCore.Terminal.Back = KCore.Theme.Fore;
+ KCore.Terminal.Set(left, top);
+ KCore.Terminal.Write('-');
+ }).Send();
+ }
+
+ private void timer1_Tick(object sender, EventArgs e)
+ {
+ if (ClickRequest) ConsoleMouseClickHandler();
+ if (MoveRequest) ConsoleMouseMoveHandler();
+ }
+
+ public MainForm()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Editor/MainForm.resx b/Editor/MainForm.resx
new file mode 100644
index 0000000..282eb44
--- /dev/null
+++ b/Editor/MainForm.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/Editor/Program.cs b/Editor/Program.cs
new file mode 100644
index 0000000..36c7acf
--- /dev/null
+++ b/Editor/Program.cs
@@ -0,0 +1,81 @@
+using KCore;
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Security.Permissions;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Editor
+{
+ internal static class Program
+ {
+ [DllImport("user32.dll", CharSet = CharSet.Auto)]
+ public static extern IntPtr FindWindow(string strClassName, string strWindowName);
+
+ [DllImport("user32.dll")]
+ public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle);
+
+ public struct Rect
+ {
+ public int Left { get; set; }
+ public int Top { get; set; }
+ public int Right { get; set; }
+ public int Bottom { get; set; }
+ }
+
+ public static MainForm MainForm;
+ public static ConsoleControl ConsoleControl;
+ public static IntPtr ConsoleHandler;
+ public static Rect ConsoleRect;
+
+ public static bool NeedRestart = false;
+ public static readonly (int, int) PixelSize = (12, 20);
+ public static (int, int) Offset = (8, -6);
+
+ ///
+ /// Главная точка входа для приложения.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ var full_path = Assembly.GetEntryAssembly().ManifestModule.FullyQualifiedName.Replace('\\', '_');
+ var console = Registry.CurrentUser.OpenSubKey("Console", true);
+ var editor = console.OpenSubKey(full_path);
+ if (editor == null)
+ {
+ editor = console.CreateSubKey(full_path);
+ NeedRestart = true;
+ editor.SetValue("QuickEdit", 0, RegistryValueKind.DWord);
+ editor.SetValue("LineSelection", 0, RegistryValueKind.DWord);
+ editor.SetValue("CursorType", 0, RegistryValueKind.DWord);
+ editor.SetValue("FaceName", "Lucida Console", RegistryValueKind.String);
+ editor.SetValue("FontFamily", 54, RegistryValueKind.DWord);
+ editor.SetValue("FontSize", 1310720, RegistryValueKind.DWord);
+ editor.SetValue("FontWeight", 400, RegistryValueKind.DWord);
+ return;
+ }
+
+ var KCore_Thread = new Thread(() =>
+ {
+ Console.Title = "KCore Editor Console";
+ while (ConsoleHandler == IntPtr.Zero)
+ ConsoleHandler = FindWindow(null, Console.Title);
+ Terminal.Init(80, 25);
+ Terminal.UpdatesPerSecond = 0;
+ Terminal.KeySplit = 1;
+ Terminal.KeyWait = 1;
+ (ConsoleControl = new ConsoleControl()).Start();
+ });
+ KCore_Thread.Start();
+
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(MainForm = new MainForm());
+ }
+ }
+}
diff --git a/Editor/Properties/AssemblyInfo.cs b/Editor/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..cc7f6e9
--- /dev/null
+++ b/Editor/Properties/AssemblyInfo.cs
@@ -0,0 +1,94 @@
+using System.IO;
+using System;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using KCore.Extensions.InsteadSLThree;
+
+// Общие сведения об этой сборке предоставляются следующим набором
+// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
+// связанных со сборкой.
+[assembly: AssemblyTitle(EditorVersion.Name)]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct(EditorVersion.Name)]
+[assembly: AssemblyCopyright(EditorVersion.Copyright)]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
+// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
+// COM, следует установить атрибут ComVisible в TRUE для этого типа.
+[assembly: ComVisible(false)]
+
+// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
+[assembly: Guid("7450c379-dd7c-410e-a122-a96ef8082f37")]
+
+// Сведения о версии сборки состоят из указанных ниже четырех значений:
+//
+// Основной номер версии
+// Дополнительный номер версии
+// Номер сборки
+// Редакция
+//
+// Можно задать все значения или принять номера сборки и редакции по умолчанию
+// используя "*", как показано ниже:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion(EditorVersion.Version)]
+[assembly: AssemblyFileVersion(EditorVersion.Version)]
+
+public static class EditorVersion
+{
+ public class Reflected
+ {
+ public int Major { get; private set; }
+ public int Minor { get; private set; }
+ public int Build { get; private set; }
+ public int Revision { get; private set; }
+ public DateTime LastUpdate { get; private set; }
+
+ public string Version { get; private set; }
+ public string VersionWithoutRevision { get; private set; }
+
+ public Reflected()
+ {
+ var slt_version = typeof(EditorVersion);
+ Major = int.Parse(slt_version.GetField("Major").GetValue(null).Cast());
+ Minor = int.Parse(slt_version.GetField("Minor").GetValue(null).Cast());
+ Build = int.Parse(slt_version.GetField("Build").GetValue(null).Cast());
+ Revision = int.Parse(slt_version.GetField("Revision").GetValue(null).Cast());
+ LastUpdate = new DateTime(slt_version.GetField("LastUpdate").GetValue(null).Cast());
+
+ Version = Major + "." + Minor + "." + Build + "." + Revision;
+ VersionWithoutRevision = Major + "." + Minor + "." + Build;
+ }
+ }
+
+ public const string Major = "0"; //vh
+ public const string Minor = "1"; //vh
+ public const string Build = "0"; //vh
+ public const string Revision = "53"; //vh
+ public const long LastUpdate = 638396998313907149; //vh
+
+ public const string Version = Major + "." + Minor + "." + Build + "." + Revision;
+ public const string VersionWithoutRevision = Major + "." + Minor + "." + Build;
+ public const string VersionRevisionInBrackets = Major + "." + Minor + "." + Build + " (" + Revision + ")";
+ public const string Name = "KCore Editor";
+ public const string Author = "Alexandr Kotov";
+ public const string Copyright = Author + " 2023";
+
+ internal static string[] ReadStrings(Stream stream)
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ return sr.ReadToEnd().Split(new string[1] { Environment.NewLine }, StringSplitOptions.None);
+ }
+ }
+
+ static EditorVersion()
+ {
+ var ass = Assembly.GetExecutingAssembly();
+
+ }
+}
diff --git a/Editor/Properties/Resources.Designer.cs b/Editor/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..2fb801d
--- /dev/null
+++ b/Editor/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// Этот код создан программным средством.
+// Версия среды выполнения: 4.0.30319.42000
+//
+// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
+// код создан повторно.
+//
+//------------------------------------------------------------------------------
+
+namespace Editor.Properties
+{
+
+
+ ///
+ /// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
+ ///
+ // Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
+ // класс с помощью таких средств, как ResGen или Visual Studio.
+ // Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
+ // с параметром /str или заново постройте свой VS-проект.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Editor.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Переопределяет свойство CurrentUICulture текущего потока для всех
+ /// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Editor/Properties/Resources.resx b/Editor/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/Editor/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Editor/Properties/Settings.Designer.cs b/Editor/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..d651dc6
--- /dev/null
+++ b/Editor/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace Editor.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Editor/Properties/Settings.settings b/Editor/Properties/Settings.settings
new file mode 100644
index 0000000..3964565
--- /dev/null
+++ b/Editor/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/KCore.nuspec b/KCore.nuspec
index a395af5..a226c23 100644
--- a/KCore.nuspec
+++ b/KCore.nuspec
@@ -2,23 +2,20 @@
KCore
- 0.1.0
+ 0.2.0
Kotov
false
MIT
A simple but powerful shell for creating applications in the Windows console
------- KCore 0.1.0 ------ [10.12.23]
-The first version. Not everything from KTXCore has been adapted yet.
-Main from KTXCore:
- - Transition animations
- - Graphics architecture
-New:
- - Widgets, new Forms, Requests instead Reactions
+------ KCore 0.2.0 ------ [01.01.24]
+Main:
+ - New DASHBOARD
+ - Storage for KCore applications
+ - Localizations (en, ru)
+ - Inifile -> Initial
New widgets:
- - Window, BoxLayout, ListBox
- - WithVerticalScroll, VerticalScroll, Padding
- - ScrollableText, TextWidget, TextRow
+ - Panel (Form is also Panel)
$copyright$
windows console shell terminal widgets
diff --git a/KCore.sln b/KCore.sln
index 5c48f72..6f264e3 100644
--- a/KCore.sln
+++ b/KCore.sln
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCore", "KCore\KCore.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runner", "Runner\Runner.csproj", "{DE417F09-8B21-4D00-961E-54F352118A21}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editor", "Editor\Editor.csproj", "{7450C379-DD7C-410E-A122-A96EF8082F37}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
{DE417F09-8B21-4D00-961E-54F352118A21}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE417F09-8B21-4D00-961E-54F352118A21}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE417F09-8B21-4D00-961E-54F352118A21}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7450C379-DD7C-410E-A122-A96EF8082F37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7450C379-DD7C-410E-A122-A96EF8082F37}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7450C379-DD7C-410E-A122-A96EF8082F37}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7450C379-DD7C-410E-A122-A96EF8082F37}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/KCore/CoreForms/Dashboard.cs b/KCore/CoreForms/Dashboard.cs
index cf6498f..7a5ff77 100644
--- a/KCore/CoreForms/Dashboard.cs
+++ b/KCore/CoreForms/Dashboard.cs
@@ -1,9 +1,18 @@
-using KCore.Graphics;
+using KCore.Extensions.InsteadSLThree;
+using KCore.Extensions;
+using KCore.Graphics;
+using KCore.Graphics.Containers;
+using KCore.Graphics.Core;
+using KCore.Graphics.Widgets;
+using KCore.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
+using System.Security.Permissions;
namespace KCore.CoreForms
{
@@ -12,75 +21,1078 @@ internal class Dashboard : Form
public static KCoreVersion.Reflected Version = new KCoreVersion.Reflected();
public TriggerRedrawer Downline;
- public Dashboard()
+ //Dashboard options:
+ //KCore version info (+ difference list)
+ //KCore settings
+ //KCore Form information
+ //KCore Palette
+ //SLThree console (if SLThree.dll available)
+
+ public static class Settings
{
- Bind(Downline = new TriggerRedrawer(this, form =>
+ public static readonly Type SettingsType = typeof(Settings);
+ public static Type EntryType = null;
+
+ public const int Spacing = 40;
+ public abstract class Setting : Widget
{
- Terminal.Set(1, Terminal.FixedWindowHeight - 1);
- ($"KCore {Version.Version} %=>DarkCyan%{Terminal.FixedWindowWidth}x{Terminal.FixedWindowHeight}%=>reset% "
- + $"%=>Red%{Terminal.UpdatesPerSecond} UPS%=>reset%").PrintSuperText();
- }));
+ public Dashboard Reference;
+ public virtual bool HasTitle => false;
+ public override bool AllowedVisible => base.AllowedVisible;
+ public virtual bool HasValue => true;
+ public override int Height => HasTitle ? 3 : 1;
+ public override int Width => Container.Width;
+ public override void Resize() { }
+ public override (int, int) Clear(int left, int top)
+ {
+ Graph.FillRectangle(Theme.Back, left, top, Width, Height);
+ return (left, top);
+ }
+ public Setting(Dashboard dashboard) : base(0, 0, null, null, true, false)
+ {
+ Reference = dashboard;
+ }
+
+ public virtual void OnEntered() { }
+ public virtual void OnLeaving() { }
+
+ public IContainer GetSettingKeyContainer(int left, int top)
+ {
+ return new StaticContainer(left + 2, top, Spacing - 2, 1);
+ }
+
+ public IContainer GetSettingValueContainer(int left, int top)
+ {
+ return new StaticContainer(left + Spacing + 2, top, Width - Spacing - 2, 1);
+ }
+
+ public IContainer GetContainer(int left, int top)
+ {
+ return new StaticContainer(left + 2, top, Width - 2, 1);
+ }
+
+ public override (int, int) Draw(int left, int top)
+ {
+ if (HasTitle)
+ {
+ Terminal.Set(left, ++top);
+ Terminal.Write(Title.PadCenter(Width).Replace(' ', '-').Replace('_', ' '));
+ top += 1;
+ }
+
+ if (HasValue)
+ {
+ GetSettingKey().PrintSuperText(GetSettingKeyContainer(left, top), null, TextAlignment.Left);
+ Terminal.Set(left + Spacing, top);
+ Terminal.Write(": ");
+ var value_container = GetSettingValueContainer(left, top);
+ Graph.FillRectangle(Theme.Back, value_container);
+ GetSettingValue().PrintSuperText(value_container, null, TextAlignment.Left);
+ }
+ else
+ {
+ GetSettingKey().PrintSuperText(GetContainer(left, top), null, TextAlignment.Left);
+ }
+
+ return (left, top);
+ }
+
+ public override bool SelectNeedsRedraw => true;
+
+ public virtual string Title => "";
+ public abstract string GetSettingKey();
+ public abstract string GetSettingValue();
+ public bool IsActive => Reference.FieldSettingsPanel.ActiveSubwidget == this;
+ }
+
+ public abstract class OnlyKeySetting : Setting
+ {
+ public override bool HasValue => false;
+ public override string GetSettingValue() => "";
+ public OnlyKeySetting(Dashboard dashboard) : base(dashboard)
+ {
+ }
+ }
+
+ public class Language : Setting, IControlable
+ {
+ public Language(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger EnterTrigger;
+ public override IList GetBinds(Form form)
+ {
+ return new Request[] {
+ EnterTrigger = new Trigger(form, panel =>
+ {
+ Localization.Next();
+ (panel as Form).Clear();
+ KCoreStorage.SaveGlobalConfig();
+ })
+ };
+ }
+ public override bool HasTitle => true;
+ public override string Title => Localization.Current["DASH_MAIN"];
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_Language"];
+
+ public override string GetSettingValue()
+ {
+ var str = Localization.Current.LocalName;
+ return IsActive ? $"%=>Magenta%{str}%=>reset%" : str;
+ }
+ }
+
+ public class ConsoleSize : Setting, IControlable
+ {
+ public ConsoleSize(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger UpTrigger;
+ public Trigger DownTrigger;
+ public Trigger LeftTrigger;
+ public Trigger RightTrigger;
+ public override bool HasTitle => true;
+ public override string Title => Localization.Current["DASH_GRAPHICS"];
+ public bool HeightResizing;
+ public bool SavedWSEM;
+
+ public override void OnEntered()
+ {
+ SavedWSEM = Terminal.WindowSizeExternalManage;
+ Terminal.WindowSizeExternalManage = false;
+ }
+
+ public override void OnLeaving()
+ {
+ Terminal.WindowSizeExternalManage = SavedWSEM;
+ }
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[] {
+ UpTrigger = new Trigger(form, panel =>
+ {
+ if (HeightResizing)
+ Terminal.FixedWindowHeight += 1;
+ else Terminal.FixedWindowWidth += 1;
+ KCoreStorage.SaveLocalConfig();
+ }),
+ DownTrigger = new Trigger(form, panel =>
+ {
+ if (HeightResizing)
+ Terminal.FixedWindowHeight -= 1;
+ else Terminal.FixedWindowWidth -= 1;
+ KCoreStorage.SaveLocalConfig();
+ }),
+ LeftTrigger = new Trigger(form, panel =>
+ {
+ HeightResizing = false;
+ Redraw();
+ }),
+ RightTrigger = new Trigger(form, panel =>
+ {
+ HeightResizing = true;
+ Redraw();
+ }),
+ };
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.A || key == Key.LeftArrow)
+ LeftTrigger.Pull();
+ if (key == Key.D || key == Key.RightArrow)
+ RightTrigger.Pull();
+ if (key == Key.W || key == Key.UpArrow)
+ UpTrigger.Pull();
+ if (key == Key.S || key == Key.DownArrow)
+ DownTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_ConsoleSize"];
+
+ public override string GetSettingValue()
+ {
+ var width = Terminal.FixedWindowWidth.ToString();
+ var height = Terminal.FixedWindowHeight.ToString();
+ if (Reference.FieldSettingsPanel.ActiveSubwidget == this)
+ {
+ if (HeightResizing) height = $"%=>Magenta%{height}%=>reset%";
+ else width = $"%=>Magenta%{width}%=>reset%";
+ }
+ return $"{width}x{height}";
+ }
+ }
+
+ public class MakeMaximal : OnlyKeySetting, IControlable
+ {
+ public MakeMaximal(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger EnterTrigger;
+ public bool HeightResizing;
+ public bool SavedWSEM;
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[] {
+ EnterTrigger = new Trigger(form, panel =>
+ {
+ (Terminal.FixedWindowWidth, Terminal.FixedWindowHeight) = (Console.LargestWindowWidth, Console.LargestWindowHeight);
+ KCoreStorage.SaveLocalConfig();
+ (panel as Dashboard).Clear();
+ }),
+ };
+ }
+
+ public override void OnEntered()
+ {
+ SavedWSEM = Terminal.WindowSizeExternalManage;
+ Terminal.WindowSizeExternalManage = false;
+ }
+
+ public override void OnLeaving()
+ {
+ Terminal.WindowSizeExternalManage = SavedWSEM;
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => IsActive ? $"%=>Magenta%{Localization.Current["DASH_MakeMaximal"]}%=>reset%": Localization.Current["DASH_MakeMaximal"];
+ }
+
+ public class MakeMinimal : OnlyKeySetting, IControlable
+ {
+ public MakeMinimal(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger EnterTrigger;
+ public bool HeightResizing;
+ public bool SavedWSEM;
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[] {
+ EnterTrigger = new Trigger(form, panel =>
+ {
+ (Terminal.FixedWindowWidth, Terminal.FixedWindowHeight) = (Terminal.MinimalWindowWidth, Terminal.MinimalWindowHeight);
+ KCoreStorage.SaveLocalConfig();
+ (panel as Dashboard).Clear();
+ }),
+ };
+ }
+ public override void OnEntered()
+ {
+ SavedWSEM = Terminal.WindowSizeExternalManage;
+ Terminal.WindowSizeExternalManage = false;
+ }
+
+ public override void OnLeaving()
+ {
+ Terminal.WindowSizeExternalManage = SavedWSEM;
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+
+ public override string GetSettingKey() => IsActive ? $"%=>Magenta%{Localization.Current["DASH_MakeMinimal"]}%=>reset%" : Localization.Current["DASH_MakeMinimal"];
+ }
+
+ public class ExternalSize : Setting, IControlable
+ {
+ public ExternalSize(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger EnterTrigger;
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[1] { EnterTrigger = new Trigger(form, x =>
+ {
+ Terminal.WindowSizeExternalManage = !Terminal.WindowSizeExternalManage;
+ KCoreStorage.SaveLocalConfig();
+ Redraw();
+ })};
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_ExternalResizing"];
+
+ public bool GetWSEM()
+ {
+ if (Reference.FieldSettingsPanel.ActiveSubwidget?.GetType() == typeof(ConsoleSize))
+ return (Reference.FieldSettingsPanel.ActiveSubwidget as ConsoleSize).SavedWSEM;
+ else return Terminal.WindowSizeExternalManage;
+ }
+
+ public override string GetSettingValue()
+ {
+ var str = GetWSEM() ? Localization.Current["DASH_Enabled"] : Localization.Current["DASH_Disabled"];
+ return IsActive ? $"%=>Magenta%{str}%=>reset%" : str;
+ }
+ }
+
+ public class UpdatesPerSec : Setting, IControlable
+ {
+ public Trigger LeftTrigger;
+ public Trigger RightTrigger;
+ public static string GetText()
+ {
+ if (Terminal.UpdatesPerSecond == 0)
+ return Localization.Current["DASH_Unlimited"];
+ return Terminal.UpdatesPerSecond.ToString();
+ }
+
+ public static int[] Allowed = new int[] { 12, 24, 44, 70, 0 };
+
+ public UpdatesPerSec(Dashboard dashboard) : base(dashboard) { }
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[] {
+ LeftTrigger = new Trigger(form, panel =>
+ {
+ var ind = Array.IndexOf(Allowed, Terminal.UpdatesPerSecond);
+ if (ind == -1) ind = 0;
+ ind--;
+ if (ind < 0) ind = 0;
+ Terminal.UpdatesPerSecond = Allowed[ind];
+ KCoreStorage.SaveLocalConfig();
+ Redraw();
+ }),
+ RightTrigger = new Trigger(form, panel =>
+ {
+ var ind = Array.IndexOf(Allowed, Terminal.UpdatesPerSecond);
+ if (ind == -1) ind = Allowed.Length - 1;
+ ind++;
+ if (ind >= Allowed.Length) ind = Allowed.Length - 1;
+ Terminal.UpdatesPerSecond = Allowed[ind];
+ KCoreStorage.SaveLocalConfig();
+ Redraw();
+ }),
+ };
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.A || key == Key.LeftArrow)
+ LeftTrigger.Pull();
+ if (key == Key.D || key == Key.RightArrow)
+ RightTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_UpdatesPerSec"];
+ public override string GetSettingValue()
+ {
+ var str = GetText().ToString();
+ return IsActive ? $"%=>Magenta%{str}%=>reset%" : str;
+ }
+ }
+
+ public class TransitionAnimations : Setting, IControlable
+ {
+ public TransitionAnimations(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger EnterTrigger;
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[1] { EnterTrigger = new Trigger(form, x =>
+ {
+ GraphicsExtensions.AllowTransitionAnimations = !GraphicsExtensions.AllowTransitionAnimations;
+ KCoreStorage.SaveLocalConfig();
+ Redraw();
+ })};
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_TransitionAnimations"];
+ public override string GetSettingValue()
+ {
+ var str = GraphicsExtensions.AllowTransitionAnimations ? Localization.Current["DASH_Enabled"] : Localization.Current["DASH_Disabled"];
+ return IsActive ? $"%=>Magenta%{str}%=>reset%" : str;
+ }
+ }
+
+ public class TransitionAnimationSpeed : Setting, IControlable
+ {
+ public Trigger LeftTrigger;
+ public Trigger RightTrigger;
+
+ public static int[] Allowed = new int[] { 1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30, 35, 40 };
+
+ public TransitionAnimationSpeed(Dashboard dashboard) : base(dashboard) { }
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[] {
+ LeftTrigger = new Trigger(form, panel =>
+ {
+ var ind = Array.IndexOf(Allowed, GraphicsExtensions.TransitionAnimationsSpeed);
+ if (ind == -1) ind = 0;
+ ind--;
+ if (ind < 0) ind = 0;
+ GraphicsExtensions.TransitionAnimationsSpeed = Allowed[ind];
+ KCoreStorage.SaveLocalConfig();
+ Redraw();
+ }),
+ RightTrigger = new Trigger(form, panel =>
+ {
+ var ind = Array.IndexOf(Allowed, GraphicsExtensions.TransitionAnimationsSpeed);
+ if (ind == -1) ind = Allowed.Length - 1;
+ ind++;
+ if (ind >= Allowed.Length) ind = Allowed.Length - 1;
+ GraphicsExtensions.TransitionAnimationsSpeed = Allowed[ind];
+ KCoreStorage.SaveLocalConfig();
+ Redraw();
+ }),
+ };
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.A || key == Key.LeftArrow)
+ LeftTrigger.Pull();
+ if (key == Key.D || key == Key.RightArrow)
+ RightTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_TransitionAnimationSpeed"];
+ public override string GetSettingValue()
+ {
+ return IsActive ? $"%=>Magenta%{GraphicsExtensions.TransitionAnimationsSpeed}%=>reset%" : GraphicsExtensions.TransitionAnimationsSpeed.ToString();
+ }
+ }
+
+ public class CurrentApplication : Setting, IControlable
+ {
+ public CurrentApplication(Dashboard dashboard) : base(dashboard) { }
+
+ public override bool HasTitle => true;
+ public override string Title => Localization.Current["DASH_ADVANCED"];
+
+ public override IList GetBinds(Form form)
+ {
+ return Array.Empty();
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ //if (key == Key.E || key == Key.Enter)
+ // EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_CurrentApplication"];
+ public override string GetSettingValue() => KCoreStorage.Portable ? Localization.Current["DASH_Portable"] : Localization.Current["DASH_Common"];
+ }
+
+ public class ShowUPS : Setting, IControlable
+ {
+ public ShowUPS(Dashboard dashboard) : base(dashboard) { }
+
+ public Trigger EnterTrigger;
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[1] { EnterTrigger = new Trigger(form, panel =>
+ {
+ Form.ShowUPS = !Form.ShowUPS;
+ (panel as Form).Clear();
+ })};
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterTrigger.Pull();
+ }
+
+ public void OnKeyUp(byte key) { }
+
+ public override string GetSettingKey() => Localization.Current["DASH_ShowUPS"];
+ public override string GetSettingValue()
+ {
+ var str = Form.ShowUPS ? Localization.Current["DASH_Enabled"] : Localization.Current["DASH_Disabled"];
+ return IsActive ? $"%=>Magenta%{str}%=>reset%": str;
+ }
+ }
}
- protected override bool IsRecursiveForm() => true;
+ public abstract class DashboardPanel : Panel
+ {
+ public DashboardPanel(Form form) : base(form) { }
- protected override void OnAllRedraw()
+ public abstract string PanelName { get; }
+ public abstract bool LockChanger { get; }
+ }
+
+ public class SettingsPanel : DashboardPanel, IControlable
+ {
+ public override string PanelName => Localization.Current["DASH_PN_Settings"];
+ public override bool LockChanger => ActiveSubwidget != null;
+ public ListBox SettingsList;
+ public Trigger EnterAction;
+ public Trigger BackAction;
+ public IControlable ActiveSubwidget;
+
+ public SettingsPanel(Form form) : base(form)
+ {
+ SettingsList = new ListBox();
+ SettingsList.SelectingPadding = (-1, 0);
+ SettingsList.SelectingLocation = ListBox.Location.Left;
+ SettingsList.SelectingRelativeChildLocation = ListBox.RelativeLocation.Down;
+ SettingsList.Container = new DynamicContainer()
+ {
+ GetLeft = () => 1,
+ GetTop = () => 3,
+ GetHeight = () => Terminal.FixedWindowHeight - 5,
+ GetWidth = () => Terminal.FixedWindowWidth - 2,
+ };
+ SettingsList.Childs = typeof(Settings).GetNestedTypes().Where(x => x.BaseType == typeof(Settings.OnlyKeySetting) || x.BaseType == typeof(Settings.Setting) && !(x == typeof(Settings.OnlyKeySetting)))
+ .Select(x => new ListBox.ListItem(Activator.CreateInstance(x, new object[1] { form as Dashboard }) as Widget)).ToList();
+
+ OnResizing += panel => SettingsList.Resize();
+
+ Bind(SettingsList);
+ foreach (var x in SettingsList.Childs)
+ {
+ Bind(x.Child);
+ foreach (var req in x.Child.GetBinds(form))
+ Bind(req);
+ }
+ Bind(EnterAction = new Trigger(this, panel => (panel as SettingsPanel).Enter()));
+ Bind(BackAction = new Trigger(this, panel => (panel as SettingsPanel).Back()));
+
+ Optimize();
+ }
+
+ public void Enter()
+ {
+ ActiveSubwidget = SettingsList.Childs[SettingsList.Position].Child as IControlable;
+ var setting = ActiveSubwidget as Settings.Setting;
+ setting.OnEntered();
+ setting.Redraw();
+ }
+
+ public void Back()
+ {
+ ActiveSubwidget = null;
+ var setting = SettingsList.Childs[SettingsList.Position].Child as Settings.Setting;
+ setting.OnLeaving();
+ setting.Redraw();
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ if (ActiveSubwidget == null)
+ {
+ if (key == Key.E || key == Key.Enter)
+ EnterAction.Pull();
+ else SettingsList.OnKeyDown(key);
+ }
+ else
+ {
+ if (key == Key.Tab || key == Key.Backspace)
+ BackAction.Pull();
+ else ActiveSubwidget.OnKeyDown(key);
+ }
+
+ }
+
+ public void OnKeyUp(byte key)
+ {
+ if (ActiveSubwidget == null)
+ SettingsList.OnKeyUp(key);
+ else ActiveSubwidget.OnKeyUp(key);
+ }
+ }
+
+ public class FormPanel : DashboardPanel, IControlable
{
+ public override string PanelName => Localization.Current["DASH_PN_FormInfo"];
+ public override bool LockChanger => false;
+ public TriggerRedrawer OldFormInfoRedrawer;
- var extras = new string[]
+ public FormPanel(Form form) : base(form)
{
- "EXTRA KEYS", "F2 - External resize", "F3/F4 - Height -/+", "F5/F6 - Width -/+",
- "F7 - Show UPS", "F8 - UPS unlim", "F9 - Pause KCore", "F10 - All redraw"
+ Bind(OldFormInfoRedrawer = new TriggerRedrawer(form, panel =>
+ {
+ var dashboard = (panel as Form);
+ var Reference = dashboard.Reference;
+
+ Terminal.Set(1, 4);
+ $"{Localization.Current["DASH_F_Current"]}: %=>Red%{Reference?.GetType().FullName ?? "null"}%=>reset%".PrintSuperText();
+ if (Reference != null)
+ {
+ var req = Reference.Requests;
+ Terminal.Set(4, 5);
+ $"{Localization.Current["DASH_F_StartedFrom"]}: %=>Red%{Reference.Reference?.GetType().FullName ?? "null"}%=>reset%".PrintSuperText();
+ Terminal.Set(4, 6);
+ $"{Localization.Current["DASH_F_FormTimer"]}: %=>DarkGreen%{Reference.FormTimer.TotalSeconds:0.##}%=>reset% {Localization.Current["DASH_F_sec"]}".PadRight(50).PrintSuperText();
+ Terminal.Set(4, 7);
+ $"{Localization.Current["DASH_F_Delay"]}: %=>DarkGreen%{Reference.RealUPS.TotalMilliseconds:0.##}%=>reset% {Localization.Current["DASH_F_msec"]}".PadRight(50).PrintSuperText();
+ Terminal.Set(4, 8);
+ $"{Localization.Current["DASH_F_Total"]}: %=>DarkGreen%{req.Count(x => x.AllRedraw)}%=>reset%/%=>DarkGreen%{req.Length}%=>reset%".PrintSuperText();
+ Terminal.Set(4, 9);
+ var childs = Reference.Root.GetChilds();
+ $"{Localization.Current["DASH_F_RootWidgets"]}: %=>DarkGreen%{childs.Length}%=>reset%".PrintSuperText();
+ var max = Math.Min(Terminal.FixedWindowHeight - 12, childs.Length);
+ for (var i = 0; i < max; i++)
+ {
+ Terminal.Set(7, 10 + i);
+ var type = childs[i].GetType();
+ var assembly = type.Assembly.GetName().Name;
+ var name = type.Name;
+ $"%=>Blue%[{assembly}]%=>reset% {name}".PrintSuperText();
+ }
+ }
+ }));
+ Optimize();
+ }
+
+ public void OnKeyDown(byte key)
+ {
+
+ }
+
+ public void OnKeyUp(byte key)
+ {
+
+ }
+ }
+
+ public class PalettePanel : DashboardPanel, IControlable
+ {
+ public override string PanelName => Localization.Current["DASH_PN_Palette"];
+ public override bool LockChanger => false;
+ public TriggerRedrawer PaletteRedrawer;
+ public string chars = Chars.MixingMultipliers.Keys.ToArray().JoinIntoString("");
+
+ public PalettePanel(Form form) : base(form)
+ {
+
+ Bind(PaletteRedrawer = new TriggerRedrawer(form, panel =>
+ {
+ Terminal.Set(1, 4);
+ Terminal.Write(Localization.Current["DASH_PaletteInfo"]);
+ Terminal.ResetColor();
+ var j = 0;
+ foreach (var x in chars.Batch(Terminal.FixedWindowWidth / 2 + Terminal.FixedWindowWidth / 3))
+ {
+ Terminal.Set(2, j + 6);
+ Terminal.Write(x.JoinIntoString(""));
+ j += 1;
+ }
+ Terminal.ResetColor();
+ }));
+ Optimize();
+ }
+
+ public void OnKeyDown(byte key)
+ {
+
+ }
+
+ public void OnKeyUp(byte key)
+ {
+
+ }
+ }
+
+ public class VersionPanel : DashboardPanel, IControlable
+ {
+ private const string DeveloperNotSpecify = "#DNS#";
+ #region KCore Version API
+
+ public static Func GetEntryVersion = () =>
+ {
+ var assembly = Assembly.GetEntryAssembly();
+ var ret = new KCoreVersionInfo();
+ var name = assembly.GetName();
+ ret.Name = name.Name;
+ ret.Copyright = assembly.GetCustomAttribute().Copyright;
+ ret.Version = name.Version.ToString();
+ ret.Differences = new KeyValuePair[1] {
+ new KeyValuePair(ret.Version.ToString(), DeveloperNotSpecify)
+ };
+ return ret;
+ };
+ public interface IKCoreVersionInfo
+ {
+ string Copyright { get; set; }
+ KeyValuePair[] Differences { get; set; }
+ string Name { get; set; }
+ string Version { get; set; }
+ }
+
+ #region non-public
+ internal class KCoreVersionInfo : IKCoreVersionInfo
+ {
+ public string Name { get; set; }
+ public string Copyright { get; set; }
+ public string Version { get; set; }
+ public KeyValuePair[] Differences { get; set; }
+ }
+
+ private static KeyValuePair[] kcore_diffs;
+
+ static VersionPanel()
+ {
+ var kcore_ass = Assembly.GetExecutingAssembly();
+ kcore_diffs = kcore_ass.GetManifestResourceNames().Where(x => x.StartsWith("KCore.docs.versions."))
+ .Select(x => new KeyValuePair(x.Replace("KCore.docs.versions.", ""), kcore_ass.GetManifestResourceStream(x).ReadString())).ToArray();
+ }
+
+ internal static Func GetKCoreVersion = () =>
+ {
+ return new KCoreVersionInfo()
+ {
+ Name = KCoreVersion.Name,
+ Copyright = KCoreVersion.Copyright,
+ Version = Version.Version,
+ Differences = kcore_diffs,
+ };
};
- var left = Terminal.FixedWindowWidth - extras.Select(x => x.Length).Max() - 1;
- for (var i = 0; i < extras.Length; i++)
+ #endregion
+ #endregion
+
+ public IKCoreVersionInfo KCoreVersionInformation;
+ public IKCoreVersionInfo EntryVersionInformation;
+
+ public string[] VersionContent;
+ public ListBox VersionList;
+ public ScrollableText VersionText;
+ public Window VersionShow;
+ public TriggerRedrawer MainInfoRedrawer;
+ private Localization last_localization;
+
+ public VersionPanel(Form form) : base(form)
{
- Terminal.Set(left, 1 + i);
- Terminal.Write(extras[i]);
+ KCoreVersionInformation = GetKCoreVersion();
+ EntryVersionInformation = GetEntryVersion();
+
+ VersionList = new ListBox();
+
+ var initial_diffs = EntryVersionInformation.Differences.OrderByDescending(x => x.Key)
+ .Select(x => (x.Value, $"{EntryVersionInformation.Name} {x.Key}"))
+ .Concat(KCoreVersionInformation.Differences.OrderByDescending(x => x.Key)
+ .Select(x => (x.Value, $"{KCoreVersionInformation.Name} {x.Key}")));
+
+
+ VersionContent = initial_diffs.Select(x => x.Item1).ToArray();
+ VersionList.Childs =
+ initial_diffs.Select(x => x.Item2)
+ .Select(x => new ListBox.ListItem(new TextWidget(x, alignment: Alignment.LeftWidth | Alignment.UpHeight, fillHeight: false)))
+ .ToList();
+ VersionList.SelectingPadding = (1, 1);
+
+ var max = initial_diffs.Select(x => x.Item2).MaxBy(x => x).Length;
+ VersionList.Container = new DynamicContainer()
+ {
+ GetLeft = () => 1,
+ GetTop = () => 4,
+ GetWidth = () => max + 4,
+ GetHeight = () => 4,
+ };
+ var scroll = new VerticalScroll(VersionList, container: new DynamicContainer()
+ {
+ GetLeft = () => max + 5,
+ GetTop = () => 4,
+ GetWidth = () => 1,
+ GetHeight = () => 4,
+ }, pixel: ' ', scrollPixel: '▐');
+ VersionList.Scroll = scroll;
+ scroll.Resize();
+ Bind(scroll);
+
+ VersionList.Resize();
+ VersionList.OnChanged += list_box =>
+ {
+ VersionText.Text = VersionContent[VersionList.Position];
+ VersionShow.Resize();
+ VersionText.Redraw();
+ };
+ Bind(VersionList);
+
+ VersionShow = new Window(
+ VersionText = new ScrollableText(VersionContent[0], textAlignment: TextAlignment.Left)
+ );
+ VersionShow.HasBorder = false;
+ VersionShow.Padding = (0, 0, 0, 0);
+ VersionText.Autoscroll = true;
+ Bind(VersionText);
+
+ VersionShow.Container = new DynamicContainer()
+ {
+ GetLeft = () => 1,
+ GetTop = () => 9,
+ GetWidth = () => Terminal.FixedWindowWidth - 2,
+ GetHeight = () => Terminal.FixedWindowHeight - 10,
+ };
+ VersionShow.Resize();
+ Bind(VersionShow);
+
+ Bind(MainInfoRedrawer = new TriggerRedrawer(form, __ =>
+ {
+ var cont = new StaticContainer(max + 8, 4, Terminal.FixedWindowWidth - max - 8, 2);
+ var cont2 = new StaticContainer(max + 8, 6, Terminal.FixedWindowWidth - max - 8, 2);
+
+ string.Format(Localization.Current["DASH_EntryBy"], EntryVersionInformation.Name, EntryVersionInformation.Version, EntryVersionInformation.Copyright, KCoreStorage.EntryLINK).PrintSuperText(cont);
+
+ string.Format(Localization.Current["DASH_KCoreBy"], KCoreVersionInformation.Name, KCoreVersionInformation.Version, KCoreVersionInformation.Copyright, KCoreStorage.KCoreLINK).PrintSuperText(cont2);
+ }));
+
+ Bind(new DelegateRequest(form, frm => VersionText.Text.StartsWith(DeveloperNotSpecify) || last_localization != Localization.Current, frm =>
+ {
+ if (Localization.Current != last_localization && VersionContent[VersionList.Position].StartsWith(DeveloperNotSpecify))
+ {
+ VersionText.Text = VersionContent[VersionList.Position].Replace(DeveloperNotSpecify, string.Format(Localization.Current["DASH_VersionUndefined"], EntryVersionInformation.Name));
+ }
+ else VersionText.Text = VersionText.Text.Replace(DeveloperNotSpecify, string.Format(Localization.Current["DASH_VersionUndefined"], EntryVersionInformation.Name));
+ last_localization = Localization.Current;
+ VersionText.Resize();
+ VersionText.Redraw();
+ }));
+
+ Optimize();
}
- Terminal.Set(Terminal.FixedWindowWidth - 11, Terminal.FixedWindowHeight - 1);
- Terminal.Write("Close: F12");
+ public override string PanelName => Localization.Current["DASH_PN_Version"];
- Terminal.Set(1, 1);
- $"Current: %=>Red%{Reference?.GetType().FullName ?? "null"}%=>reset%".PrintSuperText();
- if (Reference != null)
+ public override bool LockChanger => false;
+
+ public void OnKeyDown(byte key)
+ {
+ VersionList.OnKeyDown(key);
+ }
+
+ public void OnKeyUp(byte key)
+ {
+
+ }
+ }
+
+ public class PanelChanger : Widget, IControlable
+ {
+ public Dashboard Reference;
+ public Trigger LeftTrigger;
+ public Trigger RightTrigger;
+
+ public PanelChanger(Dashboard form)
+ {
+ Reference = form;
+ Container = new DynamicContainer()
+ {
+ GetLeft = () => 0,
+ GetTop = () => 1,
+ GetWidth = () => Terminal.FixedWindowWidth,
+ GetHeight = () => 2
+ };
+ }
+
+ public override IList GetBinds(Form form)
+ {
+ return new Request[]
+ {
+ LeftTrigger = new Trigger(form, x => Prev()),
+ RightTrigger = new Trigger(form, x => Next()),
+ };
+ }
+
+
+ public void Prev()
+ {
+ var ind = Array.FindIndex(Reference.Panels, x => Reference.current_panel == x);
+ var xind = ind;
+ ind--;
+ if (ind < 0) ind = 0;
+ if (xind != ind)
+ {
+ Reference.CurrentPanel = Reference.Panels[ind] as IControlable;
+ Reference.Clear();
+ }
+ }
+ public void Next()
{
- var req = Reference.Requests;
- Terminal.Set(4, 2);
- $"Started from: %=>Red%{Reference.Reference?.GetType().FullName ?? "null"}%=>reset%".PrintSuperText();
- Terminal.Set(4, 3);
- $"FormTimer: %=>DarkGreen%{Reference.FormTimer.TotalSeconds:0.##}%=>reset% sec".PadRight(50).PrintSuperText();
- Terminal.Set(4, 4);
- $"Delay: %=>DarkGreen%{Reference.RealUPS.TotalMilliseconds:0.##}%=>reset% ms".PadRight(50).PrintSuperText();
- Terminal.Set(4, 5);
- $"Total redrawers/requests: %=>DarkGreen%{req.Count(x => x.AllRedraw)}%=>reset%/%=>DarkGreen%{req.Length}%=>reset%".PrintSuperText();
- Terminal.Set(4, 6);
- $"Root widgets: %=>DarkGreen%{Reference.Root.Childs.Count}%=>reset%".PrintSuperText();
- var max = Math.Min(Terminal.FixedWindowHeight - 8, Reference.Root.Childs.Count);
- for (var i = 0; i < max; i++)
+ var ind = Array.FindIndex(Reference.Panels, x => Reference.current_panel == x);
+ var xind = ind;
+ ind++;
+ if (ind >= Reference.Panels.Length) ind = Reference.Panels.Length - 1;
+ if (xind != ind)
{
- Terminal.Set(7, 7 + i);
- var type = Reference.Root.Childs[i].GetType();
- var assembly = type.Assembly.GetName().Name;
- var name = type.Name;
- $"%=>Blue%[{assembly}]%=>reset% {name}".PrintSuperText();
+ Reference.CurrentPanel = Reference.Panels[ind] as IControlable;
+ Reference.Clear();
}
}
+
+ public override IContainer Container { get => TerminalContainer.This; set { } }
+ public override int Width => Terminal.FixedWindowWidth;
+ public override int Height => 1;
+ public override void Resize() { }
+ public override bool AlwaysClear => true;
+
+ public override (int, int) Draw(int left, int top)
+ {
+ var indent = 0;
+ Terminal.Set(0, 2);
+ Terminal.Write(Graph.Chars('─', Terminal.FixedWindowWidth));
+ for (var i = 0; i < Reference.Panels.Length; i++)
+ {
+ var str = $"{Reference.Panels[i].PanelName}";
+ if (Reference.CurrentPanel == Reference.Panels[i])
+ {
+ Terminal.Set(1 + indent, 2);
+ Console.Write('┘' + Graph.Chars(' ', str.Length + 2) + '└');
+ str = $"│ {str} │";
+ }
+ else str = $" {str} ";
+ Terminal.Set(1 + indent, 1);
+ indent += str.Length + 2;
+ str.PrintSuperText();
+ }
+ return (left, top);
+ }
+ public override (int, int) Clear(int left, int top)
+ {
+ Graph.FillRectangle(Theme.Back, this);
+ return (left, top);
+ }
+
+ public void OnKeyDown(byte key)
+ {
+ Reference.CurrentPanel.OnKeyDown(key);
+ if ((Reference.CurrentPanel as DashboardPanel).LockChanger) return;
+ if (key == Key.A || key == Key.LeftArrow)
+ LeftTrigger.Pull();
+ else if (key == Key.D || key == Key.RightArrow)
+ RightTrigger.Pull();
+ }
+ public void OnKeyUp(byte key)
+ {
+ Reference.CurrentPanel.OnKeyUp(key);
+ }
+ }
+
+ public PanelChanger Changer;
+
+ public DashboardPanel[] Panels;
+
+ public SettingsPanel FieldSettingsPanel;
+ public FormPanel FieldFormPanel;
+ public VersionPanel FieldVersionPanel;
+ public PalettePanel FieldPalettePanel;
+
+ internal IControlable current_panel;
+ public IControlable CurrentPanel { get => current_panel; set
+ {
+ if (current_panel != null)
+ {
+ var panel1 = (current_panel as Panel);
+ panel1.Visible = false;
+ panel1.Enabled = false;
+ }
+ current_panel = value;
+ var panel2 = (current_panel as Panel);
+ panel2.Visible = true;
+ panel2.Enabled = true;
+ } }
+
+ public Dashboard()
+ {
+ Bind(Downline = new TriggerRedrawer(this, form =>
+ {
+ Terminal.Set(1, Terminal.FixedWindowHeight - 1);
+ ($"KCore {Version.Version}").PrintSuperText();
+ }));
+
+ FieldSettingsPanel = new SettingsPanel(this);
+ FieldFormPanel = new FormPanel(this);
+ FieldVersionPanel = new VersionPanel(this);
+ FieldPalettePanel = new PalettePanel(this);
+
+ Panels = new DashboardPanel[] { FieldSettingsPanel, FieldFormPanel, FieldVersionPanel, FieldPalettePanel };
+ foreach (var x in Panels)
+ {
+ Bind(x);
+ if (x == FieldSettingsPanel) continue;
+ x.Visible = false;
+ x.Enabled = false;
+ }
+ Bind(Changer = new PanelChanger(this));
+ ActiveWidget = Changer;
+ }
+
+ protected override void OnOpening()
+ {
+ CurrentPanel = FieldSettingsPanel;
+ Clear();
+ }
+
+ protected override void OnResize()
+ {
+ FieldSettingsPanel.Resize();
+ }
+
+ protected override bool IsRecursiveForm() => true;
+
+ protected override void OnAllRedraw()
+ {
+ var str = Localization.Current["KCore_DASH_Close"];
+ Terminal.Set(Terminal.FixedWindowWidth - 1 - str.Length, Terminal.FixedWindowHeight - 1);
+ Terminal.Write(str);
}
protected override void OnKeyDown(byte key)
{
+ base.OnKeyDown(key);
if (key == Key.F12) Close();
if (key == Key.OemPlus && Terminal.UpdatesPerSecond > 0)
{
Terminal.UpdatesPerSecond += 10;
- Downline.Do();
+ Downline.Pull();
}
if (key == Key.OemMinus && Terminal.UpdatesPerSecond > 10)
{
Terminal.UpdatesPerSecond -= 10;
- Downline.Do();
+ Downline.Pull();
}
}
}
diff --git a/KCore/CoreForms/ExceptionViewer.cs b/KCore/CoreForms/ExceptionViewer.cs
index 0408f6d..6e3605a 100644
--- a/KCore/CoreForms/ExceptionViewer.cs
+++ b/KCore/CoreForms/ExceptionViewer.cs
@@ -152,10 +152,10 @@ private void ChangeStyle()
private Trigger ExitRequest, RestartRequest, ChangeStyleRequest;
protected override void OnKeyDown(byte key)
{
- if (key == Key.F5) ChangeStyleRequest.Do();
- else if (key == Key.Escape) ExitRequest.Do();
- else if (key == Key.Enter || key == Key.E || key == Key.Spacebar) RestartRequest.Do();
- else if (key != Key.Escape && key > 2) RestartRequest.Do();
+ if (key == Key.F5) ChangeStyleRequest.Pull();
+ else if (key == Key.Escape) ExitRequest.Pull();
+ else if (key == Key.Enter || key == Key.E || key == Key.Spacebar) RestartRequest.Pull();
+ else if (key != Key.Escape && key > 2) RestartRequest.Pull();
}
}
}
diff --git a/KCore/CoreForms/ResizeViewer.cs b/KCore/CoreForms/ResizeViewer.cs
index 5c25cd0..3807174 100644
--- a/KCore/CoreForms/ResizeViewer.cs
+++ b/KCore/CoreForms/ResizeViewer.cs
@@ -1,5 +1,6 @@
using KCore.Extensions;
using KCore.Graphics;
+using KCore.Storage;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,14 +13,15 @@ public class ResizeViewer : Form
{
public static TimeSpan ResizePause = new TimeSpan(1 * TimeSpan.TicksPerSecond);
public static bool ResizeStarted;
- public static string YouAreResizingTheConsoleWindow = "You are resizing the console window";
- public static string GoingBackVia = "Going back via {0:0.0} secs";
+ private static string YouAreResizingTheConsoleWindow => Localization.Current["KCore_Resizing1"];
+ private static string GoingBackVia => Localization.Current["KCore_Resizing2"];
public ResizeViewer()
{
+ AllowedDashboard = false;
LastResize = FormTimer;
- Bind(new DelegateRequest(this, form => (form.FormTimer - LastResize) > ResizePause, form => Close()));
- Bind(new Redrawer(this, form => (form.FormTimer - LastSecsRedrawed).TotalMilliseconds > 5, form => RedrawSecs()));
+ Bind(new DelegateRequest(this, form => ((form as Form).FormTimer - LastResize) > ResizePause, form => Close()));
+ Bind(new Redrawer(this, form => ((form as Form).FormTimer - LastSecsRedrawed).TotalMilliseconds > 5, form => RedrawSecs()));
}
public TimeSpan LastResize;
@@ -28,11 +30,11 @@ public ResizeViewer()
public void RedrawSecs()
{
LastSecsRedrawed = FormTimer;
- Terminal.Set(0, Terminal.FixedWindowHeight / 2);
+ Terminal.Set(10, Terminal.FixedWindowHeight / 2);
Terminal.Write(string.Format(
GoingBackVia,
(LastResize - FormTimer + ResizePause)
- .TotalSeconds.Round(1)).PadCenter(Terminal.FixedWindowWidth));
+ .TotalSeconds.Round(1)).PadCenter(Terminal.FixedWindowWidth - 20));
}
protected override void OnOpening()
@@ -52,10 +54,17 @@ protected override void OnResize()
protected override void OnAllRedraw()
{
- Terminal.Set(0, Terminal.FixedWindowHeight / 2 - 2);
- Terminal.Write($"{Terminal.FixedWindowWidth}x{Terminal.FixedWindowHeight}".PadCenter(Terminal.FixedWindowWidth));
- Terminal.Set(0, Terminal.FixedWindowHeight / 2 - 1);
- Terminal.Write(YouAreResizingTheConsoleWindow.PadCenter(Terminal.FixedWindowWidth));
+ Terminal.Set(10, Terminal.FixedWindowHeight / 2 - 2);
+ Terminal.Write($"{Terminal.FixedWindowWidth}x{Terminal.FixedWindowHeight}".PadCenter(Terminal.FixedWindowWidth - 20));
+ Terminal.Set(10, Terminal.FixedWindowHeight / 2 - 1);
+ Terminal.Write(YouAreResizingTheConsoleWindow.PadCenter(Terminal.FixedWindowWidth - 20));
+
+ Terminal.Back = Theme.Fore;
+ Graph.Row((Terminal.FixedWindowWidth - 20) / 2, 0, 20);
+ Graph.Row((Terminal.FixedWindowWidth - 20) / 2, Terminal.FixedWindowHeight - 1, 20);
+ Graph.Column(0, (Terminal.FixedWindowHeight - 6) / 2, 6);
+ Graph.Column(Terminal.FixedWindowWidth - 1, (Terminal.FixedWindowHeight - 6) / 2, 6);
+ Terminal.ResetColor();
}
}
}
diff --git a/KCore/Extensions/InsteadSLThree/SLThreeExtensions.cs b/KCore/Extensions/InsteadSLThree/SLThreeExtensions.cs
index 7e37bda..9faeace 100644
--- a/KCore/Extensions/InsteadSLThree/SLThreeExtensions.cs
+++ b/KCore/Extensions/InsteadSLThree/SLThreeExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
@@ -10,6 +11,20 @@ namespace KCore.Extensions.InsteadSLThree
{
public static class SLThreeExtensions
{
+ public static string ReadString(this Stream stream)
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ return sr.ReadToEnd();
+ }
+ }
+ public static string[] ReadStrings(this Stream stream)
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ return sr.ReadToEnd().Split(new string[1] { Environment.NewLine }, StringSplitOptions.None);
+ }
+ }
public static string JoinIntoString(this IEnumerable e, string delim)
{
var g = e.GetEnumerator();
@@ -52,5 +67,21 @@ public static T MaxBy(this IEnumerable enumerable, Func sel
var comp = Comparer.Default;
return enumerable.Aggregate((max, x) => comp.Compare(selector(x), selector(max)) > 0 ? x : max);
}
+
+ public static IEnumerable Batch(this IEnumerable enumerable, int size)
+ {
+ var buf = new List();
+ foreach (var elem in enumerable)
+ {
+ buf.Add(elem);
+ if (buf.Count == size)
+ {
+ yield return buf.ToArray();
+ buf.Clear();
+ }
+ }
+ if (buf.Count > 0)
+ yield return buf.ToArray();
+ }
}
}
diff --git a/KCore/Forms/Form.cs b/KCore/Forms/Form.cs
index c28e0b5..86167ed 100644
--- a/KCore/Forms/Form.cs
+++ b/KCore/Forms/Form.cs
@@ -10,26 +10,26 @@
using KCore.Graphics;
using KCore.Graphics.Widgets;
using System.CodeDom.Compiler;
+using KCore.Storage;
+using KCore.Tools;
namespace KCore
{
///
/// Базовый тип консольных окон
///
- public abstract class Form
+ public abstract class Form : BasePanel
{
public Form()
{
Root = new RootWidget(this);
}
#region fields and vmethods
- private bool status, allredraw, resize;
+ internal bool allredraw;
- private bool clear;
-
- private int redrawersstart;
+ private bool status, resize;
- private bool optimized = false;
+ private bool clear;
private bool needshowing = false;
@@ -94,33 +94,12 @@ protected virtual void OnResize() { }
private TimeSpan LastEndExecuted;
public TimeSpan RealUPS => LastEndExecuted - LastStartExecuted;
- private List requestList = new List();
- private Request[] requests;
- public Request[] Requests => requestList.ToArray();
private readonly Stopwatch stopwatch = new Stopwatch();
public Form Reference { get; set; } = null;
-
- private void Optimize()
- {
- if (requestList?.Count > 0)
- {
- requests = new Request[requestList.Count]; var index = 0;
-
- for (var i = 0; i < requestList.Count; i++)
- if (!requestList[i].AllRedraw) requests[index++] = requestList[i];
- for (var i = 0; i < requestList.Count; i++)
- if (requestList[i].AllRedraw) requests[index++] = requestList[i];
-
- redrawersstart = Array.FindIndex(requests, x => x.AllRedraw);
- if (redrawersstart == -1) redrawersstart = requests.Length;
- }
- else
- {
- requests = new Request[0];
- }
- optimized = true;
- }
+ public override Form GetBindingForm() => this;
+ public override bool AllRedraw => allredraw;
+ protected override IList GetPanelBinds() => requestList;
public readonly RootWidget Root;
///
@@ -128,40 +107,6 @@ private void Optimize()
///
public IControlable ActiveWidget { get; set; }
- #region Binds
- public void Bind(Request request)
- {
- requestList.Add(request);
- optimized = false;
- }
- public void Bind(params Request[] requests)
- {
- requestList.AddRange(requests);
- optimized = false;
- }
- public void Bind(Widget widget)
- {
- requestList.AddRange(widget.InternalGetBinds(this));
- optimized = false;
- }
- public void Bind(params Widget[] widgets)
- {
- for (var i = 0; i < widgets.Length; i++)
- requestList.AddRange(widgets[i].InternalGetBinds(this));
- optimized = false;
- }
- public void Unbind(Request request)
- {
- requestList.Remove(request);
- optimized = false;
- }
- public void Unbind(Widget widget)
- {
- requestList.RemoveAll(x => x is Widget.IWidgetRequest wr && wr.Widget == widget);
- optimized = false;
- }
- #endregion
-
#region Main Logic
private void MainLoop(bool exit_after = true)
{
@@ -257,11 +202,11 @@ private void MainLoop(bool exit_after = true)
}
catch (ArgumentException e) when (e.TargetSite.Name == "SetCursorPosition")
{
- //resize = true;
+ Log.Add(e.ToString());
}
catch (ArgumentOutOfRangeException e) when (e.TargetSite.Name == "SetBufferSize")
{
- //resize = true;
+ Log.Add(e.ToString());
}
if (!needshowing && !Terminal.WindowIsActive)
@@ -311,6 +256,7 @@ public void OneTimeDrawForRedirection()
public void Start(bool redirected = false)
{
+ KCoreStorage.Init();
if (!optimized) Optimize();
Terminal.AddKeyDown(OnKeyDown);
@@ -332,6 +278,7 @@ public void Start(bool redirected = false)
}
catch (Exception e)
{
+ Log.Add(e.ToString());
var ev = new ExceptionViewer(e, AllowedRestartAfterException);
this.StartAnimation(ev);
if (!ev.Restarted) status = false;
@@ -480,10 +427,10 @@ public static void Abort()
protected bool AllowedDashboard = AllowDashboardInAllForms;
private static bool ManualStop = false;
internal static string ConsoleShellTextLeft = "KCore " + Dashboard.Version.Major + "." + Dashboard.Version.Minor + " ";
- const string ConsoleShellTextRight = "Dashboard: F12";
+ internal static string ConsoleShellTextRight => Localization.Current["KCore_DASH"];
private static bool ManualRedraw = false;
private static bool RaiseException = false;
- private static bool ShowUPS = false;
+ internal static bool ShowUPS = false;
public bool ManualLock = false;
protected virtual bool IsRecursiveForm() => false;
protected static Form ExceptionForm;
@@ -491,13 +438,7 @@ public static void Abort()
private static bool ActiveDashboard;
private static void ConsoleShellActivate(byte x)
{
- if (x == Key.F7)
- {
- ShowUPS = !ShowUPS;
- ManualRedraw = true;
- }
if (x == Key.F8) ManualRedraw = true;
- //if (x == Key.F9) RaiseException = true;
if (x == Key.F9) ManualStop = !ManualStop;
if (x == Key.F10) ManualRedraw = true;
if (x == Key.F12) ActiveDashboard = true;
diff --git a/KCore/Forms/Request.cs b/KCore/Forms/Request.cs
index 97c69d4..497a7d3 100644
--- a/KCore/Forms/Request.cs
+++ b/KCore/Forms/Request.cs
@@ -11,13 +11,14 @@ namespace KCore.Graphics
[DebuggerDisplay("[{GetType().Name}]")]
public abstract class Request
{
- private Form bindedTo;
- public Form BindedTo => bindedTo;
+ private BasePanel bindedTo;
+ public BasePanel BindedTo => bindedTo;
public virtual bool AllRedraw => false;
+ public abstract void Send();
public abstract void Cancel();
public abstract bool Condition();
public abstract void Invoke();
- public Request(Form form)
+ public Request(BasePanel form)
{
bindedTo = form;
}
@@ -26,9 +27,9 @@ public Request(Form form)
public class Trigger : Request
{
private bool Request;
- public Action