Exemplo n.º 1
0
        private void BoxDefActivity_ButtonClick(object sender, EventArgs e)
        {
            TreeListPopup treeListPopup = new TreeListPopup();

            treeListPopup.ThemeChanged(m_visualTheme);
            treeListPopup.Tree.Columns.Add(new TreeList.Column());

            IList <object> acts = new List <object> {
                TrailsPlugin.Properties.Resources.UI_EditList_AutomaticRefActivity
            };                                                                                                          //TBD: How to handle null activity?

            System.Collections.IList currSel = new object[1] {
                acts[0]
            };
            foreach (IActivity act in TrailResultWrapper.Activities(TrailsPlugin.Controller.TrailController.Instance.Results))
            {
                acts.Add(act);
                if (act != null && act == this.Trail.DefaultRefActivity)
                {
                    currSel[0] = (IActivity)act;
                }
            }

            treeListPopup.Tree.RowData = acts;
#if ST_2_1
            treeListPopup.Tree.Selected = currSel;
#else
            treeListPopup.Tree.SelectedItems = currSel;
#endif
            treeListPopup.Tree.LabelProvider = new ActivityDropdownLabelProvider();
            treeListPopup.ItemSelected      += new TreeListPopup.ItemSelectedEventHandler(BoxDefActivity_ItemSelected);
            treeListPopup.Popup(this.boxDefActivity.Parent.RectangleToScreen(this.boxDefActivity.Bounds));
        }
Exemplo n.º 2
0
        private void btnTypeOpen_Click(object sender, EventArgs e)
        {
            // Create TreeListPopup
            popup = new TreeListPopup();
            popup.ThemeChanged(PluginMain.GetApplication().VisualTheme);
            size = false; // Indicate this popup is for the type (not the size) control
            popup.Tree.Columns.Clear();
            popup.Tree.Columns.Add(new TreeList.Column());
            popup.Tree.RowData  = types;
            popup.ItemSelected += new TreeListPopup.ItemSelectedEventHandler(popup_ItemSelected);
            Rectangle rect = new Rectangle(txtType.Location, txtType.Size);

            rect.Offset(this.Location);
            rect.Offset(4, txtType.Height + 4);
            popup.Popup(rect);
        }
Exemplo n.º 3
0
        public static void OpenListPopup <T>(ITheme theme, IList <T> items, System.Windows.Forms.Control control, T selected, ItemSelectHandler <T> selectHandler)
        {
            TreeListPopup popup = new TreeListPopup();

            popup.ThemeChanged(theme);
            popup.Tree.Columns.Add(new TreeList.Column());
            popup.Tree.RowData = items;
            if (selected != null)
            {
                popup.Tree.Selected = new object[] { selected };
            }
            popup.ItemSelected += delegate(object sender, TreeListPopup.ItemSelectedEventArgs e)
            {
                if (e.Item is T)
                {
                    selectHandler((T)e.Item);
                }
            };
            popup.Popup(control.Parent.RectangleToScreen(control.Bounds));
        }
        internal static bool boxCategory_ButtonClickedCommon(System.Windows.Forms.Label categoryLabel,
            ZoneFiveSoftware.Common.Visuals.TextBox boxCategory, 
            int noOfSelectedActivities, ITheme visualTheme)
        {
            TreeListPopup treeListPopup = new TreeListPopup();
            treeListPopup.ThemeChanged(visualTheme);
            treeListPopup.Tree.Columns.Add(new TreeList.Column());

            IList<object> list = new List<object>();
            list.Add(Util.StringResources.UseAllCategories);
            foreach (IActivityCategory category in Plugin.GetApplication().Logbook.ActivityCategories)
            {
                list.Add(category);
            }

            treeListPopup.Tree.RowData = list;
            treeListPopup.Tree.ContentProvider = new ActivityCategoryContentProvider(list);
            treeListPopup.Tree.ShowPlusMinus = true;
            treeListPopup.FitContent = false;

            if (Settings.SelectedCategory != null)
            {
                treeListPopup.Tree.Selected = new object[] { Settings.SelectedCategory };
            }
            //Expand by default
            System.Collections.IList parentCategories = new System.Collections.ArrayList();
            foreach (IActivityCategory category in Plugin.GetApplication().Logbook.ActivityCategories)
            {
                addNode(category, parentCategories);
            }
            treeListPopup.Tree.Expanded = parentCategories;

            bool result = false;
            treeListPopup.ItemSelected += delegate(object sender2, TreeListPopup.ItemSelectedEventArgs e2)
            {
                if (e2.Item is IActivityCategory)
                {
                    Settings.SelectedCategory = (IActivityCategory)e2.Item;
                }
                else
                {
                    Settings.SelectedCategory = null;
                }
                setCategoryLabel(categoryLabel, boxCategory, noOfSelectedActivities);
                result = true;
            };
            treeListPopup.Popup(boxCategory.Parent.RectangleToScreen(boxCategory.Bounds));
            return result;
        }
        private void modelComboBox_ButtonClicked(object sender, EventArgs e)
        {
            TreeListPopup treeListPopup = new TreeListPopup();
            treeListPopup.ThemeChanged(m_visualTheme);
            treeListPopup.Tree.Columns.Add(new TreeList.Column());

            treeListPopup.Tree.RowData = PredictionModelUtil.List;
            treeListPopup.Tree.LabelProvider = new PredictionModelLabelProvider();

            if (PredictionModelUtil.List.Contains(Settings.Model))
            {
                treeListPopup.Tree.Selected = new object[] { Settings.Model };
            }
            treeListPopup.ItemSelected += delegate(object sender2, TreeListPopup.ItemSelectedEventArgs e2)
            {
                try
                {
                    Settings.Model = ((PredictionModel)(e2).Item);
                    modelComboBox.Text = PredictionModelUtil.Name(Settings.Model);
                    predict_Click(Settings.Model);
                }
                catch (KeyNotFoundException)
                {
                    //MessageDialog.Show("Settings (position group) for Matrix was changed, please redo your actions");
                }
            };
            treeListPopup.Popup(this.modelComboBox.Parent.RectangleToScreen(this.modelComboBox.Bounds));
        }