Exemplo n.º 1
0
 static void Main(string[] args)
 {
     NSApplication.Init();
     NSApplication.Main(args);
 }
Exemplo n.º 2
0
 partial void PlatformSpecificInitialization()
 {
     NSApplication.Init();
 }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     NSApplication.Init();
     NSApplication.SharedApplication.Delegate = new AppDelegate();
     NSApplication.Main(args);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Inits code to allow us to use AppKit on Mac OSX
 /// This lets us use the native browser and native file open/save dialogs
 /// Thia initialisation must be done once and only once
 /// Keeping this in a separate function allows the Microsoft .Net Frameworks
 /// to run even when MonoDoc.dll is not present (that is, with Microsoft,
 /// checking for referenced DLLs seems to occur on a "method", rather than "class" basis.
 /// The Mono runtime works differently.
 /// </summary>
 private void InitMac()
 {
     NSApplication.Init();
 }
Exemplo n.º 5
0
 private static void Main(string[] arguments)
 {
     NSApplication.Init();
     NSApplication.Main(arguments);
 }
Exemplo n.º 6
0
 static Task <int> Main(string[] args)
 {
     NSApplication.Init();
     return(RunTests(args));
 }
Exemplo n.º 7
0
 static void Main(string[] args)
 {
     NSApplication.Init();
     SetCurrentCulture();
     NSApplication.Main(args);
 }
 /// <summary>
 /// Initialize MonoMac. Use instead of the above functions when running
 /// in an embedded environment.
 /// </summary>
 internal static void MonoMacInit()
 {
     NSApplication.Init();
     NSApplication.InitDrawingBridge();
 }
