public NonlinearRandom()
        {
            InitializeComponent();

            _errorEffect = new DropShadowEffect()
            {
                Color = UtilityWPF.ColorFromHex("FF0000"),
                BlurRadius = 4,
                Direction = 0,
                Opacity = .5,
                ShadowDepth = 0,
            };

            txtBell2.Text =
@"0 0
.1 .15
.9 .15
1 1";

            txtBell3.Text =
@".4 .3
.6 .8";

            try
            {
                RebuildBell3Combo();
            }
            catch (Exception) { }

            _initialized = true;
        }
    SetEffect
    (
        Effect effect
    )
    {
        AssertValid();

        this.VisualEffect = effect;
    }
Exemplo n.º 3
0
    /// <summary>
    /// Apply Blur Effect on the window
    /// </summary>
    /// <param name="win"></param>
    public static void ApplyEffect(this System.Windows.Window win)
    {
        // Create new effective objects
        System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
        objBlur.Radius = 5;
        System.Windows.Media.SolidColorBrush mask = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.DarkGray);
        mask.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);
    }
        private void setControls()
        {
            panel.Children.Clear();

            if (this.DataContext is Effect || this.DataContext == null)
            {
                Effect iEffect = DataContext as Effect;
                _editingEffect = iEffect ?? PlayInfo.DefaultEffect.CloneCurrentValue();

                if (_editingEffect is SilhouetteSaverLib.GrayAlphaEffect)
                {
                    SilhouetteSaverLib.GrayAlphaEffect gaef = _editingEffect as SilhouetteSaverLib.GrayAlphaEffect;
                    GrayAlphaEffectControl ctrl = new GrayAlphaEffectControl();
                    ctrl.DataContext = gaef;
                    panel.Children.Add(ctrl);
                }
            }
        }
        public MainWindow()
        {
            m_model = new PageInfo();

            InitializeComponent();

            DataContext = m_model;
           
            InitPage();
           
            PageManager.setPageListener(this);

            PageManager.setPageChange(ePAGE.ePage_StartPage);

            m_effect = gdBackgroundContainer.Effect;

            _updateEffect();
        }
        public void Start()
        {
            _tileData = new TileData
            {
                Title = "Hot artists",
                BackgroundImage = _tileIcon
            };

            _tileEffect = new ColorToneShaderEffect
            {
                DarkColor = Colors.Black,
                LightColor = Colors.DarkOrange,
                Desaturation = 0.5,
                Toned = 0.5
            };
            _tileEffect.Freeze();

            _dispatcher.BeginInvoke(new Action(() => _tileService.Add<Views.Hot.HotArtistsView>(_tileData)), DispatcherPriority.ContextIdle);

            Job<TileData> job = new Job<TileData>("HotTile");
            job.Data = _tileData;
            job.Run.From(DateTime.Now).Every.Seconds(60);
            _scheduler.SubmitJob(job, HotTileJobExecution);
        }
Exemplo n.º 7
0
 public EffectViewItem(Effect e)
 {
     _effect = e;
 }
Exemplo n.º 8
0
 public static void SetEffect(DependencyObject dc, Effect value)
 {
     dc.SetValue(EffectProperty, value);
 }
