コード例 #1
0
        private void LoadComboBox()
        {
            List <WorkoutCategoryDetailDTO> wcList = wcBll.GetCategories();

            wcList.Insert(0, new WorkoutCategoryDetailDTO
            {
                Name = "全部類別",
                ID   = -1
            });

            this.cmbWorkoutCategory.DisplayMember = "Name";
            this.cmbWorkoutCategory.ValueMember   = "ID";
            this.cmbWorkoutCategory.DataSource    = wcList;

            List <ActivityLevelDetailDTO> alList = alBll.GetActivityLevels().OrderBy(e => e.ID).ToList();

            alList.Insert(0, new ActivityLevelDetailDTO
            {
                Description = "全部強度",
                ID          = -1
            });

            this.cmbActivityLevel.DisplayMember = "Description";
            this.cmbActivityLevel.ValueMember   = "ID";
            this.cmbActivityLevel.DataSource    = alList;

            List <WorkoutDetailDTO> wList = wBll.GetWorkoutByWCAL();

            this.cmbWorkout.DisplayMember = "Name";
            this.cmbWorkout.ValueMember   = "ID";
            this.cmbWorkout.DataSource    = wList;
        }
コード例 #2
0
        private void clbWPreferences_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.flowLayoutPanel1.Controls.Clear();

            var clb   = sender as CheckedListBox;
            var item  = clb.SelectedItem as ClbItem;
            var wList = wBll.GetWorkoutByWCAL(item.wcID);

            foreach (var w in wList)
            {
                Label lblWorkout = new Label();
                lblWorkout.Text   = w.Name;
                lblWorkout.Font   = new Font(lblWorkout.Font.Name, 16f);
                lblWorkout.Height = (int)(lblWorkout.Font.Size * 2.5);
                lblWorkout.Margin = new Padding(5);
                lblWorkout.Paint += LblWorkout_Paint;
                this.flowLayoutPanel1.Controls.Add(lblWorkout);
            }
        }
コード例 #3
0
        private async void LoadTableContentAsync(List <WorkoutCategoryDetailDTO> wcList, List <ActivityLevelDetailDTO> alList)
        {
            this.Parent.Parent.Parent.Parent.Enabled = false;

            List <Task> tasks = new List <Task>();
            Dictionary <String, List <string> > keywords = new Dictionary <String, List <string> >();

            foreach (var item in wBll.GetWorkoutByWCAL(-1, -1))
            {
                string kw = wBll.ToPlacesKeyword(item.Name);
                if (kw == null)
                {
                    kw = "";
                }
                if (keywords.ContainsKey(kw))
                {
                    keywords[kw].Add(item.Name);
                }
                else
                {
                    keywords.Add(kw, new List <string> {
                        item.Name
                    });
                    Task <PlacesNearbySearchResponse> task = wBll.GetWorkoutPlaces(kw, coord);
                    tasks.Add(task);
                }
            }

            while (tasks.Count > 0)
            {
                Task finishedTask = await Task.WhenAny(tasks);

                int index = tasks.IndexOf(finishedTask);

                List <String> places = keywords.ElementAt(index).Value;

                Task <PlacesNearbySearchResponse> task     = finishedTask as Task <PlacesNearbySearchResponse>;
                PlacesNearbySearchResponse        response = task.Result;
                if (response.Results.Count() > 0)
                {
                    for (int k = 0; k < places.Count; k++)
                    {
                        Workout w = wBll.GetWorkout(places[k]);

                        Label lbl = new Label();
                        lbl.Text   = places[k];
                        lbl.Font   = new Font(lbl.Font.Name, 12f);
                        lbl.Height = (int)(lbl.Font.Size * 2.5);
                        lbl.Margin = new Padding(2);
                        lbl.Paint += FrmAddWorkoutPreferences.LblWorkout_Paint;
                        lbl.Click += lblWorkout_Click;
                        int yIndex = wcList.IndexOf(wcList.SingleOrDefault(wc => wc.ID == w.WorkoutCategoryID));
                        int xIndex = alList.IndexOf(alList.SingleOrDefault(al => al.ID == w.ActivityLevelID));

                        panelList[yIndex][xIndex].Controls.Add(lbl);
                    }
                }

                keywords.Remove(keywords.ElementAt(index).Key);
                tasks.Remove(finishedTask);
            }

            MessageBox.Show("load success");
            this.Parent.Parent.Parent.Parent.Enabled = true;
        }