示例#1
0
        static void Main(string[] args)
        {
            #region Generazione e popolamento menu
            Menu menu = new Menu();
            menu.ListOfToppingsAvailableInMenu = new List <ITopping>();

            GenericTopping gT = new GenericTopping("toppingDProva", "X", 0.56f);
            menu.AddToppingToMenu((ITopping)gT);

            Cocoa       cocoa  = new Cocoa();
            CocoaPowder powder = new CocoaPowder();
            Milk        milk   = new Milk();
            MilkFoam    foam   = new MilkFoam();

            menu.AddToppingToMenu(cocoa);
            menu.AddToppingsToMenu(cocoa, powder, milk, foam);
            #endregion

            foreach (ITopping topping in menu.ListOfToppingsAvailableInMenu.Where((topping) => topping.Price > 0.10f))
            {
                Console.Write($"{topping.Code}\t");
                Console.Write($"{topping.Price:0.00}\t");
                Console.Write($"{topping.Name}\n");
            }
            Console.ReadLine();
            //Test con la lambda/delegate ... fallito miseramente ...
            //DlgMetod provaScrittura(sondaLambda())
            //sondaLambda(txt);
        }
示例#2
0
        protected override void Dispose(bool disposing)
        {
            if (IsDisposed || Handle.Handle == IntPtr.Zero)
            {
                return;
            }

            Debug.Print("Disposing of Cocoa context.");

            if (!NSApplication.IsUIThread)
            {
                return;
            }

            if (IsCurrent)
            {
                Cocoa.SendVoid(NSOpenGLContext, Selector.Get("clearCurrentContext"));
            }
            Cocoa.SendVoid(Handle.Handle, Selector.Get("clearDrawable"));
            Cocoa.SendVoid(Handle.Handle, Selector.Get("release"));

            Handle = ContextHandle.Zero;

            IsDisposed = true;
        }
        public MacPlatformService()
        {
            if (initedGlobal)
            {
                throw new Exception("Only one MacPlatformService instance allowed");
            }
            initedGlobal = true;

            timer.BeginTiming();

            systemVersion = Carbon.Gestalt("sysv");

            mimemap = new Lazy <Dictionary <string, string> > (LoadMimeMapAsync);

            //make sure the menu app name is correct even when running Mono 2.6 preview, or not running from the .app
            Carbon.SetProcessName(BrandingService.ApplicationName);

            Cocoa.InitMonoMac();

            CheckGtkVersion(2, 24, 14);

            timer.Trace("Installing App Event Handlers");
            GlobalSetup();

            timer.EndTiming();
        }
示例#4
0
        private void scrollWheel(IntPtr receiver, IntPtr selector, IntPtr theEvent)
        {
            bool hasPrecise = Cocoa.SendBool(theEvent, sel_respondstoselector_, sel_hasprecisescrollingdeltas) &&
                              Cocoa.SendBool(theEvent, sel_hasprecisescrollingdeltas);

            if (!hasPrecise)
            {
                // calls the unswizzled [SDLView scrollWheel:(NSEvent *)] method if this is a regular scroll wheel event
                // the receiver may sometimes not be SDLView, ensure it has a scroll wheel selector implemented before attempting to call.
                if (Cocoa.SendBool(receiver, sel_respondstoselector_, originalScrollWheel))
                {
                    Cocoa.SendVoid(receiver, originalScrollWheel, theEvent);
                }

                return;
            }

            // according to osuTK, 0.1f is the scaling factor expected to be returned by CGEventSourceGetPixelsPerLine
            // this is additionally scaled down by a factor of 8 so that a precise scroll of 1.0 is roughly equivalent to one notch on a traditional scroll wheel.
            const float scale_factor = 0.1f / 8;

            float scrollingDeltaX = Cocoa.SendFloat(theEvent, sel_scrollingdeltax);
            float scrollingDeltaY = Cocoa.SendFloat(theEvent, sel_scrollingdeltay);

            ScheduleEvent(() => TriggerMouseWheel(new Vector2(scrollingDeltaX * scale_factor, scrollingDeltaY * scale_factor), true));
        }
