Пример #1
0
        public void UpdateProgress(int total, int completed, int state)
        {
            if (this.statusStrip.InvokeRequired)
            {
                UpdateProgressCallback d = new UpdateProgressCallback(UpdateProgress);
                this.Invoke(d, new object[] { total, completed, state });
                return;
            }

            if (total == completed || state == TileDownloader.DOWNLOAD_STATE_STOP)
            {
                this.button_start.Enabled = true;
                this.button_pause.Enabled = false;

                if (total == completed)
                {
                    this.toolStripStatusLabel_download_status.Text = "下载完成";
                }
                else
                {
                    this.toolStripStatusLabel_download_status.Text = "下载停止";
                }
                this.button_pause.Text = "停止";
            }
        }
Пример #2
0
 public void UpdateProgress(long status)
 {
     if (pbar.InvokeRequired)
     {
         UpdateProgressCallback callback = new UpdateProgressCallback(UpdateProgress);
         pbar.Invoke(callback, status);
     }
     else
     {
         if (startTime == -1)
         {
             startTime = DateTime.Now.Ticks;
         }
         else
         {
             long cTime      = DateTime.Now.Ticks - startTime;
             long estimation = cTime * fileSize / status - cTime;
             time.Text = TimeSpan.FromTicks(estimation).ToString(@"hh\:mm\:ss") + " remaining...";
         }
         pbar.Value = (int)Math.Ceiling((double)status / (1024 * 1024));
         if (pbar.Value == pbar.Maximum)
         {
             /* The transfer has ended. The button will be still active to hide the
              * the transfer from the panel but the icon will change for a better visualization.
              */
             button.BackgroundImage = Image.FromFile(@"icons\done.png");
         }
     }
 }
Пример #3
0
        private void writeBGWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            UpdateProgressCallback progress_cb = new UpdateProgressCallback(update_progress);

            try
            {
                remote_write = true;
                writer       = new BitmapWriter(remote_filepath + filename, filename, part.matrix());
                writer.Write(progress_cb);
            }
            catch
            {
                remote_write = false;
                try
                {
                    string desktop =
                        Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\";
                    writer = new BitmapWriter(desktop + filename, filename, part.matrix());
                    writer.Write(progress_cb);
                    MessageBox.Show("Unable to connect to printer. Output images were stored on the desktop.");
                }
                catch
                {
                    MessageBox.Show("Unable to connect to printer and unable to store images on the desktop.");
                }

                statusLabel.Text    = "Connecting... Failed";
                printButton.Enabled = true;
            }
        }
Пример #4
0
        public static void GetHashList(UpdateProgressCallback callback, bool forceUpdate = false)
        {
            Thread t = new Thread(() =>
            {
                LocalHashFile = Path.GetTempFileName();
                using (WebClient hashFileDL = new WebClient())
                {
                    hashFileDL.DownloadProgressChanged += (sender, e) =>
                    {
                        callback(e.ProgressPercentage, "Getting Hashlist...");
                    };

                    hashFileDL.DownloadFile(Settings.HashlistURL, LocalHashFile);

                    if (Properties.Settings.Default.Hashlist == MD5Lib.GetHash(LocalHashFile) && !forceUpdate)
                    {
                        // Hashlist hasnt changed
                        callback(100, "Your client is up-to-date", true);
                        return;
                    }
                }

                CheckFiles(callback);
            });

            t.Start();
        }
