本文整理汇总了C#中System.Item.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Item.Equals方法的具体用法?C# Item.Equals怎么用?C# Item.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.Equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestTwoItemsWithSameItemIdAreEqual
public void TestTwoItemsWithSameItemIdAreEqual()
{
var item1 = new Item(2009, new TimeSpan(10000));
var item2 = new Item(2009, TimeSpan.Zero);
Assert.IsTrue(item1.Equals(item2));
Assert.IsTrue(item2.Equals(item1));
// one of the gurantees of equals
Assert.IsFalse(item1.Equals(null));
Assert.AreNotSame(item1, item2);
}
示例2: IsTomboy
bool IsTomboy(Item item)
{
return item.Equals (Do.Platform.Services.UniverseFactory.MaybeApplicationItemFromCommand ("tomboy"));
}
示例3: DrawItem
private void DrawItem(Graphics g,Item item,Bar bar,bool hot,bool pressed)
{
SolidBrush textBrush = new SolidBrush(hot ? m_ViewStyle.BarItemHotTextColor : m_ViewStyle.BarItemTextColor);
if(hot || item.Equals(m_StuckenItem)){
Rectangle iRect = new Rectangle(item.Bounds.Location,item.Bounds.Size);
ItemsStyle itemStyle = bar.ItemsStyle;
//--- If must use default item style ---------//
//--- First load from ViewStyle
if(bar.ItemsStyle == ItemsStyle.UseDefault){
itemStyle = m_ViewStyle.BarItemsStyle;
}
//--- If ViewStyle retuned UseDefault, set IconSelect as default
if(itemStyle == ItemsStyle.UseDefault){
itemStyle = ItemsStyle.IconSelect;
}
//-------------------------------------------//
//--- If item style is IconSelect
if(itemStyle == ItemsStyle.IconSelect){
iRect = new Rectangle(((this.Width-32)/2)-1,item.Bounds.Y+2,34,34);
}
//------- Draw item -----------------------------------------------------------//
//--- if not stucken(selected) item
if(!item.Equals(m_StuckenItem)){
if(pressed){
g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemPressedColor),iRect);
}
else{
g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemHotColor),iRect);
}
}
else{ //---- If stucken(selected) item
g.FillRectangle(new SolidBrush(m_ViewStyle.BarItemSelectedColor),iRect);
textBrush = new SolidBrush(m_ViewStyle.BarItemSelectedTextColor);
}
// Draw border
g.DrawRectangle(new Pen(m_ViewStyle.BarItemBorderHotColor),iRect);
//----------------------------------------------------------------------------//
}
else{
//this.Invalidate(new Rectangle(item.Bounds.X,item.Bounds.Y,item.Bounds.Width+1,item.Bounds.Height+1));
//g.FillRectangle(new SolidBrush(m_ViewStyle.BarClientAreaColor1),item.Bounds.X,item.Bounds.Y,item.Bounds.Width+1,item.Bounds.Height+1);
}
//---- Draw image ---------------------------//
Rectangle imgRect = new Rectangle((this.Width-32)/2,item.Bounds.Y+4,32,32);
if(item.ImageIndex > -1 && this.ImageList != null && item.ImageIndex < this.ImageList.Images.Count){
g.DrawImage((Image)ImageList.Images[item.ImageIndex],imgRect);
}
//--------------------------------------------//
//---- Draw items text ---------------------------------------------------------------//
Rectangle txtRect = new Rectangle(item.Bounds.X+2,imgRect.Bottom+3,item.Bounds.Width,item.Bounds.Bottom - imgRect.Bottom + 3);
g.DrawString(item.Caption,bar.ItemsFont,textBrush,txtRect,bar.ItemsStringFormat);
//-------------------------------------------------------------------------------------//
}
示例4: IsSkype
public static bool IsSkype(Item item)
{
return item.Equals (Services.UniverseFactory.MaybeApplicationItemFromCommand ("skype"));
}
示例5: addItem
/// <summary>
/// Adds a given number of the given Item type to this Inventory
/// </summary>
/// <param name="type">The Item type to add</param>
/// <param name="quantity">The number of items to add</param>
public void addItem(Item type, int quantity)
{
if (quantity < 0 || type.Equals(Item.Nothing))
return; //bad arguments
if (this.items[(int)type] == 0)
{
this.order[numTypes++] = (int)type;
}
this.items[(int)type] += quantity;
total += quantity;
// push event
InventoryEventArgs args = new InventoryEventArgs();
args.type = type;
args.quantity = quantity;
pushEvent(args);
}
示例6: removeItem
/// <summary>
/// Removes a given number of the given item type from this Inventory
/// </summary>
/// <param name="type">The Item type to remove</param>
/// <param name="quantity">The number of items to remove</param>
public void removeItem(Item type, int quantity)
{
if (quantity < 0 || type.Equals(Item.Nothing))
return; //bad arguments
if (this.items[(int)type] <= quantity)
{
int i = 0;
for (; order[i] != (int)type; i++) ;
Array.Copy(order, i + 1, order, i, numTypes - 1 - i);
order[numTypes - 1] = -1;
numTypes--; // O(n) operation
quantity = this.items[(int)type]; //remove all items of this type
}
this.items[(int)type] -= quantity;
this.total -= quantity;
// push event
InventoryEventArgs args = new InventoryEventArgs();
args.type = type;
args.quantity = -quantity;
pushEvent(args);
}
示例7: IsVinagre
bool IsVinagre(Item item)
{
return item.Equals (Do.Platform.Services.UniverseFactory.MaybeApplicationItemFromCommand ("vinagre"));
}
示例8: Unlink
/// <summary>
/// Remove association between two items
/// </summary>
/// <param name="item">source item</param>
/// <param name="name">attribute name (verb in terms of associative database model)</param>
/// <param name="target">target item</param>
/// <returns>true if association between this two items exists, false otherwise</returns>
public bool Unlink(Item item, String name, Item target)
{
checkIfActive();
checkIfNotInverseLink(name);
int id;
if (!db.name2id.TryGetValue(name, out id))
{
return false;
}
if (item.relations != null)
{
int offs = item.stringFields.Length + item.numericFields.Length;
int l = offs, n = item.fieldIds.Length, r = n;
while (l < r)
{
int m = (l + r) >> 1;
if (item.fieldIds[m] < id)
{
l = m + 1;
}
else
{
r = m;
}
}
while (r < n && item.fieldIds[r] == id)
{
if (target.Equals(item.relations.GetRaw(r - offs)))
{
item.relations.Remove(r - offs);
item.fieldIds = Arrays.Remove(item.fieldIds, r);
modify(item);
removeLink(item, target, id);
return true;
}
r += 1;
}
}
else
{
if (db.root.relations.Unlink(new Key(((long)item.Oid << 32) | (uint)id), target))
{
removeLink(item, target, id);
item.fieldNames = null;
return true;
}
}
return false;
}
示例9: removeLink
void removeLink(Item source, Item target, int id)
{
Index index = (Index)db.storage.GetObjectByOID(id);
index.Remove(new Key(target), source);
if (target.relations != null)
{
int[] fieldIds = target.fieldIds;
int nFields = fieldIds.Length;
int nDeleted = 0;
for (int i = target.stringFields.Length + target.numericFields.Length, j = 0; i < nFields; i++)
{
if (!source.Equals(target.relations.GetRaw(j)))
{
target.fieldIds[i - nDeleted] = fieldIds[i];
j += 1;
}
else
{
index = (Index)db.storage.GetObjectByOID(fieldIds[i]);
index.Remove(new Key(source), target);
target.relations.Remove(j);
nDeleted += 1;
}
}
if (nDeleted > 0)
{
fieldIds = new int[nFields -= nDeleted];
Array.Copy(target.fieldIds, 0, fieldIds, 0, nFields);
target.fieldIds = fieldIds;
modify(target);
}
}
else
{
String name = db.id2name[id];
int inverseId = db.name2id[name.StartsWith("-") ? name.Substring(1) : ("-" + name)];
index = (Index)db.storage.GetObjectByOID(inverseId);
index.Remove(new Key(source), target);
target.fieldNames = null;
db.root.relations.Remove(new Key(((long)target.Oid << 32) | (uint)inverseId), source);
}
}
示例10: IsTelepathy
public static bool IsTelepathy(Item item)
{
return item.Equals (Do.Platform.Services.UniverseFactory.MaybeApplicationItemFromCommand ("empathy"));
}
示例11: IsPidgin
public static bool IsPidgin(Item item)
{
return item.Equals (Do.Platform.Services.UniverseFactory.MaybeApplicationItemFromCommand ("pidgin"));
}