Inheritance: NSObject, IDisposable
Example #1
0
        public SparkleUI()
        {
            // Use translations
            Catalog.Init ("sparkleshare",
                Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));

            using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {

                // Needed for Growl
                GrowlApplicationBridge.WeakDelegate = this;
                GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate ();

                NSApplication.SharedApplication.ApplicationIconImage
                    = NSImage.ImageNamed ("sparkleshare.icns");

                SetFolderIcon ();

                Font = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

                BoldFont = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Bold, 0, 13);

                StatusIcon = new SparkleStatusIcon ();
                Bubbles = new SparkleBubbles ();

                if (Program.Controller.FirstRun) {
                    Setup = new SparkleSetup ();
                    Setup.Controller.ShowSetupPage ();
                }
            }
        }
Example #2
0
        public StatusIcon() : base() {
            using (var a = new NSAutoreleasePool()) {
                this.CreateAnimationFrames();

                this.status_item = NSStatusBar.SystemStatusBar.CreateStatusItem(28);
                this.status_item.HighlightMode = true;
                this.status_item.Image = this.animation_frames[0];

                this.status_item.Image               = this.animation_frames[0];
                this.status_item.Image.Size          = new SizeF(16, 16);
                this.status_item.AlternateImage      = this.animation_frames_active[0];
                this.status_item.AlternateImage.Size = new SizeF(16, 16);

                this.CreateMenu();
            }

            this.Controller.UpdateIconEvent += delegate(int icon_frame) {
                using (var a = new NSAutoreleasePool()) {
                    BeginInvokeOnMainThread(delegate {
                        if (icon_frame > -1) {
                            this.status_item.Image               = this.animation_frames[icon_frame];
                            this.status_item.Image.Size          = new SizeF(16, 16);
                            this.status_item.AlternateImage      = this.animation_frames_active[icon_frame];
                            this.status_item.AlternateImage.Size = new SizeF(16, 16);

                        } else {
                            this.status_item.Image               = this.error_image;
                            this.status_item.AlternateImage      = this.error_image_active;
                            this.status_item.Image.Size          = new SizeF(16, 16);
                            this.status_item.AlternateImage.Size = new SizeF(16, 16);
                        }
                    });
                }
            };

            this.Controller.UpdateMenuEvent += delegate {
                using (var a = new NSAutoreleasePool()) {
                    this.InvokeOnMainThread(() => this.CreateMenu());
                }
            };

            this.Controller.UpdateSuspendSyncFolderEvent += delegate(string reponame) {
                using (var a = new NSAutoreleasePool()){
                    this.InvokeOnMainThread(delegate {
                        foreach (var repoItem in this.repoItems) {
                            if (repoItem.RepositoryName == reponame) {
                                foreach (var repo in Program.Controller.Repositories) {
                                    if (repo.Name.Equals(reponame)) {
                                        repoItem.Status = repo.Status;
                                        break;
                                    }
                                }

                                break;
                            }
                        }
                    });
                }
            };
        }
Example #3
0
 public override Thread CreateWorkerThread(Action act)
 {
     return new Thread (() => {
         using (var pool = new NSAutoreleasePool ())
             act ();
     });
 }
        public SparkleController()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                string content_path =
                    Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ();

                string app_path   = Directory.GetParent (content_path).ToString ();
                string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");

                // Needed for Growl
                Dlfcn.dlopen (growl_path, 0);
                NSApplication.Init ();
            }

            // Let's use the bundled git first
            SparkleLib.Git.SparkleGit.Path =
                Path.Combine (NSBundle.MainBundle.ResourcePath,
                    "git", "libexec", "git-core", "git");

            SparkleLib.Git.SparkleGit.ExecPath =
                Path.Combine (NSBundle.MainBundle.ResourcePath,
                    "git", "libexec", "git-core");
        }
