Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();

            var configurationDictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(File.ReadAllText("configuration.json"));

            var configurationReader = new ToastrConfigurationReader();
            var configuration = configurationReader.Get(configurationDictionary);

            var actionsExecutor = new ActionsExecutor(Dispatcher);
            _controller = new NotificationsController(
                (uint)SystemParameters.PrimaryScreenWidth,
                (uint)SystemParameters.PrimaryScreenHeight,
                actionsExecutor,
                configuration,
                (notification, config) =>
                {
                    var notificationWindow = new NotificationWindow(notification, config);
                    notificationWindow.Show();
                    return notificationWindow;
                });

            Closing += (sender, args) =>
            {
                actionsExecutor.Dispose();
            };
        }
Exemplo n.º 2
0
 public MainWindow(Staff inStaff,int Power)
 {
     InitializeComponent();
     curStaff=inStaff;            
     if (Power == 1)
     {
      
     }
     if (Power == 2)
     {
         //StockManger: Show cái j lên thì bỏ vào đây
         btnStaff.IsEnabled = false;
         btnPayment.IsEnabled = false;
         btnCustomer.IsEnabled = false;
         btnDiscount.IsEnabled = false;
         btnReport.IsEnabled = false;
     }
     if (Power == 3)
     {
         //Dealer: Show cái j lên thì bỏ vào đây
         btnStaff.IsEnabled = false;
         btnDiscount.IsEnabled = false;
         btnReport.IsEnabled = false;
     }
     NotificationWindow noti = new NotificationWindow();
     noti.Owner = Window.GetWindow(this);
     noti.Show();
     
 }
        private void ReadInConfigXML()
        {
            XmlDocument lXMLConfig = new XmlDocument();
            string lConfigLocation = @"C:\POS\Config\config.xml";

            if ( File.Exists( lConfigLocation ) )
            {
                int lDepartments = 0;
                //Load File
                FileStream lFileStream = new FileStream( lConfigLocation, FileMode.Open, FileAccess.Read );
                lXMLConfig.Load( lFileStream ); 
                XmlNodeList lXMLNodeList;
                lXMLNodeList = lXMLConfig.GetElementsByTagName( "Setup" );

                for ( int i = 0; i < lXMLNodeList.Count; i++ )
                {
                    if ( lXMLNodeList[ i ].Attributes.GetNamedItem( "departments" ).Name == "departments" )
                    {
                        lDepartments = Convert.ToInt16( lXMLNodeList[ i ].Attributes.GetNamedItem( "departments" ).Value.ToString() );
                    }
                }

                lFileStream.Close();

            }
            else
            {
                //Show error message
                NotificationWindow lNotify = new NotificationWindow( "Configuration Not Found!",
                    "The configuration file for this system was not found, please contact support!\r\n\r\nThe system will now exit",
                    "OKOnly" );
                lNotify.Show();
            }

        }
        internal void ProcessMessages()
        {
            try
            {
                MessagingFactory factory = MessagingFactory.Create(
                    ServiceBusEnvironment.CreateServiceUri("sb",
                        Properties.Settings.Default.SBNamespace,
                        String.Empty),
                    TokenProvider.CreateSharedSecretTokenProvider("wpfsample",
                            Properties.Settings.Default.SBListenerCredentials));
                MessageReceiver theQueue = factory.CreateMessageReceiver("thequeue");

                while (isProcessing)
                {
                    BrokeredMessage message = theQueue.Receive(new TimeSpan(0, 0, 0, 5));
                    if (message != null)
                    {
                        Dispatcher.Invoke((System.Action)(()
                            =>

                        {
                            NotificationWindow w;
                            try
                            {
                                w = new NotificationWindow(
                                    message.Properties["Sender"].ToString(),
                                    message.GetBody<String>(),
                                    message.Properties["Color"].ToString());
                            }
                            catch (KeyNotFoundException)
                            {
                                w = new NotificationWindow(
                                    "system",
                                    String.Format("Invalid message:\n{0}", message.GetBody<String>()),
                                    "Red"
                                );
                            }
                            WindowRegistry.Add(w);
                            w.Show();
                            message.Complete();
                        }));
                    }
                }
            }

            catch (Exception ex)
            {
                Dispatcher.Invoke((System.Action)(()
                    =>
                    {
                        btnServiceControl.Content = "Start Responding";
                        this.Background = new SolidColorBrush(Colors.Orange);
                        this.isProcessing = false;
                    }));
                MessageBox.Show(ex.Message, "Processing halted", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
        public void notify(Notification notification)
        {
            filterNotification(notification);

            var notificationViewModel = new NotificationViewModel(notification);
            var notificationWindow = new NotificationWindow(notificationViewModel);

            var screenWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
            var screenHeight = System.Windows.SystemParameters.PrimaryScreenHeight;

            var nHeight = notificationWindow.Height;
            var nWidth = notificationWindow.Width;

            var notificationSpot = -1;
            for (int i = 0; i < _maxNumNotifications; ++i) {
                if (_availableNotificationSpots[i]) {
                    notificationSpot = i;
                    break;
                }
            }
            if(notificationSpot == -1) {
                for (int i = 0; i < _maxNumNotifications; ++i)
                {
                    _availableNotificationSpots[i] = true;
                }
                notificationSpot = 0;
            }

            notificationWindow.Left = screenWidth - nWidth - _rightOffset;
            notificationWindow.Top = _topOffset + notificationSpot * 90;

            notificationWindow.Opacity = 0;
            notificationWindow.Show();
            _availableNotificationSpots[notificationSpot] = false;

            var showAnimation = new DoubleAnimation(0, 1, (Duration)_fadeInDuration);
            showAnimation.Completed += (s1, e1) =>
            {
                var waitAnimation = new DoubleAnimation(1, _displayDuration);
                waitAnimation.Completed += (s2, e2) =>
                {
                    var hideAnimation = new DoubleAnimation(0, (Duration)_fadeOutDuration);
                    hideAnimation.Completed += (s3, e3) =>
                    {
                        notificationWindow.Hide();
                        notificationWindow.Close();
                        _availableNotificationSpots[notificationSpot] = true;
                    };
                    notificationWindow.BeginAnimation(UIElement.OpacityProperty, hideAnimation);
                };
                notificationWindow.BeginAnimation(UIElement.OpacityProperty, waitAnimation);
            };
            notificationWindow.BeginAnimation(UIElement.OpacityProperty, showAnimation);
        }
Exemplo n.º 6
0
 private void AddNotificationToQueue(NotificationWindow notification)
 {
     if (toastWindow == null)
     {
         toastWindow = notification;
         notification.Show((int)ConfigurationSettings.NotificationTimer);
     }
     else
     {
         _notifyQueue.Enqueue(notification);
     }
 }
Exemplo n.º 7
0
        private void MessageAdded(AppMessage msg)
        {
            NotificationWindow nw = new NotificationWindow(msg.Caption, msg.Message, msg.FadeOut);
            nw.Owner = Window.GetWindow(this);
            nw.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            if (msg.FadeOut)
            {
                nw.Show();
            }
            else
            {
                nw.ShowDialog();
            }
        }
        private void Notify(string message)
        {
            if (App.Current.IsRunningOutOfBrowser)
            {
                var toast = new NotificationWindow { Width = 400, Height = 100 };

                var nc = new NotificationControl { NotificationText = { Text = message } };
                toast.Content = nc;

                toast.Show(3000);
            }
            else
            {
                MessageBox.Show(message);
            }
        }
        internal void ProcessMessages()
        {
            MessagingFactory factory = MessagingFactory.Create(
                ServiceBusEnvironment.CreateServiceUri("sb",
                    Properties.Settings.Default.SBNamespace,
                    String.Empty),
                TokenProvider.CreateSharedSecretTokenProvider("wpfsample",
                    Properties.Settings.Default.SBListenerCredentials));

            SubscriptionClient urgentMessageClient =
                factory.CreateSubscriptionClient("thetopic", "urgentmessages");

            while (isProcessing)
            {
                BrokeredMessage message = urgentMessageClient.Receive(new TimeSpan(0, 0, 2));
                if (message != null)
                {
                    Dispatcher.Invoke((System.Action)(() =>
                        {
                            try
                            {
                                var w = new NotificationWindow(
                                    message.Properties["Sender"].ToString(),
                                    message.GetBody<String>(),
                                    message.Properties["BackColor"].ToString(),
                                    message.Properties["ForeColor"].ToString()
                                );
                                WindowRegistry.Add(w);
                                w.Show();
                            }

                            catch (Exception ex)
                            {

                                btnServiceControl.Content = "Start Responding";
                                this.Background = new SolidColorBrush(Colors.Orange);
                                this.isProcessing = false;

                                MessageBox.Show(ex.Message, "Processing halted", MessageBoxButton.OK, MessageBoxImage.Stop);
                            }
                        }
                    ));

                    message.Complete();
                }
            }
        }
		/// <summary>
		/// Shows a toast notification for the specified model.
		/// </summary>
		/// <param name="rootModel">The root model.</param>
		/// <param name="durationInMilliseconds">How long the notification should appear for.</param>
		/// <param name="context">The context.</param>
		/// <param name="settings">The optional RadWindow Settings</param>
		public void ShowNotification(object rootModel, int durationInMilliseconds, object context = null, IDictionary<string, object> settings = null)
		{
			var window = new NotificationWindow();
			var view = ViewLocator.LocateForModel(rootModel, window, context);

			ViewModelBinder.Bind(rootModel, view, null);
			window.Content = (FrameworkElement)view;

			ApplySettings(window, settings);

			var activator = rootModel as IActivate;
			if (activator != null)
				activator.Activate();

			var deactivator = rootModel as IDeactivate;
			if (deactivator != null)
				window.Closed += delegate { deactivator.Deactivate(true); };

			window.Show(durationInMilliseconds);
		}
Exemplo n.º 11
0
        private static void Display(NotificationWindow window)
        {
            window.Show();

            System.Media.SystemSounds.Hand.Play();
        }
Exemplo n.º 12
0
        private void ShowPopup(Notification notification)
        {
            if (notification == null
                || notification.IsDismissed)
            {
                return;
            }

            if (this.Displays(notification))
            {
                return;
            }

            DisplayedNotifications.Add(notification);

            lock (lockObject)
            {
                if (notification.IsDismissed)
                {
                    return;
                }

                

                _timer.Dispatcher.Invoke(
                    DispatcherPriority.Normal,
                    new Action(
                        delegate()
                        {
                            NotificationWindow notifier = new NotificationWindow(notification)
                                    {
                                        WindowStartupLocation = WindowStartupLocation.CenterOwner,
                                        OtherWindowCount = DisplayedNotifications.CountBeforeReset - 1,
                                        CloseCommand = new RemoveNotificationCommand(notification, DisplayedNotifications)
                                    };
                            notifier.BeginInvoke();
                            notifier.Show();
                        }));
            }

        }
Exemplo n.º 13
0
 public static void ShowNotification(string Title, string Message, Contact contact)
 {
     NotificationWindow wnd = new NotificationWindow();
     wnd.Left = (SystemParameters.FullPrimaryScreenWidth - wnd.Width) - 10;
     wnd.Top = 10;
     wnd.txt_notificationtitle.Content = Title;
     wnd.txt_notificationcontent.Text = Message;
     wnd.Show();
     Windows.Add(wnd);
     ReDraw();
 }
Exemplo n.º 14
0
 private void btnNotify_Click(object sender , RoutedEventArgs s)
 {
     var nw = new NotificationWindow();
     nw.Content = new MainPage();
     nw.Show(5000);
 }
Exemplo n.º 15
0
        public static void ShowCallNotification(Contact contact, string UDPAddress, int Port)
        {
            SoundManager.VoiceRingingSound.PlayLooping();

            NotificationWindow wnd = new NotificationWindow(true);
            wnd.Left = (SystemParameters.FullPrimaryScreenWidth - wnd.Width) - 10;
            wnd.Top = 10;
            wnd.txt_notificationtitle.Content = "Incoming Call From " + contact.NickName;
            wnd.txt_notificationcontent.Text = "";

            wnd.btn_call_accept.Visibility = Visibility.Visible;
            wnd.btn_call_deny.Visibility = Visibility.Visible;
            wnd.profile_image.Visibility = Visibility.Visible;

            wnd.profile_image_source.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("https://blaze-games.com/api/image/nocompress/?nickname=" + contact.NickName));

            wnd.UDPAddress = UDPAddress;
            wnd.Port = Port;
            wnd.contact = contact;

            wnd.Show();
            Windows.Add(wnd);
            ReDraw();
        }
Exemplo n.º 16
0
 void Notifications_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.NewItems == null)
     {
         return;
     }
     foreach (var item in e.NewItems)
     {
         // notification windows management
         var nw = new NotificationWindow(this.FindAncestor<Window>(), NotificationTime, NotificationTemplate, _notificationsWindows) { DataContext = item };
         _notificationsWindows.Add(nw);
         nw.Closed += nw_Closed;
         nw.Show();
     }
 }
