Ejemplo n.º 1
0
        // 填寫資料欄位
        private void edit_page_Show(object sender, EventArgs e)
        {
            flatButton.FlatButton panel = (flatButton.FlatButton)sender;
            Console.WriteLine(">>" + panel.userData);
            int recordId = Int32.Parse(panel.userData);

            record_btn_edit.Visible = true;
            record_btn_del.Visible  = true;
            record_btn_save.Visible = false;
            // 將recordId放到欲操作的userData中
            record_btn_edit.userData = panel.userData;
            record_btn_del.userData  = panel.userData;

            // TODO: 將資料庫的資料拉進來
            addRecord_date.Value        = new DateTime(dataBase.getRecordYear(recordId, sender, e), dataBase.getRecordMonth(recordId, sender, e), dataBase.getRecordDate(recordId, sender, e));
            addRecord_time.Value        = new DateTime(2018, 1, 1, dataBase.getRecordTimeHr(recordId, sender, e), dataBase.getRecordTimeMin(recordId, sender, e), 0);
            addRecord_cost.Value        = (decimal)dataBase.getRecordEndureTime(recordId, sender, e) * 60;
            addRecord_type.SelectedItem = dataBase.getRecordExerciseName(recordId, sender, e);
            update_exersiceType();

            addRecord_kcal.Value    = (decimal)dataBase.getRecordCalories(recordId, sender, e);
            addRecord_panel.Enabled = true;

            addRecord_panel.BringToFront();
        }
Ejemplo n.º 2
0
        // 側邊欄位操作
        private void navbarBtn_Click(object sender, EventArgs e)
        {
            flatButton.FlatButton btn = (flatButton.FlatButton)sender;
            Panel panel = (Panel)btn.linkControl;


            // 其他畫面都關掉

            if (active_navbar_btn != null)
            {
                active_navbar_btn.themeColor          = btn.themeColor;
                active_navbar_btn.linkControl.Enabled = false;
                active_navbar_btn.linkControl.Visible = false;
                active_navbar_btn.Enabled             = true;
            }

            btn.themeColor = Color.FromArgb(166, 211, 179);

            if (!is_recordPage_show_all_id)
            {
                is_recordPage_show_all_id = true;
                record_page.Enabled       = false;
                record_page.Visible       = false;
            }

            // 改變btn的狀態
            btn.Enabled       = false;
            btn.Cursor        = Cursors.Arrow;
            active_navbar_btn = btn;
            panel.Enabled     = true;
        }
Ejemplo n.º 3
0
 private void del_exersiceType(object sender, EventArgs e)
 {
     flatButton.FlatButton panel = (flatButton.FlatButton)sender;
     dataBase.delExerciseByName((string)panel.Tag);
     MessageBox.Show("已經把刪除" + (string)panel1.Tag + "了~");
     setting_page.Enabled = false;
     setting_page.Enabled = true;
 }
Ejemplo n.º 4
0
        // Setting
        private void setting_page_EnabledChange(object sender, EventArgs e)
        {
            // 將所有type拉進來
            Panel     panel = (Panel)sender;
            ArrayList names = dataBase.getAllExerciseName(null, null);

            exersiceType_table.Controls.Clear();

            for (int i = 0; i < names.Count / 3; i++)
            {
                Console.WriteLine((names[i * 3] + "").Trim() + " " + names[i * 3 + 1] + " " + names[i * 3 + 2]);
                Label                 name     = new Label();
                Label                 txt      = new Label();
                NumericUpDown         cal      = new NumericUpDown();
                flatButton.FlatButton edit_btn = new flatButton.FlatButton();
                Font txt_font = new Font(new FontFamily("微軟正黑體"), 17f, FontStyle.Regular, GraphicsUnit.Pixel);

                name.AutoSize = false;
                name.Size     = new Size(50, 20);
                txt.AutoSize  = false;
                txt.Size      = new Size(100, 20);
                cal.Size      = new Size(80, 20);

                name.Font     = txt_font;
                txt.Font      = txt_font;
                name.Text     = (names[i * 3] + "").Trim();
                txt.Text      = "kcal/min";
                cal.Maximum   = 50000;
                cal.Value     = int.Parse((string)names[i * 3 + 1]);
                edit_btn.Text = "刪除";
                edit_btn.Tag  = name.Text;

                edit_btn.Click += new System.EventHandler(del_exersiceType);

                exersiceType_table.Controls.Add(name);
                exersiceType_table.Controls.Add(cal);
                exersiceType_table.Controls.Add(txt);
                exersiceType_table.Controls.Add(edit_btn);
            }
            panel.Visible = true;
            Console.WriteLine(panel.Name);
        }
