public App(CustomTextEditorDelegate customTextEditorDelegate) { // FolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)); FolderPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); KGui.Register(new XMGui(customTextEditorDelegate)); DocListPage.docs = Tutorial.Groups(); MainTabbedPage.theMainTabbedPage = new MainTabbedPage(); MainTabbedPage.theMainTabbedPage.CurrentPageChanged += MainTabbedPage.currentPageChangedDelegate; theApp = this; MainPage = MainTabbedPage.theMainTabbedPage; MainTabbedPage.SwitchToTab(MainTabbedPage.theDocListPageNavigation); }
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; } }); }
// ON LOAD private void GuiToWin_Load(object sender, EventArgs e) { this.texter = new PlatformTexter(); fonts = new Dictionary <float, Font>(); fontsFixed = new Dictionary <float, Font>(); // Register this Gui for platform-independent access via interface KGuiControl KGui.Register(this); // Register this Gui for platform-independent access via interface KControls winControls = new WinControls(); // set up platform-specific gui controls KGui.Register(new KControls(winControls)); // bind actions to them (non-platform specific) and register them throug KGui txtInput.MouseClick += (object ms, MouseEventArgs me) => { KGui.kControls.CloseOpenMenu(); }; txtOutput.MouseClick += (object ms, MouseEventArgs me) => { KGui.kControls.CloseOpenMenu(); }; panel1.MouseDown += (object ms, MouseEventArgs me) => { Title_MouseDown(ms, me); KGui.kControls.CloseOpenMenu(); }; panel1.MouseUp += (object ms, MouseEventArgs me) => { Title_MouseUp(ms, me); }; panel1.MouseMove += (object ms, MouseEventArgs me) => { Title_MouseMove(ms, me); }; panel2.MouseDown += (object ms, MouseEventArgs me) => { Title_MouseDown(ms, me); KGui.kControls.CloseOpenMenu(); }; panel2.MouseUp += (object ms, MouseEventArgs me) => { Title_MouseUp(ms, me); }; panel2.MouseMove += (object ms, MouseEventArgs me) => { Title_MouseMove(ms, me); }; panel_Splash.MouseClick += (object ms, MouseEventArgs me) => { KGui.kControls.CloseOpenMenu(); }; this.KeyPreview = true; // used to detect shift key down //AutoScaleMode and AutoScaleDimensions are set in the GUI editor this.Width = Math.Min(this.Width, Screen.PrimaryScreen.Bounds.Size.Width); this.Height = Math.Min(this.Height, Screen.PrimaryScreen.Bounds.Size.Height); this.CenterToScreen(); this.BackColor = WinControls.cMainButtonDeselected; this.panel1.BackColor = WinControls.cMainButtonDeselected; this.panel2.BackColor = WinControls.cMainButtonDeselected; this.splitContainer_Columns.BackColor = WinControls.cMainButtonDeselected; // Splash screen this.panel_Splash.Location = this.panel_KChart.Location; this.panel_Splash.Size = this.panel_KChart.Size; this.panel_Splash.BringToFront(); this.panel_Splash.Visible = true; // Text WinControls.SetTextFont(WinControls.currentFontSize, true); WinControls.SetEditable(true); // Device this.panel_Microfluidics.Controls.Add(new DeviceSKControl()); this.panel_Microfluidics.BackColor = Extensions.ToDrawingColor(KDeviceHandler.deviceBackColor); // KChart this.panel_KChart.Controls.Add(new KChartSKControl()); this.panel_KChart.BackColor = Color.White; // KScore this.panel_KScore.Controls.Add(new KScoreSKControl()); this.panel_KScore.BackColor = Color.White; // Saved state winControls.RestorePreferences(); // needs winControls initialized GuiRestoreInput(); }