Пример #5
0
        public static void CheckFiles(UpdateProgressCallback callback)
        {
            string line = null;

            string[] file;

            int lineCount     = 0;
            int totalLines    = TotalLines(LocalHashFile);
            int existingCount = 0;

            using (StreamReader hashReader = new StreamReader(LocalHashFile))
            {
                while ((line = hashReader.ReadLine()) != null)
                {
                    lineCount++;
                    file = line.Split(new char[] { ':' });

                    if (file.Length != 2)
                    {
                        throw new FormatException("Hashlist got wrong format!");
                    }

                    callback((int)((float)((float)lineCount / (float)totalLines) * 100), "Checking files...");

                    if (!File.Exists(file[0]))
                    {
                        DownloadManager.Add(file[0]);
                    }
                    else
                    {
                        existingCount++;

                        if (MD5Lib.GetHash(file[0]) != file[1])
                        {
                            DownloadManager.Add(file[0]);
                        }
                    }
                }
            }

            string Hashlist = MD5Lib.GetHash(LocalHashFile);

            DeleteLocalHashfile();

            if (existingCount == 0)
            {
                string Message = String.Format("Would you like to install Cosmic Ascension to \"{0}\"?\nIf not, move this file to your preferred folder and start it again!", Application.StartupPath);

                if (MessageBox.Show(Message, "Install", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    callback(100, "Cancelled Installation");
                    return;
                }
            }

            DownloadManager.StartDownload(callback, Hashlist);
        }
Пример #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     // Instantiate the delegate, telling it what method to call.
     UpdateProgressCallback callback = new UpdateProgressCallback(this.DoUpdate);
     // Do something that needs periodic progress reports.
     // This passes a delegate instance that knows how to update the bar.
     DoSomethingLengthy(callback);
     // Clear the bar so that it can be used again.
     progressBar1.Value = 0;
 }
Пример #7
0
 internal DialogCallbacks(DisplayErrorCallback displayError, DisplayLoginCallback displayLogin, DisplayQuestionCallback displayQuestion,
                          DisplayProgressCallback displayProgress, CancelCallback cancel, UpdateProgressCallback updateProgress)
 {
     DisplayError    = displayError;
     DisplayLogin    = displayLogin;
     DisplayQuestion = displayQuestion;
     DisplayProgress = displayProgress;
     Cancel          = cancel;
     UpdateProgress  = updateProgress;
 }
Пример #8
0
        private void ButtonStart_Click(object sender, EventArgs e)
        {
            label1.Visible = true;
            label1.Refresh();
            UpdateProgressCallback callback = new UpdateProgressCallback(this.DoUpdate);

            DoSomethingLengthy(callback);
            progressBar1.Value = 0;
            label1.Visible     = false;
            label1.Refresh();
        }
 public void UpdateProgress(int value)
 {
     if (this.ProgressBar1.InvokeRequired == true)
     {
         UpdateProgressCallback aDelegate = UpdateProgress;
         Invoke(aDelegate, value);
     }
     else
     {
         this.ProgressBar1.Value = value;
     }
 }
Пример #10
0
        private void btnSync_MouseUp(object sender, MouseEventArgs e)
        {
            btnSync.Image = Properties.Resources.sync_normal;

            panelSettings.Visible = false;

            UpdateProgress(0, "Starting Re-Sync");

            UpdateProgressCallback callback = UpdateProgress;

            FileCheck.GetHashList(callback, true);
        }
Пример #11
0
        private void button1_Click(object sender, EventArgs e)
        {
            UpdateProgressCallback callback =
                new UpdateProgressCallback(this.DoUpdate);

            // Do something that needs periodic progress reports. This
            // passes a delegate instance that knows how to update the bar.
            DoSomethingLengthy(callback);

            // Clear the bar so that it can be used again.
            progressBar1.Value = 0;
        }
Пример #12
0
 private void UpdateProgress()
 {
     if (progressBar1.InvokeRequired)
     {
         UpdateProgressCallback callback = new UpdateProgressCallback(UpdateProgress);
         this.Invoke(callback);
     }
     else
     {
         progressBar1.Value++;
     }
 }
Пример #13
0
        private void UpdateProgress(string status, int progress)
        {
            var callback = new UpdateProgressCallback((s, p) =>
            {
                label6.Text = s;

                progressBar1.Value = p;

                Update();
            });

            Invoke(callback, status, progress);
        }
Пример #14
0
    // Button-click handlers. 

    // This one is for the "Click to Start" button.
    private void button1_Click(object sender, EventArgs e)
    {
      // If using a raw delegate, instantiate the delegate, telling it what method to call.
      // If you use a lambda expression (Ch 16), you don't need the delegate instantiation.
      // You could also use an anonymous method in DoSomethingLengthy() - see next section.
      UpdateProgressCallback callback = new UpdateProgressCallback(this.DoUpdate);

      // Do something that needs periodic progress reports.
      // This passes a delegate instance that knows how to update the bar.
      DoSomethingLengthy(callback);
      // Clear the bar so it can be used again.
      progressBar1.Value = 0;
    }
