Example #1
0
        public void JPushSetAlias(string aliasName)
        {
            ObjCRuntime.Selector sel = new ObjCRuntime.Selector("tagsAliasCallback");
            NSObject             obj = new NSObject();

            JPUSHService.SetAlias(aliasName, sel, obj);
        }
Example #2
0
        public void FocusSearchBar()
        {
            var entry = searchEntry;

            if (!IsSearchEntryInOverflow)
            {
                entry.SelectText(entry);
            }
            else
            {
                // NSSearchField -> NSToolbarItemViewer -> _NSToolbarClipView -> NSToolbarView -> NSToolbarClippedItemsIndicator
                var clipItem = (NSButton)searchEntry.Superview.Superview.Superview.Subviews [1];
                var sel      = new ObjCRuntime.Selector("_computeMenuForClippedItemsIfNeeded");
                if (!clipItem.RespondsToSelector(sel))
                {
                    throw new Exception("Cocoa selector changed for clipped items menu.");
                }

                clipItem.PerformSelector(sel);
                var menu       = clipItem.Menu;
                var searchItem = menu.ItemAt(0);
                var searchView = (SearchBar)searchItem.View;
                AttachToolbarEvents(searchView);
                menu.PopUpMenu(menu.ItemAt(0), new CGPoint(0, -5), clipItem);
                searchView.SelectText(searchView);
            }
        }
Example #3
0
            public override bool DoCommandBySelector(NSTextView textView, ObjCRuntime.Selector commandSelector)
            {
//				if (commandSelector.Name == "insertTab:") {
//					textView.InsertText (new NSString ("    "));
//					return true;
//				}
                return(false);
            }
Example #4
0
 public AlertButtonWrapper(NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert)
 {
     this.nsbutton    = nsbutton;
     this.message     = message;
     this.alertButton = alertButton;
     this.alert       = alert;
     oldAction        = nsbutton.Action;
 }
Example #5
0
 public override void PerformAction(UITableView tableView, ObjCRuntime.Selector action, NSIndexPath indexPath, NSObject sender)
 {
     if (action.Name.Equals("copy:"))
     {
         var text = tableView.CellAt(indexPath).TextLabel.Text;
         UIPasteboard.General.SetData(NSData.FromString(text), "public.plain-text");
     }
 }
            protected override void TerminateWithSuccess()
            {
                Console.WriteLine("Exiting test run with success");

                var s = new ObjCRuntime.Selector("terminateWithSuccess");

                UIApplication.SharedApplication.PerformSelector(s, UIApplication.SharedApplication, 0);
            }
Example #7
0
        public override bool RespondsToSelector(ObjCRuntime.Selector sel)
        {
            if (TabViewController != null && TabViewController.RespondsToSelector(sel))
            {
                return(true);
            }

            return(base.RespondsToSelector(sel));
        }
        public override bool RespondsToSelector(ObjCRuntime.Selector sel)
        {
            if (sel.Name == "copy:")
            {
                return(logTableView.SelectedRowCount > 0);
            }

            return(base.RespondsToSelector(sel));
        }
 // Remove copy-paste actions
 public override bool CanPerform(ObjCRuntime.Selector action, NSObject withSender)
 {
     if (action == new ObjCRuntime.Selector("copy:") || action == new ObjCRuntime.Selector("selectAll:") || action == new ObjCRuntime.Selector("paste:"))
     {
         return(false);
     }
     else
     {
         return(base.CanPerform(action, withSender));
     }
 }
Example #10
0
        public override bool RespondsToSelector(ObjCRuntime.Selector sel)
        {
            var viewController = TabView?.Selected?.ViewController;

            if (viewController != null && viewController.RespondsToSelector(sel))
            {
                return(true);
            }

            return(base.RespondsToSelector(sel));
        }
        private static void TerminateWithSuccess()
        {
#if __IOS__
            var selector = new ObjCRuntime.Selector("terminateWithSuccess");
            UIKit.UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0);
#elif __DROID__
            System.Environment.Exit(0);
#elif WINDOWS_UWP
            Windows.UI.Xaml.Application.Current.Exit();
