Exemple #1
0
        private void OpenWithForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            BackColor = Main.Colors.BaseDark;

            Icon = Resources.PortableApps_blue;

            Lang.SetControlLang(this);
            Text = Lang.GetText(Name);

            Main.SetFont(this);
            Main.SetFont(appMenu);

            var notifyBox = new NotifyBox {
                Opacity = .8d
            };

            notifyBox.Show(Lang.GetText(nameof(en_US.FileSystemAccessMsg)), Main.Title, NotifyBox.NotifyBoxStartPosition.Center);
            Main.CheckCmdLineApp();
            notifyBox.Close();
            if (WinApi.NativeHelper.GetForegroundWindow() != Handle)
            {
                WinApi.NativeHelper.SetForegroundWindow(Handle);
            }

            AppsBox_Update(false);
        }
        private void OpenWithForm_Load(object sender, EventArgs e)
        {
            var notifyBox = NotifyBoxEx.Show(Language.GetText(nameof(en_US.FileSystemAccessMsg)), Resources.GlobalTitle, NotifyBoxStartPosition.Center, 0u, false);

            Arguments.DefineAppName();
            notifyBox.Close();

            if (WinApi.NativeHelper.GetForegroundWindow() != Handle)
            {
                WinApi.NativeHelper.SetForegroundWindow(Handle);
            }

            FormEx.Dockable(this);
            AppsBoxUpdate(false);
        }
Exemple #3
0
        private void AboutForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            Icon = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.HelpShield, Main.SystemResourcePath);

            Lang.SetControlLang(this);
            Text = Lang.GetText(Name);

            Main.SetFont(this);

            AddFileInfoLabels();

            logoPanel.BackColor = Main.Colors.Base;

            updateBtnPanel.Width = TextRenderer.MeasureText(updateBtn.Text, updateBtn.Font).Width + 32;
            updateBtn.Image      = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Network, Main.SystemResourcePath)?.ToBitmap();
            updateBtn.ForeColor  = Main.Colors.ButtonText;
            updateBtn.BackColor  = Main.Colors.Button;
            updateBtn.FlatAppearance.MouseDownBackColor = Main.Colors.Button;
            updateBtn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover;

            _progressCircle = new ProgressCircle
            {
                Anchor        = updateBtnPanel.Anchor,
                BackColor     = Color.Transparent,
                ForeColor     = mainPanel.BackColor,
                InnerRadius   = 7,
                Location      = new Point(updateBtnPanel.Right + 3, updateBtnPanel.Top + 1),
                OuterRadius   = 9,
                RotationSpeed = 80,
                Size          = new Size(updateBtnPanel.Height, updateBtnPanel.Height),
                Thickness     = 3,
                Visible       = false
            };
            mainPanel.Controls.Add(_progressCircle);

            aboutInfoLabel.ActiveLinkColor = Main.Colors.Base;
            aboutInfoLabel.BorderStyle     = BorderStyle.None;
            aboutInfoLabel.Text            = string.Format(Lang.GetText(aboutInfoLabel), "Si13n7 Developments", Lang.GetText(aboutInfoLabel.Name + "LinkLabel1"), Lang.GetText(aboutInfoLabel.Name + "LinkLabel2"));
            aboutInfoLabel.Links.Clear();
            aboutInfoLabel.LinkText("Si13n7 Developments", "http://www.si13n7.com");
            aboutInfoLabel.LinkText(Lang.GetText(aboutInfoLabel.Name + "LinkLabel1"), "http://paypal.si13n7.com");
            aboutInfoLabel.LinkText(Lang.GetText(aboutInfoLabel.Name + "LinkLabel2"), "https://support.si13n7.com");

            copyrightLabel.Text = string.Format(copyrightLabel.Text, DateTime.Now.Year);
        }
