/// <inheritdoc />
        public override bool Execute()
        {
            // BuildNumber + "0...0" + RevisionNumber.
            var stamp = BuildNumber.ToString(CultureInfo.InvariantCulture);

            var revisionString = RevisionNumber.ToString(CultureInfo.InvariantCulture);

            for (int i = 0; i < 5 - revisionString.Length; i++)
            {
                stamp += "0";
            }

            stamp += revisionString;

            BuildStamp = stamp;

            return(!Log.HasLoggedErrors);
        }
Esempio n. 2
0
        public MainForm(StopLocation[] stops)
        {
            m_stops = stops;
            InitializeComponent();

            System.IO.Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BusTracker.startup.jpg");
            m_startupScreenPictureBox.Image = new Bitmap(stream);

            // Create shortcuts on startup if it doesn't exist.
            string exePath                   = Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
            string exeFolder                 = exePath.Substring(0, exePath.LastIndexOf("\\"));
            string shortcutPath              = Path.Combine(ShortcutFolder, string.Format("{0}.lnk", AppName));
            string startMenuShortcutPath     = Path.Combine(StartMenuShortcutFolder, string.Format("{0}.lnk", AppName));
            string startUpFolderShortcutPath = Path.Combine(StartUpFolder, string.Format("{0}.lnk", AppName));
            string shortcutData              = string.Format("{0}#\"{1}\"", exePath.Length, exePath);
            string updatePath                = Path.Combine(UpdateShare, BinaryName);



            // Shortcut in start menu
            if (!File.Exists(shortcutPath) && !File.Exists(startMenuShortcutPath))
            {
                StreamWriter f = new StreamWriter(shortcutPath);
                f.WriteLine(shortcutData);
                f.Close();
            }
            if (!File.Exists(startUpFolderShortcutPath))
            {
                StreamWriter f = new StreamWriter(startUpFolderShortcutPath);
                f.WriteLine(shortcutData);
                f.Close();
            }

            m_infoFetcher = new InfoFetcher();
            m_infoFetcher.BusInfoAvailable                 += new BusInfoAvailableEventHandler(m_infoFetcher_BusInfoAvailable);
            m_infoFetcher.BusInfoFetchComplete             += new EventHandler(m_infoFetcher_BusInfoFetchComplete);
            m_infoFetcher.BusInfoSourceAvailabilityChanged += new EventHandler(m_infoFetcher_BusInfoSourceAvailabilityChanged);

            this.Menu        = null;
            this.WindowState = FormWindowState.Maximized;

            m_stopControls = new StopControl[stops.Length];
            for (int i = 0; i < m_stopControls.Length; i++)
            {
                m_stopControls[i]      = new StopControl(stops[i].FriendlyName, m_stops[i].MaxBuses);
                m_stopControls[i].Left = 0;
                m_panel.Controls.Add(m_stopControls[i]);
            }

            m_panel.BackColor = ColorService.BACKGROUND;
            this.BackColor    = ColorService.BACKGROUND;

            m_quitButton.BackColor         = ColorService.BUTTON_BACKGROUND;
            m_quitButton.ForeColor         = ColorService.BUTTON_FOREGROUND;
            m_quitButtonPanel.BackColor    = m_quitButton.ForeColor;
            m_refreshButton.BackColor      = ColorService.BUTTON_BACKGROUND;
            m_refreshButton.ForeColor      = ColorService.BUTTON_FOREGROUND;
            m_refreshButtonPanel.BackColor = m_refreshButton.ForeColor;

            m_timeLabel.BackColor = ColorService.BACKGROUND;
            m_timeLabel.ForeColor = ColorService.TIME;
            m_timeLabel.Font      = new Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold);

            m_rebootButton.ForeColor = Color.White;
            m_rebootButton.BackColor = Color.Red;

            // Load the image for when the tracker is offline
            stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BusTracker.offline.jpg");
            m_offlinePictureBox.Image = new Bitmap(stream);

            UpdateStopControlsLayout();
            m_updateTimer.Enabled = true;

            m_currentVersion             = (new FileInfo(exePath)).LastWriteTime;
            m_versionLabel.Text          = m_currentVersion.ToShortDateString() + " " + m_currentVersion.ToShortTimeString();
            m_availableVersion           = (new FileInfo(updatePath)).LastWriteTime;
            m_availableVersionLabel.Text = m_availableVersion.ToShortDateString() + " " + m_availableVersion.ToShortTimeString();
            m_revisionLabel.Text         = RevisionNumber.ToString();

            //ScreenOn();
        }