public static void Toast(string messageAutor = "", string messageTheme="[Без темы]",
     ToasterPosition position = ToasterPosition.PrimaryScreenTopRight, ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
     double margin = 10.0)
 {
     var err = new SuccessToaster(messageAutor, messageTheme, position, animation, margin);
     err.Show();
 }
Exemple #2
0
        public ToasterWindow(FrameworkElement owner, string title, string message,
                             ToasterPosition position, ToasterAnimation animation, double margin)
        {
            InitializeComponent();
            ToasterTitle = title;
            Message      = message;
            Position     = position;
            Animation    = animation;
            Margins      = margin;

            var story = ToastSupport.GetAnimation(Animation, Notification);

            story.Completed += (sender, args) => { Close(); };
            story.Begin(Notification);

            Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
            {
                var topLeftDict = ToastSupport.GetTopandLeft(Position, this, Margins);
                Top             = topLeftDict["Top"];
                Left            = topLeftDict["Left"];
            }));

            if (owner != null)
            {
                owner.Unloaded += Owner_Unloaded;
            }
        }
 public static void Toast(string message = "Something terrible may have just happened and you are being notified of it.",
         ToasterPosition position = ToasterPosition.PrimaryScreenBottomRight,ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
         double margin = 10.0)
 {
     var err = new WarningToaster(message, position, animation, margin);
     err.Show();
 }
 public static void Toast(netoaster.Message _myMes1, netoaster.Message _myMes2, string messageEmail1 = "A", string messageAutor1 = "", string messageTheme1 = "[Без темы]", string messageEmail2 = "A", string messageAutor2 = "", string messageTheme2 = "[Без темы]", int timeActive = 3, 
         ToasterPosition position = ToasterPosition.PrimaryScreenBottomRight,ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
         double margin = 10.0)
 {
     var err = new WarningToaster(_myMes1, _myMes2, messageEmail1, messageAutor1, messageTheme1, messageEmail2, messageAutor2, messageTheme2, timeActive, position, animation, margin);
     err.Show();
 }
Exemple #5
0
        private static ToasterWindow GetToasterWindow(FrameworkElement owner, ToastType type, string title, string message,
                                                      ToasterPosition position, ToasterAnimation animation, double margin)
        {
            var toaster = new ToasterWindow(owner, title, message, position, animation, margin);

            switch (type)
            {
            case ToastType.Error:
                toaster.Ico.Data = NotificationIcoPath.Error;
                toaster.Notification.Background = NotificationColor.Error;
                break;

            case ToastType.Info:
                toaster.Ico.Data = NotificationIcoPath.Info;
                toaster.Notification.Background = NotificationColor.Info;
                break;

            case ToastType.Warning:
                toaster.Ico.Data = NotificationIcoPath.Warning;
                toaster.Notification.Background = NotificationColor.Warning;
                break;

            case ToastType.Success:
                toaster.Ico.Data = NotificationIcoPath.Success;
                toaster.Notification.Background = NotificationColor.Success;
                break;
            }
            return(toaster);
        }
    private WarningToaster(string messageEmail1, string messageAutor1, string messageTheme1, string messageEmail2, string messageAutor2, string messageTheme2, int timeActive , ToasterPosition position, ToasterAnimation animation, double margin)
  {
    InitializeComponent();

    Brush[] brushes = new Brush[] {
            new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x1E, 0x4B)),
            new SolidColorBrush(Color.FromArgb(0xFF, 0x7B, 0x25, 0xFA)),
            new SolidColorBrush(Color.FromArgb(0xFF, 0x71, 0x9F, 0x3F))
        };
    Random rnd = new Random();
    avatar1.Fill = brushes[rnd.Next(brushes.Length)];
    avatar2.Fill = brushes[rnd.Next(brushes.Length)];

    var msgAutor1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorname1");
    if (msgAutor1 != null) msgAutor1.Text = messageAutor1 ?? string.Empty;
    var msgTheme1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("themetext1");
    if (messageTheme1.Length >= 28)
    {
        if (msgTheme1 != null) msgTheme1.Text = messageTheme1.Substring(0, 27) + "..." ?? string.Empty;
    }
    else
    {
        if (msgTheme1 != null) msgTheme1.Text = messageTheme1 ?? string.Empty;
    }
    var msgEmail1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("emailtext1");
    if (msgEmail1 != null) msgEmail1.Text = messageEmail1 ?? string.Empty;
    var msgName1 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorletter1");
    if (msgName1 != null) msgName1.Text = messageEmail1.Substring(0, 1).ToUpper() ?? string.Empty;

    var msgAutor2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorname2");
    if (msgAutor2 != null) msgAutor2.Text = messageAutor2 ?? string.Empty;
    var msgTheme2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("themetext2");
    if (messageTheme2.Length >= 28)
    {
        if (msgTheme2 != null) msgTheme2.Text = messageTheme2.Substring(0, 27) + "..." ?? string.Empty;
    }
    else
    {
        if (msgTheme1 != null) msgTheme2.Text = messageTheme2 ?? string.Empty;
    }
    var msgEmail2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("emailtext2");
    if (msgEmail2 != null) msgEmail2.Text = messageEmail2 ?? string.Empty;
    var msgName2 = (System.Windows.Documents.Run)WarningToasterInstance.FindName("autorletter2");
    if (msgName2 != null) msgName2.Text = messageEmail2.Substring(0, 1).ToUpper() ?? string.Empty;

    Storyboard story = ToastSupport.GetAnimation(animation, ref WarningToasterInstance, timeActive);
    story.Completed += (sender, args) => { this.Close(); };
    story.Begin(WarningToasterInstance);

    Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
    {
        var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
        Top = topLeftDict["Top"];
        Left = topLeftDict["Left"];
    }));
  }
