Esempio n. 1
0
 private async void CommandBinding_Executed_RenameResourceNodeDlg(object sender, ExecutedRoutedEventArgs e)
 {
     RenameDialog dlg    = new RenameDialog();
     var          result = await DialogHost.Show(dlg);
 }
        public async void ModificarProductoTerminado()
        {
            var formProductoTerminado                     = new FormProductoTerminado(context, ProductoTerminadoSeleccionado);
            var formProductoTerminadoDataContext          = formProductoTerminado.DataContext as FormProductoTerminadoViewModel;
            var productosTerminadosComposicionesIniciales = formProductoTerminadoDataContext.ProductosTerminadosComposiciones.ToList();
            var historialHuecosAlmacenajesIniciales       = formProductoTerminadoDataContext.HistorialHuecosAlmacenajes.ToList();

            if ((bool)await DialogHost.Show(formProductoTerminado, "RootDialog"))
            {
                ProductoTerminadoSeleccionado.TipoId        = formProductoTerminadoDataContext.TipoProductoTerminado.TipoProductoTerminadoId;
                ProductoTerminadoSeleccionado.Unidades      = formProductoTerminadoDataContext.Unidades;
                ProductoTerminadoSeleccionado.Volumen       = formProductoTerminadoDataContext.Volumen;
                ProductoTerminadoSeleccionado.Observaciones = formProductoTerminadoDataContext.Observaciones;
                if (formProductoTerminadoDataContext.FechaBaja != null)
                {
                    ProductoTerminadoSeleccionado.FechaBaja = new DateTime(
                        formProductoTerminadoDataContext.FechaBaja.Value.Year,
                        formProductoTerminadoDataContext.FechaBaja.Value.Month,
                        formProductoTerminadoDataContext.FechaBaja.Value.Day,
                        formProductoTerminadoDataContext.HoraBaja.Value.Hour,
                        formProductoTerminadoDataContext.HoraBaja.Value.Minute,
                        formProductoTerminadoDataContext.HoraBaja.Value.Second);
                }
                else
                {
                    ProductoTerminadoSeleccionado.FechaBaja = null;
                }
                if (!context.ProductosTerminadosComposiciones.Any(ptc => ptc.ProductoId == ProductoTerminadoSeleccionado.ProductoTerminadoId))
                {
                    // Se borran todos los productos terminados comosiciones antiguos y se añaden los nuevos
                    context.ProductosTerminadosComposiciones.RemoveRange(productosTerminadosComposicionesIniciales);
                    var productosTerminadosComposiciones = new List <ProductoTerminadoComposicion>();
                    foreach (var ptc in formProductoTerminadoDataContext.ProductosTerminadosComposiciones)
                    {
                        var hhrId = ptc.HistorialHuecoRecepcion.HistorialHuecoRecepcionId;
                        // Los huecos que no se ha añadido ninguna cantidad no se añaden
                        if (ptc.Unidades != 0 && ptc.Volumen != 0)
                        {
                            // Hay que asegurarse que la cantidad de materia prima escogida es como máximo la disponible en el hueco
                            if (ptc.HistorialHuecoRecepcion.MateriaPrima.TipoMateriaPrima.MedidoEnUnidades == true)
                            {
                                ptc.Unidades = (ptc.Unidades > ptc.HistorialHuecoRecepcion.UnidadesRestantes) ? (ptc.HistorialHuecoRecepcion.UnidadesRestantes) : (ptc.Unidades);
                            }
                            else
                            {
                                ptc.Volumen = (ptc.Volumen > ptc.HistorialHuecoRecepcion.VolumenRestante) ? (ptc.HistorialHuecoRecepcion.UnidadesRestantes) : (ptc.Volumen);
                            }
                            ptc.HistorialHuecoRecepcion = null;
                            ptc.HistorialHuecoId        = hhrId;
                            ptc.ProductoTerminado       = ProductoTerminadoSeleccionado;
                            productosTerminadosComposiciones.Add(ptc);
                        }
                    }
                    context.ProductosTerminadosComposiciones.AddRange(productosTerminadosComposiciones);

                    // Se borran todos los historiales huecos almacenajes antiguos y se añaden los nuevos
                    context.HistorialHuecosAlmacenajes.RemoveRange(historialHuecosAlmacenajesIniciales);
                    var historialHuecosAlmacenajes = new List <HistorialHuecoAlmacenaje>();
                    foreach (var hha in formProductoTerminadoDataContext.HistorialHuecosAlmacenajes)
                    {
                        var haId = hha.HuecoAlmacenaje.HuecoAlmacenajeId;
                        // Los huecos que no se ha añadido ninguna cantidad no se añaden
                        if (hha.Unidades != 0 && hha.Volumen != 0)
                        {
                            hha.HuecoAlmacenaje   = null;
                            hha.HuecoAlmacenajeId = haId;
                            hha.ProductoTerminado = ProductoTerminadoSeleccionado;
                            historialHuecosAlmacenajes.Add(hha);
                        }
                    }
                    context.HistorialHuecosAlmacenajes.AddRange(historialHuecosAlmacenajes);
                }

                context.SaveChanges();
                ProductosTerminadosView.Refresh();
            }
        }
 private async void AddCategory(object param)
 {
     Wizards.EditInvoiceCategories eic;
     eic = new Wizards.EditInvoiceCategories();
     var result = await DialogHost.Show(eic, "HelperDialog", ExtendedOpenedEventHandler, ExtendedClosingInvoiceCategoriesEventHandler);
 }
 private void OpenDialogWithModel(object?sender, RoutedEventArgs e)
 {
     DialogHost.Show(new Sample2Model(new Random().Next(0, 100)), "MainDialogHost");
 }