Пример #15
0
        // Button-click handlers.

        // This one is for the "Click to Start" button.
        private void button1_Click(object sender, EventArgs e)
        {
            // If using a raw delegate, instantiate the delegate, telling it what method to call.
            // If you use a lambda expression (Ch 16), you don't need the delegate instantiation.
            // You could also use an anonymous method in DoSomethingLengthy() - see next section.
            UpdateProgressCallback callback = new UpdateProgressCallback(this.DoUpdate);

            // Do something that needs periodic progress reports.
            // This passes a delegate instance that knows how to update the bar.
            DoSomethingLengthy(callback);
            // Clear the bar so it can be used again.
            progressBar1.Value = 0;
        }
Пример #16
0
 public void UpdateProgress(int Percentage)
 {
     if (this.UpdateProgressBar.InvokeRequired & this.ProgressLabel.InvokeRequired)
     {
         UpdateProgressCallback Update = new UpdateProgressCallback(UpdateProgress);
         this.Invoke(Update, new object[] { Percentage });
     }
     else
     {
         this.UpdateProgressBar.Value = Percentage;
         this.ProgressLabel.Text      = this.ProgressLabel.Tag.ToString().Replace("{0}", Percentage.ToString());
     }
 }
Пример #17
0
 // DoSomethingLengthy -- My workhorse method takes a delegate.
 private void DoSomethingLengthy(UpdateProgressCallback updateProgress)
 {
     int duration = 2000;
     int updateInterval = duration / 10;
     for (int i = 0; i < duration; i++)
     {
         Console.WriteLine("Something or other");
         // Update every tenth of the duration.
         if ((i % updateInterval) == 0 && updateProgress != null)
         {
             updateProgress();  // Invoke the delegate.
         }
     }
 }
Пример #18
0
        // DoSomethingLengthy - Our work-horse method that takes a delegate.
        private void DoSomethingLengthy(UpdateProgressCallback updateProgress)
        {
            int duration       = 2000;
            int updateInterval = duration / 10;

            for (int i = 0; i < duration; i++)
            {
                Console.WriteLine("Something or other");
                // Update every tenth of the duration.
                // Make sure the delegate passed in is not null.
                if ((i % updateInterval) == 0 && updateProgress != null)
                {
                    updateProgress(); // Invoke the delegate instance passed in.
                }
            }
        }
        private void InitCallbacks(ref libvlc_dialog_cbs cbs)
        {
            DisplayErrorCallback    error          = new DisplayErrorCallback(pf_display_error);
            DisplayLoginCallback    login          = new DisplayLoginCallback(pf_display_login);
            DisplayQuestionCallback question       = new DisplayQuestionCallback(pf_display_question);
            DisplayProgressCallback progress       = new DisplayProgressCallback(pf_display_progress);
            CancelCallback          cancel         = new CancelCallback(pf_cancel);
            UpdateProgressCallback  updateProgress = new UpdateProgressCallback(pf_update_progress);

            cbs.pf_cancel           = Marshal.GetFunctionPointerForDelegate(cancel);
            cbs.pf_display_error    = Marshal.GetFunctionPointerForDelegate(error);
            cbs.pf_display_login    = Marshal.GetFunctionPointerForDelegate(login);
            cbs.pf_display_progress = Marshal.GetFunctionPointerForDelegate(progress);
            cbs.pf_display_question = Marshal.GetFunctionPointerForDelegate(question);
            cbs.pf_update_progress  = Marshal.GetFunctionPointerForDelegate(updateProgress);
        }
Пример #20
0
        private void DoSomethingLengthy(UpdateProgressCallback updateProgress)
        {
            int duration       = 2000;
            int updateInterval = 10;

            for (int i = 0; i < duration; i++)
            {
                double summation = 1;
                Console.WriteLine("Step {0}", i);
                for (int j = 0; j < i; j++)
                {
                    summation += Math.Pow(summation, Math.Sqrt(j));
                }

                //Update every 10th
                if (i % updateInterval == 0 && updateProgress != null)
                {
                    Console.WriteLine("Update progress");
                    updateProgress("Step " + i + " Complete");
                }
            }
        }