#endif
        }
Example #12
0
        public override bool FinishedLaunching(UIApplication uiApplication, NSDictionary launchOptions)
        {
            Forms.Init();

            var nunit = new App();

            nunit.AddTestAssembly(typeof(TestHelpers).Assembly);
            var options = new TestOptions
            {
                LogToOutput = true
            };

            var arguments = NSProcessInfo.ProcessInfo.Arguments
                            .Select(a => a.Replace("-app-arg=", string.Empty))
                            .ToArray();

            if (arguments.Any("--headless".Equals))
            {
                options.AutoRun             = true;
                options.CreateXmlResultFile = true;

                var hasResultsPath = false;
                for (var i = 0; i < arguments.Length; i++)
                {
                    if (arguments[i] == "--resultpath")
                    {
                        options.ResultFilePath = arguments[i + 1];
                        hasResultsPath         = true;
                        break;
                    }
                }

                if (!hasResultsPath)
                {
                    throw new Exception("You must provide path to store test results with --resultpath path/to/results.xml");
                }

                options.OnCompletedCallback = () =>
                {
                    TestHelpers.TransformTestResults(options.ResultFilePath);

                    var selector = new ObjCRuntime.Selector("terminateWithSuccess");
                    UIApplication.SharedApplication.PerformSelector(selector, UIApplication.SharedApplication, 0);

                    return(Task.CompletedTask);
                };
            }

            nunit.Options = options;
            LoadApplication(nunit);

            return(base.FinishedLaunching(uiApplication, launchOptions));
        }
Example #13
0
        public int RunModalSheet(NSWindow parent)
        {
            var sel = new ObjCRuntime.Selector("sheetSel");

            NSApplication.SharedApplication.BeginSheet(this, parent, this, sel, IntPtr.Zero);
            DidResignKey += StopSharedAppModal;
            try {
                sheet = true;
                return(SaveIfOk((int)NSApplication.SharedApplication.RunModalForWindow(this)));
            } finally {
                sheet         = false;
                DidResignKey -= StopSharedAppModal;
            }
        }
Example #14
0
        bool CommandBySelector(NSControl control, NSTextField field, ObjCRuntime.Selector sel)
        {
            switch (sel.Name)
            {
            case "insertTab:":             // down arrow
                CommandRaised?.Invoke(this, SearchTextFieldCommand.InsertTab);
                return(true);

            case "insertBacktab:":             // up arrow
                CommandRaised?.Invoke(this, SearchTextFieldCommand.InsertBacktab);
                return(true);
            }
            return(false);
        }
Example #15
0
        public static bool IsSelectorExcludedFromWebScript(ObjCRuntime.Selector aSelector)
        {
            // For security, you must explicitly allow a selector to be called from JavaScript.
            if (aSelector.Name == "showMessage:")
            {
                return(false);                // i.e. showMessage: is NOT _excluded_ from scripting, so it can be called.
            }
            if (aSelector.Name == "alert:")
            {
                return(false);
            }

            return(true);            // disallow everything else
        }
Example #16
0
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");
            global::Xamarin.Forms.Forms.Init();


            //force to app to run  RTL layout
            ObjCRuntime.Selector selector = new ObjCRuntime.Selector("setSemanticContentAttribute:");
            AppDelegate.IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, UISemanticContentAttribute.ForceRightToLeft);

            LoadApplication(new App());

            return(base.FinishedLaunching(app, options));
        }
        public TabButton(IHostResourceProvider hostResource, string imageName = null)
        {
            if (hostResource == null)
            {
                throw new ArgumentNullException(nameof(hostResource));
            }

            Bordered = false;
            Action   = new ObjCRuntime.Selector(ClickedName);

            var clicked = new NSClickGestureRecognizer(OnClicked);

            AddGestureRecognizer(clicked);

            this.hostResource = hostResource;
            this.imageName    = imageName;

            AppearanceChanged();
        }
