本文整理汇总了C#中ObservableCollection.SingleOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.SingleOrDefault方法的具体用法?C# ObservableCollection.SingleOrDefault怎么用?C# ObservableCollection.SingleOrDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.SingleOrDefault方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetBooking
public void SetBooking(Booking booking)
{
if (booking == null)
return;
_booking = booking;
FareInfo = booking.FareInfo;
OnPropertyChanged(() => FareInfo);
if (booking.FareInfo != null)
{
FareInfoItems = new ObservableCollection<FareTypeInfoItemViewModel>(booking.FareInfo.Items.Select(i => new FareTypeInfoItemViewModel(i, false)));
OnPropertyChanged(() => FareInfoItems);
FareInfoItems.ForEach(i => i.IsSelected = i.FareInfoItem.FareType == booking.FareType);
SelectedFareInfoItem = FareInfoItems.SingleOrDefault(i => i.IsSelected);
AcceptedTnC = SelectedFareInfoItem != null;
OnPropertyChanged(() => AcceptedTnC);
}
else
{
FareInfoItems = new ObservableCollection<FareTypeInfoItemViewModel>();
OnPropertyChanged(() => FareInfoItems);
SelectedFareInfoItem = null;
}
}
示例2: MainViewModel
public MainViewModel(XmlDatabase database)
{
if (database == null)
throw new ArgumentNullException("database");
_database = database;
Tabs = new ObservableCollection<TabViewModel>();
TabsView = (ListCollectionView) CollectionViewSource.GetDefaultView(Tabs);
TabsView.SortDescriptions.Add(new SortDescription("Title", ListSortDirection.Ascending));
// Loading applications asynchronously using reactive extensions to reduce initial startup time.
// TODO: Does this actually speed things up or is it loading all the sections before add doing
// the subscribe??
_database.LoadTabs().ToObservable().Subscribe(tabModel =>
{
TabViewModel tabViewModel = new TabViewModel(tabModel);
Tabs.Add(tabViewModel);
Configuration.AvailableTabs.Add(tabViewModel.Title);
},
() => // OnComplete
{
Tabs.CollectionChanged += OnTabsChanged;
// Expand the default tab when the application starts up.
ExpandedTab = Tabs.SingleOrDefault(obj => obj.Title == Configuration.DefaultTab) ?? Tabs.FirstOrDefault();
});
Messenger.Default.Register<ApplicationMessage>(this, OnApplicationMessage);
Messenger.Default.Register<TabMessage>(this, OnTabMessage);
Messenger.Default.Register<TabToMainMessage>(this, OnTabToMainMessage);
}
示例3: LoadGridColumnsWidth
public static void LoadGridColumnsWidth(ObservableCollection<XamGrid> xamGrids, XElement xml)
{
foreach (XElement widthElement in xml.Elements("GridSetting"))
{
if (widthElement != null)
{
string widthData = widthElement.Attribute("ColumnsWidth").Value;
string[] allWidth = widthData.Split(',');
string gridName = widthElement.Attribute("Name").Value;
int i = 0;
foreach (string widthStr in allWidth)
{
if (!string.IsNullOrEmpty(widthStr))
{
double width = 0;
if (double.TryParse(widthStr, out width))
{
xamGrids.SingleOrDefault(x => x.Name == gridName).Columns.DataColumns[i].Width = new ColumnWidth(width, false);
}
}
i++;
}
}
}
}
示例4: Refresh
public void Refresh(ObservableCollection<TicketItemPropertyViewModel> properties)
{
foreach (var model in Properties)
{
var m = model;
var tiv = properties.SingleOrDefault(x => x.Model.Name == m.Name);
model.TicketItemProperty = tiv != null ? tiv.Model : null;
model.Refresh();
}
}
示例5: LoadData
public async Task LoadData()
{
IsLoading = true;
ExistingPlayers = new ObservableCollection<Player>(PlayerHandler.instance.GetPlayersFromDatabase());
//Delete players in teams from existing player list
foreach (Team t in TeamHandler.instance.GetTeamsFromDatabase())
{
foreach (Player p in t.Players)
{
if (ExistingPlayers.SingleOrDefault(ep => ep == p) != null)
{
ExistingPlayers.Remove(p);
}
}
}
ExistingPlayers.CollectionChanged += ExistingPlayers_CollectionChanged;
CurrentTeam.Players.CollectionChanged += ExistingPlayers_CollectionChanged;
}
示例6: SearchViewModel
public SearchViewModel(ObservableCollection<TabViewModel> tabs)
{
Tabs = tabs;
SelectedTab = Tabs.SingleOrDefault(tabElem => tabElem.Title == Configuration.DefaultTab) ?? Tabs.FirstOrDefault();
_applications = new ObservableCollection<ApplicationViewModel>();
Applications = (ListCollectionView) CollectionViewSource.GetDefaultView(_applications);
Applications.SortDescriptions.Add(new SortDescription("Title", ListSortDirection.Ascending));
Applications.Filter = FilterPredicate;
SelectedApplications = new ObservableCollection<ApplicationViewModel>();
_loadWorker = new BackgroundWorker();
_loadWorker.WorkerSupportsCancellation = true;
_loadWorker.WorkerReportsProgress = true;
_loadWorker.DoWork += LoadApplications;
_loadWorker.ProgressChanged += LoadingProgressChanged;
_loadWorker.RunWorkerCompleted += LoadingComplete;
_loadWorker.RunWorkerAsync();
}
示例7: DownloadActivities
/// <summary>
/// Download MarketplaceAsset that AssetType is equal to Activities
/// </summary>
/// <param name="assets"></param>
/// <param name="assetType"></param>
public void DownloadActivities(IWorkflowsQueryService client)
{
var downloadedAssemblies = new List<ActivityAssemblyItem>();
foreach (MarketplaceAssetModel model in this.activities)
{
if (IsCancelDownload)
{
CancelDownload();
return;
}
ActivityAssemblyItem toDownloadAssembly = new ActivityAssemblyItem { Name = model.Name, Version = System.Version.Parse(model.Version) };
AssemblyDownloader.GetActivityItemsByActivityAssemblyItem(toDownloadAssembly, client);
//download dependendies
var dependecies = Caching.ComputeDependencies(client, toDownloadAssembly);
dependecies.Add(toDownloadAssembly);
var toCachedAssembly = Caching.DownloadAssemblies(client, dependecies);
toCachedAssembly.ToList().ForEach(i => i.UserSelected = model.IsAddToToolbox);
downloadedAssemblies.AddRange(toCachedAssembly);
//set download progress
currentDownloadingNumber++;
SetDownloadProgress();
}
if (!IsCancelDownload)
{
Caching.CacheAssembly(downloadedAssemblies);
Caching.Refresh();
if (this.currentWorkflow != null)
{
ObservableCollection<ActivityAssemblyItem> importAssemblies = new ObservableCollection<ActivityAssemblyItem>(this.currentWorkflow.WorkflowDesigner.DependencyAssemblies);
downloadedAssemblies.ForEach(i =>
{
if (importAssemblies.SingleOrDefault(item => item.FullName != i.FullName) == null)
importAssemblies.Add(i);
});
this.currentWorkflow.WorkflowDesigner.ImportAssemblies(importAssemblies.ToList());
}
this.activities.ForEach(
m => m.Location = Caching.ActivityAssemblyItems
.Where(i => i.Name == m.Name && i.Version.ToString() == m.Version)
.First().Location);
}
}
示例8: GetAllClinicalCasesByPatientRequestCompleted
private void GetAllClinicalCasesByPatientRequestCompleted( ReceivedResponses receivedResponses )
{
var response = receivedResponses.Get<GetAllClinicalCasesByPatientResponse> ();
var caseSummaryDtos = response.ClinicalCases;
AllClinicalCases = new ObservableCollection<ClinicalCaseSummaryDto> ( caseSummaryDtos );
if ( SelectedClinicalCase != null )
{
SelectedClinicalCase = AllClinicalCases.SingleOrDefault ( x => x.Key == SelectedClinicalCase.Key );
}
}
示例9: GetTaskSystemRoleListCompleted
private void GetTaskSystemRoleListCompleted( ReceivedResponses receivedResponses )
{
var response = receivedResponses.Get<DtoResponse<TaskSystemRolesDto>> ();
var taskSystemRoleList = response.DataTransferObject.SystemRoles;
taskSystemRoleList = new ObservableCollection<SystemRoleDto> ( taskSystemRoleList.OrderBy ( p => p.Name ).ToList () );
foreach ( var task in taskSystemRoleList )
{
task.GrantedSystemPermissions =
new ObservableCollection<SystemPermissionDto> ( task.GrantedSystemPermissions.OrderBy ( p => p.DisplayName ) );
}
TaskCollectionView = new PagedCollectionView ( taskSystemRoleList );
if ( IsBegunWithTaskWorkingMode.HasValue && IsBegunWithTaskWorkingMode.Value )
{
var initialTaskToEdit = taskSystemRoleList.SingleOrDefault ( p => p.Key == _initialSystemRoleKeyToEdit );
if ( initialTaskToEdit != null )
{
SelectedItemInTaskList = initialTaskToEdit;
}
else if ( _isAddingNewTask )
{
_isAddingNewTask = false;
ExecuteCreateNewTaskCommand ();
Thread.Sleep ( 500 );
}
else if ( !_isTaskGroupWorkingModeInitialized )
{
UpdateSelectedItemInTreeView ( true );
}
}
}
示例10: LoadSettings
private async Task LoadSettings()
{
await _webrtcSettingsService.InitializeWebRTC();
SignalingServerPort = int.Parse(SignalingSettings.SignalingServerPort);
SignalingServerHost = SignalingSettings.SignalingServerHost;
Domain = RegistrationSettings.Domain;
#if WIN10
AppInsightsEnabled = SignalingSettings.AppInsightsEnabled;
#endif
Cameras = new ObservableCollection<MediaDevice>(_webrtcSettingsService.VideoCaptureDevices);
if (_localSettings.Values[nameof(SelectedCamera)] != null)
{
var id = (string)_localSettings.Values[nameof(SelectedCamera)];
var camera = Cameras.SingleOrDefault(c => c.Id.Equals(id));
if (camera != null)
{
SelectedCamera = camera;
}
}
else
{
SelectedCamera = Cameras.FirstOrDefault();
}
_webrtcSettingsService.VideoDevice = SelectedCamera;
Microphones = new ObservableCollection<MediaDevice>(_webrtcSettingsService.AudioCaptureDevices);
if (_localSettings.Values[nameof(SelectedMicrophone)] != null)
{
var id = (string)_localSettings.Values[nameof(SelectedMicrophone)];
var mic = Microphones.SingleOrDefault(m => m.Id.Equals(id));
if (mic != null)
{
SelectedMicrophone = mic;
}
}
else
{
SelectedMicrophone = Microphones.FirstOrDefault();
}
_webrtcSettingsService.AudioDevice = SelectedMicrophone;
AudioCodecs = new ObservableCollection<CodecInfo>();
var audioCodecList = _webrtcSettingsService.AudioCodecs;
foreach (var audioCodec in audioCodecList)
{
if (!incompatibleAudioCodecs.Contains(audioCodec.Name + audioCodec.Clockrate))
{
AudioCodecs.Add(audioCodec);
}
}
if (_localSettings.Values[nameof(SelectedAudioCodec)] != null)
{
var audioCodecId = (int)_localSettings.Values[nameof(SelectedAudioCodec)];
var audioCodec = AudioCodecs.SingleOrDefault(a => a.Id.Equals(audioCodecId));
if (audioCodec != null)
{
SelectedAudioCodec = audioCodec;
}
}
else
{
SelectedAudioCodec = AudioCodecs.FirstOrDefault();
}
_webrtcSettingsService.AudioCodec = SelectedAudioCodec;
var videoCodecList = WebRTC.GetVideoCodecs().OrderBy(codec =>
{
switch (codec.Name)
{
case "VP8": return 1;
case "VP9": return 2;
case "H264": return 3;
default: return 99;
}
});
VideoCodecs = new ObservableCollection<CodecInfo>(videoCodecList);
if (_localSettings.Values[nameof(SelectedVideoCodec)] != null)
{
var videoCodecId = (int)_localSettings.Values[nameof(SelectedVideoCodec)];
var videoCodec = VideoCodecs.SingleOrDefault(v => v.Id.Equals(videoCodecId));
if (videoCodec != null)
{
SelectedVideoCodec = videoCodec;
}
}
else
{
SelectedVideoCodec = VideoCodecs.FirstOrDefault();
}
_webrtcSettingsService.VideoCodec = SelectedVideoCodec;
AudioPlayoutDevices = new ObservableCollection<MediaDevice>(_webrtcSettingsService.AudioPlayoutDevices);
string savedAudioPlayoutDeviceId = null;
if (_localSettings.Values[nameof(SelectedAudioPlayoutDevice)] != null)
{
savedAudioPlayoutDeviceId = (string)_localSettings.Values[nameof(SelectedAudioPlayoutDevice)];
var playoutDevice = AudioPlayoutDevices.SingleOrDefault(a => a.Id.Equals(savedAudioPlayoutDeviceId));
if (playoutDevice != null)
//.........这里部分代码省略.........
示例11: GetDraftOrder
public static ObservableCollection<Pick> GetDraftOrder(ObservableCollection<Team> teams)
{
OracleConnection cn = null;
OracleCommand cmd = null;
OracleDataReader rdr = null;
DataTable tbl = null;
ObservableCollection<Pick> picks = new ObservableCollection<Pick>();
try
{
cn = createConnectionSDR();
if (cn != null)
{
string sql = "select * from espnews.draftorder";
cmd = new OracleCommand(sql, cn);
rdr = cmd.ExecuteReader();
tbl = new DataTable();
tbl.Load(rdr);
rdr.Close();
Pick pick;
foreach (DataRow row in tbl.Rows)
{
pick = new Pick();
pick.OverallPick = Convert.ToInt16(row["pick"].ToString());
pick.Round = Convert.ToInt16(row["round"].ToString());
pick.RoundPick = Convert.ToInt16(row["roundpick"].ToString());
//pick.Team = GetTeam(Convert.ToInt32(row["teamid"].ToString()));
pick.Team = (Team)teams.SingleOrDefault(s => s.ID == Convert.ToInt32(row["teamid"]));
picks.Add(pick);
}
}
}
finally
{
if (cmd != null) cmd.Dispose();
if (tbl != null) tbl.Dispose();
if (cn != null) cn.Close(); cn.Dispose();
}
return picks;
}
示例12: MainViewModel
private MainViewModel(IWindowManager windowManager, IEventAggregator eventAggregator)
{
_windowManager = windowManager;
eventAggregator.Subscribe(this);
_userData = new UserData(Path.Combine(Directory.GetCurrentDirectory(), Global.UserConfigurationFile));
// fill the language combobox
_languages = LocalizationEx.GetSupportedLanguages();
// automatically use the correct translations if available (fallback: en)
LocalizeDictionary.Instance.SetCurrentThreadCulture = true;
// overwrite language detection
LocalizeDictionary.Instance.Culture = _userData.Language.Equals("auto")
? Thread.CurrentThread.CurrentCulture
: new CultureInfo(_userData.Language);
// select the current language in the combobox
_selectedLanguage =
_languages.SingleOrDefault(l => l.ShortCode.Equals(LocalizeDictionary.Instance.Culture.TwoLetterISOLanguageName));
// this is already defined in the app.manifest, but to be sure check it again
if (!IsAdministrator())
{
_windowManager.ShowMetroMessageBox(
LocalizationEx.GetUiString("dialog_message_bad_privileges", Thread.CurrentThread.CurrentCulture),
LocalizationEx.GetUiString("dialog_error_title", Thread.CurrentThread.CurrentCulture),
MessageBoxButton.OK, BoxType.Error);
Environment.Exit(1);
}
// do a simple check, if all needed files are available
if (!ValidateDnsCryptProxyFolder())
{
_windowManager.ShowMetroMessageBox(
LocalizationEx.GetUiString("dialog_message_missing_proxy_files",
Thread.CurrentThread.CurrentCulture),
LocalizationEx.GetUiString("dialog_error_title", Thread.CurrentThread.CurrentCulture),
MessageBoxButton.OK, BoxType.Error);
Environment.Exit(1);
}
if (_userData.UseIpv6)
{
DisplayName = string.Format("{0} {1}", Global.ApplicationName, VersionUtilities.PublishVersion);
}
else
{
DisplayName = string.Format("{0} {1} ({2})", Global.ApplicationName, VersionUtilities.PublishVersion,
LocalizationEx.GetUiString("global_ipv6_disabled", Thread.CurrentThread.CurrentCulture));
}
_resolvers = new List<DnsCryptProxyEntry>();
_updateResolverListOnStart = _userData.UpdateResolverListOnStart;
_isWorkingOnPrimaryService = false;
_isWorkingOnSecondaryService = false;
LocalNetworkInterfaces = new CollectionViewSource {Source = _localNetworkInterfaces};
PrimaryDnsCryptProxyManager = new DnsCryptProxyManager(DnsCryptProxyType.Primary);
SecondaryDnsCryptProxyManager = new DnsCryptProxyManager(DnsCryptProxyType.Secondary);
ShowHiddenCards = false;
if (PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.TcpOnly ||
SecondaryDnsCryptProxyManager.DnsCryptProxy.Parameter.TcpOnly)
{
_useTcpOnly = true;
}
// check the primary resolver for plugins
if (PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.Plugins.Any())
{
_plugins = PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.Plugins.ToList();
}
else
{
if (SecondaryDnsCryptProxyManager.DnsCryptProxy.Parameter.Plugins.Any())
{
_plugins = SecondaryDnsCryptProxyManager.DnsCryptProxy.Parameter.Plugins.ToList();
}
else
{
// no stored plugins
_plugins = new List<string>();
}
}
var proxyList = Path.Combine(Directory.GetCurrentDirectory(),
Global.DnsCryptProxyFolder, Global.DnsCryptProxyResolverListName);
var proxyListSignature = Path.Combine(Directory.GetCurrentDirectory(),
Global.DnsCryptProxyFolder, Global.DnsCryptProxySignatureFileName);
if (!File.Exists(proxyList) || !File.Exists(proxyListSignature) || UpdateResolverListOnStart)
{
// download and verify the proxy list if there is no one.
AsyncHelpers.RunSync(DnsCryptProxyListManager.UpdateResolverListAsync);
}
var dnsProxyList =
DnsCryptProxyListManager.ReadProxyList(proxyList, proxyListSignature, _userData.UseIpv6);
if (dnsProxyList != null && dnsProxyList.Any())
{
foreach (var dnsProxy in dnsProxyList)
{
if (
dnsProxy.Name.Equals(
PrimaryDnsCryptProxyManager.DnsCryptProxy.Parameter.ResolverName))
{
_primaryResolver = dnsProxy;
//.........这里部分代码省略.........
示例13: LoadSettings
private async Task LoadSettings()
{
_voipChannel.InitializeRTC();
SignalingServerPort = int.Parse(SignalingSettings.SignalingServerPort);
SignalingServerHost = SignalingSettings.SignalingServerHost;
Domain = RegistrationSettings.Domain;
#if WIN10
AppInsightsEnabled = SignalingSettings.AppInsightsEnabled;
#endif
if (_localSettings.Values[nameof(NtpServerIP)] != null)
{
NtpServerIP = (string)_localSettings.Values[nameof(NtpServerIP)];
}
if (_localSettings.Values[nameof(RTCTraceServerIp)] != null)
{
RTCTraceServerIp = (string)_localSettings.Values[nameof(RTCTraceServerIp)];
}
if (_localSettings.Values[nameof(RTCTraceServerPort)] != null)
{
RTCTraceServerPort = (string)_localSettings.Values[nameof(RTCTraceServerPort)];
}
Cameras = new ObservableCollection<MediaDevice>(_mediaSettings.GetVideoCaptureDevices().Devices);
SelectedCamera = null;
if (_localSettings.Values[nameof(SelectedCamera)] != null)
{
var id = (string)_localSettings.Values[nameof(SelectedCamera)];
var camera = Cameras.SingleOrDefault(c => c.Id.Equals(id));
if (camera != null)
{
SelectedCamera = camera;
}
}
if (SelectedCamera == null && Cameras.Count > 0)
{
SelectedCamera = Cameras.First();
}
_mediaSettings.SetVideoDevice(SelectedCamera);
Microphones = new ObservableCollection<MediaDevice>(_mediaSettings.GetAudioCaptureDevices().Devices);
SelectedMicrophone = null;
if (_localSettings.Values[nameof(SelectedMicrophone)] != null)
{
var id = (string)_localSettings.Values[nameof(SelectedMicrophone)];
var mic = Microphones.SingleOrDefault(m => m.Id.Equals(id));
if (mic != null)
{
SelectedMicrophone = mic;
}
}
if (SelectedMicrophone == null && Microphones.Count > 0)
{
SelectedMicrophone = Microphones.First();
}
_mediaSettings.SetAudioDevice(SelectedMicrophone);
AudioCodecs = new ObservableCollection<CodecInfo>();
var audioCodecList = _mediaSettings.GetAudioCodecs();
foreach (var audioCodec in audioCodecList.Codecs)
{
if (!incompatibleAudioCodecs.Contains(audioCodec.Name + audioCodec.Clockrate))
{
AudioCodecs.Add(audioCodec);
}
}
SelectedAudioCodec = null;
if (_localSettings.Values[nameof(SelectedAudioCodec)] != null)
{
var audioCodecId = (int)_localSettings.Values[nameof(SelectedAudioCodec)];
var audioCodec = AudioCodecs.SingleOrDefault(a => a.Id.Equals(audioCodecId));
if (audioCodec != null)
{
SelectedAudioCodec = audioCodec;
}
}
if (SelectedAudioCodec == null && AudioCodecs.Count > 0)
{
SelectedAudioCodec = AudioCodecs.First();
}
_mediaSettings.SetAudioCodec(SelectedAudioCodec);
var videoCodecList = _mediaSettings.GetVideoCodecs().Codecs.OrderBy(codec =>
{
switch (codec.Name)
{
case "VP8": return 1;
case "VP9": return 2;
case "H264": return 3;
default: return 99;
}
});
VideoCodecs = new ObservableCollection<CodecInfo>(videoCodecList);
SelectedVideoCodec = null;
if (_localSettings.Values[nameof(SelectedVideoCodec)] != null)
{
var videoCodecId = (int)_localSettings.Values[nameof(SelectedVideoCodec)];
var videoCodec = VideoCodecs.SingleOrDefault(v => v.Id.Equals(videoCodecId));
//.........这里部分代码省略.........
示例14: LoadShooterList
private void LoadShooterList()
{
try
{
int selectedShooterId = default (int);
if (SelectedUiShooter != null)
{
selectedShooterId = SelectedUiShooter.ShooterId;
}
Func<Shooter, UiShooter> selector = shooter => new UiShooter
{
PersonId = shooter.PersonId,
ShooterNumber = shooter.ShooterNumber,
ShooterId = shooter.ShooterId
};
List<UiShooter> shooterListItems;
if (SelectedUiPerson != null)
{
shooterListItems = _shooterDataStore.FindByPersonId(SelectedUiPerson.PersonId).Select(selector).ToList();
}
else
{
shooterListItems = _shooterDataStore.GetAll().Select(selector).ToList();
}
ShooterListItems = new ObservableCollection<UiShooter>(shooterListItems.Select(_ => _.FetchPerson(_personDataStore)));
SelectedUiShooter = ShooterListItems.SingleOrDefault(_ => _.ShooterId == selectedShooterId);
}
catch (Exception e)
{
ReportException(e);
}
}
示例15: PersonViewModel
//.........这里部分代码省略.........
}
PersonAddresses.CollectionChanged += (sender, e) =>
{
CurrentAddress = PersonAddresses.FirstOrDefault();
};
if (Model.Phones.Count > 0)
{
foreach (var phone in Model.Phones)
{
PersonPhones.Add(new PhoneViewModel(phone));
}
}
PersonPhones.CollectionChanged += (sender, e) =>
{
CurrentPhone = PersonPhones.FirstOrDefault();
};
AllConferences = new ObservableCollection<ConferenceViewModel>();
foreach (var c in DataManager.Instance.GetAllConferences())
{
AllConferences.Add(new ConferenceViewModel(c));
}
AllConferences.CollectionChanged += AllConferences_CollectionChanged;
// Проверяем режим работы конференция
if (DefaultManager.Instance.ConferenceMode)
{
var defConf = DefaultManager.Instance.DefaultConference;
var persConf = DataManager.Instance.GetPersonConference(Model, defConf);
if (persConf == null)
{
var newPersConf = DataManager.Instance.CreateObject<PersonConference>();
newPersConf.PersonConferenceId = GuidComb.Generate();
newPersConf.PersonId = Model.Id;
newPersConf.ConferenceId = defConf.Id;
newPersConf.PersonConferences_Detail =
DefaultManager.Instance.DefaultPersonConferenceDetail(newPersConf.PersonConferenceId);
newPersConf.PersonConferences_Payment =
DefaultManager.Instance.DefaultPersonConferencePayment(newPersConf.PersonConferenceId);
DataManager.Instance.AddPersonConference(newPersConf);
}
}
// Проверяем режим работы регистрация
if (DefaultManager.Instance.RegistrationMode)
{
var defConf = DefaultManager.Instance.DefaultConference;
var persConf = DataManager.Instance.GetPersonConference(Model, defConf);
if (persConf == null)
{
var newPersConf = DataManager.Instance.CreateObject<PersonConference>();
newPersConf.PersonConferenceId = GuidComb.Generate();
newPersConf.PersonId = Model.Id;
newPersConf.ConferenceId = defConf.Id;
newPersConf.PersonConferences_Detail =
DefaultManager.Instance.DefaultPersonConferenceDetail(newPersConf.PersonConferenceId);
newPersConf.PersonConferences_Detail.IsArrive = true;
newPersConf.PersonConferences_Detail.RankId = DefaultManager.Instance.DefaultRank.Id;
newPersConf.PersonConferences_Detail.DateArrive = DateTime.Now;
newPersConf.PersonConferences_Payment =
DefaultManager.Instance.DefaultPersonConferencePayment(newPersConf.PersonConferenceId);
DataManager.Instance.AddPersonConference(newPersConf);
}
else
{
persConf.PersonConferences_Detail.IsArrive = true;
persConf.PersonConferences_Detail.DateArrive = DateTime.Now;
DataManager.Instance.Save();
}
}
AllPersonConferences = new ObservableCollection<PersonConference>(DataManager.Instance.GetPersonConferencesForPerson(Model));
CurrentPersonConference = AllPersonConferences.Count > 0 ? AllPersonConferences[0] : null;
if (DefaultManager.Instance.ConferenceMode || DefaultManager.Instance.RegistrationMode)
{
CurrentPersonConference =
AllPersonConferences.SingleOrDefault(o => o.Conference == DefaultManager.Instance.DefaultConference);
}
AllAbstracts = new ObservableCollection<Abstract>(DataManager.Instance.GetAbstractsByPersonConferenceID(CurrentPersonConference.PersonConferenceId));
CurrentAbstract = AllAbstracts.FirstOrDefault();
PrintBadgeCommand = new DelegateCommand(o => PrintBadge());
PrintOrderCommand = new DelegateCommand(o => PrintOrder());
AddPersonConferenceCommand = new DelegateCommand(o => AddPersonConference());
RemovePersonConferenceCommand = new DelegateCommand(o => RemoveCurrentPersonConference(), (o) => CurrentPersonConference != null);
SaveCommand = new DelegateCommand(o => Save());
CancelCommand = new DelegateCommand(o => Cancel());
AddEmailCommand = new DelegateCommand(o => AddEmail());
AddAddressCommand = new DelegateCommand(o => AddAddress());
AddPhoneCommand = new DelegateCommand(o => AddPhone());
DeleteEmailCommand = new DelegateCommand(o => DeleteEmail(), (o) => CurrentEmail != null);
DeleteAddressCommand = new DelegateCommand(o => DeleteAddress(), (o) => CurrentAddress != null);
DeletePhoneCommand = new DelegateCommand(o => DeletePhone(), (o) => CurrentPhone != null);
AddAbstractCommand = new DelegateCommand(o => AddAbstract());
RemoveAbstractCommand = new DelegateCommand(o => DeleteAbstract(), o => CurrentAbstract != null);
}