public OpenWithForm() { InitializeComponent(); notifyIcon.Icon = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Asterisk, true, Main.SystemResourcePath); searchBox.BackColor = Main.Colors.Control; searchBox.ForeColor = Main.Colors.ControlText; searchBox.DrawSearchSymbol(Main.Colors.ControlText); startBtn.Split(Main.Colors.ButtonText); foreach (var btn in new[] { startBtn, settingsBtn }) { btn.BackColor = Main.Colors.Button; btn.ForeColor = Main.Colors.ButtonText; btn.FlatAppearance.MouseDownBackColor = Main.Colors.Button; btn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover; } appMenu.EnableAnimation(ContextMenuStripEx.Animations.SlideVerPositive, 100); appMenu.SetFixedSingle(); appMenuItem2.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap(); appMenuItem3.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Directory, Main.SystemResourcePath)?.ToBitmap(); appMenuItem7.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.RecycleBinEmpty, Main.SystemResourcePath)?.ToBitmap(); if (!searchBox.Focused) { searchBox.Select(); } }
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); }
internal static Icon GetSystemIcon(ResourcesEx.IconIndex index, bool large = false) { Icon icon; if (Icons.Any()) { icon = Icons.FirstOrDefault(x => x.Item1.Equals(index) && x.Item2.Equals(large))?.Item3; if (icon != default(Icon)) { goto Return; } } icon = ResourcesEx.GetSystemIcon(index, large); if (icon == default(Icon)) { goto Return; } var tuple = new Tuple <ResourcesEx.IconIndex, bool, Icon>(index, large, icon); Icons.Add(tuple); Return: return(icon); }
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 MenuViewForm_Update(bool setWindowLocation = true) { Main.CheckAvailableApps(); appsListView.BeginUpdate(); try { appsListView.Items.Clear(); if (!appsListView.Scrollable) { appsListView.Scrollable = true; } imgList.Images.Clear(); var cachePath = Path.Combine(Main.TmpDir, "images.dat"); var cacheDict = new Dictionary <string, Image>(); var cacheSize = 0; string dictPath = null; Dictionary <string, Image> imgDict = null; Image defExeIcon = null; for (var i = 0; i < Main.AppsInfo.Count; i++) { var appInfo = Main.AppsInfo[i]; var longName = appInfo.LongName; if (string.IsNullOrWhiteSpace(longName)) { continue; } appsListView.Items.Add(longName, i); var shortName = appInfo.ShortName; if (File.Exists(cachePath)) { if (cacheDict?.Any() != true) { cacheDict = File.ReadAllBytes(cachePath).DeserializeObject <Dictionary <string, Image> >(); cacheSize = cacheDict.Count; } if (cacheDict?.ContainsKey(shortName) == true) { var img = cacheDict[shortName]; imgList.Images.Add(shortName, img); continue; } } if (dictPath == null) { dictPath = PathEx.Combine(PathEx.LocalDir, "Assets\\images.dat"); } if (!File.Exists(dictPath)) { goto TryHard; } if (imgDict == null) { imgDict = File.ReadAllBytes(dictPath).DeserializeObject <Dictionary <string, Image> >(); } if (imgDict == null) { goto TryHard; } if (imgDict?.ContainsKey(shortName) == true) { var img = imgDict[shortName]; imgList.Images.Add(shortName, img); cacheDict.Add(shortName, img); continue; } TryHard: try { var exePath = appInfo.ExePath; var imgPath = Path.ChangeExtension(exePath, ".png"); Image img; if (!string.IsNullOrEmpty(imgPath) && File.Exists(imgPath)) { img = Image.FromFile(imgPath); imgList.Images.Add(shortName, img); cacheDict.Add(shortName, img); continue; } var appDir = Path.GetDirectoryName(exePath); if (!string.IsNullOrEmpty(appDir) && !File.Exists(imgPath)) { imgPath = Path.Combine(appDir, "App\\AppInfo\\appicon_16.png"); } if (!string.IsNullOrEmpty(imgPath) && File.Exists(imgPath)) { img = Image.FromFile(imgPath)?.Redraw(16, 16); imgList.Images.Add(shortName, img); cacheDict.Add(shortName, img); continue; } using (var ico = ResourcesEx.GetIconFromFile(exePath)) { img = ico?.ToBitmap()?.Redraw(16, 16); if (img == null) { goto Default; } imgList.Images.Add(shortName, img); cacheDict.Add(shortName, img); continue; } } catch (Exception ex) { Log.Write(ex); } Default: if (defExeIcon == null) { defExeIcon = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.ExeFile, Main.SystemResourcePath)?.ToBitmap().Redraw(16, 16); } if (defExeIcon == null) { continue; } imgList.Images.Add(shortName, defExeIcon); } appsListView.SmallImageList = imgList; if (cacheDict.Count > 0 && (cacheDict.Count != cacheSize || !File.Exists(cachePath))) { File.WriteAllBytes(cachePath, cacheDict.SerializeObject()); } if (!setWindowLocation) { return; } var defaultPos = Ini.Read("Settings", "Window.DefaultPosition", 0); var taskbarLocation = TaskBar.GetLocation(Handle); if (defaultPos == 0 && taskbarLocation != TaskBar.Location.Hidden) { var screen = Screen.PrimaryScreen.WorkingArea; foreach (var scr in Screen.AllScreens) { if (!scr.Bounds.Contains(Cursor.Position)) { continue; } screen = scr.WorkingArea; break; } switch (taskbarLocation) { case TaskBar.Location.Left: case TaskBar.Location.Top: Left = screen.X; Top = screen.Y; break; case TaskBar.Location.Right: Left = screen.Width - Width; Top = screen.Y; break; default: Left = screen.X; Top = screen.Height - Height; break; } } else { var newLocation = GetWindowStartPos(new Point(Width, Height)); Left = newLocation.X; Top = newLocation.Y; } } finally { appsListView.EndUpdate(); appsCount.Text = string.Format(Lang.GetText(appsCount), appsListView.Items.Count, appsListView.Items.Count == 1 ? Lang.GetText(nameof(en_US.App)) : Lang.GetText(nameof(en_US.Apps))); if (!appsListView.Focus()) { appsListView.Select(); } } }
private void MenuViewForm_Load(object sender, EventArgs e) { BackColor = Color.FromArgb(byte.MaxValue, Main.Colors.Base.R, Main.Colors.Base.G, Main.Colors.Base.B); if (Main.ScreenDpi > 96) { Font = SystemFonts.CaptionFont; } Icon = Resources.PortableApps_blue; MaximumSize = Screen.FromHandle(Handle).WorkingArea.Size; Lang.SetControlLang(this); for (var i = 0; i < appMenu.Items.Count; i++) { appMenu.Items[i].Text = Lang.GetText(appMenu.Items[i].Name); } if (Main.SetFont(this)) { layoutPanel.Size = new Size(Width - 2, Height - 2); } Main.SetFont(appMenu); layoutPanel.BackgroundImage = Main.BackgroundImage; layoutPanel.BackgroundImageLayout = Main.BackgroundImageLayout; layoutPanel.BackColor = Main.Colors.Base; layoutPanel.SetControlStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer); ControlEx.DrawSizeGrip(layoutPanel, Main.Colors.Base, (o, args) => { Point point; switch (TaskBar.GetLocation(Handle)) { case TaskBar.Location.Right: point = new Point(1, Height - 1); break; case TaskBar.Location.Bottom: point = new Point(Width - 1, 1); break; default: point = new Point(Width - 1, Height - 1); break; } WinApi.NativeHelper.ClientToScreen(Handle, ref point); WinApi.NativeHelper.SetCursorPos((uint)point.X, (uint)point.Y); var inputMouseDown = new WinApi.DeviceInput(); inputMouseDown.Data.Mouse.Flags = 0x2; inputMouseDown.Type = 0; var inputMouseUp = new WinApi.DeviceInput(); inputMouseUp.Data.Mouse.Flags = 0x4; inputMouseUp.Type = 0; WinApi.DeviceInput[] inputs = { inputMouseUp, inputMouseDown }; WinApi.NativeHelper.SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(typeof(WinApi.DeviceInput))); }, (o, args) => { var p = o as PictureBox; if (p == null) { return; } switch (TaskBar.GetLocation(Handle)) { case TaskBar.Location.Right: case TaskBar.Location.Bottom: p.Cursor = Cursors.SizeNESW; break; default: p.Cursor = Cursors.SizeNWSE; break; } }); _hideHScrollBar = Ini.Read("Settings", "Window.HideHScrollBar", false); if (Main.ScreenDpi > 96) { appsListViewPanel.Font = SystemFonts.SmallCaptionFont; } appsListViewPanel.BackColor = Main.Colors.Control; appsListViewPanel.ForeColor = Main.Colors.ControlText; appsListView.BackColor = appsListViewPanel.BackColor; appsListView.ForeColor = appsListViewPanel.ForeColor; appsListView.SetDoubleBuffer(); appsListView.SetMouseOverCursor(); searchBox.BackColor = Main.Colors.Control; searchBox.ForeColor = Main.Colors.ControlText; searchBox.DrawSearchSymbol(Main.Colors.ControlText); SearchBox_Leave(searchBox, EventArgs.Empty); title.ForeColor = Main.BackgroundImage.GetAverageColor().InvertRgb().ToGrayScale(); logoBox.Image = Resources.PortableApps_Logo_gray.Redraw(logoBox.Height, logoBox.Height); appsCount.ForeColor = title.ForeColor; aboutBtn.BackgroundImage = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Help, Main.SystemResourcePath)?.ToBitmap(); aboutBtn.BackgroundImage = aboutBtn.BackgroundImage.SwitchGrayScale($"{aboutBtn.Name}BackgroundImage"); profileBtn.BackgroundImage = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.UserDir, true, Main.SystemResourcePath)?.ToBitmap(); downloadBtn.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Network, Main.SystemResourcePath)?.ToBitmap(); settingsBtn.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.SystemControl, Main.SystemResourcePath)?.ToBitmap(); foreach (var btn in new[] { downloadBtn, settingsBtn }) { btn.BackColor = Main.Colors.Button; btn.ForeColor = Main.Colors.ButtonText; btn.FlatAppearance.MouseDownBackColor = Main.Colors.Button; btn.FlatAppearance.MouseOverBackColor = Main.Colors.ButtonHover; } appMenuItem2.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Uac, Main.SystemResourcePath)?.ToBitmap(); appMenuItem3.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Directory, Main.SystemResourcePath)?.ToBitmap(); appMenuItem5.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.Pin, Main.SystemResourcePath)?.ToBitmap(); appMenuItem7.Image = ResourcesEx.GetSystemIcon(ResourcesEx.IconIndex.RecycleBinEmpty, Main.SystemResourcePath)?.ToBitmap(); appMenu.CloseOnMouseLeave(32); appMenu.EnableAnimation(); appMenu.SetFixedSingle(); var docDir = PathEx.Combine(PathEx.LocalDir, "Documents"); if (Directory.Exists(docDir) && Data.DirIsLink(docDir) && !Data.MatchAttributes(docDir, FileAttributes.Hidden)) { Data.SetAttributes(docDir, FileAttributes.Hidden); } _windowOpacity = Ini.Read("Settings", "Window.Opacity", 95d); if (_windowOpacity.IsBetween(20d, 100d)) { _windowOpacity /= 100d; } else { _windowOpacity = .95d; } var windowFadeInEffect = Ini.Read("Settings", "Window.FadeInEffect", 0); _windowFadeInDuration = Ini.Read("Settings", "Window.FadeInDuration", 100); if (_windowFadeInDuration < 25) { _windowFadeInDuration = 25; } if (_windowFadeInDuration > 750) { _windowFadeInDuration = 750; } var windowWidth = Ini.Read("Settings", "Window.Size.Width", MinimumSize.Width); if (windowWidth > MinimumSize.Width && windowWidth < MaximumSize.Width) { Width = windowWidth; } if (windowWidth > MaximumSize.Width) { Width = MaximumSize.Width; } var windowHeight = Ini.Read("Settings", "Window.Size.Height", MinimumSize.Height); if (windowHeight > MinimumSize.Height && windowHeight < MaximumSize.Height) { Height = windowHeight; } if (windowHeight > MaximumSize.Height) { Height = MaximumSize.Height; } MenuViewForm_Update(); var windowAnimation = windowFadeInEffect == 0 ? WinApi.AnimateWindowFlags.Blend : WinApi.AnimateWindowFlags.Slide; switch (windowAnimation) { case WinApi.AnimateWindowFlags.Blend: return; case WinApi.AnimateWindowFlags.Slide: var windowPosition = Ini.Read("Settings", "Window.DefaultPosition", 0); if (windowPosition == 1) { windowAnimation = WinApi.AnimateWindowFlags.Center; break; } switch (TaskBar.GetLocation(Handle)) { case TaskBar.Location.Left: windowAnimation |= WinApi.AnimateWindowFlags.HorPositive; break; case TaskBar.Location.Top: windowAnimation |= WinApi.AnimateWindowFlags.VerPositive; break; case TaskBar.Location.Right: windowAnimation |= WinApi.AnimateWindowFlags.HorNegative; break; case TaskBar.Location.Bottom: windowAnimation |= WinApi.AnimateWindowFlags.VerNegative; break; default: windowAnimation = WinApi.AnimateWindowFlags.Center; break; } break; } Opacity = _windowOpacity; WinApi.NativeHelper.AnimateWindow(Handle, _windowFadeInDuration, windowAnimation); }