private async Task Main2() { rightPanelMgr = new ImFormsMgr(ImWpfPanelRight.Children); var timer = new System.Windows.Threading.DispatcherTimer(); timer.Tick += (o, e) => rightPanelMgr.Refresh(); int updateRate = 1000; while (true) { rightPanelMgr.Text("This ImForms panel auto-updates once every:"); rightPanelMgr.RadioButton("Second", ref updateRate, 1000); rightPanelMgr.RadioButton("100ms", ref updateRate, 100); rightPanelMgr.RadioButton("10ms", ref updateRate, 10); rightPanelMgr.RadioButton("Never", ref updateRate, -1); timer.Interval = TimeSpan.FromMilliseconds((updateRate > 0) ? updateRate : int.MaxValue); timer.IsEnabled = (updateRate > 0); rightPanelMgr.Space(CompileTime.ID()); rightPanelMgr.Text("Auto-updating is an easy way to display values from other threads"); rightPanelMgr.Text("y = " + y, CompileTime.ID()); rightPanelMgr.Text("t = " + t, CompileTime.ID()); await rightPanelMgr.NextFrame(); } }
public async Task Main2(Panel panel) { rightPanelMgr = new ImFormsMgr(panel); var timer = new Timer(); timer.Tick += (o, e) => rightPanelMgr.Refresh(); int updateRate = 1000; while (true) { rightPanelMgr.Label("This ImForms panel auto-updates once every:"); rightPanelMgr.RadioButton("Second", ref updateRate, 1000); rightPanelMgr.RadioButton("100ms", ref updateRate, 100); rightPanelMgr.RadioButton("10ms", ref updateRate, 10); rightPanelMgr.RadioButton("Never", ref updateRate, -1); timer.Interval = (updateRate > 0) ? updateRate : int.MaxValue; timer.Enabled = (updateRate > 0); rightPanelMgr.Space(CompileTime.ID()); rightPanelMgr.Label("Auto-updating is an easy way to display values from other threads"); rightPanelMgr.Label("y = " + y, CompileTime.ID()); rightPanelMgr.Label("t = " + t, CompileTime.ID()); await rightPanelMgr.NextFrame(); } }
/// <summary> /// Initializes static members of the <see cref="Signature"/> class. /// </summary> static Signature() { var ver = Assembly.GetExecutingAssembly().GetName().Version; Version = ver.Major + "." + ver.Minor + "." + ver.Build + "." + ver.Revision; VersionFormatted = "v" + ver.Major + "." + ver.Minor + (ver.Build != 0 ? "." + ver.Build : string.Empty) + " b" + ver.Revision + (IsNightly ? " nightly" : string.Empty); Log.Info(Software + " " + VersionFormatted); if (CompileTime != DateTime.MinValue) { Log.Info("Compiled on " + BuildMachine + " at " + CompileTime.ToString("yyyy'-'MM'-'dd HH':'mm':'ss") + " from commit " + GitRevision); } else { Log.Info("No compilation info available."); } try { AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Developer, Software) + Path.DirectorySeparatorChar; InstallPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar; UACVirtualPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "VirtualStore", Regex.Replace(InstallPath, @"^[a-zA-Z]{1,2}:[\\/]", string.Empty)); } catch (ArgumentException ex) { Log.Warn("Error while loading $AppDataPath/$InstallPath/$UACVirtualPath.", ex); } if (AppDataPath != null && !Directory.Exists(AppDataPath)) { try { Directory.CreateDirectory(AppDataPath); } catch (Exception ex) { Log.Error("$AppDataPath (" + AppDataPath + ") doesn't exist and can't be created.", ex); } } int minWorkThd = 0, maxWorkThd = 0, minIOWait = 0, maxIOWait = 0, cpu = Environment.ProcessorCount, destCpu = cpu * 8; ThreadPool.GetMinThreads(out minWorkThd, out minIOWait); ThreadPool.GetMaxThreads(out maxWorkThd, out maxIOWait); Log.Debug("Thread pool status: " + minWorkThd + "/" + minIOWait + " min, " + maxWorkThd + "/" + maxIOWait + " max, " + cpu + " cpu."); if (ThreadPool.SetMinThreads(destCpu, destCpu)) { Log.Debug("Thread pool minimum set to " + destCpu + " threads."); } else { Log.Warn("Failed to set thread pool minimum to " + destCpu + " threads."); } if (Log.IsDebugEnabled) { Log.Debug("Running with" + (Utils.IsAdmin ? string.Empty : "out") + " administrator rights."); } _actTask = new Task(() => { //CheckAssembly(); InitLicense(); }); _actTask.Start(TaskScheduler.Current); }
private async Task Main() { ImFormsMgr mgr = new ImFormsMgr(ImWpfPanelLeft.Children); IList <int> list = new List <int> { 1, 2, 3 }; int x = 0; bool displayList = false; bool reverseList = false; while (true) { mgr.Text("This ImForms panel refreshes only when there is user interaction"); mgr.Space(CompileTime.ID()); mgr.Text("ImForms makes it easy to display and modify one value with multiple controls"); mgr.Text("x ="); mgr.RadioButton("0", ref x, 0); mgr.RadioButton("1", ref x, 1); int valueToAssignX = (x == 1) ? 0 : 1; if (mgr.Button("x <- " + valueToAssignX, CompileTime.ID())) { x = valueToAssignX; } bool xIs1 = (x == 1); mgr.Checkbox("X == 1", ref xIs1); x = xIs1 ? 1 : 0; mgr.Space(CompileTime.ID()); mgr.Text("Just like with other ImGui implementations, if a function isn't called for it," + " a control isn't displayed."); mgr.Checkbox("Show list", ref displayList); if (displayList) { var seq = reverseList ? list.Reverse() : list; if (mgr.Button("Add to end")) { list.Add(list.LastOrDefault() + 1); } if (list.Any() && mgr.Button("Remove from front")) { list.RemoveAt(0); } mgr.Checkbox("Display reversed", ref reverseList); foreach (var n in seq) { mgr.Text("[" + n + "]"); } } mgr.Space(CompileTime.ID()); mgr.Text("Values from other threads can be displayed when a panel refreshes."); mgr.LinkText("Try it!"); mgr.Text("y = " + y, CompileTime.ID()); await mgr.NextFrame(); } }
public async Task Main(Panel panel) { ImFormsMgr mgr = new ImFormsMgr(panel); IList <int> list = new List <int> { 1, 2, 3 }; int x = 0; bool displayList = false; bool reverseList = false; float f = 0; string teststr = ""; while (true) { mgr.Label("This ImForms panel refreshes only when there is user interaction"); mgr.Space(CompileTime.ID()); mgr.Label("ImForms makes it easy to display and modify one value with multiple controls"); mgr.Label("x =" + x); mgr.Label("f =" + f, "f ="); mgr.TreeView(new string[] { "bdfihdf", "dshsdiusdh" }); string res = ""; if (mgr.ComboBox("text box", ref res, new string[] { "t", "f", "c" })) { mgr.Label(res); } mgr.InputMultilineText("Text box:", ref teststr); mgr.Label(teststr); mgr.RadioButton("0", ref x, 0); mgr.RadioButton("1", ref x, 1); mgr.SliderFloat("slider flt val:", ref f); mgr.ProgressFloat("progress:", ref f); int valueToAssignX = (x == 1) ? 0 : 1; if (mgr.Button("x <- " + valueToAssignX)) { x = valueToAssignX; } bool xIs1 = (x == 1); mgr.Checkbox("X == 1", ref xIs1); mgr.Space(CompileTime.ID()); mgr.Label("Just like with other ImGui implementations, if a function isn't called for it," + " a control isn't displayed."); mgr.Checkbox("Show list", ref displayList); if (displayList) { var seq = reverseList ? list.Reverse() : list; if (mgr.Button("Add to end")) { list.Add(list.LastOrDefault() + 1); } if (list.Any() && mgr.Button("Remove from front")) { list.RemoveAt(0); } mgr.Checkbox("Display reversed", ref reverseList); foreach (var n in seq) { mgr.Label("[" + n + "]"); } } mgr.Space(CompileTime.ID()); mgr.Label("Values from other threads can be displayed when a panel refreshes."); mgr.LinkLabel("Try it!"); mgr.Label("y = " + y, CompileTime.ID()); await mgr.NextFrame(); } }
static INamedExpressionTuple ParseResult(INamedExpressionTuple result, IEnumerator <TokenData> tokens, IContext context, ref bool done) { while (!done) { var token = tokens.Current; switch (token.Type) { case Token.OperatorLiteral: var operatorLiteral = (IIdentifierLiteral)token.Data; var itentifyerLiteralList = new List <TokenData>(); string operatorLiteralContent = operatorLiteral.Content; string operatorLiteralContentTail = ""; string notFoundLiteral = ""; while (!operatorLiteralContent.IsEmpty()) { if (operatorLiteralContent == "&") { if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report error: missing tokens } var inner = Parse(tokens, context, ref done); var execResult = CompileTime.Execute(inner, context); if (execResult != null) { if (execResult is INamedExpressionTuple execNamedTuple) { result.Tuple.AddRange(execNamedTuple.Tuple); } else { result.Tuple.Add(new NamedExpression { Expression = execResult }); } } continue; } var resolve = context.Identifiers[operatorLiteralContent]; if (resolve == null) { if (operatorLiteralContent.Length == 1) { notFoundLiteral += operatorLiteralContent; operatorLiteralContent = operatorLiteralContentTail; operatorLiteralContentTail = ""; } else { operatorLiteralContentTail = operatorLiteralContent.Last() + operatorLiteralContentTail; operatorLiteralContent = operatorLiteralContent.Substring(0, operatorLiteralContent.Length - 1); } } else { if (!notFoundLiteral.IsEmpty()) { itentifyerLiteralList.Add(new TokenData { Type = Token.IdentifierLiteral, Data = new IdentifierLiteral { Content = notFoundLiteral } }); notFoundLiteral = ""; } itentifyerLiteralList.Add(new TokenData { Type = Token.IdentifierLiteral, Data = new IdentifierLiteral { Content = operatorLiteralContent } // TODO Error and Range }); operatorLiteralContent = operatorLiteralContentTail; operatorLiteralContentTail = ""; } } if (!notFoundLiteral.IsEmpty()) { itentifyerLiteralList.Add(new TokenData { Type = Token.IdentifierLiteral, Data = new IdentifierLiteral { Content = notFoundLiteral } }); } using (var newTokens = itentifyerLiteralList.Before(tokens).GetEnumerator()) { return(ParseResult(result, newTokens, context, ref done)); } case Token.IdentifierLiteral: var identifierLiteral = (IIdentifierLiteral)token.Data; var resolved = context.Identifiers[identifierLiteral.Content]; if (null != resolved) { var subexpression = ParseResolved((dynamic)resolved, result, tokens, context, ref done); result.Tuple.Add(new NamedExpression { Expression = subexpression ?? identifierLiteral }); continue; } result.Tuple.Add(new NamedExpression { Expression = identifierLiteral }); break; case Token.StringLiteral: var stringLiteral = (IStringLiteral)token.Data; result.Tuple.Add(new NamedExpression { Expression = stringLiteral }); break; case Token.NumberLiteral: var numberLiteral = (INumberLiteral)token.Data; result.Tuple.Add(new NamedExpression { Expression = numberLiteral }); break; case Token.BlockStartIndentation: var tokenBlock = (IBlockLiteral)token.Data; result.Tuple.Add(new NamedExpression { Expression = tokenBlock }); break; } if (done) { break; } if (!tokens.MoveNext()) { done = true; } } return(result); }