//サーバーに参加
        private async void Server_Connect_B_Click(object sender, RoutedEventArgs e)
        {
            if (IsClosing)
            {
                return;
            }
            if (Server_Lists.SelectedIndex == -1)
            {
                Message_Feed_Out("サーバーが選択されていません。");
                return;
            }
            try
            {
                string Directory_Name = Server_Names_List[Server_Lists.SelectedIndex] + "/Voices";
                if (Directory.Exists(Voice_Set.Special_Path + "/Server/" + Directory_Name) && Directory.GetFiles(Voice_Set.Special_Path + "/Server/" + Directory_Name).Length == 0)
                {
                    Directory.Delete(Voice_Set.Special_Path + "/Server/" + Directory_Name, true);
                }
                XDocument xml2  = XDocument.Load(Voice_Set.FTPClient.GetFileRead("/WoTB_Voice_Mod/Voice_Online/" + Server_Names_List[Server_Lists.SelectedIndex] + "/Server_Config.dat"));
                XElement  item2 = xml2.Element("Server_Create_Config");
                if (bool.Parse(item2.Element("IsEnablePassword").Value))
                {
                    if (Password_T.Text != item2.Element("Password").Value)
                    {
                        Message_Feed_Out("パスワードが違います。");
                        return;
                    }
                }
                Message_T.Text = "サーバーに参加しています...";
                await Task.Delay(50);

                Server_Voices.Voice_List.Clear();
                FtpWebRequest fwr = (FtpWebRequest)WebRequest.Create(new Uri("ftp://" + SRTTbacon_Server.IP + "/WoTB_Voice_Mod/Voice_Online/" + Directory_Name + "/"));
                fwr.UsePassive  = true;
                fwr.KeepAlive   = false;
                fwr.Credentials = new NetworkCredential(SRTTbacon_Server.Name, SRTTbacon_Server.Password);
                fwr.Method      = WebRequestMethods.Ftp.ListDirectory;
                StreamReader sr  = new StreamReader(fwr.GetResponse().GetResponseStream());
                string       str = sr.ReadLine();
                while (str != null)
                {
                    if (str != "")
                    {
                        Server_Voices.Voice_List.Add(str);
                    }
                    str = sr.ReadLine();
                }
                sr.Close();
                fwr.Abort();
                Voice_Set.SRTTbacon_Server_Name = Server_Names_List[Server_Lists.SelectedIndex];
                Directory.CreateDirectory(Voice_Set.Special_Path + "/Server/" + Directory_Name);
                Voice_Set.FTPClient.DownloadFile("/WoTB_Voice_Mod/Voice_Online/" + Directory_Name + "/" + Server_Voices.Voice_List[0], Voice_Set.Special_Path + "/Server/" + Directory_Name + "/" + Server_Voices.Voice_List[0]);
                string Chat_Temp = Server_File.Server_Open_File("/WoTB_Voice_Mod/Voice_Online/" + Voice_Set.SRTTbacon_Server_Name + "/Chat.dat");
                if (Voice_Set.UserName == item2.Element("Master_User_Name").Value)
                {
                    if (!Chat_Temp.Contains(Voice_Set.UserName + "(管理者)が参加しました。"))
                    {
                        Voice_Set.AppendString("/WoTB_Voice_Mod/Voice_Online/" + Voice_Set.SRTTbacon_Server_Name + "/Chat.dat", Voice_Set.UserName + "が参加しました。\n");
                    }
                }
                else
                {
                    if (!Chat_Temp.Contains(Voice_Set.UserName + "が参加しました。"))
                    {
                        Voice_Set.AppendString("/WoTB_Voice_Mod/Voice_Online/" + Voice_Set.SRTTbacon_Server_Name + "/Chat.dat", Voice_Set.UserName + "が参加しました。\n");
                    }
                }
                Voice_Set.TCP_Server.Send(Voice_Set.SRTTbacon_Server_Name + "|Chat");
                Visibility = Visibility.Hidden;
                Opacity    = 0;
            }
            catch (Exception e1)
            {
                Sub_Code.Error_Log_Write(e1.Message);
                Message_Feed_Out("エラーが発生しました。");
            }
        }
