示例#1
0
        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();
        }
示例#2
0
        protected virtual void DoPaintBackground()
        {
            Rectangle workingArea;
            float     offset    = 0;
            int       imageSize = 0;

            if (GlobalConfig.LowMemory)
            {
                workingArea = new Rectangle(0, 0, (int)maxSize, (int)maxSize);
            }
            else
            {
                imageSize   = (int)(maxSize * scale);
                offset      = (float)((manager.StoneSize - maxSize * scale) / 2);
                workingArea = new Rectangle((int)offset, (int)offset, imageSize, imageSize);
            }

            if ((backgroundBitmap != IntPtr.Zero))
            {
                if (isMouseDown && (!MouseOverSettingsButton))
                {
                    BitmapPainter.DrawImageScaled(backgroundBitmap, window.Buffer.Handle, (int)offset, (int)offset,
                                                  backgroundBitmapWidth, backgroundBitmapHeight, imageSize, imageSize, 180);
                }
                else
                {
                    BitmapPainter.DrawImageScaled(backgroundBitmap, window.Buffer.Handle, (int)offset, (int)offset,
                                                  backgroundBitmapWidth, backgroundBitmapHeight, imageSize, imageSize);
                }
            }
        }
示例#3
0
        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();
        }
示例#4
0
        private void LoadLogo(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                LoadDefaultLogo();
            }
            else
            {
                if (Logo != null)
                {
                    Logo.Dispose();
                    Logo = null;
                }

                string fullName = FileOperations.StripFileName(name);
                if (FileOperations.FileExists(fullName))
                {
                    Bitmap tmp = FastBitmap.FromFile(fullName);
                    if (tmp != null)
                    {
                        Logo = BitmapPainter.ConvertToRealColors(tmp, false);
                        tmp.Dispose();
                    }
                }

                if (Logo == null)
                {
                    LoadDefaultLogo();
                }
            }
        }
示例#5
0
        protected override void AssignDefaultImage()
        {
            Image tmp = null;

            EmptyCustomIcon();
            if (!string.IsNullOrEmpty(resourceName))
            {
                tmp = NativeThemeManager.LoadBitmap(resourceName);
            }
            else
            if (defaultImage != null)
            {
                tmp = BitmapPainter.ConvertToRealColors(defaultImage, false);
            }
            else
            {
                tmp = NativeThemeManager.Load("UnknownFile.png");
            }
            if (tmp != null)
            {
                if (imgLogo.Image != null)
                {
                    imgLogo.Image.Dispose();
                    imgLogo.Image = null;
                }
                imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, false);
                tmp.Dispose();
                tmp = null;
            }
        }
示例#6
0
        /// <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);
            }
        }
示例#7
0
 protected virtual void PaintItem(Graphics g, DockItem item)
 {
     if (item != null)
     {
         if (item.Scale == 1.0f)
         {
             if (item.Alpha == 255)
             {
                 BitmapPainter.DrawImageUnscaled(item.Icon, g, item.X, item.Y);
             }
             else
             {
                 BitmapPainter.DrawImageUnscaled(item.Icon, g, item.X, item.Y, item.Alpha);
             }
         }
         else
         {
             if (item.Alpha == 255)
             {
                 BitmapPainter.DrawImageScaled(item.Icon, g, item.X, item.Y, item.PaintWidth, item.PaintHeight);
             }
             else
             {
                 BitmapPainter.DrawImageScaled(item.Icon, g, item.X, item.Y, item.PaintWidth, item.PaintHeight, item.Alpha);
             }
         }
     }
 }
示例#8
0
 private void LoadDefaultLogo()
 {
     if (Logo != null)
     {
         Logo.Dispose();
     }
     Logo = BitmapPainter.ConvertToRealColors(DefaultRingImage, false);
 }
示例#9
0
 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);
 }
示例#10
0
 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);
 }
示例#11
0
        internal void LoadOptimizedBackgroundImage(Bitmap original)
        {
            if (backgroundImage != null)
            {
                backgroundImage.Dispose();
                backgroundImage = null;
            }

            backgroundImage = BitmapPainter.BuildImageFromSkin(original, Width, Height, defaultMargins);
        }
示例#12
0
 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);
 }
示例#13
0
        internal override void LoadBackground()
        {
            base.LoadBackground();
            if (textField != null)
            {
                textField.Dispose();
                textField = null;
            }

            textField = BitmapPainter.BuildImageFromSkin(searchField, Width - Distance * 2, searchTextHeight + 4, new SkinOffset(12, 12, 12, 12));
        }