Example #18
0
        private void Terminate()
        {
            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
            {
#if __IOS__
                var selector = new ObjCRuntime.Selector("terminateWithSuccess");
                UIKit.UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0);
#endif

                /*
                 * // We'll just use reflection here, rather than having to start doing multi-targeting just for this one platform specific thing
                 * // Reflection code equivalent to:
                 * // var selector = new ObjCRuntime.Selector("terminateWithSuccess");
                 * // UIKit.UIApplication.SharedApplication.PerformSelector(selector, UIKit.UIApplication.SharedApplication, 0);
                 * var selectorType = Type.GetType("ObjCRuntime.Selector, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065");
                 * var cnst = selectorType.GetConstructor(new Type[] { typeof(string) });
                 * var selector = cnst.Invoke(new object[] { "terminateWithSuccess" });
                 * var UIAppType = Type.GetType("UIKit.UIApplication, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065");
                 * var prop = UIAppType.GetProperty("SharedApplication");
                 * var app = prop.GetValue(null);
                 * var nsObjectType = Type.GetType("Foundation.NSObject, Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065");
                 * var psMethod = UIAppType.GetMethod("PerformSelector", new Type[] { selector.GetType(), nsObjectType, typeof(double) });
                 * psMethod.Invoke(app, new object[] { selector, app, 0d });
                 */
            }
            break;

            case Device.Android:
#if __ANDROID__
                Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
#endif
                break;

            default:
                Environment.Exit(0);
                break;
            }
        }
Example #19
0
        protected override void OnElementChanged(VisualElementChangedEventArgs args)
        {
            base.OnElementChanged(args);

            if (!_keyCommands.Any())
            {
                var selector = new ObjCRuntime.Selector(_keySelector);

                // Add support for special commands (viewable on iPad (>= iOS 9) when holding down ⌘)
                _keyCommands.Add(UIKeyCommand.Create(new NSString(HardwareInput.CopyCharacter), UIKeyModifierFlags.Command, selector, new NSString(LocalizedStrings.Copy)));
                _keyCommands.Add(UIKeyCommand.Create(new NSString(HardwareInput.PasteCharacter), UIKeyModifierFlags.Command, selector, new NSString(LocalizedStrings.Paste)));
                _keyCommands.Add(UIKeyCommand.Create(new NSString(HardwareInput.RootCharacter), UIKeyModifierFlags.Command, selector, new NSString(LocalizedStrings.RootOperator)));

                // Add support for enter and equals key
                _keyCommands.Add(UIKeyCommand.Create((NSString)_enterKey, 0, selector));
                _keyCommands.Add(UIKeyCommand.Create((NSString)HardwareInput.ResultOperator, 0, selector));

                // Add support for backspace key
                _keyCommands.Add(UIKeyCommand.Create((NSString)_backspaceKey, 0, selector));

                // Add support for numbers
                for (var i = 0; i < 10; i++)
                {
                    _keyCommands.Add(UIKeyCommand.Create((NSString)i.ToString(), 0, selector));
                }

                // Add support for parentheses, decimal separators and operators
                foreach (var symbol in HardwareInput.ParenthesesDecimalSeparatorsAndOperators)
                {
                    _keyCommands.Add(UIKeyCommand.Create((NSString)symbol, 0, selector));
                }

                foreach (var kc in _keyCommands)
                {
                    AddKeyCommand(kc);
                }
            }
        }
Example #20
0
        void handleControl(UIView view, UIControlEvent controlEvent)
        {
            var control = view as UIControl;

            if (control != null)
            {
                var targets = control.AllTargets;
                foreach (var target in targets)
                {
                    var actions = control.GetActions(target, controlEvent);
                    if ((actions != null)
                        )
                    {
                        foreach (var action in actions)
                        {
                            var selectorString = action;
                            var selector       = new ObjCRuntime.Selector(selectorString);
                            control.SendAction(selector, target, null);
                        }
                    }
                }
            }
        }
Example #21
0
 public override bool RespondsToSelector(ObjCRuntime.Selector sel)
 {
     log("RespondsToSelector -> " + sel.Name);
     return(base.RespondsToSelector(sel));
     // Internal - nothing to do here.
 }
 public static void OnLayoutDirectionChange()
 {
     ObjCRuntime.Selector selector = new ObjCRuntime.Selector("setSemanticContentAttribute:");
     IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, GetSemanticContentAttribute());
 }