Exemple #4
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            highlightInstalledCheck.Checked = Settings.Window.HighlightInstalled;
            showLargeImagesCheck.Checked    = Settings.Window.LargeImages;
            showGroupsCheck.Checked         = Settings.Window.ShowGroups;
            showColorsCheck.Checked         = Settings.Window.ShowGroupColors;

            group1ColorPanel.BackColor  = Settings.Window.Colors.GroupColor1;
            group2ColorPanel.BackColor  = Settings.Window.Colors.GroupColor2;
            group3ColorPanel.BackColor  = Settings.Window.Colors.GroupColor3;
            group4ColorPanel.BackColor  = Settings.Window.Colors.GroupColor4;
            group5ColorPanel.BackColor  = Settings.Window.Colors.GroupColor5;
            group6ColorPanel.BackColor  = Settings.Window.Colors.GroupColor6;
            group7ColorPanel.BackColor  = Settings.Window.Colors.GroupColor7;
            group8ColorPanel.BackColor  = Settings.Window.Colors.GroupColor8;
            group9ColorPanel.BackColor  = Settings.Window.Colors.GroupColor9;
            group11ColorPanel.BackColor = Settings.Window.Colors.GroupColor11;
            group12ColorPanel.BackColor = Settings.Window.Colors.GroupColor12;

            FormEx.Dockable(this);
            WinApi.NativeHelper.MoveWindowToVisibleScreenArea(Handle);
        }
