Inheritance: MonoBehaviour
示例#1
0
        private void OnGuiUpdate(GuiUpdate obj)
        {
            switch (obj.Status)
            {
            case Status.Failed:
                return;

            case Status.Succeeded:
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
                    ProcessSucceeded(obj.Settings);
                }));
                return;

            case Status.UpToDate:
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
                    ProcessUpToDate(obj.Settings);
                }));
                return;

            case Status.Notification:
                // (Konrad) This can be ignored here since we are not updating the UI.
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#2
0
        /// <summary>
        /// This method handles all GUI updates coming from the ZombieService. Since we stored the
        /// reference to a control on this view model, it's a good place to set status manager updates
        /// from here. They have to be dispatched on a UI thread.
        /// </summary>
        /// <param name="obj"></param>
        private void OnGuiUpdate(GuiUpdate obj)
        {
            // (Konrad) Since the UpdateRunner runs on a pool thread we can't set UI controls from there.
            // One way to set their status is to use a Dispatcher that every UI control has.

            switch (obj.Status)
            {
            case Status.Failed:
                Control?.Dispatcher.Invoke(() => { StatusBarManager.StatusLabel.Text = obj.Message; });
                break;

            case Status.Succeeded:
                Model.Settings = obj.Settings;
                Control?.Dispatcher.Invoke(() => { StatusBarManager.StatusLabel.Text = obj.Message; });
                break;

            case Status.UpToDate:
                Model.Settings = obj.Settings;
                Control?.Dispatcher.Invoke(() => { StatusBarManager.StatusLabel.Text = obj.Message; });
                break;

            case Status.Notification:
                Model.ShowNotification(obj.Message);
                Control?.Dispatcher.Invoke(() => { StatusBarManager.StatusLabel.Text = obj.Message; });
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#3
0
 private static void OnGuiUpdate(GuiUpdate update)
 {
     if (StopUpdates)
     {
         return;
     }
     Messenger.Default.Send(update);
 }
示例#4
0
        public void PublishGuiUpdate(GuiUpdate update)
        {
            var se = new GuiUpdateEventArgs
            {
                Update = update
            };

            GuiUpdateEvent(this, se);
        }
示例#5
0
        //ctor
        internal TerminalWindow(SessionDataObject sdo)
        {
            this.SessionData = sdo;
            InitializeComponent();
            this.SetStyle(
                System.Windows.Forms.ControlStyles.UserPaint |
                System.Windows.Forms.ControlStyles.AllPaintingInWmPaint |
                System.Windows.Forms.ControlStyles.OptimizedDoubleBuffer,
                true);

            refresh = new GuiUpdate(DoRefresh);
            ticker  = new System.Timers.ElapsedEventHandler(heartbeat_Tick);

            heartbeat          = new System.Timers.Timer(500);
            heartbeat.Elapsed += ticker;
            heartbeat.Start();
        }
示例#6
0
        /// <summary>
        /// Broadcasts a an event to all clients that are subscribed. This will
        /// cause GUI updates on all Zombie instances.
        /// </summary>
        /// <param name="update">Update message.</param>
        public void Broadcast(GuiUpdate update)
        {
            var binding  = ServiceUtils.CreateClientBinding(ServiceUtils.FreeTcpPort());
            var endpoint = new EndpointAddress(new Uri("http://localhost:8000/ZombieService/Service.svc"));
            var context  = new InstanceContext(new ZombieServiceCallback());
            var client   = new ZombieServiceClient(context, binding, endpoint);

            client.Open();
            client.Subscribe();

            try
            {
                client.PublishGuiUpdate(update);
                client.Unsubscribe();
                client.Close();
            }
            catch (Exception e)
            {
                _logger.Fatal(e.Message);
                client.Abort();
            }
        }
示例#7
0
        /// <summary>
        /// Utility method that publishes a GUI update to ZombieGUI.
        /// </summary>
        /// <param name="settings">Latest ZombieSettings file that GUI will be updated to.</param>
        /// <param name="status">Message status type.</param>
        /// <param name="message">String message to be displayed in the GUI.</param>
        private static void PublishGuiUpdate(ZombieSettings settings, Status status, string message)
        {
            var msg = "Status: " + status + " Message: " + message;

            if (string.IsNullOrWhiteSpace(Program.RecentLog) || msg != Program.RecentLog)
            {
                _logger.Info(msg);
                Program.RecentLog = msg;
            }

            var update = new GuiUpdate
            {
                Settings = settings,
                Status   = status,
                Message  = message
            };

            new Thread(() => new ZombieMessenger().Broadcast(update))
            {
                Priority     = ThreadPriority.BelowNormal,
                IsBackground = true
            }.Start();
        }
示例#8
0
 public void GuiUpdate(GuiUpdate update)
 {
     _syncContext.Post(OnServiceCallbackEvent, new GuiUpdateEventArgs {
         Update = update
     });
 }
示例#9
0
 public void GuiUpdate(GuiUpdate update)
 {
     GuiUpdateCallbackEvent(update);
 }