コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        private void ShowPoints(object clickedButton, RoutedEventArgs e)
        {
            Button b__ = (Button)clickedButton;


            // mcid(playername)を表示させる
            mcid.Text = b__.Content.ToString();

            var playerdata = DictionaryManager.getDictionary();

            int scpoint = playerdata[b__.Content.ToString()].getSc_();
            int cppoint = playerdata[b__.Content.ToString()].getContribution_();

            string convertedSCPoint = ConvertNumber(scpoint);
            string convertedCPPoint = ConvertNumber(cppoint);


            // UIにポイントを表示させる
            SC.Text           = convertedSCPoint;
            Contribution.Text = convertedCPPoint;


            scpoint_copy           = scpoint;
            contributionpoint_copy = cppoint;
        }
コード例 #2
0
ファイル: PlayerData.xaml.cs プロジェクト: sota70/Sukka
        // DataGridにデータを追加するメソッド
        public static List <Customer> Customers()
        {
            MainPage mainPage = MainPage.returnInstance();

            var unsortedList = new List <Customer>();

            foreach (Button buttonsInNameList in mainPage.getAllButtonFromNameList())
            {
                var playerdataDictionary = DictionaryManager.getDictionary();

                string playername = buttonsInNameList.Content.ToString();

                int    sc           = playerdataDictionary[playername].getSc_();
                int    contribution = playerdataDictionary[playername].getContribution_();
                string mcid         = playername;
                int    id           = playerdataDictionary[playername].getId_();

                var playerdata = new Customer(mcid, sc, contribution, id);

                unsortedList.Add(playerdata);
            }

            // DataGridのデータのコピーを取る
            customers = unsortedList;


            return(unsortedList);
        }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        private async void InputMCIDDIalogAsync(string title)
        {
            TextBox inputTextBox = new TextBox
            {
                AcceptsReturn = false,
                Height        = 32,
            };


            ContentDialog dialog = new ContentDialog
            {
                Content = inputTextBox,
                Title   = title,
                IsSecondaryButtonEnabled = false,
                PrimaryButtonText        = "OK",
                CloseButtonText          = "Cancel"
            };

            var result = await dialog.ShowAsync();

            var OK = ContentDialogResult.Primary;

            if (result == OK)
            {
                if (inputTextBox.Text == null)
                {
                    return;
                }


                ChangeStyle(mcid.Text, inputTextBox.Text);


                // データとmcidのテキストを入れ替える
                var playerdata = DictionaryManager.getDictionary();

                Points data = playerdata[mcid.Text];
                playerdata.Remove(mcid.Text);
                playerdata.Add(inputTextBox.Text, data);

                DictionaryManager.setPlayerData(mcid.Text, data);


                mcid.Text = inputTextBox.Text;


                if (EditOnce)
                {
                    return;
                }

                EditOnce = true;
            }
        }
