예제 #1
0
 private void TabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         MemLabel.Text = ParamsHelper.BytesToMegs(IOHelper.GetStorageSpace(ParamsHelper.InstallPath)).ToString("0.##") + " МБ";
     }
     catch (ArgumentNullException)
     {
         MemLabel.Text = "0 байт";
     }
 }
예제 #2
0
 private void CleanBufferButton_Click(object sender, EventArgs e)
 {
     try
     {
         IOHelper.CleanBuffer();
         UsedTempSizeLabel.Text = "Занято сейчас: " + ParamsHelper.BytesToMegs(IOHelper.GetDirectorySize(ParamsHelper.TempPath)).ToString("0.###") + " МБ";
     }
     catch
     {
     }
 }
예제 #3
0
        /// <summary>
        /// Retrieves a package information from the FTP server
        /// </summary>
        /// <param name="URI"></param>
        /// <param name="AppName"></param>
        /// <returns>The file info as a string</returns>
        static public string LoadInfo(Uri URI, string AppName)
        {
            Uri    InfoUri    = new Uri(URI.ToString() + "/" + AppName + ".info");
            Uri    FileUri    = new Uri(URI.ToString() + "/" + AppName + ".zip");
            Uri    LogoUri    = new Uri(URI.ToString() + "/Logo.png");
            string AppSize    = "";
            string AppInfo    = "";
            string AppScrShot = null;
            string AppLogo    = null;
            int    bufferSize = 1024;
            int    readCount;

            byte[] buffer = new byte[bufferSize];

            try
            {
                using (Stream FTPReader = CreateDownloadRequest(InfoUri))
                {
                    readCount = FTPReader.Read(buffer, 0, bufferSize);
                    while (readCount > 0)
                    {
                        AppInfo  += Encoding.UTF8.GetString(buffer, 0, bufferSize);
                        readCount = FTPReader.Read(buffer, 0, bufferSize);
                    }
                }
            }
            catch
            {
                AppInfo = null;
            }

            try
            {
                AppSize = ParamsHelper.BytesToMegs(GetFileSizeRequest(FileUri)).ToString("0.##") + " МБ";
            }
            catch
            {
                throw;
                AppSize = null;
            }

            return(AppSize + "\n" + AppInfo + "\n" + AppLogo + "\n" + AppScrShot);
        }
예제 #4
0
        /// <summary>
        /// Retrieves a package information from the FTP server
        /// </summary>
        /// <param name="URI"></param>
        /// <param name="AppName"></param>
        /// <returns>The file info as a string</returns>
        static public string LoadInfo(Uri URI, string AppName)
        {
            FTP    Ftp         = new FTP(URI.Host, URI.Port);
            string FileName    = AppName + ".zip";
            string InfoName    = AppName + ".info";
            string ScrShotName = AppName + ".png";
            string LogoName    = "Logo.png";
            string FileSize;
            string BufferPath = ParamsHelper.TempPath + "\\" + AppName;
            string AppInfo;

            if (!Directory.Exists(BufferPath))
            {
                Directory.CreateDirectory(BufferPath);
            }

            Ftp.Connect(URI.UserInfo, "");

            try
            {
                Ftp.ChangeDirectory(URI.AbsolutePath);
                FileSize = Ftp.GetFileSize(FileName);
                FileSize = ParamsHelper.BytesToMegs((ulong)Convert.ToInt64(FileSize)).ToString("0.###") + " МБ";
            }
            catch
            {
                FileSize = null;
            }

            try
            {
                Ftp.GetFile(InfoName, BufferPath + "\\" + InfoName, true);
                InfoName = BufferPath + "\\" + InfoName;
            }
            catch
            {
                File.Delete(BufferPath + "\\" + InfoName);
                InfoName = null;
            }

            try
            {
                Ftp.GetFile(LogoName, BufferPath + "\\" + LogoName, true);
                LogoName = BufferPath + "\\" + LogoName;
            }
            catch
            {
                File.Delete(BufferPath + "\\" + LogoName);
                LogoName = null;
            }

            try
            {
                Ftp.GetFile(ScrShotName, BufferPath + "\\" + ScrShotName, true);
                ScrShotName = BufferPath + "\\" + ScrShotName;
            }
            catch
            {
                File.Delete(BufferPath + "\\" + ScrShotName);
                ScrShotName = null;
            }

            AppInfo = FileSize + "\n" + InfoName + "\n" + LogoName + "\n" + ScrShotName;

            Ftp.Disconnect();

            return(AppInfo);
        }
예제 #5
0
        private void ParamsBox_Load(object sender, EventArgs e)
        {
            DownloadPathBox.Text     = ParamsHelper.DownloadPath;
            OverwriteDirsBox.Checked = ParamsHelper.IsOverwrite;
            AutoInstallBox.Checked   = ParamsHelper.IsAutoInstall;
            RmPackageBox.Checked     = ParamsHelper.IsRmPackage;
            TempSizeBox.Text         = ParamsHelper.BytesToMegs(ParamsHelper.TempSize).ToString("0.##");
            UsedTempSizeLabel.Text   = "Занято сейчас: " + ParamsHelper.BytesToMegs(IOHelper.GetDirectorySize(ParamsHelper.TempPath)).ToString("0.###") + " МБ";

            List <string> StoragesNames = IO.GetAllRemovableStorages();

            if (!(StoragesNames.Count == 0))
            {
                int ButtonTop;
                int ButtonLeft;
                int ButtonWidth;

                if (this.Width == 480)
                {
                    ButtonTop   = 303;
                    ButtonLeft  = 14;
                    ButtonWidth = 400;
                }
                else
                {
                    ButtonTop   = 140;
                    ButtonLeft  = 7;
                    ButtonWidth = 200;
                }

                int i = 1;

                foreach (string storage in StoragesNames)
                {
                    RadioButton StorageButton = new RadioButton();

                    StorageButton.Left            = ButtonLeft;
                    StorageButton.Top             = ButtonTop;
                    StorageButton.Width           = ButtonWidth;
                    StorageButton.Text            = storage;
                    StorageButton.Name            = "StorageButton" + i;
                    StorageButton.CheckedChanged += StorageButton_CheckedChanged;

                    if (!String.IsNullOrEmpty(ParamsHelper.InstallPath))
                    {
                        if (storage == ParamsHelper.InstallPath.Split('\\')[1])
                        {
                            StorageButton.Checked = true;
                        }
                    }

                    InstallTabPage.Controls.Add(StorageButton);

                    if (this.Width == 480)
                    {
                        ButtonTop += 46;
                    }
                    else
                    {
                        ButtonTop += 23;
                    }

                    i++;
                }
            }
            else
            {
                DeviceInstallButton.Checked = true;
            }
        }