Exemplo n.º 1
0
        /// <inheritdoc />
        protected override bool CanPaste(bool asRoot)
        {
            var copyPasteService = ServiceProvider.TryGet <ICopyPasteService>();

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

            if (asRoot)
            {
                return(PasteAsRootMonitor.Get(() =>
                                              copyPasteService.CanPaste(SafeClipboard.GetText(), Asset.AssetType, typeof(AssetCompositeHierarchyData <UIElementDesign, UIElement>), typeof(AssetCompositeHierarchyData <UIElementDesign, UIElement>))));
            }

            var canAddOrInsert = SelectedItems.All(element =>
            {
                var contentControl = element as ContentControlViewModel;
                if (contentControl != null)
                {
                    return(contentControl.AssetSideControl.Content == null);
                }
                return(element is PanelViewModel);
            });

            if (!canAddOrInsert)
            {
                return(false);
            }

            return(PasteMonitor.Get(() => copyPasteService.CanPaste(SafeClipboard.GetText(), Asset.AssetType, typeof(UIElement), typeof(AssetCompositeHierarchyData <UIElementDesign, UIElement>))));
        }
Exemplo n.º 2
0
        private async Task <KeyedList <string, TLObject> > SearchLocalAsync(string query1)
        {
            var query = LocaleHelper.GetQuery(query1);

            var dialogs = await Task.Run(() => CacheService.GetDialogs());

            var contacts = await Task.Run(() => CacheService.GetContacts());

            if (dialogs != null && contacts != null)
            {
                var simple = new List <TLUser>();

                var contactsResults = contacts.OfType <TLUser>().Where(x =>
                                                                       SelectedItems.All(selectedUser => selectedUser.Id != x.Id) &&
                                                                       x.IsLike(query, StringComparison.OrdinalIgnoreCase));

                foreach (var result in contactsResults)
                {
                    simple.Add(result);
                }

                if (simple.Count > 0)
                {
                    return(new KeyedList <string, TLObject>(null, simple));
                }
            }

            return(null);
        }
Exemplo n.º 3
0
 void UpdateSum()
 {
     if (SelectedItems == null)
     {
         return;
     }
     Sum = SelectedItems.All(i => i.IsPricePerDay) ? SelectedItems.Sum(i => i.TotalPrice * DaysSliderValue) : SelectedItems.Sum(s => s.TotalPrice);
 }
Exemplo n.º 4
0
 bool CanCheckIn(CheckInTarget target)
 {
     if (!IsCorrectlyLoaded)
     {
         return(false);
     }
     if (IsSingleSelection)
     {
         return(CanCheckInItem(target, SelectedItem));
     }
     return(SelectedItems.All(item => CanCheckInItem(target, item)));
 }
