Exemplo n.º 1
0
        private void InitSystem()
        {
            this.Icon = BitmapFrame.Create(this.GetImageResourceStream("main.ico"));

            _uiState = SbmqSystem.UIState;
            RestoreWindowState();

            this.IsEnabled       = false;
            lbLoading.Visibility = System.Windows.Visibility.Visible;

            BackgroundWorker w = new BackgroundWorker();

            w.DoWork += (s, e) => {
                try {
                    _sys = SbmqSystem.Create();
                    _sys.ItemsChanged   += sys_ItemsChanged;
                    _sys.ErrorOccured   += _sys_ErrorOccured;
                    _sys.WarningOccured += _sys_WarningOccured;
                    _mgr = _sys.Manager;
                } catch (Exception ex) {
                    Dispatcher.Invoke(DispatcherPriority.Normal,
                                      new Action(() => { LogError("Failed to initialize System", ex, true); }));
                }
            };

            w.RunWorkerCompleted += (s, e) => {
                RestoreQueueButtonsState();
                this.IsEnabled       = true;
                lbLoading.Visibility = System.Windows.Visibility.Hidden;


                btnSendCommand.IsEnabled       = _sys.CanSendCommand;
                btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions;

                lbItems.ItemsSource = _sys.Items;

                SetupContextMenu();

                UpdateNotifyIconText();

                if (_sys.Config.StartCount == 1)
                {
                    ShowConfigDialog();
                }
                else if (_sys.Config.VersionCheck.Enabled)
                {
                    if (_sys.Config.VersionCheck.LastCheck < DateTime.Now.AddDays(-14))
                    {
                        CheckIfLatestVersion(false);
                    }
                }

                UpdateTitle();

                _sys.StartMonitoring();
            };

            w.RunWorkerAsync();
        }
Exemplo n.º 2
0
        private void InitSystem()
        {
            this.Icon = BitmapFrame.Create(this.GetImageResourceStream("main.ico"));

              _uiState = SbmqSystem.UIState;
              RestoreWindowState();

              this.IsEnabled = false;
              lbLoading.Visibility = System.Windows.Visibility.Visible;

              BackgroundWorker w = new BackgroundWorker();
              w.DoWork += (s, e) => {
            try {
              _sys = SbmqSystem.Create();
              _sys.ItemsChanged += sys_ItemsChanged;
              _sys.ErrorOccured += _sys_ErrorOccured;
              _sys.WarningOccured += _sys_WarningOccured;

              _sys.StartedLoadingQueues += _sys_StartedLoadingQueues;
              _sys.FinishedLoadingQueues += _sys_FinishedLoadingQueues;

              _features = _sys.GetDiscoveryService().Features;

              _mgr = _sys.Manager;

            } catch( Exception ex ) {

              Dispatcher.Invoke(DispatcherPriority.Normal,
                            new Action(() => { LogError("Failed to initialize System", ex, true); }));

            }
              };

              w.RunWorkerCompleted += (s, e) => {

            RestoreQueueButtonsState();
            this.IsEnabled = true;

            btnSendCommand.IsEnabled = _sys.CanSendCommand;
            btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions;

            lbItems.ItemsSource = _sys.Items;
            if( !lbItems.IsEnabled )
              lbItems.IsEnabled = true;

            SetupContextMenu();

            UpdateNotifyIconText();

            if( _sys.Config.StartCount == 1 ) {
              ShowConfigDialog();

            } else if( _sys.Config.VersionCheck.Enabled ) {
              if( _sys.Config.VersionCheck.LastCheck < DateTime.Now.AddDays(-14) )
            CheckIfLatestVersion(false);
            }

            UpdateTitle();

            _sys.StartMonitoring();

            lbLoading.Visibility = System.Windows.Visibility.Hidden;
              };

              w.RunWorkerAsync();
        }
        private void InitSystem()
        {
            this.Icon = BitmapFrame.Create(this.GetImageResourceStream("main.ico"));

              _dlg = new ContentWindow();

              _uiState = SbmqSystem.UIState;
              RestoreWindowState();

              this.IsEnabled = false;

              BackgroundWorker w = new BackgroundWorker();
              w.DoWork += (s,e) => {
            _sys = SbmqSystem.Create();
            _sys.ItemsChanged += MessageMgr_ItemsChanged;

            _mgr = _sys.Manager;
              };

              w.RunWorkerCompleted += (s,e) => {

            RestoreQueueButtonsState();
            this.IsEnabled = true;

            btnSendCommand.IsEnabled = _sys.CanSendCommand;
            btnViewSubscriptions.IsEnabled = _sys.CanViewSubscriptions;

            lbItems.ItemsSource = _mgr.Items;

            SetupContextMenu();

            SetupQueueMonitorTimer(_sys.Config.MonitorInterval);

            if( _sys.Config.StartCount == 1 ) {
              ShowConfigDialog();

            } else if( _sys.Config.VersionCheck.Enabled ) {
              if( _sys.Config.VersionCheck.LastCheck < DateTime.Now.AddDays(-14) )
            CheckIfLatestVersion(false);
            }

              };

              w.RunWorkerAsync();
        }