当前位置: 首页>>代码示例>>C#>>正文


C# Id.CastTo方法代码示例

本文整理汇总了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;
        }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:7,代码来源:Controller.cs

示例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;
        }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:43,代码来源:Controller.cs

示例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;
        }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:7,代码来源:Controller.cs

示例4: OutlineViewObjectValueForTableColumnByItem

 public Id OutlineViewObjectValueForTableColumnByItem(NSOutlineView outlineView, NSTableColumn tableColumn, Id item)
 {
     PDFOutline outline = item.CastTo<PDFOutline>();
     return outline.Label;
 }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:5,代码来源:MyPDFDocument.cs

示例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;
     }
 }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:18,代码来源:MyPDFDocument.cs

示例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);
     }
 }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:18,代码来源:MyPDFDocument.cs

示例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();
     }
 }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:18,代码来源:MyPDFDocument.cs

示例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);
        }
开发者ID:Monobjc,项目名称:monobjc-samples,代码行数:11,代码来源:MyWindowController.cs


注:本文中的Id.CastTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。