Exemplo n.º 9
0
        //public static void RenderXrayImage_TrimatEffect(ref BitmapSource bsource, TrimatEffect trimatEffect, SourceObject sourceObject, ViewObject viewObject)
        //{
        //    PixelFormat pixelFormat = PixelFormats.Bgr24;

        //    int pixelOffset = pixelFormat.BitsPerPixel / 8;
        //    int stride = sourceObject.Width * pixelOffset;

        //    byte[] newData = new byte[viewObject.Trimat.Data.Length * pixelOffset];
        //    ImageBrush colorMapping = trimatEffect.ColorMapping as ImageBrush;
        //    BitmapImage bs = colorMapping.ImageSource as BitmapImage;
        //    int width = (int)bs.Width;
        //    int height = (int)bs.Height;

        //    PixelFormat pf = bs.Format;
        //    int po = pf.BitsPerPixel / 8;
        //    int rawstride = width * po;

        //    byte[] pixels = new byte[rawstride * height];
        //    bs.CopyPixels(pixels, rawstride, 0);

        //    Parallel.For(0, sourceObject.Data.Length, i =>
        //    {
        //        float data = viewObject.Trimat.Data[i];
        //        float alpha = viewObject.Trimat.AlphaData[i];
        //        Color color = new Color();
        //        float compare = 1.0F - data;

        //        if (compare < 0.15 || compare > 0.907)
        //        {
        //            color.ScR = color.ScG = color.ScB = data;
        //        }
        //        else
        //        {
        //            int y = (int)(alpha * height);
        //            int x = (int)(compare * width);

        //            int location = y * rawstride + x * po;

        //            color.B = pixels[location];
        //            color.G = pixels[location + 1];
        //            color.R = pixels[location + 2];
        //        }

        //        newData[i * pixelOffset + 0] = color.B;
        //        newData[i * pixelOffset + 1] = color.G;
        //        newData[i * pixelOffset + 2] = color.R;
        //    });

        //    bsource = BitmapSource.Create(viewObject.Trimat.Width, viewObject.Trimat.Height, 96.0, 96.0, pixelFormat, null, newData, stride);
        //}

        /// <summary>
        /// Apply an effect to a bitmap. Renders the bitmap again and returns the new bitmap.
        /// </summary>
        /// <param name="source">The starting source.</param>
        /// <param name="effect">The effect to apply.</param>
        /// <returns>The newly rendered bitmap with effect applied.</returns>
        private static void ApplyEffectToBitmap(ref BitmapSource source, Effect effect)
        {
            if (effect != null)
            {
                DrawingVisual dw = new DrawingVisual();

                ImageBrush ib = new ImageBrush();
                ib.ImageSource = source;
                using (DrawingContext dc = dw.RenderOpen())
                {
                    Size sz = new Size((int)source.Width, (int)source.Height);
                    Pen p = new Pen();
                    Point pt = new Point(0, 0);

                    dc.DrawRectangle(ib, p, new System.Windows.Rect(pt, sz));
                    dc.Close();
                }
                dw.Effect = effect;

                // force run the garbage collection before rendering to mitigate the possibility of an OutOfMemoryException
                GC.Collect();
                GC.WaitForPendingFinalizers();

                source = new RenderTargetBitmap((int)source.Width, (int)source.Height, 96, 96, PixelFormats.Default);
                ((RenderTargetBitmap)source).Render(dw);
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 对UIElement执行最简单的Double类型的单属性Effect动画
 /// </summary>
 /// <param name="obj">UIElement对象</param>
 /// <param name="effect">特效</param>
 /// <param name="autoReverse">至结束后是否翻向播放至起点</param>
 /// <param name="repeat">是否永远执行</param>
 /// <param name="propertyName">要执行动画的特效属性</param>
 /// <param name="from">起始值</param>
 /// <param name="to">结束值</param>
 /// <param name="duration">间隔</param>
 /// <param name="easingFunction">缓动接口</param>
 /// <param name="superposition">是否允许对同一对象叠加执行</param>
 public static void RunEffectAnimation(UIElement obj, Effect effect, bool autoReverse, bool repeat, string propertyName, double from, double to, Duration duration, IEasingFunction easingFunction, bool superposition)
 {
     if (superposition || (!superposition && !animateUIElement.Contains(obj))) {
         if (!superposition) { animateUIElement.Add(obj); }
         obj.Effect = effect;
         Storyboard storyboard = new Storyboard() { AutoReverse = autoReverse };
         if (repeat) { storyboard.RepeatBehavior = RepeatBehavior.Forever; }
         storyboard.Children.Add(CreateDoubleAnimation(effect,propertyName, from, to,duration,easingFunction));
         EventHandler handler = null;
         storyboard.Completed += handler = (s, e) => {
             Storyboard sb = s as Storyboard;
             sb.Stop();
             sb.Completed -= handler;
             obj.Effect = null;
             if (!superposition) { animateUIElement.Remove(obj); }
         };
         storyboard.Begin();
     }
 }
Exemplo n.º 11
0
        public void AddEffect(ThumbPosition position, Effect effect)
        {
            Thumb control;
            switch (position)
            {
                default:
                case ThumbPosition.Left:
                    control = left;
                    break;
                case ThumbPosition.Top:
                    control = top;
                    break;
                case ThumbPosition.Right:
                    control = right;
                    break;
                case ThumbPosition.Bottom:
                    control = bottom;
                    break;
            }

            control.Effect = effect;
        }
 public HoverGlowBehaviourEffect(FrameworkElement e, Effect effect)
     : base(e) {
     hovereffect = effect;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Create an effect on a bitmap source
 /// </summary>
 /// <param name="source"></param>
 /// <param name="effect">The effect</param>
 /// <param name="visual">A visual to get the dpi from it</param>
 /// <returns>bitmap source with effect</returns>
 public static BitmapSource UseEffect(this BitmapSource source, Effect effect, Visual visual)
 {
     Matrix mat = PresentationSource.FromVisual(visual).CompositionTarget.TransformToDevice;
     return UseEffect(source, effect, mat.M11, mat.M22);
 }
Exemplo n.º 14
0
 public static BitmapSource UseEffect(this BitmapSource source, Effect effect)
 {
     return UseEffect(source, effect, source.DpiX, source.DpiY);
 }
Exemplo n.º 15
0
        public static BitmapSource UseEffect(this BitmapSource source, Effect effect, double dpiX, double dpiY)
        {
            RenderTargetBitmap bmp = new RenderTargetBitmap((int)source.PixelWidth,
                (int)source.PixelHeight, dpiX, dpiY,
                PixelFormats.Pbgra32);
            Border image = new Border();
            image.RenderSize = new Size(source.Width, source.Height);
            image.Background = new ImageBrush(source);
            image.Effect = effect;
            image.Measure(new Size(source.Width, source.Height));
            image.Arrange(new Rect(new Size(source.Width, source.Height)));
            bmp.Render(image);

            return BitmapFrame.Create(bmp);
        }
        public EvenDistributionCube()
        {
            InitializeComponent();

            _errorEffect = new DropShadowEffect()
            {
                Color = UtilityWPF.ColorFromHex("FF0000"),
                BlurRadius = 4,
                Direction = 0,
                Opacity = .5,
                ShadowDepth = 0,
            };

            _timer = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromMilliseconds(10);
            _timer.Tick += Timer_Tick;

            _initialized = true;
        }
Exemplo n.º 17
0
        public MadShatter()
        {
            InitializeComponent();

            // Camera Trackball
            _trackball = new TrackBallRoam(_camera);
            _trackball.EventSource = grdViewPort;		//NOTE:  If this control doesn't have a background color set, the trackball won't see events (I think transparent is ok, just not null)
            _trackball.AllowZoomOnMouseWheel = true;
            _trackball.Mappings.AddRange(TrackBallMapping.GetPrebuilt(TrackBallMapping.PrebuiltMapping.MouseComplete_NoLeft));
            //_trackball.GetOrbitRadius += new GetOrbitRadiusHandler(Trackball_GetOrbitRadius);

            _errorEffect = new DropShadowEffect()
            {
                Color = UtilityWPF.ColorFromHex("FF0000"),
                BlurRadius = 4,
                Direction = 0,
                Opacity = .5,
                ShadowDepth = 0,
            };

            _initialized = true;
        }
 private void OnMouseEnter(object sender, MouseEventArgs e) {
     backup = AttachedElement.Effect;
     AttachedElement.Effect = hovereffect;
 }
Exemplo n.º 19
0
 private void setMyProtectedVisualEffect(Effect effect)
 {
     VisualEffect = effect;
 }
Exemplo n.º 20
0
        private void DrawFlag(Point position, double width, double height, FlagVisual flag, Effect effect = null)
        {
            // This fails when trying to clone (no default constructor)
            //FrameworkElement cloned = UtilityCore.Clone(flag);
            //cloned.Width = width;
            //cloned.Height = height;

            FlagVisual cloned = new FlagVisual(width, height, flag.FlagProps);

            Canvas.SetLeft(cloned, position.X - (width / 2));
            Canvas.SetTop(cloned, position.Y - (height / 2));

            if (effect != null)
            {
                cloned.Effect = effect;
            }

            canvasMap.Children.Add(cloned);
        }
Exemplo n.º 21
0
        private void DrawTriangle(Point position, double width, double height, double angle, Brush fill, Brush stroke, double strokeThickness, Effect effect = null)
        {
            Polygon triangle = new Polygon()
            {
                Fill = fill,
                Stroke = stroke,
                StrokeThickness = strokeThickness
            };

            double halfWidth = width / 2;
            double halfHeight = height / 2;

            triangle.Points.Add(new Point(-halfWidth, halfHeight));
            triangle.Points.Add(new Point(halfWidth, halfHeight));
            triangle.Points.Add(new Point(0, -halfHeight));

            Canvas.SetLeft(triangle, position.X - halfWidth);
            Canvas.SetTop(triangle, position.Y - halfHeight);

            if (effect != null)
            {
                triangle.Effect = effect;
            }

            triangle.RenderTransform = new RotateTransform(angle);

            canvasMap.Children.Add(triangle);
        }
Exemplo n.º 22
0
 private TextBlock CreateLabel(Color color, Effect effect, double top, double left, int i)
 {
     return new TextBlock
       {
     Name = "CalendarLabel" + i,
     Text = i.ToString(),
     FontFamily = font,
     FontSize = 36,
     Effect = effect,
     VerticalAlignment = VerticalAlignment.Top,
     HorizontalAlignment = HorizontalAlignment.Left,
     TextAlignment = TextAlignment.Right,
     Width = 50,
     Margin = new Thickness(left, top, 0, 0),
     Foreground = new SolidColorBrush(color),
       };
 }