Example #1
0
        private async void Button_ClickedAsync(object sender, EventArgs e)
        {
            if (!await CheckPermission(Permission.LocationAlways))
            {
                return;
            }

            //if (!await CheckPermission(Permission.Location))
            //    return;

            if (!await CheckPermission(Permission.Storage))
            {
                return;
            }

            viewModel.TestButtonEnabled = false;
            try
            {
                if (!await Pod.WithLotAndTid(42692, 521355))
                {
                    Pod.RadioAddress = 0x1f0e89f3;
                }

                var cts      = new CancellationTokenSource();
                var progress = new MessageProgress();
                await Pod.UpdateStatus(progress, cts.Token);

                //await pod.Bolus(0.5m);
            }
            finally
            {
                viewModel.TestButtonEnabled = true;
            }
        }
Example #2
0
        public static bool InteractiveValidationCallback(string message, ErrorSeverity severity, int code, StateHolder state)
        {
            Dictionary <int, bool> responses       = (Dictionary <int, bool>)state ["responses"];
            MessageProgress        messageProgress = null;

            if (state.ContainsKey("messageProgress"))
            {
                messageProgress = (MessageProgress)state ["messageProgress"];
            }

            if (responses.ContainsKey(code))
            {
                return(severity == ErrorSeverity.Warning && responses [code]);
            }

            try {
                if (messageProgress != null)
                {
                    messageProgress.Hide();
                }
                using (MessageError dlgError = new MessageError(message, severity)) {
                    if (severity == ErrorSeverity.Warning)
                    {
                        dlgError.Buttons = MessageButtons.YesNo | MessageButtons.Remember;
                        ResponseType resp = dlgError.Run();
                        if (dlgError.RememberChoice)
                        {
                            responses [code] = resp == ResponseType.Yes;
                        }

                        return(resp == ResponseType.Yes);
                    }
                    else
                    {
                        dlgError.Buttons = MessageButtons.OK | MessageButtons.Remember;
                        dlgError.Run();
                        if (dlgError.RememberChoice)
                        {
                            responses [code] = true;
                        }
                        return(false);
                    }
                }
            } finally {
                if (messageProgress != null)
                {
                    messageProgress.Show();
                }
            }
        }
Example #3
0
    public void UpdateMessageState(MessageProgress newState)
    {
        state = newState;
        switch (newState)
        {
        case (MessageProgress.Sent):
            StartSentAnimation();
            break;

        case (MessageProgress.Seen):
            StartRecievedAnimation();
            break;

        default:
            break;
        }
    }
Example #4
0
        public static void ImportData <T> (EventHandler <ValidateEventArgs> validateCallback = null, EventHandler <ImportEventArgs> commitCallback = null, bool usesLocation = false) where T : IStrongEntity, IPersistableEntity <T>
        {
            Dictionary <int, bool> responses = new Dictionary <int, bool> ();

            using (MessageProgress progress = new MessageProgress(Translator.GetString("Importing..."), "Icons.Import24.png", Translator.GetString("Importing in progress..."))) {
                bool cancelImport = false;
                progress.Response          += delegate { cancelImport = true; };
                progress.CustomProgressText = true;

                StateHolder state = new StateHolder();
                state ["responses"]       = responses;
                state ["messageProgress"] = progress;

                ImportData(delegate(T entity, long?locationId, int current, int total, out bool cancel)
                {
                    progress.Show();
                    progress.Progress     = ((double)current * 100) / (total - 1);
                    progress.ProgressText = string.Format(Translator.GetString("{0} of {1}"), current + 1, total);
                    PresentationDomain.ProcessUIEvents();
                    cancel = cancelImport;
                    if (validateCallback != null)
                    {
                        ValidateEventArgs args = new ValidateEventArgs(InteractiveValidationCallback, state);
                        validateCallback(entity, args);
                        if (!args.IsValid)
                        {
                            return;
                        }
                    }

                    if (!entity.Validate(InteractiveValidationCallback, state))
                    {
                        return;
                    }

                    entity.CommitChanges();

                    if (commitCallback != null)
                    {
                        commitCallback(entity, new ImportEventArgs(locationId));
                    }
                }, usesLocation);
            }
        }
