Exemple #1
0
        public void AddBGPreview(ImageSource source)
        {
            currentImage = source.Clone();
            VisualBrush vb = new VisualBrush();
            Image       im = new Image();
            BlurEffect  ef = new BlurEffect();

            ef.Radius = (int)GetBlurLv();

            //FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
            //try
            //{
            //    BitmapImage bitmap = new BitmapImage();
            //    bitmap.BeginInit();
            //    bitmap.StreamSource = stream;
            //    bitmap.EndInit();

            //    im.Source = bitmap;
            //}
            //catch
            //{
            //    stream.Close();
            //    throw;
            //}
            im.Source = source;

            im.Effect  = ef;
            vb.Visual  = im;
            vb.Stretch = Stretch.Uniform;
            vb.Viewbox = new Rect(0.05, 0.05, 0.9, 0.9);
            borderBG_Preview.Background = vb;

            ChatPage.Instance.addBackgroundImage(source, (int)GetBlurLv());
        }
Exemple #2
0
        private static void ReceiveIcons()
        {
            while (CanRun)
            {
                if (CanFetchIcons)
                {
                    foreach (FileViewModel file in FetcherPool)
                    {
                        if (CanFetchIcons)
                        {
                            if (IconHelper.IsImageFile(file.FilePath))
                            {
                                if (CanFetchIcons)
                                {
                                    ImageSource source = IconHelper.LoadBitmapImage(file.FilePath);
                                    source.Freeze();
                                    Application.Current?.Dispatcher?.Invoke(() =>
                                    {
                                        file.Icon = source.Clone();
                                    });
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                Icon icon = IconHelper.GetIconOfFile(file.FilePath, false, false);
                                if (CanFetchIcons)
                                {
                                    ImageSource source = IconHelper.ToImageSource(icon);
                                    source.Freeze();
                                    Application.Current?.Dispatcher?.Invoke(() =>
                                    {
                                        file.Icon = source.Clone();
                                    });
                                }
                                else
                                {
                                    break;
                                }
                            }

                            Thread.Sleep(1);
                        }
                        else
                        {
                            break;
                        }
                    }

                    FetcherPool.Clear();
                    StopFetching();
                }
            }

            Thread.Sleep(1);
        }
        public void Display()
        {
            #region 方向性檢查
            int rotation = 0;
            if (_direction == Map.Direction.East)
            {
                rotation = 90;
            }
            else if (_direction == Map.Direction.South)
            {
                rotation = 180;
            }
            else if (_direction == Map.Direction.West)
            {
                rotation = 270;
            }
            #endregion

            #region 貼圖主程序
            #region 主圖層
            if (_iMainTexture == null)
            {
                MainTextureImage.Source = null;
            }
            else
            {
                TransformedBitmap tran = new TransformedBitmap(
                    (BitmapSource)_iMainTexture.Clone(),
                    new RotateTransform(rotation)
                    );
                MainTextureImage.Source = tran;
            }
            #endregion

            #region 表圖層
            if (_iSurfaceTexture == null)
            {
                SurfaceTextureImage.Source = null;
            }
            else
            {
                TransformedBitmap tran = new TransformedBitmap(
                    (BitmapSource)_iSurfaceTexture.Clone(),
                    new RotateTransform(rotation)
                    );
                SurfaceTextureImage.Source = tran;
            }
            #endregion

            #region 左側貼圖
            LeftSideTextureImage.Source = _iLeftSideTexture;
            #endregion

            #region 右側貼圖
            RightSideTextureImage.Source = _iRightSideTexture;
            #endregion
            #endregion
        }
Exemple #4
0
 public ImageProcessingModel(string path)
 {
     lock (bitmapLock)
     {
         ImageSource     = (Bitmap)Image.FromFile(path);
         baseImageSource = (Bitmap)ImageSource.Clone();
         UpdateHistogram();
         UpdateProjection();
     }
 }
 public void PasteImage(CalendarDay[] destination, ImageSource imageSource)
 {
     if (destination == null || imageSource == null)
     {
         return;
     }
     foreach (var day in destination)
     {
         day.Logo = imageSource.Clone <ImageSource, ImageSource>();
     }
     DayPasted?.Invoke(null, null);
 }
        public Watermark CopyOf()
        {
            if (ImageSource == null)
            {
                return(null);
            }

            var waterMark = new Watermark {
                ImageSource = _imageSource.Clone(), Opacity = _opacity, Size = _size
            };

            return(waterMark);
        }
Exemple #7
0
        private static ImageSource EnsureClonedSource(Image image, ImageSource imageSource)
        {
            if (image == null || imageSource == null)
            {
                return(null);
            }
            if (GetSourceCloned(image))
            {
                return(imageSource); //already a clone
            }
            var cloned = imageSource.Clone();

            SetSourceCloned(image, true);
            return(cloned);
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the Card class.
        /// </summary>
        /// <param name="id">The user assigned identifier of the Card.</param>
        /// <param name="size">The rendering size of the Card.</param>
        /// <param name="position">The position of the Card.</param>
        /// <param name="frontImage">The Front Image of the Card.</param>
        public Card(long id, Size size, Point position, ImageSource frontImage)
        {
            if (back == null)
            {
                throw new InvalidOperationException("BackImage not initialized. The BackImage must be initialized BEFORE creating any Card");
            }

            this.Margin    = new Thickness(position.X, position.Y, 0, 0);
            this.Width     = size.Width;
            this.Height    = size.Height;
            this.IsTabStop = false;
            this.Cursor    = Cursors.Hand;

            this.cid   = id;
            this.front = frontImage.Clone();

            this.revealed = false;
            this.animator = new Animator(this);
        }
		public void PasteImage(CalendarDay[] destination, ImageSource imageSource)
		{
			if (destination == null || imageSource == null) return;
			foreach (var day in destination)
				day.Logo = imageSource.Clone<ImageSource, ImageSource>();
			DayPasted?.Invoke(null, null);
		}
Exemple #10
0
 public CompletionTypeFilter(string completionFilterType, ImageSource icon)
 {
     CompletionFilterType = completionFilterType;
     TheIcon = icon.Clone();
 }
        private static void ReceiveIcons()
        {
            while (CanRun)
            {
                lock (FetcherPool)
                {
                    IsFetchingIcons = true;
                    foreach (FileViewModel file in FetcherPool)
                    {
                        if (IsFetchingIcons)
                        {
                            Icon icon = IconHelper.GetIconOfFile(file.FilePath, true, file.FileType == FileType.Directory ? true : false);
                            if (IsFetchingIcons)
                            {
                                ImageSource source = IconHelper.ToImageSource(icon);
                                source.Freeze();
                                if (IsFetchingIcons)
                                {
                                    Application.Current?.Dispatcher?.Invoke(() =>
                                    {
                                        file.Icon = source.Clone();
                                    });
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    FetcherPool.Clear();
                    IsFetchingIcons = false;
                }


                if (IncommingFetcherPool.Count > 0)
                {
                    lock (IncommingFetcherPool)
                    {
                        lock (FetcherPool)
                        {
                            foreach (FileViewModel file in IncommingFetcherPool)
                            {
                                FetcherPool.Add(file);
                            }
                            IncommingFetcherPool.Clear();
                        }
                    }
                }

                Thread.Sleep(1);
            }
        }