本文整理汇总了C#中ObservableCollection.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.ToList方法的具体用法?C# ObservableCollection.ToList怎么用?C# ObservableCollection.ToList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FenetreGestionAdmin
public FenetreGestionAdmin()
{
//Delegate pour exécuter du code personnalisé lors du changement de langue de l'UI.
CultureManager.UICultureChanged += CultureManager_UICultureChanged;
InitializeComponent();
// Header de la fenetre
App.Current.MainWindow.Title = Nutritia.UI.Ressources.Localisation.FenetreGestionAdmin.Titre;
//Récupère tout les membres de la BD.
listMembres = new ObservableCollection<Membre>(serviceMembre.RetrieveAll());
//Récupère le temps de DerniereMaj (Mise à jour) des membres le plus récent et l'enregistre dans
//currentTime et previousTime.
currentTime = previousTime = listMembres.Max(m => m.DerniereMaj);
//On enlève le membre actuellement connecté de la liste pour qu'il ne puisse pas intéragir sur son propre compte.
listMembres.Remove(listMembres.FirstOrDefault(x => x.NomUtilisateur == App.MembreCourant.NomUtilisateur));
//Configure la dataGrid de la searchBox et le predicate pour le filtre.
filterDataGrid.DataGridCollection = CollectionViewSource.GetDefaultView(listMembres);
filterDataGrid.DataGridCollection.Filter = new Predicate<object>(Filter);
//De listMembres, obtient la liste des administrateurs seulement.
listAdmins = new ObservableCollection<Membre>(listMembres.Where(m => m.EstAdministrateur).ToList());
dgAdmin.ItemsSource = listAdmins;
adminDepart = listAdmins.ToList();
//Configuration du thread. Met en background pour forcer la terminaison lorsque le logiciel se ferme.
dbPoolingThread = new Thread(PoolDB);
dbPoolingThread.IsBackground = true;
dbPoolingThread.Start();
}
示例2: OnNavigatedTo
//evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString);
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string texto = "";
string texto1 = "";
if (NavigationContext.QueryString.TryGetValue("name", out texto))
this.name = texto;
if (NavigationContext.QueryString.TryGetValue("uri", out texto1))
this.uri = texto1;
//---------------------------------------------------------------------------------------------------------
using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
{
if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(uri)){
Favorite fav = new Favorite { Name = name, Uri = uri };
context.Favorites.InsertOnSubmit(fav);
context.SubmitChanges();
}
// Define query to fetch all customers in database.
var favv = from Favorite todo in context.Favorites
select todo;
// Execute query and place results into a collection.
aux = new ObservableCollection<Favorite>(favv);
listBox.ItemsSource = aux.ToList();
}
}
示例3: LoadTrackableResourceScreenItems
public void LoadTrackableResourceScreenItems()
{
IsDesignModeActive = true;
Widgets = new ObservableCollection<IDiagram>(_resourceService.LoadWidgets(SelectedResourceScreen.Name).Select(WidgetCreatorRegistry.CreateWidgetViewModel));
Widgets.ToList().ForEach(x => x.DesignMode = true);
RaisePropertyChanged(() => Widgets);
}
示例4: GetRecurrence
public void GetRecurrence(ObservableCollection<NotificacionModel> notifs)
{
NotificationRepository _NotificationRepository = new NotificationRepository();
long fechaSystema = long.Parse(String.Format("{0:yyyy:MM:dd:HH:mm:ss:fff}", DateTime.Now).Replace(":", ""));
if (notifs.Count() !=0)
{
notifs.ToList().ForEach(p =>
{
if (this.GetFUMRecurrencia(p) <= fechaSystema)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
this.GetParetWindows().GetScreenActive();
//actualizar la fecha por la del sistema
_NotificationRepository.UpdateNotificationRecurrencia(
new Model.NotificacionModel()
{
IdNotificacion = p.IdNotificacion,
Recurrencia =p.Recurrencia,
FechaUltimaMuestra = new UNID().getNewUNID()
});
}));
}
});
}
}
示例5: GetNotifications
public ObservableCollection<NotificacionModel> GetNotifications(UsuarioModel user, int runRefresh)
{
ObservableCollection<NotificacionModel> notifications = new ObservableCollection<NotificacionModel>();
ObservableCollection<NotificacionModel> notificationsRecurrencia = new ObservableCollection<NotificacionModel>();
//cuando arranca la aplicacion
if (runRefresh ==0)
{
//se Recetean la tabla de NOTIFICACION_ACTIVA
this.ResetNotificationActiva();
notifications = this.LoadNotifications(user);
//actualiza o inserta en la tabla NOTIFICACION_ACTIVA la bandera IsActiva en true
if (notifications.Count != 0)
this.UpdateNotificationActiva(notifications);
//Si la recurrencia es > 0 actualiza la fecha ultima muestra
notifications.ToList().Where(r => r.Recurrencia > 0).ToList().ForEach(n =>
{
n.FechaUltimaMuestra = new UNID().getNewUNID();
notificationsRecurrencia.Add(n);
});
//inserta los registros con recurrencia
if (notificationsRecurrencia.Count != 0)
this.UpdateNotificationRecurrencia(notificationsRecurrencia);
}
else
{
notifications = this.LoadNotifications(user);
}
return notifications;
}
示例6: Copy
public void Copy(ObservableCollection<ItemData> selectedItems)
{
var list = selectedItems.ToList();
if (!list.Any()) return;
Clipboard.Clear();
Clipboard.SetDataObject(list, false);
}
示例7: InputViewModel
public InputViewModel(string prompt, string defaultInputValue, IEnumerable<string> options, RelayCommand<string> dismissed)
{
Options = new ObservableCollection<string>(options);
SearchOptions = new ObservableCollection<string>();
Dismissed = dismissed;
SearchHelper = new SearchHelper(() =>
{
SearchOptions.Clear();
foreach (var option in Options)
SearchOptions.Add(option);
},
(searchString) =>
{
var lowerCaseSearch = searchString.ToLower();
var filteredOptions = Options.Where(str => str.ToLower().Contains(searchString) || lowerCaseSearch.Contains(str.ToLower())).ToList();
var existingSearch = SearchOptions.ToList();
foreach (var option in existingSearch)
{
if (filteredOptions.Contains(option))
filteredOptions.Remove(option);
else
SearchOptions.Remove(option);
}
foreach (var option in filteredOptions)
SearchOptions.Add(option);
}, 1, "`", 0);
Prompt = prompt;
InputValue = defaultInputValue;
//clear it so we dont start with any search populated
SearchOptions.Clear();
}
示例8: salaryClient_ImportEmployeeAddSumFromExcelForShowCompleted
void salaryClient_ImportEmployeeAddSumFromExcelForShowCompleted(object sender, ImportEmployeeAddSumFromExcelForShowCompletedEventArgs e)
{
RefreshUI(RefreshedTypes.HideProgressBar);
if (e.Error == null)
{
if (!string.IsNullOrEmpty(e.strMsg))
{
ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), e.strMsg,
Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
return;
}
if (e.Result != null)
{
ListPensions = e.Result;
this.LoadData(ListPensions.ToList());
}
else
{
ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), "没有导入的数据",
Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
return;
}
}
else
{
ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("CAUTION"), "导入员工员工加扣款记录失败",
Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
return;
}
}
示例9: ConnectWindow
public ConnectWindow()
{
InitializeComponent();
try
{
IsAvailableServer = ServiceCtrlClass.ServiceIsInstalled("EpgTimer Service") == true ||
System.IO.File.Exists(SettingPath.ModulePath.TrimEnd('\\') + "\\EpgTimerSrv.exe") == true;
btn_edit.Visibility = Visibility.Collapsed;
ConnectionList = new ObservableCollection<NWPresetItem>(Settings.Instance.NWPreset);
var nowSet = new NWPresetItem(DefPresetStr, Settings.Instance.NWServerIP, Settings.Instance.NWServerPort, Settings.Instance.NWWaitPort, Settings.Instance.NWMacAdd, Settings.Instance.NWPassword);
int pos = ConnectionList.ToList().FindIndex(item => item.EqualsTo(nowSet, true));
if (pos == -1)
{
ConnectionList.Add(nowSet);
pos = ConnectionList.Count - 1;
}
if (IsAvailableServer == true)
{
ConnectionList.Insert(0, new NWPresetItem("ローカル接続", "", 0, 0, "", new SerializableSecureString()));
pos++;
}
ConnectionList.Add(new NWPresetItem("<新規登録>", "", 0, 0, "", new SerializableSecureString()));
listView_List.ItemsSource = ConnectionList;
if (IsAvailableServer == false)
{
Settings.Instance.NWMode = true;
}
listView_List.SelectedIndex = Settings.Instance.NWMode == true ? pos : 0;
}
catch { }
}
示例10: GetKanjiLists
public ObservableCollection<KanjiListViewModel> GetKanjiLists()
{
kanjiLists = new ObservableCollection<KanjiListViewModel>();
App.ReviewList.KanjiLists.ForEach(k => kanjiLists.Add(new KanjiListViewModel() { Name = k.Name, Kanji = k.Kanji, Bookmark = k.Bookmark, Completed = k.Completed }));
kanjiLists.ToList().ForEach(k => k.PropertyChanged += ReviewListChanged);
isDirty = false;
return kanjiLists;
}
示例11: WriteSpacesFile
public static void WriteSpacesFile(Project project, ObservableCollection<Space> spaces)
{
Log.Info("Saving spaces file to " + project.Files.Spaces);
var json = new JsonSerializer { Formatting = Formatting.Indented };
using (var sw = new StreamWriter(project.Files.Spaces))
{
json.Serialize(sw, spaces.ToList());
}
Log.Info("Spaces file saved successfully");
}
示例12: ModulesList
public ModulesList(Settings settings, ObservableCollection<IPlugin> plugins)
{
InitializeComponent();
_plugins = new ObservablePluginGroup("Plugins", "");
plugins.ToList().ForEach(_plugins.Add);
_plugins.CollectionChanged += Update;
PluginsToTypes();
TypesToGroups();
DataContext = this;
}
示例13: CollectionAsList
public static List<string> CollectionAsList(ObservableCollection<string> collection)
{
List<string> newList = new List<string>(); ;
if (collection != null)
GUIDispatcher.Invoke((Action)(() => { newList = collection.ToList<string>(); }));
else
throw new ArgumentNullException("Collection can not be null");
return newList;
}
示例14: Cut
public void Cut(ObservableCollection<ItemData> selectedItems, RangeObservableCollection<ItemData> itemsSource)
{
Clipboard.Clear();
var list = selectedItems.ToList();
Clipboard.SetDataObject(list, false);
if (selectedItems == null) return;
foreach (var selectedItem in list)
{
itemsSource.Remove(selectedItem);
}
}
示例15: TestPdfDoesntOverwriteOtherFileWithSameName
// [Test]
public void TestPdfDoesntOverwriteOtherFileWithSameName()
{
var attachment =
new ProtectAttachment(TestUtils.CreateAttachment("FilesWithSameName.zip", "FilesWithSameName.zip", "1"));
var attachments = new ObservableCollection<IProtectAttachment>()
{
attachment
};
var actionQueue = new ActionQueue();
bool discoveryCompleted = false;
bool appliedAllActions = false;
actionQueue.StatusUpdate += (sender, args) =>
{
if (args.Status == PropertyNames.DiscoveryCompleted)
{
discoveryCompleted = true;
}
if (args.Status == PropertyNames.AppliedAllActions)
{
appliedAllActions = true;
}
};
actionQueue.Discover(attachments.ToList());
SpinWait.SpinUntil(() => discoveryCompleted, 90000);
Assert.IsTrue(discoveryCompleted, "Discovery failed to complete.");
var xlsx = attachment.Children.First(x => x.FileName.Contains(".xlsx"));
var options = new Dictionary<string, dynamic> {{PropertyNames.PdfFormat, PropertyValues.PdfA}};
var pdf = WorkshareTaskFactory.CreatePdfTask(xlsx, options);
var task = new TaskRepack(attachments);
actionQueue.ApplyTasks(new List<IWorkshareTask>()
{
pdf,
task
});
SpinWait.SpinUntil(() => appliedAllActions, 90000);
Assert.IsTrue(appliedAllActions, "Failed to apply all actions within the time limit");
new Workshare.API.Cleaning.OfficeApplicationCacheControl().ReleaseOfficeApplications();
VerifyFilesAreNotEqual(attachment.FileName);
SpinWait.SpinUntil(TestUtils.HasOfficeShutDown, 60000);
}