public Action(string name, int cost, Sprite icon, MakeAction makeAction) { this.Name = name; this.Cost = cost; this.Icon = icon; this.DelegateMakeAction = makeAction; }
private static T MeasureTime <T>(MakeAction <T> makeAction, ref TimeSpan totalTime, ref int numberOfCalls) { var stopwatch = new Stopwatch(); stopwatch.Start(); var res = makeAction(); var ts = stopwatch.Elapsed; totalTime += ts; numberOfCalls++; return(res); }
private void initState() { makeAction += PreventSleep; getState += () => this.appState; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.notifyIcon.Visible = true; this.notifyIcon.MouseDoubleClick += NotifyIcon_MouseDoubleClick; this.ShowInTaskbar = false; this.btnStart.Enabled = true; this.btnStop.Enabled = false; }
private void HandleException(MakeAction makeAction, string headerMessage) { try { makeAction(); } catch (Exception e) { if (_drawingMode != DrawingMode.Canceled) { _drawingMode = DrawingMode.NotChanged; } if (e is GraphRenderException || e is ValidationException) { MessageBox.Show(e.Message, headerMessage, MessageBoxButton.OK, MessageBoxImage.Error); } else { var exceptionViewer = new ExceptionViewer(headerMessage, e); exceptionViewer.ShowDialog(); } } }