Пример #21
0
        public static void StartDownload(UpdateProgressCallback callback, string Hashlist)
        {
            int    downloadCount = 0;
            string currentDir    = "";

            bool downloadFinished = false;
            bool downloadFailed   = false;

            using (WebClient downloadClient = new WebClient())
            {
                downloadClient.DownloadFileCompleted += (sender, e) =>
                {
                    if (e.Error != null)
                    {
                        downloadFailed = true;
                        return;
                    }

                    downloadFinished = true;
                };

                downloadClient.DownloadProgressChanged += (sender, e) =>
                {
                    callback(GetPercentage((float)downloadCount + ((float)GetPercentage(e.BytesReceived, e.TotalBytesToReceive) / 100.0f), m_DownloadFiles.Count)
                             , String.Format("Downloading Files {0} of {1} "
                                             , downloadCount + 1
                                             , m_DownloadFiles.Count)
                             );
                };

                foreach (string file in m_DownloadFiles)
                {
                    callback(GetPercentage(downloadCount, m_DownloadFiles.Count), String.Format("Downloading Files {0} of {1}", downloadCount + 1, m_DownloadFiles.Count));

                    currentDir = Path.GetDirectoryName(file);

                    if (!string.IsNullOrWhiteSpace(currentDir) && !Directory.Exists(currentDir))
                    {
                        Directory.CreateDirectory(currentDir);
                    }

                    try
                    {
                        downloadClient.DownloadFileAsync(new Uri(string.Format("{0}{1}", Settings.UpdateBaseURL, file.Replace("\\", "/"))), file);

                        while (!downloadFinished)
                        {
                            if (downloadFailed)
                            {
                                callback(100, String.Format("Failed to download: {0}", file));
                                return;
                            }
                            Thread.Sleep(1);
                        }

                        downloadCount++;
                        downloadFinished = false;
                    }
                    catch
                    {
                        callback(100, String.Format("Failed to download: {0}", file));
                        return;
                    }
                }
            }

            Properties.Settings.Default.Hashlist = Hashlist;
            Properties.Settings.Default.Save();

            callback(100, (m_DownloadFiles.Count != 0) ? "Finished Updating" : "Your client is up-to-date", true);

            m_DownloadFiles.Clear();
        }
Пример #22
0
 public static extern bool ScanDrive(string driveToScan,
     UpdateProgressCallback updateProgress,
     RestorableItemFoundCallback itemFound,
     string extFilter,
     bool advancedSearch);
Пример #23
0
 internal DialogCallbacks(DisplayErrorCallback displayError, DisplayLoginCallback displayLogin, DisplayQuestionCallback displayQuestion,
                          DisplayProgressCallback displayProgress, CancelCallback cancel, UpdateProgressCallback updateProgress)
 {
     DisplayError    = Marshal.GetFunctionPointerForDelegate(displayError);
     DisplayLogin    = Marshal.GetFunctionPointerForDelegate(displayLogin);
     DisplayQuestion = Marshal.GetFunctionPointerForDelegate(displayQuestion);
     DisplayProgress = Marshal.GetFunctionPointerForDelegate(displayProgress);
     Cancel          = Marshal.GetFunctionPointerForDelegate(cancel);
     UpdateProgress  = Marshal.GetFunctionPointerForDelegate(updateProgress);
 }
