using System; using System.Collections.Generic; using System.Drawing; using System.Text; using System.Xml; using ProcessHacker.Common; using ProcessHacker.Common.Settings; using System.Windows.Forms; namespace ProcessHacker { public class Settings : SettingsBase { private static Settings _instance; private static XmlFileSettingsStore _store; public static Settings Instance { get { return _instance; } set { _instance = value; } } public Settings(string fileName) : base(new XmlFileSettingsStore(fileName)) { this.Invalidate(); } protected override void Invalidate() { _refreshInterval = (int)this["RefreshInterval"]; } private bool? _alwaysOnTop; [SettingDefault("False")] public bool AlwaysOnTop { get { return _alwaysOnTop.HasValue ? _alwaysOnTop.Value : (bool)this["AlwaysOnTop"]; } set { this["AlwaysOnTop"] = _alwaysOnTop = value; } } private string _callStackColumns; [SettingDefault("")] public string CallStackColumns { get { return _callStackColumns != null ? _callStackColumns : (string)this["CallStackColumns"]; } set { this["CallStackColumns"] = _callStackColumns = value; } } private Color? _colorDebuggedProcesses; [SettingDefault("204, 187, 255")] public Color ColorDebuggedProcesses { get { return _colorDebuggedProcesses.HasValue ? _colorDebuggedProcesses.Value : (Color)this["ColorDebuggedProcesses"]; } set { this["ColorDebuggedProcesses"] = _colorDebuggedProcesses = value; } } private Color? _colorElevatedProcesses; [SettingDefault("255, 170, 0")] public Color ColorElevatedProcesses { get { return _colorElevatedProcesses.HasValue ? _colorElevatedProcesses.Value : (Color)this["ColorElevatedProcesses"]; } set { this["ColorElevatedProcesses"] = _colorElevatedProcesses = value; } } private Color? _colorNew; [SettingDefault("Chartreuse")] public Color ColorNew { get { return _colorNew.HasValue ? _colorNew.Value : (Color)this["ColorNew"]; } set { this["ColorNew"] = _colorNew = value; } } private Color? _colorOwnProcesses; [SettingDefault("255, 255, 170")] public Color ColorOwnProcesses { get { return _colorOwnProcesses.HasValue ? _colorOwnProcesses.Value : (Color)this["ColorOwnProcesses"]; } set { this["ColorOwnProcesses"] = _colorOwnProcesses = value; } } private Color? _colorRemoved; [SettingDefault("255, 60, 40")] public Color ColorRemoved { get { return _colorRemoved.HasValue ? _colorRemoved.Value : (Color)this["ColorRemoved"]; } set { this["ColorRemoved"] = _colorRemoved = value; } } private Color? _colorServiceProcesses; [SettingDefault("204, 255, 255")] public Color ColorServiceProcesses { get { return _colorServiceProcesses.HasValue ? _colorServiceProcesses.Value : (Color)this["ColorServiceProcesses"]; } set { this["ColorServiceProcesses"] = _colorServiceProcesses = value; } } private Color? _colorSystemProcesses; [SettingDefault("170, 204, 255")] public Color ColorSystemProcesses { get { return _colorSystemProcesses.HasValue ? _colorSystemProcesses.Value : (Color)this["ColorSystemProcesses"]; } set { this["ColorSystemProcesses"] = _colorSystemProcesses = value; } } private bool? _deletedServices; [SettingDefault("True")] public bool DeletedServices { get { return _deletedServices.HasValue ? _deletedServices.Value : (bool)this["DeletedServices"]; } set { this["DeletedServices"] = _deletedServices = value; } } private string _groupListColumns; [SettingDefault("")] public string GroupListColumns { get { return _groupListColumns != null ? _groupListColumns : (string)this["GroupListColumns"]; } set { this["GroupListColumns"] = _groupListColumns = value; } } private string _handleFilterWindowListViewColumns; [SettingDefault("")] public string HandleFilterWindowListViewColumns { get { return _handleFilterWindowListViewColumns != null ? _handleFilterWindowListViewColumns : (string)this["HandleFilterWindowListViewColumns"]; } set { this["HandleFilterWindowListViewColumns"] = _handleFilterWindowListViewColumns = value; } } private Size? _handleFilterWindowSize; [SettingDefault("554, 463")] public string HandleFilterWindowSize { get { return _handleFilterWindowSize.HasValue ? _handleFilterWindowSize.Value : (Size)this["HandleFilterWindowSize"]; } set { this["HandleFilterWindowSize"] = _handleFilterWindowSize = value; } } private string _handleListViewColumns; [SettingDefault("")] public string HandleListViewColumns { get { return _handleListViewColumns != null ? _handleListViewColumns : (string)this["HandleListViewColumns"]; } set { this["HandleListViewColumns"] = _handleListViewColumns = value; } } private bool? _hideWhenMinimized; [SettingDefault("False")] public bool HideWhenMinimized { get { return _hideWhenMinimized.HasValue ? _hideWhenMinimized.Value : (bool)this["HideWhenMinimized"]; } set { this["HideWhenMinimized"] = _hideWhenMinimized = value; } } private int _highlightingDuration; [SettingDefault("1000")] public int HighlightingDuration { get { return _highlightingDuration; } set { this["HighlightingDuration"] = _highlightingDuration = value; } } private string _memoryListViewColumns; [SettingDefault("")] public string MemoryListViewColumns { get { return _memoryListViewColumns != null ? _memoryListViewColumns : (string)this["MemoryListViewColumns"]; } set { this["MemoryListViewColumns"] = _memoryListViewColumns = value; } } private Size? _memoryWindowSize; [SettingDefault("791, 503")] public Size MemoryWindowSize { get { return _memoryWindowSize.HasValue ? _memoryWindowSize.Value : (Size)this["MemoryWindowSize"]; } set { this["MemoryWindowSize"] = _memoryWindowSize = value; } } private string _moduleListViewColumns; [SettingDefault("")] public string ModuleListViewColumns { get { return _moduleListViewColumns != null ? _moduleListViewColumns : (string)this["ModuleListViewColumns"]; } set { this["ModuleListViewColumns"] = _moduleListViewColumns = value; } } private bool? _newProcesses; [SettingDefault("False")] public bool NewProcesses { get { return _newProcesses.HasValue ? _newProcesses.Value : (bool)this["NewProcesses"]; } set { this["NewProcesses"] = _newProcesses = value; } } private bool? _newServices; [SettingDefault("True")] public bool NewServices { get { return _newServices.HasValue ? _newServices.Value : (bool)this["NewServices"]; } set { this["NewServices"] = _newServices = value; } } private string _peCoffHColumns; [SettingDefault("")] public string PECOFFHColumns { get { return _peCoffHColumns != null ? _peCoffHColumns : (string)this["PECOFFHColumns"]; } set { this["PECOFFHColumns"] = _peCoffHColumns = value; } } private string _peCoffOHColumns; [SettingDefault("")] public string PECOFFOHColumns { get { return _peCoffOHColumns != null ? _peCoffOHColumns : (string)this["PECOFFOHColumns"]; } set { this["PECOFFOHColumns"] = _peCoffOHColumns = value; } } private string _peExportsColumns; [SettingDefault("")] public string PEExportsColumns { get { return _peExportsColumns != null ? _peExportsColumns : (string)this["PEExportsColumns"]; } set { this["PEExportsColumns"] = _peExportsColumns = value; } } private string _peImageDataColumns; [SettingDefault("")] public string PEImageDataColumns { get { return _peImageDataColumns != null ? _peImageDataColumns : (string)this["PEImageDataColumns"]; } set { this["PEImageDataColumns"] = _peImageDataColumns = value; } } private string _peImportsColumns; [SettingDefault("")] public string PEImportsColumns { get { return _peImportsColumns != null ? _peImportsColumns : (string)this["PEImportsColumns"]; } set { this["PEImportsColumns"] = _peImportsColumns = value; } } private string _peSectionsColumns; [SettingDefault("")] public string PESectionsColumns { get { return _peSectionsColumns != null ? _peSectionsColumns : (string)this["PESectionsColumns"]; } set { this["PESectionsColumns"] = _peSectionsColumns = value; } } private Size? _peWindowSize; [SettingDefault("439, 413")] public Size PEWindowSize { get { return _peWindowSize.HasValue ? _peWindowSize.Value : (Size)this["PEWindowSize"]; } set { this["PEWindowSize"] = _peWindowSize = value; } } private bool _plotterAntialias; [SettingDefault("False")] public bool PlotterAntialias { get { return _plotterAntialias; } set { this["PlotterAntialias"] = _plotterAntialias = value; } } private Color? _plotterCPUKernelColor; [SettingDefault("Lime")] public Color PlotterCPUKernelColor { get { return _plotterCPUKernelColor.HasValue ? _plotterCPUKernelColor.Value : (Color)this["PlotterCPUKernelColor"]; } set { this["PlotterCPUKernelColor"] = _plotterCPUKernelColor = value; } } private Color? _plotterCPUUserColor; [SettingDefault("Red")] public Color PlotterCPUUserColor { get { return _plotterCPUUserColor.HasValue ? _plotterCPUUserColor.Value : (Color)this["PlotterCPUUserColor"]; } set { this["PlotterCPUUserColor"] = _plotterCPUUserColor = value; } } private Color? _plotterIOROColor; [SettingDefault("Yellow")] public Color PlotterIOROColor { get { return _plotterIOROColor.HasValue ? _plotterIOROColor.Value : (Color)this["PlotterIOROColor"]; } set { this["PlotterIOROColor"] = _plotterIOROColor = value; } } private Color? _plotterIOWColor; [SettingDefault("DarkViolet")] public Color PlotterIOWColor { get { return _plotterIOWColor.HasValue ? _plotterIOWColor.Value : (Color)this["PlotterIOWColor"]; } set { this["PlotterIOWColor"] = _plotterIOWColor = value; } } private Color? _plotterMemoryPrivateColor; [SettingDefault("Orange")] public Color PlotterMemoryPrivateColor { get { return _plotterMemoryPrivateColor.HasValue ? _plotterMemoryPrivateColor.Value : (Color)this["PlotterMemoryPrivateColor"]; } set { this["PlotterMemoryPrivateColor"] = _plotterMemoryPrivateColor = value; } } private Color? _plotterMemoryWSColor; [SettingDefault("Cyan")] public Color PlotterMemoryWSColor { get { return _plotterMemoryWSColor.HasValue ? _plotterMemoryWSColor.Value : (Color)this["PlotterMemoryWSColor"]; } set { this["PlotterMemoryWSColor"] = _plotterMemoryWSColor = value; } } private string _privilegeListColumns; [SettingDefault("")] public string PrivilegeListColumns { get { return _privilegeListColumns != null ? _privilegeListColumns : (string)this["PrivilegeListColumns"]; } set { this["PrivilegeListColumns"] = _privilegeListColumns = value; } } private string _processTreeColumns; [SettingDefault("")] public string ProcessTreeColumns { get { return _processTreeColumns != null ? _processTreeColumns : (string)this["ProcessTreeColumns"]; } set { this["ProcessTreeColumns"] = _processTreeColumns = value; } } private string _processWindowSelectedTab; [SettingDefault("tabGeneral")] public string ProcessWindowSelectedTab { get { return _processWindowSelectedTab != null ? _processWindowSelectedTab : (string)this["ProcessWindowSelectedTab"]; } set { this["ProcessWindowSelectedTab"] = _processWindowSelectedTab = value; } } private Size? _processWindowSize; [SettingDefault("505, 512")] public Size ProcessWindowSize { get { return _processWindowSize.HasValue ? _processWindowSize.Value : (Size)this["ProcessWindowSize"]; } set { this["ProcessWindowSize"] = _processWindowSize = value; } } private string _promptBoxText; [SettingDefault("")] public string PromptBoxText { get { return _promptBoxText != null ? _promptBoxText : (string)this["PromptBoxText"]; } set { this["PromptBoxText"] = _promptBoxText = value; } } private int _refreshInterval; [SettingDefault("1000")] public int RefreshInterval { get { return _refreshInterval; } set { this["RefreshInterval"] = _refreshInterval = value; } } private string _resultsListViewColumns; [SettingDefault("")] public string ResultsListViewColumns { get { return _resultsListViewColumns != null ? _resultsListViewColumns : (string)this["ResultsListViewColumns"]; } set { this["ResultsListViewColumns"] = _resultsListViewColumns = value; } } private Size? _resultsWindowSize; [SettingDefault("504, 482")] public Size ResultsWindowSize { get { return _resultsWindowSize.HasValue ? _resultsWindowSize.Value : (Size)this["ResultsWindowSize"]; } set { this["ResultsWindowSize"] = _resultsWindowSize = value; } } private string _runAsCommand; [SettingDefault("")] public string RunAsCommand { get { return _runAsCommand != null ? _runAsCommand : (string)this["RunAsCommand"]; } set { this["RunAsCommand"] = _runAsCommand = value; } } private string _runAsUsername; [SettingDefault("")] public string RunAsUsername { get { return _runAsUsername != null ? _runAsUsername : (string)this["RunAsUsername"]; } set { this["RunAsUsername"] = _runAsUsername = value; } } private string _searchEngine; [SettingDefault("http://www.google.com/search?q=%s")] public string SearchEngine { get { return _searchEngine != null ? _searchEngine : (string)this["SearchEngine"]; } set { this["SearchEngine"] = _searchEngine = value; } } private string _searchType; [SettingDefault("&String Scan...")] public string SearchType { get { return _searchType != null ? _searchType : (string)this["SearchType"]; } set { this["SearchType"] = _searchType = value; } } private string _serviceListViewColumns; [SettingDefault("")] public string ServiceListViewColumns { get { return _serviceListViewColumns != null ? _serviceListViewColumns : (string)this["ServiceListViewColumns"]; } set { this["ServiceListViewColumns"] = _serviceListViewColumns = value; } } private bool _showAccountDomains; [SettingDefault("False")] public bool ShowAccountDomains { get { return _showAccountDomains; } set { this["ShowAccountDomains"] = _showAccountDomains = value; } } private bool? _startedServices; [SettingDefault("False")] public bool StartedServices { get { return _startedServices.HasValue ? _startedServices.Value : (bool)this["StartedServices"]; } set { this["StartedServices"] = _startedServices = value; } } private bool? _stoppedServices; [SettingDefault("False")] public bool StoppedServices { get { return _stoppedServices.HasValue ? _stoppedServices.Value : (bool)this["StoppedServices"]; } set { this["StoppedServices"] = _stoppedServices = value; } } private bool? _terminatedProcesses; [SettingDefault("False")] public bool TerminatedProcesses { get { return _terminatedProcesses.HasValue ? _terminatedProcesses.Value : (bool)this["TerminatedProcesses"]; } set { this["TerminatedProcesses"] = _terminatedProcesses = value; } } private string _threadListViewColumns; [SettingDefault("")] public string ThreadListViewColumns { get { return _threadListViewColumns != null ? _threadListViewColumns : (string)this["ThreadListViewColumns"]; } set { this["ThreadListViewColumns"] = _threadListViewColumns = value; } } private Size? _threadWindowSize; [SettingDefault("415, 503")] public Size ThreadWindowSize { get { return _threadWindowSize.HasValue ? _threadWindowSize.Value : (Size)this["ThreadWindowSize"]; } set { this["ThreadWindowSize"] = _threadWindowSize = value; } } private Size? _tokenWindowSize; [SettingDefault("481, 468")] public Size TokenWindowSize { get { return _tokenWindowSize.HasValue ? _tokenWindowSize.Value : (Size)this["TokenWindowSize"]; } set { this["TokenWindowSize"] = _tokenWindowSize = value; } } private string _tokenWindowTab; [SettingDefault("tabPrivileges")] public string TokenWindowTab { get { return _tokenWindowTab != null ? _tokenWindowTab : (string)this["TokenWindowTab"]; } set { this["TokenWindowTab"] = _tokenWindowTab = value; } } private bool _warnDangerous; [SettingDefault("True")] public bool WarnDangerous { get { return _warnDangerous; } set { this["WarnDangerous"] = _warnDangerous = value; } } private Point? _windowLocation; [SettingDefault("200, 200")] public Point WindowLocation { get { return _windowLocation.HasValue ? _windowLocation.Value : (Point)this["WindowLocation"]; } set { this["WindowLocation"] = _windowLocation = value; } } private Size? _windowSize; [SettingDefault("844, 550")] public Size WindowSize { get { return _windowSize.HasValue ? _windowSize.Value : (Size)this["WindowSize"]; } set { this["WindowSize"] = _windowSize = value; } } private FormWindowState? _windowState; [SettingDefault("Normal")] public FormWindowState WindowState { get { return _windowState.HasValue ? _windowState.Value : (FormWindowState)this["WindowState"]; } set { this["WindowState"] = _windowState = value; } } } }