Пример #1
0
        public void Flyout(Type source, object parameter = null)
        {
            var view = (Control)Activator.CreateInstance(source);

            view.DataContext = parameter;
            _flyout          = new SettingsFlyout
            {
                Title             = view.Name,
                Content           = view,
                Width             = view.Width,
                Foreground        = view.Foreground,
                Background        = view.Background,
                HeaderBackground  = view.BorderBrush,
                BorderBrush       = view.BorderBrush,
                RequestedTheme    = _frame.RequestedTheme,
                VerticalAlignment = VerticalAlignment.Stretch,
                Padding           = new Thickness(0),
            };

            ScrollViewer.SetVerticalScrollBarVisibility(_flyout, ScrollBarVisibility.Disabled);
            ScrollViewer.SetVerticalScrollMode(_flyout, ScrollMode.Disabled);

            _flyout.BackClick += OnFlyoutBack;
            _flyout.ShowIndependent();
        }
        private void ShowDirectionsPanel_Tapped(object sender, TappedRoutedEventArgs e)
        {
            // Close bottom appbar.
            this.BottomAppBar.IsOpen = false;

            // Show the directions input flyout.
            directionsInputFlyout.ShowIndependent();
        }
        /// <summary>
        /// Shows a settings flyout panel for the specified model.
        /// </summary>
        /// <param name="viewModel">The settings view model.</param>
        /// <param name="commandLabel">The settings command label.</param>
        /// <param name="viewSettings">The optional dialog settings.</param>
        /// <param name="independent">Show settings independent from <seealso cref="Windows.UI.ApplicationSettings.SettingsPane"/>.</param>
        public async void ShowSettingsFlyout(object viewModel, string commandLabel,
            IDictionary<string, object> viewSettings = null, bool independent = false) {
            var view = ViewLocator.LocateForModel(viewModel, null, null);
            ViewModelBinder.Bind(viewModel, view, null);

            viewSettings = viewSettings ?? new Dictionary<string, object>();

            var settingsFlyout = new SettingsFlyout
            {
                Title = commandLabel,
                Content = view,
                HorizontalContentAlignment = HorizontalAlignment.Stretch
            };

            // extract the header color/logo from the appmanifest.xml
            var visualElements = await AppManifestHelper.GetManifestVisualElementsAsync();

            // enable the overriding of these, but default to manifest
            var headerBackground = viewSettings.ContainsKey("headerbackground")
                ? (SolidColorBrush) viewSettings["headerbackground"]
                : new SolidColorBrush(visualElements.BackgroundColor);

            var smallLogoUri = viewSettings.ContainsKey("smalllogouri")
                ? (Uri) viewSettings["smalllogouri"]
                : visualElements.SmallLogoUri;

            var smallLogo = new BitmapImage(smallLogoUri);

            // use real property names for ApplySettings
            if (!viewSettings.ContainsKey("HeaderBackground"))
                viewSettings["HeaderBackground"] = headerBackground;

            if (!viewSettings.ContainsKey("IconSource"))
                viewSettings["IconSource"] = smallLogo;

            ApplySettings(settingsFlyout, viewSettings);

            var deactivator = viewModel as IDeactivate;
            if (deactivator != null) {
                RoutedEventHandler closed = null;
                closed = (s, e) => {
                    settingsFlyout.Unloaded -= closed;
                    deactivator.Deactivate(true);
                };

                settingsFlyout.Unloaded += closed;
            }

            var activator = viewModel as IActivate;
            if (activator != null) {
                activator.Activate();
            }

            if (independent)
                settingsFlyout.ShowIndependent();
            else
                settingsFlyout.Show();
        }
