Exemple #1
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);
        }
Exemple #2
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;
            }
        }