Пример #1
0
        /// <summary>
        /// Event callback for a release device request for instance 2.
        /// </summary>
        /// <param name="sender">The drawer receiving the release device request.</param>
        /// <param name="e">Unused for ReleaseDeviceRequested events.</param>
        private async void claimedCashDrawerInstance2_ReleaseDeviceRequested(ClaimedCashDrawer drawer, object e)
        {
            await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() =>
            {
                rootPage.NotifyUser("Release instance 2 requested.", NotifyType.StatusMessage);

                if (RetainCheckBox2.IsChecked == true)
                {
                    if (await claimedCashDrawerInstance2.RetainDeviceAsync() == false)
                    {
                        rootPage.NotifyUser("Cash drawer instance 2 retain failed.", NotifyType.ErrorMessage);
                    }
                }
                else
                {
                    claimedCashDrawerInstance2.Dispose();
                    claimedCashDrawerInstance2 = null;

                    if (cashDrawerInstance2 != null)
                    {
                        cashDrawerInstance2.Dispose();
                        cashDrawerInstance2 = null;
                    }

                    SetReleasedUI(CashDrawerInstance.Instance2);
                }
            });
        }
Пример #2
0
        /// <summary>
        /// Resets the display elements to original state
        /// </summary>
        private void ResetScenarioState()
        {
            if (claimedCashDrawerInstance1 != null)
            {
                claimedCashDrawerInstance1.Dispose();
                claimedCashDrawerInstance1 = null;
            }

            if (claimedCashDrawerInstance2 != null)
            {
                claimedCashDrawerInstance2.Dispose();
                claimedCashDrawerInstance2 = null;
            }

            if (cashDrawerInstance1 != null)
            {
                cashDrawerInstance1.Dispose();
                cashDrawerInstance1 = null;
            }

            if (cashDrawerInstance2 != null)
            {
                cashDrawerInstance2.Dispose();
                cashDrawerInstance2 = null;
            }

            ClaimButton1.IsEnabled    = true;
            ClaimButton2.IsEnabled    = true;
            ReleaseButton1.IsEnabled  = false;
            ReleaseButton2.IsEnabled  = false;
            RetainCheckBox1.IsChecked = true;
            RetainCheckBox2.IsChecked = true;

            rootPage.NotifyUser("Click a claim button to begin.", NotifyType.StatusMessage);
        }
        /// <summary>
        /// Event callback for release instance 2 button.
        /// </summary>
        /// <param name="sender">Button that was clicked.</param>
        /// <param name="e">Event data associated with click event.</param>
        private void ReleaseButton2_Click(object sender, RoutedEventArgs e)
        {
            if (claimedCashDrawerInstance2 != null)
            {
                claimedCashDrawerInstance2.Dispose();
                claimedCashDrawerInstance2 = null;

                SetReleasedUI(CashDrawerInstance.Instance2);

                rootPage.NotifyUser("Claimed instance 2 was released.", NotifyType.StatusMessage);
            }
        }
        /// <summary>
        /// Reset the scenario to its initial state.
        /// </summary>
        private void ResetScenarioState()
        {
            drawer = null;

            if (claimedDrawer != null)
            {
                claimedDrawer.Dispose();
                claimedDrawer = null;
            }

            InitDrawerButton.IsEnabled = true;
            OpenDrawerButton.IsEnabled = false;

            rootPage.NotifyUser("Click the init drawer button to begin.", NotifyType.StatusMessage);
        }
Пример #5
0
        /// <summary>
        /// Reset the scenario to its initial state.
        /// </summary>
        private void ResetScenarioState()
        {
            drawer = null;

            if (claimedDrawer != null)
            {
                claimedDrawer.Dispose();
                claimedDrawer = null;
            }

            UpdateStatusOutput(CashDrawerStatusKind.Offline);

            InitDrawerButton.IsEnabled = true;
            DrawerWaitButton.IsEnabled = false;

            rootPage.NotifyUser("Click the init drawer button to begin.", NotifyType.StatusMessage);
        }