Пример #24
0
        public void Write(UpdateProgressCallback progress_cb)
        {
            if (!Directory.Exists(filepath))
            {
                Directory.CreateDirectory(filepath);
            }

            var    data   = matrix.data();
            UInt32 size_x = matrix.size_x();
            UInt32 size_y = matrix.size_y();

            int num_complete = 0;

            Parallel.For(0, height, kk =>
            {
                for (UInt32 slice = 0; slice < num_slices; ++slice)
                {
                    string filename = filepath + "\\" + base_filename + "_" +
                                      kk.ToString() + "_" + slice.ToString() +
                                      ".bmp";
                    FileStream file     = new FileStream(filename, FileMode.Create);
                    BinaryWriter writer = new BinaryWriter(file);

                    writer.Write('B');                      // Bitmap header
                    writer.Write('M');                      // Bitmap header
                    writer.Write(62 + length * width / 8);  // File size
                    writer.Write(0);                        // Reserved
                    writer.Write(62);                       // Image offset
                    writer.Write(40);                       // Header size
                    writer.Write(width);                    // Image width
                    writer.Write(length);                   // Image length
                    writer.Write((UInt16)1);                // Number of colour planes
                    writer.Write((UInt16)1);                // Bits per pixel
                    writer.Write(0);                        // Compression type
                    writer.Write(length * width / 8);       // Image size
                    writer.Write(0);                        // Horizontal resolution (unused)
                    writer.Write(0);                        // Vertical resolution (unused)
                    writer.Write(0);                        // Number of colours
                    writer.Write(0);                        // Number of important colours
                    writer.Write((UInt64)16777215);         // Palette info

                    for (UInt32 jj = slice * length; jj < (slice + 1) * length;
                         ++jj)
                    {
                        if (jj >= size_y)
                        {
                            for (UInt32 ii = 0; ii < width / 32; ++ii)
                            {
                                writer.Write(0);
                            }
                            continue;
                        }

                        byte[] line = new byte[width];
                        for (UInt32 ii = 0; ii < width; ++ii)
                        {
                            if (ii < size_x)
                            {
                                for (UInt32 vv = 0; vv < z_scaling; ++vv)
                                {
                                    line[ii] |= (byte)data[(kk * z_scaling + vv) * size_y * size_x +
                                                           jj * size_x + ii];
                                }
                            }
                        }

                        for (UInt32 byt = 0; byt < width / 8; ++byt)
                        {
                            byte value = (byte)0;
                            for (UInt32 bit = 0; bit < 8; ++bit)
                            {
                                value |= (byte)(line[byt * 8 + bit] << (int)(7 - bit));
                            }
                            writer.Write(value);
                        }
                    }

                    writer.Close();
                    file.Close();
                }

                Interlocked.Increment(ref num_complete);
                progress_cb((double)num_complete / height, (int)Status.WRITE);
            });
        }
Пример #25
0
 public static void GenerateDatabaseAsync(int rowsCount, UpdateProgressCallback updateProgressCallback, DatabaseGeneratedCallback databaseGeneratedCallback)
 {
     worker.ProgressChanged    += delegate(object sender, ProgressChangedEventArgs e) { updateProgressCallback(e.ProgressPercentage); };
     worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { databaseGeneratedCallback(); };
     worker.RunWorkerAsync(rowsCount);
 }
Пример #26
0
        public void UpdateProgress(int maxVal, int currVal)
        {
            if (this.progressBar1.InvokeRequired)
            {
                UpdateProgressCallback cb = new UpdateProgressCallback(UpdateProgress);
                this.Invoke(cb, new object[] { maxVal, currVal });

            }
            else
            {
                this.progressBar1.Maximum = maxVal;
                this.progressBar1.Value = currVal;
                this.progressBar1.Update();
            }
        }