Example #5
0
 private void OnEventReceived(BaseEvent ommEvent)
 {
     if (ommEvent == null)
     {
         return;
     }
     if (ommEvent is EventDECTSubscriptionMode dectSubscriptionMode)
     {
         DECTSubscriptionModeChanged?.Invoke(this, new OmmEventArgs <EventDECTSubscriptionMode>(dectSubscriptionMode));
     }
     else if (ommEvent is EventAlarmCallProgress alarmCallProgress)
     {
         AlarmCallProgress?.Invoke(this, new OmmEventArgs <EventAlarmCallProgress>(alarmCallProgress));
     }
     else if (ommEvent is EventRFPSummary rfpSummary)
     {
         RfpSummary?.Invoke(this, new OmmEventArgs <EventRFPSummary>(rfpSummary));
     }
     else if (ommEvent is EventPPDevSummary ppDevSummary)
     {
         PPDevSummary?.Invoke(this, new OmmEventArgs <EventPPDevSummary>(ppDevSummary));
     }
     else if (ommEvent is EventPPUserSummary ppUserSummary)
     {
         PPUserSummary?.Invoke(this, new OmmEventArgs <EventPPUserSummary>(ppUserSummary));
     }
     else if (ommEvent is EventPPDevCnf ppDevCnf)
     {
         PPDevCnf?.Invoke(this, new OmmEventArgs <EventPPDevCnf>(ppDevCnf));
     }
     else if (ommEvent is EventPPUserCnf ppUserCnf)
     {
         PPUserCnf?.Invoke(this, new OmmEventArgs <EventPPUserCnf>(ppUserCnf));
     }
     else if (ommEvent is EventPPCnf ppCnf)
     {
         PPCnf?.Invoke(this, new OmmEventArgs <EventPPCnf>(ppCnf));
     }
     else if (ommEvent is EventRFPState rfpState)
     {
         RFPState?.Invoke(this, new OmmEventArgs <EventRFPState>(rfpState));
     }
     else if (ommEvent is EventRFPCnf rfpCnf)
     {
         RFPCnf?.Invoke(this, new OmmEventArgs <EventRFPCnf>(rfpCnf));
     }
     else if (ommEvent is EventRFPSyncRel rfpSyncRel)
     {
         RFPSyncRel?.Invoke(this, new OmmEventArgs <EventRFPSyncRel>(rfpSyncRel));
     }
     else if (ommEvent is EventRFPSyncQuality rfpSyncQuality)
     {
         RFPSyncQuality?.Invoke(this, new OmmEventArgs <EventRFPSyncQuality>(rfpSyncQuality));
     }
     else if (ommEvent is EventStbStateChange stbStateChange)
     {
         StbStateChange?.Invoke(this, new OmmEventArgs <EventStbStateChange>(stbStateChange));
     }
     else if (ommEvent is EventLicenseCnf licenseCnf)
     {
         LicenseCnf?.Invoke(this, new OmmEventArgs <EventLicenseCnf>(licenseCnf));
     }
     else if (ommEvent is EventMessageProgress messageProgress)
     {
         MessageProgress?.Invoke(this, new OmmEventArgs <EventMessageProgress>(messageProgress));
     }
     else if (ommEvent is EventMessageConfirmation messageConfirmation)
     {
         MessageConfirmation?.Invoke(this, new OmmEventArgs <EventMessageConfirmation>(messageConfirmation));
     }
     else if (ommEvent is EventMessageQueueEmpty messageQueueEmpty)
     {
         MessageQueueEmpty?.Invoke(this, new OmmEventArgs <EventMessageQueueEmpty>(messageQueueEmpty));
     }
     else if (ommEvent is EventMessageSend messageSend)
     {
         MessageSend?.Invoke(this, new OmmEventArgs <EventMessageSend>(messageSend));
     }
     else if (ommEvent is EventPositionHistory positionHistory)
     {
         PositionHistory?.Invoke(this, new OmmEventArgs <EventPositionHistory>(positionHistory));
     }
     else if (ommEvent is EventPositionInfo positionInfo)
     {
         PositionInfo?.Invoke(this, new OmmEventArgs <EventPositionInfo>(positionInfo));
     }
     else if (ommEvent is EventPositionTrack positionTrack)
     {
         PositionTrack?.Invoke(this, new OmmEventArgs <EventPositionTrack>(positionTrack));
     }
     else if (ommEvent is EventPositionRequest positionRequest)
     {
         PositionRequest?.Invoke(this, new OmmEventArgs <EventPositionRequest>(positionRequest));
     }
     else if (ommEvent is EventPPState ppState)
     {
         PPState?.Invoke(this, new OmmEventArgs <EventPPState>(ppState));
     }
     else if (ommEvent is EventDECTAuthCodeCnf dectAuthCodeCnf)
     {
         DECTAuthCodeCnf?.Invoke(this, new OmmEventArgs <EventDECTAuthCodeCnf>(dectAuthCodeCnf));
     }
 }