本文整理汇总了C#中ObservableCollection.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.ToArray方法的具体用法?C# ObservableCollection.ToArray怎么用?C# ObservableCollection.ToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntegerToStatusDetail
private StatusDetail[] IntegerToStatusDetail(int? defaultTypeInt)
{
var detailsForStatusDetails = new ObservableCollection<StatusDetail>();
if (defaultTypeInt == null)
return detailsForStatusDetails.ToArray();
//Split the integers and convert them to the StatusDetail enum
var statusDetailString = defaultTypeInt.ToString().ToCharArray()
.Select(sd => ((StatusDetail)Convert.ToInt32(sd))).ToArray();
foreach (var statusDetail in statusDetailString)
{
if (statusDetail == StatusDetail.CreatedDefault)
detailsForStatusDetails.Add(StatusDetail.CreatedDefault);
if (statusDetail == StatusDetail.RoutedDefault)
detailsForStatusDetails.Add(StatusDetail.RoutedDefault);
if (statusDetail == StatusDetail.CompletedDefault)
detailsForStatusDetails.Add(StatusDetail.CompletedDefault);
}
return detailsForStatusDetails.ToArray();
}
示例2: LogEntryCounter
public LogEntryCounter(ObservableCollection<LogEntryViewModel> entries)
{
this.Entries = entries;
Count = new Observable<LogEntryLevelCount>();
Count.Value = GetCount(Entries.ToArray());
Entries.CollectionChanged += EntriesCollectionChanged;
}
示例3: PlayerListBox
public PlayerListBox()
{
DrawMode = DrawMode.OwnerDrawVariable;
this.BackColor = Color.DimGray;
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
realItems = new ObservableCollection<PlayerListItem>();
realItems.CollectionChanged += RealItemsOnCollectionChanged;
timer = new Timer() { Interval = stagingMs, };
timer.Tick += (sender, args) =>
{
try {
BeginUpdate();
int currentScroll = base.TopIndex;
base.Items.Clear();
base.Items.AddRange(realItems.ToArray());
base.TopIndex = currentScroll;
EndUpdate();
timer.Stop();
} catch (Exception ex) {
Trace.TraceError("Error updating list: {0}",ex);
}
};
IntegralHeight = false; //so that the playerlistBox completely fill the edge (not snap to some item size)
}
示例4: ConvertBack
public object[] ConvertBack(object value, Type[] targetType,
object parameter, CultureInfo culture)
{
if (targetType[0] != typeof(ObservableCollection<string>))
throw new InvalidOperationException(
"The target must be an ObservableCollection<string>");
var list =
new ObservableCollection<string>();
foreach (string s in value.ToString().Split('\r'))
{
string val = s.Replace('\n', ' ');
val = val.Trim();
if (!string.IsNullOrEmpty(val))
{
list.Add(val);
}
}
return list.ToArray();
}
示例5: StationMachinesVM
public StationMachinesVM(StationVM station, AccessType access):base(access)
{
UnitOfWork = new SoheilEdmContext();
CurrentStation = station;
StationDataService = new StationDataService(UnitOfWork);
StationDataService.MachineAdded += OnMachineAdded;
StationDataService.MachineRemoved += OnMachineRemoved;
MachineDataService = new MachineDataService(UnitOfWork);
StationMachineDataService = new StationMachineDataService(UnitOfWork);
MachineFamilyDataService = new MachineFamilyDataService(UnitOfWork);
var selectedVms = new ObservableCollection<StationMachineVM>();
foreach (var stationMachine in StationDataService.GetMachines(station.Id))
{
selectedVms.Add(new StationMachineVM(stationMachine, Access, StationMachineDataService, RelationDirection.Straight));
}
SelectedItems = new ListCollectionView(selectedVms);
var allVms = new ObservableCollection<MachineVM>();
foreach (var machine in MachineDataService.GetActives()
.Where(machine => !selectedVms.Any(stationMachine => stationMachine.MachineId == machine.Id)))
{
allVms.Add(new MachineVM(machine, Access, MachineDataService, MachineFamilyDataService));
}
AllItems = new ListCollectionView(allVms);
IncludeCommand = new Command(Include, CanInclude);
ExcludeCommand = new Command(Exclude, CanExclude);
IncludeAllCommand = new Command(o =>
{
foreach (var vm in allVms.ToArray())
{
StationDataService.AddMachine(CurrentStation.Id, ((IEntityItem)vm).Id);
}
}, () => allVms.Any());
}
示例6: ReflectCollectionChanged
private void ReflectCollectionChanged(NotifyCollectionChangedEventArgs e, ObservableCollection<StatusViewModel> ctl)
{
lock (_collectionLock)
{
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
ctl.Insert(e.NewStartingIndex, GenerateStatusViewModel((StatusModel)e.NewItems[0]));
break;
case NotifyCollectionChangedAction.Move:
ctl.Move(e.OldStartingIndex, e.NewStartingIndex);
break;
case NotifyCollectionChangedAction.Remove:
var removal = ctl[e.OldStartingIndex];
ctl.RemoveAt(e.OldStartingIndex);
removal.Dispose();
break;
case NotifyCollectionChangedAction.Reset:
var cache = ctl.ToArray();
ctl.Clear();
Task.Run(() => cache.ForEach(c => c.Dispose()));
break;
default:
throw new ArgumentException();
}
}
}
示例7: reportVentas
public String[][] reportVentas()
{
ObservableCollection<String[]> strings = new ObservableCollection<String[]>();
int cont = 0;
String[] header = new String[4];
header[0] = "Código";
header[1] = "Cliente";
header[2] = "Fecha";
header[3] = "Total";
strings.Add(header);
MySqlCommand instruccion = connection.CreateCommand();
instruccion.CommandText = "call get_ventas_del_mes()";
MySqlDataReader reader = instruccion.ExecuteReader();
while (reader.Read())
{
String[] ps = new String[4];
ps[0] = reader["CODIGO"].ToString();
ps[1] = reader["NOMBRE_CLIENTE"].ToString();
ps[2] = reader["FECHA"].ToString().Substring(0, 10);
ps[3] = reader["TOTAL"].ToString();
strings.Add(ps);
cont++;
}
reader.Close();
if (cont > 0)
{
return strings.ToArray();
}
return null;
}
示例8: reportTablaProductos
public String[][] reportTablaProductos()
{
var products = from p in _ProductosCollection
select new { Nombre = p.pr_nombre, Codigo = p.pr_codigo, Cantidad = p.pr_cantidad, Fecha = p.pr_caducidad, Precio = p.pr_precio };
ObservableCollection<String[]> strings = new ObservableCollection<String[]>();
int cont = 0;
String[] header = new String[3];
header[0] = "Codigo";
header[1] = "Nombre";
header[2] = "Precio ($)";
strings.Add(header);
foreach (var item in products)
{
String[] ps = new String[3];
ps[0] = item.Codigo.ToString();
ps[1] = item.Nombre.ToString();
ps[2] = item.Precio.ToString("n2");
strings.Add(ps);
cont++;
}
if (cont > 0)
{
return strings.ToArray();
}
return null;
}
示例9: AddStoresToAccount
public void AddStoresToAccount(ObservableCollection<AccountsStoreDetailsSet> storesForAddList)
{
_accountStoresRepository.Add(storesForAddList.ToArray());
}
示例10: SendDocByCompanyid
private void SendDocByCompanyid(string companyid)
{
Dictionary<string, string> dicCompany=new Dictionary<string,string>();
string strSunCompany = @"select c.companyid,c.cname from smthrm.t_hr_company c
where c.fatherid='" + companyid + "'";
OracleHelp.Connect();
DataTable dtsun = OracleHelp.getTable(strSunCompany);
if (dtsun != null)
{
if (dtsun.Rows.Count > 0)
{
for (int i = 0; i < dtsun.Rows.Count; i++)
{
dicCompany.Add(dtsun.Rows[i]["cname"].ToString(), dtsun.Rows[i]["companyid"].ToString());
string strGrandSunCompany = @"select c.companyid,c.cname from smthrm.t_hr_company c
where c.fatherid='" + dtsun.Rows[i]["companyid"].ToString() + "'";
DataTable dtGrandSun = OracleHelp.getTable(strGrandSunCompany);
if (dtGrandSun != null)
{
if (dtGrandSun.Rows.Count > 0)
{
for (int j = 0; j < dtGrandSun.Rows.Count; j++)
{
dicCompany.Add(dtGrandSun.Rows[j]["cname"].ToString(), dtGrandSun.Rows[j]["companyid"].ToString());
}
}
}
}
}
}
OracleHelp.close();
if (string.IsNullOrEmpty(TxtSendDocid.Text))
{
MessageBox.Show("请先查询公文id");
return;
}
string msg = string.Empty;
ObservableCollection<T_OA_DISTRIBUTEUSER> distributeAddList = new ObservableCollection<T_OA_DISTRIBUTEUSER>() ;
SmtOACommonOfficeClient DocDistrbuteClient = new SmtOACommonOfficeClient();
ObservableCollection<string> CompanyIDsList = new ObservableCollection<string>();
ObservableCollection<string> StrDepartmentIDsList = new ObservableCollection<string>(); //获取部门ID
ObservableCollection<string> StrPositionIDsList = new ObservableCollection<string>();
ObservableCollection<string> StrStaffList = new ObservableCollection<string>(); //员工ID
if (dicCompany.Count > 0)
{
foreach (var q in dicCompany)
{
//if (q.Key == "杭州新神州通货物运输有限公司") continue;
ShowMessage("发布公文给这个公司:"+q.Key+" 公司id:"+q.Value);
CompanyIDsList.Add(q.Value);
T_OA_DISTRIBUTEUSER distributeTmp = new T_OA_DISTRIBUTEUSER();
distributeTmp.DISTRIBUTEUSERID = Guid.NewGuid().ToString();
distributeTmp.MODELNAME = "CompanySendDoc";
distributeTmp.FORMID = TxtSendDocid.Text;
distributeTmp.VIEWTYPE = "0";//公司
distributeTmp.VIEWER = q.Value;
distributeTmp.CREATEDATE = DateTime.Now;
distributeTmp.CREATEUSERID =GlobalParameters.employeeid;
distributeTmp.CREATEUSERNAME = GlobalParameters.employeeName;
distributeTmp.CREATEPOSTID = GlobalParameters.employeeMasterPostid;
distributeTmp.CREATEDEPARTMENTID = GlobalParameters.employeeMasterDepartmentid;
distributeTmp.CREATECOMPANYID = GlobalParameters.employeeMasterCompanyid;
distributeTmp.OWNERID =GlobalParameters.employeeid;
distributeTmp.OWNERNAME = GlobalParameters.employeeName;
distributeTmp.OWNERPOSTID = GlobalParameters.employeeMasterPostid;
distributeTmp.OWNERDEPARTMENTID = GlobalParameters.employeeMasterDepartmentid;
distributeTmp.OWNERCOMPANYID = GlobalParameters.employeeMasterCompanyid;
distributeAddList.Add(distributeTmp);
}
ShowMessage("发布公文给所有公司完毕,共发送:" + dicCompany.Count+ " 条数据");
}
V_BumfCompanySendDoc tmpSenddoc=DocDistrbuteClient.GetBumfDocInfo(TxtSendDocid.Text);
if (tmpSenddoc.OACompanySendDoc == null)
{
MessageBox.Show("通过id获取的公文为空,请检查后再试");
return;
}
T_OA_SENDDOC sendDoc = tmpSenddoc.OACompanySendDoc;
sendDoc.T_OA_SENDDOCTYPE = null;
sendDoc.T_OA_SENDDOCTYPEReference = null;
DocDistrbuteClient.BatchAddCompanyDocDistrbuteForNew(distributeAddList.ToArray(), CompanyIDsList.ToArray(), StrDepartmentIDsList.ToArray(), StrPositionIDsList.ToArray(), StrStaffList.ToArray(), sendDoc);
//MessageBox.Show("发布公文成功!");
}
示例11: reportDirectorioClientes
public String[][] reportDirectorioClientes()
{
ObservableCollection<String[]> strings = new ObservableCollection<String[]>();
int cont = 0;
String[] header = new String[4];
header[0] = "Nombre";
header[1] = "RUC";
header[2] = "Teléfono";
header[3] = "Dirección";
strings.Add(header);
MySqlCommand instruccion = connection.CreateCommand();
instruccion.CommandText = "call GET_DIRECTORIO_CLIENTES()";
MySqlDataReader reader = instruccion.ExecuteReader();
while (reader.Read())
{
String[] ps = new String[4];
ps[0] = reader["NOMBRE"].ToString();
ps[1] = reader["RUC"].ToString();
ps[2] = reader["TELEFONO"].ToString();
ps[3] = reader["DIRECCION"].ToString();
strings.Add(ps);
cont++;
}
reader.Close();
if (cont > 0)
{
return strings.ToArray();
}
return null;
}
示例12: reportBodega
public String[][] reportBodega(String ub)
{
ObservableCollection<String[]> strings = new ObservableCollection<String[]>();
int cont = 0;
String[] header = new String[3];
header[0] = "Nombre";
header[1] = "Fecha";
header[2] = "Cantidad";
strings.Add(header);
MySqlCommand instruccion = connection.CreateCommand();
instruccion.CommandText = "call get_unidades_bodega(\'" + ub + "\')";
MySqlDataReader reader = instruccion.ExecuteReader();
while (reader.Read())
{
String[] ps = new String[3];
ps[0] = reader["NOMBRE"].ToString();
ps[1] = reader["FECHA"].ToString().Substring(0,10);
ps[2] = reader["CANTIDAD"].ToString();
strings.Add(ps);
cont++;
}
reader.Close();
if (cont > 0)
{
return strings.ToArray();
}
return null;
}
示例13: UpdateWorks
public void UpdateWorks(ObservableCollection<StoreProvenWorkSet> changedWorkList)
{
_worksRepository.Update(changedWorkList.ToArray());
}
示例14: Rebind
private void Rebind(ObservableCollection<StatusViewModel> ctl)
{
if (TimelineModel == null) return;
System.Diagnostics.Debug.WriteLine("REBIND CORE...");
_isCollectionAddEnabled = false;
var cache = ctl.ToArray();
ctl.Clear();
Task.Run(() => cache.ForEach(c => c.Dispose()));
var collection = TimelineModel.Statuses.ToArray();
_isCollectionAddEnabled = true;
collection
.Select(GenerateStatusViewModel)
.ForEach(ctl.Add);
}
示例15: PreferenceWindow
public PreferenceWindow(TwitterAccountManager mgr, MainWindow mwin)
{
_mwin = mwin;
_mgr = mgr;
InitializeComponent ();
_accounts = mgr.Accounts;
_oldAccounts = (TwitterAccount[])_accounts.Clone ();
_targets = new IStreamingHandler[_accounts.Length];
for (int i = 0; i < _targets.Length; i ++)
_targets[i] = _accounts[i].StreamingClient == null ? null : _accounts[i].StreamingClient.Target;
StreamingTargetSelector selector = new StreamingTargetSelector ();
selector.NullTemplate = (DataTemplate)Resources["nullTemplate"];
selector.HomeTemplate = (DataTemplate)Resources["homeTemplate"];
selector.SearchTemplate = (DataTemplate)Resources["searchTemplate"];
selector.ListTemplate = (DataTemplate)Resources["listTemplate"];
Resources.Add ("targetTemplateSelector", selector);
_observableAccountList = new ObservableCollection<TwitterAccount> (mgr.Accounts);
List<object> list = new List<object> ();
list.Add ("null");
for (int i = 0; i < mgr.Accounts.Length; i ++) list.Add (mgr.Accounts[i]);
for (int i = 0; i < mgr.Searches.Length; i ++) list.Add (mgr.Searches[i]);
for (int i = 0; i < mgr.Lists.Length; i ++) list.Add (mgr.Lists[i]);
_targetList = list.ToArray ();
this.DataContext = _observableAccountList;
this.Closed += delegate (object sender, EventArgs e) {
_accounts = _observableAccountList.ToArray<TwitterAccount> ();
IsAccountArrayChanged = false;
do {
if (_accounts.Length != _oldAccounts.Length) {
IsAccountArrayChanged = true;
break;
}
for (int i = 0; i < _accounts.Length; i++) {
if (_accounts[i] != _oldAccounts[i]) {
IsAccountArrayChanged = true;
break;
}
}
} while (false);
IsStreamingTargetsChanged = IsAccountArrayChanged;
do {
for (int i = 0; i < _accounts.Length; i ++) {
if (_accounts[i].StreamingClient == null && _targets[i] == null)
continue;
if (_accounts[i].StreamingClient != null && _accounts[i].StreamingClient.Target == _targets[i])
continue;
IsStreamingTargetsChanged = true;
break;
}
} while (false);
};
}