Example #23
0
 public override bool RespondsToSelector(ObjCRuntime.Selector sel)
 {
     return(base.RespondsToSelector(sel));
 }
        protected override void TerminateWithSuccess()
        {
            var s = new ObjCRuntime.Selector("terminateWithSuccess");

            UIApplication.SharedApplication.PerformSelector(s, UIApplication.SharedApplication, 0);
        }
Example #25
0
 public virtual override bool RespondsToSelector(ObjCRuntime.Selector sel)
 {
     throw new NotImplementedException();
 }
Example #26
0
 public virtual override Foundation.NSObject PerformSelector(ObjCRuntime.Selector aSelector, Foundation.NSObject object1, Foundation.NSObject object2)
 {
     throw new NotImplementedException();
 }
Example #27
0
 public override void DoesNotRecognizeSelector(ObjCRuntime.Selector sel)
 {
     log("DoesNotRecognizeSelector -> " + sel.Name);
     // Internal - nothing to do here.
 }
Example #28
0
 public override void PerformSelector(ObjCRuntime.Selector sel, NSObject obj, double delay)
 {
     log("PerformSelector");
     // Internal - nothing to do here.
 }
Example #29
0
        public override bool DoCommandBySelector(NSControl control, NSTextView textView, ObjCRuntime.Selector commandSelector)
        {
            if (commandSelector.Name.Equals("cancelOperation:"))      //Esc
            {
                PressedEscKey?.Invoke(control, EventArgs.Empty);
            }

            else if (commandSelector.Name.Equals("insertNewline:"))   //Enter
            {
                PressedEnterKey?.Invoke(control, EventArgs.Empty);
            }

            else if (commandSelector.Name.Equals("insertLineBreak:")) //Ctrl + Enter
            {
                return(true);
            }

            else if (commandSelector.Name.Equals("insertNewlineIgnoringFieldEditor:")) //Alt + Enter
            {
                return(true);
            }

            return(false);
        }
		public int RunModalSheet (NSWindow parent)
		{
			var sel = new ObjCRuntime.Selector ("sheetSel");
			NSApplication.SharedApplication.BeginSheet (this, parent, this, sel, IntPtr.Zero);
			DidResignKey += StopSharedAppModal;
			try {
				sheet = true;
				return SaveIfOk ((int)NSApplication.SharedApplication.RunModalForWindow (this));
			} finally {
				sheet = false;
				DidResignKey -= StopSharedAppModal;
			}
		}
Example #31
0
		public void FocusSearchBar ()
		{
			var entry = searchEntry;
			if (!IsSearchEntryInOverflow)
				entry.SelectText (entry);
			else {
				// NSSearchField -> NSToolbarItemViewer -> _NSToolbarClipView -> NSToolbarView -> NSToolbarClippedItemsIndicator
				var clipItem = (NSButton)searchEntry.Superview.Superview.Superview.Subviews [1];
				var sel = new ObjCRuntime.Selector ("_computeMenuForClippedItemsIfNeeded");
				if (!clipItem.RespondsToSelector (sel))
					throw new Exception ("Cocoa selector changed for clipped items menu.");

				clipItem.PerformSelector (sel);
				var menu = clipItem.Menu;
				var searchItem = menu.ItemAt (0);
				var searchView = (SearchBar)searchItem.View;
				AttachToolbarEvents (searchView);
				menu.PopUpMenu (menu.ItemAt (0), new CGPoint (0, -5), clipItem);
				searchView.SelectText (searchView);
			}
		}
Example #32
0
 public override void InvokeOnMainThread(ObjCRuntime.Selector sel, Foundation.NSObject obj)
 {
 }
		public AlertButtonWrapper (NSButton nsbutton, MessageDescription message, AlertButton alertButton, NSAlert alert)
		{
			this.nsbutton = nsbutton;
			this.message = message;
			this.alertButton = alertButton;
			this.alert = alert;
			oldAction = nsbutton.Action;
		}