示例#5
0
        protected void OnUpdateFrame(object sender, FrameEventArgs e)
        {
            // update the window mode if we have an update queued
            WindowMode?mode = pendingWindowMode;

            if (mode.HasValue)
            {
                pendingWindowMode = null;

                bool currentFullScreen = styleMask.HasFlag(NSWindowStyleMask.FullScreen);
                bool toggleFullScreen  = mode.Value == Configuration.WindowMode.Fullscreen ? !currentFullScreen : currentFullScreen;

                if (toggleFullScreen)
                {
                    Cocoa.SendVoid(WindowInfo.Handle, selToggleFullScreen, IntPtr.Zero);
                }
                else if (currentFullScreen)
                {
                    NSApplication.PresentationOptions = fullscreenPresentationOptions;
                }
                else if (isCursorHidden)
                {
                    NSApplication.PresentationOptions = NSApplicationPresentationOptions.DisableCursorLocationAssistance;
                }

                WindowMode.Value = mode.Value;
            }

            // If the cursor should be hidden, but something in the system has made it appear (such as a notification),
            // invalidate the cursor rects to hide it.  osuTK has a private function that does this.
            if (isCursorHidden && Cocoa.CGCursorIsVisible() && !menuBarVisible)
            {
                methodInvalidateCursorRects.Invoke(nativeWindow, new object[0]);
            }
        }
示例#6
0
        private unsafe int GetContextValue(NSOpenGLContextParameter par)
        {
            int  ret;
            int *p = &ret;

            Cocoa.SendVoid(Handle.Handle, Selector.Get("getValues:forParameter:"), (IntPtr)p, (int)par);
            return(ret);
        }
示例#7
0
        private NSPoint _getMousePointBeforeTranslation()
        {
            var nsEvent = Cocoa.objc_getClass("NSEvent");
            var point   = Cocoa.SendPoint(nsEvent, Selector.Get("mouseLocation"));

            CF.CFRelease(nsEvent);
            return(point);
        }
示例#8
0
        public void CocoaNameTest()
        {
            CoffeeMachine coffee_machine = new Cocoa();
            string        expected       = "Какао";
            string        actual;

            actual = coffee_machine.Name;
            Assert.AreEqual(expected, actual);
        }
示例#9
0
        public void CocoaCostTest()
        {
            CoffeeMachine coffee_machine = new Cocoa();
            int           expected       = 35;
            int           actual;

            actual = coffee_machine.GetCost();
            Assert.AreEqual(expected, actual);
        }
 private void refreshCursorState(object sender, OpenTK.FrameEventArgs e)
 {
     // If the cursor should be hidden, but something in the system has made it appear (such as a notification),
     // invalidate the cursor rects to hide it.  OpenTK has a private function that does this.
     if (CursorState.HasFlag(CursorState.Hidden) && Cocoa.CGCursorIsVisible())
     {
         methodInvalidateCursorRects.Invoke(nativeWindow, new object[0]);
     }
 }
示例#11
0
 public override void MakeCurrent(IWindowInfo window)
 {
     if (window == null)
     {
         Cocoa.SendVoid(NSOpenGLContext, selClearCurrentContext);
     }
     else
     {
         Cocoa.SendVoid(Handle.Handle, selMakeCurrentContext);
     }
 }
示例#12
0
        public CocoaContext(ContextHandle handle, IWindowInfo window, IGraphicsContext shareContext, int majorVersion, int minorVersion)
        {
            if (handle == ContextHandle.Zero)
            {
                throw new ArgumentException("handle");
            }
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            Handle      = handle;
            cocoaWindow = (CocoaWindowInfo)window;
            Cocoa.SendVoid(cocoaWindow.ViewHandle, Selector.Get("setAutoresizingMask:"), (uint)(MonoMac.AppKit.NSViewResizingMask.HeightSizable | MonoMac.AppKit.NSViewResizingMask.WidthSizable));
        }