Example #5
0
		}//if
        
		void BackgroundWorkerThread ()
		{
			// Create an Autorelease Pool or we will leak objects.
			using (var pool = new NSAutoreleasePool()) {
				// Create a loop that will add 5 new components with
				// a 2 second pause between additions
				Console.WriteLine ("Before component load");
				for (int x = 1; x <= 5; x++) {

					Console.WriteLine ("Before add");

					// Make sure we invoke this on the Main Thread or OpenGL will throw an error
					MonoMac.AppKit.NSApplication.SharedApplication.BeginInvokeOnMainThread (delegate {
						Components.Add (new TestTexture (this));
					});
					Console.WriteLine ("After add");
					// Sleep for 2 seconds between each component addition
					Thread.Sleep (2000);

				}
				Console.WriteLine ("After component load");

			}

		}
Example #6
0
        public SparkleSetup()
            : base()
        {
            SparkleSetupController.HideWindowEvent += delegate {
                NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                    PerformClose (this);
                });
            };

            SparkleSetupController.ShowWindowEvent += delegate {
                NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                    OrderFrontRegardless ();
                });
            };

            SparkleSetupController.ChangePageEvent += delegate (Controller.PageType type, string [] warnings) {
                using (var a = new NSAutoreleasePool ())
                {
                    NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                        Reset ();
                        ShowPage (type, warnings);
                        ShowAll ();
                    });
                }
            };
        }
Example #7
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            Debug.WriteLine("[Dark Havoc] Starting up...");

#if !MONOMAC
            // Add application exit event hook.
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);

            // Create game instance.
            gameInstance = new DarkHavocGame();

            // Run game.
            gameInstance.Run();

#else
			Debug.WriteLine("[Dark Havoc] Initializing Mac OS X Subsystem...");

			NSApplication.Init();

			using (var p = new NSAutoreleasePool()) 
			{
				NSApplication.SharedApplication.Delegate = new AppDelegate();
				NSApplication.Main(args);
			}
#endif
        }
Example #8
0
 static void Main(string[] args)
 {
     NSApplication.Init ();
     using (var p = new NSAutoreleasePool ()) {
         NSApplication.SharedApplication.Delegate = new AppDelegate();
         NSApplication.Main(args);
     }
 }
Example #9
0
 public void SetFolderIcon ()
 {
     using (var a = new NSAutoreleasePool ())
     {
         NSImage folder_icon = NSImage.ImageNamed ("cmissync-folder.icns");
         NSWorkspace.SharedWorkspace.SetIconforFile (folder_icon, Program.Controller.FoldersPath, 0);
     }
 }
Example #10
0
		static void Main(string[] args)
        {
            NSApplication.Init();
            using (var p = new NSAutoreleasePool ())
            {
                NSApplication.Main(args);
            }
		}
		public ICredentials GetCredentials (Uri uri, IWebProxy proxy, CredentialType credentialType, ICredentials existingCredentials, bool retrying)
		{
			bool result = false;
			DispatchService.GuiSyncDispatch (() => {
				using (var ns = new NSAutoreleasePool ()) {
					var message = string.Format ("{0} needs {1} credentials to access {2}.", BrandingService.ApplicationName, 
					                             credentialType == CredentialType.ProxyCredentials ? "proxy" : "request", uri.Host);

					NSAlert alert = NSAlert.WithMessage ("Credentials Required", "OK", "Cancel", null, message);
					alert.Icon = NSApplication.SharedApplication.ApplicationIconImage;

					NSView view = new NSView (new RectangleF (0, 0, 313, 91));

					var creds = Utility.GetCredentialsForUriFromICredentials (uri, existingCredentials);

					var usernameLabel = new NSTextField (new RectangleF (17, 55, 71, 17)) {
						Identifier = "usernameLabel",
						StringValue = "Username:"******"Password:",
						Alignment = NSTextAlignment.Right,
						Editable = false,
						Bordered = false,
						DrawsBackground = false,
						Bezeled = false,
						Selectable = false,
					};
					view.AddSubview (passwordLabel);

					var passwordInput = new NSSecureTextField (new RectangleF (93, 20, 200, 22));
					passwordInput.StringValue = creds != null ? creds.Password : string.Empty;
					view.AddSubview (passwordInput);

					alert.AccessoryView = view;
					result = alert.RunModal () == 1;

					username = usernameInput.StringValue;
					password = passwordInput.StringValue;
				}
			});

			return result ? new NetworkCredential (username, password) : null;
		}
