示例#1
0
    void HandleSearchPropertyChanged(object?sender, PropertyChangedEventArgs e)
    {
        if (sender is not SearchViewModel searchViewModel)
        {
            return;
        }

        if (e.PropertyName != nameof(searchViewModel.Operation))
        {
            return;
        }

        if (this._lastSearchOperation != null)
        {
            BindingOperations.DisableCollectionSynchronization(this._lastSearchOperation.Results);
            BindingOperations.DisableCollectionSynchronization(this._lastSearchOperation.SearchErrors);
        }

        BindingOperations.EnableCollectionSynchronization(
            searchViewModel.Operation.Results,
            searchViewModel.Operation.ResultsLocker);
        BindingOperations.EnableCollectionSynchronization(
            searchViewModel.Operation.SearchErrors,
            searchViewModel.Operation.SearchErrorsLocker);

        this._lastSearchOperation = searchViewModel.Operation;
    }
        public void Dispose()
        {
            // Dispose each item
            ProgressionSlots?.ForEach(x => x.Dispose());

            // Disable collection synchronization
            BindingOperations.DisableCollectionSynchronization(ProgressionSlots);
        }
示例#3
0
    public void Dispose()
    {
        DisplayName?.Dispose();

        // Disable collection synchronization
        BindingOperations.DisableCollectionSynchronization(InstalledGames);
        BindingOperations.DisableCollectionSynchronization(NotInstalledGames);
    }
 private void NewsButton_MouseDown(object sender, MouseButtonEventArgs e)
 {
     TaskButton.UpdateColorToStart();
     NewsButton.UpdateColorToEnd();
     Items.ItemsSource = ((UserViewModels)DataContext).NormalUsers;
     BindingOperations.DisableCollectionSynchronization(((UserViewModels)DataContext).Admins);
     BindingOperations.EnableCollectionSynchronization(((UserViewModels)DataContext).NormalUsers, Items.ItemsSource);
 }
示例#5
0
    /// <summary>
    /// Disposes the directory and its containing files
    /// </summary>
    public virtual void Dispose()
    {
        // Disable collection synchronization
        BindingOperations.DisableCollectionSynchronization(Files);
        BindingOperations.DisableCollectionSynchronization(this);

        // Dispose files
        Files.DisposeAll();
    }
 public UserTab()
 {
     InitializeComponent();
     this.DataContext  = new UserViewModels();
     NewsButton.Locked = true;
     Items.ItemsSource = ((UserViewModels)DataContext).NormalUsers;
     BindingOperations.DisableCollectionSynchronization(((UserViewModels)DataContext).Admins);
     BindingOperations.EnableCollectionSynchronization(((UserViewModels)DataContext).NormalUsers, Items.ItemsSource);
 }
示例#7
0
        public void method_2()
        {
            object @lock = this._lock;

            lock (@lock)
            {
                BindingOperations.DisableCollectionSynchronization(this.Filtered);
                this.Filtered = new ObservableCollection <TreeNode>(this.Filtered.Where(new Func <TreeNode, bool>(this.method_11)));
                BindingOperations.EnableCollectionSynchronization(this.Filtered, this._lock);
            }
        }
示例#8
0
 private void DeleteSpellCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (this.GetSpellCollection(this.TabControl_Spellbook.SelectedIndex).SelectedItem is Spell s)
     {
         object o = new object();
         BindingOperations.EnableCollectionSynchronization(this[this.TabControl_Spellbook.SelectedIndex], o);
         this[this.TabControl_Spellbook.SelectedIndex].Remove(s);
         BindingOperations.DisableCollectionSynchronization(this[this.TabControl_Spellbook.SelectedIndex]);
         //this.GetSpellCollection(this.TabControl_Spellbook.SelectedIndex)
     }
 }
示例#9
0
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                viewModel.StatusText = "";
                var newTab = e.AddedItems[0];
                if (newTab != ScheduleTab)
                {
                    foreach (var schedule in viewModel.Schedule)
                    {
                        BindingOperations.DisableCollectionSynchronization(schedule);
                    }
                    return;
                }
                string message = null;
                if (viewModel.Students.Count == 0)
                {
                    message = "Nincsenek résztvevők!";
                    newTab  = ParticipantsTab;
                }
                if (message != null)
                {
                    viewModel.StatusText    = message;
                    viewModel.MagicPossible = false;
                    SaveButton.IsEnabled    = false;
                    // we don't activate newTab here anymore, because it caused weird behaviour
                }
                else if (newTab == ScheduleTab)
                {
                    viewModel.InitSchedule();

                    for (int i = 0; i < kcs.Length; i++)
                    {
                        if (i < viewModel.Teachers.Count)
                        {
                            BindingOperations.GetBindingExpression(kcs[i], ItemsControl.ItemsSourceProperty).UpdateTarget();
                            BindingOperations.GetBindingExpression(kcs[i], HeaderedItemsControl.HeaderProperty).UpdateTarget();
                        }
                        else
                        {
                            kcs[i].Visibility = Visibility.Collapsed;
                        }
                    }
                    viewModel.Algorithm     = new Algorithms(viewModel, _lock);
                    viewModel.MagicPossible = true;

                    foreach (var schedule in viewModel.Schedule)
                    {
                        BindingOperations.EnableCollectionSynchronization(schedule, _lock);
                    }
                }
            }
        }
        protected override void OnSourceChanged(object oldSource, object newSource)
        {
            if (oldSource is IEnumerable oldEnumerable && IsSynchronized)
            {
                BindingOperations.DisableCollectionSynchronization(oldEnumerable);
            }


            if (newSource is IEnumerable newEnumerable && IsSynchronized)
            {
                BindingOperations.EnableCollectionSynchronization(newEnumerable, _lock);
            }
        }
 private void OnIsSynchronizedChanged(DependencyPropertyChangedEventArgs args)
 {
     if (View != null && args.NewValue is bool value)
     {
         if (value)
         {
             BindingOperations.EnableCollectionSynchronization(View.SourceCollection, _lock);
         }
         else
         {
             BindingOperations.DisableCollectionSynchronization(View.SourceCollection);
         }
     }
 }