示例#13
0
        public override List <Display> GetDisplays()
        {
            //I strongly suspect this is going to be broken for multiple monitors due to the way
            //cocoa treats the coordiante system.
            //a second monitor above the current would be given positive coords, rather than the negative coords i'm expecting.
            //solution is... -1 *

            var screens    = Cocoa.SendIntPtr(Cocoa.objc_getClass("NSScreen"), Selector.Get("screens"));
            var primary    = Cocoa.SendIntPtr(screens, Selector.Get("objectAtIndex:"), 0);
            var screenRect = Cocoa.SendRect(primary, Selector.Get("frame"));

            return(new List <Display> {
                new Display(screenRect.X, -1 * screenRect.Y, screenRect.Width, screenRect.Height)
            });
        }
示例#14
0
        public override string GetText()
        {
            NSArray classArray = NSArray.ArrayWithObject(Class.Get("NSString"));

            if (GeneralPasteboard.CanReadObjectForClasses(classArray, null))
            {
                var result  = GeneralPasteboard.ReadObjectsForClasses(classArray, null);
                var objects = result?.ToArray() ?? new IntPtr[0];
                if (objects.Length > 0 && objects[0] != IntPtr.Zero)
                {
                    return(Cocoa.FromNSString(objects[0]));
                }
            }
            return(string.Empty);
        }
示例#15
0
        public override void SetClipboard(string value)
        {
            //grab pasteboard
            var pasteBoard = Cocoa.SendIntPtr(Cocoa.objc_getClass("NSPasteboard"), Selector.Get("generalPasteboard"));

            //clear it
            Cocoa.SendInt(pasteBoard, Selector.Get("clearContents"));


            var data = Cocoa.ToNSString(value);

            var arr = Cocoa.SendIntPtr(Cocoa.objc_getClass("NSArray"), Selector.Get("arrayWithObjects:"), data, IntPtr.Zero);


            //send contents
            Cocoa.SendVoid(pasteBoard, Selector.Get("writeObjects:"), arr);
        }
示例#16
0
        private NSPoint _getMousePoint()
        {
            //NSEvent treats coordinates as starting in bottom left.
            //We apply a transform to make them match our windows counterpart.
            var point = _getMousePointBeforeTranslation();

            var screenRect =
                Cocoa.SendRect(
                    Cocoa.SendIntPtr(
                        Cocoa.SendIntPtr(Cocoa.objc_getClass("NSScreen"), Selector.Get("screens")),
                        Selector.Get("objectAtIndex:"), 0),
                    Selector.Get("frame"));

            point.Y = screenRect.Height - point.Y;

            return(point);
        }
示例#17
0
        void Dispose(bool disposing)
        {
            if (IsDisposed || Handle.Handle == IntPtr.Zero)
            {
                return;
            }

            Debug.Print("Disposing of Cocoa context.");

            Cocoa.SendVoid(NSOpenGLContext, Selector.Get("clearCurrentContext"));
            Cocoa.SendVoid(Handle.Handle, Selector.Get("clearDrawable"));
            Cocoa.SendVoid(Handle.Handle, Selector.Get("release"));

            Handle = ContextHandle.Zero;

            IsDisposed = true;
        }
示例#18
0
        public override void Update(IWindowInfo window)
        {
            var cocoaWindow = (CocoaWindowInfo)window;

            if (Width > 0 && Height > 0)
            {
                GLib.Idle.Add(new GLib.IdleHandler(() =>
                {
                    var previous = MonoMac.AppKit.NSApplication.CheckForIllegalCrossThreadCalls;
                    MonoMac.AppKit.NSApplication.CheckForIllegalCrossThreadCalls = false;
                    var view = new MonoMac.AppKit.NSView(cocoaWindow.ViewHandle);
                    view.SetFrameSize(new MonoMac.CoreGraphics.CGSize(Width, Height));
                    MonoMac.AppKit.NSApplication.CheckForIllegalCrossThreadCalls = previous;
                    return(false);
                }));
            }
            Cocoa.SendVoid(Handle.Handle, selUpdate);
        }
