本文整理汇总了C#中DataItem类的典型用法代码示例。如果您正苦于以下问题:C# DataItem类的具体用法?C# DataItem怎么用?C# DataItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataItem类属于命名空间,在下文中一共展示了DataItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DownloadFile
public string DownloadFile(DataItem dataItem, Country country, Resolution resolution, DateTime dateTime)
{
var url = BuildFileName(dataItem, country, resolution, dateTime);
var file = DownloadFile(url);
File.WriteAllBytes(SavePath + url, file);
return url;
}
示例2: CollectionChangedReplaceDataItemsResultInCollectionChangedForAdapter
public void CollectionChangedReplaceDataItemsResultInCollectionChangedForAdapter()
{
//create a list of dataItem containing urls
IEventedList<IDataItem> dataItems = new EventedList<IDataItem>();
var oldUrl = new Url();
var newUrl = new Url();
var dataItem = new DataItem(oldUrl);
dataItems.Add(dataItem);
//adapter for the list
var adapter = new DataItemListAdapter<Url>(dataItems);
int callCount = 0;
adapter.CollectionChanged += (sender, e) =>
{
callCount++;
Assert.AreEqual(NotifyCollectionChangedAction.Replace,e.Action);
Assert.AreEqual(adapter, sender);
Assert.AreEqual(newUrl, e.Item);
//discutable but current eventedlist implementation does this
Assert.AreEqual(-1, e.OldIndex);
Assert.AreEqual(0, e.Index);
};
//action! replace one dataitem with another
dataItems[0] = new DataItem(newUrl);
Assert.AreEqual(1, callCount);
}
示例3: HomePageViewModel
public HomePageViewModel()
{
var worldRepository = new WorldDataRepository();
Data = new ObservableCollection<DataItem>();
ItemsSource = new ObservableCollection<CountryItem>();
worldRepository.GetCountries().ContinueWith(list =>
{
Countries = list.Result;
var dataItems = new ObservableCollection<DataItem>();
foreach (var item in Countries)
{
var countryItem = new CountryItem
{
Name = item.Name,
Change = item.Chg1Y,
IsChangePositive = item.IsChangePositive
};
double val = 0.0;
double.TryParse(item.LifeExpectancy, out val);
countryItem.LifeExpectancy = val;
ItemsSource.Add(countryItem);
}
foreach (var region in worldRepository.CountriesByRegion)
{
var dataItem = new DataItem {Label = region.Key, Level = region.Value.Sum(x => x.Level.ToDouble())};
dataItems.Add(dataItem);
}
WorldPopulation = dataItems.Sum(l => l.Level * 1000).ToString("#,##0,,,.B", CultureInfo.InvariantCulture);
LifeExpectancy = ItemsSource.Average(x => x.LifeExpectancy).ToString("00.00", CultureInfo.InvariantCulture);
Data = dataItems;
});
}
示例4: GetData
public void GetData(Action<DataItem, Exception> callback)
{
// Use this to connect to the actual data service
var item = new DataItem("Welcome to MVVM Light");
callback(item, null);
}
示例5: ProcessBytes
public void ProcessBytes(byte[] bytes, int byteSize)
{
Debug.Log("SYNC IN " + dataModel.client.prefab);
try {
MemoryStream memStream = new MemoryStream(bytes, false);
BinaryReader br = new BinaryReader(memStream);
Debug.Log ("PLN: 1" );
var item = new DataItem ();
item.uid = br.ReadInt32 ();
item.position.x = br.ReadSingle();
item.position.y = br.ReadSingle();
item.position.z = br.ReadSingle();
item.velocity.x = br.ReadSingle();
item.velocity.y = br.ReadSingle();
item.velocity.z = br.ReadSingle();
//Debug.Log ("@" + (client== null));
syncLocally(item);
}catch (Exception e){
Debug.Log(e);
}
}
示例6: createByForm
public IDataItem createByForm(IConnection aConnection, IWin32Window aOwner)
{
Connection lConnection = (Connection)aConnection;
DataItem lItem = new DataItem();
bool lCreated = false;
using (var lSetupForm = new ItemSetupForm(lConnection, lItem))
{
do
{
try
{
lSetupForm.ShowDialog(aOwner);
if (lSetupForm.DialogResult == DialogResult.OK)
{
lItem = lConnection.addItem(lSetupForm.Topic, lSetupForm.Subscribe, lSetupForm.Publish, "");
lCreated = true;
}
else
{
lItem = null;
}
}
catch (Exception lExc)
{
Log.Error("Error while user was creating new data item for MQQT broker '"
+ lConnection.mHost + ":" + lConnection.mPort + "'. " + lExc.Message, lExc.ToString());
MessageForm.showMessage(lExc.Message, aOwner);
}
}
while (lSetupForm.DialogResult == DialogResult.OK && lCreated == false);
}
return lItem;
}
示例7: HomePageViewModel
public HomePageViewModel()
{
var worldRepository = new WorldDataRepository();
Data = new ObservableCollection<DataItem>();
ItemsSource = new ObservableCollection<Item>();
worldRepository.GetCountries().ContinueWith((list) =>
{
Countries = list.Result;
var data = new ObservableCollection<DataItem>();
foreach (var item in Countries)
{
ItemsSource.Add(new Item { Name = item.Name, Change = item.Chg1Y, IsChangePositive = item.IsChangePositive});
}
foreach (var region in worldRepository.CountriesByRegion)
{
var dataItem = new DataItem();
dataItem.Label = region.Key;
dataItem.Level = region.Value.Sum(x => x.Level.ToDouble());
data.Add(dataItem);
}
Data = data;
});
}
示例8: GetData
public Task<DataItem> GetData()
{
// Use this to create design time data
var item = new DataItem("Welcome to MVVM Light [design]");
return Task.FromResult(item);
}
示例9: TestSequenceLinkFirstTargetThenSource
public void TestSequenceLinkFirstTargetThenSource()
{
string result = "";
SimplerModel sourceModel = new SimplerModel { Name = "source" };
sourceModel.Executing += (s, e) => result += ((SimplerModel)s).Name;
SimplerModel targetModel = new SimplerModel { Name = "target" };
targetModel.Executing += (s, e) => result += ((SimplerModel)s).Name;
IDataItem sourceInput = new DataItem { Name = "SI", Value = new object(), Role = DataItemRole.Input };
IDataItem sourceOutput = new DataItem { Name = "SO", Value = new object(), Role = DataItemRole.Output };
IDataItem targetInput = new DataItem { Name = "TI", Value = new object(), Role = DataItemRole.Input };
IDataItem targetOutput = new DataItem { Name = "TO", Value = new object(), Role = DataItemRole.Output };
sourceModel.DataItems.Add(sourceInput);
sourceModel.DataItems.Add(sourceOutput);
targetModel.DataItems.Add(targetInput);
targetModel.DataItems.Add(targetOutput);
var compositeModel = new CompositeModel
{
Name = "composite model",
Models = { sourceModel, targetModel }
};
sourceInput.LinkTo(targetOutput);
compositeModel.Initialize();
compositeModel.Execute();
Assert.AreEqual("targetsource", result);
}
示例10: ProcessInput
void ProcessInput()
{
//Debug.Log ("IN");
float dV= 0.25f;
DataItem d;
if(Input.anyKeyDown){
d = dataModel.GetItem(this);
Debug.Log ("PREL-- X:" + d.velocity.x +" Y:"+ d.velocity.y );
if (Input.GetKeyDown (KeyCode.W)){
d.velocity.y += dV;
}else if(Input.GetKeyDown (KeyCode.S)){
d.velocity.y += -dV;
}else if(Input.GetKeyDown (KeyCode.D)){
d.velocity.x += dV;
}else if(Input.GetKeyDown (KeyCode.A)){
d.velocity.x += -dV;
}
Debug.Log ("POST-- X:" + d.velocity.x +" Y:"+ d.velocity.y );
Debug.Log ("PINTPU");
DataItem di = new DataItem();
di.uid = d.uid;
di.position = d.position;
di.velocity = d.velocity;
dataModel.UpdateItem(di);
saveDataToDataModel();
}
}
示例11: InputAreaData
/// <summary>
/// Конструктор.
/// </summary>
/// <param name="aTopicName">Имя топика для OPC-тегов.</param>
/// <param name="aOpcConnection">Соединеие с OPC-сервером.</param>
public InputAreaData(string aTopicName, OpcConnectionHolder aOpcConnection)
{
IdCheckOutputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_CHECK_OUT, aOpcConnection);
IdNumberOutputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_NUMBER_OUT, aOpcConnection);
IdCheckInputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_CHECK_IN, aOpcConnection);
IdNumberInputItem = new DataItem(aTopicName + ITEMID_INPUTAREA_ID_NUMBER_IN, aOpcConnection);
}
示例12: addItem
public void addItem(DataItem di)
{
Debug.Log ("ADDD " + di.uid + client.prefab);
allThings[di.uid] = di;
//uidObjectMap[di.uid] = go;
newItems.Enqueue(di.uid);
}
示例13: ItemsLoaded
private void ItemsLoaded()
{
DataItem root = new DataItem();
root.Text = "Personal Folders";
root.ImageUrl = "../../Images/ContextMenu/Outlook/1PersonalFolders.png";
root.IsExpanded = true;
DataItem deletedItems = new DataItem();
root.Items.Add(deletedItems);
deletedItems.Text = "Deleted Items(6)";
deletedItems.ImageUrl = "../../Images/ContextMenu/Outlook/2DeletedItems.png";
DataItem inbox = new DataItem();
root.Items.Add(inbox);
inbox.Text = "Inbox(14)";
inbox.ImageUrl = "../../Images/ContextMenu/Outlook/4Inbox.png";
DataItem folders = new DataItem();
inbox.Items.Add(folders);
folders.Text = "Folders";
folders.ImageUrl = "../../Images/ContextMenu/Outlook/folder.png";
DataItem junkEmails = new DataItem();
root.Items.Add(junkEmails);
junkEmails.Text = "Junk E-mails";
junkEmails.ImageUrl = "../../Images/ContextMenu/Outlook/junk.png";
DataItem outbox = new DataItem();
root.Items.Add(outbox);
outbox.Text = "Outbox";
outbox.ImageUrl = "../../Images/ContextMenu/Outlook/outbox.png";
DataItem sentItems = new DataItem();
root.Items.Add(sentItems);
sentItems.Text = "Sent Items";
sentItems.ImageUrl = "../../Images/ContextMenu/Outlook/sent.png";
DataItem search = new DataItem();
root.Items.Add(search);
search.Text = "Search Folder";
search.ImageUrl = "../../Images/ContextMenu/Outlook/searchFolder.png";
DataItem followup = new DataItem();
search.Items.Add(followup);
followup.Text = "From Follow up";
followup.ImageUrl = "../../Images/ContextMenu/Outlook/folder.png";
DataItem largeMail = new DataItem();
search.Items.Add(largeMail);
largeMail.Text = "Large Mail";
largeMail.ImageUrl = "../../Images/ContextMenu/Outlook/search.png";
DataItem unreadMail = new DataItem();
search.Items.Add(unreadMail);
unreadMail.Text = "Unread Mail";
unreadMail.ImageUrl = "../../Images/ContextMenu/Outlook/search.png";
this.Items.Add(root);
}
示例14: OutputAreaData
/// <summary>
/// Конструктор.
/// </summary>
/// <param name="aTopicName">Имя топика.</param>
/// <param name="aOpcConnection">Соединение с OPC-сервером.</param>
public OutputAreaData(string aTopicName, OpcConnectionHolder aOpcConnection)
{
IdCheckOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_CHECK_OUT, aOpcConnection);
IdNumberOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_NUMBER_OUT, aOpcConnection);
IdCheckInputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_CHECK_IN, aOpcConnection);
IdNumberInputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_ID_NUMBER_IN, aOpcConnection);
WeightOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_WEIGHT_OUT, aOpcConnection);
LengthOutputItem = new DataItem(aTopicName + ITEMID_OUTPUTAREA_LENGTH_OUT, aOpcConnection);
}
示例15: GetFristCol
public Stock GetFristCol(string data)
{
List<Price> prices = new List<Price>();
List<DataItem> items = new List<DataItem>();
string firstCol = string.Empty;
List<string> lines = data.Split('\n').ToList<string>();
for (int i = 2; i < lines.Count; i++)
{
string line = lines[i];
List<string> numStrs = line.Split(' ').ToList<string>();
if (numStrs.Count < 5)
continue;
DataItem item = new DataItem();
Price price = new Price();
price.content = new string[4];
for (int numI = 0; numI < numStrs.Count; numI++)
{
if (numI == 0)
item.content = numStrs[numI];
if (numI > 0 && numI < 5)
{
price.content[numI-1] = numStrs[numI];
if (numI == 3)
{
price.content[numI-1] = numStrs[numI+1];
}
if (numI == 4)
{
price.content[numI - 1] = numStrs[numI-1];
}
}
// if (numI > 0 && numI < 4)
//price.content += ",";
}
items.Add(item);
prices.Add(price);
}
Stock stock = new Stock();
stock.price = new Price[prices.Count];
for (int itemI = 0; itemI < items.Count; itemI++)
{
stock.data += items[itemI].content;
if (itemI != items.Count - 1)
stock.data += ",";
}
for (int priceI = 0; priceI < prices.Count; priceI++)
{
stock.price[priceI] = prices[priceI]; // += "[" + prices[priceI].content + "]";
//if (priceI != prices.Count - 2)
// stock.price += ";";
}
// stock.data = "[" + stock.data + "]";
// stock.price = "[" + stock.price + "]";
return stock;
}