コード例 #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);
            }
        }
コード例 #2
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);
                    }
                }
            }
        }
コード例 #3
0
        private int AddExtButton(Grid GridContainer, int ColIndex, string Title, string Detail, string Uri, RoutedEventHandler OnClickEventHandler, object Tag, out CtrlExtButton Button)
        {
            var rd = new RowDefinition();

            rd.Height = GridLength.Auto;
            int grid_row_index = GridContainer.RowDefinitions.Count;

            GridContainer.RowDefinitions.Add(rd);

            CtrlExtButton btn = new CtrlExtButton();

            btn.Title  = Title;
            btn.Detail = Detail;
            Image       img        = new Image();
            BitmapImage img_bitmap = new BitmapImage();

            img_bitmap.BeginInit();
            img_bitmap.UriSource = new Uri(Uri);
            img_bitmap.EndInit();
            img.Source       = img_bitmap;
            btn.Image_Source = img_bitmap;
            btn.SetValue(Grid.ColumnProperty, ColIndex);
            btn.SetValue(Grid.RowProperty, grid_row_index);
            btn.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            btn.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            GridContainer.Children.Add(btn);
            btn.Tag = Tag;
            btn.OnExtButtonClicked += OnClickEventHandler;
            Button = btn;
            return(grid_row_index);
        }