Esempio n. 5
0
        public override void SubscribeMessenger()
        {
            //非阻塞式窗口提示消息
            Messenger.Default.Register <string>(View, "Snackbar", arg =>
            {
                var messageQueue = View.SnackbarThree.MessageQueue;
                messageQueue.Enqueue(arg);
            });
            //阻塞式窗口提示消息
            Messenger.Default.Register <MsgInfo>(View, "UpdateDialog", m =>
            {
                if (m.IsOpen)
                {
                    _ = DialogHost.Show(new SplashScreenView()
                    {
                        DataContext = new { Msg = m.Msg }
                    }, "Root");
                }
                else
                {
                    ViewModel.DialogIsOpen = false;
                }
            });
            //执行菜单模块动画
            Messenger.Default.Register <string>(View, "WindowMinimize", arg =>
            {
                View.WindowState = System.Windows.WindowState.Minimized;
            });
            Messenger.Default.Register <string>(View, "WindowMaximize", arg =>
            {
                if (View.WindowState == System.Windows.WindowState.Maximized)
                {
                    View.WindowState = System.Windows.WindowState.Normal;
                }
                else
                {
                    View.WindowState = System.Windows.WindowState.Maximized;
                }
            });
            //菜单执行相关动画及模板切换
            Messenger.Default.Register <string>(View, "ExpandMenu", arg =>
            {
                if (View.MENU.Width < 200)
                {
                    AnimationHelper.CreateWidthChangedAnimation(View.MENU, 60, 200, new TimeSpan(0, 0, 0, 0, 300));
                }
                else
                {
                    AnimationHelper.CreateWidthChangedAnimation(View.MENU, 200, 60, new TimeSpan(0, 0, 0, 0, 300));
                }
                for (int i = 0; i < ViewModel.ModuleManager.ModuleGroups.Count; i++)
                {
                    ViewModel.ModuleManager.ModuleGroups[i].ContractionTemplate = View.MENU.Width < 200 ? false : true;
                }

                //由于...
                var template = View.IC.ItemTemplateSelector;
                View.IC.ItemTemplateSelector = null;
                View.IC.ItemTemplateSelector = template;
            });
            //执行返回首页
            Messenger.Default.Register <string>(View, "GoHomePage", arg =>
            {
                InitHomeView();
            });
            //打开页面
            Messenger.Default.Register <string>(View, "OpenPage", async name =>
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        return;
                    }
                    var m = ViewModel.ModuleManager.Modules.FirstOrDefault(t => t.Name.Equals(name));
                    if (m == null)
                    {
                        return;
                    }
                    var module = ViewModel.ModuleList.FirstOrDefault(t => t.Name == m.Name);
                    if (module == null)
                    {
                        NetCoreProvider.Get <IModule>(m.TypeName, out IModule dialog);
                        if (dialog == null)
                        {
                            //404
                            return;
                        }
                        _ = DialogHost.Show(new SplashScreenView()
                        {
                            DataContext = new { Msg = "正在打开页面..." }
                        }, "Root");
                        ViewModel.DialogIsOpen = true;
                        await Task.Delay(100);
                        //将数据库中获取的菜单Namespace在容器当中查找依赖关系的实例
                        await dialog.BindDefaultModel(m.Auth);
                        ViewModel.ModuleList.Add(new ModuleUIComponent()
                        {
                            Code     = m.Code,
                            Auth     = m.Auth,
                            Name     = m.Name,
                            TypeName = m.TypeName,
                            Body     = dialog.GetView()
                        });
                        ViewModel.CurrentModule = ViewModel.ModuleList[ViewModel.ModuleList.Count - 1];
                    }
                    else
                    {
                        ViewModel.CurrentModule = module;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                }
                finally
                {
                    ViewModel.DialogIsOpen = false; //关闭等待窗口
                    GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                    GC.Collect();
                }
            });
            //关闭页面
            Messenger.Default.Register <string>(View, "ClosePage", m =>
            {
                try
                {
                    var module = ViewModel.ModuleList.FirstOrDefault(t => t.Name.Equals(m));
                    if (module != null)
                    {
                        ViewModel.ModuleList.Remove(module);
                        if (ViewModel.ModuleList.Count > 0)
                        {
                            ViewModel.CurrentModule = ViewModel
                                                      .ModuleList[ViewModel.ModuleList.Count - 1];
                        }
                        else
                        {
                            ViewModel.CurrentModule = null;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                }
                finally
                {
                    GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                    GC.Collect();
                }
            });
            base.SubscribeMessenger();
        }
Esempio n. 6
0
 public async Task ShowThirdPartyLicenses()
 {
     await DialogHost.Show(null, DialogIdentifier).ConfigureAwait(true);
 }
Esempio n. 7
0
 public static void ShowMessageBox(string message)
 {
     model.Message    = message;
     view.DataContext = model;
     DialogHost.Show(view, "RootDialog");
 }
Esempio n. 8
0
        public static async Task ShowSaveWadOperationDialog(string wadLocation, WadViewModel wad)
        {
            SaveWadOperationDialog dialog = new SaveWadOperationDialog(wadLocation, wad);

            await DialogHost.Show(dialog, "OperationDialog", dialog.Save, null);
        }
Esempio n. 9
0
        public static async Task ShowExtractOperationDialog(string extractLocation, IEnumerable <WadFileViewModel> entries)
        {
            ExtractOperationDialog dialog = new ExtractOperationDialog(extractLocation, entries);

            await DialogHost.Show(dialog, "OperationDialog", dialog.StartExtraction, null);
        }
Esempio n. 10
0
 public async Task <object> ShowDialog <T>(object obj)
 {
     CloseDialog();
     return(await DialogHost.Show((T)obj, DialogIdentifier));
 }
Esempio n. 11
0
 public async void ShowDialog(object binding)
 {
     await DialogHost.Show(binding, "RootDialog", this.ClosingEventHandler);
 }
Esempio n. 12
0
 public async Task <object> ShowDialog <T>(object obj, DialogClosingEventHandler closingEventHandler)
 {
     CloseDialog();
     return(await DialogHost.Show((T)obj, DialogIdentifier, closingEventHandler));
 }
Esempio n. 13
0
 private async void add_Click(object sender, RoutedEventArgs e)
 {
     var result = await DialogHost.Show(new DoctorEditAddDialog(new Doctor()), "RootDialog", ExtendedAddSecClosingEventHandler);
 }
Esempio n. 14
0
        private async void Edit_Click(object sender, RoutedEventArgs e)
        {
            Doctor clickedDoctor = ((FrameworkElement)sender).DataContext as Doctor;

            var result = await DialogHost.Show(new DoctorEditAddDialog(clickedDoctor), "RootDialog", ExtendedAddSecClosingEventHandler);
        }
Esempio n. 15
0
        public MainWindowViewModel()
        {
            _disposables           = new CompositeDisposable();
            _connectionDisposables = new CompositeDisposable();

            VideoPlayer         = new VideoPlayerModel().AddTo(_disposables);
            ConnectedDevice     = new DeviceModel();
            SelectDeviceCommand = new ReactiveCommand().AddTo(_disposables);
            SelectDeviceCommand.Delay(new TimeSpan(100)).ObserveOnUIDispatcher().SelectMany(_ => DialogHost.Show(new DeviceSelectDialog(), OnSelectDeviceDialogClosing).ToObservable())
            .Subscribe(async(result) => await ConnenctDevice(result as DiscoverResult)).AddTo(_disposables);

            _viewMode    = new BehaviorSubject <ViewMode>(ViewMode.None).AddTo(_disposables);
            IsModeRec    = new ReactiveProperty <bool>().AddTo(_disposables);
            IsModeLive   = new ReactiveProperty <bool>().AddTo(_disposables);
            IsModeInput  = new ReactiveProperty <bool>().AddTo(_disposables);
            IsModeOutput = new ReactiveProperty <bool>().AddTo(_disposables);
            _viewMode.DistinctUntilChanged().Subscribe(m => {
                IsModeRec.Value    = (m == ViewMode.Rec);
                IsModeLive.Value   = (m == ViewMode.Live);
                IsModeInput.Value  = (m == ViewMode.Input);
                IsModeOutput.Value = (m == ViewMode.Output);
            }).AddTo(_disposables);
            IsModeRec.Where(b => b).Subscribe(async(_) => await ToRecMode()).AddTo(_disposables);
            IsModeLive.Where(b => b).Subscribe(async(_) => await ToLiveMode()).AddTo(_disposables);
            IsModeInput.Where(b => b).Subscribe(async(_) => await ToInputMode()).AddTo(_disposables);
            IsModeOutput.Where(b => b).Subscribe(async(_) => await ToOutputMode()).AddTo(_disposables);
            _viewMode.OnNext(ViewMode.Output);

            SliderValue = new[] {
                new ReactiveProperty <double>(1.0).AddTo(_disposables),
                new ReactiveProperty <double>(0.0).AddTo(_disposables),
                new ReactiveProperty <double>(0.0).AddTo(_disposables),
                new ReactiveProperty <double>(0.0).AddTo(_disposables)
            };
            SliderMaximum  = new ReactiveProperty <double>(1.0).AddTo(_disposables);
            IsSliderActive = new[] {
                new ReactiveProperty <bool>(true).AddTo(_disposables),
                new ReactiveProperty <bool>(false).AddTo(_disposables),
                new ReactiveProperty <bool>(false).AddTo(_disposables),
                new ReactiveProperty <bool>(false).AddTo(_disposables)
            };
            SliderValue[0].Subscribe(async(value) => await OnSliderValueChanged(0, value)).AddTo(_disposables);
            SliderValue[1].Subscribe(async(value) => await OnSliderValueChanged(1, value)).AddTo(_disposables);
            SliderValue[2].Subscribe(async(value) => await OnSliderValueChanged(2, value)).AddTo(_disposables);
            SliderValue[3].Subscribe(async(value) => await OnSliderValueChanged(3, value)).AddTo(_disposables);
        }
Esempio n. 16
0
        public static async Task ShowSyncingLocalizationsDialog()
        {
            SyncingLocalizationsDialog dialog = new SyncingLocalizationsDialog();

            await DialogHost.Show(dialog, "OperationDialog", dialog.StartSyncing, null);
        }
Esempio n. 17
0
 public async Task ShowLicense()
 {
     await DialogHost.Show(logParserLicense, DialogIdentifier).ConfigureAwait(true);
 }
Esempio n. 18
0
        /// <summary>
        /// Init commands
        /// </summary>
        private void InitCommands()
        {
            #region Remove Command

            // Init the remove command
            RemoveCommand = new DelegateCommand(async() =>
            {
                // Get selected users
                var selected      = Users.Where(u => u.IsSelected).Select(u => u.UserModel).ToList();
                var selectedCount = selected.Count;

                // return if the selected users are 0
                if (selectedCount <= 0)
                {
                    return;
                }

                // Do a single deletion
                if (selectedCount == 1)
                {
                    Action deleteAction = null;
                    deleteAction        = async() =>
                    {
                        var done = await _hotspotClient.RemoveUserAsync(Users.Single(u => u.IsSelected).UserModel);
                        if (done)
                        {
                            Users.Remove(Users.SingleOrDefault(u => u.IsSelected));
                        }

                        // Inform the user
                        _eventAggregator.GetEvent <NotificationEvent>().Publish(
                            done
                                ? new NotificationEventArgs("Deleted User Successfully!", "UNDO", null, new SideNotificationViewModel("Hotspot Users", "Deleted User Successfully!"))
                                : new NotificationEventArgs("Failed in deleting user", "RETRY",
                                                            () => deleteAction.Invoke(), new SideNotificationViewModel("Hotspot Users", "Deleted User Successfully!"))
                            );

                        RaisePropertyChanged(nameof(UsersCount));
                    };

                    deleteAction.Invoke();
                    return;
                }

                // Show Confirm Message and return if the user has canceled
                var confirm = await _dialogService.ShowMessageAsync("Confirm",
                                                                    $"Are sure you want to delete selected items ( {selected.Count} items ) ?",
                                                                    MessageDialogStyle.AffirmativeAndNegative);
                if (confirm == MessageDialogResult.Negative)
                {
                    return;
                }

                var loading = await _dialogService.ShowProgressAsync("Deleting",
                                                                     $"Deleting Item - from {SelectedUsersCount} items...");
                loading.SetCancelable(true);

                var i = 0;
                for (; i < selectedCount; i++)
                {
                    // break if canceled
                    if (loading.IsCanceled)
                    {
                        break;
                    }

                    // set progress of the progress dialog
                    loading.SetMessage($"Deleting Item {i} from {selectedCount} items...");
                    loading.SetProgress((double)i / selectedCount);

                    // continue if failed
                    if (!await _hotspotClient.RemoveUserAsync(selected[i]))
                    {
                        continue;
                    }

                    // Update the UI
                    var item = Users.SingleOrDefault(u => u.Username == selected[i].Name);
                    if (item != null)
                    {
                        Users.Remove(item);
                    }
                }

                // Close the progress dialog
                await loading.CloseAsync();

                // Show Notifcation
                _eventAggregator.GetEvent <NotificationEvent>()
                .Publish(new NotificationEventArgs($"Deleted {i} items successfully!", null, new SideNotificationViewModel("Hotspot Users", $"Deleted {i + 1} items successfully!")));

                RaisePropertyChanged(nameof(UsersCount));
            });

            #endregion

            #region Toggle Command

            ToggleCommand = new DelegateCommand <bool?>(async newValue =>
            {
                // return if there is no selected users
                if (!HasSelectedUsers)
                {
                    return;
                }

                // fetch selected users
                var selected = await Task.Run(() => Users.Where(u => u.IsSelected && u.IsDisabled != newValue.GetValueOrDefault()).Select(u => Users.IndexOf(u)).ToList());
                if (selected.Count == 0)
                {
                    return;
                }

                // Do A Single action if the selected users count is 0
                if (selected.Count == 1)
                {
                    // set the disabled value
                    Users[selected[0]].IsDisabled = newValue.GetValueOrDefault();

                    // Notification message string
                    string message;

                    // do modification operation
                    if (await _hotspotClient.UpdateUserAsync(Users[selected[0]].UserModel))
                    {
                        // set the message to success if the change is successed
                        message = $"The user \"{Users[selected[0]].Username}\" has been {(Users[selected[0]].IsDisabled ? "disabled" : "enabled")} successfully!";
                    }
                    else
                    {
                        // set the message to fail if the operation has failed
                        message = $"Can't {(Users[selected[0]].IsDisabled ? "disable" : "enable")} user!";

                        // set the disabled value back to the value that it was
                        Users[selected[0]].IsDisabled = !newValue.GetValueOrDefault();
                    }

                    // Show notification about the proccess
                    _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs(message, null, new SideNotificationViewModel("Hotspot Users", message)));

                    // Update the UI and return
                    UsersSelectionChanged();
                    return;
                }

                /* Do Multiple Action */

                // calculate the action string to be used in messages
                var actionStr = newValue.GetValueOrDefault() ? "Disabling" : "Enabling";

                // Init the loading dialog
                var loading = await _dialogService.ShowProgressAsync("Toggling Users", $"{actionStr} users...");
                loading.SetCancelable(true);

                int i = 0, fail = 0;
                for (; i < selected.Count; i++)
                {
                    Users[selected[i]].IsDisabled = newValue.GetValueOrDefault();

                    // return if the user has canceled the operation
                    if (loading.IsCanceled)
                    {
                        break;
                    }

                    // Update the progress dialog
                    loading.SetMessage($"{actionStr} User \"{Users[selected[i]].Username}\" ...");
                    loading.SetProgress((double)i / selected.Count);

                    // DO the changing task and do the dependecies
                    if (!await _hotspotClient.UpdateUserAsync(Users[selected[i]].UserModel))
                    {
                        Users[selected[i]].IsDisabled = !newValue.GetValueOrDefault();
                        fail++;
                    }
                    else
                    {
                        Users[selected[i]].IsDisabled = newValue.GetValueOrDefault();
                    }
                }

                // close the progress dialog
                await loading.CloseAsync();

                // Show a notification about the operation
                _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs($"{i - fail + 1} Users have been {(newValue.GetValueOrDefault() ? "disabled" : "enabled")} successfully!", null, new SideNotificationViewModel("Hotspot Users", $"{i - fail + 1} Users have been {(newValue.GetValueOrDefault() ? "disabled" : "enabled")} successfully!")));

                // Update UI
                UsersSelectionChanged();
            });

            #endregion

            #region Refresh Command

            // Init Refresh Command
            RefreshCommand = new DelegateCommand <DataGrid>(async dg =>
            {
                await DialogHost.Show(new ProgressDialog(), "RootDialog", async(s, e) =>
                {
                    // fetch users from server
                    var users = (await _hotspotClient.LoadAllUsersAsync()).ToList().Select(u => new HotspotUserViewModel(u));

                    // Update user list
                    Users.Clear();
                    Users.AddRange(users);

                    e.Session.Close();

                    // update the users count and search command
                    RaisePropertyChanged(nameof(UsersCount));
                    RaisePropertyChanged(nameof(SelectedUsersCount));
                    RaisePropertyChanged(nameof(HasSelectedUsers));
                    ((DelegateCommand <DataGrid>)SearchCommand).RaiseCanExecuteChanged();
                }, null);
            });

            #endregion

            #region Search Command

            // A Command to find a user from the search box
            SearchCommand = new DelegateCommand <DataGrid>(async dg =>
            {
                if (string.IsNullOrEmpty(SearchText?.Trim()))
                {
                    return;
                }

                await Task.Run(() =>
                {
                    // found items list
                    var found = new List <HotspotUserViewModel>();

                    // do a parallel search in background
                    Parallel.ForEach(Users, user =>
                    {
                        // if entry matched add it to the list
                        if (user != null && (user.Username.Contains(SearchText) || user.Password.Contains(SearchText)))
                        {
                            found.Add(user);
                        }
                    });

                    // Deselect all items
                    Users.ForEach(u => u.IsSelected = false);

                    // Set found items as selected
                    foreach (var user in found)
                    {
                        if (user == null)
                        {
                            continue;
                        }
                        user.IsSelected = true;

                        // Scroll to the last item
                        if (user == found.Last())
                        {
                            Application.Current.Invoke(() => dg.ScrollIntoView(user));
                        }
                    }

                    // Show notification about the task status
                    _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs(SelectedUsersCount > 0 ? $"Found {SelectedUsersCount} Matches!" : "No Matches Found!"));

                    // Update the UI
                    RaisePropertyChanged(nameof(SelectedUsersCount));
                    RaisePropertyChanged(nameof(HasSelectedUsers));
                });
            }, dg => UsersCount > 0);

            #endregion

            #region AddUserCommand

            AddUserCommand = new DelegateCommand(async() => await DialogHost.Show(new AddHotspotUserView()));

            #endregion

            #region Add Users Command

            AddUsersCommand = new DelegateCommand(async() => await DialogHost.Show(new AddMultipleHotspotUsersView()));

            #endregion

            #region EditUserCommand

            EditUserCommand = new DelegateCommand(async() =>
            {
                var user = Users.SingleOrDefault(u => u.IsSelected);
                if (user == null)
                {
                    return;
                }

                var addDialogViewModel = new AddHotspotUserViewModel(_eventAggregator, _hotspotClient, new HotspotUserViewModel(user.UserModel.CloneEntity()));

                await DialogHost.Show(new AddHotspotUserView {
                    DataContext = addDialogViewModel
                });
            });

            #endregion

            #region Reset Command

            ResetCommand = new DelegateCommand(async() =>
            {
                // return if there is no selected users
                if (!HasSelectedUsers)
                {
                    return;
                }

                // get selected users
                var selected = Users.Where(u => u.IsSelected).Select(u => Users.IndexOf(u)).ToList();

                // Do Single Action
                if (selected.Count == 1)
                {
                    // Get a clone of the selected user model
                    var user = Users[selected[0]];

                    // Clone properties
                    ByteSize lbi   = user.LimitBytesIn, lbo = user.LimitBytesOut, lbt = user.LimitBytesTotal;
                    string profile = user.Profile, lut = user.LimitUptime, ip = user.IpAddress, mac = user.MacAddress;

                    // reset properties
                    user.LimitBytesOut = user.LimitBytesIn = user.LimitBytesTotal = ByteSize.MinValue;
                    user.LimitUptime   = "00:00:00";
                    user.Profile       = "default";
                    user.MacAddress    = "00:00:00:00:00:00";
                    user.IpAddress     = "0.0.0.0";

                    string message;

                    if (await _hotspotClient.UpdateUserAsync(user.UserModel))
                    {
                        message = $"The user \"{user.Username}\" has been reset successfully!";
                    }
                    else
                    {
                        message = $"Can't reset user \"{user.Username}\" !";

                        // Set old values back
                        user.IpAddress       = ip;
                        user.MacAddress      = mac;
                        user.LimitBytesOut   = lbo;
                        user.LimitBytesIn    = lbi;
                        user.LimitBytesTotal = lbt;
                        user.LimitUptime     = lut;
                        user.Profile         = profile;
                    }

                    _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs(message, null, new SideNotificationViewModel("Hotspot Users", message)));

                    // Update the UI
                    UsersSelectionChanged();

                    return;
                }

                /* DO Multiple reset operation */

                // Init loadng dialog
                var loading = await _dialogService.ShowProgressAsync("Reseting Users", "Reseting user - ...");
                loading.SetCancelable(true);

                var fail = 0;
                for (var i = 0; i < selected.Count; i++)
                {
                    if (loading.IsCanceled)
                    {
                        break;
                    }

                    // Get a clone of the selected user model
                    var user = Users[selected[i]];

                    // Update the loading dialog
                    loading.SetProgress((double)i / selected.Count);
                    loading.SetMessage($"Reseting user \"{user.Username}\" ...");

                    // Clone properties
                    ByteSize lbi   = user.LimitBytesIn, lbo = user.LimitBytesOut, lbt = user.LimitBytesTotal;
                    string profile = user.Profile, lut = user.LimitUptime, ip = user.IpAddress, mac = user.MacAddress;

                    // reset properties
                    user.LimitBytesOut = user.LimitBytesIn = user.LimitBytesTotal = ByteSize.MinValue;
                    user.LimitUptime   = "00:00:00";
                    user.Profile       = "default";
                    user.MacAddress    = "00:00:00:00:00:00";
                    user.IpAddress     = "0.0.0.0";

                    if (!await _hotspotClient.UpdateUserAsync(user.UserModel))
                    {
                        fail++;

                        // Set old values back
                        user.IpAddress       = ip;
                        user.MacAddress      = mac;
                        user.LimitBytesOut   = lbo;
                        user.LimitBytesIn    = lbi;
                        user.LimitBytesTotal = lbt;
                        user.LimitUptime     = lut;
                        user.Profile         = profile;
                    }
                }

                // Close the loading dialog and show a report about the operation
                await loading.CloseAsync();
                _eventAggregator.GetEvent <NotificationEvent>().Publish(new NotificationEventArgs($"{selected.Count - fail} User have been reset!", null, new SideNotificationViewModel("Hotspot Users", $"{selected.Count - fail} User have been reset!")));
            });

            #endregion
        }