Exemple #5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Check internet connection
            if (!Network.InternetIsAvailable)
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Get update infos from GitHub if enabled
            if (Settings.UpdateChannel == Settings.UpdateChannelOptions.Beta)
            {
                if (!NetEx.IPv4IsAvalaible && NetEx.IPv6IsAvalaible)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }
                SetUpdateInfo(false, CorePaths.RepoSnapshotsUrl);
            }

            // Get update infos if not already set
            if (string.IsNullOrWhiteSpace(HashInfo))
            {
                DownloadMirrors.AddRange(new[]
                {
                    "https://port-a.de",
                    "https://p-able.de",

                    // Backup
                    "https://dl.si13n7.de/Port-Able",
                    "https://dl.si13n7.com/Port-Able",

                    // Reserved
                    "http://dl-0.de/Port-Able",
                    "http://dl-1.de/Port-Able",
                    "http://dl-2.de/Port-Able",
                    "http://dl-3.de/Port-Able",
                    "http://dl-4.de/Port-Able",
                    "http://dl-5.de/Port-Able"
                });
                if (!DownloadMirrors.Any())
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }
                SetUpdateInfo(true, DownloadMirrors.ToArray());
            }
            if (string.IsNullOrWhiteSpace(HashInfo))
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Compare hashes
            var updateAvailable = false;

            try
            {
                foreach (var key in Ini.GetKeys("SHA256", HashInfo))
                {
                    var file = PathEx.Combine(PathEx.LocalDir, $"{key}.exe");
                    if (!File.Exists(file))
                    {
                        file = Path.Combine(CorePaths.HomeDir, $"{key}.exe");
                    }
                    if (Ini.Read("SHA256", key, HashInfo).EqualsEx(file.EncryptFile(ChecksumAlgorithm.Sha256)))
                    {
                        continue;
                    }
                    updateAvailable = true;
                    break;
                }
            }
            catch (Exception ex) when(ex.IsCaught())
            {
                Log.Write(ex);
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Install updates
            if (updateAvailable)
            {
                if (string.IsNullOrEmpty(CorePaths.FileArchiver))
                {
                    if (MessageBox.Show(Language.GetText(nameof(en_US.RequirementsErrorMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes)
                    {
                        Process.Start(CorePaths.RepoReleasesUrl);
                    }
                    Environment.ExitCode = 1;
                    Environment.Exit(Environment.ExitCode);
                }
                if (MessageBox.Show(Language.GetText(nameof(en_US.UpdateAvailableMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    SetChangeLog(DownloadMirrors.ToArray());
                    ShowInTaskbar = true;
                    FormEx.Dockable(this);
                    return;
                }
                DirectoryEx.TryDelete(CachePaths.UpdateDir);
            }

            // Exit the application if no updates were found
            Environment.ExitCode = 2;
            Application.Exit();
        }
 private void SettingsForm_Load(object sender, EventArgs e)
 {
     LoadSettings();
     FormEx.Dockable(this);
     WinApi.NativeHelper.MoveWindowToVisibleScreenArea(Handle);
 }
Exemple #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            Lang.SetControlLang(this);

            // Check internet connection
            if (!(_ipv4 = NetEx.InternetIsAvailable()) && !(_ipv6 = NetEx.InternetIsAvailable(true)))
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Get update infos from GitHub if enabled
            if (Ini.Read("Settings", "UpdateChannel", 0) > 0)
            {
                if (!_ipv4 && _ipv6)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }
                try
                {
                    var path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitSnapshotsPath, "Last.ini");
                    if (!NetEx.FileIsAvailable(path, 60000))
                    {
                        throw new PathNotFoundException(path);
                    }
                    var data = NetEx.Transfer.DownloadString(path);
                    if (string.IsNullOrWhiteSpace(data))
                    {
                        throw new ArgumentNullException(nameof(data));
                    }
                    _lastStamp = Ini.ReadOnly("Info", "LastStamp", data);
                    if (string.IsNullOrWhiteSpace(_lastStamp))
                    {
                        throw new ArgumentNullException(_lastStamp);
                    }
                    path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitSnapshotsPath, $"{_lastStamp}.ini");
                    if (!NetEx.FileIsAvailable(path, 60000))
                    {
                        throw new PathNotFoundException(path);
                    }
                    data = NetEx.Transfer.DownloadString(path);
                    if (string.IsNullOrWhiteSpace(data))
                    {
                        throw new ArgumentNullException(nameof(data));
                    }
                    _hashInfo = data;
                }
                catch (Exception ex)
                {
                    Log.Write(ex);
                }
            }

            // Get update infos if not already set
            if (string.IsNullOrWhiteSpace(_hashInfo))
            {
                // Get available download mirrors
                var dnsInfo = string.Empty;
                for (var i = 0; i < 3; i++)
                {
                    if (!_ipv4 && _ipv6)
                    {
                        dnsInfo = Resources.IPv6DNS;
                        break;
                    }
                    try
                    {
                        var path = PathEx.AltCombine(Resources.GitRawProfileUri, Resources.GitDnsPath);
                        if (!NetEx.FileIsAvailable(path, 60000))
                        {
                            throw new PathNotFoundException(path);
                        }
                        var data = NetEx.Transfer.DownloadString(path);
                        if (string.IsNullOrWhiteSpace(data))
                        {
                            throw new ArgumentNullException(nameof(data));
                        }
                        dnsInfo = data;
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                    if (string.IsNullOrWhiteSpace(dnsInfo) && i < 2)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }
                    break;
                }
                if (!string.IsNullOrWhiteSpace(dnsInfo))
                {
                    foreach (var section in Ini.GetSections(dnsInfo))
                    {
                        var addr = Ini.Read(section, _ipv4 ? "addr" : "ipv6", dnsInfo);
                        if (string.IsNullOrEmpty(addr))
                        {
                            continue;
                        }
                        var domain = Ini.Read(section, "domain", dnsInfo);
                        if (string.IsNullOrEmpty(domain))
                        {
                            continue;
                        }
                        var ssl = Ini.ReadOnly(section, "ssl", false, dnsInfo);
                        domain = PathEx.AltCombine(ssl ? "https:" : "http:", domain);
                        if (!DownloadMirrors.ContainsEx(domain))
                        {
                            DownloadMirrors.Add(domain);
                        }
                    }
                }
                if (DownloadMirrors.Count == 0)
                {
                    Environment.ExitCode = 1;
                    Application.Exit();
                    return;
                }

                // Get file hashes
                foreach (var mirror in DownloadMirrors)
                {
                    try
                    {
                        var path = PathEx.AltCombine(mirror, Resources.ReleasePath, "Last.ini");
                        if (!NetEx.FileIsAvailable(path, 60000))
                        {
                            throw new PathNotFoundException(path);
                        }
                        var data = NetEx.Transfer.DownloadString(path);
                        if (string.IsNullOrWhiteSpace(data))
                        {
                            throw new ArgumentNullException(nameof(data));
                        }
                        _lastFinalStamp = Ini.ReadOnly("Info", "LastStamp", data);
                        if (string.IsNullOrWhiteSpace(_lastFinalStamp))
                        {
                            throw new ArgumentNullException(nameof(_lastFinalStamp));
                        }
                        path = PathEx.AltCombine(mirror, Resources.ReleasePath, $"{_lastFinalStamp}.ini");
                        if (!NetEx.FileIsAvailable(path, 60000))
                        {
                            throw new PathNotFoundException(path);
                        }
                        data = NetEx.Transfer.DownloadString(path);
                        if (string.IsNullOrWhiteSpace(data))
                        {
                            throw new ArgumentNullException(nameof(data));
                        }
                        _hashInfo = data;
                    }
                    catch (Exception ex)
                    {
                        Log.Write(ex);
                    }
                    if (!string.IsNullOrWhiteSpace(_hashInfo))
                    {
                        break;
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(_hashInfo))
            {
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Compare hashes
            var updateAvailable = false;

            try
            {
                foreach (var key in Ini.GetKeys("SHA256", _hashInfo))
                {
                    var file = Path.Combine(HomeDir, $"{key}.exe");
                    if (!File.Exists(file))
                    {
                        file = PathEx.Combine(PathEx.LocalDir, $"{key}.exe");
                    }
                    if (Ini.Read("SHA256", key, _hashInfo).EqualsEx(Crypto.EncryptFileToSha256(file)))
                    {
                        continue;
                    }
                    updateAvailable = true;
                    break;
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex);
                Environment.ExitCode = 1;
                Application.Exit();
                return;
            }

            // Install updates
            if (updateAvailable)
            {
                if (MessageBox.Show(Lang.GetText(nameof(en_US.UpdateAvailableMsg)), Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                {
                    // Update changelog
                    if (DownloadMirrors.Count > 0)
                    {
                        var changes = string.Empty;
                        foreach (var mirror in DownloadMirrors)
                        {
                            var path = PathEx.AltCombine(mirror, Resources.ReleasePath, "ChangeLog.txt");
                            if (string.IsNullOrWhiteSpace(path))
                            {
                                continue;
                            }
                            if (!NetEx.FileIsAvailable(path, 60000))
                            {
                                continue;
                            }
                            changes = NetEx.Transfer.DownloadString(path);
                            if (!string.IsNullOrWhiteSpace(changes))
                            {
                                break;
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(changes))
                        {
                            changeLog.Font = new Font("Consolas", 8.25f);
                            changeLog.Text = TextEx.FormatNewLine(changes);
                            var colorMap = new Dictionary <Color, string[]>
                            {
                                {
                                    Color.PaleGreen, new[]
                                    {
                                        " PORTABLE APPS SUITE",
                                        " UPDATED:",
                                        " CHANGES:"
                                    }
                                },
                                {
                                    Color.SkyBlue, new[]
                                    {
                                        " Global:",
                                        " Apps Launcher:",
                                        " Apps Downloader:",
                                        " Apps Suite Updater:"
                                    }
                                },
                                {
                                    Color.Khaki, new[]
                                    {
                                        "Version History:"
                                    }
                                },
                                {
                                    Color.Plum, new[]
                                    {
                                        "{", "}",
                                        "(", ")",
                                        "|",
                                        ".",
                                        "-"
                                    }
                                },
                                {
                                    Color.Tomato, new[]
                                    {
                                        " * "
                                    }
                                },
                                {
                                    Color.Black, new[]
                                    {
                                        new string('_', 84)
                                    }
                                }
                            };
                            foreach (var line in changeLog.Text.Split('\n'))
                            {
                                if (line.Length < 1 || !DateTime.TryParseExact(line.Trim(' ', ':'), "d MMMM yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _))
                                {
                                    continue;
                                }
                                changeLog.MarkText(line, Color.Khaki);
                            }
                            foreach (var color in colorMap)
                            {
                                foreach (var s in color.Value)
                                {
                                    changeLog.MarkText(s, color.Key);
                                }
                            }
                        }
                    }
                    else
                    {
                        changeLog.Dock     = DockStyle.None;
                        changeLog.Size     = new Size(changeLogPanel.Width, TextRenderer.MeasureText(changeLog.Text, changeLog.Font).Height);
                        changeLog.Location = new Point(0, changeLogPanel.Height / 2 - changeLog.Height - 16);
                        changeLog.SelectAll();
                        changeLog.SelectionAlignment = HorizontalAlignment.Center;
                        changeLog.DeselectAll();
                    }
                    ShowInTaskbar = true;
                    return;
                }
            }

            // Exit the application if no updates were found
            Environment.ExitCode = 2;
            Application.Exit();
        }
Exemple #8
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            FormEx.Dockable(this);

            if (Main.ScreenDpi > 96)
            {
                Font = SystemFonts.CaptionFont;
            }

            Icon = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.SystemControl, Main.SystemResourcePath);

            foreach (TabPage tab in tabCtrl.TabPages)
            {
                tab.BackColor = Main.Colors.BaseDark;
            }

            locationBtn.BackgroundImage = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Directory, Main.SystemResourcePath)?.ToBitmap();
            fileTypesMenu.EnableAnimation();
            fileTypesMenu.SetFixedSingle();
            associateBtn.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
            try
            {
                restoreFileTypesBtn.Image = new Bitmap(28, 16);
                using (var g = Graphics.FromImage(restoreFileTypesBtn.Image))
                {
                    g.DrawImage(ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath).ToBitmap(), 0, 0);
                    g.DrawImage(ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Undo, Main.SystemResourcePath).ToBitmap(), 12, 0);
                }
            }
            catch
            {
                restoreFileTypesBtn.Image      = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
                restoreFileTypesBtn.ImageAlign = ContentAlignment.MiddleLeft;
                restoreFileTypesBtn.Text       = @"<=";
                if (restoreFileTypesBtn.Image != null)
                {
                    restoreFileTypesBtn.TextAlign = ContentAlignment.MiddleRight;
                }
            }

            previewBg.BackgroundImage       = Main.BackgroundImage.Redraw((int)Math.Round(Main.BackgroundImage.Width * .65f) + 1, (int)Math.Round(Main.BackgroundImage.Height * .65f) + 1);
            previewBg.BackgroundImageLayout = Main.BackgroundImageLayout;
            previewLogoBox.BackgroundImage  = Resources.PortableApps_Logo_gray.Redraw(previewLogoBox.Height, previewLogoBox.Height);
            var exeIco = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.ExeFile, Main.SystemResourcePath);

            if (exeIco != null)
            {
                previewImgList.Images.Add(exeIco.ToBitmap());
                previewImgList.Images.Add(exeIco.ToBitmap());
            }

            foreach (var btn in new[] { saveBtn, exitBtn })
            {
                btn.BackColor = Main.Colors.Button;
                btn.ForeColor = Main.Colors.ButtonText;
                btn.FlatAppearance.MouseDownBackColor = Main.Colors.Button;
                btn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover;
            }
            var strAppNames = Main.AppsInfo.Select(x => x.LongName).ToArray();
            var objAppNames = new object[strAppNames.Length];

            Array.Copy(strAppNames, objAppNames, objAppNames.Length);
            appsBox.Items.AddRange(objAppNames);

            appsBox.SelectedItem = _selectedItem;
            if (appsBox.SelectedIndex < 0)
            {
                appsBox.SelectedIndex = 0;
            }

            fileTypes.MaxLength  = short.MaxValue;
            addToShellBtn.Image  = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();
            rmFromShellBtn.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap();

            LoadSettings();
        }
 private void LangSelectionForm_Load(object sender, EventArgs e)
 {
     FormEx.Dockable(this);
     Lang.SetControlLang(this);
     Text = _name;
 }