Пример #4
0
        protected virtual void ShowSettingsFlyout(SettingsFlyout settingsFlyout)
        {
            if (settingsFlyout == null)
            {
                throw new ArgumentNullException(nameof(settingsFlyout));
            }

            // Show the settings flyout
            // NB: Call 'ShowIndependent()' rather than 'Show()' as we handle displaying the system settings pane as required

            settingsFlyout.ShowIndependent();
        }
        public static async void ShowProductFilterFlyout(SubCategoryDisplayItem subcategoryDisplayItem, ProductListFilterViewModel fvm)
        {
            try
            {
                //Check if we are on Windows Mobile
                bool isWindowsPhone = DeviceFamilyHelper.CurrentDeviceFamily() == DeviceFamily.Mobile;

                //If Windows Phone then use the Dialog Control otherwise use the SettingsFlyout control.
                if (isWindowsPhone)
                {
                    ProductListFilterFlyout flyout = new ProductListFilterFlyout()
                    {
                        DataContext = fvm, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch
                    };
                    flyout.Margin = new Thickness(0, 20, 0, 0);
                    ContentDialog dialog = new ContentDialog()
                    {
                        Title                    = "Select Product Filters",
                        Content                  = flyout,
                        PrimaryButtonText        = "Close",
                        FullSizeDesired          = true,
                        Background               = (SolidColorBrush)Application.Current.Resources["FlyoutBackgroundThemeBrush"],
                        Foreground               = new SolidColorBrush(Colors.White),
                        RequestedTheme           = ElementTheme.Dark,
                        VerticalAlignment        = VerticalAlignment.Stretch,
                        VerticalContentAlignment = VerticalAlignment.Stretch
                    };

                    await dialog.ShowAsync();
                }
                else
                {
                    SettingsFlyout          fly    = new SettingsFlyout();
                    ProductListFilterFlyout flyout = new ProductListFilterFlyout()
                    {
                        DataContext = fvm
                    };                                                                                    //(subcategoryDisplayItem);
                    fly.Content          = flyout;
                    fly.RequestedTheme   = ElementTheme.Dark;
                    fly.Background       = (SolidColorBrush)Application.Current.Resources["FlyoutBackgroundThemeBrush"];
                    fly.HeaderBackground = (SolidColorBrush)Application.Current.Resources["FlyoutBackgroundThemeBrush"];
                    fly.Title            = "Filter Products";
                    fly.ShowIndependent();
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
        }
 public void ShowDialog()
 {
     _flyout.ShowIndependent();
 }
Пример #7
0
        /// <summary>
        /// Shows a settings flyout panel for the specified model.
        /// </summary>
        /// <param name="viewModel">The settings view model.</param>
        /// <param name="commandLabel">The settings command label.</param>
        /// <param name="viewSettings">The optional dialog settings.</param>
        /// <param name="independent">Show settings independent from <seealso cref="Windows.UI.ApplicationSettings.SettingsPane"/>.</param>
        public async void ShowSettingsFlyout(object viewModel, string commandLabel,
                                             IDictionary <string, object> viewSettings = null, bool independent = false)
        {
            var view = ViewLocator.LocateForModel(viewModel, null, null);

            ViewModelBinder.Bind(viewModel, view, null);

            viewSettings = viewSettings ?? new Dictionary <string, object>();

            var settingsFlyout = new SettingsFlyout
            {
                Title   = commandLabel,
                Content = view,
                HorizontalContentAlignment = HorizontalAlignment.Stretch
            };

            // extract the header color/logo from the appmanifest.xml
            var visualElements = await AppManifestHelper.GetManifestVisualElementsAsync();

            // enable the overriding of these, but default to manifest
            var headerBackground = viewSettings.ContainsKey("headerbackground")
                ? (SolidColorBrush)viewSettings["headerbackground"]
                : new SolidColorBrush(visualElements.BackgroundColor);

            var smallLogoUri = viewSettings.ContainsKey("smalllogouri")
                ? (Uri)viewSettings["smalllogouri"]
                : visualElements.SmallLogoUri;

            var smallLogo = new BitmapImage(smallLogoUri);

            // use real property names for ApplySettings
            if (!viewSettings.ContainsKey("HeaderBackground"))
            {
                viewSettings["HeaderBackground"] = headerBackground;
            }

            if (!viewSettings.ContainsKey("IconSource"))
            {
                viewSettings["IconSource"] = smallLogo;
            }

            ApplySettings(settingsFlyout, viewSettings);

            var deactivator = viewModel as IDeactivate;

            if (deactivator != null)
            {
                RoutedEventHandler closed = null;
                closed = (s, e) => {
                    settingsFlyout.Unloaded -= closed;
                    deactivator.Deactivate(true);
                };

                settingsFlyout.Unloaded += closed;
            }

            var activator = viewModel as IActivate;

            if (activator != null)
            {
                activator.Activate();
            }

            if (independent)
            {
                settingsFlyout.ShowIndependent();
            }
            else
            {
                settingsFlyout.Show();
            }
        }
Пример #8
0
        public CollectionOrDeliveryDetailsPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, SettingsFlyout addCustomerPage)
            : base(navigationService)
        {
            _navigationService         = navigationService;
            this._eventAggregator      = eventAggregator;
            this._addCustomerPage      = addCustomerPage;
            this._task                 = PersistentData.Instance.CollectDeliveryTask;
            this.CustomerDetails       = PersistentData.Instance.CustomerDetails;
            this.DocumentList          = new ObservableCollection <Document>();
            this.CollectVisibility     = Visibility.Collapsed;
            this.CompleteVisibility    = Visibility.Collapsed;
            this.DocuDeliveryDetails   = new CollectDeliveryDetail();
            this.DocumentCollectDetail = new DocumentCollectDetail();
            this.DocumnetDeliverDetail = new DocumnetDeliverDetail();
            this.AddContactCommand     = new DelegateCommand(() =>
            {
                addCustomerPage.ShowIndependent();
            });
            this.CollectCommand = new DelegateCommand(async() =>
            {
                try
                {
                    this.IsBusy = true;

                    switch (this._userInfo.CDUserType)
                    {
                    case CDUserType.Driver:
                        foreach (var task in this.SelectedTaskBucket)
                        {
                            if (this.DocumentList.Any(a => a.CaseNumber == task.CaseNumber && a.IsMarked))
                            {
                                switch (task.ServiceId)
                                {
                                case CollectDeliverServices.LICENCEDUP:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.PERMIT:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.POLICECLEARANCE:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.FINESPOB:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.FINESRTA:
                                    task.Status   = CDTaskStatus.AwaitDeliveryConfirmation;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.PNP:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.REQUESTCOF:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.FINESRTC:
                                    task.Status   = CDTaskStatus.AwaitDeliveryConfirmation;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                case CollectDeliverServices.LICENCERENEWAL:
                                    task.Status   = CDTaskStatus.AwaitInvoice;
                                    task.TaskType = CDTaskType.None;
                                    break;

                                default:

                                    task.Status   = CDTaskStatus.AwaitDeliveryConfirmation;
                                    task.TaskType = CDTaskType.Delivery;

                                    break;
                                }



                                task.IsNotSyncedWithAX = true;
                                await SqliteHelper.Storage.UpdateSingleRecordAsync(task);
                                await CollectedDocumnetsFromTaskBucket(task, false);
                            }
                        }
                        break;

                    case CDUserType.Courier:
                        foreach (var task in this.SelectedTaskBucket)
                        {
                            if (this.DocumentList.Any(a => a.CaseNumber == task.CaseNumber && a.IsMarked))
                            {
                                task.Status            = CDTaskStatus.AwaitDeliveryConfirmation;
                                task.TaskType          = CDTaskType.Delivery;
                                task.IsNotSyncedWithAX = true;
                                await SqliteHelper.Storage.UpdateSingleRecordAsync(task);
                                this.DocuDeliveryDetails.DeliveryDate = this.DocuDeliveryDetails.ReceivedDate;
                                await DeliveredDocumentsFromTaskBucket(task);
                            }
                        }
                        break;

                    case CDUserType.Customer: foreach (var task in this.SelectedTaskBucket)
                        {
                            if (this.DocumentList.Any(a => a.CaseNumber == task.CaseNumber && a.IsMarked))
                            {
                                task.Status            = CDTaskStatus.Completed;
                                task.TaskType          = CDTaskType.None;
                                task.IsNotSyncedWithAX = true;
                                await SqliteHelper.Storage.UpdateSingleRecordAsync(task);
                                await CollectedDocumnetsFromTaskBucket(task, true);
                            }
                        }
                        break;

                    default:
                        break;
                    }

                    await DDServiceProxyHelper.Instance.SynchronizeAllAsync();
                    this.IsBusy = false;
                    _navigationService.Navigate("InspectionDetails", string.Empty);
                }
                catch (Exception ex)
                {
                    AppSettings.Instance.ErrorMessage = ex.Message;
                    this.IsBusy = false;
                }
            },
                                                      () =>
            {
                return(this.DocumentList.Any(a => a.IsMarked) && ((this.SelectedContact != null && !this.IsAlternateOn) || (this.SelectedAlternateContact != null && this.IsAlternateOn)) &&
                       this.CRSignature != null && _task.TaskType == CDTaskType.Collect);
            }
                                                      );

            this.CompleteCommand = new DelegateCommand(async() =>
            {
                try
                {
                    this.IsBusy = true;

                    if (this._userInfo.CDUserType == CDUserType.Courier)
                    {
                        foreach (var task in this.SelectedTaskBucket)
                        {
                            if (this.DocumentList.Any(a => a.CaseNumber == task.CaseNumber & a.IsMarked))
                            {
                                task.Status            = CDTaskStatus.AwaitInvoice;
                                task.TaskType          = CDTaskType.None;
                                task.IsNotSyncedWithAX = true;
                                await SqliteHelper.Storage.UpdateSingleRecordAsync(task);

                                //await DeliveredDocumentsFromTaskBucket(task);
                                await UpdateDeliveryDetailForCourierAsync(task);
                            }
                        }
                    }
                    else
                    {
                        foreach (var task in this.SelectedTaskBucket)
                        {
                            if (this.DocumentList.Any(a => a.CaseNumber == task.CaseNumber && a.IsMarked))
                            {
                                task.Status            = CDTaskStatus.Completed;
                                task.TaskType          = CDTaskType.None;
                                task.IsNotSyncedWithAX = true;
                                await SqliteHelper.Storage.UpdateSingleRecordAsync(task);
                                await DeliveredDocumentsFromTaskBucket(task);
                            }
                        }
                    }
                    await DDServiceProxyHelper.Instance.SynchronizeAllAsync();
                    this.IsBusy = false;
                    _navigationService.Navigate("InspectionDetails", string.Empty);
                }
                catch (Exception ex)
                {
                    AppSettings.Instance.ErrorMessage = ex.Message;
                    this.IsBusy = false;
                }
            }, () =>
            {
                return(this.DocumentList.Any(a => a.IsMarked) && ((this.SelectedContact != null && !this.IsAlternateOn) || (this.SelectedAlternateContact != null && this.IsAlternateOn)) &&
                       this.CRSignature != null && _task.TaskType == CDTaskType.Delivery);
            });
            //this.SelectedDocuments = new ObservableCollection<Document>();

            this._eventAggregator.GetEvent <AlternateContactPersonEvent>().Subscribe(async(customerContacts) =>
            {
                this.AlternateContactPersons = await SqliteHelper.Storage.LoadTableAsync <AlternateContactPerson>();
                this._addCustomerPage.Hide();
            });

            this.DocumentsChangedCommand = new DelegateCommand <ObservableCollection <object> >((param) =>
            {
                foreach (var item in this.DocumentList)
                {
                    item.IsMarked = false;
                }
                foreach (var item in param)
                {
                    ((Document)item).IsMarked = true;
                }
                this.CompleteCommand.RaiseCanExecuteChanged();
                this.CollectCommand.RaiseCanExecuteChanged();
            });
        }
        protected virtual void ShowSettingsFlyout(SettingsFlyout settingsFlyout)
        {
            if (settingsFlyout == null)
                throw new ArgumentNullException(nameof(settingsFlyout));

            // Show the settings flyout
            // NB: Call 'ShowIndependent()' rather than 'Show()' as we handle displaying the system settings pane as required

            settingsFlyout.ShowIndependent();
        }
Пример #10
0
        public ServiceSchedulingPageViewModel(INavigationService navigationService, IEventAggregator eventAggregator, SettingsFlyout settingsFlyout)
            : base(navigationService)
        {
            _navigationService = navigationService;
            _settingsFlyout    = settingsFlyout;
            _eventAggregator   = eventAggregator;
            this.Address       = new Address();
            this.IsAddFlyoutOn = Visibility.Collapsed;
            this.Model         = new ServiceSchedulingDetail();
            this.GoToSupplierSelectionCommand = new DelegateCommand(async() =>
            {
                try
                {
                    if (await ODOImageValidate() && this.Model.ValidateProperties())
                    {
                        var messageDialog = new MessageDialog("Details once saved cannot be edited. Do you want to continue ?");
                        messageDialog.Commands.Add(new UICommand("Yes", OnYesButtonClicked));
                        messageDialog.Commands.Add(new UICommand("No"));
                        await messageDialog.ShowAsync();
                    }
                }
                catch (Exception ex)
                {
                    this.IsBusy = false;
                    AppSettings.Instance.ErrorMessage = ex.Message;
                }
            });

            this.AddAddressCommand = new DelegateCommand <string>((x) =>
            {
                settingsFlyout.Title = x + " Address";
                settingsFlyout.ShowIndependent();
            });

            this.ODOReadingPictureCommand = new DelegateCommand(async() =>
            {
                CameraCaptureUI cam = new CameraCaptureUI();
                var file            = await cam.CaptureFileAsync(CameraCaptureUIMode.Photo);
                if (file != null)
                {
                    ODOReadingImagePath = file.Path;
                }
            });

            this.OpenImageViewerCommand = new DelegateCommand <ImageCapture>(param =>
            {
                CoreWindow currentWindow = Window.Current.CoreWindow;
                Popup popup = new Popup();
                popup.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch;
                popup.VerticalAlignment   = Windows.UI.Xaml.VerticalAlignment.Stretch;

                if (_imageViewer == null)
                {
                    _imageViewer = new ImageViewerPopup();
                }
                else
                {
                    _imageViewer      = null;
                    this._imageViewer = new ImageViewerPopup();
                }
                _imageViewer.DataContext = param;


                popup.Child           = _imageViewer;
                this._imageViewer.Tag = popup;

                this._imageViewer.Height = currentWindow.Bounds.Height;
                this._imageViewer.Width  = currentWindow.Bounds.Width;

                popup.IsOpen = true;
            });

            this._eventAggregator.GetEvent <AddressEvent>().Subscribe((address) =>
            {
                if (address != null)
                {
                    this.Address     = address;
                    StringBuilder sb = new StringBuilder();


                    sb.Append(address.Street).Append(",").Append(Environment.NewLine);

                    if ((address.SelectedSuburb != null) && !String.IsNullOrEmpty(address.SelectedSuburb.Name))
                    {
                        sb.Append(address.SelectedSuburb.Name).Append(",").Append(Environment.NewLine);
                    }
                    if (address.SelectedRegion != null)
                    {
                        sb.Append(address.SelectedRegion.Name).Append(",").Append(Environment.NewLine);
                    }
                    if ((address.SelectedCity != null) && !String.IsNullOrEmpty(address.SelectedCity.Name))
                    {
                        sb.Append(address.SelectedCity.Name).Append(",").Append(Environment.NewLine);
                    }
                    if ((address.SelectedProvince != null) && !String.IsNullOrEmpty(address.SelectedProvince.Name))
                    {
                        sb.Append(address.SelectedProvince.Name).Append(",").Append(Environment.NewLine);
                    }

                    if ((address.SelectedCountry != null) && !String.IsNullOrEmpty(address.SelectedCountry.Name))
                    {
                        sb.Append(address.SelectedCountry.Name).Append(",").Append(Environment.NewLine);
                    }

                    sb.Append(address.SelectedZip);


                    this.Model.Address = sb.ToString();
                }
                settingsFlyout.Hide();
            });

            this.TakePictureCommand = DelegateCommand <ImageCapture> .FromAsyncHandler(async (param) =>
            {
                await TakePictureAsync(param);
            });

            #region Location Type Changed
            this.LocTypeChangedCommand = new DelegateCommand <object>(async(param) =>
            {
                try
                {
                    var locType = ((LocationType)param).LocType;
                    this.IsBusy = true;
                    if (this.Model.DestinationTypes != null)
                    {
                        this.Model.DestinationTypes.Clear();
                        this.Model.SelectedDestinationType = null;
                    }
                    if (this.Model.DestinationTypes != null && locType == LocationTypeConstants.Driver && this._task != null)
                    {
                        this.Model.DestinationTypes.AddRange(await SSProxyHelper.Instance.GetDriversFromSvcAsync(this._task.CustomerId));
                    }
                    if (this.Model.DestinationTypes != null && locType == LocationTypeConstants.Customer && this._task != null)
                    {
                        this.Model.DestinationTypes.AddRange(await SSProxyHelper.Instance.GetCustomersFromSvcAsync(this._task.CustomerId));
                    }

                    if (this.Model.DestinationTypes != null && locType == LocationTypeConstants.Vendor)
                    {
                        this.Model.DestinationTypes.AddRange(await SSProxyHelper.Instance.GetVendorsFromSvcAsync());
                    }
                    this.IsAddFlyoutOn = Visibility.Collapsed;
                    this.IsAlternative = Visibility.Visible;
                    if (locType == LocationTypeConstants.Other)
                    {
                        this.Model.DestinationTypes        = new ObservableCollection <DestinationType>();
                        this.Model.SelectedDestinationType = new DestinationType();
                        this.IsAddFlyoutOn = Visibility.Visible;
                        this.IsAlternative = Visibility.Collapsed;
                    }

                    this.IsBusy = false;
                }
                catch (Exception ex)
                {
                    this.IsBusy = false;
                    AppSettings.Instance.ErrorMessage = ex.Message;
                }
            });
            #endregion

            this.DestiTypeChangedCommand = new DelegateCommand <object>(async(param) =>
            {
                try
                {
                    this.IsBusy = true;
                    if (param != null)
                    {
                        if (param is DestinationType)
                        {
                            this.Address.EntityRecId        = ((DestinationType)param).RecID;
                            DestinationType destinationType = param as DestinationType;
                            this.Model.Address = destinationType.Address;
                        }
                    }
                    this.IsBusy = false;
                }
                catch (Exception ex)
                {
                    this.IsBusy = false;
                    AppSettings.Instance.ErrorMessage = ex.Message;
                }
            });
        }