예제 #1
0
        public override void ViewDidLoad()
        {
            login.Enabled = false;
            //Console.WriteLine(PingHost("10.0.5.18"));
            if (PingHost("10.0.5.18") == true)
            {
                base.ViewDidLoad();
                //var feidepass = password.StringValue;
                NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, Enter);
            }
            else
            {
                var alert = new NSAlert();
                alert.MessageText     = "Feil!";
                alert.AlertStyle      = NSAlertStyle.Critical;
                alert.InformativeText = "Får ingen tilkobling til NFK.";
                alert.RunModal();
                base.ViewDidLoad();
            }
            progressBar.StartAnimation(new NSObject());
            var urlgit = "https://github.com/danielmb/MAC-Uniflow/raw/master/Uniflowprinterinstaller/Resources/CNADVC5045X1.PPD.gz";

            WebClient Client = new WebClient();


            Client.DownloadProgressChanged += Client_DownloadProgressChanged;
            Client.DownloadFileAsync(new System.Uri(urlgit), System.IO.Path.GetTempPath() + "CNADVC5045X1.PPD.gz");     // Kan endres eller fjernes


            username.SelectText(new NSObject());
        }
예제 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            NSCursor.Hide();

            // Do any additional setup after loading the view.
            NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, (theEvent) =>
            {
                this.KeyDown(theEvent);
                return(null);
            });

            MainTimer          = new Timer(1000);
            MainTimer.Elapsed += (sender, e) =>
            {
                TimeLeft--;
                // Format the remaining time nicely for the label
                TimeSpan time       = TimeSpan.FromSeconds(TimeLeft);
                string   timeString = time.ToString(@"mm\:ss");
                InvokeOnMainThread(() =>
                {
                    //We want to interact with the UI from a different thread,
                    // so we must invoke this change on the main thread

                    timerLevel.DoubleValue = (1.0) * (15 * 60 - TimeLeft);
                });
            };
            MainTimer.Start();
        }
 /// <inheritdoc/>
 public void BeginEdit()
 {
     DebugOutput("!$!$!$!$ BEGIN EDIT");
     LiveValue = InitialValue;
     if (KeyMonitor == null)
     {
         DebugOutput("  !$!$!$!$ INSTALLED KEY MONITOR");
         KeyMonitor = NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, LocalKeyEventHandler);
     }
     if (EditingStartedObserver == null)
     {
         DebugOutput("  !$!$!$!$ INSTALLED EDITING STARTED OBSERVER");
         EditingStartedObserver = NSNotificationCenter.DefaultCenter.AddObserver(NSControlTextDidBeginEditingNotification, CellTextEditStarted);
     }
     if (EditingTextChanged == null)
     {
         DebugOutput("  !$!$!$!$ INSTALLED TEXT CHANGED OBSERVER");
         EditingTextChanged = NSNotificationCenter.DefaultCenter.AddObserver(NSControlTextDidChangeNotification, CellTextChanged);
     }
     if (EditingEndedObserver == null)
     {
         DebugOutput("  !$!$!$!$ INSTALLED EDITING ENDED OBSERVER");
         EditingEndedObserver = NSNotificationCenter.DefaultCenter.AddObserver(NSControlTextDidEndEditingNotification, CellTextEditEnded);
     }
 }
 public AdministratorView(IntPtr handle) : base(handle)
 {
     baseHandler     = new BaseHandler(this);
     adminHandler    = new AdminHandler(this);
     segueName       = "";
     segueType       = "";
     segueLocation   = "";
     segueHours      = "";
     segueList       = "";
     segueAvailable  = "";
     segueMaxNumber  = "";
     segueFName      = "";
     segueLName      = "";
     segueCity       = "";
     segueAddress    = "";
     segueState      = "";
     segueCountry    = "";
     wasActivityName = false;
     wasActivity     = false;
     timer           = new Timer(10);
     timer.Enabled   = true;
     timer.Start();
     timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, KeyboardEventHandler);
 }
