Пример #1
0
        private void transmitFile(object obj)
        {
            string ipAddress = ((string[])obj)[0];
            string file = ((string[])obj)[1];
            Protocol prot = ((string[])obj)[2].Contains("JODI") ? Protocol.JODI : Protocol.HAXX;

            setControls(false);

            HbcTransmitter transmitter = new HbcTransmitter(prot, ipAddress);
            transmitter.Progress += new System.EventHandler<System.ComponentModel.ProgressChangedEventArgs>(transmitter_Progress);

            if (!transmitter.TransmitFile(file))
            { MessageBox.Show(transmitter.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            else
            { MessageBox.Show(string.Format("Successfully transmitted file!{0}", (transmitter.CompressionRatio > 0) ? "\nCompression Ratio: " + transmitter.CompressionRatio + "%" : string.Empty), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); }

            setControls(true);
        }
        void bwTransmit_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                BackgroundWorker bwTransmit = sender as BackgroundWorker;

                //Insert wad into stub dol
                string fileName = "CMiiInstaller.dol";
                byte[] fileData = CustomizeMiiInstaller.InstallerHelper.CreateInstaller(wadCreationInfo.wadFile, (byte)wadCreationInfo.transmitIos).ToArray();

                //Transmit installer
                Stopwatch transmitTimer = new Stopwatch();

                HbcTransmitter transmitter = new HbcTransmitter(wadCreationInfo.transmitProtocol, wadCreationInfo.transmitIp);
                transmitter.Progress += new EventHandler<ProgressChangedEventArgs>(transmitter_Progress);

                transmitter_Progress(null, new ProgressChangedEventArgs(0, null));
                transmitTimer.Start();

                bool success = transmitter.TransmitFile(fileName, fileData);

                transmitTimer.Stop();

                if (!success) errorBox(transmitter.LastError);
                else
                {
                    transmitInfo.timeElapsed = (int)transmitTimer.ElapsedMilliseconds;
                    transmitInfo.compressionRatio = transmitter.CompressionRatio;
                    transmitInfo.transmittedLength = Math.Round(transmitter.TransmittedLength * 0.0009765625, 2);
                }
            }
            catch (Exception ex) { errorBox(ex.Message); }
        }