Example #12
0
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            NSApplication.Init();

            using (var p = new MonoMac.Foundation.NSAutoreleasePool())
            {
                NSApplication.SharedApplication.Delegate = new Program();
                NSApplication.Main(args);
            }
        }
Example #13
0
        public SparkleUI()
        {
            using (var a = new NSAutoreleasePool ()) {
                NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("qloudsync-app.icns");
                Setup = new SparkleSetup ();
                About = new AboutWindow ();
                StatusIcon = new IconController ();

            }
        }
Example #14
0
 static StorageDeviceHelper()
 {
     if (fileManager == null)
     {
         // Because this will run in a background thread we need to wrap it
         using (var p = new MonoMac.Foundation.NSAutoreleasePool()) {
             fileManager = NSFileManager.DefaultManager;
             attributes  = fileManager.GetFileSystemAttributes(path, out error);
         }
     }
 }
Example #15
0
		static StorageDeviceHelper ()
		{
			if (fileManager == null) {

				// Because this will run in a background thread we need to wrap it
				using (var p = new NSAutoreleasePool ()) {
					fileManager = NSFileManager.DefaultManager;
					attributes = fileManager.GetFileSystemAttributes(path, out error);
				}					
			}
		}
Example #16
0
        // Shared initialization code
        void Initialize ()
        {
            Controller = new SetupController ();

            Controller.ShowWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    Window.OrderFrontRegardless();
                });
            };

            Controller.HideWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    Window.PerformClose (this);
                });
            };

            Controller.ChangePageEvent += delegate (PageType type) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        if (!IsWindowLoaded) {
                            LoadWindow();
                        }
                        switch (type)
                        {
                        case PageType.Setup:
                            ShowWelcomePage();
                            break;
                        case PageType.Tutorial:
                            ShowTutorialPage();
                            break;
                        case PageType.Add1:
                            ShowLoginPage();
                            break;
                        case PageType.Add2:
                            ShowRepoSelectPage();
                            break;
                        case PageType.Customize:
                            ShowCustomizePage();
                            break;
                        // case PageType.Syncing:
                        //    ShowSyncingPage();
                        //    break;
                        case PageType.Finished:
                            ShowFinishedPage();
                            break;
                        case PageType.Settings:
                            ShowSettingsPage();
                            break;
                        }
                    });
                }
            };
        }
Example #17
0
 public override IDesktopPreferencesView CreatePreferencesView()
 {
     IDesktopPreferencesView view = null;
     using (var pool = new NSAutoreleasePool())
     {
         pool.InvokeOnMainThread(delegate {
             view = base.CreatePreferencesView();
         });
     }
     return view;
 }
Example #18
0
 public override ICloudConnectView CreateCloudConnectView()
 {
     ICloudConnectView view = null;
     using (var pool = new NSAutoreleasePool())
     {
         pool.InvokeOnMainThread(delegate {
             view = base.CreateCloudConnectView();
         });
     }
     return view;
 }