Exemple #7
0
 public static void Toast(
     Window owner,
     string title = "Error",
     string message = "Something terrible may have just happened and you are being notified of it.",
     ToasterPosition position = ToasterPosition.PrimaryScreenBottomRight,
     ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
     double margin = 10.0)
 {
     var toaster = new ErrorToaster(owner, title, message, position, animation, margin);
     toaster.Show();
 }
Exemple #8
0
 public static void Toast(
     Window owner,
     string title = "Info",
     string message = "Something you may notice.",
     ToasterPosition position = ToasterPosition.PrimaryScreenTopRight,
     ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
     double margin = 10.0)
 {
     var toaster = new InfoToaster(owner, title, message, position, animation, margin);
     toaster.Show();
 }
 public static void Toast(
     Window owner,
     string title = "Success",
     string message = "All good.",
     ToasterPosition position = ToasterPosition.PrimaryScreenTopRight,
     ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
     double margin = 10.0)
 {
     var toaster = new SuccessToaster(owner, title, message, position, animation, margin);
     toaster.Show();
 }
Exemple #10
0
        public static void ShowSuccess(
            Window owner,
            string title               = "Success",
            string message             = "All good.",
            ToasterPosition position   = ToasterPosition.PrimaryScreenBottomRight,
            ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
            double margin              = 10.0)
        {
            var toaster = GetToasterWindow(owner, ToastType.Success, title, message, position, animation, margin);

            toaster.Show();
        }
Exemple #11
0
        public static void ShowInfo(
            Window owner,
            string title               = "Info",
            string message             = "Something you may notice.",
            ToasterPosition position   = ToasterPosition.ApplicationBottomRight,// .PrimaryScreenBottomRight,
            ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
            double margin              = 10.0)
        {
            var toaster = GetToasterWindow(owner, ToastType.Info, title, message, position, animation, margin);

            toaster.Show();
        }
Exemple #12
0
        public static void ShowWarning(
            Window owner,
            string title               = "Warning",
            string message             = "Something terrible may have just happened and you are being notified of it.",
            ToasterPosition position   = ToasterPosition.PrimaryScreenBottomRight,
            ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
            double margin              = 10.0)
        {
            var toaster = GetToasterWindow(owner, ToastType.Warning, title, message, position, animation, margin);

            toaster.Show();
        }
        public static void Toast(
            Window owner,
            string title               = "Success",
            string message             = "All good.",
            ToasterPosition position   = ToasterPosition.PrimaryScreenTopRight,
            ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
            double margin              = 10.0)
        {
            var toaster = new SuccessToaster(owner, title, message, position, animation, margin);

            toaster.Show();
        }
