本文整理汇总了C#中Id.CastTo方法的典型用法代码示例。如果您正苦于以下问题:C# Id.CastTo方法的具体用法?C# Id.CastTo怎么用?C# Id.CastTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Id
的用法示例。
在下文中一共展示了Id.CastTo方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeTranslateY
partial void ChangeTranslateY(Id sender)
{
NSStepper stepper = sender.CastTo<NSStepper>();
float value = this.TranslateY + stepper.FloatValue;
this.TranslateY = value;
stepper.FloatValue = 0.0f;
}
示例2: ChangeFontStyle
partial void ChangeFontStyle(Id sender)
{
NSFont theFont;
int itemIndex;
// If the sender is an NSMenuItem then this is the menuFormRepresentation. Otherwise, we're being called from
// the NSPopUpButton. We need to check this to find out how to calculate the index of the picked menu item.
if (FoundationFramework.NSStringFromClass(sender.Class).IsEqualToString("NSMenuItem"))
{
NSMenuItem item = sender.CastTo<NSMenuItem>();
itemIndex = item.Menu.IndexOfItem(item) - 1; // for ordinary NSMenus, the title is item #0, so we have to offset things
}
else
{
NSPopUpButton button = sender.CastTo<NSPopUpButton>();
itemIndex = button.IndexOfSelectedItem; // this is an NSPopUpButton, so the first useful item really is #0
}
this.fontSizeField.TakeIntValueFrom(this.fontSizeStepper);
theFont = this.contentView.Font;
// set the font properties depending upon what was selected
if (itemIndex == 0)
{
theFont = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(theFont, NSFontTraitMask.NSItalicFontMask);
theFont = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(theFont, NSFontTraitMask.NSBoldFontMask);
}
else if (itemIndex == 1)
{
theFont = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(theFont, NSFontTraitMask.NSItalicFontMask);
theFont = NSFontManager.SharedFontManager.ConvertFontToHaveTrait(theFont, NSFontTraitMask.NSBoldFontMask);
}
else if (itemIndex == 2)
{
theFont = NSFontManager.SharedFontManager.ConvertFontToHaveTrait(theFont, NSFontTraitMask.NSItalicFontMask);
theFont = NSFontManager.SharedFontManager.ConvertFontToNotHaveTrait(theFont, NSFontTraitMask.NSBoldFontMask);
}
// make sure the fontStylePicked variable matches the menu selection plus 1, which also matches
// the menu item tags in the menuFormRepresentation (see the menu in Interface Builder), so
// that -validateMenuItem: can do its work.
this.fontStylePicked = itemIndex + 1;
this.contentView.Font = theFont;
}
示例3: ChangeScaleX
partial void ChangeScaleX(Id sender)
{
NSStepper stepper = sender.CastTo<NSStepper>();
float value = this.ScaleX + stepper.FloatValue;
this.ScaleX = value;
stepper.FloatValue = 0.0f;
}
示例4: OutlineViewObjectValueForTableColumnByItem
public Id OutlineViewObjectValueForTableColumnByItem(NSOutlineView outlineView, NSTableColumn tableColumn, Id item)
{
PDFOutline outline = item.CastTo<PDFOutline>();
return outline.Label;
}
示例5: OutlineViewNumberOfChildrenOfItem
public NSInteger OutlineViewNumberOfChildrenOfItem(NSOutlineView outlineView, Id item)
{
if (item == null)
{
if (this._outline != null)
{
return (int) this._outline.NumberOfChildren;
}
else
{
return 0;
}
}
else
{
return item.CastTo<PDFOutline>().NumberOfChildren;
}
}
示例6: OutlineViewIsItemExpandable
public bool OutlineViewIsItemExpandable(NSOutlineView outlineView, Id item)
{
if (item == null)
{
if (this._outline != null)
{
return (this._outline.NumberOfChildren > 0);
}
else
{
return false;
}
}
else
{
return (item.CastTo<PDFOutline>().NumberOfChildren > 0);
}
}
示例7: OutlineViewChildOfItem
public Id OutlineViewChildOfItem(NSOutlineView outlineView, NSInteger index, Id item)
{
if (item == null)
{
if (this._outline != null)
{
return this._outline.ChildAtIndex(index).Retain();
}
else
{
return null;
}
}
else
{
return item.CastTo<PDFOutline>().ChildAtIndex((uint) index).Retain();
}
}
示例8: ShowPopoverAction
partial void ShowPopoverAction(Id sender)
{
NSView view = sender.CastTo<NSView> ();
this.CreatePopover ();
// configure the preferred position of the popover
NSRectEdge prefEdge = (NSRectEdge)(int)this.popoverPosition.SelectedRow;
this.myPopover.ShowRelativeToRectOfViewPreferredEdge (view.Bounds, view, prefEdge);
}