Beispiel #1
0
        public static void WriteFile(Dota2Player Dota2Player, string NameFile)
        {
            string AllFile = ReadAllTextFile(NameFile);

            string[] SplitOnDiscypline = AllFile.Split('@');
            SplitOnDiscypline[0] += Dota2Player.AllInfoForWriteInFile();
            using (StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + @"\textfiles\" + NameFile, false))
            {
                sw.Write(SplitOnDiscypline[0]);
                sw.Write("\r\n@");
                sw.Write(SplitOnDiscypline[1]);
            }
        }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            comboBoxPentagon1.Visible = false;
            comboBoxPentagon2.Visible = false;
            comboBoxPentagon3.Visible = false;
            comboBoxPentagon4.Visible = false;
            comboBoxPentagon5.Visible = false;

            labelPentagon.Visible = true;

            PictureBoxSignature1.Visible = true;
            PictureBoxSignature2.Visible = true;
            PictureBoxSignature3.Visible = true;

            dateTimeDateBirth.Visible = false;
            comboBoxEditHero1.Visible = false;
            comboBoxEditHero2.Visible = false;
            comboBoxEditHero3.Visible = false;

            TextBoxEditName.Visible     = false;
            TextBoxEditSurname.Visible  = false;
            TextBoxEditNickname.Visible = false;
            TextBoxEditTeam.Visible     = false;
            TextBoxEditCity.Visible     = false;
            TextBoxEditCountry.Visible  = false;
            //TextBoxEditCity.Visible = false;
            //TextBoxEditAge.Visible = false;
            TextBoxEditRole.Visible        = false;
            TextBoxEditNumberGames.Visible = false;
            TextBoxEditProcentWin.Visible  = false;
            TextBoxEditMMR.Visible         = false;

            buttonSave.Visible             = false;
            buttonEditPhotoPrifile.Visible = false;

            if (GlobalVariables.SelectedDiscypline == "Dota2")
            {
                Dota2Player tempPlayer   = new Dota2Player(GlobalVariables.MyProfileDota2);
                string      tempName     = String.Copy(tempPlayer.Name);
                string      tempNickname = String.Copy(tempPlayer.Nickname);
                string      tempSurname  = String.Copy(tempPlayer.Surname);

                string tempTeam        = String.Copy(tempPlayer.Team);
                string tempCountry     = String.Copy(tempPlayer.Country);
                string tempCity        = String.Copy(tempPlayer.City);
                string tempNationality = tempCountry;
                string tempDateBirth   = ((tempPlayer.DateBirth.Day < 10) ? ("0" + tempPlayer.DateBirth.Day) : (Convert.ToString(tempPlayer.DateBirth.Day))) + "." + ((tempPlayer.DateBirth.Month < 10) ? ("0" + tempPlayer.DateBirth.Month) : (Convert.ToString(tempPlayer.DateBirth.Month))) + "." + tempPlayer.DateBirth.Year;
                //string tempAge = Convert.ToString(tempPlayer.Age);
                string   tempRole         = String.Copy(tempPlayer.Role);
                string[] tempSignature    = tempPlayer.Signature;
                string   tempNumberGames  = Convert.ToString(tempPlayer.NumberGames);
                string   tempProcentWin   = Convert.ToString(tempPlayer.ProcentWinGames);
                string   tempMMR          = String.Copy(tempPlayer.MMR);
                int[]    tempPentagon     = tempPlayer.Pentagon;
                string   tempPhotoProfile = tempPlayer.PhotoProfile;
                bool     tempEdit         = true;
                string   TempOldNickname  = "";

                if (TextBoxEditName.Text != "")
                {
                    tempName = TextBoxEditName.Text;
                }
                if (TextBoxEditSurname.Text != "")
                {
                    tempSurname = TextBoxEditSurname.Text;
                }
                if (TextBoxEditNickname.Text != "")
                {
                    TempOldNickname = string.Copy(tempNickname);
                    tempNickname    = TextBoxEditNickname.Text;
                }
                if (TextBoxEditTeam.Text != "")
                {
                    tempTeam = TextBoxEditTeam.Text;
                }
                if (TextBoxEditCity.Text != "")
                {
                    tempCity = TextBoxEditCity.Text;
                }
                if (TextBoxEditCountry.Text != "")
                {
                    tempCountry = TextBoxEditCountry.Text;
                }
                if (((dateTimeDateBirth.Value.Day < 10) ? ("0" + dateTimeDateBirth.Value.Day) : (Convert.ToString(dateTimeDateBirth.Value.Day))) + "." + ((dateTimeDateBirth.Value.Month < 10) ? ("0" + dateTimeDateBirth.Value.Month) : (Convert.ToString(dateTimeDateBirth.Value.Month))) + "." + dateTimeDateBirth.Value.Year != "01.01.1900")
                {
                    tempDateBirth = ((dateTimeDateBirth.Value.Day < 10) ? ("0" + dateTimeDateBirth.Value.Day) : (Convert.ToString(dateTimeDateBirth.Value.Day))) + "." + ((dateTimeDateBirth.Value.Month < 10) ? ("0" + dateTimeDateBirth.Value.Month) : (Convert.ToString(dateTimeDateBirth.Value.Month))) + "." + dateTimeDateBirth.Value.Year;
                }
                if (TextBoxEditRole.Text != "")
                {
                    tempRole = TextBoxEditRole.Text;
                }

                if (comboBoxEditHero1.Text != "All")
                {
                    tempSignature[0] = comboBoxEditHero1.Text;
                }
                if (comboBoxEditHero2.Text != "All")
                {
                    tempSignature[1] = comboBoxEditHero2.Text;
                }
                if (comboBoxEditHero3.Text != "All")
                {
                    tempSignature[2] = comboBoxEditHero3.Text;
                }

                if (TextBoxEditNumberGames.Text != "")
                {
                    tempNumberGames = TextBoxEditNumberGames.Text;
                }
                if (TextBoxEditProcentWin.Text != "")
                {
                    tempProcentWin = TextBoxEditProcentWin.Text;
                }
                if (TextBoxEditMMR.Text != "")
                {
                    tempMMR = TextBoxEditMMR.Text;
                }
                if (openFileDialogEditPhotoProfile.FileName != "")
                {
                    tempPhotoProfile = tempNickname + ".png";
                }

                if (comboBoxPentagon1.SelectedItem != null)
                {
                    tempPentagon[0] = (int)comboBoxPentagon1.SelectedItem;
                }
                if (comboBoxPentagon2.SelectedItem != null)
                {
                    tempPentagon[1] = (int)comboBoxPentagon2.SelectedItem;
                }
                if (comboBoxPentagon3.SelectedItem != null)
                {
                    tempPentagon[2] = (int)comboBoxPentagon3.SelectedItem;
                }
                if (comboBoxPentagon4.SelectedItem != null)
                {
                    tempPentagon[3] = (int)comboBoxPentagon4.SelectedItem;
                }
                if (comboBoxPentagon5.SelectedItem != null)
                {
                    tempPentagon[4] = (int)comboBoxPentagon5.SelectedItem;
                }
                buttonSave.Visible = false;

                if (TempOldNickname != "")
                {
                    File.Copy(Environment.CurrentDirectory + @"\image\photoProfiles\" + TempOldNickname + ".png", Environment.CurrentDirectory + @"\image\photoProfiles\" + tempNickname + ".png");
                    File.Delete(Environment.CurrentDirectory + @"\image\photoProfiles\" + TempOldNickname + ".png");
                }
                //MyProfiles[0] = new Dota2Player(new object[] { Dota2Name, Dota2Nickname, Dota2Surname, Dota2Team, Dota2Country, Dota2City, Dota2Nationality, Dota2DateBirth, Dota2Role, Dota2Signature, Dota2NumberGames, Dota2ProcentWinGames, Dota2MMR, Dota2Pentagon, Dota2PhotoProfile });

                GlobalVariables.MyProfileDota2 = new Dota2Player(new object[] { tempName, tempNickname, tempSurname, tempTeam, tempCountry, tempCity, tempNationality, tempDateBirth, tempRole, tempSignature, tempNumberGames, tempProcentWin, tempMMR, tempPentagon, tempPhotoProfile, tempEdit });

                MethodsWorkWithFile.EditFile(tempPlayer, GlobalVariables.MyProfileDota2, "MyProfile.txt");

                GlobalVariables.ListPlayerInDiscypline = MethodsWorkWithFile.CreateListPlayer("ListPlayer.txt");

                MethodsWorkWithFile.CreateLists(GlobalVariables.ListPlayerInDiscypline);

                Player[] MyProfiles = MethodsWorkWithFile.ReadMyProfile();
                GlobalVariables.MyProfileDota2 = (Dota2Player)MyProfiles[0];
                GlobalVariables.MyProfileCSGO  = (CSGOPlayer)MyProfiles[1];

                GlobalVariables.ListPlayerInDiscypline[0].Add(GlobalVariables.PlayerDota2Clear);
                GlobalVariables.ListPlayerInDiscypline[0].Add(GlobalVariables.MyProfileDota2);
                GlobalVariables.ListPlayerInDiscypline[1].Add(GlobalVariables.PlayerCSGOClear);
                GlobalVariables.ListPlayerInDiscypline[1].Add(GlobalVariables.MyProfileCSGO);
                GlobalVariables.ListPlayerInDiscyplineSearched = new List <List <Player> >(GlobalVariables.ListPlayerInDiscypline);

                MyProfile_Load(null, null);
            }
            else
            {
                CSGOPlayer tempPlayer = new CSGOPlayer(GlobalVariables.MyProfileCSGO);
            }
            //MethodsWorkWithFile.EditFile(GlobalVariables.MyProfileDota2, GlobalVariables.MyProfileDota2);
        }
Beispiel #3
0
        public static Player[] ReadMyProfile()
        {
            Player[] MyProfiles   = new Player[2];
            string[] AllLinesFile = File.ReadAllLines(Environment.CurrentDirectory + @"\textfiles\MyProfile.txt");

            string Dota2Name        = AllLinesFile[2].Substring(9);
            string Dota2Nickname    = AllLinesFile[3].Substring(13);
            string Dota2Surname     = AllLinesFile[4].Substring(12);
            string Dota2Team        = AllLinesFile[5].Substring(9);
            string Dota2Country     = AllLinesFile[6].Substring(12);
            string Dota2City        = AllLinesFile[7].Substring(9);
            string Dota2Nationality = AllLinesFile[8].Substring(16);
            string Dota2DateBirth   = AllLinesFile[9].Substring(14);
            string Dota2Role        = AllLinesFile[10].Substring(9);

            string[] Dota2SignatureTemp = AllLinesFile[11].Substring(14).Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            Dota2SignatureTemp[0] = Dota2SignatureTemp[0].Substring(1);
            int templastIndex = Dota2SignatureTemp.Length - 1;

            Dota2SignatureTemp[templastIndex] = Dota2SignatureTemp[templastIndex].Substring(0, Dota2SignatureTemp[templastIndex].Length - 1);
            string[] Dota2Signature = Dota2SignatureTemp;

            string Dota2NumberGames     = AllLinesFile[12].Substring(16);
            string Dota2ProcentWinGames = AllLinesFile[13].Substring(20);
            string Dota2MMR             = AllLinesFile[14].Substring(8);

            string[] Dota2PentagonTemp = AllLinesFile[15].Substring(13).Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            Dota2PentagonTemp[0]             = Dota2PentagonTemp[0].Substring(1);
            templastIndex                    = Dota2PentagonTemp.Length - 1;
            Dota2PentagonTemp[templastIndex] = Dota2PentagonTemp[templastIndex].Substring(0, Dota2PentagonTemp[templastIndex].Length - 1);
            int[] tempIntArray = new int[Dota2PentagonTemp.Length];
            int   j            = 0;

            foreach (string element in Dota2PentagonTemp)
            {
                tempIntArray[j] = Convert.ToInt32(element);
                j++;
            }
            int[] Dota2Pentagon = tempIntArray;

            string Dota2PhotoProfile = AllLinesFile[16].Substring(17);
            string Dota2Edit         = AllLinesFile[17].Substring(9);

            MyProfiles[0] = new Dota2Player(new object[] { Dota2Name, Dota2Nickname, Dota2Surname, Dota2Team, Dota2Country, Dota2City, Dota2Nationality, Dota2DateBirth, Dota2Role, Dota2Signature, Dota2NumberGames, Dota2ProcentWinGames, Dota2MMR, Dota2Pentagon, Dota2PhotoProfile, Dota2Edit });

            string CSGOName        = AllLinesFile[21].Substring(9);
            string CSGONickname    = AllLinesFile[22].Substring(13);
            string CSGOSurname     = AllLinesFile[23].Substring(12);
            string CSGOTeam        = AllLinesFile[24].Substring(9);
            string CSGOCountry     = AllLinesFile[25].Substring(12);
            string CSGOCity        = AllLinesFile[26].Substring(9);
            string CSGONationality = AllLinesFile[27].Substring(16);
            string CSGODateBirth   = AllLinesFile[28].Substring(14);
            string CSGORole        = AllLinesFile[29].Substring(9);

            string[] CSGOSignatureTemp = AllLinesFile[30].Substring(14).Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            CSGOSignatureTemp[0]             = CSGOSignatureTemp[0].Substring(1);
            templastIndex                    = CSGOSignatureTemp.Length - 1;
            CSGOSignatureTemp[templastIndex] = CSGOSignatureTemp[templastIndex].Substring(0, CSGOSignatureTemp[templastIndex].Length - 1);
            string[] CSGOSignature = CSGOSignatureTemp;

            string CSGONumberGames     = AllLinesFile[31].Substring(16);
            string CSGOProcentWinGames = AllLinesFile[32].Substring(20);
            string CSGOMMR             = AllLinesFile[33].Substring(8);

            string[] CSGOPentagonTemp = AllLinesFile[34].Substring(13).Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
            CSGOPentagonTemp[0]             = CSGOPentagonTemp[0].Substring(1);
            templastIndex                   = CSGOPentagonTemp.Length - 1;
            CSGOPentagonTemp[templastIndex] = CSGOPentagonTemp[templastIndex].Substring(0, CSGOPentagonTemp[templastIndex].Length - 1);
            tempIntArray = new int[CSGOPentagonTemp.Length];
            j            = 0;
            foreach (string element in CSGOPentagonTemp)
            {
                tempIntArray[j] = Convert.ToInt32(element);
                j++;
            }
            int[] CSGOPentagon = tempIntArray;

            string CSGOPhotoProfile = AllLinesFile[35].Substring(17);
            string CSGOEdit         = AllLinesFile[36].Substring(9);

            MyProfiles[1] = new CSGOPlayer(new object[] { CSGOName, CSGONickname, CSGOSurname, CSGOTeam, CSGOCountry, CSGOCity, CSGONationality, CSGODateBirth, CSGORole, CSGOSignature, CSGONumberGames, CSGOProcentWinGames, CSGOMMR, CSGOPentagon, CSGOPhotoProfile, CSGOEdit });


            return(MyProfiles);
        }
Beispiel #4
0
 public static void EditFile(Dota2Player PlayerOld, Dota2Player PlayerNew, string NameFile)
 {
     RemovePlayerInFile(PlayerOld, NameFile);
     WriteFile(PlayerNew, NameFile);
 }
Beispiel #5
0
        public static Player CreateObjectPlayer(string[] LinesFile, int IndexStart, int IndexEnd, string discypline)
        {
            string[] NameField = new string[]
            {
                "Name",
                "Nickname",
                "Surname",
                "Team",
                "Country",
                "City",
                "Nationality",
                "DateBirth",
                "Role",
                "Signature",
                "NumberGames",
                "ProcentWinGames",
                "MMR",
                "Pentagon",
                "PhotoProfile",
                "Edit",
            };
            object[] ValueFild = new object[NameField.Length];
            string   tempString;

            string[] tempStringArray;
            int[]    tempIntArray;
            int      templastIndex;
            int      tempIndexNameField = 0;

            for (int i = IndexStart; i < IndexEnd; i++)
            {
                switch (NameField[tempIndexNameField])
                {
                case "Signature":
                    tempString = LinesFile[i].Substring(LinesFile[i].IndexOf(NameField[tempIndexNameField]) + NameField[tempIndexNameField].Length + 3);
                    if (tempString == "" || tempString[0] != '[' || tempString[tempString.Length - 1] != ']')
                    {
                        return((Player)GlobalVariables.MessageErrorData());
                    }
                    tempStringArray = tempString.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                    try
                    {
                        tempStringArray[0] = tempStringArray[0].Substring(1);
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        return((Player)GlobalVariables.MessageErrorData());
                    }
                    templastIndex = tempStringArray.Length - 1;
                    tempStringArray[templastIndex] = tempStringArray[templastIndex].Substring(0, tempStringArray[templastIndex].Length - 1);
                    ValueFild[tempIndexNameField]  = tempStringArray;
                    break;

                case "Pentagon":
                    tempString                     = LinesFile[i].Substring(LinesFile[i].IndexOf(NameField[tempIndexNameField]) + NameField[tempIndexNameField].Length + 3);
                    tempStringArray                = tempString.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                    tempStringArray[0]             = tempStringArray[0].Substring(1);
                    templastIndex                  = tempStringArray.Length - 1;
                    tempStringArray[templastIndex] = tempStringArray[templastIndex].Substring(0, tempStringArray[templastIndex].Length - 1);
                    tempIntArray                   = new int[tempStringArray.Length];
                    int j = 0;
                    foreach (string element in tempStringArray)
                    {
                        tempIntArray[j] = Convert.ToInt32(element);
                        j++;
                    }
                    ValueFild[tempIndexNameField] = tempIntArray;
                    break;

                default:
                    ValueFild[tempIndexNameField] = LinesFile[i].Substring(LinesFile[i].IndexOf(NameField[tempIndexNameField]) + NameField[tempIndexNameField].Length + 3);
                    break;
                }
                tempIndexNameField++;
            }
            Player tempPlayer;

            if (discypline == "Dota2")
            {
                tempPlayer = new Dota2Player(ValueFild);
            }
            else
            {
                tempPlayer = new CSGOPlayer(ValueFild);
            }

            return(tempPlayer);
        }