Пример #1
0
        public async Task DeleteZone(object obj)
        {
            if (NotNetOrConnection)
            {
                return;
            }

            try
            {
                ZoneViewModel zvm = (ZoneViewModel)obj;
                State = ModelState.Loading;
                Zone zone = new Zone();
                zvm.SaveFields(zone);
                await NAV.DeleteZone(zone, ACD.Default).ConfigureAwait(true);

                ZoneViewModels.Remove(zvm);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                ErrorText = e.Message;
                State     = ModelState.Error;
            }
            finally
            {
                State         = ModelState.Normal;
                LoadAnimation = false;
            }
        }
        public async Task DeleteZone(object obj)
        {
            if (NotNetOrConnection)
            {
                return;
            }

            ZoneViewModel zvm = (ZoneViewModel)obj;

            //string request = String.Format(AppResources.ZonesPlanViewModel_DeleteZone, zvm.Name);

            string variant1 = String.Format(AppResources.ZonesPlanViewModel_DeleteZone, zvm.Code);
            string variant2 = String.Format(AppResources.ZonesPlanViewModel_DeleteZone2, zvm.Code);
            var    action   = await App.Current.MainPage.DisplayActionSheet(
                AppResources.ZonesPlanViewModel_DeleteQuestion,
                AppResources.ZonesPlanViewModel_DeleteCancel,
                null,
                variant1,
                variant2);

            if ((action != null) && (action != AppResources.ZonesPlanViewModel_DeleteCancel))
            {
                if (action == variant1)
                {
                    await zvm.SaveToZoneSchemeVisible(false);
                }
                if (action == variant2)
                {
                    try
                    {
                        State = ModelState.Loading;
                        Zone zone = new Zone();
                        zvm.SaveFields(zone);
                        await NAV.DeleteZone(zone, ACD.Default).ConfigureAwait(true);

                        ZoneViewModels.Remove(zvm);
                        State = ModelState.Normal;
                    }
                    catch (Exception e)
                    {
                        System.Diagnostics.Debug.WriteLine(e.Message);
                        ErrorText = e.Message;
                        State     = ModelState.Error;
                    }
                    finally
                    {
                        LoadAnimation = false;
                    }
                }
                await Load();
            }
        }
        private async void Zvm_OnTap(ZoneViewModel zvm)
        {
            if (!IsEditMode)
            {
                Zone zone = new Zone();
                zvm.SaveFields(zone);
                RacksViewModel  rvm = new RacksViewModel(Navigation, zone);
                RacksSchemePage rsp = new RacksSchemePage(rvm);
                await Navigation.PushAsync(rsp);
            }
            else
            {
                foreach (ZoneViewModel zv in ZoneViewModels)
                {
                    if (zv != zvm)
                    {
                        zv.IsSelected = false;
                        zv.EditMode   = SchemeElementEditMode.None;
                    }
                }
                if (zvm.IsSelected)
                {
                    switch (zvm.EditMode)
                    {
                    case SchemeElementEditMode.None:
                        break;

                    case SchemeElementEditMode.Move:
                        zvm.EditMode = SchemeElementEditMode.Resize;
                        break;

                    case SchemeElementEditMode.Resize:
                        zvm.IsSelected        = false;
                        SelectedZoneViewModel = null;
                        zvm.EditMode          = SchemeElementEditMode.None;
                        break;

                    default:
                        throw new InvalidOperationException("ZonesViewModel.Zvm_OnTap Impossible value");
                    }
                }
                else
                {
                    zvm.IsSelected        = true;
                    SelectedZoneViewModel = zvm;
                    zvm.EditMode          = SchemeElementEditMode.Move;
                    MessagingCenter.Send(this, "BringToFront");
                }
            }
        }