示例#14
0
 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();
     }
 }
示例#15
0
 public static BitmapDrawable FromBitmap(Bitmap bitmap)
 {
     if (bitmap == null)
     {
         return(new BitmapDrawable());
     }
     else
     {
         Bitmap tmp = BitmapPainter.ConvertToRealColors(bitmap, false);
         return(new BitmapDrawable(tmp));
     }
 }
示例#16
0
        private static Bitmap GetLogoFromRing(string ringName)
        {
            if (!FileOperations.FileExists(ringName))
            {
                return(null);
            }

            KrentoRing ring   = new KrentoRing(ringName);
            Bitmap     result = BitmapPainter.ConvertToRealColors(ring.Logo, false);

            ring.Dispose();
            return(result);
        }
示例#17
0
 protected override void OnPaint(PaintEventArgs pe)
 {
     if (wallpaper == null)
     {
         base.OnPaint(pe);
     }
     else
     {
         pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
         BitmapPainter.CopyImageScaled((Bitmap)wallpaper, pe.Graphics, 0, 0, this.Width, this.Height);
         base.OnPaint(pe);
     }
 }
示例#18
0
 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;
 }
示例#19
0
 protected override void Paint()
 {
     if (glyph != null)
     {
         if (Alpha == 255)
         {
             BitmapPainter.DrawImageScaled(glyph, Canvas, Left, Top, Width, Height);
         }
         else
         {
             BitmapPainter.DrawImageScaled(glyph, Canvas, Left, Top, Width, Height, Alpha);
         }
     }
 }
示例#20
0
        private void LoadLogo()
        {
            string fullLogoFile = FileOperations.StripFileName(logoFile);

            if (FileOperations.FileExists(fullLogoFile))
            {
                if (imgLogo.Image != null)
                {
                    imgLogo.Image.Dispose();
                }
                Bitmap tmp = FastBitmap.FromFile(fullLogoFile);
                imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, false);
                tmp.Dispose();
            }
        }
示例#21
0
        protected virtual void AssignDefaultImage()
        {
            Image tmp = null;

            customIcon = null;
            tmp        = BitmapPainter.ConvertToRealColors(KrentoRing.DefaultRingImage, false);
            if (tmp != null)
            {
                if (imgLogo.Image != null)
                {
                    imgLogo.Image.Dispose();
                    imgLogo.Image = null;
                }
                imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, true);
            }
        }
示例#22
0
        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);
        }
示例#23
0
 /// <summary>
 /// Updates the target icon if the custom icon file name is provided
 /// </summary>
 private void UpdateTargetIcon()
 {
     if (!string.IsNullOrEmpty(customIcon))
     {
         string fullCustomIcon = FileOperations.StripFileName(customIcon);
         if (FileOperations.FileExists(fullCustomIcon))
         {
             Bitmap tmp = FastBitmap.FromFile(fullCustomIcon);
             if (imgLogo.Image != null)
             {
                 imgLogo.Image.Dispose();
                 imgLogo.Image = null;
             }
             imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, true);
         }
     }
 }
示例#24
0
        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);
        }
示例#25
0
        private void AssignDefaultIcon()
        {
            Image tmp = null;

            if (string.IsNullOrEmpty(edtTarget.Text))
            {
                return;
            }

            customIcon = null;
            tmp        = FileOperations.GetFileLogo(edtTarget.Text);
            if (tmp != null)
            {
                if (imgLogo.Image != null)
                {
                    imgLogo.Image.Dispose();
                    imgLogo.Image = null;
                }
                imgLogo.Image = BitmapPainter.ConvertToRealColors(tmp, true);
            }
        }
示例#26
0
        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);
            }
        }
示例#27
0
        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));
            }
        }
示例#28
0
        protected void FixupCacheLogo()
        {
            //Reload image from cache
            Bitmap cacheOriginal;

            if (FileOperations.FileExists(CacheLogoName))
            {
                if (Logo != null)
                {
                    Logo.Dispose();
                    Logo = null;
                }

                cacheOriginal = FastBitmap.FromFile(CacheLogoName);
                if (cacheOriginal != null)
                {
                    if (cacheOriginal.Width == FileImage.ImageSize)
                    {
                        Logo         = BitmapPainter.ConvertToRealColors(cacheOriginal, true);
                        AnimatedLogo = false;
                    }
                }
            }
        }
示例#29
0
        /// <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();
        }
示例#30
0
        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;
        }