protected override void FixupTargetLogo() { if (Logo != null) { Logo.Dispose(); Logo = null; } if (!string.IsNullOrEmpty(targetName)) { if (NativeMethods.FileExtensionIs(targetName, ".circle")) { Logo = GetLogoFromRing(targetName); } } if (Logo == null) { Logo = BitmapPainter.ConvertToRealColors(KrentoRing.DefaultRingImage, false); } AnimatedLogo = ImageAnimator.CanAnimate(Logo); if (!AnimatedLogo) { Logo = BitmapPainter.ResizeBitmap(Logo, FileImage.ImageSize, FileImage.ImageSize, true); } SaveLogoToCache(); }
/// <summary> /// Loads the image and resizes it /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="newWidth">The new width.</param> /// <param name="newHeight">The new height.</param> /// <returns></returns> public Image LoadImage(string fileName, int newWidth, int newHeight) { if (string.IsNullOrEmpty(fileName)) { return(null); } string imageFile; if (Path.IsPathRooted(fileName)) { imageFile = fileName; } else { imageFile = Path.Combine(currentFolder, fileName); } try { Image tmp = Image.FromFile(imageFile); tmp = BitmapPainter.ResizeBitmap(tmp, newWidth, newHeight, true); return(tmp); } catch { return(null); } }
protected void FixupCustomLogo() { StopAnimation(); if (string.IsNullOrEmpty(customIcon)) { return; } Bitmap newImage = FastBitmap.FromFile(customIcon); if (newImage == null) { return; } if (Logo != null) { Logo.Dispose(); Logo = null; } AnimatedLogo = NativeMethods.IsAnimatedGIF(customIcon); if (AnimatedLogo) { Logo = newImage; } else { Logo = BitmapPainter.ResizeBitmap(newImage, FileImage.ImageSize, FileImage.ImageSize, true); } SaveLogoToCache(); }
public void ReloadButtonDelete(string fileName) { buttonRemoveStone.NormalFace = FastBitmap.FromFile(fileName); if (buttonRemoveStone.NormalFace == null) { buttonRemoveStone.NormalFace = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("ButtonStoneDelete.png"), buttonSize, buttonSize, true); } buttonRemoveStone.SetSize(buttonSize, buttonSize); }
public void ReloadButtonSelect(string fileName) { buttonChangeType.NormalFace = FastBitmap.FromFile(fileName); if (buttonChangeType.NormalFace == null) { buttonChangeType.NormalFace = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("ButtonStoneSelect.png"), buttonSize, buttonSize, true); } buttonChangeType.SetSize(buttonSize, buttonSize); }
public void ReloadButtonResources() { buttonAbout.NormalFace = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("ButtonStoneAbout.png"), buttonSize, buttonSize, true); buttonChangeType.NormalFace = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("ButtonStoneSelect.png"), buttonSize, buttonSize, true); buttonConfigureStone.NormalFace = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("ButtonStoneEdit.png"), buttonSize, buttonSize, true); buttonRemoveStone.NormalFace = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("ButtonStoneDelete.png"), buttonSize, buttonSize, true); buttonAbout.SetSize(buttonSize, buttonSize); buttonChangeType.SetSize(buttonSize, buttonSize); buttonConfigureStone.SetSize(buttonSize, buttonSize); buttonRemoveStone.SetSize(buttonSize, buttonSize); }
protected internal void FixupResourceLogo() { if (Logo == null) { Bitmap tmp = NativeThemeManager.LoadBitmap(ResourceName); Logo = BitmapPainter.ResizeBitmap(tmp, FileImage.ImageSize, FileImage.ImageSize); tmp.Dispose(); AnimatedLogo = false; SaveLogoToCache(); } }
public Pulsar() : base() { Name = "Pulsar"; pulsarPen = new Pen(Brushes.Pink, 2.0f); frequency = 100; TopMostWindow = true; surfaceImage = NativeThemeManager.LoadBitmap("Pulsar.png"); surfaceImage = BitmapPainter.ResizeBitmap(surfaceImage, Dimension, Dimension, true); surfaceCache = new CachedBitmap(surfaceImage, this.Canvas); Text = "Krento Pulsar"; VerticalShift = -1; HorizontalShift = 1; }
protected virtual Bitmap ProcessImage(Image image) { Bitmap result; Bitmap originalResult; int mirrorSize; float denomination = 1.0f; if (image == null) { return(null); } if (dockManager.UseDenomination) { denomination = (float)((float)image.Width / settings.IconSize); result = BitmapPainter.ConvertToRealColors(image, false); } else { if ((image.Width != settings.IconSize) || (image.Height != settings.IconSize)) { result = BitmapPainter.ResizeBitmap(image, settings.IconSize, settings.IconSize); } else { result = BitmapPainter.ConvertToRealColors(image, false); } } if (settings.ReflectionDepth > 0) { if (dockManager.UseDenomination) { mirrorSize = (int)(settings.ReflectionDepth * denomination); } else { mirrorSize = settings.ReflectionDepth; } originalResult = result; result = (Bitmap)BitmapPainter.CreateReflectionImage(result, mirrorSize); originalResult.Dispose(); } return(result); }
public static Image DownloadSiteIcon(string siteAddress) { if (File.Exists(GlobalConfig.SiteImagesFileName)) { Uri siteUri = new Uri(siteAddress); string imageName = null; string siteHost = siteUri.Host; string[] parts = siteHost.Split('.'); MemIniFile iniFile = new MemIniFile(GlobalConfig.SiteImagesFileName); try { iniFile.Load(); foreach (var part in parts) { imageName = iniFile.ReadString("site", part); if (!string.IsNullOrEmpty(imageName)) { if (FileOperations.FileExists(imageName)) { return(BitmapPainter.ResizeBitmap(FastBitmap.FromFile(FileOperations.StripFileName(imageName)), FileImage.ImageSize, FileImage.ImageSize, true)); } } } //no image for url part, return default image if (iniFile.SectionExists("default")) { imageName = iniFile.ReadString("default", "url"); if (!string.IsNullOrEmpty(imageName)) { if (FileOperations.FileExists(imageName)) { return(BitmapPainter.ResizeBitmap(FastBitmap.FromFile(FileOperations.StripFileName(imageName)), FileImage.ImageSize, FileImage.ImageSize, true)); } } } } finally { iniFile.Dispose(); } } return(null); }
public static Image Load(string resourceName, int width, int height) { Bitmap temp = null; try { temp = FastBitmap.FromNativeResource(resourceName); } catch { temp = null; } if (temp != null) { return(BitmapPainter.ResizeBitmap(temp, width, height, true)); } else { return(null); } }
public void AddCustomIcon(string fileName) { bool found = false; if (!string.IsNullOrEmpty(fileName)) { if (FileOperations.FileExists(fileName)) { found = true; } } if (found) { Bitmap tmp = FastBitmap.FromFile(fileName); icons.Add(BitmapPainter.ResizeBitmap(tmp, 32, 32, true)); } else { icons.Add(BitmapPainter.ResizeBitmap(NativeThemeManager.Load("SmallKrento.png"), 32, 32, true)); } }
/// <summary> /// Updates the logo URL. This method must be used only in case if custom logo is not /// present or not provided. Check for custom logo using WebsiteImages.CustomSiteIcon method /// and compare result with empty string. /// </summary> /// <param name="newTarget">The new target.</param> private void UpdateLogoURL(string newTarget) { StopAnimation(); Bitmap tmpBitmap = (Bitmap)FileOperations.GetSiteLogo(newTarget); if (Logo != null) { Logo.Dispose(); Logo = null; } AnimatedLogo = ImageAnimator.CanAnimate(tmpBitmap); if (!AnimatedLogo) { Logo = BitmapPainter.ResizeBitmap(tmpBitmap, FileImage.ImageSize, FileImage.ImageSize, true); } else { Logo = tmpBitmap; } SaveLogoToCache(); }
protected override void BuildItems() { FolderItem item; string fullTarget; DisposeItems(); string fullPath = FileOperations.StripFileName(path); string[] files = Directory.GetFileSystemEntries(fullPath); HeaderText = Path.GetFileNameWithoutExtension(fullPath); item = new FolderItem(fullPath); item.Logo = BitmapPainter.ResizeBitmap(NativeThemeManager.LoadBitmap("Folder.png"), FileImage.ImageSize, FileImage.ImageSize, true); Items.Add(item); int totalItems = 0; for (int i = 0; i < files.Length; i++) { fullTarget = files[i]; if ((File.GetAttributes(fullTarget) & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } totalItems++; if (totalItems > Limit) { totalItems = Limit; break; } item = new FolderItem(fullTarget); if (TextHelper.SameText(Path.GetExtension(fullTarget), ".circle")) { item.Logo = GetLogoFromRing(fullTarget); } if (item.Logo == null) { item.Logo = (Bitmap)FileImage.FileNameImage(fullTarget); } if (item.Logo == null) { if (FileOperations.DirectoryExists(fullTarget)) { item.Logo = NativeThemeManager.LoadBitmap("Folder.png"); } else { item.Logo = NativeThemeManager.LoadBitmap("UnknownFile.png"); } } Items.Add(item); } files = null; }
/// <summary> /// Loads the image and resizes it proportionally /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="newWidth">The new width.</param> /// <param name="newHeight">The new height.</param> /// <param name="fillColor">Color to fill extra area</param> /// <returns></returns> public Image LoadImage(string fileName, int newWidth, int newHeight, Color fillColor) { if (string.IsNullOrEmpty(fileName)) { return(null); } string imageFile; if (Path.IsPathRooted(fileName)) { imageFile = fileName; } else { imageFile = Path.Combine(currentFolder, fileName); } try { Image tmp = Image.FromFile(imageFile); int sourceWidth = tmp.Width; int sourceHeight = tmp.Height; float nPercent = 0; float nPercentW = 0; float nPercentH = 0; nPercentW = ((float)newWidth / (float)sourceWidth); nPercentH = ((float)newHeight / (float)sourceHeight); if (nPercentH < nPercentW) { nPercent = nPercentH; } else { nPercent = nPercentW; } int destWidth = (int)(sourceWidth * nPercent); int destHeight = (int)(sourceHeight * nPercent); tmp = BitmapPainter.ResizeBitmap(tmp, destWidth, destHeight, true); Bitmap result = new Bitmap(newWidth, newHeight, PixelFormat.Format32bppPArgb); using (Graphics gr = Graphics.FromImage(result)) { gr.InterpolationMode = GlobalConfig.InterpolationMode; using (SolidBrush br = new SolidBrush(fillColor)) { gr.FillRectangle(br, new Rectangle(0, 0, newWidth, newHeight)); } gr.DrawImage(tmp, (int)((newWidth - destWidth) / 2), (int)((newHeight - destHeight) / 2), destWidth, destHeight); } tmp.Dispose(); return(result); } catch { return(null); } }
public void ActivateEngine() { TraceDebug.Trace("Activate Engine"); bool doCheck = GlobalSettings.CheckUpdate; bool disableCheck = false; Visible = false; NativeMethods.ShowWindow(this.Handle, 0); NativeMethods.RemoveSystemMenu(this.Handle); #region First Instance Execution if (context.FirstInstance) { if (!string.IsNullOrEmpty(GlobalSettings.IconName)) { Icon customIcon = null; if (FileOperations.FileExists(GlobalSettings.IconName)) { Icon loadIcon = new Icon(FileOperations.StripFileName(GlobalSettings.IconName)); try { customIcon = (Icon)loadIcon.Clone(); } finally { loadIcon.Dispose(); loadIcon = null; } notifyIcon.Icon = customIcon; //this.Icon = customIcon; } } if (splashScreen != null) { splashScreen.Show(); } if (!string.IsNullOrEmpty(GlobalSettings.GlyphName)) { if (FileOperations.FileExists(GlobalSettings.GlyphName)) { Bitmap tmp = FastBitmap.FromFile(GlobalSettings.GlyphName); notifier.Glyph = BitmapPainter.ResizeBitmap(tmp, notifier.GlyphSize, notifier.GlyphSize, true); } } if (notifier.Glyph == null) { notifier.Glyph = NativeThemeManager.Load("BigKrento.png"); } context.Manager.SetHookMessage(context); ReloadAll(); PreparePulsar(); context.Manager.Rotate(0); if (!GlobalSettings.ShowManagerButtons) { context.Manager.DrawText(SR.KrentoWelcome); } context.Manager.Update(); context.Manager.Visible = false; notifyIcon.Visible = GlobalSettings.ShowTrayIcon; if (splashScreen != null) { if (KrentoContext.FirstRun) { splashScreen.Hide(); NativeMethods.PostMessage(InteropHelper.MainWindow, NativeMethods.CM_SPLASHCLOSE, IntPtr.Zero, IntPtr.Zero); } else { splashScreen.Close(200); } } systemReady = true; string keyMessage = HotKeyMessage; notifier.Caption = SR.KrentoWelcome; if (GlobalSettings.MouseHook == MouseHookButton.None) { notifier.Text = SR.WelcomeMessage(keyMessage, "", ""); } else { string mouseText = ""; switch (GlobalSettings.MouseHook) { case MouseHookButton.Wheel: mouseText = MouseKeyMessage + SR.MouseWheelButton; break; case MouseHookButton.XButton1: mouseText = MouseKeyMessage + SR.MouseXButton1; break; case MouseHookButton.XButton2: mouseText = MouseKeyMessage + SR.MouseXButton2; break; default: mouseText = ""; break; } notifier.Text = SR.WelcomeMessage(keyMessage, SR.OrClick, mouseText); } //Only show popup window when asked if (GlobalSettings.ShowPopupAlerts) { if (GlobalConfig.LowMemory) { notifyIcon.BalloonTipTitle = notifier.Caption; notifyIcon.BalloonTipText = notifier.Text; notifyIcon.BalloonTipIcon = ToolTipIcon.Info; notifyIcon.ShowBalloonTip(5000); } else { notifier.Show(); } } Manager.ClearUnusedMemory(); #region manage autoupdate DateTime lastCheck = Settings.Default.LastCheck; TimeSpan ts = DateTime.Now - lastCheck; if (ts.Days >= 7) { Settings.Default.LastCheck = DateTime.Now; Settings.Default.Save(); if (Settings.Default.AskForCheck) { UpdateDialog upd = new UpdateDialog(); try { upd.ShowDialog(); doCheck = (upd.DialogResult == DialogResult.OK); disableCheck = (upd.btnDisable.Checked); if (disableCheck) { GlobalSettings.CheckUpdate = doCheck; Settings.Default.AskForCheck = false; Settings.Default.Save(); } } finally { upd.Dispose(); } } if ((GlobalSettings.CheckUpdate) && (doCheck)) { checker.CheckNewVersion(); } } #endregion if (GlobalSettings.StartVisible || KrentoContext.FirstRun) { InteropHelper.ShowDesktop(); if (!Manager.Visible) { if (KrentoContext.FirstRun) { Manager.ShowAndExecute(Manager.SimulateWheelRotation); } else { ChangeVisibility(); } } } } #endregion else { systemReady = false; context.FirstInstance = false; } }
/// <summary> /// Get the image for the specified file type. /// You can provide the full file name, for example doc1.docx /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns>Image or null. The size of the image = size of the icon</returns> private static Image FileTypeImage(string fileName) { Image result = null; Icon icon = null; IconFlags flags; IntPtr hIcon = IntPtr.Zero; IntPtr shellInfo; IconSize size; IImageList iImageList = null; if (!string.IsNullOrEmpty(fileName)) { SHFILEINFO fileInfo = new SHFILEINFO(); fileName = FileSearch.FullPath(fileName); if (FileOperations.FileOrFolderExists(fileName)) { fileInfo.dwAttributes = (uint)File.GetAttributes(fileName); } //first try to query the icon location and get the icon from there flags = IconFlags.LargeIcon | IconFlags.IconLocation | IconFlags.UseFileAttributes; shellInfo = NativeMethods.SHGetFileInfo(fileName, 0, ref fileInfo, (uint)Marshal.SizeOf(fileInfo), flags); if (shellInfo == (IntPtr)1) { //we have the result, try to parse it if (FileOperations.FileIsIcon(fileInfo.szDisplayName)) { icon = new Icon(fileInfo.szDisplayName); result = ConvertIconToBitmap(icon); icon.Dispose(); return(result); } else if (FileOperations.FileIsExe(fileName)) { result = ExtractIconFromExecutable(fileInfo.szDisplayName, (int)fileInfo.iIcon); } } if (result != null) { return(result); } //if we have no result: continue to search using system image list flags = IconFlags.LargeIcon | IconFlags.SysIconIndex; if (!FileOperations.FileOrFolderExists(fileName)) { flags = flags | IconFlags.UseFileAttributes; } shellInfo = NativeMethods.SHGetFileInfo(fileName, 0, ref fileInfo, (uint)Marshal.SizeOf(fileInfo), flags); if (shellInfo == IntPtr.Zero) { return(null); } size = IconSize.ExtraLarge; if (InteropHelper.RunningOnXP) { Guid iidImageList = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950"); NativeMethods.SHGetImageList( (int)size, ref iidImageList, ref iImageList ); // the image list handle is the IUnknown pointer, but // using Marshal.GetIUnknownForObject doesn't return // the right value. It really doesn't hurt to make // a second call to get the handle: NativeMethods.SHGetImageListHandle((int)size, ref iidImageList, ref shellInfo); } if (iImageList == null) { hIcon = NativeMethods.ImageList_GetIcon(shellInfo, (int)fileInfo.iIcon, NativeMethods.ILD_TRANSPARENT); } else { iImageList.GetIcon((int)fileInfo.iIcon, (int)NativeMethods.ILD_TRANSPARENT, ref hIcon); } if (hIcon == IntPtr.Zero) { return(null); } icon = Icon.FromHandle(hIcon); //do not destroy icon from the system image list //NativeMethods.DestroyIcon(hIcon); result = ConvertIconToBitmap(icon); } if (icon != null) { icon.Dispose(); } if (result != null) { result = BitmapPainter.ResizeBitmap(result, imageSize, imageSize, true); } return(result); }
private static Image FileNameImageInternal(string fileName) { Image result = null; Icon icon = null; if (!string.IsNullOrEmpty(fileName)) { fileName = FileOperations.StripFileName(fileName); //if we have only name of the file without path //try to find it in the search path of Windows fileName = FileSearch.FullPath(fileName); if (!FileOperations.FileOrFolderExists(fileName)) { result = FileTypeImage(fileName); return(result); } //if this is a link to executable with original //executable icon if (FileOperations.FileIsLink(fileName)) { result = TryExtractImageFromShellLink(fileName); if (result != null) { return(result); } } if (FileOperations.FileIsImage(fileName)) { try { result = Image.FromFile(fileName); result = BitmapPainter.ResizeBitmap(result, imageSize, imageSize, true); } catch { result = null; } if (result != null) { return(result); } } // 1. The file is icon // 2. The file is exe or dll // 3. The file is a shell link .lnk // 4. Other file types if (FileOperations.FileIsIcon(fileName)) { //Simply load icon from file icon = new Icon(fileName); } else //Extract icon from exe or dll directly if (FileOperations.FileIsExe(fileName)) { return(ExtractIconFromExecutable(fileName)); } else { result = FileTypeImage(fileName); return(result); } result = ConvertIconToBitmap(icon); } if (icon != null) { icon.Dispose(); } return(result); }
public static Image VirtualFolderImage(int folderId) { IntPtr pidl; Image result = null; IntPtr shellInfo; IconFlags flags; SHFILEINFO fileInfo = new SHFILEINFO(); Icon icon = null; IntPtr hIcon = IntPtr.Zero; IconSize size; IImageList iImageList = null; if (NativeMethods.SHGetSpecialFolderLocation(IntPtr.Zero, folderId, out pidl) != 0) { return(null); } flags = IconFlags.PIDL | IconFlags.LargeIcon | IconFlags.SysIconIndex | IconFlags.UseFileAttributes; shellInfo = NativeMethods.SHGetFileInfo(pidl, 0, ref fileInfo, (uint)Marshal.SizeOf(fileInfo), flags); if (shellInfo != IntPtr.Zero) { size = IconSize.ExtraLarge; if (InteropHelper.RunningOnXP) { Guid iidImageList = new Guid("46EB5926-582E-4017-9FDF-E8998DAA0950"); NativeMethods.SHGetImageList( (int)size, ref iidImageList, ref iImageList ); // the image list handle is the IUnknown pointer, but // using Marshal.GetIUnknownForObject doesn't return // the right value. It really doesn't hurt to make // a second call to get the handle: NativeMethods.SHGetImageListHandle((int)size, ref iidImageList, ref shellInfo); } if (iImageList == null) { hIcon = NativeMethods.ImageList_GetIcon(shellInfo, (int)fileInfo.iIcon, NativeMethods.ILD_TRANSPARENT); } else { iImageList.GetIcon((int)fileInfo.iIcon, (int)NativeMethods.ILD_TRANSPARENT, ref hIcon); } if (hIcon != IntPtr.Zero) { icon = (Icon)Icon.FromHandle(hIcon); //NativeMethods.DestroyIcon(hIcon); result = ConvertIconToBitmap(icon); } } Marshal.FreeCoTaskMem(pidl); if (icon != null) { icon.Dispose(); icon = null; } if (result != null) { result = BitmapPainter.ResizeBitmap(result, imageSize, imageSize, true); } return(result); }
private void SettingsDialog_Load(object sender, EventArgs e) { CultureInfo culture; DockItem item; Image icon; fish.UseDenomination = true; fish.Settings.MaxScale = 1.5; fish.Settings.ScaleCaption = false; fish.ItemsLayout = ItemsLayout.Default; fish.Settings.LeftMargin = 12; fish.Settings.IconsSpacing = 34; fish.DockOrientation = DockOrientation.Vertical; icon = NativeThemeManager.Load("SmallKrento.png"); item = fish.AddItem(SR.General, icon); item.Tag = 1; icon.Dispose(); icon = NativeThemeManager.Load("exec.png"); item = fish.AddItem(SR.Tuning, icon); item.Tag = 2; icon.Dispose(); icon = BitmapPainter.ResizeBitmap(KrentoRing.DefaultRingImage, 48, 48, false); item = fish.AddItem(SR.Circle, icon); item.Tag = 3; icon.Dispose(); activeWorkplace = workplaceGeneral; workplaceGeneral.Visible = true; workplaceManager.Visible = false; workplaceTuning.Visible = false; workplaceGeneral.BringToFront(); #if PORTABLE edtRunWindows.Enabled = false; btnCircle.Enabled = false; #else edtRunWindows.Checked = InteropHelper.GetStartup("Krento"); #endif if ((GlobalSettings.Modifiers == Keys.LWin) && (GlobalSettings.Shortcut == Keys.S)) { edtUseDefault.Checked = true; edtHotKey.Enabled = false; } else { edtUseDefault.Checked = false; edtHotKey.Enabled = true; this.modifierHotKeys = GlobalSettings.Modifiers; this.shortcut = GlobalSettings.Shortcut; } switch (GlobalSettings.MouseHook) { case MouseHookButton.Wheel: rbWheel.Checked = true; break; case MouseHookButton.XButton1: rbXButton1.Checked = true; break; case MouseHookButton.XButton2: rbXButton2.Checked = true; break; } edtShiftButton.Checked = ((GlobalSettings.MouseModifiers & Keys.Shift) != 0); edtAltButton.Checked = ((GlobalSettings.MouseModifiers & Keys.Alt) != 0); edtControlButton.Checked = ((GlobalSettings.MouseModifiers & Keys.Control) != 0); edtShowHintWindow.Checked = GlobalSettings.ShowStoneHint; edtShowAlerts.Checked = GlobalSettings.ShowPopupAlerts; edtTrayIcon.Checked = GlobalSettings.ShowTrayIcon; edtShowSplashScreen.Checked = GlobalSettings.ShowSplashScreen; edtManagerButtons.Checked = GlobalSettings.ShowManagerButtons; edtUseSounds.Checked = GlobalSettings.UseSound; edtHideOnClick.Checked = GlobalSettings.HideOnClick; edtRotateOnClick.Checked = GlobalSettings.RotateOnClick; edtCheckUpdates.Checked = GlobalSettings.CheckUpdate; edtLiveReflection.Checked = GlobalSettings.LiveReflection; edtDesktopClick.Checked = GlobalSettings.DesktopClick; edtRightClick.Checked = GlobalSettings.UseRightClick; edtCircleSelector.Checked = GlobalSettings.CircleSelector; edtUseMouse.Checked = GlobalSettings.UseMouseActivation; edtKeyboardActivation.Checked = GlobalSettings.UseKeyboardActivation; edtStonesNumber.Value = GlobalSettings.DefaultStonesNumber; goodNumber = Math.Min(GlobalSettings.FadeDelay, (int)edtFadeDelay.Maximum); edtFadeDelay.Value = Math.Max(goodNumber, edtFadeDelay.Minimum); goodNumber = Math.Min(GlobalSettings.Radius, (int)edtRadius.Maximum); edtRadius.Value = Math.Max(goodNumber, edtRadius.Minimum); goodNumber = Math.Min(GlobalSettings.WindowHeight, (int)edtWindowHeight.Maximum); edtWindowHeight.Value = Math.Max(goodNumber, edtWindowHeight.Minimum); goodNumber = Math.Min(GlobalSettings.WindowWidth, (int)edtWindowWidth.Maximum); edtWindowWidth.Value = Math.Max(goodNumber, edtWindowWidth.Minimum); goodNumber = Math.Min(GlobalSettings.Transparency, (int)edtTransparency.Maximum); edtTransparency.Value = Math.Max(goodNumber, edtTransparency.Minimum); goodNumber = Math.Min(GlobalSettings.StoneSize, (int)edtStoneSize.Maximum); edtStoneSize.Value = Math.Max(goodNumber, edtStoneSize.Minimum); goodNumber = Math.Min(GlobalSettings.IconSize, (int)edtIconSize.Maximum); edtIconSize.Value = Math.Max(goodNumber, edtIconSize.Minimum); switch (KrentoContext.MainForm.Manager.CircleLocation) { case CircleLocation.Point: rbMousePosition.Checked = true; break; case CircleLocation.ScreenCenter: rbScreenCenter.Checked = true; break; case CircleLocation.Fixed: rbFixed.Checked = true; break; default: break; } if (NativeMethods.IsWow64()) { edtDesktopClick.Enabled = false; } cbLanguage.ValueMember = "NativeName"; //"EnglishName" cbLanguage.Items.Add(new CultureInfo("en-US")); languageIndex = 0; string[] langFiles = Directory.GetFiles(GlobalConfig.LanguagesFolder, "*.lng"); foreach (string lang in langFiles) { string langName = Path.GetFileNameWithoutExtension(lang); if (!TextHelper.SameText(langName, "en-US")) { try { culture = new CultureInfo(langName); } catch { culture = null; } if (culture != null) { idx = cbLanguage.Items.Add(culture); if (TextHelper.SameText(langName, GlobalSettings.Language)) { languageIndex = idx; } } } } cbLanguage.SelectedIndex = languageIndex; KrentoSkinInfo defaultSkin = new KrentoSkinInfo(null, SR.DefaultSkin); cbMenuSkins.Items.Add(defaultSkin); menuSkinIndex = 0; string GlobalMenuSkinFile = ""; if (!string.IsNullOrEmpty(GlobalSettings.MenuSkin)) { GlobalMenuSkinFile = FileOperations.StripFileName(GlobalSettings.MenuSkin); } string[] skinFiles = Directory.GetFiles(GlobalConfig.MenusFolder, "*.ini", SearchOption.AllDirectories); foreach (string skinFile in skinFiles) { KrentoSkinInfo skin = new KrentoSkinInfo(skinFile, KrentoMenuSkin.GetSkinCaption(skinFile)); idx = cbMenuSkins.Items.Add(skin); if (TextHelper.SameText(skin.FileName, GlobalMenuSkinFile)) { menuSkinIndex = idx; } } cbMenuSkins.ValueMember = "Caption"; cbMenuSkins.SelectedIndex = menuSkinIndex; menuSkinFile = GlobalSettings.MenuSkin; this.Text = SR.Settings; btnCancel.Text = SR.Cancel; this.hintInfo.SetToolTip(this.btnCancel, SR.FileConfigCancelHint); btnOK.Text = SR.OK; gbRunWindows.Text = SR.KrentoStartup; edtRunWindows.Text = SR.RunWithWindows; gbKeyboard.Text = SR.KeyboardActivation; edtUseDefault.Text = SR.UseDefaultKey; gbMouseActivation.Text = SR.MouseActivation; hintInfo.SetToolTip(gbMouseActivation, SR.MouseActivation); edtControlButton.Text = SR.ButtonControl; this.hintInfo.SetToolTip(this.edtControlButton, SR.ButtonControl); edtShiftButton.Text = SR.ButtonShift; this.hintInfo.SetToolTip(this.edtShiftButton, SR.ButtonShift); edtAltButton.Text = SR.ButtonAlt; this.hintInfo.SetToolTip(this.edtAltButton, SR.ButtonAlt); gbRingLocation.Text = SR.RingLocation; rbScreenCenter.Text = SR.ScreenCenter; rbMousePosition.Text = SR.MouseCursorPosition; btnCircle.Text = SR.AssociateRing; lblHint.Text = SR.UseCtrlTab; rbXButton1.Text = SR.MouseActionOneButton; rbXButton2.Text = SR.MouseActionTwoButton; rbWheel.Text = SR.MouseWheelClick; gbPersonalization.Text = SR.Personalization; gbUserFolders.Text = SR.UserFolders; gbMaintainance.Text = SR.Maintainance; edtTrayIcon.Text = SR.ShowTrayIcon; edtShowSplashScreen.Text = SR.ShowSplashScreen; edtShowAlerts.Text = SR.ShowPopupAlerts; btnOpenSkins.Text = SR.OpenSkinsFolder; btnOpenStones.Text = SR.OpenStonesFolder; btnOpenData.Text = SR.OpenDataFolder; btnOpenCache.Text = SR.OpenCacheFolder; btnClearCache.Text = SR.ClearCache; gbLanguage.Text = SR.Language; lblWindowHeight.Text = SR.WindowHeight; lblWindowWidth.Text = SR.WindowWidth; lblRadius.Text = SR.Radius; lblStoneSize.Text = SR.StoneSize; lblTransparency.Text = SR.Trancparency; lblFadeDelay.Text = SR.FadeDelay; gbMenuSkins.Text = SR.MenuSkins; gbManager.Text = SR.Circle; btnReset.Text = SR.ResetToDefault; btnBackup.Text = SR.BackupData; btnSettings.Text = SR.AdvancedSettings + "..."; edtKeyboardActivation.Text = SR.ActivateUsingKeyboard; edtUseMouse.Text = SR.ActivateUsingMouse; rbFixed.Text = SR.FixedPosition; edtCircleSelector.Text = SR.ShowSelector; edtDesktopClick.Text = SR.DesktopClick; edtRightClick.Text = SR.RightButtonActivation; lblStonesNumber.Text = SR.StonesNumber; lblIconSize.Text = SR.IconSize; edtRotateOnClick.Text = SR.RotateOnClick; edtShowCircleStartup.Text = SR.ActivateOnStart; edtUseSounds.Text = SR.UseSounds; edtCheckUpdates.Text = SR.CheckUpdates; edtLiveReflection.Text = SR.LiveReflection; edtManagerButtons.Text = SR.ShowManagerButtons; edtShowHintWindow.Text = SR.ShowStonesHint; edtHideOnClick.Text = SR.HideOnClick; }
private void UpdateLogoFile(string newTarget) { StopAnimation(); if (Logo != null) { Logo.Dispose(); Logo = null; } string fullTarget = FileOperations.StripFileName(newTarget); if (!FileOperations.IsValidPathName(fullTarget)) { Logo = NativeThemeManager.LoadBitmap("UnknownFile.png"); } else { if (!string.IsNullOrEmpty(fullTarget)) { if (NativeMethods.FileExtensionIs(fullTarget, ".circle")) { Logo = GetLogoFromRing(fullTarget); } } if (Logo == null) { try { Logo = (Bitmap)FileImage.FileNameImage(fullTarget); } catch { Logo = null; } } if (Logo == null) { if (FileOperations.DirectoryExists(fullTarget)) { Logo = NativeThemeManager.LoadBitmap("Folder.png"); } else { Logo = FileOperations.GetExtensionLogo(fullTarget); if (Logo == null) { Logo = NativeThemeManager.LoadBitmap("UnknownFile.png"); } } } } AnimatedLogo = ImageAnimator.CanAnimate(Logo); if (!AnimatedLogo) { Logo = BitmapPainter.ResizeBitmap(Logo, FileImage.ImageSize, FileImage.ImageSize, true); } SaveLogoToCache(); }