Exemplo n.º 17
0
Arquivo: Task.cs Projeto: stiano/sl4
        public override void Execute()
        {
            if (Application.Current.IsRunningOutOfBrowser)
            {
                var toast =
                    new ToastControl
                        {
                            Title = {Text = Title + _counter++},
                            //Message = {Text = Message},
                            Height = 100,
                            MaxHeight = 100,
                            Width = 400,
                            MaxWidth = 400
                        };

                var notification =
                    new NotificationWindow
                        {
                            Height = 100,
                            Width = 400
                        };

                var text = new TextBlock();
                text.Text = "La la la" + _counter;

                notification.Content = toast;
                notification.Closed += NotificationClosed;

                lock (SyncLock)
                {
                    if (_currentWindow == null)
                    {
                        _currentWindow = notification;
                        _currentWindow.Show(TimeoutMs);
                    }
                    else
                    {
                        NotifyQueue.Enqueue(notification);
                    }
                }
            }
        }
Exemplo n.º 18
0
Arquivo: Task.cs Projeto: stiano/sl4
 void NotificationClosed(object sender, System.EventArgs e)
 {
     lock (SyncLock)
     {
         _currentWindow = null;
         if (NotifyQueue.Count > 0)
         {
             _currentWindow = NotifyQueue.Dequeue();
             _currentWindow.Show(TimeoutMs);
         }
     }
 }