Exemplo n.º 9
0
        public Controller() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                NSApplication.Init();
            }

            NSWorkspace.SharedWorkspace.NotificationCenter.AddObserver(
                NSWorkspace.WillSleepNotification,
                delegate
            {
                Logger.Info(String.Format("Machine sleep event detected, stop all repositories"));
                StopAll();
            }
                );

            NSWorkspace.SharedWorkspace.NotificationCenter.AddObserver(
                NSWorkspace.DidWakeNotification,
                delegate
            {
                Logger.Info(String.Format("Machine sleep event detected, start all repositories"));
                StartAll();
            }
                );

            // We get the Default notification Center
            notificationCenter = NSUserNotificationCenter.DefaultUserNotificationCenter;

            notificationCenter.DidDeliverNotification += (s, e) =>
            {
                //Console.WriteLine("Notification Delivered");
            };

            notificationCenter.DidActivateNotification += (s, e) =>
            {
                if (IsNotificationTransmission(e.Notification))
                {
                    LocalFolderClicked(Path.GetDirectoryName(e.Notification.InformativeText));
                }

                if (IsNotificationCredentials(e.Notification))
                {
                    //RemoveNotificationCredentials(e.Notification.Title);
                    EditRepositoryCredentials(e.Notification.Title);
                }
            };

            // If we return true here, Notification will show up even if your app is TopMost.
            notificationCenter.ShouldPresentNotification = (c, n) => { return(false); };

            ShowChangePassword += delegate(string reponame) {
                InsertNotificationCredentials(reponame);
            };

            SuccessfulLogin += delegate(string reponame)
            {
                RemoveNotificationCredentials(reponame);
            };

            OnTransmissionListChanged += delegate {
                using (var a = new NSAutoreleasePool()) {
                    notificationCenter.BeginInvokeOnMainThread(delegate {
                        lock (transmissionLock) {
                            List <FileTransmissionEvent> transmissions      = ActiveTransmissions();
                            NSUserNotification[] notifications              = notificationCenter.DeliveredNotifications;
                            List <NSUserNotification> finishedNotifications = new List <NSUserNotification>();
                            foreach (NSUserNotification notification in notifications)
                            {
                                if (!IsNotificationTransmission(notification))
                                {
                                    continue;
                                }
                                FileTransmissionEvent transmission = transmissions.Find((FileTransmissionEvent e) => { return(e.Path == notification.InformativeText); });
                                if (transmission == null)
                                {
                                    finishedNotifications.Add(notification);
                                }
                                else
                                {
                                    if (transmissionFiles.ContainsKey(transmission.Path))
                                    {
                                        transmissions.Remove(transmission);
                                    }
                                    else
                                    {
                                        notificationCenter.RemoveDeliveredNotification(notification);
                                    }
                                }
                            }

                            finishedNotifications.Sort(new ComparerNSUserNotification());
                            for (int i = 0; i < (notifications.Length - notificationKeep) && i < finishedNotifications.Count; ++i)
                            {
                                notificationCenter.RemoveDeliveredNotification(finishedNotifications[i]);
                            }

                            foreach (FileTransmissionEvent transmission in transmissions)
                            {
                                if (transmission.Status.Aborted == true)
                                {
                                    continue;
                                }

                                if (transmission.Status.FailedException != null)
                                {
                                    continue;
                                }

                                if (startedTransmissions.Contains(transmission.Path))
                                {
                                    continue;
                                }

                                startedTransmissions.Add(transmission.Path);

                                NSUserNotification notification = new NSUserNotification();
                                notification.Title           = Path.GetFileName(transmission.Path);
                                notification.Subtitle        = TransmissionStatus(transmission);
                                notification.InformativeText = transmission.Path;
                                NSMutableDictionary userInfo = new NSMutableDictionary();
                                userInfo.Add((NSString)notificationType, (NSString)notificationTypeTransmission);
                                notification.UserInfo     = userInfo;
                                notification.DeliveryDate = NSDate.Now;
                                notificationCenter.DeliverNotification(notification);

                                transmissionFiles.Add(transmission.Path, NSDate.Now);
                                transmission.TransmissionStatus += TransmissionReport;
                            }
                        }
                    });
                }
            };
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            var xPos       = NSScreen.MainScreen.Frame.Width / 2;  // NSWidth([[window screen] frame])/ 2 - NSWidth([window frame])/ 2;
            var yPos       = NSScreen.MainScreen.Frame.Height / 2; // NSHeight([[window screen] frame])/ 2 - NSHeight([window frame])/ 2;
            var mainWindow = new MacAccInspectorWindow(new CGRect(xPos, yPos, 300, 368), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false);

            var stackView = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical
            };

            mainWindow.ContentView = stackView;
            stackView.AddArrangedSubview(new NSTextField {
                StringValue = "123"
            });

            stackView.AddArrangedSubview(new NSTextField {
                StringValue = "45"
            });
            stackView.AddArrangedSubview(new NSTextField {
                StringValue = "345"
            });
            var button = new NSButton {
                Title = "Press to show a message"
            };

            stackView.AddArrangedSubview(button);

            var hotizontalView = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Horizontal
            };

            hotizontalView.AddArrangedSubview(new NSTextField()
            {
                StringValue = "test"
            });

            stackView.AddArrangedSubview(hotizontalView);

            button.Activated += (sender, e) => {
                var alert = new NSAlert();
                alert.MessageText     = "You clicked the button!!!";
                alert.InformativeText = "Are you sure!?";
                alert.AddButton("OK!");
                alert.RunModal();
            };

            var button2 = new NSButton {
                Title = "Opens Localized text"
            };

            button2.Activated += (sender, e) => {
                var window = new NSWindow()
                {
                    StyleMask = NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable
                };
                var stack = NativeViewHelper.CreateHorizontalStackView();
                var label = NativeViewHelper.CreateLabel(Strings.HelloText);
                stack.AddArrangedSubview(label);
                window.ContentView = stack;
                window.WillClose  += (sender1, e1) =>
                {
                    window.Dispose();
                };
                window.MakeKeyAndOrderFront(mainWindow);
            };
            stackView.AddArrangedSubview(button2);
            button2.HeightAnchor.ConstraintEqualToConstant(100).Active = true;;

            mainWindow.Title = "Example Debug Xamarin.Mac";

            //mainWindow.MakeKeyWindow();
            mainWindow.MakeKeyAndOrderFront(null);
            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
            //mainWindow.Dispose();
        }
Exemplo n.º 11
0
 static void Main(string[] args)
 {
     NSApplication.Init();
     RunTests();
 }
 static NSApplicationInitializer()
 {
     NSApplication.Init();
 }
Exemplo n.º 13
0
 static void Main(string[] args)
 {
     f(10); // throwing function
     NSApplication.Init();
     NSApplication.Main(args);
 }
Exemplo n.º 14
0
 static void Main(string[] args)
 {
     Kpo4310_asadovrs.AppGlobalSettings.Initialize();
     NSApplication.Init();
     NSApplication.Main(args);
 }