示例#19
0
        private GraphicsMode GetGraphicsMode(IntPtr context)
        {
            IntPtr cgl_context = Cocoa.SendIntPtr(context, Selector.Get("CGLContextObj"));
            IntPtr cgl_format  = Cgl.GetPixelFormat(cgl_context);

            int  id = 0; // CGL does not support the concept of a pixel format id
            int  color, depth, stencil, samples, accum;
            bool doublebuffer, stereo;

            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatInt.ColorSize, out color);
            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatInt.DepthSize, out depth);
            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatInt.StencilSize, out stencil);
            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatInt.Samples, out samples);
            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatInt.AccumSize, out accum);
            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatBool.Doublebuffer, out doublebuffer);
            Cgl.DescribePixelFormat(cgl_format, 0, Cgl.PixelFormatBool.Stereo, out stereo);

            return(new GraphicsMode((IntPtr)id, color, depth, stencil, samples, accum, doublebuffer ? 2 : 1, stereo));
        }
示例#20
0
        static string GetFontPath(string fontName, FontStyles styles)
        {
            string path = null;
            //Create NSAutoreleasePool
            var autoreleasePool = Cocoa.SendIntPtr(Class.NSAutoreleasePool, Selector.Alloc);

            autoreleasePool = Cocoa.SendIntPtr(autoreleasePool, Selector.Init);
            //Create Font Attributes
            var nsDictionary = Cocoa.SendIntPtr(Class.NSMutableDictionary, Selector.Alloc);

            nsDictionary = Cocoa.SendIntPtr(nsDictionary, Selector.Init);
            Cocoa.SendVoid(nsDictionary, Selector.SetObjectForKey, Cocoa.ToNSString(fontName), CoreText.kCTFontFamilyNameAttribute);
            uint symbolicTraits = 0;

            if ((styles & FontStyles.Bold) == FontStyles.Bold)
            {
                symbolicTraits |= (uint)CTFontSymbolicTraits.Bold;
            }
            if ((styles & FontStyles.Italic) == FontStyles.Italic)
            {
                symbolicTraits |= (uint)CTFontSymbolicTraits.Italic;
            }
            if (symbolicTraits != 0)
            {
                //Put traits in dictionary
                var traitDictionary = Cocoa.SendIntPtr(Class.NSMutableDictionary, Selector.Alloc);
                traitDictionary = Cocoa.SendIntPtr(traitDictionary, Selector.Init);
                var num = Cocoa.SendIntPtr(Class.NSNumber, Selector.Alloc);
                num = Cocoa.SendIntPtr(num, Selector.InitWithUnsignedInt, symbolicTraits);
                Cocoa.SendVoid(traitDictionary, Selector.SetObjectForKey, num, CoreText.kCTFontSymbolicTrait);
                //Set traits
                Cocoa.SendVoid(nsDictionary, Selector.SetObjectForKey, traitDictionary, CoreText.kCTFontTraitsAttribute);
            }
            var desc   = CoreText.CTFontDescriptorCreateWithAttributes(nsDictionary);
            var urlref = CoreText.CTFontDescriptorCopyAttribute(desc, CoreText.kCTFontURLAttribute);

            path = Cocoa.FromNSString(Cocoa.SendIntPtr(urlref, Selector.Path));
            //Delete NSAutoreleasePool
            CoreText.CFRelease(desc);
            Cocoa.SendVoid(autoreleasePool, Selector.Release);
            return(path);
        }
示例#21
0
        /// <summary>
        /// Swizzled replacement of [SDLView scrollWheel:(NSEvent *)] that checks for precise scrolling deltas.
        /// </summary>
        private void scrollWheel(IntPtr receiver, IntPtr selector, IntPtr theEvent)
        {
            var hasPrecise = Cocoa.SendBool(theEvent, sel_respondstoselector_, sel_hasprecisescrollingdeltas) &&
                             Cocoa.SendBool(theEvent, sel_hasprecisescrollingdeltas);

            if (!hasPrecise)
            {
                // calls the unswizzled [SDLView scrollWheel:(NSEvent *)] method if this is a regular scroll wheel event
                Cocoa.SendVoid(receiver, originalScrollWheel, theEvent);
                return;
            }

            // according to osuTK, 0.1f is the scaling factor expected to be returned by CGEventSourceGetPixelsPerLine
            const float scale_factor = 0.1f;

            float scrollingDeltaX = Cocoa.SendFloat(theEvent, sel_scrollingdeltax);
            float scrollingDeltaY = Cocoa.SendFloat(theEvent, sel_scrollingdeltay);

            ScheduleEvent(() => OnMouseWheel(new Vector2(scrollingDeltaX * scale_factor, scrollingDeltaY * scale_factor), true));
        }
