Пример #1
0
        protected void clockNameChanged_event(object sender, EventArgs e)
        {
            TreeIter activeIter;

            if (watchNameCombo.GetActiveIter(out activeIter))
            {
                LoggingHandler selectedHandler =
                    _handlerListStore.GetValue(activeIter, 0) as LoggingHandler;

                if (selectedHandler != null)
                {
                    watchNameCombo.Entry.Text = selectedHandler.Name;
                }
            }
        }
Пример #2
0
        private Program()
        {
            Gtk.Window.DefaultIconList = new Pixbuf[]
            {
                Pixbuf.LoadFromResource("chrono-marker-16.png"),
                Pixbuf.LoadFromResource("chrono-marker-24.png"),
                Pixbuf.LoadFromResource("chrono-marker-32.png"),
                Pixbuf.LoadFromResource("chrono-marker-48.png"),
                Pixbuf.LoadFromResource("chrono-marker-64.png"),
            };

            // Load settings. This is important.
            Settings = Preferences.Load(settingsFilename);

            TextRefresher = new FrequentCaller(textRefreshFrequency);

            TimeLogger = new TimeLogger(Settings.TimeDisplaySettings);

            TimeLogger.ClockAdded   += loggerClockAdded_event;
            TimeLogger.ClockRemoved += loggerClockRemoved_event;

            History = new History(historySteps);

            // Creates exporters
            LogExporters = new List <Chrono.Files.ILogExporter>();
            LogExporters.Add(new Files.HTMLExporter());
            LogExporters.Add(new Files.XMLExporter());
            LogExporters.Add(new Files.PlainTextExporter());

            clockWindows          = new Dictionary <LoggingHandler, StopwatchWindow>();
            LoggerWindow          = new LoggerWindow(this);
            ClockPropertiesWindow = new ClockPropertiesWindow(this);
            PreferencesWindow     = new PreferencesWindow(this);

            // Creates the first clock if configured to do so
            if (Settings.CreateWatchOnStartup && TimeLogger.CanCreateClock(Settings.StartupWatchName))
            {
                LoggingHandler firstClockHandler =
                    TimeLogger.CreateClock(Settings.StartupWatchName);

                StopwatchWindow clockWindow = clockWindows [firstClockHandler];

                clockWindow.DisplayVisible = true;
            }
        }
Пример #3
0
        /// <summary>
        /// Creates a new clock logging handler with the given name
        /// </summary>
        /// <returns>
        /// The newly created handler
        /// </returns>
        /// <param name='name'>
        /// Name for the handler
        /// </param>
        public LoggingHandler CreateClock(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("Blank name");
            }

            if (_namedHandlers.ContainsKey(name))
            {
                throw new ArgumentException(string.Format(
                                                "Handler \"{0}\" already exists", name));
            }

            LoggingHandler result = new LoggingHandler(this, new Clock(), name);

            _namedHandlers.Add(name, result);

            if (ClockAdded != null)
            {
                ClockAdded(this, new ClockHandlerEventArgs(result));
            }

            return(result);
        }
Пример #4
0
 public bool TryGetClockWindow(LoggingHandler handler, out StopwatchWindow window)
 {
     return(clockWindows.TryGetValue(handler, out window));
 }
Пример #5
0
        protected void clockNameBtn_event(object sender, EventArgs e)
        {
            string clockName = watchNameCombo.Entry.Text;

            if (_currentHandler == null)
            {
                if (!Logger.CanCreateClock(clockName))
                {
                    string localError = Catalog.GetString("Failed to create stopwatch \"{0}\".");

                    Program.ShowError(this, localError, clockName);
                    return;
                }

                LoggingHandler newHandler = Logger.CreateClock(clockName);
                ChangeHandler(newHandler);

                _clockWindow.DisplayVisible = true;

                // This avoids having the newly created window appear
                // Over the properties window
                this.Present();

                RefreshControls( );
            }
            else
            {
                RenameClockDialog renameDiag = new RenameClockDialog(_currentHandler.Name);
                renameDiag.TransientFor = this;

RunRenameDialog:
                if (renameDiag.Run() == (int)ResponseType.Ok)
                {
                    string newName = renameDiag.NewName;
                    if (newName != _currentHandler.Name)
                    {
                        if (string.IsNullOrWhiteSpace(newName))
                        {
                            string localError = Catalog.GetString("Blank names are not valid.");

                            Program.ShowError(renameDiag, localError);

                            goto RunRenameDialog;
                        }
                        // This name comparison allows the user to rename a clock using different casing
                        else if (!string.Equals(newName, _currentHandler.Name, TimeLogger.HandlerNameComparison) &&
                                 _currentHandler.Logger.HasClock(newName))
                        {
                            string localError = Catalog.GetString("A stopwatch with named \"{0}\" already exists!\n" +
                                                                  "Please choose another name.");

                            Program.ShowError(renameDiag, localError, newName);

                            goto RunRenameDialog;
                        }

                        _currentHandler.Name = newName;

                        RefreshControls();
                    }
                }

                renameDiag.Destroy();
            }
        }
Пример #6
0
 public void SetHandler(LoggingHandler handler)
 {
     watchNameCombo.Entry.Text = handler.Name;
 }
Пример #7
0
 public ClockHandlerEventArgs(LoggingHandler loggingHandler)
 {
     _loggingHandler = loggingHandler;
 }
Пример #8
0
 public bool TryGetHandler(string name, out LoggingHandler result)
 {
     return(_namedHandlers.TryGetValue(name, out result));
 }