예제 #1
0
        public Wallpaper()
        {
            s = Settings.Instance;
            allScreen = MultiScreenInfo.Instance;
            CanAddAnotherBitmap = true;

            try
            {
                desktop = new Bitmap(allScreen.VirtualDesktop.Width, allScreen.VirtualDesktop.Height);
                gDesktop = Graphics.FromImage(desktop);
                gDesktop.SetHighQuality();
                needFullRedraw = true;

                try
                {
                    if (allScreen.IsChanged == false)
                    {
                        var currentPath = GetCurrentPath();
                        var expectedPath = SafeFilename.Convert(s.SaveFolder, "Current Wallpaper.bmp", true);

                        if (currentPath == expectedPath)
                        {
                            using (var currentDesktop = new Bitmap(currentPath))
                            {
                                //not needed?
                                if (currentDesktop.Size == allScreen.VirtualDesktop.Size)
                                {
                                    gDesktop.DrawImageUnscaled(currentDesktop, 0, 0);
                                    needFullRedraw = false;
                                }
                            }
                        }
                    }
                }
                catch
                {
                }
            }
            catch
            {
                if (gDesktop != null)
                {
                    gDesktop.Dispose();
                    gDesktop = null;
                }

                if (desktop != null)
                {
                    desktop.Dispose();
                    desktop = null;
                }
            }

            if (desktop == null)
            {
                throw new ArgumentException();
            }
        }
예제 #2
0
        internal SourceBitmap(Source from, string url, byte[] bitmapBytes)
        {
            try
            {
                bitmapData = bitmapBytes;
                ms = new MemoryStream(bitmapData);
                bitmap = new Bitmap(ms);
                s = Settings.Instance;
                parent = from;
                Url = url;
            }
            catch
            {
                Dispose(true);

                throw;
            }
        }
예제 #3
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (bitmap != null)
                {
                    var tb = bitmap;
                    bitmap = null;
                    tb.Dispose();
                }

                if (ms != null)
                {
                    var tms = ms;
                    ms = null;
                    tms.Dispose();
                }

                bitmapData = null;
                parent = null;
                s = null;
            }
        }
예제 #4
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (bitmaps != null)
                {
                    var tBitmaps = bitmaps;
                    bitmaps = null;
                    tBitmaps.Clear();
                }

                if (gDesktop != null)
                {
                    var tGDesktop = gDesktop;
                    gDesktop = null;
                    tGDesktop.Dispose();
                }

                if (desktop != null)
                {
                    var tdesktop = desktop;
                    desktop = null;
                    tdesktop.Dispose();
                }

                s = null;
            }
        }