Esempio n. 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();
        }
Esempio n. 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);
                }
            }
        }
Esempio n. 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();
        }
Esempio n. 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();
                }
            }
        }
Esempio n. 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;
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
             }
         }
     }
 }
Esempio n. 8
0
 private void LoadDefaultLogo()
 {
     if (Logo != null)
     {
         Logo.Dispose();
     }
     Logo = BitmapPainter.ConvertToRealColors(DefaultRingImage, false);
 }
Esempio n. 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);
 }
Esempio n. 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);
 }
Esempio n. 11
0
        internal void LoadOptimizedBackgroundImage(Bitmap original)
        {
            if (backgroundImage != null)
            {
                backgroundImage.Dispose();
                backgroundImage = null;
            }

            backgroundImage = BitmapPainter.BuildImageFromSkin(original, Width, Height, defaultMargins);
        }
Esempio n. 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);
 }
Esempio n. 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));
        }
Esempio n. 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();
     }
 }
Esempio n. 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));
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
     }
 }
Esempio n. 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;
 }
Esempio n. 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);
         }
     }
 }
Esempio n. 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();
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
        }
Esempio n. 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);
         }
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 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));
            }
        }
Esempio n. 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;
                    }
                }
            }
        }
Esempio n. 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();
        }
Esempio n. 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;
        }