Пример #27
0
        private void OnReceivedPacket(object sender, PacketEventArgs e)
        {
            int    nBytesUsed = 0;
            ushort nRecvType  = 0;

            while (nBytesUsed < e.Length)
            {
                nRecvType   = BitConverter.ToUInt16(e.Data, nBytesUsed);
                nBytesUsed += 2;
                switch (nRecvType)
                {
                case Protocols.T_PC_CONNECT_GET_SERVER_GROUP_LIST_OK:
                {
                    MSG_PC_CONNECT_GET_SERVER_GROUP_LIST_OK Info = Operations.ByteArrayToStruct <MSG_PC_CONNECT_GET_SERVER_GROUP_LIST_OK>(e.Data, ref nBytesUsed);

                    if (Info.NumOfServerGroup == 0)
                    {
                        MessageBox.Show("Gameserver is offline!\nPlease check [http://ace.gaming-paradise.net] for further information!");
                        Exit();
                    }

                    if (Info.ServerGroup.Crowdedness <= 0)
                    {
                        UpdateProgress(0, "Gameserver offline", false);

                        System.Threading.Thread.Sleep(5000);

                        m_Sock.SendPacket(Protocols.T_PC_CONNECT_GET_SERVER_GROUP_LIST);

                        continue;
                    }

                    m_ServerGroup = Info.ServerGroup;

                    MSG_PC_CONNECT_SINGLE_FILE_VERSION_CHECK Msg = new MSG_PC_CONNECT_SINGLE_FILE_VERSION_CHECK();
                    Msg.DeleteFileListVersion = new ushort[] { 0, 0, 0, 0 };
                    Msg.NoticeVersion         = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_SINGLE_FILE_VERSION_CHECK, Msg);
                }
                break;

                case Protocols.T_PC_CONNECT_SINGLE_FILE_UPDATE_INFO:
                {
                    MSG_PC_CONNECT_SINGLE_FILE_UPDATE_INFO Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_SINGLE_FILE_UPDATE_INFO>(e.Data, ref nBytesUsed);

                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_SINGLE_FILE_VERSION_CHECK_OK:
                {
                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = new ushort[] { 0, 0, 0, 0 };

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_REINSTALL_CLIENT:
                {
                    MSG_PC_CONNECT_REINSTALL_CLIENT Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_REINSTALL_CLIENT>(e.Data, ref nBytesUsed);

                    // Use current version, we don't need the update thingy
                    MSG_PC_CONNECT_VERSION SendMsg = new MSG_PC_CONNECT_VERSION();
                    SendMsg.ClientVersion = Msg.LatestVersion;

                    m_Sock.SendPacket(Protocols.T_PC_CONNECT_VERSION, SendMsg);
                }
                break;

                case Protocols.T_PC_CONNECT_VERSION_OK:
                {
                    UpdateProgressCallback callback = UpdateProgress;
                    FileCheck.GetHashList(callback);
                }
                break;

                case Protocols.T_PC_CONNECT_LOGIN_OK:
                {
                    MSG_PC_CONNECT_LOGIN_OK Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_LOGIN_OK>(e.Data, ref nBytesUsed);

                    if (Properties.Settings.Default.StoreLogins)
                    {
                        Properties.Settings.Default.AccountName = tbAccount.Text;
                        Properties.Settings.Default.Password    = tbPassword.Text;
                        Properties.Settings.Default.Save();
                    }

                    string Args = String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11}"
                                                , Msg.FieldServerIP.ToManagedString()
                                                , Msg.FieldServerPort
                                                , Msg.IMServerIP.ToManagedString()
                                                , Msg.IMServerPort

                                                , Msg.AccountName.ToManagedString()
                                                , BitConverter.ToString(MD5Lib.GetPasswordMD5(tbPassword.Text)).Replace("-", "").ToLowerInvariant()

                                                , (Properties.Settings.Default.Fullscreen) ? 1 : 0
                                                , Properties.Settings.Default.Width
                                                , Properties.Settings.Default.Height
                                                , 2

                                                , (Msg.ConnectToTestServer) ? 1 : 0

                                                , (Properties.Settings.Default.UseVSync) ? 1 : 0);

                    ProcessStartInfo pInfo = new ProcessStartInfo();
                    pInfo.FileName  = "ca.exe";
                    pInfo.Arguments = Args;

                    Process.Start(pInfo);

                    Environment.Exit(0);
                }
                break;

                case Protocols.T_PC_CONNECT_LOGIN_BLOCKED:
                {
                    MSG_PC_CONNECT_LOGIN_BLOCKED Msg = Operations.ByteArrayToStruct <MSG_PC_CONNECT_LOGIN_BLOCKED>(e.Data, ref nBytesUsed);

                    if (Msg.IsMacBlocked)
                    {
                        MessageBox.Show("Your account is blocked presently.\n If you believe this is an error please Contact Customer Support at [http://gaming-paradise.net/support/] for further details");
                    }
                    else
                    {
                        string BlockedMsg = String.Format("{0}\'s account is blocked presently.\n  Reason: {1}\n  Period: {2} ~ {3}\n\nContact Customer Support at [http://gaming-paradise.net/support/] for further details."
                                                          , Msg.szAccountName.ToManagedString()
                                                          , Msg.szBlockedReasonForUser.ToManagedString()
                                                          , Msg.atimeStart.ToString()
                                                          , Msg.atimeEnd.ToString());
                        MessageBox.Show(BlockedMsg);
                    }
                }
                break;

                case Protocols.T_ERROR:
                {
                    MSG_ERROR ErrorMsg = Operations.ByteArrayToStruct <MSG_ERROR>(e.Data, ref nBytesUsed);

                    string Msg = Operations.GetChatMessageFromPacket(e.Data, ref nBytesUsed, ErrorMsg.StringLength);

                    ShowError(ErrorMsg, Msg);
                }
                break;

                default:
                {
                    MessageBox.Show("Got unknown data from server!");
                    Exit();
                }
                break;
                }
            }
        }