Пример #6
0
        /// <summary>
        /// Attempt to claim the connected cash drawer.
        /// </summary>
        /// <returns>True if the cash drawer was successfully claimed, false otherwise.</returns>
        private async Task <bool> ClaimCashDrawer()
        {
            if (drawer == null)
            {
                return(false);
            }

            if (claimedDrawer == null)
            {
                claimedDrawer = await drawer.ClaimDrawerAsync();

                if (claimedDrawer == null)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #7
0
        /// <summary>
        /// Attempt to claim the connected cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was successfully claimed, false otherwise.</returns>
        private async Task <bool> ClaimCashDrawer(CashDrawerInstance instance)
        {
            bool claimAsyncStatus = false;

            switch (instance)
            {
            case CashDrawerInstance.Instance1:

                claimedCashDrawerInstance1 = await cashDrawerInstance1.ClaimDrawerAsync();

                if (claimedCashDrawerInstance1 != null)
                {
                    rootPage.NotifyUser("Successfully claimed instance 1.", NotifyType.StatusMessage);
                    claimAsyncStatus = true;
                }
                else
                {
                    rootPage.NotifyUser("Failed to claim instance 1.", NotifyType.ErrorMessage);
                }
                break;

            case CashDrawerInstance.Instance2:

                claimedCashDrawerInstance2 = await cashDrawerInstance2.ClaimDrawerAsync();

                if (claimedCashDrawerInstance2 != null)
                {
                    rootPage.NotifyUser("Successfully claimed instance 2.", NotifyType.StatusMessage);
                    claimAsyncStatus = true;
                }
                else
                {
                    rootPage.NotifyUser("Failed to claim instance 2.", NotifyType.ErrorMessage);
                }
                break;

            default:
                break;
            }

            return(claimAsyncStatus);
        }
        /// <summary>
        /// Reset the scenario to its initial state.
        /// </summary>
        private void ResetScenarioState()
        {
            drawer = null;

            if (claimedDrawer != null)
            {
                claimedDrawer.Dispose();
                claimedDrawer = null;
            }

            InitDrawerButton.IsEnabled = true;
            OpenDrawerButton.IsEnabled = false;

            rootPage.NotifyUser("Click the init drawer button to begin.", NotifyType.StatusMessage);
        }
        /// <summary>
        /// Attempt to claim the connected cash drawer.
        /// </summary>
        /// <returns>True if the cash drawer was successfully claimed, false otherwise.</returns>
        private async Task<bool> ClaimCashDrawer()
        {
            if (drawer == null)
                return false;

            if (claimedDrawer == null)
            {
                claimedDrawer = await drawer.ClaimDrawerAsync();
                if (claimedDrawer == null)
                    return false;
            }

            return true;
        }
        /// <summary>
        /// Reset the scenario to its initial state.
        /// </summary>
        private void ResetScenarioState()
        {
            drawer = null;

            if (claimedDrawer != null)
            {
                claimedDrawer.Dispose();
                claimedDrawer = null;
            }

            UpdateStatusOutput(CashDrawerStatusKind.Offline);

            InitDrawerButton.IsEnabled = true;
            DrawerWaitButton.IsEnabled = false;

            rootPage.NotifyUser("Click the init drawer button to begin.", NotifyType.StatusMessage);
        }
        /// <summary>
        /// Resets the display elements to original state
        /// </summary>
        private void ResetScenarioState()
        {
            cashDrawerInstance1 = null;
            cashDrawerInstance2 = null;

            if (claimedCashDrawerInstance1 != null)
            {
                claimedCashDrawerInstance1.Dispose();
                claimedCashDrawerInstance1 = null;
            }

            if (claimedCashDrawerInstance2 != null)
            {
                claimedCashDrawerInstance2.Dispose();
                claimedCashDrawerInstance2 = null;
            }

            ClaimButton1.IsEnabled = true;
            ClaimButton2.IsEnabled = true;
            ReleaseButton1.IsEnabled = false;
            ReleaseButton2.IsEnabled = false;
            RetainCheckBox1.IsChecked = true;
            RetainCheckBox2.IsChecked = true;

            rootPage.NotifyUser("Click a claim button to begin.", NotifyType.StatusMessage);
        }
        /// <summary>
        /// Event callback for a release device request for instance 2.
        /// </summary>
        /// <param name="sender">The drawer receiving the release device request.</param>
        /// <param name="e">Unused for ReleaseDeviceRequested events.</param>
        private async void claimedCashDrawerInstance2_ReleaseDeviceRequested(ClaimedCashDrawer drawer, object e)
        {
            await MainPage.Current.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
            {
                rootPage.NotifyUser("Release instance 2 requested.", NotifyType.StatusMessage);

                if (RetainCheckBox2.IsChecked == true)
                {
                    if (await claimedCashDrawerInstance2.RetainDeviceAsync() == false)
                        rootPage.NotifyUser("Cash drawer instance 2 retain failed.", NotifyType.ErrorMessage);
                }
                else
                {
                    claimedCashDrawerInstance2.Dispose();
                    claimedCashDrawerInstance2 = null;

                    SetReleasedUI(CashDrawerInstance.Instance2);
                }
            });
        }
        /// <summary>
        /// Event callback for release instance 2 button.
        /// </summary>
        /// <param name="sender">Button that was clicked.</param>
        /// <param name="e">Event data associated with click event.</param>
        private void ReleaseButton2_Click(object sender, RoutedEventArgs e)
        {
            if (claimedCashDrawerInstance2 != null)
            {
                claimedCashDrawerInstance2.Dispose();
                claimedCashDrawerInstance2 = null;

                SetReleasedUI(CashDrawerInstance.Instance2);

                rootPage.NotifyUser("Claimed instance 2 was released.", NotifyType.StatusMessage);
            }
        }
        /// <summary>
        /// Attempt to claim the connected cash drawer.
        /// </summary>
        /// <param name="instance">Specifies the cash drawer instance that should be used.</param>
        /// <returns>True if the cash drawer was successfully claimed, false otherwise.</returns>
        private async Task<bool> ClaimCashDrawer(CashDrawerInstance instance)
        {
            bool claimAsyncStatus = false;

            switch (instance)
            {
                case CashDrawerInstance.Instance1:

                    claimedCashDrawerInstance1 = await cashDrawerInstance1.ClaimDrawerAsync();
                    if (claimedCashDrawerInstance1 != null)
                    {
                        rootPage.NotifyUser("Successfully claimed instance 1.", NotifyType.StatusMessage);
                        claimAsyncStatus = true;
                    }
                    else
                    {
                        rootPage.NotifyUser("Failed to claim instance 1.", NotifyType.ErrorMessage);
                    }
                    break;

                case CashDrawerInstance.Instance2:

                    claimedCashDrawerInstance2 = await cashDrawerInstance2.ClaimDrawerAsync();
                    if (claimedCashDrawerInstance2 != null)
                    {
                        rootPage.NotifyUser("Successfully claimed instance 2.", NotifyType.StatusMessage);
                        claimAsyncStatus = true;
                    }
                    else
                    {
                        rootPage.NotifyUser("Failed to claim instance 2.", NotifyType.ErrorMessage);
                    }
                    break;

                default:
                    break;
            }

            return claimAsyncStatus;
        }
 public ClaimedCashDrawerEvents(ClaimedCashDrawer This)
 {
     this.This = This;
 }