Esempio n. 19
0
        //private void ClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
        //{
        //    showdata();
        //}

        private void btn_tambah_Click(object sender, RoutedEventArgs e)
        {
            var showdialog = new dialogTambahKamar();

            DialogHost.Show(showdialog, "MainDialog", ClosingEventHandler);
        }
Esempio n. 20
0
        private async void ProcessResults(object parameter)
        {
            if (ProcessButtonText == "Process")
            {
                if (!Directory.Exists(_projectFolder))
                {
                    var view = new AlertView
                    {
                        DataContext = new AlertViewModel("Project Folder Doesn't Exist")
                    };
                    await DialogHost.Show(view, "RootDialog");

                    //_notificationManager.Show(new NotificationContent
                    //{
                    //    Title = "What Should I Purge",
                    //    Message = "Project Folder Doesn't Exist",
                    //    Type = NotificationType.Error,
                    //});
                    return;
                }

                tokenSource     = new CancellationTokenSource();
                token           = tokenSource.Token;
                ProcessRunning  = true;
                ProgressPercent = 0;

                //_notificationManager.Show(new NotificationContent
                //{
                //    Title = "What Should I Purge",
                //    Message = "Processing",
                //    Type = NotificationType.Information
                //});

                Projects.Clear();

                List <string> projects          = Directory.GetDirectories(_projectFolder).ToList();
                List <string> autocompletePaths = new List <string>();
                foreach (string project in projects)
                {
                    if (project != null)
                    {
                        autocompletePaths.Add(project);
                        Projects.Add(new Model.Project2(Path.GetFileName(project), project));
                    }
                }

                AutoCompletePaths = autocompletePaths;
                ProcessButtonText = "Cancel";

                var tasks = new List <Task>();

                tasks.AddRange(Projects.Select(project => Task.Run(() => GetProjectInformation(project), token)));

                Task task = Task.WhenAll(tasks.ToArray());

                try
                {
                    await task;
                }
                catch { }

                if (task.Status == TaskStatus.RanToCompletion)
                {
                    ResetProcessButton();
                    ProgressPercent = 100;

                    //if (!token.IsCancellationRequested)
                    //_notificationManager.Show(new NotificationContent
                    //{
                    //    Title = "What Should I Purge",
                    //    Message = "Processed All Projects",
                    //    Type = NotificationType.Success,
                    //});
                }
            }
            else
            {
                tokenSource.Cancel();
                ResetProcessButton();

                //_notificationManager.Show(new NotificationContent
                //{
                //    Title = "What Should I Purge",
                //    Message = "Cancelled",
                //    Type = NotificationType.Warning
                //});
            }
        }
