diff --git a/BlueprintExplorer/BlueprintControl.cs b/BlueprintExplorer/BlueprintControl.cs index deae8ff..566b433 100644 --- a/BlueprintExplorer/BlueprintControl.cs +++ b/BlueprintExplorer/BlueprintControl.cs @@ -169,7 +169,11 @@ private string CalculatePath() } } - public int RowHeight { get; set; } = 36; + public int RowHeight + { + get { return (Regular?.Height ?? 32) + 4; } + set { } + } protected override CreateParams CreateParams { @@ -206,6 +210,18 @@ public BlueprintControl() }; ToastTimer.Interval = 33; ToastTimer.Start(); + + Regular = new Font(Font.FontFamily, (float)BubblePrints.Settings.BlueprintFontSize, FontStyle.Regular); + Bold = new Font(Font.FontFamily, (float)BubblePrints.Settings.BlueprintFontSize, FontStyle.Bold); + + BubblePrints.OnSettingsChanged += BubblePrints_OnSettingsChanged; + } + + private void BubblePrints_OnSettingsChanged() + { + Regular = new Font(Font.FontFamily, (float)BubblePrints.Settings.BlueprintFontSize, FontStyle.Regular); + Bold = new Font(Font.FontFamily, (float)BubblePrints.Settings.BlueprintFontSize, FontStyle.Bold); + ValidateBlueprint(false); } protected override void OnBackColorChanged(EventArgs e) => UpdateRowHoverColor(); @@ -288,6 +304,8 @@ private void ValidateBlueprint(bool scroll) int strWidthAllowed = StringWidthAllowed; currentHover = -1; int totalRows = 0; + if (DisplayedObject == null) return; + if (DisplayedObject != null) { Elements.Add(new () @@ -823,15 +841,18 @@ protected override void OnMouseMove(MouseEventArgs e) } } + private Font Regular; + private Font Bold; protected override void OnPaint(PaintEventArgs e) { var g = e.Graphics; + DrawParams drawing = new() { - Bold = new Font(Font, FontStyle.Bold), - Regular = Font, + Regular = Regular, + Bold = Bold, Graphics = g, }; @@ -867,7 +888,7 @@ protected override void OnPaint(PaintEventArgs e) } - public Font LinkFont { get => linkFont ?? Font; set => linkFont = value; } + public Font LinkFont { get => Regular; set => linkFont = value; } private SolidBrush RowHoverColor; private Pen RowLineGuide; private SolidBrush RowPreviewHoverColor; diff --git a/BlueprintExplorer/BlueprintViewer.Designer.cs b/BlueprintExplorer/BlueprintViewer.Designer.cs index 276cac5..1214932 100644 --- a/BlueprintExplorer/BlueprintViewer.Designer.cs +++ b/BlueprintExplorer/BlueprintViewer.Designer.cs @@ -33,9 +33,11 @@ private void InitializeComponent() this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); this.currentPath = new System.Windows.Forms.TextBox(); - this.filter = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); this.openExternal = new System.Windows.Forms.Button(); + this.copyTemplate = new System.Windows.Forms.Button(); + this.label1 = new System.Windows.Forms.Label(); + this.filter = new System.Windows.Forms.TextBox(); + this.templatesList = new System.Windows.Forms.ComboBox(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.references = new System.Windows.Forms.DataGridView(); this.From = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -62,7 +64,7 @@ private void InitializeComponent() this.view.Name = "view"; this.view.NameColumnWidth = 600; this.view.RowHeight = 36; - this.view.Size = new System.Drawing.Size(1845, 1054); + this.view.Size = new System.Drawing.Size(1843, 1060); this.view.TabIndex = 0; this.view.Text = "blueprintControl1"; // @@ -79,21 +81,25 @@ private void InitializeComponent() this.tableLayoutPanel1.RowCount = 3; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 54F)); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 60F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 54F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(2336, 1174); this.tableLayoutPanel1.TabIndex = 0; // // tableLayoutPanel2 // - this.tableLayoutPanel2.ColumnCount = 4; + this.tableLayoutPanel2.ColumnCount = 6; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 400F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 120F)); this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel2.Controls.Add(this.currentPath, 3, 0); - this.tableLayoutPanel2.Controls.Add(this.filter, 1, 0); - this.tableLayoutPanel2.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.currentPath, 5, 0); this.tableLayoutPanel2.Controls.Add(this.openExternal, 2, 0); + this.tableLayoutPanel2.Controls.Add(this.copyTemplate, 4, 0); + this.tableLayoutPanel2.Controls.Add(this.label1, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.filter, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.templatesList, 3, 0); this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 3); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; @@ -106,21 +112,36 @@ private void InitializeComponent() // this.currentPath.Dock = System.Windows.Forms.DockStyle.Fill; this.currentPath.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.currentPath.Location = new System.Drawing.Point(703, 3); + this.currentPath.Location = new System.Drawing.Point(1023, 3); this.currentPath.Name = "currentPath"; this.currentPath.PlaceholderText = "..."; this.currentPath.ReadOnly = true; - this.currentPath.Size = new System.Drawing.Size(1624, 39); + this.currentPath.Size = new System.Drawing.Size(1304, 39); this.currentPath.TabIndex = 3; // - // filter + // openExternal // - this.filter.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.filter.Location = new System.Drawing.Point(103, 3); - this.filter.Name = "filter"; - this.filter.PlaceholderText = "..."; - this.filter.Size = new System.Drawing.Size(394, 39); - this.filter.TabIndex = 1; + this.openExternal.AutoSize = true; + this.openExternal.Dock = System.Windows.Forms.DockStyle.Fill; + this.openExternal.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.openExternal.Location = new System.Drawing.Point(503, 3); + this.openExternal.Name = "openExternal"; + this.openExternal.Size = new System.Drawing.Size(194, 42); + this.openExternal.TabIndex = 1; + this.openExternal.Text = "Open In Editor"; + this.openExternal.UseVisualStyleBackColor = true; + // + // copyTemplate + // + this.copyTemplate.AutoSize = true; + this.copyTemplate.Dock = System.Windows.Forms.DockStyle.Fill; + this.copyTemplate.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.copyTemplate.Location = new System.Drawing.Point(903, 3); + this.copyTemplate.Name = "copyTemplate"; + this.copyTemplate.Size = new System.Drawing.Size(114, 42); + this.copyTemplate.TabIndex = 4; + this.copyTemplate.Text = "Template!"; + this.copyTemplate.UseVisualStyleBackColor = true; // // label1 // @@ -132,16 +153,24 @@ private void InitializeComponent() this.label1.Text = "Filter:"; this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // openExternal + // filter // - this.openExternal.AutoSize = true; - this.openExternal.Font = new System.Drawing.Font("Segoe UI", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.openExternal.Location = new System.Drawing.Point(503, 3); - this.openExternal.Name = "openExternal"; - this.openExternal.Size = new System.Drawing.Size(194, 40); - this.openExternal.TabIndex = 1; - this.openExternal.Text = "Open In Editor"; - this.openExternal.UseVisualStyleBackColor = true; + this.filter.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.filter.Location = new System.Drawing.Point(103, 3); + this.filter.Name = "filter"; + this.filter.PlaceholderText = "..."; + this.filter.Size = new System.Drawing.Size(392, 39); + this.filter.TabIndex = 1; + // + // templatesList + // + this.templatesList.Dock = System.Windows.Forms.DockStyle.Fill; + this.templatesList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.templatesList.FormattingEnabled = true; + this.templatesList.Location = new System.Drawing.Point(703, 3); + this.templatesList.Name = "templatesList"; + this.templatesList.Size = new System.Drawing.Size(194, 33); + this.templatesList.TabIndex = 5; // // splitContainer1 // @@ -157,8 +186,8 @@ private void InitializeComponent() // splitContainer1.Panel2 // this.splitContainer1.Panel2.Controls.Add(this.references); - this.splitContainer1.Size = new System.Drawing.Size(2330, 1054); - this.splitContainer1.SplitterDistance = 1845; + this.splitContainer1.Size = new System.Drawing.Size(2330, 1060); + this.splitContainer1.SplitterDistance = 1843; this.splitContainer1.TabIndex = 0; // // references @@ -179,7 +208,7 @@ private void InitializeComponent() this.references.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.DisableResizing; this.references.RowTemplate.Height = 33; this.references.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.references.Size = new System.Drawing.Size(481, 1054); + this.references.Size = new System.Drawing.Size(483, 1060); this.references.TabIndex = 1; // // From @@ -195,15 +224,14 @@ private void InitializeComponent() this.historyBread.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.historyBread.Dock = System.Windows.Forms.DockStyle.Fill; this.historyBread.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.historyBread.Location = new System.Drawing.Point(3, 1117); + this.historyBread.Location = new System.Drawing.Point(3, 1123); this.historyBread.Name = "historyBread"; - this.historyBread.Size = new System.Drawing.Size(2330, 54); + this.historyBread.Size = new System.Drawing.Size(2330, 48); this.historyBread.TabIndex = 0; // // BlueprintViewer // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; this.Controls.Add(this.tableLayoutPanel1); this.Name = "BlueprintViewer"; this.Size = new System.Drawing.Size(2336, 1174); @@ -232,5 +260,7 @@ private void InitializeComponent() private System.Windows.Forms.Button openExternal; private System.Windows.Forms.TextBox currentPath; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.Button copyTemplate; + private System.Windows.Forms.ComboBox templatesList; } } diff --git a/BlueprintExplorer/BlueprintViewer.cs b/BlueprintExplorer/BlueprintViewer.cs index c2568ab..6de311d 100644 --- a/BlueprintExplorer/BlueprintViewer.cs +++ b/BlueprintExplorer/BlueprintViewer.cs @@ -52,6 +52,22 @@ public BlueprintViewer() } }; + BubblePrints.OnTemplatesChanged += BubblePrints_OnTemplatesChanged; + BubblePrints_OnTemplatesChanged(0, BubblePrints.Settings.GeneratorTemplate?.Length ?? 0); + if (templatesList.Items.Count > 0) + templatesList.SelectedIndex = 0; + + copyTemplate.Click += (sender, e) => + { + var availableTemplates = BubblePrints.Settings.GeneratorTemplate; + if (templatesList.SelectedIndex == -1) return; + if (templatesList.SelectedIndex >= availableTemplates.Length) return; + + var template = availableTemplates[templatesList.SelectedIndex]; + var result = TemplateRunner.Execute(template.Value, view.Blueprint as BlueprintHandle); + Clipboard.SetText(result); + }; + view.OnPathHovered += path => { currentPath.Text = path ?? "-"; @@ -67,7 +83,7 @@ public BlueprintViewer() filter.TextChanged += (sender, e) => view.Filter = filter.Text; if (Form1.Dark) { - BubbleTheme.DarkenControls(view, filter, references, openExternal, currentPath); + BubbleTheme.DarkenControls(view, filter, references, openExternal, copyTemplate, templatesList, currentPath); BubbleTheme.DarkenStyles(references.DefaultCellStyle, references.ColumnHeadersDefaultCellStyle); } @@ -77,6 +93,16 @@ public BlueprintViewer() this.AddMouseClickRecursively(HandleXbuttons); } + + private void BubblePrints_OnTemplatesChanged(int oldCount, int newCount) + { + templatesList.Items.Clear(); + foreach (var template in BubblePrints.Settings.GeneratorTemplate) + { + templatesList.Items.Add(template.Name); + } + } + private void HandleXbuttons(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.XButton1) diff --git a/BlueprintExplorer/BubblePrints.cs b/BlueprintExplorer/BubblePrints.cs index de10d43..dcb53b8 100644 --- a/BlueprintExplorer/BubblePrints.cs +++ b/BlueprintExplorer/BubblePrints.cs @@ -1,4 +1,6 @@ using System; +using System.Collections; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing.Design; using System.IO; @@ -11,6 +13,12 @@ namespace BlueprintExplorer { public static class BubblePrints { + public delegate void TemplatesChangedDelegate(int oldCount, int newCount); + public static event TemplatesChangedDelegate OnTemplatesChanged; + + public delegate void SettingsChangedDelegate(); + public static event SettingsChangedDelegate OnSettingsChanged; + public static SettingsProxy Settings = new(); private static string StoredWrathPath = null; public static bool TryGetWrathPath(out string path) @@ -64,7 +72,7 @@ internal static void SetWrathPath() if (folderBrowser.ShowDialog() != DialogResult.OK) return; - + path = folderBrowser.SelectedPath; var exePath = Path.Combine(path, "Wrath.exe"); @@ -87,8 +95,12 @@ internal static void SetWrathPath() public static string MakeDataPath(string subpath) => Path.Combine(DataPath, subpath); public static string SettingsPath => MakeDataPath("settings.json"); - - internal static void SaveSettings() => File.WriteAllText(SettingsPath, JsonSerializer.Serialize(Settings)); + internal static void SaveSettings() + { + File.WriteAllText(SettingsPath, JsonSerializer.Serialize(Settings)); + OnSettingsChanged?.Invoke(); + } + internal static void NotifyTemplatesChanged(int oldCount, int newCount) => OnTemplatesChanged?.Invoke(oldCount, newCount); } public enum ExportMode @@ -102,12 +114,16 @@ public class SettingsProxy { public void Sync() { + int oldCount = BubblePrints.Settings.GeneratorTemplate?.Length ?? 0; + var settings = BubblePrints.Settings; foreach (var p in GetType().GetProperties()) { p.SetValue(settings, p.GetValue(this)); } BubblePrints.SaveSettings(); + + BubblePrints.NotifyTemplatesChanged(oldCount, GeneratorTemplate?.Length ?? 0); } @@ -174,5 +190,21 @@ public SettingsProxy(SettingsProxy settings) [Description("This path will be used if the 'check for updates' is false, or if there is no connectivity to check for any later version")] [DisplayName("Most recent blueprints loaded")] public string LastLoaded { get; set; } + + [Description("Size of the font for the blueprint viewer")] + [DisplayName("Blueprint font size")] + public int BlueprintFontSize { get; set; } = 12; + + [Description("Template string for blueprint template generation - see help for more details")] + [DisplayName("Generator template")] + //[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] + public Template[] GeneratorTemplate { get; set; } + } + + public class Template + { + public string Name { get; set; } + public string Value { get; set; } + } } diff --git a/BlueprintExplorer/Form1.Designer.cs b/BlueprintExplorer/Form1.Designer.cs index 8dd7f60..1e7c11e 100644 --- a/BlueprintExplorer/Form1.Designer.cs +++ b/BlueprintExplorer/Form1.Designer.cs @@ -65,8 +65,8 @@ private void InitializeComponent() this.panel1.Dock = System.Windows.Forms.DockStyle.Top; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Padding = new System.Windows.Forms.Padding(8); - this.panel1.Size = new System.Drawing.Size(2442, 82); + this.panel1.Padding = new System.Windows.Forms.Padding(9, 8, 9, 8); + this.panel1.Size = new System.Drawing.Size(2440, 82); this.panel1.TabIndex = 1; // // controlBar @@ -85,17 +85,17 @@ private void InitializeComponent() this.controlBar.Controls.Add(this.availableVersions, 2, 0); this.controlBar.Controls.Add(this.notifications, 5, 0); this.controlBar.Dock = System.Windows.Forms.DockStyle.Fill; - this.controlBar.Location = new System.Drawing.Point(8, 8); + this.controlBar.Location = new System.Drawing.Point(9, 8); this.controlBar.Name = "controlBar"; this.controlBar.RowCount = 1; this.controlBar.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.controlBar.Size = new System.Drawing.Size(2426, 66); + this.controlBar.Size = new System.Drawing.Size(2422, 66); this.controlBar.TabIndex = 2; // // helpButton // this.helpButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.helpButton.Location = new System.Drawing.Point(2265, 3); + this.helpButton.Location = new System.Drawing.Point(2261, 3); this.helpButton.Name = "helpButton"; this.helpButton.Size = new System.Drawing.Size(94, 60); this.helpButton.TabIndex = 4; @@ -106,7 +106,7 @@ private void InitializeComponent() // settingsButton // this.settingsButton.Dock = System.Windows.Forms.DockStyle.Fill; - this.settingsButton.Location = new System.Drawing.Point(2165, 3); + this.settingsButton.Location = new System.Drawing.Point(2161, 3); this.settingsButton.Name = "settingsButton"; this.settingsButton.Size = new System.Drawing.Size(94, 60); this.settingsButton.TabIndex = 2; @@ -118,11 +118,11 @@ private void InitializeComponent() this.omniSearch.BorderStyle = System.Windows.Forms.BorderStyle.None; this.omniSearch.Dock = System.Windows.Forms.DockStyle.Fill; this.omniSearch.Font = new System.Drawing.Font("Segoe UI", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.omniSearch.Location = new System.Drawing.Point(191, 8); - this.omniSearch.Margin = new System.Windows.Forms.Padding(8); + this.omniSearch.Location = new System.Drawing.Point(192, 8); + this.omniSearch.Margin = new System.Windows.Forms.Padding(9, 8, 9, 8); this.omniSearch.Name = "omniSearch"; this.omniSearch.PlaceholderText = "enter search text..."; - this.omniSearch.Size = new System.Drawing.Size(1763, 54); + this.omniSearch.Size = new System.Drawing.Size(1757, 54); this.omniSearch.TabIndex = 0; this.omniSearch.TextChanged += new System.EventHandler(this.omniSearch_TextChanged_1); this.omniSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.omniSearch_KeyDown); @@ -147,7 +147,7 @@ private void InitializeComponent() this.availableVersions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.availableVersions.FormattingEnabled = true; this.availableVersions.ItemHeight = 25; - this.availableVersions.Location = new System.Drawing.Point(1965, 3); + this.availableVersions.Location = new System.Drawing.Point(1961, 3); this.availableVersions.Name = "availableVersions"; this.availableVersions.Size = new System.Drawing.Size(194, 33); this.availableVersions.TabIndex = 3; @@ -161,7 +161,7 @@ private void InitializeComponent() this.notifications.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.notifications.Font = new System.Drawing.Font("Segoe UI", 14F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); this.notifications.ForeColor = System.Drawing.SystemColors.ControlText; - this.notifications.Location = new System.Drawing.Point(2365, 3); + this.notifications.Location = new System.Drawing.Point(2361, 3); this.notifications.Name = "notifications"; this.notifications.Size = new System.Drawing.Size(58, 60); this.notifications.TabIndex = 5; @@ -185,8 +185,8 @@ private void InitializeComponent() // this.splitContainer1.Panel2.Controls.Add(this.blueprintDock); this.splitContainer1.Panel2.Cursor = System.Windows.Forms.Cursors.Default; - this.splitContainer1.Size = new System.Drawing.Size(2442, 1167); - this.splitContainer1.SplitterDistance = 299; + this.splitContainer1.Size = new System.Drawing.Size(2440, 1166); + this.splitContainer1.SplitterDistance = 297; this.splitContainer1.SplitterWidth = 16; this.splitContainer1.TabIndex = 3; // @@ -209,7 +209,7 @@ private void InitializeComponent() this.resultsGrid.RowHeadersWidth = 62; this.resultsGrid.RowTemplate.Height = 33; this.resultsGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.resultsGrid.Size = new System.Drawing.Size(2442, 299); + this.resultsGrid.Size = new System.Drawing.Size(2440, 297); this.resultsGrid.TabIndex = 2; this.resultsGrid.VirtualMode = true; this.resultsGrid.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.resultsGrid_CellContentClick); @@ -273,7 +273,7 @@ private void InitializeComponent() this.blueprintDock.Root.WorkspaceControl = this.blueprintDock; this.blueprintDock.SeparatorStyle = Krypton.Toolkit.SeparatorStyle.LowProfile; this.blueprintDock.ShowMaximizeButton = false; - this.blueprintDock.Size = new System.Drawing.Size(2442, 852); + this.blueprintDock.Size = new System.Drawing.Size(2440, 853); this.blueprintDock.SplitterWidth = 5; this.blueprintDock.TabIndex = 0; this.blueprintDock.TabStop = true; @@ -288,10 +288,10 @@ private void InitializeComponent() // // Form1 // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BlueprintFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.ClientSize = new System.Drawing.Size(2442, 1249); + this.ClientSize = new System.Drawing.Size(2440, 1248); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.panel1); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); diff --git a/BlueprintExplorer/Form1.cs b/BlueprintExplorer/Form1.cs index c5af7bc..2b0b063 100644 --- a/BlueprintExplorer/Form1.cs +++ b/BlueprintExplorer/Form1.cs @@ -60,7 +60,6 @@ public BlueprintViewer NewBlueprintViewer(KryptonWorkspaceCell cell = null) //} //else { - var cell = blueprintDock.CellForPage(page); var viewer = NewBlueprintViewer(cell); viewer.ShowBlueprint(bp, ShowFlags.F_ClearHistory | ShowFlags.F_UpdateHistory); @@ -290,6 +289,11 @@ public Form1() omniSearch.Select(); ShowBlueprint(BlueprintDB.Instance.Blueprints.Values.First(), ShowFlags.F_UpdateHistory); + var template = "var @{bp.name:firstLower}Ref = BlueprintTool.Get<@{bp.type}>(\"@{bp.guid}\").ToReference<>();"; + Console.WriteLine("applying template: " + template + " to blueprint"); + Console.WriteLine(TemplateRunner.Execute(template, BlueprintDB.Instance.Blueprints[Guid.Parse("dbe1d6ac18ad4eafb4f6d24e48eb12dc")])); + + foreach (var v in BlueprintDB.Instance.Available) availableVersions.Items.Add(v); availableVersions.SelectedIndex = availableVersions.Items.Count - 1; diff --git a/BlueprintExplorer/HelpView.Designer.cs b/BlueprintExplorer/HelpView.Designer.cs index e7d4b67..93b5813 100644 --- a/BlueprintExplorer/HelpView.Designer.cs +++ b/BlueprintExplorer/HelpView.Designer.cs @@ -38,7 +38,6 @@ private void InitializeComponent() // this.contents.BorderStyle = System.Windows.Forms.BorderStyle.None; this.contents.BulletIndent = 2; - this.contents.Cursor = System.Windows.Forms.Cursors.Default; this.contents.Dock = System.Windows.Forms.DockStyle.Fill; this.contents.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.contents.Location = new System.Drawing.Point(32, 32); @@ -62,8 +61,8 @@ private void InitializeComponent() // // HelpView // - this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.ClientSize = new System.Drawing.Size(1314, 922); this.Controls.Add(this.panel1); this.Name = "HelpView"; diff --git a/BlueprintExplorer/Program.cs b/BlueprintExplorer/Program.cs index ff4b6e8..3a85f27 100644 --- a/BlueprintExplorer/Program.cs +++ b/BlueprintExplorer/Program.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Forms; using static BlueprintExplorer.BlueprintHandle; @@ -102,12 +103,18 @@ static void Main() // } //} - Application.SetHighDpiMode(HighDpiMode.SystemAware); + SetProcessDPIAware(); + + + Application.SetHighDpiMode(HighDpiMode.PerMonitorV2); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } + + [System.Runtime.InteropServices.DllImport("user32.dll")] + private static extern bool SetProcessDPIAware(); } } diff --git a/BlueprintExplorer/TemplateRunner.cs b/BlueprintExplorer/TemplateRunner.cs new file mode 100644 index 0000000..fa45f76 --- /dev/null +++ b/BlueprintExplorer/TemplateRunner.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace BlueprintExplorer +{ + public static class TemplateRunner + { + + public static string Lookup(BlueprintHandle bp, string key) + { + return key switch + { + "guid" => bp.GuidText, + "type" => bp.TypeName, + "name" => bp.Name, + _ => null, + }; + } + public static string Format(string value, string []format) + { + foreach (var item in format) + { + value = item switch + { + "" => value, + "firstLower" => char.ToLower(value[0]) + value[1..], + _ => value, + }; + } + return value; + } + + private static Regex regex = new("(@{.*?})"); + public static string Execute(string template, BlueprintHandle bp) + { + StringBuilder sb = new(); + + //var template = "{@{bp.guid}hello { } @{bp.type} \"@{bp.name}"; + var m = regex.Matches(template); + + int copyFrom = 0; + for (int i = 0; i < m.Count; i++) + { + int copyTo = m[i].Index; + sb.Append(template[copyFrom..copyTo]); + + copyFrom = m[i].Index + m[i].Length; + + string[] key = m[i].Value[2..^1].Split(':', StringSplitOptions.RemoveEmptyEntries); + var type = key[0].Split('.'); + if (type.Length != 2) + { + sb.Append(m[i].Value).Append("<>"); + continue; + } + + string value = ""; + if (type[0] == "bp") + { + value = Lookup(bp, type[1]); + } + else + { + sb.Append(m[i].Value).Append("<>"); + } + + if (key.Length > 1) + value = Format(value, key[1..]); + + sb.Append(value); + + + } + if (copyFrom != template.Length) + sb.Append(template[copyFrom..]); + + return sb.ToString(); + } + } +}