private static uint CreateBitMask(List <CheckBox> checkBoxes) { uint mask = 0; for (var i = 0; i < checkBoxes.Count; ++i) { if (checkBoxes[i].IsChecked ?? false) { BitManip.SetBit(ref mask, i); } } return(mask); }
private FrameworkElement CreateSettingsControl() { var startTimeOffsetEditBox = new TextBox(); _startTimeOffsetEditBox = startTimeOffsetEditBox; startTimeOffsetEditBox.Width = 40; startTimeOffsetEditBox.Text = _app.Config.CutStartOffset.ToString(); startTimeOffsetEditBox.ToolTip = "How many seconds before the (first) pattern matching event do we start the cut?"; var endTimeOffsetEditBox = new TextBox(); _endTimeOffsetEditBox = endTimeOffsetEditBox; endTimeOffsetEditBox.Width = 40; endTimeOffsetEditBox.Text = _app.Config.CutEndOffset.ToString(); endTimeOffsetEditBox.ToolTip = "How many seconds after the (last) pattern matching event event do we end the cut?"; var outputModeCheckBox = new CheckBox(); _outputModeCheckBox = outputModeCheckBox; outputModeCheckBox.HorizontalAlignment = HorizontalAlignment.Left; outputModeCheckBox.VerticalAlignment = VerticalAlignment.Center; outputModeCheckBox.IsChecked = _app.Config.OutputToInputFolder; outputModeCheckBox.Content = " Output cut demos to the input demos' folders?"; outputModeCheckBox.Checked += (obj, args) => OnSameOutputChecked(); outputModeCheckBox.Unchecked += (obj, args) => OnSameOutputUnchecked(); var outputFolderRow = CreateFolderRow( ref _outputFolderTextBox, _app.Config.OutputFolder, "Browse for the folder the processed demos will get written to"); var skipChatOffsetsDialogCheckBox = new CheckBox(); skipChatOffsetsDialogCheckBox.HorizontalAlignment = HorizontalAlignment.Left; skipChatOffsetsDialogCheckBox.VerticalAlignment = VerticalAlignment.Center; skipChatOffsetsDialogCheckBox.IsChecked = _app.Config.SkipChatOffsetsDialog; skipChatOffsetsDialogCheckBox.Content = " Skip the 'Cut Offsets' dialog?"; skipChatOffsetsDialogCheckBox.Checked += (obj, args) => OnSkipChatOffsetsChecked(); skipChatOffsetsDialogCheckBox.Unchecked += (obj, args) => OnSkipChatOffsetsUnchecked(); var skipFolderScanModeCheckBox = new CheckBox(); _skipFolderScanModeCheckBox = skipFolderScanModeCheckBox; skipFolderScanModeCheckBox.HorizontalAlignment = HorizontalAlignment.Left; skipFolderScanModeCheckBox.VerticalAlignment = VerticalAlignment.Center; skipFolderScanModeCheckBox.IsChecked = _app.Config.SkipScanFoldersRecursivelyDialog; skipFolderScanModeCheckBox.Content = " Skip the dialog asking if folder scanning should be recursive?"; skipFolderScanModeCheckBox.Checked += (obj, args) => OnSkipFolderScanRecursiveChecked(); skipFolderScanModeCheckBox.Unchecked += (obj, args) => OnSkipFolderScanRecursiveUnchecked(); var folderScanModeCheckBox = new CheckBox(); _folderScanModeCheckBox = folderScanModeCheckBox; folderScanModeCheckBox.HorizontalAlignment = HorizontalAlignment.Left; folderScanModeCheckBox.VerticalAlignment = VerticalAlignment.Center; folderScanModeCheckBox.IsChecked = _app.Config.ScanFoldersRecursively; folderScanModeCheckBox.Content = " Scan subfolders recursively?"; folderScanModeCheckBox.Checked += (obj, args) => OnFolderScanRecursiveChecked(); folderScanModeCheckBox.Unchecked += (obj, args) => OnFolderScanRecursiveUnchecked(); var maxThreadCountTextBox = new TextBox(); _maxThreadCountTextBox = maxThreadCountTextBox; maxThreadCountTextBox.ToolTip = "The maximum number of threads that you allow UDT to use during batch process operations\n" + "Only set this to a number greater than 1 if you read your demo files from an SSD\n" + "Otherwise, performance will decrease"; maxThreadCountTextBox.HorizontalAlignment = HorizontalAlignment.Left; maxThreadCountTextBox.VerticalAlignment = VerticalAlignment.Center; maxThreadCountTextBox.Text = _app.Config.MaxThreadCount.ToString(); maxThreadCountTextBox.Width = 25; var useInputFolderForBrowsingCheckBox = new CheckBox(); _useInputFolderForBrowsingCheckBox = useInputFolderForBrowsingCheckBox; useInputFolderForBrowsingCheckBox.HorizontalAlignment = HorizontalAlignment.Left; useInputFolderForBrowsingCheckBox.VerticalAlignment = VerticalAlignment.Center; useInputFolderForBrowsingCheckBox.IsChecked = _app.Config.UseInputFolderAsDefaultBrowsingLocation; useInputFolderForBrowsingCheckBox.Content = " Use input folder as default browsing location?"; useInputFolderForBrowsingCheckBox.Checked += (obj, args) => OnInputFolderForBrowsingChecked(); useInputFolderForBrowsingCheckBox.Unchecked += (obj, args) => OnInputFolderForBrowsingUnchecked(); var useInputFolderOnStartUpCheckBox = new CheckBox(); _useInputFolderOnStartUpCheckBox = useInputFolderOnStartUpCheckBox; useInputFolderOnStartUpCheckBox.HorizontalAlignment = HorizontalAlignment.Left; useInputFolderOnStartUpCheckBox.VerticalAlignment = VerticalAlignment.Center; useInputFolderOnStartUpCheckBox.IsChecked = _app.Config.OpenDemosFromInputFolderOnStartUp; useInputFolderOnStartUpCheckBox.Content = " Open demos from input folder on application start-up?"; useInputFolderOnStartUpCheckBox.Checked += (obj, args) => OnUseInputFolderOnStartUpChecked(); useInputFolderOnStartUpCheckBox.Unchecked += (obj, args) => OnUseInputFolderOnStartUpUnchecked(); var inputFolderRow = CreateFolderRow( ref _inputFolderTextBox, _app.Config.InputFolder, "Browse for the folder demos will be read or searched from"); var analyzeOnLoadCheckBox = new CheckBox(); _analyzeOnLoadCheckBox = analyzeOnLoadCheckBox; analyzeOnLoadCheckBox.HorizontalAlignment = HorizontalAlignment.Left; analyzeOnLoadCheckBox.VerticalAlignment = VerticalAlignment.Center; analyzeOnLoadCheckBox.IsChecked = _app.Config.AnalyzeOnLoad; analyzeOnLoadCheckBox.Content = " Analyze demos when loading them into the list?"; analyzeOnLoadCheckBox.Checked += (obj, args) => _app.Config.AnalyzeOnLoad = true; analyzeOnLoadCheckBox.Unchecked += (obj, args) => _app.Config.AnalyzeOnLoad = false; analyzeOnLoadCheckBox.ToolTip = " You can always launch the analysis pass from the \"Manage\" tab."; var mergeCutSectionsCheckBox = new CheckBox(); _mergeCutSectionsCheckBox = mergeCutSectionsCheckBox; mergeCutSectionsCheckBox.HorizontalAlignment = HorizontalAlignment.Left; mergeCutSectionsCheckBox.VerticalAlignment = VerticalAlignment.Center; mergeCutSectionsCheckBox.IsChecked = _app.Config.MergeCutSectionsFromDifferentPatterns; mergeCutSectionsCheckBox.Content = " Merge overlapping cut sections matched by different pattern types?"; mergeCutSectionsCheckBox.Checked += (obj, args) => _app.Config.MergeCutSectionsFromDifferentPatterns = true; mergeCutSectionsCheckBox.Unchecked += (obj, args) => _app.Config.MergeCutSectionsFromDifferentPatterns = false; var colorLogMessagesCheckBox = new CheckBox(); _colorLogMessagesCheckBox = colorLogMessagesCheckBox; colorLogMessagesCheckBox.HorizontalAlignment = HorizontalAlignment.Left; colorLogMessagesCheckBox.VerticalAlignment = VerticalAlignment.Center; colorLogMessagesCheckBox.IsChecked = _app.Config.ColorLogWarningsAndErrors; colorLogMessagesCheckBox.Content = " Color the log window's warning and error messages?"; colorLogMessagesCheckBox.Checked += (obj, args) => _app.Config.ColorLogWarningsAndErrors = true; colorLogMessagesCheckBox.Unchecked += (obj, args) => _app.Config.ColorLogWarningsAndErrors = false; colorLogMessagesCheckBox.ToolTip = "The option is disabled by default because it might not integrate well with your current theme."; var runUpdaterAtStartUpCheckBox = new CheckBox(); _runUpdaterAtStartUpCheckBox = runUpdaterAtStartUpCheckBox; runUpdaterAtStartUpCheckBox.HorizontalAlignment = HorizontalAlignment.Left; runUpdaterAtStartUpCheckBox.VerticalAlignment = VerticalAlignment.Center; runUpdaterAtStartUpCheckBox.IsChecked = _app.Config.RunUpdaterAtStartUp; runUpdaterAtStartUpCheckBox.Content = " Run the updater at application start-up time?"; runUpdaterAtStartUpCheckBox.Checked += (obj, args) => _app.Config.RunUpdaterAtStartUp = true; runUpdaterAtStartUpCheckBox.Unchecked += (obj, args) => _app.Config.RunUpdaterAtStartUp = false; const int OutputFolderIndex = 1; const int SkipRecursiveDialogIndex = 4; const int InputFolderIndex = 8; var panelList = new List <Tuple <FrameworkElement, FrameworkElement> >(); panelList.Add(App.CreateTuple("Output Mode", outputModeCheckBox)); panelList.Add(App.CreateTuple("=> Output Folder", outputFolderRow)); panelList.Add(App.CreateTuple("Chat/Death History", skipChatOffsetsDialogCheckBox)); panelList.Add(App.CreateTuple("Recursive Scan", skipFolderScanModeCheckBox)); panelList.Add(App.CreateTuple("=> Recursive", folderScanModeCheckBox)); panelList.Add(App.CreateTuple("Max Thread Count", maxThreadCountTextBox)); panelList.Add(App.CreateTuple("Browsing Location", useInputFolderForBrowsingCheckBox)); panelList.Add(App.CreateTuple("Open on Start-up", useInputFolderOnStartUpCheckBox)); panelList.Add(App.CreateTuple("=> Input Folder", inputFolderRow)); panelList.Add(App.CreateTuple("Analyze on Load", analyzeOnLoadCheckBox)); panelList.Add(App.CreateTuple("Start Time Offset [s]", startTimeOffsetEditBox)); panelList.Add(App.CreateTuple("End Time Offset [s]", endTimeOffsetEditBox)); panelList.Add(App.CreateTuple("Merge Cut Sections", mergeCutSectionsCheckBox)); panelList.Add(App.CreateTuple("Color Log Messages", colorLogMessagesCheckBox)); panelList.Add(App.CreateTuple("Start-up Updates", runUpdaterAtStartUpCheckBox)); var settingsPanel = WpfHelper.CreateDualColumnPanel(panelList, 135, 2); settingsPanel.HorizontalAlignment = HorizontalAlignment.Left; settingsPanel.VerticalAlignment = VerticalAlignment.Top; settingsPanel.Margin = new Thickness(0); var settingStackPanel = settingsPanel as StackPanel; _outputFolderRow = settingStackPanel.Children[OutputFolderIndex] as FrameworkElement; SetActive(_outputFolderRow, !_app.Config.OutputToInputFolder); _skipRecursiveDialog = settingStackPanel.Children[SkipRecursiveDialogIndex] as FrameworkElement; SetActive(_skipRecursiveDialog, _app.Config.SkipScanFoldersRecursivelyDialog); _inputFolderRow = settingStackPanel.Children[InputFolderIndex] as FrameworkElement; UpdateInputFolderActive(); var settingsGroupBox = new GroupBox(); settingsGroupBox.HorizontalAlignment = HorizontalAlignment.Left; settingsGroupBox.VerticalAlignment = VerticalAlignment.Top; settingsGroupBox.Margin = new Thickness(5); settingsGroupBox.Header = "Settings"; settingsGroupBox.Content = settingsPanel; var plugInNames = UDT_DLL.GetStringArray(UDT_DLL.udtStringArray.PlugInNames); var jsonPlugInsStackPanel = new StackPanel(); jsonPlugInsStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; jsonPlugInsStackPanel.VerticalAlignment = VerticalAlignment.Stretch; jsonPlugInsStackPanel.Margin = new Thickness(5); jsonPlugInsStackPanel.Children.Add(new TextBlock { Text = "Select which analyzers are enabled" }); for (int i = 0; i < (int)UDT_DLL.udtParserPlugIn.Count; ++i) { var checkBox = new CheckBox(); checkBox.Margin = new Thickness(5, 5, 0, 0); checkBox.Content = " " + plugInNames[i].Capitalize(); checkBox.IsChecked = BitManip.IsBitSet(_app.Config.JSONPlugInsEnabled, i); var iCopy = i; // Make sure we capture a local copy in the lambda. checkBox.Checked += (obj, args) => BitManip.SetBit(ref _app.Config.JSONPlugInsEnabled, iCopy); checkBox.Unchecked += (obj, args) => BitManip.ClearBit(ref _app.Config.JSONPlugInsEnabled, iCopy); _jsonEnabledPlugInsCheckBoxes.Add(checkBox); jsonPlugInsStackPanel.Children.Add(checkBox); } var jsonPlugInsGroupBox = new GroupBox(); jsonPlugInsGroupBox.HorizontalAlignment = HorizontalAlignment.Left; jsonPlugInsGroupBox.VerticalAlignment = VerticalAlignment.Top; jsonPlugInsGroupBox.Margin = new Thickness(5); jsonPlugInsGroupBox.Header = "JSON Export"; jsonPlugInsGroupBox.Content = jsonPlugInsStackPanel; var perfStatsNames = UDT_DLL.GetStringArray(UDT_DLL.udtStringArray.PerfStatsNames); var perfStatsStackPanel = new StackPanel(); perfStatsStackPanel.HorizontalAlignment = HorizontalAlignment.Stretch; perfStatsStackPanel.VerticalAlignment = VerticalAlignment.Stretch; perfStatsStackPanel.Margin = new Thickness(5); perfStatsStackPanel.Children.Add(new TextBlock { Text = "Select which job stats are printed in the log window" }); for (int i = 0; i < (int)CSharpPerfStats.Count; ++i) { var checkBox = new CheckBox(); checkBox.Margin = new Thickness(5, 5, 0, 0); checkBox.Content = " " + CSharpPerfStatsConstants.Strings[i].Capitalize(); checkBox.IsChecked = BitManip.IsBitSet(_app.Config.CSharpPerfStatsEnabled, i); var iCopy = i; // Make sure we capture a local copy in the lambda. checkBox.Checked += (obj, args) => BitManip.SetBit(ref _app.Config.CSharpPerfStatsEnabled, iCopy); checkBox.Unchecked += (obj, args) => BitManip.ClearBit(ref _app.Config.CSharpPerfStatsEnabled, iCopy); _enabledCSharpPerfStatsCheckBoxes.Add(checkBox); perfStatsStackPanel.Children.Add(checkBox); } for (int i = 0; i < (int)UDT_DLL.StatsConstants.PerfFieldCount; ++i) { var checkBox = new CheckBox(); checkBox.Margin = new Thickness(5, 5, 0, 0); checkBox.Content = " " + perfStatsNames[i].Capitalize(); checkBox.IsChecked = BitManip.IsBitSet(_app.Config.PerfStatsEnabled, i); var iCopy = i; // Make sure we capture a local copy in the lambda. checkBox.Checked += (obj, args) => BitManip.SetBit(ref _app.Config.PerfStatsEnabled, iCopy); checkBox.Unchecked += (obj, args) => BitManip.ClearBit(ref _app.Config.PerfStatsEnabled, iCopy); _enabledPerfStatsCheckBoxes.Add(checkBox); perfStatsStackPanel.Children.Add(checkBox); } var perfStatsGroupBox = new GroupBox(); perfStatsGroupBox.HorizontalAlignment = HorizontalAlignment.Left; perfStatsGroupBox.VerticalAlignment = VerticalAlignment.Top; perfStatsGroupBox.Margin = new Thickness(5); perfStatsGroupBox.Header = "Performance Logging"; perfStatsGroupBox.Content = perfStatsStackPanel; var rootPanel = new WrapPanel(); rootPanel.HorizontalAlignment = HorizontalAlignment.Stretch; rootPanel.VerticalAlignment = VerticalAlignment.Stretch; rootPanel.Children.Add(settingsGroupBox); rootPanel.Children.Add(perfStatsGroupBox); rootPanel.Children.Add(jsonPlugInsGroupBox); var scrollViewer = new ScrollViewer(); scrollViewer.HorizontalAlignment = HorizontalAlignment.Stretch; scrollViewer.VerticalAlignment = VerticalAlignment.Stretch; scrollViewer.Margin = new Thickness(5); scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scrollViewer.Content = rootPanel; return(scrollViewer); }