Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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();
                }
            }
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
 private void LoadDefaultLogo()
 {
     if (Logo != null)
     {
         Logo.Dispose();
     }
     Logo = BitmapPainter.ConvertToRealColors(DefaultRingImage, false);
 }
Exemplo n.º 5
0
 public static BitmapDrawable FromBitmap(Bitmap bitmap)
 {
     if (bitmap == null)
     {
         return(new BitmapDrawable());
     }
     else
     {
         Bitmap tmp = BitmapPainter.ConvertToRealColors(bitmap, false);
         return(new BitmapDrawable(tmp));
     }
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
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);
         }
     }
 }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
            }
        }
Exemplo n.º 12
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;
                    }
                }
            }
        }
Exemplo n.º 13
0
        protected internal override void ExecuteConfigurationCall()
        {
            Manager.SuppressHookMessage(true);
            try
            {
                StoneFileConfig config = new StoneFileConfig();
                try
                {
                    config.Target = this.TargetName;
                    if (!TextHelper.SameText(TargetDescription, SR.MissingFile))
                    {
                        config.Description = this.TargetDescription;
                    }

                    config.CommandLine = this.TargetParameters;
                    config.Image       = (Image)BitmapPainter.ConvertToRealColors(this.Logo, false);
                    config.CustomIcon  = this.CustomIcon;
                    config.Argument    = this.ArgumentDescription;

                    if (config.ShowDialog() == DialogResult.OK)
                    {
                        if (!string.IsNullOrEmpty(config.Target))
                        {
                            this.targetName       = config.Target;
                            this.targetParameters = config.CommandLine;

                            if (!string.IsNullOrEmpty(targetParameters))
                            {
                                targetParameters = FileOperations.StripFileName(targetParameters);
                            }

                            string newDescription = config.Description;
                            if (string.IsNullOrEmpty(newDescription))
                            {
                                if (string.IsNullOrEmpty(TranslationId))
                                {
                                    newDescription = FileOperations.GetFileDescription(targetName);
                                }
                            }
                            this.TargetDescription = newDescription;

                            this.argumentDescription = config.Argument;
                            CustomIcon = config.CustomIcon;

                            //If Target is missing the description is not stored
                            DestroyLogoImage();
                            FixupConfiguration();
                            Update(true);
                            Manager.RedrawScreenHint();
                        }

                        Manager.FlushCurrentCircle();
                    }
                }
                finally
                {
                    config.Dispose();
                }
            }
            finally
            {
                Manager.SuppressHookMessage(false);
            }
        }