Example #1
0
        private void Init()
        {
            this.AddExtButton(
                grdContent,
                0,  /*Col Index*/
                "New Card",
                "Add a new Card",
                "pack://application:,,,/pic/plus_64.png",
                OnNewCardClicked,
                null,/*Tag*/
                out btnNewCard);

            this.AddExtButton(
                grdContent,
                0,  /*Col Index*/
                "Search",
                "Search & Filter",
                "pack://application:,,,/pic/search_64.png",
                OnSearchClicked,
                null,/*Tag*/
                out btnSearch
                );

            string def_grp_name = Globals.GetDefaultGroupName();

            this.AddExtButton(
                grdContent,
                0,      /*Col Index*/
                string.Format("Default Group: [{0}]", def_grp_name),
                "Press to change the default group.",
                "pack://application:,,,/pic/group_64.png",
                OnChangeDefaultGroupClicked,
                null,    /*Tag*/
                out btnDefaultGroup);

            if (this.Face == Faces.ShowMissedCards)
            {
                int cnt = Globals.GetNumberOfMissedCards();
                this.AddExtButton(
                    grdContent,
                    0,      /*Col Index*/
                    string.Format("Missed: [{0}]", cnt),
                    "Total Missed cards",
                    "pack://application:,,,/pic/missed_64.png",
                    OnShowMissedCardsClicked,
                    "[ALL]",
                    out btnCards
                    );

                string[] groups = Globals.GetPathOfEachGroup();
                if (groups != null)
                {
                    foreach (string group_path in groups)
                    {
                        string group_name = Globals.GetLastPartOfDir(group_path);
                        cnt = Globals.GetNumberOfMissedCards(group_path);
                        if (cnt == 0)
                        {
                            continue;
                        }
                        CtrlExtButton btn_grp   = null;
                        int           row_index =
                            this.AddExtButton(
                                grdCards,
                                1, /*Col Index*/
                                string.Format("{0}: [{1}]", group_name, cnt),
                                string.Format("You have {0} cards avilable", cnt),
                                "pack://application:,,,/pic/group_128.png",
                                OnShowMissedCardsClicked,
                                group_path,
                                out btn_grp);
                        btnCardGroups.Add(btn_grp);

                        this.SetImageToGrid(
                            grdCards,
                            "pack://application:,,,/pic/down_right_100.png",
                            row_index,
                            0);
                    }
                }
            }
            else if (this.Face == Faces.ShowPendingCards)
            {
                int cnt = Globals.GetNumberOfPendingCards();
                this.AddExtButton(
                    grdContent,
                    0,      /*Col Index*/
                    string.Format("Pending: [{0}]", cnt),
                    "Total Pending cards",
                    "pack://application:,,,/pic/alarm_64.png",
                    OnShowPendingCardsClicked,
                    "[ALL]",
                    out btnCards
                    );

                string[] groups = Globals.GetPathOfEachGroup();
                if (groups != null)
                {
                    foreach (string group_path in groups)
                    {
                        string group_name = Globals.GetLastPartOfDir(group_path);
                        cnt = Globals.GetNumberOfPendingCards(group_path);
                        if (cnt == 0)
                        {
                            continue;
                        }
                        CtrlExtButton btn_grp   = null;
                        int           row_index =
                            this.AddExtButton(
                                grdCards,
                                1, /*Col Index*/
                                string.Format("{0}: [{1}]", group_name, cnt),
                                string.Format("You have {0} cards avilable", cnt),
                                "pack://application:,,,/pic/group_128.png",
                                OnShowPendingCardsClicked,
                                group_path,
                                out btn_grp);
                        btnCardGroups.Add(btn_grp);

                        this.SetImageToGrid(
                            grdCards,
                            "pack://application:,,,/pic/down_right_100.png",
                            row_index,
                            0);
                    }
                }
            }

            else if (this.Face == Faces.ShowAllCards)
            {
                int cnt = Globals.GetNumberOfAllCards();
                this.AddExtButton(
                    grdContent,
                    0,      /*Col Index*/
                    string.Format("All: [{0}]", cnt),
                    "Total cards",
                    "pack://application:,,,/pic/star_128.png",
                    OnShowAllCardsClicked,
                    "[ALL]",
                    out btnCards
                    );

                string[] groups = Globals.GetPathOfEachGroup();
                if (groups != null)
                {
                    foreach (string group_path in groups)
                    {
                        string group_name = Globals.GetLastPartOfDir(group_path);
                        cnt = Globals.GetNumberOfCards(group_path);
                        if (cnt == 0)
                        {
                            continue;
                        }
                        CtrlExtButton btn_grp   = null;
                        int           row_index =
                            this.AddExtButton(
                                grdCards,
                                1, /*Col Index*/
                                string.Format("{0}: [{1}]", group_name, cnt),
                                string.Format("You have {0} cards avilable", cnt),
                                "pack://application:,,,/pic/group_128.png",
                                OnShowAllCardsClicked,
                                group_path,
                                out btn_grp);
                        btnCardGroups.Add(btn_grp);

                        this.SetImageToGrid(
                            grdCards,
                            "pack://application:,,,/pic/down_right_100.png",
                            row_index,
                            0);
                    }
                }
            }
        }