Esempio n. 21
0
        public async Task WhenContentIsNullItThrows()
        {
            var ex = await Assert.ThrowsAsync <ArgumentNullException>(() => DialogHost.Show(null));

            Assert.Equal("content", ex.ParamName);
        }
        private async void TrySave_Click(object sender, RoutedEventArgs e)
        {
            List <string> issues = new List <string>();

            if (ItemTextbox.SelectedIndex == -1)
            {
                issues.Add("Select an item.");
            }
            if (_selectedItem != null && _selectedItem.ItemHasRanks)
            {
                if (string.IsNullOrEmpty(Text_RankMin.Text))
                {
                    issues.Add("Include a minimum rank you would like to search for.");
                }

                if (string.IsNullOrEmpty(Text_RankMax.Text))
                {
                    issues.Add("Include a maximum rank you would like to search for.");
                }
            }
            if (string.IsNullOrEmpty(Text_Price.Text))
            {
                issues.Add("Include a price.");
            }
            switch ((CB_QuantityType.SelectedItem as ComboBoxItem).Content.ToString())
            {
            case "Any":
                break;

            case "At least":
                if (string.IsNullOrEmpty(Quantity_Selector_Single.Text))
                {
                    issues.Add("Include a minimum quantity to search for.");
                }
                break;

            case "At most":
                if (string.IsNullOrEmpty(Quantity_Selector_Single.Text))
                {
                    issues.Add("Include a maximum quantity to search for.");
                }
                break;

            case "Between":
                if (string.IsNullOrEmpty(Quantity_Selector_Single.Text))
                {
                    issues.Add("Include a maximum quantity to search for.");
                }
                if (string.IsNullOrEmpty(Quantity_Selector_Single.Text))
                {
                    issues.Add("Include a minimum quantity to search for.");
                }
                break;
            }

            if (issues.Count != 0)
            {
                StackPanel stackPanel = new StackPanel {
                    Margin = new Thickness(4, 4, 4, 4)
                };

                Button b = new Button
                {
                    Command = DialogHost.CloseDialogCommand,
                    Content = "Close"
                };
                TextBlock te = new TextBlock
                {
                    Text       = "Please fix the following issues:",
                    Padding    = new Thickness(20, 20, 20, 10),
                    FontWeight = FontWeights.Bold,
                    Foreground = Brushes.IndianRed
                };
                stackPanel.Children.Add(te);
                foreach (var issue in issues)
                {
                    TextBlock t = new TextBlock
                    {
                        Text    = issue,
                        Padding = new Thickness(20, 10, 20, 10)
                    };
                    stackPanel.Children.Add(t);
                }

                stackPanel.Children.Add(b);
                await DialogHost.Show(stackPanel);
            }
            else
            {
                C.Item itemBody = new C.Item
                {
                    UrlName = _selectedItem.UrlName,
                    Name    = ItemTextbox.Text,
                    Price   = int.Parse(Text_Price.Text),
                    Enabled = true
                };

                if (_selectedItem.ItemHasRanks)
                {
                    itemBody.ModRankMin = int.Parse(Text_RankMin.Text);
                    itemBody.ModRankMax = int.Parse(Text_RankMax.Text);
                }

                switch ((CB_QuantityType.SelectedItem as ComboBoxItem).Content.ToString())
                {
                case "Any":
                    itemBody.QuantityMin = 0;
                    itemBody.QuantityMax = 999;
                    break;

                case "At least":
                    itemBody.QuantityMin = int.Parse(Quantity_Selector_Single.Text);
                    itemBody.QuantityMax = 999;
                    break;

                case "At most":
                    itemBody.QuantityMin = 0;
                    itemBody.QuantityMax = int.Parse(Quantity_Selector_Single.Text);
                    break;

                case "Between":
                    itemBody.QuantityMin = int.Parse(Text_QuantityMin.Text);
                    itemBody.QuantityMax = int.Parse(Text_QuantityMax.Text);
                    break;
                }


                switch ((CB_BuySellSelector.SelectedItem as ComboBoxItem).Content.ToString())
                {
                case "Buying":
                    itemBody.Type = OrderType.Buy;
                    break;

                case "Selling":
                    itemBody.Type = OrderType.Sell;
                    break;
                }
                if (_importedConfig != null)
                {
                    int index = Global.Configuration.Items.IndexOf(_importedConfig);
                    if (index != -1)
                    {
                        Global.Configuration.Items[index] = itemBody;
                    }
                }
                else
                {
                    Global.Configuration.Items.Add(itemBody);
                }
                Functions.Config.Save();
                Close();
            }
        }
