示例#1
0
        private void GetUserSetting()
        {
            string settingPath = BaseDir + @"Resources\setting.cfg";

            try
            {
                MasterVolumeValue = int.Parse(FileOperation.GetSettingValueFromFile(settingPath, "MasterVolume"));
                EffectVolumeValue = int.Parse(FileOperation.GetSettingValueFromFile(settingPath, "EffectVolume"));
                MusicVolumeValue  = int.Parse(FileOperation.GetSettingValueFromFile(settingPath, "MusicVolume"));
            }
            catch (Exception e)
            {
                MessageBoxResult result = MessageBox.Show("Unable to load setting! Would U like to restore default Setting? Detail Problem: \n" + e.ToString(), "Opps Error X.X", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    string output = FileOperation.FileToString(BaseDir + @"Resources\defaultSetting.cfg", EncodingType.UTF8);
                    if (output == "Fail to Gain Access, Pls Close program that use this resources!")
                    {
                        MessageBox.Show("Backup Setting not found or corrupted! Please re-install the game!", "Game Failure (X . X)");
                        Environment.Exit(-1);
                    }
                    byte[] recover = Encoding.Default.GetBytes(output);
                    FileOperation.ByteArraytoFile(BaseDir + @"Resources\setting.cfg", recover, recover.Length);
                    GetUserSetting();
                    return;
                }
            }
        }
示例#2
0
        private void LoginCallBack(IAsyncResult ar)
        {
            Socket socket = ar.AsyncState as Socket;

            socket.EndSend(ar);
            byte[] buffer      = new byte[1024];
            int    receiveSize = 0;

            try { receiveSize = socket.Receive(buffer); }
            catch (Exception e)
            {
                FileOperation.ExceptionHandle(e, "Server Disconnected!");
            }
            string receivedString = Encoding.Default.GetString(buffer, 0, receiveSize);

            if (receivedString == "WrongPassword" || receivedString == "WrongUsername")
            {
                Dispatcher.Invoke(() => { ShowOverlayMessage("Failed to Login:"******"Resources\UserInfo.cfg", buffer, receiveSize);
            workingResources.ReloadInformation();
        }