示例#1
0
        void OnChangeDefaultGroupClicked(object sender, RoutedEventArgs e)
        {
            frmSelectCardGroup f = new frmSelectCardGroup();

            f.ShowDialog();
            if (f.IsCanceled == true)
            {
                return;
            }
            Globals.SetDefaultGroup(f.SelectedGroupPath);
            if (sender is CtrlExtButton)
            {
                CtrlExtButton btn          = (CtrlExtButton)sender;
                string        def_grp_name = Globals.GetDefaultGroupName();
                btn.Title = string.Format("Default Group: [{0}]", def_grp_name);
            }
        }
        public void Init()
        {
            ctrlQuestion.BgColor = new SolidColorBrush(Color.FromRgb(195, 210, 230));
            ctrlAnswer.BgColor   = new SolidColorBrush(Color.FromRgb(170, 250, 175));
            ctrlReminder.BgColor = new SolidColorBrush(Color.FromRgb(225, 195, 220));

            string GroupName = Globals.GetDefaultGroupName();

            lblDefaultCardGroupName.Content = string.Format("Group: {0}", GroupName);


            // Creates a temporary folder and its necessary files and folders for a card.
            // If user decides to save the card, the folder will be persistent. Else the themporary
            // folder will be removed.
            // Note: manifest file is created here.
            CardFolder = Globals.CreateNewCard(GroupName);

            ctrlQuestion.CardRootFolder = CardFolder;
            ctrlQuestion.WorkingFolder  = Globals.CreateFolder(CardFolder + "Q\\");
            ctrlAnswer.WorkingFolder    = Globals.CreateFolder(CardFolder + "A\\");
            ctrlAnswer.CardRootFolder   = CardFolder;
            ctrlReminder.WorkingFolder  = Globals.CreateFolder(CardFolder + "R\\");
            ctrlReminder.CardRootFolder = CardFolder;
        }
示例#3
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);
                    }
                }
            }
        }