private static INotificationsLifetimeSupervisor CreateLifetimeSupervisor(NotificationLifetimeType lifetime)
        {
            if (lifetime == NotificationLifetimeType.Basic)
            {
                return(new CountBasedLifetimeSupervisor(MaximumNotificationCount.FromCount(5)));
            }

            return(new TimeAndCountBasedLifetimeSupervisor(TimeSpan.FromSeconds(5), MaximumNotificationCount.UnlimitedNotifications()));
        }
Exemple #2
0
        private void InitToast()
        {
            notifier = new Notifier(cfg =>
            {
                cfg.PositionProvider = new WindowPositionProvider(
                    parentWindow: Application.Current.MainWindow,
                    corner: Corner.TopRight,
                    offsetX: 0,
                    offsetY: 40);

                cfg.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(
                    notificationLifetime: TimeSpan.FromSeconds(1.5),
                    maximumNotificationCount: MaximumNotificationCount.UnlimitedNotifications());

                cfg.Dispatcher = Application.Current.Dispatcher;
            });
        }
Exemple #3
0
        public MainVM()
        {
            MainVm = this;
            Notify = new Notifier(cfg =>
            {
                cfg.PositionProvider = new PrimaryScreenPositionProvider(
                    corner: Corner.TopRight,
                    offsetX: 10,
                    offsetY: 30);
                cfg.LifetimeSupervisor = new CountBasedLifetimeSupervisor(
                    maximumNotificationCount: MaximumNotificationCount.UnlimitedNotifications());
                cfg.DisplayOptions.Width = 800;
                cfg.Dispatcher           = dispatcher;
            });
            ElementsVM = new ElementsVM(this);
            ProjectsVM = new ProjectsVM(this);
#if DEBUG
            ShortcutFolder = @"d:\vildar\test\GP\C3D_Projects";
#endif
            this.WhenAnyValue(v => v.ShortcutFolder).Delay(TimeSpan.FromMilliseconds(200))
            .ObserveOn(dispatcher)
            .Subscribe(s => UpdateExecute());
            Update = CreateCommand(UpdateExecute);
        }
Exemple #4
0
        public void TogglePing()
        {
            string Ip = "109.105.133.68";

            switch (SelectedServer)
            {
            case 0: Ip = "109.105.133.68";
                break;

            case 1:
                Ip = "109.105.133.64";
                break;

            case 2:
                Ip = "109.105.133.65";
                break;

            case 3:
                Ip = "109.105.133.67";
                break;

            case 4:
                Ip = "109.105.133.66";
                break;

            case 5:
                Ip = "109.105.133.69";
                break;
            }
            if (!PingEnabled)
            {
                Notifier = new Notifier(cfg =>
                {
                    cfg.PositionProvider = new PrimaryScreenPositionProvider(
                        Corner.TopLeft,
                        Services.Profiles.CurrentProfile.GeneralSettings.PingPosX,
                        Services.Profiles.CurrentProfile.GeneralSettings.PingPosY);
                    cfg.DisplayOptions.TopMost = true;

                    cfg.LifetimeSupervisor = new CountBasedLifetimeSupervisor(MaximumNotificationCount.UnlimitedNotifications());

                    cfg.Dispatcher = Application.Current.Dispatcher;
                });

                timer1 = new Timer();
                var pinger = new Ping();

                var pingViewModel = new CustomNotificationViewModel("");
                Notifier.Notify <CustomNotificationViewModel>(() => pingViewModel);
                timer1.Elapsed += (e, s) =>
                {
                    try
                    {
                        var reply = pinger.Send(Ip);
                        if (reply?.Status == IPStatus.Success)
                        {
                            pingViewModel.Message = reply?.RoundtripTime.ToString() + "ms";
                        }
                        else
                        {
                            pingViewModel.Message = "ERR";
                        }
                        timer1.Start();
                    }
                    catch (PingException)
                    {
                        pingViewModel.Message = "ERR";
                        timer1.Start();
                    }
                };
                timer1.Interval  = 1000;// in miliseconds
                timer1.AutoReset = false;
                timer1.Start();
                PingEnabled = true;
            }
            else
            {
                PingEnabled = false;
                timer1.Stop();
                timer1.Dispose();
                Notifier.Dispose();
            }
        }
Exemple #5
0
 private Notifier CreateNotifier()
 {
     return(new Notifier(config =>
     {
         config.PositionProvider = new WindowPositionProvider(Application.Current.MainWindow, Corner.BottomRight, 5, 5);
         config.LifetimeSupervisor = new TimeAndCountBasedLifetimeSupervisor(TimeSpan.FromSeconds(10), MaximumNotificationCount.UnlimitedNotifications());
         config.DisplayOptions.TopMost = false;
         config.DisplayOptions.Width = 350;
         config.Dispatcher = Dispatcher.CurrentDispatcher;
     }));
 }
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
            SnackbarNotify.MessageQueue = snackMessageQueue;
            AutoStartService            = false;
            EnableNotification          = false;

            _notifier = new Notifier(cfg =>
            {
                cfg.LifetimeSupervisor   = new TimeAndCountBasedLifetimeSupervisor(notificationLifetime: TimeSpan.FromSeconds(10), MaximumNotificationCount.UnlimitedNotifications());
                cfg.PositionProvider     = new PrimaryScreenPositionProvider(Corner.BottomRight, 10, 10);
                cfg.DisplayOptions.Width = 350;
            });

            //SOFTWARE VERSION
            string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            SoftwareVersionText.Text = "Versão: " + version;
        }