Ejemplo n.º 1
0
 private static NSDeviceView deviceControl = null;  // The only NSDeviceView, same as "this", but accessible from static methods
                                                    // CURRENTLY UNUSED
 private void Initialize()
 {
     this.WantsLayer = true;
     this.LayerContentsRedrawPolicy = NSViewLayerContentsRedrawPolicy.OnSetNeedsDisplay;
     deviceControl = this;
     //KChartHandler.Register(deviceControl);  // Add registration if we want to add KTouchable interface for charts
 }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.nsForm = NSObject.FromObject(this);

            this.texter = new PlatformTexter();
            fonts       = new Dictionary <float, NSFont>();
            fontsFixed  = new Dictionary <float, NSFont>();

            // Register this Gui for platform-independent access via interface KGuiControl
            KGui.Register(this);

            // Register this Gui for platform-independent access via interface KControls
            macControls = new MacControls();                        // set up platform-specific gui controls
            KGui.Register(new KControls(macControls));              // bind actions to them (non-platform specific)

            leftPanelClicker.Activated  += (object sender, EventArgs e) => { KGui.kControls.CloseOpenMenu(); };
            rightPanelClicker.Activated += (object sender, EventArgs e) => { KGui.kControls.CloseOpenMenu(); };

            // Text Areas

            inputTextView.alwaysDisableIBeamCursor              = false; // disable only when menus are up
            outputTextView.alwaysDisableIBeamCursor             = true;
            (textInput.DocumentView as AppKit.NSTextView).Font  = GetFont(12.0F, true);
            (textOutput.DocumentView as AppKit.NSTextView).Font = GetFont(12.0F, true);

            // Device

            { NSBox x = deviceBox; NSDeviceView y = kaemikaDevice; }  // just checking: these are the Outlets from Main.storyboard through XCode

            // Score

            { NSBox x = scoreBox; NSScoreView y = kaemikaScore; }  // just checking: these are the Outlets from Main.storyboard through XCode

            // Chart

            { NSChartView x = kaemikaChart; } // just checking: this is the Outlet from Main.storyboard through XCode

            SetChartTooltip("", new CGPoint(0, 0), new CGRect(0, 0, 0, 0));

            // Legend

            { NSBox x = legendFlyoutBox; NSGridView y = legendFlyoutMenu; } // just checking: these are the Outlets from Main.storyboard through XCode

            // Saved state

            macControls.RestorePreferences(); //needs kControls initialized
            GuiRestoreInput();

            // Dark Mode Detection

            var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle");

            MacControls.darkMode = interfaceStyle == "Dark";
            MacControls.SwitchMode();

            NSDistributedNotificationCenter.GetDefaultCenter().
            AddObserver(this,
                        new ObjCRuntime.Selector("themeChanged:"),
                        new NSString("AppleInterfaceThemeChangedNotification"),
                        null);

            // Keyboard Events
            // https://stackoverflow.com/questions/32446978/swift-capture-keydown-from-nsviewcontroller
            // list of keycodes:
            // https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes

            // for modifier keys
            NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.FlagsChanged,
                                                         (NSEvent e) => { try { if (MyModifiersChanged(e))
                                                                                {
                                                                                    return(null);
                                                                                }
                                                                                else
                                                                                {
                                                                                    return(e);
                                                                                } } catch { return(e); } });
            // for normal, unmodified, keys
            //NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown,
            //    (NSEvent e) => { try { if (MyKeyDown(e)) return null; else return e; } catch { return e; } });
        }