Skip to content

Commit

Permalink
ctrl p
Browse files Browse the repository at this point in the history
  • Loading branch information
factubsio committed Mar 21, 2022
1 parent cff44ab commit aa6127a
Show file tree
Hide file tree
Showing 8 changed files with 398 additions and 280 deletions.
5 changes: 5 additions & 0 deletions BlueprintExplorer/BlueprintViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public BlueprintViewer()
openExternal.Click += (sender, e) => OnOpenExternally?.Invoke(View.Blueprint as BlueprintHandle);

this.AddMouseClickRecursively(HandleXbuttons);

Load += (sender, e) =>
{
this.AddKeyDownRecursively((FindForm() as Form1).HandleGlobalKeys);
};
}

private void BubblePrints_OnTemplatesChanged(int oldCount, int newCount)
Expand Down
96 changes: 96 additions & 0 deletions BlueprintExplorer/CtrlP.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 125 additions & 0 deletions BlueprintExplorer/CtrlP.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
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 BlueprintExplorer
{
public partial class CtrlP : Form
{
public CtrlP()
{
InitializeComponent();
Form1.InstallReadline(input);
input.KeyDown += Input_KeyDown;
root.KeyDown += Input_KeyDown;
input.TextChanged += Input_TextChanged;

root.ReadOnly = true;
root.Cursor = Cursors.Arrow;

root.AutoGenerateColumns = false;
root.Columns.Add("Name", "Name");
root.Columns.Add("Type", "Type");
root.Columns.Add("Guid", "Guid");
root.Columns[0].Width = 800;
root.Columns[0].DataPropertyName = "Name";
root.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

root.Columns[1].Width = 600;
root.Columns[1].DataPropertyName = "Type";

root.Columns[2].Width = 450;
root.Columns[2].DataPropertyName = "GuidText";

root.RowHeadersVisible = false;
root.ColumnHeadersVisible = false;
root.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
root.MultiSelect = false;
root.AllowUserToResizeRows = false;

if (Form1.Dark)
{
BubbleTheme.DarkenControls(input, root);
BubbleTheme.DarkenStyles(root.DefaultCellStyle, root.ColumnHeadersDefaultCellStyle);
}

}

public Form1 Daddy;

private void Input_TextChanged(object sender, EventArgs e)
{
if (input.Text.Length > 0)
{
Daddy.InvalidateResults(input.Text);
}
}

public void SetResults(List<BlueprintHandle> results)
{
root.DataSource = results;
int neededHeight = root.Rows.GetRowsHeight(DataGridViewElementStates.None);
if (neededHeight < 640)
{
Height = neededHeight + 82;
}
else
{
Height = 640 + 82;
}
}

private void Input_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
Close();
}
if (e.KeyCode == Keys.Up || (e.KeyCode == Keys.P && ModifierKeys.HasFlag(Keys.Control)))
{
e.Handled = true;
e.SuppressKeyPress = true;

int current = root.SelectedRow();
if (current > 0)
{
root.Rows[current - 1].Selected = true;
}
}
if (e.KeyCode == Keys.Down || (e.KeyCode == Keys.N && ModifierKeys.HasFlag(Keys.Control)))
{
e.Handled = true;
e.SuppressKeyPress = true;

int current = root.SelectedRow();
if (current < (root.Rows.Count - 1))
{
root.Rows[current + 1].Selected = true;
}
}

if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
{

e.Handled = true;
e.SuppressKeyPress = true;

Daddy.ShowBlueprint(root.SelectedRow());

Close();
}
}

protected override void OnShown(EventArgs e)
{
base.OnShown(e);
input.Focus();
}
}
}
60 changes: 60 additions & 0 deletions BlueprintExplorer/CtrlP.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
Loading

0 comments on commit aa6127a

Please sign in to comment.