Esempio n. 23
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     DialogHost.Show(new Layout.UserControl_InputBox());
 }
Esempio n. 24
0
        public MainWindowViewModel()
        {
            Dictionary <string, Page> pageCache = new Dictionary <string, Page>();

            Model = new MainWindowModel();
            Page  = Model.ToReactivePropertySlimAsSynchronized(m => m.Page);

            TransitPage = new ReactiveCommand <string>();
            TransitPage.Subscribe(page =>
            {
                if (!pageCache.ContainsKey(page))
                {
                    pageCache.Add(page, (Page)Activator.CreateInstance(null !, page)?.Unwrap() !);
                }
                Page.Value = pageCache[page] !;
            });

            ButtonPower = new AsyncReactiveCommand();
            ButtonPower.Subscribe(async _ =>
            {
                var vm = new ConfirmDialogViewModel {
                    Message = { Value = "Are you sure to quit the application?" }
                };
                var dialog = new ConfirmDialog
                {
                    DataContext = vm
                };
                var res = await DialogHost.Show(dialog, "MessageDialogHost");
                if (res is bool quit && quit)
                {
                    AUTDHandler.Instance.Dispose();
                    SettingManager.SaveSetting("settings.json");
                    Application.Current.Shutdown();
                }
            });

            OpenUrl = new ReactiveCommand <string>();
            OpenUrl.Subscribe(url =>
            {
                var psi = new ProcessStartInfo
                {
                    FileName        = url,
                    UseShellExecute = true
                };
                Process.Start(psi);
            });

            Save = new AsyncReactiveCommand();
            Save.Subscribe(async _ =>
            {
                var dialogArgs = new SaveFileDialogArguments
                {
                    Width   = 600,
                    Height  = 800,
                    Filters = "json files|*.json",
                    ForceFileExtensionOfFileFilter = true,
                    CreateNewDirectoryEnabled      = true
                };
                var result = await SaveFileDialog.ShowDialogAsync("MessageDialogHost", dialogArgs);
                if (result.Canceled)
                {
                    return;
                }
                try
                {
                    SettingManager.SaveSetting(result.File);
                }
                catch
                {
                    var vm = new ErrorDialogViewModel {
                        Message = { Value = "Failed to save settings." }
                    };
                    var dialog = new ErrorDialog
                    {
                        DataContext = vm
                    };
                    await DialogHost.Show(dialog, "MessageDialogHost");
                }
            });

            Load = new AsyncReactiveCommand();
            Load.Subscribe(async _ =>
            {
                var dialogArgs = new OpenFileDialogArguments
                {
                    Width   = 600,
                    Height  = 800,
                    Filters = "json files|*.json"
                };
                var result = await OpenFileDialog.ShowDialogAsync("MessageDialogHost", dialogArgs);
                if (result.Canceled)
                {
                    return;
                }
                try
                {
                    SettingManager.LoadSetting(result.File);
                }
                catch
                {
                    var vm = new ErrorDialogViewModel {
                        Message = { Value = "Failed to load settings." }
                    };
                    var dialog = new ErrorDialog
                    {
                        DataContext = vm
                    };
                    await DialogHost.Show(dialog, "MessageDialogHost");
                }
            });

            Start = AUTDHandler.Instance.IsRunning.Select(x => !x).ToAsyncReactiveCommand();
            Start.Subscribe(async _ =>
            {
                if (!AUTDHandler.Instance.IsOpen.Value)
                {
                    var res = await Task.Run(() => AUTDHandler.Instance.Open());
                    if (res != null)
                    {
                        var vm = new ErrorDialogViewModel {
                            Message = { Value = $"Failed to open AUTD: {res}.\nSee Link options." }
                        };
                        var dialog = new ErrorDialog
                        {
                            DataContext = vm
                        };
                        await DialogHost.Show(dialog, "MessageDialogHost");
                        return;
                    }
                }

                AUTDHandler.Instance.SendGain();
                AUTDHandler.Instance.SendModulation();
            });
            Stop = AUTDHandler.Instance.IsRunning.Select(x => x).ToReactiveCommand();
            Stop.Subscribe(_ =>
            {
                AUTDHandler.Instance.Stop();
            });
        }
        private async void AnadirProductoTerminado()
        {
            var formProductoTerminado = new FormProductoTerminado(context);

            if ((bool)await DialogHost.Show(formProductoTerminado, "RootDialog"))
            {
                var formProductoTerminadoDataContext = formProductoTerminado.DataContext as FormProductoTerminadoViewModel;
                var productoTerminado = new ProductoTerminado()
                {
                    OrdenId       = OrdenElaboracionSeleccionada.OrdenElaboracionId,
                    TipoId        = (formProductoTerminado.cbTiposProductosTerminados.SelectedItem as TipoProductoTerminado).TipoProductoTerminadoId,
                    Volumen       = formProductoTerminadoDataContext.Volumen,
                    Unidades      = formProductoTerminadoDataContext.Unidades,
                    Observaciones = formProductoTerminadoDataContext.Observaciones
                };

                if (formProductoTerminadoDataContext.FechaBaja != null)
                {
                    productoTerminado.FechaBaja = new DateTime(
                        formProductoTerminadoDataContext.FechaBaja.Value.Year,
                        formProductoTerminadoDataContext.FechaBaja.Value.Month,
                        formProductoTerminadoDataContext.FechaBaja.Value.Day,
                        formProductoTerminadoDataContext.HoraBaja.Value.Hour,
                        formProductoTerminadoDataContext.HoraBaja.Value.Minute,
                        formProductoTerminadoDataContext.HoraBaja.Value.Second);
                }
                context.ProductosTerminados.Add(productoTerminado);

                var productosTerminadosComposiciones = new List <ProductoTerminadoComposicion>();
                foreach (var ptc in formProductoTerminadoDataContext.ProductosTerminadosComposiciones)
                {
                    var hhrId = ptc.HistorialHuecoRecepcion.HistorialHuecoRecepcionId;
                    // Los huecos que no se ha añadido ninguna cantidad no se añaden
                    if (ptc.Unidades != 0 && ptc.Volumen != 0)
                    {
                        // Hay que asegurarse que la cantidad de materia prima escogida es como máximo la disponible en el hueco
                        if (ptc.HistorialHuecoRecepcion.MateriaPrima.TipoMateriaPrima.MedidoEnUnidades == true)
                        {
                            ptc.Unidades = (ptc.Unidades > ptc.HistorialHuecoRecepcion.UnidadesRestantes) ? (ptc.HistorialHuecoRecepcion.UnidadesRestantes) : (ptc.Unidades);
                        }
                        else
                        {
                            ptc.Volumen = (ptc.Volumen > ptc.HistorialHuecoRecepcion.VolumenRestante) ? (ptc.HistorialHuecoRecepcion.UnidadesRestantes) : (ptc.Volumen);
                        }
                        ptc.HistorialHuecoRecepcion = null;
                        ptc.HistorialHuecoId        = hhrId;
                        ptc.ProductoTerminado       = productoTerminado;
                        productosTerminadosComposiciones.Add(ptc);
                    }
                }
                context.ProductosTerminadosComposiciones.AddRange(productosTerminadosComposiciones);

                var historialHuecosAlmacenajes = new List <HistorialHuecoAlmacenaje>();
                foreach (var hha in formProductoTerminadoDataContext.HistorialHuecosAlmacenajes)
                {
                    var haId = hha.HuecoAlmacenaje.HuecoAlmacenajeId;
                    // Los huecos que no se ha añadido ninguna cantidad no se añaden
                    if (hha.Unidades != 0 && hha.Volumen != 0)
                    {
                        hha.HuecoAlmacenaje   = null;
                        hha.HuecoAlmacenajeId = haId;
                        hha.ProductoTerminado = productoTerminado;
                        historialHuecosAlmacenajes.Add(hha);
                    }
                }
                context.HistorialHuecosAlmacenajes.AddRange(historialHuecosAlmacenajes);
                context.SaveChanges();

                CargarProductosTerminados();
            }
        }
