private static void queueForWork(AsyncTreeViewModel unit) { lock (_worker) { if (!workUnits.Contains(unit)) { workUnits.Enqueue(unit); } } _treesHaveWork.Set(); }
void SearchFinished(AsyncOperationInstance <IList <ISerializableObject> > operation, IList <ISerializableObject> result) { List <IISOViewModel> selectionList = buildQueryResult(result); DispatcherHelper.CheckBeginInvokeOnUI( () => { _queryResult = selectionList; QueryResultTree = new AsyncTreeViewModel(ISOStore); RaiseQueryResultChanged(); CurrentOperation = null; }); }
public SelectionViewModel() : base("Selection_Next", "Selection_Previous", "Selection_Title", "") { PreviousPage = Messages.Page.FieldData; NextPage = Messages.Page.Actions; CanNavigateNext = false; CanNavigateBack = false; MessengerInstance.Register <Selection>(this, (msg) => { CanNavigateNext = false; CanNavigateBack = false; BuildingSelection = false; BuildStatus = "Selection_WaitingForTree"; SelectionTree = new AsyncTreeViewModel(ISOStore); SelectionTree.TruncateDataItems = msg.TruncateDataItems; foreach (var vm in msg.Content) { SelectionTree.addGenerator(vm); } SelectionTree.SelectionBuildProgressChanged += new SelectionBuildProgressChangedHandler(SelectionTree_SelectionBuildProgressChanged); new Action(() => { _completeSelection = SelectionTree.buildSelection(); DispatcherHelper.CheckBeginInvokeOnUI(() => { SelectionTree.SelectionBuildProgressChanged -= SelectionTree_SelectionBuildProgressChanged; CanNavigateBack = true; CanNavigateNext = true; BuildingSelection = false; BuildStatus = "Selection_Done"; }); }).BeginInvoke(null, null); }); }
/// <summary> /// Initializes a new instance of the SelectFieldDataViewModel class. /// </summary> public SelectFieldDataViewModel() : base("SelectFD_Next", "SelectFD_Previous", "SelectFD_Title", "SelectFD_Description") { NextPage = Messages.Page.FinalSelection; PreviousPage = Messages.Page.Actions; CanNavigateBack = true; CanNavigateNext = true; QueryDatabase = new RelayCommand(executeSearch, () => ConfiguredSearch != null); AddToSelection = new RelayCommand <IList>((selection) => { if (SelectionTree == null) { SelectionTree = new AsyncTreeViewModel(ISOStore); } if (_queryResult != null && selection != null) { var typedSelection = Enumerable.Cast <IISOViewModel>(selection); foreach (var generator in typedSelection) { if (!_selection.Contains(generator)) { _selection.Add(generator); } } if (typedSelection.Count() > 0) { RaiseSelectionChanged(); } } }); RemoveFromSelection = new RelayCommand <IList>((selection) => { if (_queryResult != null && selection != null) { var typedSelection = Enumerable.Cast <IISOViewModel>(selection); foreach (var generator in typedSelection) { _selection.Remove(generator); } if (selection.Count > 0) { RaiseSelectionChanged(); } } }); MessengerInstance.Register <ConnectionStateChanged>(this, (msg) => { //Repository Disconnected if ((msg.Content & ConnectionState.ConnectedToRepository) != ConnectionState.ConnectedToRepository) { clearSelection(); } }); MessengerInstance.Register <Settings>(this, (msg) => updateFromSettings(msg.Content)); MessengerInstance.Send <SettingsRequest>(new SettingsRequest()); }