Exemple #14
0
        public static void Toast(
            Window owner,
            string title               = "Info",
            string message             = "Something you may notice.",
            ToasterPosition position   = ToasterPosition.PrimaryScreenTopRight,
            ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
            double margin              = 10.0)
        {
            var toaster = new InfoToaster(owner, title, message, position, animation, margin);

            toaster.Show();
        }
        public static StoryBoard GetAnimation(ToasterAnimation animation, ref Grid toaster)
        {
            Storyboard story = new Storyboard();
            SplineDoubleKeyFrame frame = new SplineDoubleKeyFrame();

                    DoubleAnimation fadein = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(1));
                    fadein.BeginTime = TimeSpan.FromSeconds(0);
                    Storyboard.SetTargetProperty(fadein, new PropertyPath("(UIElement.Opacity)"));
                    story.Children.Add(fadein);
                    DoubleAnimation fadeout = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(1));
                    fadeout.BeginTime = TimeSpan.FromSeconds(7);
                    Storyboard.SetTargetProperty(fadeout, new PropertyPath("(UIElement.Opacity)"));
                    story.Children.Add(fadeout);
            return story;
        }
    private WarningToaster(string message, ToasterPosition position, ToasterAnimation animation, double margin)
  {
    InitializeComponent();

    var msgText = (System.Windows.Documents.Run)WarningToasterInstance.FindName("MessageString");
    if (msgText != null) msgText.Text = message ?? string.Empty;

    Storyboard story = ToastSupport.GetAnimation(animation, ref WarningToasterInstance);
    story.Completed += (sender, args) => { this.Close(); };
    story.Begin(WarningToasterInstance);

    Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
    {
        var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
        Top = topLeftDict["Top"];
        Left = topLeftDict["Left"];
    }));
  }
Exemple #17
0
        private SuccessToaster(FrameworkElement owner, string title, string message, ToasterPosition position, ToasterAnimation animation, double margin)
        {
            InitializeComponent();

            ToasterTitle = title;
            Message = message ?? string.Empty;

            var story = ToastSupport.GetAnimation(animation, ref SuccessToasterInstance);
            story.Completed += (sender, args) => { this.Close(); };
            story.Begin(SuccessToasterInstance);

            Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
            {
                var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
                Top = topLeftDict["Top"];
                Left = topLeftDict["Left"];
            }));
            owner.Unloaded += Owner_Unloaded;
        }
        private WarningToaster(FrameworkElement owner, string title, string message, ToasterPosition position,
                               ToasterAnimation animation, double margin)
        {
            InitializeComponent();

            ToasterTitle = title;
            Message      = message ?? string.Empty;

            var story = ToastSupport.GetAnimation(animation, ref WarningToasterInstance);

            story.Completed += (sender, args) => { Close(); };
            story.Begin(WarningToasterInstance);

            Dispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() =>
            {
                var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
                Top             = topLeftDict["Top"];
                Left            = topLeftDict["Left"];
            }));

            owner.Unloaded += Owner_Unloaded;
        }
    private SuccessToaster(string messageAutor,string messageTheme, ToasterPosition position, ToasterAnimation animation, double margin)
    {
        InitializeComponent();

        var msgAutor = (System.Windows.Documents.Run)SuccessToasterInstance.FindName("autorname");
        if (msgAutor != null) msgAutor.Text = messageAutor ?? string.Empty;
        var msgTheme = (System.Windows.Documents.Run)SuccessToasterInstance.FindName("themetext");
        if (msgTheme != null) msgTheme.Text = messageTheme ?? string.Empty;
        var msgName = (System.Windows.Documents.Run)SuccessToasterInstance.FindName("name");
        if (msgName != null) msgName.Text = messageAutor.Substring(0,1) ?? string.Empty;

        Storyboard story = ToastSupport.GetAnimation(animation, ref SuccessToasterInstance);
        story.Completed += (sender, args) => { this.Close(); };
        story.Begin(SuccessToasterInstance);

        Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
        {
            var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
            Top = topLeftDict["Top"];
            Left = topLeftDict["Left"];
        }));
    }
Exemple #20
0
        private ErrorToaster(string message, string title, ToasterPosition position, ToasterAnimation animation, double margin)
        {
            this.InitializeComponent();
            System.Windows.Documents.Run run = (System.Windows.Documents.Run) this.ErrorToasterInstance.FindName("MessageString");
            if (run != null)
            {
                run.Text = message ?? string.Empty;
            }
            System.Windows.Documents.Run run2 = (System.Windows.Documents.Run) this.ErrorToasterInstance.FindName("TitleString");
            if (run2 != null)
            {
                run2.Text = title ?? string.Empty;
            }
            Storyboard storyboard = ToastSupport.GetAnimation(animation, ref this.ErrorToasterInstance);

            storyboard.Completed += (sender, args) => base.Close();
            storyboard.Begin(this.ErrorToasterInstance);
            base.Dispatcher.BeginInvoke(DispatcherPriority.DataBind, (Action) delegate
            {
                Dictionary <string, double> dictionary = ToastSupport.GetTopandLeft(position, this, margin);
                this.Top  = dictionary["Top"];
                this.Left = dictionary["Left"];
            });
        }