示例#2
0
        private async void Mod_Create_B_Click(object sender, RoutedEventArgs e)
        {
            if (IsBusy)
            {
                return;
            }
            if (Mod_File_List.Items.Count == 0)
            {
                Message_Feed_Out("最低1つはファイルが必要です。");
                return;
            }
            if (Mod_Create_Name_T.Text == "")
            {
                Message_Feed_Out("Mod名が指定されていません。");
                return;
            }
            try
            {
                Directory.CreateDirectory(Voice_Set.Special_Path + "/" + Mod_Create_Name_T.Text);
                Directory.Delete(Voice_Set.Special_Path + "/" + Mod_Create_Name_T.Text);
                if (Mod_Create_Name_T.Text.Contains("/"))
                {
                    Message_Feed_Out("Mod名に不適切な文字が含まれています。");
                    return;
                }
            }
            catch
            {
                Message_Feed_Out("Mod名に不適切な文字が含まれています。");
                return;
            }
            if (Mod_Create_Name_T.Text.CountOf("  ") > 0)
            {
                Message_Feed_Out("Mod名に空白を2つ続けて付けることはできません。");
                return;
            }
            if (Mod_Create_Name_T.Text == "Backup")
            {
                Message_Feed_Out("そのMod名は別の目的に使用されています。");
                return;
            }
            if (Voice_Set.FTPClient.Directory_Exist("/WoTB_Voice_Mod/Mods/" + Mod_Create_Name_T.Text))
            {
                Message_Feed_Out("同名のModが既に存在します。");
                return;
            }
            bool IsError = false;

            foreach (string File_Now in Mod_Name_Full)
            {
                if (!File.Exists(File_Now))
                {
                    IsError = true;
                    System.Windows.MessageBox.Show("次のファイルが見つかりませんでした。削除したか移動している可能性があります。\n" + File_Now);
                }
            }
            if (IsError)
            {
                Message_Feed_Out("エラー:指定されたファイルが存在しません。");
                return;
            }
            if (Mod_Explanation_T.Text == "")
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Modの説明が入力されていません。実行しますか?", "確認", MessageBoxButton.YesNo, MessageBoxImage.Exclamation, MessageBoxResult.No);
                if (result == MessageBoxResult.No)
                {
                    return;
                }
            }
            Message_T.Text = "";
            IsBusy         = true;
            try
            {
                Message_T.Text = "Modを公開しています...";
                await Task.Delay(50);

                //サーバーにフォルダを作成
                Voice_Set.FTPClient.Directory_Create("/WoTB_Voice_Mod/Mods/" + Mod_Create_Name_T.Text);
                Voice_Set.FTPClient.Directory_Create("/WoTB_Voice_Mod/Mods/" + Mod_Create_Name_T.Text + "/Files");
                //Modの情報をXMLファイルに書き込む
                XDocument xml   = new XDocument();
                XElement  datas = new XElement("Mod_Upload_Config",
                                               new XElement("IsBGMMode", BGM_Mode_C.IsChecked.Value),
                                               new XElement("IsPassword", Password_C.IsChecked.Value),
                                               new XElement("IsEnableR18", R_18_C.IsChecked.Value),
                                               new XElement("UserName", Voice_Set.UserName),
                                               new XElement("Explanation", Mod_Explanation_T.Text),
                                               new XElement("Password", Password_T.Text));
                xml.Add(datas);
                xml.Save(Voice_Set.Special_Path + "/Temp_Create_Mod.dat");
                //Mod情報をアップロード
                Voice_Set.FTPClient.UploadFile(Voice_Set.Special_Path + "/Temp_Create_Mod.dat", "/WoTB_Voice_Mod/Mods/" + Mod_Create_Name_T.Text + "/Configs.dat");
                File.Delete(Voice_Set.Special_Path + "/Temp_Create_Mod.dat");
                await Task.Delay(50);

                //Mod本体をアップロード
                foreach (string Upload_File in Mod_Name_Full)
                {
                    Voice_Set.FTPClient.UploadFile(Upload_File, "/WoTB_Voice_Mod/Mods/" + Mod_Create_Name_T.Text + "/Files/" + Path.GetFileName(Upload_File));
                }
                Voice_Set.AppendString("/WoTB_Voice_Mod/Mods/Mod_Names_Wwise.dat", Mod_Create_Name_T.Text + "\n");
                Voice_Set.TCP_Server.Send("Message|" + Voice_Set.UserName + "->Mod名:" + Mod_Create_Name_T.Text + "を公開しました。");
                IsBusy = false;
                Message_Feed_Out("Modを公開しました。");
                Window_Close();
            }
            catch (Exception e1)
            {
                System.Windows.MessageBox.Show("エラー:" + e1.Message);
                Message_Feed_Out("エラーが発生しました。");
                Sub_Code.Error_Log_Write(e1.Message);
                IsBusy = false;
                Window_Close();
            }
        }