Esempio n. 26
0
        /// <summary>
        /// HulftBook を作成するメソッド
        /// </summary>
        private async void Button_Click_CreateHulftBook(object sender, RoutedEventArgs e)
        {
            var file = HulftBookName.Text;

            if (string.IsNullOrWhiteSpace(file))
            {
                //MessageBox.Show("生成するHulftBookを指定して下さい。");
                HulftBookName.Focus();
                await DialogHost.Show(new MyMsgBox("生成するHulftBookファイルの指定がありません。指定して下さい。"));

                return;
            }
            // HulftBookのフォルダは問題ないか?
            // FileInfo クラスのインスタンスを生成
            FileInfo fileInfo = new FileInfo(HulftBookName.Text);
            // ディレクトリー名 (ディレクトリーパス) を取得
            string directoryName = fileInfo.DirectoryName;

            // 存在する場合は InitialDirectory プロパティに設定
            if (!Directory.Exists(directoryName))
            {
                //MessageBox.Show("指定したHulftBookのフォルダを見直して下さい。");
                HulftBookName.Focusable = true;
                _ = HulftBookName.Focus();
                await DialogHost.Show(new MyMsgBox("指定したHulftBookのフォルダを見直して下さい。"));

                return;
            }

            var defs = new Dictionary <string, string>()
            {
                { "snd", null }
                , { "rcv", null }
                , { "hst", null }
                , { "tgrp", null }
                , { "job", null }
            };

            // カーソルをくるくるに変える
            this.Cursor = System.Windows.Input.Cursors.Wait;

            // Snd
            if ((tbHulftSndDefFileName.Text != string.Empty) && File.Exists(tbHulftSndDefFileName.Text))
            {
                defs["snd"] = tbHulftSndDefFileName.Text;
            }
            // Rcv
            if ((tbHulftRcvDefFileName.Text != string.Empty) && File.Exists(tbHulftRcvDefFileName.Text))
            {
                defs["rcv"] = tbHulftRcvDefFileName.Text;
            }
            // Hst
            if ((tbHulftHstDefFileName.Text != string.Empty) && File.Exists(tbHulftHstDefFileName.Text))
            {
                defs["hst"] = tbHulftHstDefFileName.Text;
            }
            // TGrp
            if ((tbHulftTGrpDefFileName.Text != string.Empty) && File.Exists(tbHulftTGrpDefFileName.Text))
            {
                defs["tgrp"] = tbHulftTGrpDefFileName.Text;
            }
            // Job
            if ((tbHulftJobDefFileName.Text != string.Empty) && File.Exists(tbHulftJobDefFileName.Text))
            {
                defs["job"] = tbHulftJobDefFileName.Text;
            }

            var book = HulftBookName.Text;

            new CreateNewTemplateBook(book);

            if (defs["snd"] != null)
            {
                List <HulftSndDef> hulftSndDatas = BuildHulftSndDef.StreamBuildHulftSndDef(defs["snd"]);
                new UpdateBook(book, hulftSndDatas);
            }
            if (defs["rcv"] != null)
            {
                List <HulftRcvDef> hulftRcvDatas = BuildHulftRcvDef.StreamBuildHulftRcvDef(defs["rcv"]);
                new UpdateBook(book, hulftRcvDatas);
            }
            if (defs["hst"] != null)
            {
                List <HulftHstDef> hulftHstDatas = BuildHulftHstDef.StreamBuildHulftHstDef(defs["hst"]);
                new UpdateBook(book, hulftHstDatas);
            }
            if (defs["tgrp"] != null)
            {
                List <HulftTGrpDef> hulftTGrpDatas = BuildHulftTGrpDef.StreamBuildHulftTGrpDef(defs["tgrp"]);
                new UpdateBook(book, hulftTGrpDatas);
            }
            if (defs["job"] != null)
            {
                List <HulftJobDef> hulftJobDatas = BuildHulftJobDef.StreamBuildHulftJobDef(defs["job"]);
                new UpdateBook(book, hulftJobDatas);
            }

            // カーソルを戻す
            this.Cursor = null;
        }