Example #19
0
        // private List<RootFolder> Repositories;
        // private CmisOutlineController OutlineController;
        // private CmisTreeDataSource DataSource;
        // private OutlineViewDelegate DataDelegate;
        // Dictionary<string,AsyncNodeLoader> Loader;


        public Setup () : base ()
        {
            Controller.HideWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    PerformClose (this);
                });
            };

            Controller.ShowWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    OrderFrontRegardless ();
                });
            };

            Controller.ChangePageEvent += delegate (PageType type) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        Reset ();
                        ShowPage (type);
                        ShowAll ();
                    });
                }
            };

            Controller.UpdateSetupContinueButtonEvent += delegate(bool button_enabled) {
                InvokeOnMainThread(delegate {
                    ContinueButton.Enabled = button_enabled;
                });
            };

            Controller.UpdateAddProjectButtonEvent += delegate(bool button_enabled) {
                InvokeOnMainThread(delegate {
                    ContinueButton.Enabled = button_enabled;
                });
            };

            Controller.ChangeAddressFieldEvent += delegate(string text, string example_text) {
                InvokeOnMainThread(delegate {
                    AddressTextField.StringValue = text;
                    AddressTextField.Enabled = true;
                    AddressHelpLabel.StringValue = example_text;
                });
            };

            Controller.LocalPathExists += LocalPathExistsHandler;

            Controller.UpdateProgressBarEvent += delegate(double percentage) {
                InvokeOnMainThread(delegate {
                    ProgressIndicator.DoubleValue = percentage;
                });
            };
        }
Example #20
0
        public override void PlatformEntrance()
        {
            #if MACOS
            NSApplication.Init();

            using (var p = new NSAutoreleasePool())
            {
                NSApplication.SharedApplication.Delegate = new AppDelegate();
                NSApplication.Main(null);
            }
            #endif
        }
Example #21
0
        private static void Main(string[] args)
        {
#if MONOMAC
			NSApplication.Init ();

			using (var p = new NSAutoreleasePool ()) {
				NSApplication.SharedApplication.Delegate = new AppDelegate();
				NSApplication.Main(args);
			}
         #else
            RunGame();
#endif
        }
Example #22
0
		static void Main(string[] args)
		{
			#if !MACOS
				Game = new Game1();
				Game.Run();
			#else
				NSApplication.Init ();
				using (var p = new NSAutoreleasePool ()) {
					NSApplication.SharedApplication.Delegate = new AppDelegate ();
					NSApplication.Main (args);
				}
			#endif
		}
Example #23
0
		static void Main (string[] args)
		{
			NSApplication.Init ();

			using (var p = new NSAutoreleasePool ()) {
				NSApplication.SharedApplication.Delegate = new AppDelegate ();

				// Set our Application Icon
				NSImage appIcon = NSImage.ImageNamed ("monogameicon.png");
				NSApplication.SharedApplication.ApplicationIconImage = appIcon;				

				NSApplication.Main (args);
			}
		}
Example #24
0
        public Controller () : base ()
        {
            using (var a = new NSAutoreleasePool ())
            {
                string content_path = Directory.GetParent (System.AppDomain.CurrentDomain.BaseDirectory).ToString ();
    
                string app_path   = Directory.GetParent (content_path).ToString ();
                string growl_path = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");
    
                // Needed for Growl
                Dlfcn.dlopen (growl_path, 0);
                NSApplication.Init ();
            }
		}
Example #25
0
        static void Main (string[] args)
		{
			#if MONOMAC
            NSApplication.Init ();

            using (var p = new NSAutoreleasePool ()) {
                NSApplication.SharedApplication.Delegate = new AppDelegate();
                NSApplication.Main(args);
            }
			#elif __IOS__ || __TVOS__
            UIApplication.Main(args, null, "AppDelegate");
			#else
			RunGame ();
			#endif
		}
Example #26
0
		public override void InitializeApplication ()
		{
			NSApplication.Init ();
			//Hijack ();
			if (pool != null)
				pool.Dispose ();
			pool = new NSAutoreleasePool ();
			appDelegate = new AppDelegate (IsGuest);
			NSApplication.SharedApplication.Delegate = appDelegate;

			// If NSPrincipalClass is not set, set it now. This allows running
			// the application without a bundle
			var info = NSBundle.MainBundle.InfoDictionary;
			if (info.ValueForKey ((NSString)"NSPrincipalClass") == null)
				info.SetValueForKey ((NSString)"NSApplication", (NSString)"NSPrincipalClass");
		}
