Exemple #1
0
        protected override Control GetEditControl(string PropertyName, object CurrentValue, object instance)
        {
            TrainingPlanHtmlExporter exporter = (TrainingPlanHtmlExporter)instance;

            string[] days = new string[0];
            if (CurrentValue != null)
            {
                days = CurrentValue.ToString().Split(TrainingPlanHtmlExporter.DaysSeparator);
            }
            myListBox.BorderStyle        = BorderStyles.NoBorder;
            myListBox.HotTrackItems      = true;
            myListBox.HotTrackSelectMode = HotTrackSelectMode.SelectItemOnClick;
            //Creating ListBox items...
            //Note that as this is executed in design mode, performance is not important and there is no need to cache these items if they can change each time.
            myListBox.Items.Clear();

            foreach (var trainingPlanDay in exporter.TrainingPlan.Days)
            {
                CheckedListBoxItem item = new CheckedListBoxItem(trainingPlanDay);
                item.CheckState  = Array.IndexOf(days, trainingPlanDay.GlobalId.ToString()) > -1 ? CheckState.Checked : CheckState.Unchecked;
                item.Description = trainingPlanDay.Name;

                myListBox.Items.Add(item);
            }

            //myListBox.SelectedIndex = myListBox.FindString(CurrentValue.ToString());
            //Select current item based on CurrentValue of the property
            //myListBox.Height = myListBox.PreferredHeight;
            return(myListBox);
        }
        public static void Open(this WorkoutPlanDTO plan)
        {
            if (plan == null)
            {
                return;
            }
            HtmlPreviewWindow wnd = new HtmlPreviewWindow();

            using (TrainingPlanHtmlExporter htmlExporter = new TrainingPlanHtmlExporter(plan.ToTrainingPlan()))
            {
                wnd.Fill(htmlExporter);
                wnd.ShowDialog();
            }
            //var plan = ServiceManager.GetTrainingPlan(TrainingPlan);
        }