Exemplo n.º 5
0
        public override void ButtonDeleteClick(object sender, EventArgs e)
        {
            if (this.SelectedItems == null ||
                this.SelectedItems.Count == 0)
            {
                return;
            }

            if (!SelectedItems.All(i => i.Status == EditionRevisionStatus.Temporary))
            {
                MessageBox.Show(@"You can delete object in Status Temporary", "Exclamation",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }



            string typeName = nameof(CheckLists);

            DialogResult confirmResult =
                MessageBox.Show(this.SelectedItems.Count == 1
                        ? "Do you really want to delete " + typeName + " " + this.SelectedItems[0] + "?"
                        : "Do you really want to delete selected " + typeName + "s?", "Confirm delete operation",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (confirmResult == DialogResult.Yes)
            {
                this.radGridView1.BeginUpdate();
                GlobalObjects.NewKeeper.Delete(this.SelectedItems.OfType <BaseEntityObject>().ToList(), true);

                foreach (var check in this.SelectedItems)
                {
                    if (check.Type == RevisionType.Revision)
                    {
                        GlobalObjects.CaaEnvironment.NewLoader.Execute(
                            $"update dbo.CheckListRevisionRecord set IsDeleted = 1 where ParentId = {check.ItemId}");
                    }
                    else
                    {
                        GlobalObjects.CaaEnvironment.NewLoader.Execute(
                            $"update dbo.CheckList set IsDeleted = 1 where ItemId = {check.CheckListId})");
                    }
                }

                this.radGridView1.EndUpdate();
                _animatedThreadWorker.RunWorkerAsync();
            }
        }
        private void OnItemTapped(object sender, ItemTappedEventArgs itemTappedEventArgs)
        {
            if (itemTappedEventArgs.Item != null)
            {
                if (SelectedItems.All(x => x != itemTappedEventArgs.Item))
                {
                    SelectedItems.Add(itemTappedEventArgs.Item);
                }
                else
                {
                    SelectedItems.Remove(itemTappedEventArgs.Item);
                }

                this.SelectedItem = null;
            }
        }
Exemplo n.º 7
0
 public void UpdateSalesLines()
 {
     SelectedItems.RemoveAll(i => i.SelectedQuantity == null || i.SelectedQuantity == 0 || i.OrderType == null);
     if (ParentModel.Order.OrderBaseType == OrderBaseTypes.Current)
     {
         (ParentSalesLines as List <SalesLine>).RemoveAll(i => SelectedItems.All(j => j.No_ != i.No_));
         int maxIndex = GetMaxInd();
         foreach (var item in SelectedItems)
         {
             var sl = ParentModel.SalesLines.FirstOrDefault(i => i.No_ == item.No_);
             if (sl != null)
             {
                 sl.Quantity  = item.SelectedQuantity;
                 sl.OrderType = (int)item.OrderType.Value;
                 sl.UnitPrice = item.OrderType == OrderTypes.CQ && item.UnitPriceCQ.HasValue
                     ? item.UnitPriceCQ.Value
                     : sl.UnitPrice;
                 sl.AmountIncludingVAT = (item.OrderType == OrderTypes.Ok || item.OrderType == OrderTypes.CQ)
                     ? Math.Round(item.SelectedQuantity.Value * item.UnitPrice.Value, 2, MidpointRounding.AwayFromZero)
                     : 0;
             }
             else
             {
                 maxIndex += 100;
                 AddNewSalesLine(CreateSalesLine(item, maxIndex));
             }
         }
     }
     else
     {
         int maxIndex = GetMaxInd();
         foreach (var item in SelectedItems)
         {
             maxIndex += 100;
             AddNewSalesLine(CreateSalesLine(item, maxIndex));
         }
     }
     ParentModel.Order.AmountIncludingVat = ParentModel.SalesLines.Sum(i => i.AmountIncludingVAT);
     ParentModel.RefreshSummary();
 }
Exemplo n.º 8
0
        private async Task <KeyedList <string, TLObject> > SearchGlobalAsync(string query)
        {
            if (query.Length < 5)
            {
                return(null);
            }

            var result = await ProtoService.SearchAsync(query, 100);

            if (result.IsSucceeded)
            {
                if (result.Result.Results.Count > 0)
                {
                    var parent = new KeyedList <string, TLObject>("Global search results");

                    CacheService.SyncUsersAndChats(result.Result.Users, result.Result.Chats,
                                                   tuple =>
                    {
                        result.Result.Users = tuple.Item1;
                        result.Result.Chats = tuple.Item2;

                        foreach (var peer in result.Result.Results)
                        {
                            var item = result.Result.Users.FirstOrDefault(x => x.Id == peer.Id);
                            if (item != null && SelectedItems.All(selectedUser => selectedUser.Id != item.Id))
                            {
                                parent.Add(item);
                            }
                        }
                    });

                    return(parent);
                }
            }

            return(null);
        }
Exemplo n.º 9
0
        public override void ToggleBreakWhenThrown()
        {
            // Toggling everything seems to be less useful, it's more likely that you'd want
            // to enable all selected exceptions or disable all of them.
            bool allSet      = SelectedItems.All(a => a.BreakWhenThrown);
            var  newSettings = new DbgExceptionIdAndSettings[SelectedItems.Count];

            for (int i = 0; i < newSettings.Length; i++)
            {
                var vm    = SelectedItems[i];
                var flags = vm.Settings.Flags;
                if (allSet)
                {
                    flags &= ~DbgExceptionDefinitionFlags.StopFirstChance;
                }
                else
                {
                    flags |= DbgExceptionDefinitionFlags.StopFirstChance;
                }
                var settings = new DbgExceptionSettings(flags, vm.Settings.Conditions);
                newSettings[i] = new DbgExceptionIdAndSettings(vm.Definition.Id, settings);
            }
            dbgExceptionSettingsService.Value.Modify(newSettings);
        }
 private bool MessagesForwardCanExecute()
 {
     return(SelectedItems.Count > 0 && SelectedItems.All(x => x.CanBeForwarded));
 }
 private bool MessagesDeleteCanExecute()
 {
     return(SelectedItems.Count > 0 && SelectedItems.All(x => x.CanBeDeletedForAllUsers || x.CanBeDeletedOnlyForSelf));
 }
Exemplo n.º 12
0
 public DialogSharedMediaViewModel(IMTProtoService protoService, ICacheService cacheService, ITelegramEventAggregator aggregator)
     : base(protoService, cacheService, aggregator)
 {
     MessagesForwardCommand = new RelayCommand(MessagesForwardExecute, () => SelectedItems.Count > 0 && SelectedItems.All(x => x is TLMessage));
     MessageViewCommand     = new RelayCommand <TLMessageBase>(MessageViewExecute);
     MessageSaveCommand     = new RelayCommand <TLMessageBase>(MessageSaveExecute);
     MessageDeleteCommand   = new RelayCommand <TLMessageBase>(MessageDeleteExecute);
     MessageForwardCommand  = new RelayCommand <TLMessageBase>(MessageForwardExecute);
     MessageSelectCommand   = new RelayCommand <TLMessageBase>(MessageSelectExecute);
 }