示例#12
0
 protected override void OnDispose()
 {
     ProcessModelItemCollection(0, mi =>
     {
         if (mi.GetCurrentValue() is TDev2TOFn dto)
         {
             CEventHelper.RemoveAllEventHandlers(dto);
         }
         CEventHelper.RemoveAllEventHandlers(mi);
     });
     if (ModelItemCollection != null)
     {
         BindingOperations.DisableCollectionSynchronization(ModelItemCollection);
     }
     ModelItemCollection = null;
     base.OnDispose();
 }
示例#13
0
 public void UpdateOff()
 {
     BindingOperations.DisableCollectionSynchronization(ShemedTabItems);
 }
示例#14
0
 public void DisableConfigBinding(MainWindow configWindow)
 {
     configWindow.Dispatcher.Invoke(() => { BindingOperations.DisableCollectionSynchronization(inventory); });
 }
示例#15
0
 /// <summary>
 /// Запретить обновление из потока Патерн MVVM
 /// </summary>
 public void UpdateOff()
 {
     BindingOperations.DisableCollectionSynchronization(XmlFiles);
 }
 public void Disable(IEnumerable collection)
 {
     BindingOperations.DisableCollectionSynchronization(collection);
 }
示例#17
0
 /// <summary>
 /// Запретить обновление из потока Pattern MvVM
 /// </summary>
 public void UpdateOff(ObservableCollection <FileDb> modelPrint)
 {
     BindingOperations.DisableCollectionSynchronization(modelPrint);
 }
示例#18
0
文件: ListFiles.cs 项目: mathewsun/My
 public void UpdateOff()
 {
     BindingOperations.DisableCollectionSynchronization(ShemesFilesReport);
 }
示例#19
0
 public void DisableConfigBinding(MainWindow configWindow)
 {
     configWindow.Dispatcher.Invoke(() => { BindingOperations.DisableCollectionSynchronization(criminalrecord); });
 }
示例#20
0
 private void DBOperator(object state)
 {
     //Check dbonline or not.
     if (this.mDatabase is null)
     {
         try
         {
             this.mDatabase = new Database();
         }
         catch
         {
             return;
         }
     }
     try
     {
         var locker = new object();
         BindingOperations.EnableCollectionSynchronization(this.FileList, locker);
         var rmlist = this.mDatabase.LoadData().ToList();
         foreach (var item in rmlist)
         {
             UploadFile hit = null;
             try
             {
                 hit = FileList.Where(x => x.ID == item.ID).First();
             }
             catch { };
             if (hit is null)
             {
                 try
                 {
                     var mf = new UploadFile(item, mDatabase);
                     this.Execute(() => FileList.Add(mf));
                 }
                 catch
                 {
                     $"[{item.ID}] [{item.FullFilePath}] ERROR, FILE NOT EXIST!".ErrorLognConsole();
                 }
             }
             else
             {
                 hit.UpdateFile(item.FullFilePath);
             }
         }
         List <UploadFile> mlist = new List <UploadFile>();
         foreach (var item in FileList)
         {
             if (!item.IsOver && !rmlist.Any(y => item.ID == y.ID))
             {
                 mlist.Add(item);
             }
         }
         foreach (var item in mlist)
         {
             this.Execute(() => FileList.Remove(item));
         }
         BindingOperations.DisableCollectionSynchronization(this.FileList);
         FileList.ForEach(x => x.RefreshData());
         this.TotalLength = FileList.Sum(x => x.Length);
         this.Processed   = FileList.Sum(x => x.IsOver ? x.Length : 0);
     }
     catch
     {
         Console.WriteLine("OOPS! DB not good!");
         return;
     }
 }
示例#21
0
 public static void DisableCollectionSynchronization(this IEnumerable source)
 {
     BindingOperations.DisableCollectionSynchronization(source);
 }
示例#22
0
 /// <summary>
 /// Запретить обновление из потока Патерн MVVM
 /// </summary>
 public void UpdateOff()
 {
     BindingOperations.DisableCollectionSynchronization(SchemesXlsx);
 }