示例#22
0
        private void CreateContext(GraphicsMode mode, CocoaWindowInfo cocoaWindow, IntPtr shareContextRef, int majorVersion, int minorVersion, bool fullscreen)
        {
            // Prepare attributes
            IntPtr pixelFormat = SelectPixelFormat(mode, majorVersion, minorVersion);

            if (pixelFormat == IntPtr.Zero)
            {
                throw new GraphicsException(String.Format(
                                                "Failed to contruct NSOpenGLPixelFormat for GraphicsMode '{0}'",
                                                mode));
            }

            // Create context
            var context = Cocoa.SendIntPtr(NSOpenGLContext, Selector.Alloc);

            context = Cocoa.SendIntPtr(context, Selector.Get("initWithFormat:shareContext:"), pixelFormat, shareContextRef);
            if (context == IntPtr.Zero)
            {
                throw new GraphicsException(String.Format(
                                                "Failed to construct NSOpenGLContext",
                                                mode));
            }

            // Release pixel format
            Cocoa.SendVoid(pixelFormat, Selector.Release);
            pixelFormat = IntPtr.Zero;

            // Attach the view
            Cocoa.SendVoid(context, Selector.Get("setView:"), cocoaWindow.ViewHandle);
            Cocoa.SendVoid(cocoaWindow.ViewHandle, Selector.Get("setWantsBestResolutionOpenGLSurface:"), true);

            // Finalize
            Handle = new ContextHandle(context);
            Mode   = GetGraphicsMode(context);

            Cocoa.SendVoid(cocoaWindow.ViewHandle, Selector.Get("setAutoresizingMask:"), (uint)(MonoMac.AppKit.NSViewResizingMask.HeightSizable | MonoMac.AppKit.NSViewResizingMask.WidthSizable));

            Update(cocoaWindow);
        }
 public override void SetText(string selectedText)
 {
     generalPasteboard.ClearContents();
     generalPasteboard.WriteObjects(NSArray.ArrayWithObject(Cocoa.ToNSString(selectedText)));
 }
        private void flagsChanged(IntPtr self, IntPtr cmd, IntPtr sender)
        {
            var modifierFlags = (CocoaKeyModifiers)Cocoa.SendInt(sender, selModifierFlags);
            var keyCode       = Cocoa.SendInt(sender, selKeyCode);

            bool keyDown;

            OpenTK.Input.Key key;

            switch ((MacOSKeyCodes)keyCode)
            {
            case MacOSKeyCodes.LShift:
                key     = OpenTK.Input.Key.LShift;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftShift);
                break;

            case MacOSKeyCodes.RShift:
                key     = OpenTK.Input.Key.RShift;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightShift);
                break;

            case MacOSKeyCodes.LControl:
                key     = OpenTK.Input.Key.LControl;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftControl);
                break;

            case MacOSKeyCodes.RControl:
                key     = OpenTK.Input.Key.RControl;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightControl);
                break;

            case MacOSKeyCodes.LAlt:
                key     = OpenTK.Input.Key.LAlt;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftAlt);
                break;

            case MacOSKeyCodes.RAlt:
                key     = OpenTK.Input.Key.RAlt;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightAlt);
                break;

            case MacOSKeyCodes.LCommand:
                key     = OpenTK.Input.Key.LWin;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftCommand);
                break;

            case MacOSKeyCodes.RCommand:
                key     = OpenTK.Input.Key.RWin;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightCommand);
                break;

            default:
                return;
            }

            if (keyDown)
            {
                methodKeyDown.Invoke(nativeWindow, new object[] { key, false });
            }
            else
            {
                methodKeyUp.Invoke(nativeWindow, new object[] { key });
            }
        }
