Beispiel #1
0
        public MainForm()
        {
            settings = new Settings();
            settings.Load();

            restRequestFactory    = new RestRequestFactory();
            jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

            restClientFactory         = new RestClientFactory();
            restClientFactory.BaseUrl = this.settings.JiraBaseUrl;

            jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory);

            jiraClient = new JiraClient(jiraApiRequestFactory, jiraApiRequester);

            InitializeComponent();

            cbFilters.DropDownStyle = ComboBoxStyle.DropDownList;
            cbFilters.DisplayMember = "Name";

            ticker = new Timer();
            // First run should be almost immediately after start
            ticker.Interval = firstDelay;
            ticker.Tick    += ticker_Tick;
        }
        public MainForm()
        {
            settings = Settings.Instance;
            if (!settings.Load())
            {
                MessageBox.Show(string.Format("An error occurred while loading settings for Jira StopWatch. Your configuration file has most likely become corrupted.{0}{0}And older configuration file has been loaded instead, so please verify your settings.", Environment.NewLine), "Jira StopWatch");
            }

            Logger.Instance.LogfilePath = Path.Combine(Application.UserAppDataPath, "jirastopwatch.log");
            Logger.Instance.Enabled     = settings.LoggingEnabled;

            restRequestFactory    = new RestRequestFactory();
            jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

            restClientFactory         = new RestClientFactory();
            restClientFactory.BaseUrl = this.settings.JiraBaseUrl;

            jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory);

            jiraClient = new JiraClient(jiraApiRequestFactory, jiraApiRequester);

            InitializeComponent();

            pMain.HorizontalScroll.Maximum = 0;
            pMain.AutoScroll             = false;
            pMain.VerticalScroll.Visible = false;
            pMain.AutoScroll             = true;

            Text = string.Format("{0} v. {1}", Application.ProductName, Application.ProductVersion);

            cbFilters.DropDownStyle = ComboBoxStyle.DropDownList;
            cbFilters.DisplayMember = "Name";

            ticker = new System.Windows.Forms.Timer();
            // First run should be almost immediately after start
            ticker.Interval = firstDelay;
            ticker.Tick    += ticker_Tick;

            serialConnection = new SerialConnection(this.settings);

            List <string> comPortNames = new List <string>();

            serialConnection.GetComPorts(comPortNames);

            this.settings.ComPort = comPortNames;

            serialConnection.PositionEvent += new SerialConnection.PositionEventDelegate(PositionEventHandler);


            tcpConnection = new TcpConnection(this.settings);
            tcpConnection.PositionEvent += new TcpConnection.PositionEventDelegate(PositionEventHandler);

            waitForTimeKeepPosition = false;
            issueKeyForNewPosition  = "";
        }
Beispiel #3
0
        public MainForm()
        {
            settings = Settings.Instance;
            if (!settings.Load())
            {
                MessageBox.Show(string.Format("An error occurred while loading settings for Jira StopWatch. Your configuration file has most likely become corrupted.{0}{0}And older configuration file has been loaded instead, so please verify your settings.", Environment.NewLine), "Jira StopWatch");
            }

            Logger.Instance.LogfilePath = Path.Combine(Application.UserAppDataPath, "jirastopwatch.log");
            Logger.Instance.Enabled     = settings.LoggingEnabled;

            restRequestFactory    = new RestRequestFactory();
            jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

            restClientFactory         = new RestClientFactory();
            restClientFactory.BaseUrl = this.settings.JiraBaseUrl;

            jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory, new HttpBasicAuthenticator(this.settings.Username, this.settings.PrivateApiToken));

            jiraClient = new JiraClient(jiraApiRequestFactory, jiraApiRequester);

            InitializeComponent();
            UpdateTheme();

            Text = string.Format("{0} v. {1}", Application.ProductName, Application.ProductVersion);

            cbFilters.DropDownStyle = ComboBoxStyle.DropDownList;
            cbFilters.DisplayMember = "Name";

            ticker = new Timer();
            // First run should be almost immediately after start
            ticker.Interval = firstDelay;
            ticker.Tick    += ticker_Tick;

            UpdateTotalTimeLogged(new TimeSpan());

            this.tabControl.TabPages[this.tabControl.TabCount - 1].Text = "";
            this.tabControl.Padding  = new Point(12, 4);
            this.tabControl.DrawMode = TabDrawMode.OwnerDrawFixed;

            this.tabControl.DrawItem         += tabControl1_DrawItem;
            this.tabControl.MouseDown        += tabControl1_MouseDown;
            this.tabControl.Selecting        += tabControl1_Selecting;
            this.tabControl.HandleCreated    += tabControl1_HandleCreated;
            this.tabControl.MouseDoubleClick += TabControl_MouseDoubleClick;
        }
