Ejemplo n.º 1
0
        private void DynamicButton_Click(object sender, EventArgs e, Form passedForm)
        {
            //Form1 frmMain = (Form1)Application.OpenForms["Form1"];
            timerHide = 0;
            StatMessage statMessage = new StatMessage()
            {
                cpu_name     = Environment.MachineName,
                stat_user    = statUser,
                created_by   = statUser.user_name,
                stat_date    = DateTime.Now,
                stat_type    = (sender as Button).Text.Split('(')[0].Trim(),
                stat_comment = ""
            };

            if ((string)(sender as Button).Tag == "time")
            {
                FComment fComment = FormFactory.Create <FComment>("number", "Amount of time spent:");
                if (fComment.ShowDialog() == DialogResult.OK)
                {
                    statMessage.stat_comment = fComment.textBox1.Text;
                }
            }
            if ((string)(sender as Button).Tag == "string")
            {
                FComment fComment = FormFactory.Create <FComment>("", "Enter Comment:");
                if (fComment.ShowDialog() == DialogResult.OK)
                {
                    statMessage.stat_comment = fComment.textBox1.Text;
                }
            }
            apiStatWrapper.PostStat(statMessage);
            if (BackColor == Color.Blue)
            {
                BackColor = Color.White;
            }
            else if (BackColor == Color.White)
            {
                BackColor = Color.Blue;
            }
            string strCount    = (sender as Button).Text.Split('(')[1].Replace(")", string.Empty);
            int    countButton = 0;

            if (int.TryParse(strCount, out countButton))
            {
                countButton++;
            }
            (sender as Button).Text = $"{statMessage.stat_type}({countButton.ToString()})";
        }
Ejemplo n.º 2
0
 public bool ApiPostStat(StatMessage statMessage) => apiStatsWrapper.PostStat(statMessage);