Ejemplo n.º 5
0
        private void recordTable_Load(string[,] data, TableLayoutPanel table)
        {
            //讀取資料
            for (int i = 0; i < data.GetLongLength(0); i++)
            {
                if (data[i, 2] == null) // 如果運動內容為null表示此資料不存在
                {
                    continue;
                }

                Panel record = new Panel();
                record.Margin    = new Padding(10);
                record.Dock      = DockStyle.Fill;
                record.AutoSize  = true;
                record.BackColor = Color.FromArgb(117, 205, 176);

                Label date    = new Label();
                Label cost    = new Label();
                Label content = new Label();
                Label cal     = new Label();

                date.BackColor = cost.BackColor = content.BackColor = cal.BackColor = Color.FromArgb(117, 205, 176);

                date.AutoSize    = true;
                cost.AutoSize    = true;
                content.AutoSize = true;
                cal.AutoSize     = true;

                flatButton.FlatButton edit = new flatButton.FlatButton();
                edit.Text       = "編輯";
                edit.userData   = data[i, 0] + "";
                edit.themeColor = Color.LightCoral;
                edit.Click     += new EventHandler(edit_page_Show);

                Font txt_font = new Font(new FontFamily("微軟正黑體"), 17f, FontStyle.Regular, GraphicsUnit.Pixel);
                date.Font    = txt_font;
                cost.Font    = txt_font;
                content.Font = txt_font;
                cal.Font     = txt_font;

                Color txt_color = Color.FromArgb(51, 40, 52);
                date.ForeColor    = txt_color;
                cost.ForeColor    = txt_color;
                content.ForeColor = txt_color;
                cal.ForeColor     = txt_color;

                date.Dock    = DockStyle.Bottom;
                cost.Dock    = DockStyle.Bottom;
                content.Dock = DockStyle.Bottom;
                cal.Dock     = DockStyle.Bottom;
                edit.Dock    = DockStyle.Right;


                date.Text    = data[i, 4] + "\t id:" + data[i, 0];
                cost.Text    = data[i, 1] + "分鐘";
                content.Text = data[i, 2];
                cal.Text     = data[i, 3] + "大卡";

                record.Controls.Add(date);
                record.Controls.Add(cost);
                record.Controls.Add(content);
                record.Controls.Add(cal);
                record.Controls.Add(edit);
                table.Controls.Add(record);
            }
        }
Ejemplo n.º 6
0
        // 月曆
        private void calender_page_EnabledChanged(object sender, EventArgs e)
        {
            Panel panel = (Panel)sender;

            if (panel.Enabled)
            {
                calender_label_month.Text = calender_show_month + "月";
                calender_label_year.Text  = calender_show_year + "年";

                // 找到本月1日是星期幾
                DateTime first_day = new DateTime(calender_show_year, calender_show_month, 1);
                Console.Write((int)first_day.DayOfWeek);
                int days      = DateTime.DaysInMonth(calender_show_year, calender_show_month);
                int dayOfWeek = (int)first_day.DayOfWeek;


                for (int i = 0; i < 42; i++)
                {
                    flatButton.FlatButton btn = (flatButton.FlatButton)tableLayoutPanel1.GetControlFromPosition(i % 7, i / 7 + 1);
                    if (i < dayOfWeek || i > days + dayOfWeek - 1)
                    {
                        btn.themeColor = Color.FromArgb(160, Color.WhiteSmoke);
                        btn.Text       = "";
                        btn.Enabled    = false;
                    }
                    else
                    {
                        int day = (i - dayOfWeek + 1);
                        btn.userData = day + "";
                        float     cals = 0;
                        ArrayList Ids  = dataBase.getRecordId(calender_show_year, calender_show_month, day, sender, e); //抓資料數量進來

                        for (int j = 0; j < Ids.Count; j++)
                        {
                            cals += dataBase.getRecordCalories((int)Ids[j], sender, e);
                        }

                        if (cals > 1000)
                        {
                            btn.themeColor = Color.FromArgb(255, Color.LightCoral);
                        }
                        else if (cals > 500)
                        {
                            btn.themeColor = Color.FromArgb(180, Color.LightCoral);
                        }
                        else if (cals > 0)
                        {
                            btn.themeColor = Color.FromArgb(100, Color.LightCoral);
                        }
                        else
                        {
                            btn.themeColor = Color.FromArgb(117, 205, 176);
                        }

                        btn.Text    = day + "";
                        btn.Enabled = true;
                    }
                }
                panel.Visible = true;
            }
        }