Example #27
0
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main (string[] args)
		{
#if MONOMAC
			NSApplication.Init ();

			using (var p = new NSAutoreleasePool ()) {
				NSApplication.SharedApplication.Delegate = new AppDelegate ();
				NSApplication.Main (args);
			}
#else
			using (var game = new Particle3DSampleGame()) {
				game.Run();
			}
#endif

		}
        // Call to load from the XIB/NIB file
        public PreferenceWindowController()
            : base("PreferenceWindow")
        {
            Initialize ();

            using (var a = new NSAutoreleasePool ())
            {
                NSRunLoop.Main.BeginInvokeOnMainThread (delegate {
                    base.LoadWindow ();
                    loadFolders();
                    //will render for generic
                    Window.OpenWindow();
                });

            }
        }
Example #29
0
        public UI() {
            using (var a = new NSAutoreleasePool()) {
                NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed("cmissync-app.icns");

                this.SetFolderIcon();

                this.Setup = new SetupWizardController();
                this.About = new About();
                this.StatusIcon = new StatusIcon();
                this.Settings = new GeneralSettingsController();
                this.Transmission = new TransmissionWidgetController();
                this.Transmission.LoadWindow();
                this.Transmission.Window.IsVisible = false;

                Program.Controller.UIHasLoaded();
            }
        }
Example #30
0
	public static void Main(string[] args)
	{
		NSApplication.Init();

		Debug.WriteLine("Startup: Finished NSApplication.Init in static Main");

		using (var p = new NSAutoreleasePool())
		{
			NSApplication.SharedApplication.Delegate = new AppDelegate();

			// TODO: Offer a way of setting the application icon.
			//NSImage appIcon = NSImage.ImageNamed("monogameicon.png");
			//NSApplication.SharedApplication.ApplicationIconImage = appIcon;

			NSApplication.Main(args);
		}
	}
Example #31
0
        public SparkleUI()
        {
            string content_path = Directory.GetParent (
                System.AppDomain.CurrentDomain.BaseDirectory).ToString ();

            string app_path     = Directory.GetParent (content_path).ToString ();
            string growl_path   = Path.Combine (app_path, "Frameworks", "Growl.framework", "Growl");

            // Needed for Growl
            Dlfcn.dlopen (growl_path, 0);
            NSApplication.Init ();

            // Use translations
            Catalog.Init ("sparkleshare",
                Path.Combine (NSBundle.MainBundle.ResourcePath, "Translations"));

            using (NSAutoreleasePool pool = new NSAutoreleasePool ()) {

                // Needed for Growl
                GrowlApplicationBridge.WeakDelegate = this;
                GrowlApplicationBridge.Delegate = new SparkleGrowlDelegate ();

                NSApplication.SharedApplication.ApplicationIconImage
                    = NSImage.ImageNamed ("sparkleshare.icns");

                if (!Program.Controller.BackendIsPresent) {
                    this.alert = new SparkleAlert ();
                    this.alert.RunModal ();
                    return;
                }

                SetFolderIcon ();

                Font = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Condensed, 0, 13);

                StatusIcon = new SparkleStatusIcon ();
                Bubbles = new SparkleBubbles ();

                if (Program.Controller.FirstRun) {
                    Setup = new SparkleSetup ();
                    Setup.Controller.ShowSetupPage ();
                }
            }
        }
Example #32
0
        public SparkleUI()
        {
            using (var a = new NSAutoreleasePool ())
            {
                NSApplication.SharedApplication.ApplicationIconImage = NSImage.ImageNamed ("sparkleshare-app.icns");

                NSWorkspace.SharedWorkspace.SetIconforFile (NSImage.ImageNamed ("sparkleshare-folder.icns"),
                    Program.Controller.FoldersPath, 0);

                Setup      = new SparkleSetup ();
                EventLog   = new SparkleEventLog ();
                About      = new SparkleAbout ();
                Bubbles    = new SparkleBubbles ();
                StatusIcon = new SparkleStatusIcon ();

                Program.Controller.UIHasLoaded ();
            }
        }