Exemple #1
0
        /// <summary>
        /// Apply Blur Effect on the window
        /// </summary>
        /// <param name="win">parent window</param>
        public static void ApplyEffect(this System.Windows.Window win)
        {
            // Create new effective objects
            var objBlur = new System.Windows.Media.Effects.BlurEffect { Radius = 5 };
            var mask = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.DarkGray) { Opacity = 50 };

            // Buffering ...
            effectBuffer = win.Effect;
            brushBuffer = win.OpacityMask;

            // Change this.win effective objects
            win.Dispatcher.Invoke(new Action(delegate { win.Effect = objBlur; }), System.Windows.Threading.DispatcherPriority.Normal);
            win.Dispatcher.Invoke(new Action(delegate { win.OpacityMask = mask; }), System.Windows.Threading.DispatcherPriority.Normal);
        }
 public MainWindow()
 {
     InitializeComponent();
     bl       = FactoryBl.getBL();
     mainBlur = new System.Windows.Media.Effects.BlurEffect();
 }
Exemple #3
0
 /// <summary>
 /// Apply Blur Effect on the window
 /// </summary>
 /// <param name=”win”></param>
 internal static void ApplyBlurEffect(System.Windows.Window win)
 {
     System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
     objBlur.Radius = 4;
     win.Effect     = objBlur;
 }
Exemple #4
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            string        id           = ((Button)sender).Tag.ToString();
            BUS_Receipt   busReceipt   = new BUS_Receipt();
            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeleteReceipt");

            if ((DateTime.Now - busReceipt.GetCreateDayByID(id)).TotalDays > limitDay)
            {
                MessageBox.Show($"Không thể xóa do hóa đơn đã được tạo cách đây hơn {limitDay} ngày!");
                return;
            }

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Xóa hóa đơn",
                Content               = new PopupDeleteConfirm($"Bạn có chắc chắn muốn xóa hóa đơn\n{id} không?", id, 1),
                Width                 = 420,
                Height                = 220,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();


            int empCount = busReceipt.CountReceipt(start, end, keyword);

            if (empCount % limitRow == 0)
            {
                lblMaxPage.Content = empCount / limitRow;
            }
            else
            {
                lblMaxPage.Content = empCount / limitRow + 1;
            }
            if (currentPage > (int)lblMaxPage.Content)
            {
                tbNumPage.Text = (--currentPage).ToString();
            }

            if (currentPage == (int)lblMaxPage.Content)
            {
                btnPageNext.IsEnabled = false;
            }
            else
            {
                btnPageNext.IsEnabled = true;
            }

            if (currentPage == 1)
            {
                btnPagePre.IsEnabled = false;
            }
            else
            {
                btnPagePre.IsEnabled = true;
            }

            ReloadDGReceipt();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
        }
Exemple #5
0
 /// <summary>
 /// Dodaje efekt blur
 /// </summary>
 /// <param name="win"></param>
 private void ApplyEffect(Window win)
 {
     System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
     objBlur.Radius = 3;
     win.Effect     = objBlur;
 }
 private void Line2_1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     System.Windows.Media.Effects.BlurEffect blur = new System.Windows.Media.Effects.BlurEffect();
     blur.Radius    = 10;
     Line2_1.Effect = blur;
 }