Exemplo n.º 19
0
 public void ShowWindow(NotificationWindow ex)
 {
     ex.Show();
 }
Exemplo n.º 20
0
 public void AddNotification(string text)
 {
     var nw = new NotificationWindow(this.FindAncestor<Window>(), NotificationTime, NotificationTemplate, _notificationsWindows, text);
     _notificationsWindows.Add(nw);
     nw.Closed += nw_Closed;
     nw.Show();
 }
Exemplo n.º 21
0
        private void btNotify_Click(object sender, RoutedEventArgs e)
        {
            if (Application.Current.IsRunningOutOfBrowser)
            {
                NotificationWindow notify = new NotificationWindow();
                notify.Height = 100;
                notify.Width = 200;

                StackPanel sp = new StackPanel();
                TextBlock text = new TextBlock();
                text.Text = "Hello";
                sp.Children.Add(text);
                Button btClose = new Button();
                btClose.Content = "chiudi";
                btClose.Click +=  delegate(object s, RoutedEventArgs ev)
                {
                    notify.Close();
                };
                sp.Children.Add(btClose);

                notify.Content = sp;
                notify.Show(5000);
            }
        }
Exemplo n.º 22
0
 public virtual void ShowNotification(object rootModel, int durationInMilliseconds, object context = null, IDictionary<string, object> settings = null)
 {
     EventHandler handler = null;
     NotificationWindow window = new NotificationWindow();
     UIElement element = ViewLocator.LocateForModel(rootModel, window, context);
     ViewModelBinder.Bind(rootModel, element, null);
     window.Content = (FrameworkElement) element;
     this.ApplySettings(window, settings);
     IActivate activate = rootModel as IActivate;
     if (activate != null)
     {
         activate.Activate();
     }
     IDeactivate deactivator = rootModel as IDeactivate;
     if (deactivator != null)
     {
         if (handler == null)
         {
             handler = (, ) => deactivator.Deactivate(true);
         }
         window.Closed += handler;
     }
     window.Show(durationInMilliseconds);
 }