示例#25
0
        public static Block GetBlockById(byte blockId)
        {
            Block block = null;

            if (CustomBlockFactory != null)
            {
                block = CustomBlockFactory.GetBlockById(blockId);
            }

            if (block != null) return block;

            if (blockId == 0) block = new Air();
            else if (blockId == 1) block = new Stone();
            else if (blockId == 2) block = new Grass();
            else if (blockId == 3) block = new Dirt();
            else if (blockId == 4) block = new Cobblestone();
            else if (blockId == 5) block = new Planks();
            else if (blockId == 6) block = new Sapling();
            else if (blockId == 7) block = new Bedrock();
            else if (blockId == 8) block = new FlowingWater();
            else if (blockId == 9) block = new StationaryWater();
            else if (blockId == 10) block = new FlowingLava();
            else if (blockId == 11) block = new StationaryLava();
            else if (blockId == 12) block = new Sand();
            else if (blockId == 13) block = new Gravel();
            else if (blockId == 14) block = new GoldOre();
            else if (blockId == 15) block = new IronOre();
            else if (blockId == 16) block = new CoalOre();
            else if (blockId == 17) block = new Log();
            else if (blockId == 18) block = new Leaves();
            else if (blockId == 19) block = new Sponge();
            else if (blockId == 20) block = new Glass();
            else if (blockId == 21) block = new LapisOre();
            else if (blockId == 22) block = new LapisBlock();
            else if (blockId == 23) block = new Dispenser();
            else if (blockId == 24) block = new Sandstone();
            else if (blockId == 25) block = new NoteBlock();
            else if (blockId == 26) block = new Bed();
            else if (blockId == 27) block = new GoldenRail();
            else if (blockId == 28) block = new DetectorRail();
            else if (blockId == 30) block = new Cobweb();
            else if (blockId == 31) block = new TallGrass();
            else if (blockId == 32) block = new DeadBush();
            else if (blockId == 35) block = new Wool();
            else if (blockId == 37) block = new YellowFlower();
            else if (blockId == 38) block = new Flower();
            else if (blockId == 39) block = new BrownMushroom();
            else if (blockId == 40) block = new RedMushroom();
            else if (blockId == 41) block = new GoldBlock();
            else if (blockId == 42) block = new IronBlock();
            else if (blockId == 43) block = new DoubleStoneSlab();
            else if (blockId == 44) block = new StoneSlab();
            else if (blockId == 45) block = new Bricks();
            else if (blockId == 46) block = new Tnt();
            else if (blockId == 47) block = new Bookshelf();
            else if (blockId == 48) block = new MossStone();
            else if (blockId == 49) block = new Obsidian();
            else if (blockId == 50) block = new Torch();
            else if (blockId == 51) block = new Fire();
            else if (blockId == 52) block = new MonsterSpawner();
            else if (blockId == 53) block = new OakWoodStairs();
            else if (blockId == 54) block = new Chest();
            else if (blockId == 55) block = new RedstoneWire();
            else if (blockId == 56) block = new DiamondOre();
            else if (blockId == 57) block = new DiamondBlock();
            else if (blockId == 58) block = new CraftingTable();
            else if (blockId == 59) block = new Wheat();
            else if (blockId == 60) block = new Farmland();
            else if (blockId == 61) block = new Furnace();
            else if (blockId == 62) block = new LitFurnace();
            else if (blockId == 63) block = new StandingSign();
            else if (blockId == 64) block = new WoodenDoor();
            else if (blockId == 65) block = new Ladder();
            else if (blockId == 66) block = new Rail();
            else if (blockId == 67) block = new CobblestoneStairs();
            else if (blockId == 68) block = new WallSign();
            else if (blockId == 69) block = new Lever();
            else if (blockId == 70) block = new StonePressurePlate();
            else if (blockId == 71) block = new IronDoor();
            else if (blockId == 72) block = new WoodenPressurePlate();
            else if (blockId == 73) block = new RedstoneOre();
            else if (blockId == 74) block = new LitRedstoneOre();
            else if (blockId == 75) block = new UnlitRedstoneTorch();
            else if (blockId == 76) block = new RedstoneTorch();
            else if (blockId == 77) block = new StoneButton();
            else if (blockId == 78) block = new SnowLayer();
            else if (blockId == 79) block = new Ice();
            else if (blockId == 80) block = new Snow();
            else if (blockId == 81) block = new Cactus();
            else if (blockId == 82) block = new Clay();
            else if (blockId == 83) block = new Reeds();
            else if (blockId == 85) block = new Fence();
            else if (blockId == 86) block = new Pumpkin();
            else if (blockId == 87) block = new Netherrack();
            else if (blockId == 88) block = new SoulSand();
            else if (blockId == 89) block = new Glowstone();
            else if (blockId == 90) block = new Portal();
            else if (blockId == 91) block = new LitPumpkin();
            else if (blockId == 92) block = new Cake();
            else if (blockId == 93) block = new UnpoweredRepeater();
            else if (blockId == 94) block = new PoweredRepeater();
            else if (blockId == 95) block = new InvisibleBedrock();
            else if (blockId == 96) block = new Trapdoor();
            else if (blockId == 97) block = new MonsterEgg();
            else if (blockId == 98) block = new StoneBrick();
            else if (blockId == 99) block = new BrownMushroomBlock();
            else if (blockId == 100) block = new RedMushroomBlock();
            else if (blockId == 101) block = new IronBars();
            else if (blockId == 102) block = new GlassPane();
            else if (blockId == 103) block = new Melon();
            else if (blockId == 106) block = new Vine();
            else if (blockId == 107) block = new FenceGate();
            else if (blockId == 108) block = new BrickStairs();
            else if (blockId == 109) block = new StoneBrickStairs();
            else if (blockId == 110) block = new Mycelium();
            else if (blockId == 111) block = new Waterlily();
            else if (blockId == 112) block = new NetherBrick();
            else if (blockId == 113) block = new NetherBrickFence();
            else if (blockId == 114) block = new NetherBrickStairs();
            else if (blockId == 115) block = new NetherWart();
            else if (blockId == 116) block = new EnchantingTable();
            else if (blockId == 117) block = new BrewingStand();
            else if (blockId == 120) block = new EndPortalFrame();
            else if (blockId == 121) block = new EndStone();
            else if (blockId == 122) block = new LitRedstoneLamp();
            else if (blockId == 123) block = new RedstoneLamp();
            else if (blockId == 126) block = new ActivatorRail();
            else if (blockId == 127) block = new Cocoa();
            else if (blockId == 128) block = new SandStoneStairs();
            else if (blockId == 129) block = new EmeraldOre();
            else if (blockId == 131) block = new TripwireHook();
            else if (blockId == 132) block = new Tripwire();
            else if (blockId == 133) block = new EmeraldBlock();
            else if (blockId == 134) block = new SpruceWoodStairs();
            else if (blockId == 135) block = new BirchWoodStairs();
            else if (blockId == 136) block = new JungleWoodStairs();
            else if (blockId == 139) block = new CobblestoneWall();
            else if (blockId == 140) block = new FlowerPot();
            else if (blockId == 141) block = new Carrots();
            else if (blockId == 142) block = new Potatoes();
            else if (blockId == 143) block = new WoodenButton();
            else if (blockId == 144) block = new Skull();
            else if (blockId == 145) block = new Anvil();
            else if (blockId == 146) block = new TrappedChest();
            else if (blockId == 147) block = new LightWeightedPressurePlate();
            else if (blockId == 148) block = new HeavyWeightedPressurePlate();
            else if (blockId == 151) block = new DaylightDetector();
            else if (blockId == 152) block = new RedstoneBlock();
            else if (blockId == 153) block = new QuartzOre();
            else if (blockId == 155) block = new QuartzBlock();
            else if (blockId == 156) block = new QuartzStairs();
            else if (blockId == 157) block = new DoubleWoodSlab();
            else if (blockId == 158) block = new WoodSlab();
            else if (blockId == 159) block = new StainedHardenedClay();
            else if (blockId == 161) block = new AcaciaLeaves();
            else if (blockId == 162) block = new AcaciaLog();
            else if (blockId == 163) block = new AcaciaStairs();
            else if (blockId == 164) block = new DarkOakStairs();
            else if (blockId == 167) block = new IronTrapdoor();
            else if (blockId == 170) block = new HayBlock();
            else if (blockId == 171) block = new Carpet();
            else if (blockId == 172) block = new HardenedClay();
            else if (blockId == 173) block = new CoalBlock();
            else if (blockId == 174) block = new PackedIce();
            else if (blockId == 175) block = new Sunflower();
            else if (blockId == 178) block = new DaylightDetectorInverted();
            else if (blockId == 183) block = new SpruceFenceGate();
            else if (blockId == 184) block = new BirchFenceGate();
            else if (blockId == 185) block = new JungleFenceGate();
            else if (blockId == 186) block = new DarkOakFenceGate();
            else if (blockId == 187) block = new AcaciaFenceGate();
            else if (blockId == 198) block = new GrassPath();
            else if (blockId == 199) block = new ItemFrame();
            else if (blockId == 243) block = new Podzol();
            else if (blockId == 244) block = new Beetroot();
            else if (blockId == 245) block = new Stonecutter();
            else if (blockId == 246) block = new GlowingObsidian();
            else if (blockId == 247) block = new NetherReactorCore();
            else
            {
                //				Log.DebugFormat(@"
                //	// Add this missing block to the BlockFactory
                //	else if (blockId == {1}) block = new {0}();
                //
                //	public class {0} : Block
                //	{{
                //		internal {0}() : base({1})
                //		{{
                //		}}
                //	}}
                //", "Missing", blockId);
                block = new Block(blockId);
            }

            return block;
        }