예제 #5
0
        public AppDelegate()
        {
            var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;
            var rect  = new CoreGraphics.CGRect(200, 200, 1024, 768);

            mainWindow                 = new NSWindow(rect, style, NSBackingStore.Buffered, false);
            mainWindow.Title           = "Mission Planner on Mac!";
            mainWindow.TitleVisibility = NSWindowTitleVisibility.Hidden;
            mainWindow.DidResize      += MainWindow_DidResize;
            mainWindow.WillClose      += MainWindow_WillClose;
            NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, KeyboardEventHandler);

            Test.BlueToothDevice = new BTDevice();
            Test.UsbDevices      = new USBDevices();
            Test.Radio           = new Radio();
            Test.GPS             = new GPS();
            Test.SystemInfo      = new SystemInfo();
            Test.Speech          = new OSXSpeech();

            WinForms.OSX = true;

            Acr.UserDialogs.Infrastructure.Log.Out += (s, s1, arg3) =>
            {
                Console.WriteLine(s + ": " + s1);
            };

            new System.Drawing.android.android();
        }
예제 #6
0
        public static void Initialize(IScheduler dispatcher)
        {
            Keyboard.Implementation.GiveFocusTo = (control) => Command.Disabled;

            Keyboard.Implementation.Pressed = (self, modifier, key) =>
                                              Fusion.Application.MainThread
                                              .InvokeAsync(() => self.NativeHandle)
                                              .ToObservable()
                                              .OfType <IObservableResponder>()
                                              .Select(view => view.KeyDown).Switch()
                                              .Where(evt => evt.CharactersIgnoringModifiers == key.ToKeyEquivalent() &&
                                                     evt.ModifierFlags.HasFlag(modifier.ToNSEventModifierMask()))
                                              .Select(c => Unit.Default);

            Keyboard.Implementation.Released = (self, modifier, key) =>
                                               Fusion.Application.MainThread
                                               .InvokeAsync(() => self.NativeHandle)
                                               .ToObservable()
                                               .OfType <IObservableResponder>()
                                               .Select(view => view.KeyUp).Switch()
                                               .Where(evt => evt.CharactersIgnoringModifiers == key.ToKeyEquivalent() &&
                                                      evt.ModifierFlags.HasFlag(modifier.ToNSEventModifierMask()))
                                               .Select(c => Unit.Default);

            Keyboard.Implementation.GlobalPressed = (self, modifier, key) =>
            {
                var keyDown = new Subject <NSEvent>();

                NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown,
                                                             evt =>
                {
                    keyDown.OnNext(evt);
                    return(evt);
                });

                return(keyDown
                       .Where(evt => evt.CharactersIgnoringModifiers == key.ToKeyEquivalent() &&
                              evt.ModifierFlags.HasFlag(modifier.ToNSEventModifierMask()))
                       .Select(c => Unit.Default));
            };

            Keyboard.Implementation.GlobalReleased = (self, modifier, key) =>
            {
                var keyUp = new Subject <NSEvent>();

                NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyUp,
                                                             evt =>
                {
                    keyUp.OnNext(evt);
                    return(evt);
                });

                return(keyUp
                       .Where(evt => evt.CharactersIgnoringModifiers == key.ToKeyEquivalent() &&
                              evt.ModifierFlags.HasFlag(modifier.ToNSEventModifierMask()))
                       .Select(c => Unit.Default));
            };
        }
예제 #7
0
 public override void DidFinishLaunching(NSNotification notification)
 {
     // Insert code here to initialize your application
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, (theEvent) =>
     {
         Console.WriteLine(theEvent);
         return(theEvent);
     });
 }
예제 #8
0
 public override void DidFinishLaunching(NSNotification notification)
 {
     // Insert code here to initialize your application
     Forms.Init();
     LoadApplication(new App());
     base.DidFinishLaunching(notification);
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, KeyboardDownEventHandler);
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyUp, KeyboardUpEventHandler);
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.FlagsChanged, KeyboardFlagsEventHandler);
 }
예제 #9
0
        void StartMouseMonitoring()
        {
            StopMouseMonitoring();

            clickMonitor = NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.MouseMoved, (NSEvent theEvent) => {
                var currentX = theEvent.LocationInWindow.X - (Window.Frame.Width / 2);
                var currentY = theEvent.LocationInWindow.Y - (Window.Frame.Height / 2);
                Window.SetFrame(new CoreGraphics.CGRect(currentX, currentY, Window.Frame.Width, Window.Frame.Height), true);
                return(theEvent);
            });
        }
