BlueOrb signals
This commit is contained in:
1 parent
54c97b5610
commit
32a851954c
138 files changed
+16822
-909
No files matched your search
@@ -21,11 +21,55 @@ using System.Reactive.Subjects;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using BlueOrb.Pubsub.Diagnostics;
|
||||
|
||||
namespace BCG
|
||||
{
|
||||
public partial class MainForm : System.Windows.Forms.Form
|
||||
{
|
||||
private const string LastQueryRegistryKey = "LastQuery";
|
||||
private const string RecentSavedFilesRegistryKey = "RecentSavedFiles";
|
||||
private const string DateTimeDisplayFormat = "M/d/yyyy h:mm:ss.fff tt";
|
||||
private const int MaxRecentSavedFiles = 10;
|
||||
private static readonly Color QueryEditorDefaultColor = Color.White;
|
||||
private static readonly Color QueryEditorCommentColor = Color.FromArgb(106, 115, 125);
|
||||
private static readonly Color QueryEditorOperatorColor = Color.FromArgb(86, 156, 214);
|
||||
private static readonly Color QueryEditorAssignmentNameColor = Color.FromArgb(78, 201, 176);
|
||||
private static readonly Color GridBackgroundColor = Color.FromArgb(37, 37, 38);
|
||||
private static readonly Color GridAltRowColor = Color.FromArgb(43, 43, 48);
|
||||
private static readonly Color GridHeaderColor = Color.FromArgb(62, 62, 66);
|
||||
private static readonly Color GridGridLineColor = Color.FromArgb(58, 58, 61);
|
||||
private static readonly Color GridSelectionColor = Color.FromArgb(9, 71, 113);
|
||||
private static readonly Color GridSelectionForeColor = Color.White;
|
||||
private static readonly Color GridTimestampColor = Color.FromArgb(206, 215, 222);
|
||||
private static readonly Color GridIdentifierColor = Color.FromArgb(156, 163, 175);
|
||||
private static readonly Color GridIndicatorColor = Color.FromArgb(156, 220, 254);
|
||||
|
||||
class PrimitiveTreeNodeComparer : IComparer
|
||||
{
|
||||
public int Compare(object? x, object? y)
|
||||
{
|
||||
var left = x as TreeNode;
|
||||
var right = y as TreeNode;
|
||||
if (left is null || right is null)
|
||||
return 0;
|
||||
|
||||
string left_key = _sort_key(left);
|
||||
string right_key = _sort_key(right);
|
||||
return StringComparer.OrdinalIgnoreCase.Compare(left_key, right_key);
|
||||
}
|
||||
|
||||
static string _sort_key(TreeNode node)
|
||||
{
|
||||
if (node.Parent is null)
|
||||
return node.Text;
|
||||
|
||||
if (node.Tag is string primitive_name)
|
||||
return primitive_name;
|
||||
|
||||
return node.Text;
|
||||
}
|
||||
}
|
||||
// static async Task _run() {
|
||||
// var login = "bts";
|
||||
// var passwd = String.Empty;
|
||||
@@ -40,6 +84,8 @@ namespace BCG
|
||||
private string? myLastFileName;
|
||||
private ViewStream? myCurrentStream;
|
||||
private List<ToolStripMenuItem> mySiteItems = new List<ToolStripMenuItem>();
|
||||
private readonly List<string> _recent_saved_files = new List<string>();
|
||||
private ToolStripSeparator? _recent_saved_files_separator;
|
||||
// private string mySite = SitesCore.getMySiteName ();
|
||||
private string mySite = "TODO";
|
||||
private string myLastClassName = "MyView";
|
||||
@@ -49,11 +95,20 @@ namespace BCG
|
||||
private TextWriter? myConsoleOutput;
|
||||
IDataPacket? pendingData;
|
||||
IDisposable? titleSub;
|
||||
readonly ToolTip _primitive_tool_tip = new ToolTip();
|
||||
readonly Dictionary<string, string?> _primitive_source_path_cache = new Dictionary<string, string?>();
|
||||
Dictionary<string, string?>? _source_file_index;
|
||||
string? _repo_root_path;
|
||||
char? _last_primitive_search_char;
|
||||
TreeNode? _last_primitive_search_assembly_node;
|
||||
bool _is_applying_query_syntax_highlighting;
|
||||
HashSet<string>? _dsl_operator_names;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
//Task.Run(async () => await _run());
|
||||
InitializeComponent();
|
||||
_apply_grid_theme();
|
||||
// myKQ = ConfigurationRequester.getApplicationQualifier();
|
||||
myKQ = "TODO";
|
||||
var handleCreatedSubject = new Subject<bool>();
|
||||
@@ -72,13 +127,12 @@ namespace BCG
|
||||
myWindowState = new PersistWindowState();
|
||||
myWindowState.parent = this;
|
||||
myWindowState.saveState = false;
|
||||
myWindowState.LoadState += myLoadPersistedState;
|
||||
myWindowState.SaveState += mySavePersistedState;
|
||||
|
||||
this.Load += new EventHandler(myLoad);
|
||||
this.Closing += new CancelEventHandler(myClosing);
|
||||
myQueryTextBox.TextChanged += (o, e) =>
|
||||
{
|
||||
myQueryTextBox.ForeColor = Color.White;
|
||||
};
|
||||
myQueryTextBox.TextChanged += (o, e) => _apply_query_syntax_highlighting();
|
||||
}
|
||||
|
||||
event Action? titleInvalidated;
|
||||
@@ -86,14 +140,20 @@ namespace BCG
|
||||
public string query_text
|
||||
{
|
||||
get { return myQueryTextBox.Text; }
|
||||
set { myQueryTextBox.Text = value; }
|
||||
set
|
||||
{
|
||||
myQueryTextBox.Text = value;
|
||||
_apply_query_syntax_highlighting();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
Disposable.Dispose(ref titleSub);
|
||||
components?.Dispose();
|
||||
}
|
||||
@@ -104,7 +164,7 @@ namespace BCG
|
||||
{
|
||||
// TODO: Port PublishedTagsStream from edge (then we can uncomment impl below)
|
||||
//ViewStream vs = new PubSubServerStateStream();
|
||||
ViewStream vs = new PubSubServerStateStream(new SubscriberCoreFactory(), ViewStreamDatabase.instance);
|
||||
ViewStream vs = new PubSubServerStateStream(ViewStreamDatabase.instance);
|
||||
return new FilterStream(vs, "tag~='DS_'");
|
||||
//return new LiteralStream("tag/String", "DS_table1;DS_table2");
|
||||
}
|
||||
@@ -114,7 +174,8 @@ namespace BCG
|
||||
titleInvalidated?.Invoke();
|
||||
}
|
||||
|
||||
void refreshTitle(IBlueRowCollection rows) {
|
||||
void refreshTitle(IBlueRowCollection rows)
|
||||
{
|
||||
string route_txt = String.Empty;
|
||||
foreach (IBlueRow r in rows)
|
||||
{
|
||||
@@ -135,11 +196,11 @@ namespace BCG
|
||||
private IDictionary myGetLibraryData()
|
||||
{
|
||||
SortedList retVal = new SortedList();
|
||||
string[] primitiveNames = PrimitiveManager.instance.getPrimitiveNames();
|
||||
string[] primitiveNames = PrimitiveManager.instance.get_dsl_op_names();
|
||||
foreach (string pName in primitiveNames)
|
||||
{
|
||||
string aName = PrimitiveManager.instance.getAssemblyName(pName);
|
||||
ICollection cNames = PrimitiveManager.instance.getConstructorSigns(pName);
|
||||
string aName = PrimitiveManager.instance.get_dslop_assembly_name(pName);
|
||||
ICollection cNames = PrimitiveManager.instance.get_dsl_op_cons_args(pName);
|
||||
if (!retVal.Contains(aName))
|
||||
retVal.Add(aName, new SortedList());
|
||||
(retVal[aName] as IDictionary)[pName] = new ArrayList(cNames);
|
||||
@@ -151,6 +212,65 @@ namespace BCG
|
||||
return retVal;
|
||||
}
|
||||
|
||||
HashSet<string> _get_dsl_operator_names()
|
||||
{
|
||||
if (_dsl_operator_names != null)
|
||||
return _dsl_operator_names;
|
||||
|
||||
_dsl_operator_names = new HashSet<string>(
|
||||
PrimitiveManager.instance.get_dsl_op_names().Cast<string>(),
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
return _dsl_operator_names;
|
||||
}
|
||||
|
||||
void _apply_query_syntax_highlighting()
|
||||
{
|
||||
if (_is_applying_query_syntax_highlighting || myQueryTextBox.IsDisposed)
|
||||
return;
|
||||
|
||||
_is_applying_query_syntax_highlighting = true;
|
||||
try
|
||||
{
|
||||
int selection_start = myQueryTextBox.SelectionStart;
|
||||
int selection_length = myQueryTextBox.SelectionLength;
|
||||
|
||||
myQueryTextBox.SuspendLayout();
|
||||
myQueryTextBox.SelectAll();
|
||||
myQueryTextBox.SelectionColor = QueryEditorDefaultColor;
|
||||
|
||||
foreach (Match match in Regex.Matches(myQueryTextBox.Text, @"^\s*([A-Za-z_]\w*)\s*=", RegexOptions.Multiline))
|
||||
{
|
||||
Group group = match.Groups[1];
|
||||
myQueryTextBox.Select(group.Index, group.Length);
|
||||
myQueryTextBox.SelectionColor = QueryEditorAssignmentNameColor;
|
||||
}
|
||||
|
||||
foreach (Match match in Regex.Matches(myQueryTextBox.Text, @"\b([A-Za-z_]\w*)\s*\("))
|
||||
{
|
||||
Group group = match.Groups[1];
|
||||
if (!_get_dsl_operator_names().Contains(group.Value))
|
||||
continue;
|
||||
myQueryTextBox.Select(group.Index, group.Length);
|
||||
myQueryTextBox.SelectionColor = QueryEditorOperatorColor;
|
||||
}
|
||||
|
||||
foreach (Match match in Regex.Matches(myQueryTextBox.Text, @"//.*$", RegexOptions.Multiline))
|
||||
{
|
||||
myQueryTextBox.Select(match.Index, match.Length);
|
||||
myQueryTextBox.SelectionColor = QueryEditorCommentColor;
|
||||
}
|
||||
|
||||
myQueryTextBox.Select(selection_start, selection_length);
|
||||
if (selection_length == 0)
|
||||
myQueryTextBox.SelectionColor = QueryEditorDefaultColor;
|
||||
myQueryTextBox.ResumeLayout();
|
||||
}
|
||||
finally
|
||||
{
|
||||
_is_applying_query_syntax_highlighting = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void myLoadAssemblies()
|
||||
{
|
||||
@@ -161,13 +281,18 @@ namespace BCG
|
||||
TreeNode assemblyNode = new TreeNode(de.Key as String);
|
||||
foreach (DictionaryEntry innerDe in (de.Value as IDictionary))
|
||||
{
|
||||
TreeNode primitiveNode = new TreeNode(innerDe.Key as string);
|
||||
string primitive_name = innerDe.Key as string;
|
||||
TreeNode primitiveNode = new TreeNode(primitive_name)
|
||||
{
|
||||
Tag = primitive_name
|
||||
};
|
||||
foreach (string con in (innerDe.Value as ICollection))
|
||||
primitiveNode.Nodes.Add(con);
|
||||
assemblyNode.Nodes.Add(primitiveNode);
|
||||
}
|
||||
myTreeView.Nodes.Add(assemblyNode);
|
||||
}
|
||||
myTreeView.Sort();
|
||||
/*
|
||||
myPrimitivesTextBox.Clear ();
|
||||
ArrayList al = new ArrayList(PrimitiveManager.instance.getPrimitiveNames());
|
||||
@@ -182,7 +307,8 @@ namespace BCG
|
||||
|
||||
private void myHandleTableListChange(object o)
|
||||
{
|
||||
BeginInvoke(() => {
|
||||
BeginInvoke(() =>
|
||||
{
|
||||
tagRows = ((IDataPacket)o).newRows;
|
||||
myUpdateTableList();
|
||||
});
|
||||
@@ -195,6 +321,19 @@ namespace BCG
|
||||
get { return myQueryTextBox.Height; }
|
||||
set { myQueryTextBox.Height = value; }
|
||||
}
|
||||
|
||||
private void myLoadPersistedState(object sender, BlueRegistry blueReg)
|
||||
{
|
||||
myQueryTextBox.Text = blueReg.getValue(RegistryRoot.HKCU, LastQueryRegistryKey, string.Empty)?.ToString() ?? string.Empty;
|
||||
_load_recent_saved_files(blueReg.getValue(RegistryRoot.HKCU, RecentSavedFilesRegistryKey, string.Empty)?.ToString());
|
||||
_refresh_recent_saved_files_menu();
|
||||
}
|
||||
|
||||
private void mySavePersistedState(object sender, BlueRegistry blueReg)
|
||||
{
|
||||
blueReg.setValue(RegistryRoot.HKCU, LastQueryRegistryKey, myQueryTextBox.Text ?? string.Empty);
|
||||
blueReg.setValue(RegistryRoot.HKCU, RecentSavedFilesRegistryKey, string.Join("|", _recent_saved_files));
|
||||
}
|
||||
#endregion
|
||||
|
||||
private Stopwatch _stopwatch = new Stopwatch();
|
||||
@@ -287,6 +426,7 @@ namespace BCG
|
||||
}
|
||||
myLastFileName = fileName;
|
||||
this.Text = fileName;
|
||||
_track_recent_saved_file(fileName);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -371,6 +511,122 @@ namespace BCG
|
||||
}
|
||||
}
|
||||
|
||||
private void myApplyDateTimeFormatting(IBlueTableSchema schema)
|
||||
{
|
||||
var dateTimeColumns = new HashSet<string>(
|
||||
schema.columnInfo
|
||||
.Where(ci => ci.colType == typeof(DateTime))
|
||||
.Select(ci => ci.colName));
|
||||
|
||||
foreach (DataGridViewColumn column in myDataGrid.Columns)
|
||||
{
|
||||
if (!dateTimeColumns.Contains(column.DataPropertyName) && !dateTimeColumns.Contains(column.Name))
|
||||
continue;
|
||||
|
||||
column.DefaultCellStyle.Format = DateTimeDisplayFormat;
|
||||
column.Width = Math.Max(column.Width, 220);
|
||||
}
|
||||
}
|
||||
|
||||
void _apply_grid_theme()
|
||||
{
|
||||
myDataGrid.BackgroundColor = GridBackgroundColor;
|
||||
myDataGrid.BorderStyle = BorderStyle.None;
|
||||
myDataGrid.EnableHeadersVisualStyles = false;
|
||||
myDataGrid.GridColor = GridGridLineColor;
|
||||
myDataGrid.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
|
||||
myDataGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
myDataGrid.MultiSelect = false;
|
||||
myDataGrid.RowHeadersVisible = false;
|
||||
myDataGrid.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
|
||||
myDataGrid.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
|
||||
myDataGrid.ColumnHeadersHeight = 36;
|
||||
myDataGrid.RowTemplate.Height = 24;
|
||||
myDataGrid.Font = new Font("Consolas", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
|
||||
myDataGrid.DefaultCellStyle.BackColor = GridBackgroundColor;
|
||||
myDataGrid.DefaultCellStyle.ForeColor = Color.White;
|
||||
myDataGrid.DefaultCellStyle.SelectionBackColor = GridSelectionColor;
|
||||
myDataGrid.DefaultCellStyle.SelectionForeColor = GridSelectionForeColor;
|
||||
myDataGrid.DefaultCellStyle.Padding = new Padding(4, 1, 4, 1);
|
||||
|
||||
myDataGrid.AlternatingRowsDefaultCellStyle.BackColor = GridAltRowColor;
|
||||
myDataGrid.AlternatingRowsDefaultCellStyle.ForeColor = Color.White;
|
||||
myDataGrid.AlternatingRowsDefaultCellStyle.SelectionBackColor = GridSelectionColor;
|
||||
myDataGrid.AlternatingRowsDefaultCellStyle.SelectionForeColor = GridSelectionForeColor;
|
||||
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.BackColor = GridHeaderColor;
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.SelectionBackColor = GridHeaderColor;
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.SelectionForeColor = Color.White;
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.Font = new Font("Consolas", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
||||
myDataGrid.ColumnHeadersDefaultCellStyle.Padding = new Padding(6, 2, 6, 2);
|
||||
}
|
||||
|
||||
void _apply_grid_column_styling(IBlueTableSchema schema)
|
||||
{
|
||||
var column_types = schema.columnInfo.ToDictionary(ci => ci.colName, ci => ci.colType, StringComparer.OrdinalIgnoreCase);
|
||||
foreach (DataGridViewColumn column in myDataGrid.Columns)
|
||||
{
|
||||
if (!column_types.TryGetValue(column.DataPropertyName, out var col_type) &&
|
||||
!column_types.TryGetValue(column.Name, out col_type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
column.SortMode = DataGridViewColumnSortMode.NotSortable;
|
||||
|
||||
if (_is_numeric_type(col_type))
|
||||
{
|
||||
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
||||
}
|
||||
|
||||
if (col_type == typeof(DateTime))
|
||||
{
|
||||
column.DefaultCellStyle.ForeColor = GridTimestampColor;
|
||||
}
|
||||
else if (string.Equals(column.HeaderText, "id", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
column.DefaultCellStyle.ForeColor = GridIdentifierColor;
|
||||
}
|
||||
else if (_looks_like_indicator(column.HeaderText))
|
||||
{
|
||||
column.DefaultCellStyle.ForeColor = GridIndicatorColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
column.DefaultCellStyle.ForeColor = Color.White;
|
||||
}
|
||||
}
|
||||
|
||||
static bool _is_numeric_type(Type type)
|
||||
{
|
||||
return type == typeof(int) ||
|
||||
type == typeof(long) ||
|
||||
type == typeof(float) ||
|
||||
type == typeof(double) ||
|
||||
type == typeof(decimal) ||
|
||||
type == typeof(short) ||
|
||||
type == typeof(uint) ||
|
||||
type == typeof(ulong);
|
||||
}
|
||||
|
||||
static bool _looks_like_indicator(string column_name)
|
||||
{
|
||||
return column_name.Contains("rsi", StringComparison.OrdinalIgnoreCase) ||
|
||||
column_name.Contains("macd", StringComparison.OrdinalIgnoreCase) ||
|
||||
column_name.Contains("atr", StringComparison.OrdinalIgnoreCase) ||
|
||||
column_name.Contains("moving_average", StringComparison.OrdinalIgnoreCase) ||
|
||||
column_name.Contains("signal", StringComparison.OrdinalIgnoreCase) ||
|
||||
column_name.Contains("histogram", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
// this is the stream callback
|
||||
private void myCallback(object o)
|
||||
{
|
||||
@@ -386,7 +642,8 @@ namespace BCG
|
||||
private void myTimer_Tick(object sender, System.EventArgs e)
|
||||
{
|
||||
var dp = Interlocked.Exchange(ref pendingData, null);
|
||||
if (dp is null) {
|
||||
if (dp is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_stopwatch.Stop();
|
||||
@@ -403,6 +660,10 @@ namespace BCG
|
||||
int hscrollval = myChangeStyle ? 0 : myDataGrid.HorizScrollBarValue;
|
||||
|
||||
myDataGrid.DataSource = new SimpleBindableCollection(dp.newRows.schema, dp.newRows);
|
||||
_apply_grid_theme();
|
||||
myApplyDateTimeFormatting(dp.newRows.schema);
|
||||
_apply_grid_column_styling(dp.newRows.schema);
|
||||
myDataGrid.ClearSelection();
|
||||
var force = false;
|
||||
if (myChangeStyle && force)
|
||||
{
|
||||
@@ -475,7 +736,7 @@ namespace BCG
|
||||
private void myMenuItemOpenClick(object sender, System.EventArgs e)
|
||||
{
|
||||
OpenFileDialog od = new OpenFileDialog();
|
||||
od.Filter = "C# class (*.cs)|*.cs";
|
||||
od.Filter = "All files (*.*)|*.*|C# class (*.cs)|*.cs";
|
||||
|
||||
if (od.ShowDialog() == DialogResult.OK)
|
||||
loadFile(od.FileName);
|
||||
@@ -487,6 +748,7 @@ namespace BCG
|
||||
w.Write(myCSharpText.Text);
|
||||
myLastFileName = fileName;
|
||||
this.Text = fileName;
|
||||
_track_recent_saved_file(fileName);
|
||||
}
|
||||
|
||||
private void myMenuItemSaveClick(object sender, System.EventArgs e)
|
||||
@@ -509,6 +771,75 @@ namespace BCG
|
||||
mySave(sd.FileName);
|
||||
}
|
||||
|
||||
private void _load_recent_saved_files(string? serialized_paths)
|
||||
{
|
||||
_recent_saved_files.Clear();
|
||||
if (string.IsNullOrWhiteSpace(serialized_paths))
|
||||
return;
|
||||
|
||||
foreach (string path in serialized_paths.Split('|'))
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path))
|
||||
continue;
|
||||
if (_recent_saved_files.Contains(path, StringComparer.OrdinalIgnoreCase))
|
||||
continue;
|
||||
_recent_saved_files.Add(path);
|
||||
if (_recent_saved_files.Count >= MaxRecentSavedFiles)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void _track_recent_saved_file(string file_name)
|
||||
{
|
||||
_recent_saved_files.RemoveAll(path => string.Equals(path, file_name, StringComparison.OrdinalIgnoreCase));
|
||||
_recent_saved_files.Insert(0, file_name);
|
||||
if (_recent_saved_files.Count > MaxRecentSavedFiles)
|
||||
_recent_saved_files.RemoveRange(MaxRecentSavedFiles, _recent_saved_files.Count - MaxRecentSavedFiles);
|
||||
_refresh_recent_saved_files_menu();
|
||||
}
|
||||
|
||||
private void _refresh_recent_saved_files_menu()
|
||||
{
|
||||
var file_menu = myToolStripMenuItemFile.DropDownItems;
|
||||
for (int i = file_menu.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (file_menu[i] is ToolStripMenuItem menu_item && Equals(menu_item.Tag, "recent-saved-file"))
|
||||
file_menu.RemoveAt(i);
|
||||
}
|
||||
|
||||
if (_recent_saved_files_separator != null)
|
||||
{
|
||||
file_menu.Remove(_recent_saved_files_separator);
|
||||
_recent_saved_files_separator.Dispose();
|
||||
_recent_saved_files_separator = null;
|
||||
}
|
||||
|
||||
if (_recent_saved_files.Count == 0)
|
||||
return;
|
||||
|
||||
int insert_index = file_menu.IndexOf(myToolStripMenuItemExit);
|
||||
if (insert_index < 0)
|
||||
insert_index = file_menu.Count;
|
||||
|
||||
_recent_saved_files_separator = new ToolStripSeparator();
|
||||
file_menu.Insert(insert_index, _recent_saved_files_separator);
|
||||
insert_index++;
|
||||
|
||||
foreach (string path in _recent_saved_files)
|
||||
{
|
||||
var menu_item = new ToolStripMenuItem(Path.GetFileName(path))
|
||||
{
|
||||
Tag = "recent-saved-file",
|
||||
ToolTipText = path,
|
||||
BackColor = Color.FromArgb(36, 36, 49),
|
||||
ForeColor = Color.Lime
|
||||
};
|
||||
menu_item.Click += (_, __) => loadFile(path);
|
||||
file_menu.Insert(insert_index, menu_item);
|
||||
insert_index++;
|
||||
}
|
||||
}
|
||||
|
||||
private void myTableListBox_DoubleClick(object sender, System.EventArgs e)
|
||||
{
|
||||
if (myTableListBox.SelectedItem != null)
|
||||
@@ -599,6 +930,7 @@ namespace BCG
|
||||
}
|
||||
Console.WriteLine("Redirecting console ouput to this window...");
|
||||
|
||||
myTreeView.TreeViewNodeSorter = new PrimitiveTreeNodeComparer();
|
||||
myLoadAssemblies();
|
||||
|
||||
// ViewStreamDatabase.instance = new ViewStreamDatabase();
|
||||
@@ -606,6 +938,9 @@ namespace BCG
|
||||
myAllTagsStream.onChange += new BCG.DataStream.ChangeDelegate(myHandleTableListChange);
|
||||
myTabControl.SelectedIndex = 3;
|
||||
myTreeView.AfterSelect += new TreeViewEventHandler(myHandleTreeNodeSelect);
|
||||
myTreeView.KeyPress += myHandleTreeViewKeyPress;
|
||||
myTreeView.NodeMouseHover += myHandleTreeNodeMouseHover;
|
||||
myTreeView.MouseLeave += myHandleTreeViewMouseLeave;
|
||||
//do this lazily so we don't have to have bps, etc up to run dsqa
|
||||
//_library = new LibraryForm(this);
|
||||
}
|
||||
@@ -646,12 +981,138 @@ namespace BCG
|
||||
{
|
||||
if (myTreeView.SelectedNode.LastNode == null)
|
||||
{
|
||||
string sn = myTreeView.SelectedNode.Parent.Text + "()";
|
||||
string primitive_name = myTreeView.SelectedNode.Parent.Tag as string ?? myTreeView.SelectedNode.Parent.Text;
|
||||
string sn = primitive_name + "()";
|
||||
myQueryTextBox.Text = myQueryTextBox.Text == "" ? sn : myQueryTextBox.Text + "\n" + sn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void myHandleTreeViewKeyPress(object? sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (!Char.IsLetterOrDigit(e.KeyChar))
|
||||
return;
|
||||
|
||||
char search_char = Char.ToLowerInvariant(e.KeyChar);
|
||||
TreeNode? assembly_node = _get_selected_assembly_node();
|
||||
if (assembly_node is null)
|
||||
return;
|
||||
|
||||
int start_idx = 0;
|
||||
if (_last_primitive_search_char == search_char &&
|
||||
ReferenceEquals(_last_primitive_search_assembly_node, assembly_node) &&
|
||||
myTreeView.SelectedNode?.Parent == assembly_node)
|
||||
{
|
||||
start_idx = myTreeView.SelectedNode.Index + 1;
|
||||
}
|
||||
|
||||
TreeNode? match_node = _find_matching_primitive_node(assembly_node, search_char, start_idx) ??
|
||||
_find_matching_primitive_node(assembly_node, search_char, 0);
|
||||
|
||||
if (match_node is not null)
|
||||
{
|
||||
myTreeView.SelectedNode = match_node;
|
||||
match_node.EnsureVisible();
|
||||
_last_primitive_search_char = search_char;
|
||||
_last_primitive_search_assembly_node = assembly_node;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private TreeNode? _get_selected_assembly_node()
|
||||
{
|
||||
if (myTreeView.SelectedNode is null)
|
||||
return myTreeView.Nodes.Count > 0 ? myTreeView.Nodes[0] : null;
|
||||
|
||||
return myTreeView.SelectedNode.Parent ?? myTreeView.SelectedNode;
|
||||
}
|
||||
|
||||
private TreeNode? _find_matching_primitive_node(TreeNode assembly_node, char search_char, int start_idx)
|
||||
{
|
||||
for (int i = start_idx; i < assembly_node.Nodes.Count; i++)
|
||||
{
|
||||
TreeNode primitive_node = assembly_node.Nodes[i];
|
||||
string primitive_name = primitive_node.Tag as string ?? primitive_node.Text;
|
||||
if (primitive_name.Length > 0 && Char.ToLowerInvariant(primitive_name[0]) == search_char)
|
||||
return primitive_node;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void myHandleTreeNodeMouseHover(object? sender, TreeNodeMouseHoverEventArgs e)
|
||||
{
|
||||
if (e.Node?.Tag is not string primitive_name)
|
||||
{
|
||||
_primitive_tool_tip.Hide(myTreeView);
|
||||
return;
|
||||
}
|
||||
|
||||
Type? primitive_type = PrimitiveManager.instance.get_dsl_op_type(primitive_name);
|
||||
if (primitive_type is null)
|
||||
{
|
||||
_primitive_tool_tip.Hide(myTreeView);
|
||||
return;
|
||||
}
|
||||
|
||||
string tooltip_text = $"Namespace: {primitive_type.Namespace ?? "(none)"}";
|
||||
string? source_path = _get_source_file_path(primitive_type);
|
||||
if (!String.IsNullOrWhiteSpace(source_path))
|
||||
tooltip_text += $"\nSource: {source_path}";
|
||||
|
||||
Point mouse_point = myTreeView.PointToClient(Cursor.Position);
|
||||
_primitive_tool_tip.Show(tooltip_text, myTreeView, mouse_point.X + 12, mouse_point.Y + 12, 8000);
|
||||
}
|
||||
|
||||
private void myHandleTreeViewMouseLeave(object? sender, EventArgs e)
|
||||
{
|
||||
_primitive_tool_tip.Hide(myTreeView);
|
||||
}
|
||||
|
||||
private string? _get_source_file_path(Type primitive_type)
|
||||
{
|
||||
string cache_key = primitive_type.FullName ?? primitive_type.Name;
|
||||
if (_primitive_source_path_cache.TryGetValue(cache_key, out string? cached_path))
|
||||
return cached_path;
|
||||
|
||||
Dictionary<string, string?> source_file_index = _source_file_index ??= _build_source_file_index();
|
||||
if (!source_file_index.TryGetValue(primitive_type.Name, out string? source_path))
|
||||
return null;
|
||||
_primitive_source_path_cache[cache_key] = source_path;
|
||||
return source_path;
|
||||
}
|
||||
|
||||
private Dictionary<string, string?> _build_source_file_index()
|
||||
{
|
||||
Dictionary<string, string?> source_file_index = new Dictionary<string, string?>(StringComparer.OrdinalIgnoreCase);
|
||||
string? repo_root = _repo_root_path ??= _find_repo_root();
|
||||
if (String.IsNullOrWhiteSpace(repo_root))
|
||||
return source_file_index;
|
||||
|
||||
string source_root = Path.Combine(repo_root, "src", "DataStreamSuite");
|
||||
if (!Directory.Exists(source_root))
|
||||
return source_file_index;
|
||||
|
||||
foreach (string file_path in Directory.EnumerateFiles(source_root, "*.cs", SearchOption.AllDirectories))
|
||||
{
|
||||
string type_name = Path.GetFileNameWithoutExtension(file_path);
|
||||
if (!source_file_index.ContainsKey(type_name))
|
||||
source_file_index[type_name] = file_path;
|
||||
}
|
||||
return source_file_index;
|
||||
}
|
||||
|
||||
private string? _find_repo_root()
|
||||
{
|
||||
string? curr_path = AppDomain.CurrentDomain.BaseDirectory;
|
||||
while (!String.IsNullOrWhiteSpace(curr_path))
|
||||
{
|
||||
if (Directory.Exists(Path.Combine(curr_path, "src", "DataStreamSuite")))
|
||||
return curr_path;
|
||||
curr_path = Directory.GetParent(curr_path)?.FullName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void myToolStripMenuItemExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
@@ -681,7 +1142,7 @@ namespace BCG
|
||||
DialogResult dr = ofd.ShowDialog(this);
|
||||
if (ofd.CheckFileExists && ofd.CheckPathExists && dr == DialogResult.OK)
|
||||
{
|
||||
PrimitiveManager.instance.loadAssembly(ofd.FileName);
|
||||
PrimitiveManager.instance.load_streams_from_assembly(ofd.FileName);
|
||||
myLoadAssemblies();
|
||||
}
|
||||
}
|
||||
@@ -768,7 +1229,8 @@ namespace BCG
|
||||
s = new MutableAppendStream(s, s);
|
||||
s.onChange += OnChange;
|
||||
|
||||
void OnChange(object? obj) {
|
||||
void OnChange(object? obj)
|
||||
{
|
||||
s.onChange -= OnChange;
|
||||
//s = new MutableAppendStream(s, s);
|
||||
var rowCollection = ((IDataPacket)obj!).newRows;
|
||||
|
||||
Reference in new issue
Block a user