Esempio n. 27
0
 private async void OpenSearchOptions()
 {
     await DialogHost.Show(SearchOptions, Id);
 }
Esempio n. 28
0
 private async void BtnCreateAccount_Click(object sender, RoutedEventArgs e)
 {
     CreateAccountView createaccount = new CreateAccountView();
     await DialogHost.Show(createaccount, "MainWindow");
 }
        private void InsertItem_Click(object sender, RoutedEventArgs e)
        {
            #region validation
            if (string.IsNullOrEmpty(QuantityTextBox.Text) || !(int.TryParse(QuantityTextBox.Text, out int a)))
            {
                var sMessageDialog = new MessageDialog
                {
                    Message = { Text =
                                    "ERROR: Enter valid Quantity!" }
                };

                DialogHost.Show(sMessageDialog, "RootDialog");
                return;
            }

            if (PanelComboBox.SelectedValue == null ||
                int.Parse(QuantityTextBox.Text) <= 0 ||
                (PanelComboBox.SelectedValue == null && int.Parse(QuantityTextBox.Text) <= 0) ||
                (int.Parse(QuantityTextBox.Text) >= 0 && PanelComboBox.SelectedValue == null))
            {
                var sMessageDialog = new MessageDialog
                {
                    Message = { Text =
                                    "ERROR: Select Product and Add Quantity\n(positive number)!" }
                };

                DialogHost.Show(sMessageDialog, "RootDialog");
                return;
            }
            #endregion

            ProductItem newItem = new ProductItem()
            {
                ProductID = int.Parse(PanelComboBox.SelectedValue.ToString()),
                Quantity  = int.Parse(QuantityTextBox.Text)
            };

            //If same item added again but with more quantity...
            var addedProduct = productItemsList.Where(x => x.ProductID == newItem.ProductID).FirstOrDefault();
            if (addedProduct != null)
            {
                addedProduct.Quantity += newItem.Quantity;
            }
            else
            {
                productItemsList.Add(newItem);
            }
            ClearItems();
            LoadData();

            if (true)
            {
                var sMessageDialog = new MessageDialog
                {
                    Message = { Text =
                                    "Item added!" }
                };
                DialogHost.Show(sMessageDialog, "RootDialog");
                return;
            }
        }
Esempio n. 30
0
 private void Settle_Click(object obj, RoutedEventArgs e)
 {
     DialogHost.Show(new ChangeWork {
         DataContext = new ChangeWorkViewModel(true)
     }, "RootDialog");
 }