예제 #10
0
        public void StartHoverSelection(IWindowWrapper currentWindow)
        {
            StopHoverSelection();

            var nativeWindow = currentWindow.NativeObject as NSWindow;

            endSelection = false;

            clickMonitor = NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.LeftMouseDown, (NSEvent theEvent) => {
                StopHoverSelection();
                var selected = GetHoverSelectedView();
                if (selected != null)
                {
                    HoverSelectionEnded?.Invoke(this, new ViewWrapper(selected));
                }
                else
                {
                    HoverSelectionEnded?.Invoke(this, null);
                }

                return(null);
            });

            moveMonitor = NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.MouseMoved, (NSEvent theEvent) => {
                if (endSelection)
                {
                    return(null);
                }
                var point = nativeWindow.ConvertBaseToScreen(theEvent.LocationInWindow);
                if (!nativeWindow.AccessibilityFrame.Contains(point))
                {
                    return(null);
                }
                containerViews.Clear();
                AddContainerViews(nativeWindow.ContentView, point, containerViews);

                if (containerViews.Count > 0)
                {
                    index = containerViews.Count - 1;
                }
                else
                {
                    index = -1;
                }

                var selectedView = GetHoverSelectedView();
                if (selectedView != null)
                {
                    HoverSelecting?.Invoke(this, new ViewWrapper(selectedView));
                }
                return(null);
            });
        }
예제 #11
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            // Insert code here to initialize your application
            NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, e =>
            {
                if (e.KeyCode == 36 || e.KeyCode == 76)
                {
                    Console.WriteLine("Return");
                }

                return(e);
            });
        }
예제 #12
0
        public NativeDragView()
        {
            WantsLayer            = true;
            Layer.BackgroundColor = NSColor.SystemBlueColor.CGColor;

            field = new NSTextField
            {
                StringValue     = "Click Me to Focus or Drag in Blue Rect",
                Alignment       = NSTextAlignment.Center,
                Font            = NSFont.UserFixedPitchFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Regular)),
                Bordered        = true,
                BezelStyle      = NSTextFieldBezelStyle.Square,
                DrawsBackground = true,
                BackgroundColor = NSColor.TextBackground,
                TextColor       = NSColor.ControlText,
                Editable        = false
            };

            AddSubview(field);

            field.TranslatesAutoresizingMaskIntoConstraints = false;
            field.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, Padding).Active    = true;
            field.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -Padding).Active = true;
            field.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active             = true;

            NSEvent.AddLocalMonitorForEventsMatchingMask(
                NSEventMask.LeftMouseDragged | NSEventMask.LeftMouseUp,
                e =>
            {
                switch (e.Type)
                {
                case NSEventType.LeftMouseDragged when isDragging:
                    MouseDragged(e);
                    return(null);

                case NSEventType.LeftMouseUp:
                    isDragging = false;
                    break;
                }

                return(e);
            });
        }
예제 #13
0
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            xamarinPage = e.NewElement as Saplin.CPDT.UICore.MainPage;
            NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, KeyboardEventHandler);

            NSApplication.Notifications.ObserveWillTerminate(
                (s, eargs) =>
            {
                xamarinPage?.CloseAplication();
            }
                );

            NSWindow.Notifications.ObserveWillClose(
                (s, eargs) =>
            {
                //xamarinPage?.CloseAplication();
            }
                );
        }
예제 #14
0
 public UserView(IntPtr handle) : base(handle)
 {
     baseHandler      = new BaseHandler(this);
     this.userHandler = new UserHandler(this);
     segueName        = "";
     segueType        = "";
     segueLocation    = "";
     segueHours       = "";
     segueList        = "";
     wasActivityName  = false;
     timer2           = new Timer(10);
     timer2.Enabled   = true;
     timer2.Start();
     timer2.Elapsed += new ElapsedEventHandler(OnTimedEvent2);
     timer           = new Timer(10);
     timer.Enabled   = true;
     timer.Start();
     timer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
     NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, KeyboardEventHandler);
 }
예제 #15
0
        private void StartMonitoring()
        {
            globalEventMonitor = NSEvent.AddGlobalMonitorForEventsMatchingMask(
                NSEventMask.MouseMoved,
                (theEvent) => PrintMouseLocation("Global", theEvent.LocationInWindow));

            localEventMonitor = NSEvent.AddLocalMonitorForEventsMatchingMask(
                NSEventMask.MouseMoved,
                (theEvent) =>
            {
                CGPoint p;
                if (theEvent.Window != null)
                {
                    var rect = theEvent.Window.ConvertRectToScreen(new CGRect(theEvent.LocationInWindow, new CGSize(0, 0)));
                    p        = rect.Location;
                }
                else
                {
                    p = theEvent.LocationInWindow;
                }
                PrintMouseLocation("Local", p);
                return(theEvent);
            });
        }
예제 #16
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; } });
        }