Exemple #7
0
        public Bitmap Blur(Bitmap src, double radius = 10)
        {
            Bitmap result = new Bitmap(src);

            #region Get DPI
            float dpiX = 96f;
            float dpiY = 96f;

            using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
            {
                dpiX = g.DpiX;
                dpiY = g.DpiY;
            }
            #endregion

            int width  = (int)Math.Ceiling(radius);
            int offset = 4 * width;

            #region Create Effect
            var effect = new Media.Effects.BlurEffect();
            effect.Radius = radius;
            #endregion

            #region Draw source bitmap to DrawingVisual
            Media.DrawingVisual drawingVisual = new Media.DrawingVisual();
            drawingVisual.Effect = effect;
            using (var drawingContext = drawingVisual.RenderOpen())
            {
                //drawingContext.PushEffect( new Media.Effects.BlurBitmapEffect(), null );
                System.Windows.Rect dRect = new System.Windows.Rect(2 * width, 2 * width, src.Width, src.Height);
                drawingContext.DrawImage(src.ToBitmapSource(), dRect);
                drawingContext.Close();
            }
            #endregion

            #region Render the DrawingVisual into a RenderTargetBitmap
            var rtb = new Media.Imaging.RenderTargetBitmap(
                src.Width + offset, src.Height * offset,
                dpiX, dpiY,
                Media.PixelFormats.Pbgra32);
            rtb.Render(drawingVisual);
            #endregion

            #region Create a System.Drawing.Bitmap
            var bitmap = new Bitmap(rtb.PixelWidth, rtb.PixelHeight, PixelFormat.Format32bppArgb);
            #endregion

            #region Copy the RenderTargetBitmap pixels into the bitmap's pixel buffer
            var pdata = bitmap.LockBits(
                new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                ImageLockMode.WriteOnly,
                bitmap.PixelFormat);
            rtb.CopyPixels(System.Windows.Int32Rect.Empty,
                           pdata.Scan0, pdata.Stride * pdata.Height, pdata.Stride);
            bitmap.UnlockBits(pdata);
            #endregion

            #region Crop Opaque
            var rect = bitmap.ContentBound();
            rect.Width  = rect.Width < 0 ? 1 : rect.Width + 2;
            rect.Height = rect.Height < 0 ? 1 : rect.Height + 2;
            result      = new Bitmap(rect.Width, rect.Height, bitmap.PixelFormat);
            using (var g = Graphics.FromImage(result))
            {
                g.DrawImage(bitmap, 0, 0, rect, GraphicsUnit.Pixel);
            }
            #endregion

            return(result);
        }
Exemple #8
-1
 private void rightEar_MouseLeftButtonDown(object sender,
   System.Windows.Input.MouseButtonEventArgs e)
 {
     // Blur the ear when clicked.
     System.Windows.Media.Effects.BlurEffect blur =
       new System.Windows.Media.Effects.BlurEffect();
     blur.Radius = 10;
     rightEar.Effect = blur;
 }
Exemple #9
-1
 /// <summary>
 /// Apply Blur Effect on the window
 /// </summary>
 /// <param name=”win”></param>
 internal static void ApplyBlurEffect(System.Windows.Window win)
 {
     System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
     objBlur.Radius = 4;
     win.Effect = objBlur;
 }
Exemple #10
-1
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     double Leftmargin = (this.ActualWidth - 20 * btSum) / (2 * btSum);
     for (int i = 0; i < btSum; i++)
     {
         Button bt = new Button();
         bt.Height = 10;
         bt.Width = 20;
         bt.Tag = i;
         bt.Margin = new Thickness(Leftmargin, 0, Leftmargin, 0);
         System.Windows.Media.Effects.BlurEffect blur = new System.Windows.Media.Effects.BlurEffect();
         blur.Radius = 8;
         blur.RenderingBias = System.Windows.Media.Effects.RenderingBias.Quality;
         bt.Effect = blur;
         bt.Click += new RoutedEventHandler(bt_Click);
         spMain.Children.Add(bt);
     }
     SetUp(1, 6);
 }
Exemple #11
-1
 private void AplicarEfecto(Window win)
 {
     var objBlur = new System.Windows.Media.Effects.BlurEffect();
     objBlur.Radius = 5;
     win.Effect = objBlur;
 }
Exemple #12
-1
 private void ApplyEffect(AWindow win)
 {
     System.Windows.Media.Effects.BlurEffect objBlur =
        new System.Windows.Media.Effects.BlurEffect();
     objBlur.Radius = 4;
     win.Effect = objBlur;
 }