Пример #1
0
        private void AppForm_Load(object sender, EventArgs e)
        {
            this.Text         = AppName.Replace("_", " ");
            NameLabel.Text    = AppName.Replace("_", " ");
            StatusLabel.Text  = "";
            StatusBar.Visible = false;

            if (this.Width == 480)
            {
                DescriptionBox.Top = 200;
            }
            else
            {
                DescriptionBox.Top = 100;
            }

            ParamsHelper.CurrentURI = ParamsHelper.AppURI;

            string FileSize;
            string InfoName;
            string LogoName;
            string ScrShotName;

            string[] AppInfo;

            AppInfo = NetHelper.LoadInfo(ParamsHelper.CurrentURI, AppName).Split('\n');

            FileSize    = AppInfo[0];
            InfoName    = AppInfo[1];
            LogoName    = AppInfo[2];
            ScrShotName = AppInfo[3];

            if (String.IsNullOrEmpty(FileSize))
            {
                SizeLabel.Text    = "0 МБ";
                StatusBar.Maximum = 100;
            }
            else
            {
                SizeLabel.Text    = FileSize;
                StatusBar.Maximum = (int)(Convert.ToDouble(FileSize.Split(' ')[0]) * 100);
            }

            if (String.IsNullOrEmpty(InfoName))
            {
                DescriptionBox.Text = "Для этого приложения ещё нет описания";
            }
            else
            {
                DescriptionBox.Text = IOHelper.ReadTextFile(InfoName);
            }

            if (String.IsNullOrEmpty(LogoName))
            {
            }
            else
            {
                Bitmap LogoBitmap = new Bitmap(LogoName);
                Image  LogoImage  = (Image)LogoBitmap;
                LogoBox.Image = LogoImage;
            }

            ParamsHelper.CurrentURI = ParamsHelper.AppURI;

            Cursor.Current = Cursors.Default;
        }
Пример #2
0
        private void DownloadingThreadWorker(Uri CurrentURI, string DownloadPath, string InstallPath, string AppName)
        {
            string FileName    = AppName + ".zip";
            bool   IsInstalled = false;

            ParamsHelper.ThreadMessage = "Идёт загрузка";

            try
            {
                NetHelper.DownloadFile(CurrentURI, DownloadPath, FileName);
            }
            catch (Exception NewEx)
            {
                ParamsHelper.ThreadException = NewEx;
                ParamsHelper.IsThreadAlive   = false;
                ParamsHelper.IsThreadError   = true;
                ParamsHelper.ThreadMessage   = "Ошибка при загрузке";
                return;
            }

            ParamsHelper.IsThreadWaiting = true;
            ParamsHelper.ThreadMessage   = "Успешно загружено";

            while (ParamsHelper.IsThreadWaiting)
            {
            }

            if (ParamsHelper.ThreadMessage == "Yes")
            {
                ParamsHelper.ThreadMessage = "Идёт распаковка";

                string ExtractedPath;

                try
                {
                    ExtractedPath = IOHelper.ExtractToDirectory(DownloadPath + "\\" + FileName, DownloadPath + "\\" + AppName);
                }
                catch (Exception NewEx)
                {
                    ParamsHelper.ThreadException = NewEx;
                    ParamsHelper.IsThreadAlive   = false;
                    ParamsHelper.IsThreadError   = true;
                    ParamsHelper.ThreadMessage   = "Ошибка при распаковке";
                    return;
                }

                ParamsHelper.ThreadMessage = "Успешно распаковано";

                if (!String.IsNullOrEmpty(InstallPath))
                {
                    ParamsHelper.ThreadMessage = "Идёт установка";

                    try
                    {
                        IsInstalled = SystemHelper.AppInstall(ExtractedPath, InstallPath, AppName, ParamsHelper.IsOverwrite);
                    }
                    catch (Exception NewEx)
                    {
                        ParamsHelper.ThreadException = NewEx;
                        ParamsHelper.IsThreadAlive   = false;
                        ParamsHelper.IsThreadError   = true;
                        ParamsHelper.ThreadMessage   = "Ошибка при установке";
                        return;
                    }

                    if (IsInstalled)
                    {
                        ParamsHelper.ThreadMessage = "Успешно установлено";
                    }
                    else
                    {
                        ParamsHelper.ThreadMessage = "Ошибка при установке";
                    }
                }
                else
                {
                    ParamsHelper.ThreadException = new Exception("InstallPath Empty");
                    ParamsHelper.IsThreadAlive   = false;
                    ParamsHelper.IsThreadError   = true;
                    ParamsHelper.ThreadMessage   = "Ошибка при установке";
                    return;
                }
            }

            ParamsHelper.CurrentURI    = ParamsHelper.AppURI;
            ParamsHelper.IsThreadAlive = false;
        }