コード例 #4
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        private void AddData(object sender, RoutedEventArgs e)
        {
            dataTotal += 1;

            buttonTotal += 1;


            Button NewButton = new Button()
            {
                Content             = "Sample" + buttonTotal,
                FontSize            = 60,
                FontFamily          = new FontFamily("Arial"),
                Background          = null,
                Width               = 465,
                Height              = 87,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            // ※補足 NewButton.Click += ShowPoints -> ボタンにクリックイベントを追加するやつ
            NewButton.Click += ShowPoints;


            NewButton.HorizontalAlignment = HorizontalAlignment.Center;


            RelativePanel.SetAlignHorizontalCenterWith(NewButton, sender);


            Button addbutton = Add;


            NameList.Children.Remove(Add);

            NameList.Children.Add(NewButton);

            NameList.Children.Add(addbutton);


            Points playerData = new Points(1, 1, dataTotal);

            string playername = NewButton.Content.ToString();

            DictionaryManager.setPlayerData(playername, playerData);


            if (EditOnce == false)
            {
                EditOnce = true;
            }
        }
コード例 #5
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        private async void ChangeSC(object sender, DoubleTappedRoutedEventArgs e)
        {
            string orderedPoints = await InputPointsDialogAsync("Change SC");


            // ※補足 int.TryParse(orderedPoints, out d)) -> 取得した数字を元の数字に足して再表示する
            int d;

            if (int.TryParse(orderedPoints, out d))
            {
                if (isPlus)
                {
                    int totalpoints = scpoint_copy + d;
                    SC.Text = ConvertNumber(totalpoints);

                    var playerdata = DictionaryManager.getDictionary();

                    playerdata[mcid.Text].setSc_(totalpoints);
                    scpoint_copy = totalpoints;


                    if (EditOnce == false)
                    {
                        EditOnce = true;
                    }
                }
                else
                {
                    var playerdata = DictionaryManager.getDictionary();

                    int totalpoints = scpoint_copy - d;
                    SC.Text = ConvertNumber(totalpoints);


                    playerdata[mcid.Text].setSc_(totalpoints);
                    scpoint_copy = totalpoints;


                    if (EditOnce == false)
                    {
                        EditOnce = true;
                    }
                }
            }
        }
コード例 #6
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        private async void ChangeContribution(object sender, DoubleTappedRoutedEventArgs e)
        {
            string orderedPoints = await InputPointsDialogAsync("Change Contribution");


            // ※補足 int.TryParse(orderedPoints, out d)) -> string型からint型へ変換する
            int d;

            if (int.TryParse(orderedPoints, out d))
            {
                var playerdata = DictionaryManager.getDictionary();

                if (isPlus)
                {
                    int totalpoints = contributionpoint_copy + d;
                    Contribution.Text = ConvertNumber(totalpoints);


                    playerdata[mcid.Text].setContribution_(totalpoints);
                    contributionpoint_copy = totalpoints;


                    if (EditOnce == false)
                    {
                        EditOnce = true;
                    }
                }
                else
                {
                    int totalpoints = contributionpoint_copy - d;
                    Contribution.Text = ConvertNumber(totalpoints);


                    playerdata[mcid.Text].setContribution_(totalpoints);
                    contributionpoint_copy = totalpoints;


                    if (EditOnce == false)
                    {
                        EditOnce = true;
                    }
                }
            }
        }
コード例 #7
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        public MainPage()
        {
            this.InitializeComponent();


            Points sample__ = new Points(0, 0, 0);

            DictionaryManager.setPlayerData("Sample", sample__);

            buttonTotal += 1;


            DatabaseInit();


            LoadPlayerData();

            createTestSampleWindow();


            instance = this;
        }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        // 他のクラスでも使うためにメソッドとして作った
        public void saveAllData()
        {
            foreach (Button button in getAllButtonFromNameList())
            {
                string playername = button.Content.ToString();


                // 元からUIに存在するボタンを除くために作った
                if (playername.Equals("Add"))
                {
                    return;
                }


                var playerdata = DictionaryManager.getDictionary();

                int sc           = playerdata[playername].getSc_();
                int contribution = playerdata[playername].getContribution_();
                int id           = playerdata[playername].getId_();


                TCreatePlayerData(playername, sc, contribution, id);
            }
        }
コード例 #9
0
ファイル: MainPage.xaml.cs プロジェクト: sota70/Sukka
        private void LoadPlayerData()
        {
            ApplicationDataContainer database = ApplicationData.Current.LocalSettings;

            var playerContainer = database.Containers["key"];


            // ※補足 foreach (string mcid in sortList()) -> データの中にある全てのMCIDを取得する
            foreach (string mcid in sortList())
            {
                // なぜかデータからnullデータが出てしまうため、回避策としてreturnで返している
                if (mcid == null)
                {
                    return;
                }

                bool mcidCondition = !mcid.Equals("Sample") && !mcid.Equals("Add");

                if (mcidCondition)
                {
                    try
                    {
                        Button button = new Button
                        {
                            Content = mcid,

                            FontSize   = 60,
                            FontFamily = new FontFamily("Arial"),

                            Background = null,

                            Width  = 465,
                            Height = 87,

                            HorizontalAlignment = HorizontalAlignment.Center
                        };


                        // ※補足 button.Click += ShowPoints -> ボタンにクリックイベントを追加
                        button.Click += ShowPoints;


                        dataTotal = countKeys() - 1;

                        buttonTotal = countKeys();


                        Button addbutton = Add;


                        // 一度Addボタンを付けなおして位置を直す
                        NameList.Children.Remove(Add);

                        NameList.Children.Add(button);

                        NameList.Children.Add(addbutton);


                        RelativePanel.SetAlignHorizontalCenterWith(button, addbutton);


                        ApplicationDataCompositeValue playerdatafromdatabase = getPlayerData(mcid);

                        int scpoint           = (int)playerdatafromdatabase["SC"];
                        int contributionpoint = (int)playerdatafromdatabase["Contribution"];
                        int id = (int)playerdatafromdatabase["ID"];

                        Points data = new Points(scpoint, contributionpoint, id);

                        DictionaryManager.setPlayerData(button.Content.ToString(), data);
                    }
                    catch (Exception e)
                    {
                        return;
                    }
                }
            }
        }