Beispiel #4
0
 private void EditSettings()
 {
     using (var form = new SettingsForm(this.settings))
     {
         if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
         {
             restClientFactory.BaseUrl = this.settings.JiraBaseUrl;
             jiraApiRequester          = new JiraApiRequester(restClientFactory, jiraApiRequestFactory, new HttpBasicAuthenticator(this.settings.Username, this.settings.PrivateApiToken));
             jiraClient = new JiraClient(jiraApiRequestFactory, jiraApiRequester);
             Logging.Logger.Instance.Enabled = settings.LoggingEnabled;
             if (IsJiraEnabled)
             {
                 AuthenticateJira(this.settings.Username, this.settings.PrivateApiToken);
             }
             InitializeIssueControls();
         }
     }
 }
Beispiel #5
0
        private void pictureBox1_Click(object sender, System.EventArgs e)
        {
            var flag = false;

            try
            {
                var restRequestFactory    = new RestRequestFactory();
                var jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

                var restClientFactory = new RestClientFactory {
                    BaseUrl = tbJiraBaseUrl.Text
                };

                var jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory, new HttpBasicAuthenticator(tbUsername.Text, tbApiPrivateToken.Text));
                var request          = jiraApiRequestFactory.CreateAuthenticateRequest();
                var response         = jiraApiRequester.DoAuthenticatedRequest <object>(request);
                var authObj          = response as Dictionary <string, object>;
                if (authObj != null && authObj.ContainsKey("avatarUrls"))
                {
                    var avartObj = authObj["avatarUrls"] as Dictionary <string, object>;
                    if (avartObj != null)
                    {
                        flag = true;
                        picBox.LoadAsync(avartObj["48x48"].ToString());
                    }
                }
            }
            catch (Exception)
            {
            }

            if (!flag)
            {
                var msg = $"Jira StopWatch could not connect to your Jira server. {Environment.NewLine}";
                MessageBox.Show(msg, "Failed to retrieve JIRA Avatar!");
            }
        }
Beispiel #6
0
        public MainForm()
        {
            settings = Settings.Instance;
            if (!settings.Load())
            {
                MessageBox.Show(string.Format("An error occurred while loading settings for Jira StopWatch. Your configuration file has most likely become corrupted.{0}{0}And older configuration file has been loaded instead, so please verify your settings.", Environment.NewLine), "Jira StopWatch");
            }

            Logger.Instance.LogfilePath = Path.Combine(Application.UserAppDataPath, "jirastopwatch.log");
            Logger.Instance.Enabled     = settings.LoggingEnabled;

            restRequestFactory    = new RestRequestFactory();
            jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

            restClientFactory         = new RestClientFactory();
            restClientFactory.BaseUrl = this.settings.JiraBaseUrl;

            jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory);

            jiraClient = new JiraClient(jiraApiRequestFactory, jiraApiRequester);

            InitializeComponent();

            pMain.HorizontalScroll.Maximum = 0;
            pMain.AutoScroll             = false;
            pMain.VerticalScroll.Visible = false;
            pMain.AutoScroll             = true;

            Text = string.Format("{0} {1}", Application.ProductName, Application.ProductVersion);

            cbFilters.DropDownStyle = ComboBoxStyle.DropDownList;
            cbFilters.DisplayMember = "Name";

            ticker = new Timer();
            // First run should be almost immediately after start
            ticker.Interval = firstDelay;
            ticker.Tick    += ticker_Tick;

            idleTicker          = new Timer();
            idleTicker.Interval = idleCheckInterval;
            idleTicker.Tick    += idle_Tick;

            runningTicker          = new Timer();
            runningTicker.Interval = runningCheckInterval;
            runningTicker.Tick    += running_Tick;

            backupTicker          = new Timer();
            backupTicker.Interval = backupCheckInterval;
            backupTicker.Tick    += backup_Tick;

            backupTimer = new WatchTimer();

            // load backup timer state
            TimerState backupTimerState = new TimerState
            {
                TotalTime = settings.BackupTimer
            };

            backupTimer.SetState(backupTimerState);

            UpdateBackupTime();
        }