private void ApplyChanges() { TimeFormatSettings timeDisplaySettings = Program.Settings.TimeDisplaySettings; timeDisplaySettings.ShowHours = showHoursCheck.Active; timeDisplaySettings.ShowMinutes = showMinutesCheck.Active; timeDisplaySettings.ShowSeconds = showSecondsCheck.Active; timeDisplaySettings.ShowMilliseconds = showMillisecondsCheck.Active; timeDisplaySettings.ShowLeadingZeroes = showLeadingZerosCheck.Active; timeDisplaySettings.ShowMinusSymbol = showMinusSymbolCheck.Active; timeDisplaySettings.ShowPlusSymbol = showPlusSymbolCheck.Active; timeDisplaySettings.ShowSeparators = showSeparatorsOption.Active; Preferences.CreateWatchOnStartup = createWatchOnStartupCheck.Active; Preferences.StartupWatchName = startupClockNameEntry.Text; Preferences.WatchDockedByDefault = dockedByDefaultCheck.Active; Preferences.WatchCompactByDefault = compactByDefaultCheck.Active; List <LoggingHandler> clockList = Program.TimeLogger.GetClockList(); foreach (LoggingHandler handler in clockList) { StopwatchWindow clockWindow; if (Program.TryGetClockWindow(handler, out clockWindow)) { clockWindow.RefreshTimeDisplay(); clockWindow.RefreshControls(); } } }
public TimeLogger(TimeFormatSettings defaultFormat) { _logEntryNodes = new Dictionary <LogEntry, LinkedListNode <LogEntry> >(); _manyLogEntries = new LinkedList <LogEntry>(); _namedHandlers = new Dictionary <string, LoggingHandler>( StringComparer.CurrentCultureIgnoreCase); DefaultFormatSettings = defaultFormat; }
public PreferencesWindow(Program program) : base(Gtk.WindowType.Toplevel) { this.Build( ); this.Program = program; FontDescription monospace = FontDescription.FromString("monospace"); previewDisplayBox1.ModifyFont(monospace); previewDisplayBox2.ModifyFont(monospace); previewDisplaySettings = new TimeFormatSettings(); RefreshTexts(); }
/// <summary> /// Creates a log for when a clock has stopped ticking /// </summary> private void clockStopped_event(object sender, ClockEventArgs e) { string translatable, logDesc; if (e.Speed >= 0) { translatable = Catalog.GetString("Stopped ticking with {0}."); } else { translatable = Catalog.GetString("Stopped counting down with {0}."); } TimeSpan time = ApplyCap(e.DisplayTime); logDesc = string.Format(translatable, TimeFormatSettings.ToString(time)); Logger.AddEntry(new LogEntry(_name, logDesc, e.Timestamp)); }
public static int GetDisplayWidth(TimeFormatSettings settings) { int result = 0; if (settings.ShowPlusSymbol || settings.ShowMinusSymbol) { result += 1; // + or - } if (settings.ShowMilliseconds) { if (settings.ShowSeconds) { if (settings.ShowSeparators) { result += 4; // .999 } else { result += 5; // 999ms } } else { if (settings.ShowSeparators) { result += 9; // 86400000 } else { result += 11; // 86400000ms } } } if (settings.ShowSeconds) { if (settings.ShowMinutes) { result += 3; // :59 or 59s } else { if (settings.ShowSeparators) { result += 5; // 86400 } else { result += 6; // 86400s } } } if (settings.ShowMinutes) { if (settings.ShowHours) { result += 3; // :59 or 59m } else { if (settings.ShowSeparators) { result += 4; // 1440 } else { result += 5; // 1440m } } } if (settings.ShowHours) { if (settings.ShowSeparators) { result += 3; // 168 } else { result += 4; // 168h } } return(result); }