示例#26
0
 public MacPlatform()
 {
     Cocoa.Initialize();
     helvetica = GetFontPath("Helvetica", FontStyles.Regular);
 }
示例#27
0
 static CocoaContext()
 {
     Cocoa.Initialize();
 }
示例#28
0
        private void flagsChanged(IntPtr self, IntPtr cmd, IntPtr sender)
        {
            var modifierFlags = (CocoaKeyModifiers)Cocoa.SendInt(sender, selModifierFlags);
            var keyCode       = Cocoa.SendInt(sender, selKeyCode);

            bool keyDown;

            osuTK.Input.Key key;

            switch ((MacOSKeyCodes)keyCode)
            {
            case MacOSKeyCodes.LShift:
                key     = osuTK.Input.Key.LShift;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftShift);
                break;

            case MacOSKeyCodes.RShift:
                key     = osuTK.Input.Key.RShift;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightShift);
                break;

            case MacOSKeyCodes.LControl:
                key     = osuTK.Input.Key.LControl;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftControl);
                break;

            case MacOSKeyCodes.RControl:
                key     = osuTK.Input.Key.RControl;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightControl);
                break;

            case MacOSKeyCodes.LAlt:
                key     = osuTK.Input.Key.LAlt;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftAlt);
                break;

            case MacOSKeyCodes.RAlt:
                key     = osuTK.Input.Key.RAlt;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightAlt);
                break;

            case MacOSKeyCodes.LCommand:
                key     = osuTK.Input.Key.LWin;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.LeftCommand);
                break;

            case MacOSKeyCodes.RCommand:
                key     = osuTK.Input.Key.RWin;
                keyDown = modifierFlags.HasFlag(CocoaKeyModifiers.RightCommand);
                break;

            default:
                return;
            }

            if (keyDown)
            {
                actionKeyDown(key, false);
            }
            else
            {
                actionKeyUp(key);
            }
        }
示例#29
0
 public override void MakeCurrent(IWindowInfo window)
 {
     Cocoa.SendVoid(Handle.Handle, selMakeCurrentContext);
 }
示例#30
0
        private unsafe void SetContextValue(int val, NSOpenGLContextParameter par)
        {
            int *p = &val;

            Cocoa.SendVoid(Handle.Handle, Selector.Get("setValues:forParameter:"), (IntPtr)p, (int)par);
        }
示例#31
0
 public override void Update(IWindowInfo window)
 {
     Cocoa.SendVoid(Handle.Handle, selUpdate);
 }