예제 #1
0
 /// <summary>
 /// Called on UI bus message.
 /// </summary>
 /// <param name="message">The message.</param>
 public void OnMessage(ApplicationMessage <UIBusMessageTypes> message)
 {
     try {
         switch (message.MessageType)
         {
         case UIBusMessageTypes.InformationRequest: {
             InformationRequest irqt = message.Payload as InformationRequest;
             if (irqt != null)
             {
                 WorkspaceViewModel vm = irqt.Tag as WorkspaceViewModel;
                 if (vm != null)
                 {
                     PopupView pw = new PopupView(vm);
                     pw.Owner = this.MainWindow;
                     pw.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                     if (pw.ShowDialog() == true)
                     {
                         irqt.CompleteMethod(irqt);
                     }
                 }
                 else if (irqt.ResultType == typeof(System.IO.File))
                 {
                     SelectFileName(irqt);
                 }
             }
         }
         break;
         }
     }
     catch (Exception x) {
         AppContext.Current.LogTechError(string.Format("Technical error {0}: {1}", x.GetType().Name, x.Message), x);
         System.Diagnostics.Debug.WriteLine(x.GetDetails());
     }
 }
예제 #2
0
파일: UIBus.cs 프로젝트: xcrover/MediaRat
        /// <summary>
        /// Sends the specified message and wait untill all the subscribers are completed.
        /// </summary>
        /// <param name="message">The message.</param>
        public void Send(ApplicationMessage <TMessageType> message)
        {
            List <IApplicationBusSubscriber <TMessageType> > targets = null;

            try {
                this._rwLock.AcquireReaderLock(lockTimeOut);
                if (this._subscribers.Keys.Count > 0)
                {
                    targets = new List <IApplicationBusSubscriber <TMessageType> >(
                        from sb in this._subscribers.Keys select sb
                        );
                }
            }
            finally {
                this._rwLock.ReleaseReaderLock();
            }
            if (targets != null)
            {
                foreach (var sbs in targets)
                {
                    sbs.OnMessage(message);
                }
            }
        }
예제 #3
0
파일: UIBus.cs 프로젝트: xcrover/MediaRat
 /// <summary>
 /// Posts the specified message on the background thread and continue execution.
 /// </summary>
 /// <param name="message">The message.</param>
 public void Post(ApplicationMessage <TMessageType> message)
 {
     ThreadPool.QueueUserWorkItem((p) => this.Send(message));
 }