public SourceSplitSettings() { this.InitializeComponent(); AutoSplitEnabled.Bind(chkAutoSplitEnabled, "Checked"); _settingEntries.Add(AutoSplitEnabled); AutoSplitOnGenericMap.Bind(chkSplitGenericMap, "Checked"); _settingEntries.Add(AutoSplitOnGenericMap); AutoSplitOnLevelTrans.Bind(chkSplitLevelTrans, "Checked"); _settingEntries.Add(AutoSplitOnLevelTrans); AutoSplitOnSpecial.Bind(chkSplitSpecial, "Checked"); _settingEntries.Add(AutoSplitOnSpecial); SplitInterval.Bind(dmnSplitInterval, "Value"); _settingEntries.Add(SplitInterval); ShowGameTime.Bind(chkShowGameTime, "Checked"); _settingEntries.Add(ShowGameTime); ShowAltTime.Bind(chkShowAlt, "Checked"); _settingEntries.Add(ShowAltTime); GameTimeDecimalPlaces.Bind(nudDecimalPlaces, "Value"); _settingEntries.Add(GameTimeDecimalPlaces); AutoStartEnabled.Bind(chkAutoStart, "Checked"); _settingEntries.Add(AutoStartEnabled); AutoStopEnabled.Bind(chkAutoStop, "Checked"); _settingEntries.Add(AutoStopEnabled); AutoResetEnabled.Bind(chkAutoReset, "Checked"); _settingEntries.Add(AutoResetEnabled); StartMap.Bind(boxStartMap, "Text"); _settingEntries.Add(StartMap); ShowTickCount.Bind(chkShowTickCount, "Checked"); _settingEntries.Add(ShowTickCount); HoldUntilPause.Bind(chkHoldUntilPause, "Checked"); _settingEntries.Add(HoldUntilPause); RTAStartOffset.Bind(chkRTAStartOffset, "Checked"); _settingEntries.Add(RTAStartOffset); ServerInitialTicks.Bind(chkServerInitialTicks, "Checked"); _settingEntries.Add(ServerInitialTicks); SLPenalty.Bind(nudSLPenalty, "Value"); _settingEntries.Add(SLPenalty); SplitInstead.Bind(boxSplitInstead, "Checked"); _settingEntries.Add(SplitInstead); ResetMapTransitions.Bind(chkResetMapTransitions, "Checked"); _settingEntries.Add(ResetMapTransitions); this.rdoWhitelist.CheckedChanged += rdoAutoSplitType_CheckedChanged; this.rdoInterval.CheckedChanged += rdoAutoSplitType_CheckedChanged; this.chkAutoSplitEnabled.CheckedChanged += UpdateDisabledControls; this.chkShowGameTime.CheckedChanged += UpdateDisabledControls; // defaults lbGameProcessesSetDefault(); this.GameTimingMethod = DEFAULT_GAME_TIMING_METHOD; this.UpdateDisabledControls(this, EventArgs.Empty); // HACKHACK: due to all the data bindings shenanigans, we need to load all the tab pages when opening the settings // so just give in... this.Load += (e, f) => { for (int i = tabCtrlMaster.TabPages.Count - 1; i >= 0; i--) { tabCtrlMaster.SelectedIndex = i; Thread.Sleep(1); } }; }
/// <summary> /// Finds the optimum bins with respect to <see cref="_cumulativeCounts"/> /// </summary> /// <returns>The sorted array of indices that are exclusive upper bounds of the respective bins</returns> private int[] FindBinsCore() { if (_distinctValueCount == 0) { return new int[] { _distinctValueCount } } ; // we will put intervals into a heap so that the one with maximum gain is at the top var intervals = new Heap <SplitInterval>((x, y) => x.Gain < y.Gain); // start with a single interval covering all points intervals.Add(new SplitInterval(this, 0, _distinctValueCount, false)); // while we haven't reached max # of bins and there's still gain in splitting (best interval's gain is positive) while (intervals.Count < _maxBins && intervals.Top.Gain > 0) { // take the interval with the best split gain var toSplit = intervals.Pop(); // make the split bool isLastSplit = intervals.Count == _maxBins - 1; var left = new SplitInterval(this, toSplit.Min, toSplit.SplitLim, isLastSplit); var right = new SplitInterval(this, toSplit.SplitLim, toSplit.Lim, isLastSplit); // put the results back into the heap intervals.Add(left); intervals.Add(right); } var binCount = intervals.Count; var results = new int[binCount]; for (int i = 0; i < binCount; i++) { results[i] = intervals.Pop().Lim; } Contracts.Assert(intervals.Count == 0); Array.Sort(results); return(results); } }