Exemple #21
0
        public static StoryBoard GetAnimation(ToasterAnimation animation, ref Grid toaster)
        {
            var story = new Storyboard();

            switch (animation)
            {
            case ToasterAnimation.FadeIn:
                DoubleAnimation fadein = new DoubleAnimation(0, 1, TimeSpan.FromSeconds(2));
                fadein.BeginTime = TimeSpan.FromSeconds(0);
                Storyboard.SetTargetProperty(fadein, new PropertyPath("(UIElement.Opacity)"));
                story.Children.Add(fadein);
                DoubleAnimation fadeout = new DoubleAnimation(1, 0, TimeSpan.FromSeconds(2));
                fadeout.BeginTime = TimeSpan.FromSeconds(4);
                Storyboard.SetTargetProperty(fadeout, new PropertyPath("(UIElement.Opacity)"));
                story.Children.Add(fadeout);
                break;

            case ToasterAnimation.SlideInFromRight:
                toaster.RenderTransformOrigin = new Point(1, 0);
                toaster.RenderTransform       = new TranslateTransform(300.0, 0);
                var slideinFromRightAnimation = new DoubleAnimationUsingKeyFrames
                {
                    Duration  = new Duration(TimeSpan.FromSeconds(6)),
                    KeyFrames = new DoubleKeyFrameCollection
                    {
                        new EasingDoubleKeyFrame(300.0, KeyTime.FromPercent(0)),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.1), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseInOut
                        }),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.8)),
                        new EasingDoubleKeyFrame(300.0, KeyTime.FromPercent(0.9), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseOut
                        })
                    }
                };

                Storyboard.SetTargetProperty(slideinFromRightAnimation,
                                             new PropertyPath("RenderTransform.(TranslateTransform.X)"));
                story.Children.Add(slideinFromRightAnimation);
                break;

            case ToasterAnimation.SlideInFromLeft:
                toaster.RenderTransformOrigin = new Point(0, 1);
                toaster.RenderTransform       = new TranslateTransform(-300.0, 0);
                var slideinFromLeftAnimation = new DoubleAnimationUsingKeyFrames
                {
                    Duration  = new Duration(TimeSpan.FromSeconds(6)),
                    KeyFrames = new DoubleKeyFrameCollection
                    {
                        new EasingDoubleKeyFrame(-300.0, KeyTime.FromPercent(0)),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.1), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseInOut
                        }),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.8)),
                        new EasingDoubleKeyFrame(-300.0, KeyTime.FromPercent(0.9), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseOut
                        })
                    }
                };

                Storyboard.SetTargetProperty(slideinFromLeftAnimation,
                                             new PropertyPath("RenderTransform.(TranslateTransform.X)"));
                story.Children.Add(slideinFromLeftAnimation);
                break;

            case ToasterAnimation.SlideInFromTop:
                toaster.RenderTransformOrigin = new Point(0, 1);
                toaster.RenderTransform       = new TranslateTransform(0, 300);
                var slideinFromTopAnimation = new DoubleAnimationUsingKeyFrames
                {
                    Duration  = new Duration(TimeSpan.FromSeconds(6)),
                    KeyFrames = new DoubleKeyFrameCollection
                    {
                        new EasingDoubleKeyFrame(-300.0, KeyTime.FromPercent(0)),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.1), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseInOut
                        }),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.8)),
                        new EasingDoubleKeyFrame(-300.0, KeyTime.FromPercent(0.9), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseOut
                        })
                    }
                };

                Storyboard.SetTargetProperty(slideinFromTopAnimation,
                                             new PropertyPath("RenderTransform.(TranslateTransform.Y)"));
                story.Children.Add(slideinFromTopAnimation);
                break;

            case ToasterAnimation.SlideInFromBottom:
                toaster.RenderTransformOrigin = new Point(0, 1);
                toaster.RenderTransform       = new TranslateTransform(0, -300);
                var slideinFromBottomAnimation = new DoubleAnimationUsingKeyFrames
                {
                    Duration  = new Duration(TimeSpan.FromSeconds(6)),
                    KeyFrames = new DoubleKeyFrameCollection
                    {
                        new EasingDoubleKeyFrame(300.0, KeyTime.FromPercent(0)),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.1), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseInOut
                        }),
                        new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0.8)),
                        new EasingDoubleKeyFrame(300.0, KeyTime.FromPercent(0.9), new ExponentialEase
                        {
                            EasingMode = EasingMode.EaseOut
                        })
                    }
                };

                Storyboard.SetTargetProperty(slideinFromBottomAnimation,
                                             new PropertyPath("RenderTransform.(TranslateTransform.Y)"));
                story.Children.Add(slideinFromBottomAnimation);
                break;

            case ToasterAnimation.GrowFromRight:
                toaster.RenderTransformOrigin = new Point(1, 0);
                DoubleAnimationUsingKeyFrames growfromright = new DoubleAnimationUsingKeyFrames();
                growfromright.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
                growfromright.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(1.5)));
                growfromright.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(4)));
                growfromright.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(5.5)));
                Storyboard.SetTargetProperty(growfromright,
                                             new PropertyPath("RenderTransform.(ScaleTransform.ScaleX)"));
                story.Children.Add(growfromright);
                break;

            case ToasterAnimation.GrowFromLeft:
                toaster.RenderTransformOrigin = new Point(0, 1);
                DoubleAnimationUsingKeyFrames growfromleft = new DoubleAnimationUsingKeyFrames();
                growfromleft.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
                growfromleft.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(1.5)));
                growfromleft.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(4)));
                growfromleft.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(5.5)));
                Storyboard.SetTargetProperty(growfromleft,
                                             new PropertyPath("RenderTransform.(ScaleTransform.ScaleX)"));
                story.Children.Add(growfromleft);
                break;

            case ToasterAnimation.GrowFromTop:
                toaster.RenderTransformOrigin = new Point(1, 0);
                DoubleAnimationUsingKeyFrames growfromtop = new DoubleAnimationUsingKeyFrames();
                growfromtop.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
                growfromtop.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(1.5)));
                growfromtop.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(4)));
                growfromtop.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(5.5)));
                Storyboard.SetTargetProperty(growfromtop,
                                             new PropertyPath("RenderTransform.(ScaleTransform.ScaleY)"));
                story.Children.Add(growfromtop);
                break;

            case ToasterAnimation.GrowFromBottom:
                toaster.RenderTransformOrigin = new Point(0, 1);
                DoubleAnimationUsingKeyFrames growfrombottom = new DoubleAnimationUsingKeyFrames();
                growfrombottom.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
                growfrombottom.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(1.5)));
                growfrombottom.KeyFrames.Add(new SplineDoubleKeyFrame(1, TimeSpan.FromSeconds(4)));
                growfrombottom.KeyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(5.5)));
                Storyboard.SetTargetProperty(growfrombottom,
                                             new PropertyPath("RenderTransform.(ScaleTransform.ScaleY)"));
                story.Children.Add(growfrombottom);
                break;
            }

            return(story);
        }
 public static void Toast(
    netoaster.Message _myMes1, netoaster.Message _myMes2, netoaster.Message _myMes3, string messageEmail1, string messageAutor1 = "", string messageTheme1 = "", string messageEmail2 = "", string messageAutor2 = "", string messageTheme2 = "", string messageEmail3 = "", string messageAutor3 = "", string messageTheme3 = "", int timeActive = 3, int countNewMessage = 0, ToasterPosition position = ToasterPosition.PrimaryScreenBottomRight, ToasterAnimation animation = ToasterAnimation.SlideInFromRight,
     double margin = 10.0)
 {
     var err = new ErrorToaster(_myMes1, _myMes2, _myMes3, messageEmail1, messageAutor1, messageTheme1, messageEmail2, messageAutor2, messageTheme2, messageEmail3, messageAutor3, messageTheme3, timeActive, countNewMessage, position, animation, margin);
     err.Show();
 }
    private ErrorToaster(netoaster.Message myMessage1, netoaster.Message myMessage2, netoaster.Message myMessage3, string messageEmail1, string messageAutor1, string messageTheme1, string messageEmail2, string messageAutor2, string messageTheme2, string messageEmail3, string messageAutor3, string messageTheme3, int timeActive, int countNewMessage, ToasterPosition position, ToasterAnimation animation, double margin)
    {
        InitializeComponent();

        Brush[] brushes = new Brush[] {
            new SolidColorBrush(Color.FromArgb(0xFF, 0x2D, 0x1E, 0x4B)),
            new SolidColorBrush(Color.FromArgb(0xFF, 0x7B, 0x25, 0xFA)),
            new SolidColorBrush(Color.FromArgb(0xFF, 0x71, 0x9F, 0x3F))
        };
        Random rnd = new Random();
        avatar1.Fill = brushes[rnd.Next(brushes.Length)];
        avatar2.Fill = brushes[rnd.Next(brushes.Length)];
        avatar3.Fill = brushes[rnd.Next(brushes.Length)];

        email=myMessage1.emailUser;
        if (!(myMessage1.emailUser.Length > "summerintensiveemailcheckertest".Length))
        {
            EmailTo.Text = "Пришло на адрес: " + myMessage1.emailUser;
        }
        else
        {
            EmailTo.Text = "Пришло на адрес: " + myMessage1.emailUser.Remove("summerintensiveemailcheckertest".Length - 3) + "...";
        }

        var msgAutor1 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("autorname1");
        if (msgAutor1 != null) msgAutor1.Text = messageAutor1 ?? string.Empty;
        var msgTheme1 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("themetext1");
        if (messageTheme1.Length >= 28)
        {
            if (msgTheme1 != null) msgTheme1.Text = messageTheme1.Substring(0, 27) + "..." ?? string.Empty;
        }
        else
        {
            if (msgTheme1 != null) msgTheme1.Text = messageTheme1 ?? string.Empty;
        }
        var msgEmail1 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("emailtext1");
        if (msgEmail1 != null) msgEmail1.Text = messageEmail1 ?? string.Empty;
        var msgName1 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("autorletter1");
        if (msgName1 != null) msgName1.Text = messageEmail1.Substring(0, 1).ToUpper() ?? string.Empty;

        var msgAutor2 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("autorname2");
        if (msgAutor2 != null) msgAutor2.Text = messageAutor2 ?? string.Empty;
        var msgTheme2 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("themetext2");
        if (messageTheme2.Length >= 28)
        {
            if (msgTheme2 != null) msgTheme2.Text = messageTheme2.Substring(0, 27) + "..." ?? string.Empty;
        }
        else
        {
            if (msgTheme1 != null) msgTheme2.Text = messageTheme2 ?? string.Empty;
        }
        var msgEmail2 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("emailtext2");
        if (msgEmail2 != null) msgEmail2.Text = messageEmail2 ?? string.Empty;
        var msgName2 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("autorletter2");
        if (msgName2 != null) msgName2.Text = messageEmail2.Substring(0, 1).ToUpper() ?? string.Empty;

        var msgAutor3 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("autorname3");
        if (msgAutor3 != null) msgAutor3.Text = messageAutor3 ?? string.Empty;
        var msgTheme3 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("themetext3");
        if (messageTheme3.Length >= 28)
        {
            if (msgTheme3 != null) msgTheme3.Text = messageTheme3.Substring(0, 27) + "..." ?? string.Empty;
        }
        else
        {
            if (msgTheme3 != null) msgTheme3.Text = messageTheme3 ?? string.Empty;
        }
        var msgEmail3 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("emailtext3");
        if (msgEmail3 != null) msgEmail3.Text = messageEmail3 ?? string.Empty;
        var msgName3 = (System.Windows.Documents.Run)ErrorToasterInstance.FindName("autorletter3");
        if (msgName3 != null) msgName3.Text = messageEmail3.Substring(0, 1).ToUpper() ?? string.Empty;

        if (countNewMessage > 0)
        {
            fullinfo.Content = "Новых писем -" + " " + countNewMessage.ToString();
            fullinfo.Visibility = System.Windows.Visibility.Visible;
            rectang.Visibility = System.Windows.Visibility.Visible;
            this.Height = 252;
            bord.Height = 252;
        }
        else
        {
            fullinfo.Visibility = System.Windows.Visibility.Hidden;
            this.Height = 240;
            bord.Height = 240;
            rectang.Visibility = System.Windows.Visibility.Hidden;

        }

        Storyboard story = ToastSupport.GetAnimation(animation, ref ErrorToasterInstance, timeActive);
        story.Completed += (sender, args) => { this.Close(); };
        story.Begin(ErrorToasterInstance);

        Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
        {
            var topLeftDict = ToastSupport.GetTopandLeft(position, this, margin);
            Top = topLeftDict["Top"];
            Left = topLeftDict["Left"];
        }));
    }
 public static void Toast(string p, ToasterPosition toasterPosition, ToasterAnimation animation, double margin)
 {
     throw new NotImplementedException();
 }
Exemple #25
0
 public static void Toast(string message = "Сообщение", string title = "Ошибка", ToasterPosition position = 0, ToasterAnimation animation = ToasterAnimation.FadeIn, double margin = 20.0)
 {
     new ErrorToaster(message, title, position, animation, margin).Show();
 }