private void RunEditor_FormClosed(object sender, FormClosedEventArgs e) { editorDialog.FormClosed -= RunEditor_FormClosed; editorDialog = null; segmentList.ListChanged -= SegmentList_ListChanged; segmentList = null; }
public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode) { if (editorDialog == null && Form.ActiveForm is RunEditorDialog runEditor) { PropertyInfo info = typeof(RunEditorDialog).GetProperty("SegmentList", BindingFlags.Instance | BindingFlags.NonPublic); segmentList = info.GetValue(runEditor) as System.ComponentModel.BindingList <ISegment>; if (segmentList != null) { editorDialog = runEditor; segmentList.ListChanged += SegmentList_ListChanged; runEditor.FormClosed += RunEditor_FormClosed; } } }
public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode) { if (editorDialog == null && Form.ActiveForm is RunEditorDialog runEditor) { PropertyInfo info = typeof(RunEditorDialog).GetProperty("SegmentList", BindingFlags.Instance | BindingFlags.NonPublic); segmentList = info.GetValue(runEditor) as System.ComponentModel.BindingList <ISegment>; if (segmentList != null) { editorDialog = runEditor; segmentList.ListChanged += SegmentList_ListChanged; runEditor.FormClosed += RunEditor_FormClosed; } } DateTime dateTime = DateTime.Now; if (dateTime > lastInfoCheck) { fpsComponent = null; raceComponent = null; IList <ILayoutComponent> components = Model.CurrentState.Layout.LayoutComponents; for (int i = components.Count - 1; i >= 0; i--) { ILayoutComponent component = components[i]; if (component.Component is TextComponent text) { if (text.Settings.Text1.IndexOf("FPS", StringComparison.OrdinalIgnoreCase) >= 0) { fpsComponent = text; } else if (text.Settings.Text1.IndexOf("Trial Time", StringComparison.OrdinalIgnoreCase) >= 0) { raceComponent = text; } } } lastInfoCheck = dateTime.AddSeconds(3); } if (fpsComponent != null) { string fps = logic.Memory.FPS().ToString("0.0"); if (fps != fpsComponent.Settings.Text2) { fpsComponent.Settings.Text2 = fps; } } if (raceComponent != null && dateTime > lastTimerCheck) { lastTimerCheck = dateTime.AddMilliseconds(200); float raceTime = logic.Memory.RaceTime(); string display = null; if (raceTime == 0) { raceTime = logic.Memory.LastRaceTime(); display = $"{raceTime:0.000}"; } else { display = $"{raceTime:0.000}"; } if (display != raceComponent.Settings.Text2) { raceComponent.Settings.Text2 = display; } } }
public void Update(IInvalidator invalidator, LiveSplitState lvstate, float width, float height, LayoutMode mode) { if (editorDialog == null && Form.ActiveForm is RunEditorDialog runEditor) { PropertyInfo info = typeof(RunEditorDialog).GetProperty("SegmentList", BindingFlags.Instance | BindingFlags.NonPublic); segmentList = info.GetValue(runEditor) as System.ComponentModel.BindingList <ISegment>; if (segmentList != null) { editorDialog = runEditor; segmentList.ListChanged += SegmentList_ListChanged; runEditor.FormClosed += RunEditor_FormClosed; } } if (DateTime.Now > lastInfoCheck) { infoComponent = null; IList <ILayoutComponent> components = Model.CurrentState.Layout.LayoutComponents; for (int i = components.Count - 1; i >= 0; i--) { ILayoutComponent component = components[i]; if (component.Component is TextComponent) { TextComponent text = (TextComponent)component.Component; if (text.Settings.Text1.IndexOf("Deaths", StringComparison.OrdinalIgnoreCase) >= 0 || text.Settings.Text1.IndexOf("Kills", StringComparison.OrdinalIgnoreCase) >= 0) { infoComponent = text; break; } } } lastInfoCheck = DateTime.Now.AddSeconds(3); } if (infoComponent != null) { int killIndex = infoComponent.Settings.Text1.IndexOf("Kills", StringComparison.OrdinalIgnoreCase); int deathIndex = infoComponent.Settings.Text1.IndexOf("Deaths", StringComparison.OrdinalIgnoreCase); string info1 = string.Empty; string info2 = string.Empty; if (killIndex >= 0 && (deathIndex < 0 || killIndex < deathIndex)) { info1 = logic.Kills.ToString(); if (deathIndex >= 0) { info2 = logic.Deaths.ToString(); } } else if (deathIndex >= 0 && (killIndex < 0 || deathIndex < killIndex)) { info1 = logic.Deaths.ToString(); if (killIndex >= 0) { info2 = logic.Kills.ToString(); } } string info = string.Concat(info1, string.IsNullOrEmpty(info2) ? string.Empty : " / ", info2); if (infoComponent.Settings.Text2 != info) { infoComponent.Settings.Text2 = info; } } }