예제 #1
0
        private void OnShowToast(ShowToastMessage showToastMessage)
        {
            var toast = new ToastViewModel(showToastMessage, _chatDocumentCreator(), _bus, _activator);
            Toasts.Add(toast);

            toast.Closed.SubscribeOnceUI(_ =>
                {
                    Toasts.Remove(toast);
                    toast.Dispose();
                });
        }
예제 #2
0
        public ToastViewModel(ShowToastMessage showToastMessage, IChatDocument document, IMessageBus bus, IApplicationActivator activator)
        {
            _document          = document;
            _document.FontSize = 14;
            IsVisible          = true;
            RoomName           = showToastMessage.Message.Room.Name;
            _document.AddMessage(showToastMessage.Message.Message, showToastMessage.Message.User, null);

            CloseCommand    = new ReactiveCommand();
            ActivateCommand = new ReactiveCommand();

            Closed = Observable.Timer(TimeSpan.FromSeconds(showToastMessage.Action.SecondsVisible), RxApp.TaskpoolScheduler)
                     .Do(_ => IsClosing = true).Delay(TimeSpan.FromSeconds(2), RxApp.TaskpoolScheduler)
                     .Select(_ => Unit.Default)
                     .Merge(CloseCommand.Select(_ => Unit.Default))
                     .Merge(ActivateCommand.Select(_ => Unit.Default));

            Subscribe(() => bus.RegisterMessageSource(
                          ActivateCommand.Select(
                              _ => new ActivateModuleByIdMessage(ModuleNames.MainCampfireView, showToastMessage.Message.Room.Id))
                          .Do(_ => activator.Activate())));
        }
예제 #3
0
        private void SaveDataToCsv(int index)
        {
            Task.Run(() => {
                this.IsBusy = true;
                try
                {
                    var fileName = this.GetFileName(index);

                    this.SaveDataToCsv(fileName);

                    this.State = StartPageStates.Rescan;
                }
                catch (Exception exception)
                {
                    ShowToastMessage.Send(exception.Message);
                }
                finally
                {
                    this.IsBusy = false;
                }
            });
        }
예제 #4
0
        public ToastViewModel(ShowToastMessage showToastMessage, IChatDocument document, IMessageBus bus, IApplicationActivator activator)
        {
            _document = document;
            _document.FontSize = 14;
            IsVisible = true;
            RoomName = showToastMessage.Message.Room.Name;
            _document.AddMessage(showToastMessage.Message.Message, showToastMessage.Message.User, null);

            CloseCommand = new ReactiveCommand();
            ActivateCommand = new ReactiveCommand();

            Closed = Observable.Timer(TimeSpan.FromSeconds(showToastMessage.Action.SecondsVisible), RxApp.TaskpoolScheduler)
                 .Do(_ => IsClosing = true).Delay(TimeSpan.FromSeconds(2), RxApp.TaskpoolScheduler)
                 .Select(_ => Unit.Default)
                 .Merge(CloseCommand.Select(_ => Unit.Default))
                 .Merge(ActivateCommand.Select(_ => Unit.Default));

            Subscribe(() =>bus.RegisterMessageSource(
                ActivateCommand.Select(
                    _ => new ActivateModuleByIdMessage(ModuleNames.MainCampfireView, showToastMessage.Message.Room.Id))
                    .Do(_ => activator.Activate())));
        }
예제 #5
0
        private void CheckData(int index)
        {
            Task.Run(() => {
                this.IsBusy = true;
                try
                {
                    var storeData = this.ReadDataFromCsv(index);

                    //var currentSample = _currentData.Select(sd => (double)sd.Y).ToArray();
                    //var storeSample = storeData.Select(sd => (double)sd.Y).ToArray();

                    var current = new List <Double>();
                    var store   = new List <Double>();

                    foreach (var currentItem in _currentData)
                    {
                        var storeItem = storeData.FirstOrDefault(sd => sd.X == currentItem.X);
                        if (storeItem != null)
                        {
                            current.Add(currentItem.Y);
                            store.Add(storeItem.Y);
                        }
                    }

                    //var adv = _oakCrossCorr.ADV(current.ToArray(), store.ToArray());
                    //var fdav = _oakCrossCorr.FDAV(current.ToArray(), store.ToArray());
                    //var fdls = _oakCrossCorr.FDLS(current.ToArray(), store.ToArray());
                    //var idiff = _oakCrossCorr.IDIFF(current.ToArray(), store.ToArray());
                    //var iis = _oakCrossCorr.IS(current.ToArray(), store.ToArray());
                    //var ls = _oakCrossCorr.LS(current.ToArray(), store.ToArray());
                    //var savg = _oakCrossCorr.SAVG(current.ToArray(), store.ToArray());

                    var coeff = _oakCrossCorr.GetCoeff(current.ToArray(), store.ToArray());

                    var text   = "";
                    var result = TestResults.OK;
                    if (coeff > 0.9)
                    {
                        result = TestResults.OK;
                        text   = "SAFE ({0})";
                    }
                    else if ((coeff > 0.7) && (coeff <= 0.9))
                    {
                        result = TestResults.Warning;
                        text   = "WARNING ({0})";
                    }
                    else
                    {
                        result = TestResults.Danger;
                        text   = "DANGER ({0})";
                    }

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        this.TestResultText      = String.Format(text, coeff.ToString("0.0000"));
                        this.TestResult          = result;
                        this.IsTestResultVisible = true;
                    });
                }
                catch (Exception exception)
                {
                    ShowToastMessage.Send(exception.Message);
                }
                finally
                {
                    this.IsBusy = false;
                }
            });
        }
예제 #6
0
 private void ShowToast(ShowToastMessage message)
 {
     this.RunOnUiThread(() => {
         Toast.MakeText(this, message.Text, ToastLength.Long).Show();
     });
 }
예제 #7
0
 private void UnsubscribeMessages()
 {
     ShowToastMessage.Unsubscribe(this);
     CloseAppMessage.Unsubscribe(this);
     SendFileByEmailMessage.Unsubscribe(this);
 }
예제 #8
0
 private void SubscribeMessages()
 {
     ShowToastMessage.Subscribe(this, this.ShowToast);
     CloseAppMessage.Subscribe(this, this.CloseApp);
     SendFileByEmailMessage.Subscribe(this, this.SendFileByEmail);
 }