Esempio n. 1
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			var info = manager.GetCommandInfo (ce.CommandId);

			if (!isArrayItem) {
				SetItemValues (this, info);
				if (!Hidden)
					MDMenu.ShowLastSeparator (ref lastSeparator);
				return;
			}

			Hidden = true;

			if (index < parent.Count - 1) {
				for (int i = index + 1; i < parent.Count; i++) {
					var nextItem = parent.ItemAt (i);
					if (nextItem == null || nextItem.Target != this)
						break;
					parent.RemoveItemAt (i);
					i--;
				}
			}

			PopulateArrayItems (info.ArrayInfo, parent, ref lastSeparator, ref index);
		}
Esempio n. 2
0
		private void CreateNsMenu() {

			var menu = new NSMenu ();

			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
			statusItem.Menu = menu;
			statusItem.Image = NSImage.ImageNamed("statusicon");
			statusItem.HighlightMode = true;

			menu.RemoveAllItems ();

			browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
				Browse (NSApplication.SharedApplication);
			});
			menu.AddItem (browseMenuItem);

			configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
				Configure (NSApplication.SharedApplication);
			});
			menu.AddItem (configureMenuItem);

			communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
				Community (NSApplication.SharedApplication);
			});
			menu.AddItem (communityMenuItem);

			quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
				Quit (NSApplication.SharedApplication);
			});
			menu.AddItem (quitMenuItem);
		}
Esempio n. 3
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			Enabled = true;
			Hidden = Submenu != NSApplication.SharedApplication.ServicesMenu;
			if (!Hidden)
				MDMenu.ShowLastSeparator (ref lastSeparator);
		}
Esempio n. 4
0
		public void Run (NSMenuItem sender)
		{
			var a = sender as MDExpandedArrayItem;
			if (a != null) {
				manager.DispatchCommand (ce.CommandId, a.Info.DataItem, CommandSource.MainMenu);
			} else {
				manager.DispatchCommand (ce.CommandId, CommandSource.MainMenu);
			}
		}
Esempio n. 5
0
		public bool ValidateMenuItem(NSMenuItem item)
		{
			var h = Handler;
			if (h != null)
			{
				h.Widget.OnValidate(EventArgs.Empty);
				return h.Enabled;
			}
			return false;
		}
Esempio n. 6
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			if (ces.AutoHide) {
				((MDMenu)Submenu).UpdateCommands ();
				Hidden = Submenu.ItemArray ().All (item => item.Hidden);
			}
			if (!Hidden) {
				MDMenu.ShowLastSeparator (ref lastSeparator);
			}
		}
Esempio n. 7
0
        public override void FinishedLaunching(NSObject notification)
        {
            //			mainWindowController = new MainWindowController ();
            //			mainWindowController.Window.MakeKeyAndOrderFront (this);

            // Construct menu that will be displayed when tray icon is clicked
            var notifyMenu = new NSMenu();
            var exitMenuItem = new NSMenuItem("Quit",
                (a,b) => {
                    NSApplication.SharedApplication.Terminate(this);
                    //System.Environment.Exit(0);
                });

            var startMidiModMenuItem = new NSMenuItem("Run",
                (a,b) => { RunMidiMod(); });

            var mappingmodMidiModMenuItem = new NSMenuItem("Mapping Mod",
                (a,b) => { ActivateMappingMod(); });

            statusMenuItem = new NSMenuItem("STATUS",
                (a,b) => {  });
            statusMenuItem.Enabled = false;

            var versionMenuItem = new NSMenuItem("Version 1.0",
                (a,b) => {  });
            versionMenuItem.Enabled = false;

            var seperatorItem = NSMenuItem.SeparatorItem;

            notifyMenu.AutoEnablesItems = false;

            // Just add 'Quit' command
            notifyMenu.AddItem (statusMenuItem);
            notifyMenu.AddItem (versionMenuItem);
            notifyMenu.AddItem (seperatorItem);
            notifyMenu.AddItem (startMidiModMenuItem);
            notifyMenu.AddItem (mappingmodMidiModMenuItem);
            notifyMenu.AddItem(exitMenuItem);

            // Display tray icon in upper-right-hand corner of the screen
            sItem = NSStatusBar.SystemStatusBar.CreateStatusItem(16); //def 16
            sItem.Menu = notifyMenu;
            sItem.Title = "MidiMod";
            sItem.ToolTip = "Midi Mod";
            sItem.Image = NSImage.FromStream(System.IO.File.OpenRead(NSBundle.MainBundle.ResourcePath + @"/9b244f1232672041.icns"));
            sItem.HighlightMode = true;

            UpdateStatus ("Mod not startet");

            // Remove the system tray icon from upper-right hand corner of the screen
             	// (works without adjusting the LSUIElement setting in Info.plist)
            NSApplication.SharedApplication.ActivationPolicy =
                NSApplicationActivationPolicy.Accessory;
        }
        public RepositoryMenuItem(Repository repo, StatusIconController controller) : base(repo.Name) {
            this.repository = repo;
            this.controller = controller;
            this.Image = this.folderImage;
            this.Image.Size = new SizeF(16, 16);
            this.repository.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.Status)) {
                    this.Status = this.repository.Status;
                }

                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.LastFinishedSync)) {
                    this.changesFoundAt = this.repository.LastFinishedSync;
                    this.UpdateStatusText();
                }

                if (e.PropertyName == CmisSync.Lib.Utils.NameOf((Repository r) => r.NumberOfChanges)) {
                    this.changesFound = this.repository.NumberOfChanges;
                    this.UpdateStatusText();
                }
            };
            this.openLocalFolderItem = new NSMenuItem(Properties_Resources.OpenLocalFolder) {
                Image = this.folderImage
            };
            this.openLocalFolderItem.Image.Size = new SizeF(16, 16);

            this.openLocalFolderItem.Activated += this.OpenFolderDelegate();

            this.editItem = new NSMenuItem(Properties_Resources.Settings);
            this.editItem.Activated += this.EditFolderDelegate();

            this.suspendItem = new NSMenuItem(Properties_Resources.PauseSync);

            this.Status = repo.Status;

            this.suspendItem.Activated += this.SuspendSyncFolderDelegate();
            this.statusItem = new NSMenuItem(Properties_Resources.StatusSearchingForChanges) {
                Enabled = false
            };

            this.removeFolderFromSyncItem = new NSMenuItem(Properties_Resources.RemoveFolderFromSync);
            this.removeFolderFromSyncItem.Activated += this.RemoveFolderFromSyncDelegate();

            var subMenu = new NSMenu();
            subMenu.AddItem(this.statusItem);
            subMenu.AddItem(NSMenuItem.SeparatorItem);
            subMenu.AddItem(this.openLocalFolderItem);
            subMenu.AddItem(this.suspendItem);
            subMenu.AddItem(this.editItem);
            subMenu.AddItem(NSMenuItem.SeparatorItem);
            subMenu.AddItem(this.removeFolderFromSyncItem);
            this.Submenu = subMenu;
        }
Esempio n. 9
0
		public void Run (NSMenuItem sender)
		{
			var a = sender as MDExpandedArrayItem;
			//if the command opens a modal subloop, give cocoa a chance to unhighlight the menu item
			GLib.Timeout.Add (1, () => {
				if (a != null) {
					manager.DispatchCommand (ce.CommandId, a.Info.DataItem, CommandSource.MainMenu);
				} else {
					manager.DispatchCommand (ce.CommandId, CommandSource.MainMenu);
				}
				return false;
			});
		}
Esempio n. 10
0
		public bool ValidateMenuItem(NSMenuItem menuItem)
		{
            switch ((MenuTag) (int)menuItem.Tag)
			{
				case MenuTag.AlwaysEnable:
					return true;
				case MenuTag.RequiresFile:
					return mediaListController.Count > 0;
			}

			logger.Info("ValidateMenuItem: unexpected tag {0} for menu item '{1}'", menuItem.Tag, menuItem.Title);
			return false;
		}
Esempio n. 11
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            var menu = new NSMenu ();

            var menuItem = new NSMenuItem ();
            menu.AddItem (menuItem);

            var appMenu = new NSMenu ();
            var quitItem = new NSMenuItem ("Quit " + NSProcessInfo.ProcessInfo.ProcessName, "q", (s, e) => NSApplication.SharedApplication.Terminate (menu));
            appMenu.AddItem (quitItem);

            var window = new NSWindow ();

            menuItem.Submenu = appMenu;
            NSApplication.SharedApplication.MainMenu = menu;
        }
Esempio n. 12
0
		private void CreateNsMenu() {

			var menu = new NSMenu ();

			statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30);
			statusItem.Menu = menu;
			statusItem.Image = NSImage.ImageNamed("statusicon");
			statusItem.HighlightMode = true;

			menu.RemoveAllItems ();

			browseMenuItem = new NSMenuItem ("Browse Media Library", "b", delegate {
				Browse (NSApplication.SharedApplication);
			});
			menu.AddItem (browseMenuItem);

			configureMenuItem = new NSMenuItem ("Configure Media Browser", "c", delegate {
				Configure (NSApplication.SharedApplication);
			});
			menu.AddItem (configureMenuItem);

			developerMenuItem = new NSMenuItem ("Developer Resources");
			menu.AddItem (developerMenuItem);

			var developerMenu = new NSMenu ();
			developerMenuItem.Submenu = developerMenu;

			apiMenuItem = new NSMenuItem ("Api Documentation", "a", delegate {
				ApiDocs (NSApplication.SharedApplication);
			});
			developerMenu.AddItem (apiMenuItem);

			githubMenuItem = new NSMenuItem ("Github", "g", delegate {
				Github (NSApplication.SharedApplication);
			});
			developerMenu.AddItem (githubMenuItem);

			communityMenuItem = new NSMenuItem ("Visit Community", "v", delegate {
				Community (NSApplication.SharedApplication);
			});
			menu.AddItem (communityMenuItem);

			quitMenuItem = new NSMenuItem ("Quit", "q", delegate {
				Quit (NSApplication.SharedApplication);
			});
			menu.AddItem (quitMenuItem);
		}
Esempio n. 13
0
 public MenuItemWrapper(string text, Duplicati.GUI.TrayIcon.MenuIcons icon, Action callback, IList<Duplicati.GUI.TrayIcon.IMenuItem> subitems)
 {
     if (text == "-")
         m_item = NSMenuItem.SeparatorItem;
     else
     {
         m_item = new NSMenuItem(text, ClickHandler);
         m_callback = callback;
         
         if (subitems != null && subitems.Count > 0)
         {
             m_item.Submenu = new NSMenu();
             foreach(var itm in subitems)
                 m_item.Submenu.AddItem(((MenuItemWrapper)itm).MenuItem);
         }
     }
 }
		public SelectEncodingPopUpButton (bool showAutoDetected)
		{
			Cell.UsesItemFromMenu = false;
			
			if (showAutoDetected) {
				autoDetectedItem = new NSMenuItem () {
					Title = GettextCatalog.GetString ("Auto Detected"),
					Tag = -1,
					Target = this,
					Action = itemActivationSel,
				};
			}
			
			addRemoveItem = new NSMenuItem () {
				Title = GettextCatalog.GetString ("Add or Remove..."),
				Tag = -20,
				Target = this,
				Action = addRemoveActivationSel,
			};
			
			Populate (false);
			SelectedEncodingId = 0;
		}
		public override void AwakeFromNib ()
		{
			base.AwakeFromNib ();
			
			#region first two buttons 
			
			// add the image menu item back to the first menu item
			NSMenuItem menuItem = new NSMenuItem ("", new Selector (""), "");
			
			menuItem.Image = NSImage.ImageNamed ("moof.png");
			buttonMenu.InsertItematIndex (menuItem, 0);
			
			nibBasedPopUpDown.Menu = buttonMenu;
			nibBasedPopUpRight.Menu = buttonMenu;
		
			// create the pull down button pointing DOWN
			RectangleF buttonFrame = placeHolder1.Frame;
			codeBasedPopUpDown = new NSPopUpButton (buttonFrame, true);
			
			((NSPopUpButtonCell)codeBasedPopUpDown.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom;
			((NSPopUpButtonCell)codeBasedPopUpDown.Cell).BezelStyle = NSBezelStyle.ThickSquare;
			codeBasedPopUpDown.Menu = buttonMenu;
			popupBox.AddSubview (codeBasedPopUpDown);
			placeHolder1.RemoveFromSuperview ();
		
			// create the pull down button pointing RIGHT
			buttonFrame = placeHolder2.Frame;
			codeBasedPopUpRight = new NSPopUpButton (buttonFrame, true);
			
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).ArrowPosition = NSPopUpArrowPosition.Bottom;
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).PreferredEdge = NSRectEdge.MaxXEdge;
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).BezelStyle = NSBezelStyle.Circular;
			codeBasedPopUpRight.Menu = buttonMenu;
			((NSPopUpButtonCell)codeBasedPopUpRight.Cell).HighlightsBy = (int)NSCellMask.ChangeGrayCell;
			popupBox.AddSubview (codeBasedPopUpRight);
			placeHolder2.RemoveFromSuperview ();
			
			#endregion
			
			#region second two buttons
			
			// create the rounded button
			buttonFrame = placeHolder3.Frame;
			// note: this button we want alternate title and image, so we need to call this:
			codeBasedButtonRound = new NSButton (buttonFrame) {
				Title = "NSButton",
				AlternateTitle = "(pressed)",
				Image = NSImage.ImageNamed ("moof.png"),
				AlternateImage = NSImage.ImageNamed ("moof2.png"),
				BezelStyle = NSBezelStyle.RegularSquare,
				ImagePosition = NSCellImagePosition.ImageLeft,
				Font = NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize),
				Sound = NSSound.FromName ("Pop"),
			};
			// Two choices, either use the .NET event system:
			//    foo.Activated += delegate {..} or += SomeMethod
			//
			// Or you can use the Target = this Action = new Selector ("buttonAction:")
			// pattern
			codeBasedButtonRound.Activated += delegate {
				buttonAction (null);
			};
			codeBasedButtonRound.SetButtonType (NSButtonType.MomentaryChange);
			codeBasedButtonRound.Cell.Alignment = NSTextAlignment.Left;
			buttonBox.AddSubview (codeBasedButtonRound);
			placeHolder3.RemoveFromSuperview (); 			// we are done with the place holder, remove it from the window
			
			// create the square button
			buttonFrame = placeHolder4.Frame;
			codeBasedButtonSquare = new NSButton (buttonFrame){
				Title = "NSButton",
				BezelStyle = NSBezelStyle.ShadowlessSquare,
				ImagePosition = NSCellImagePosition.ImageLeft,
				Image = NSImage.ImageNamed ("moof.png"),
				Font = NSFont.SystemFontOfSize (NSFont.SmallSystemFontSize),
				Sound = NSSound.FromName ("Pop"),
			};
			codeBasedButtonSquare.Activated += delegate { buttonAction (null); };
			codeBasedButtonSquare.Cell.Alignment = NSTextAlignment.Left;
			buttonBox.AddSubview (codeBasedButtonSquare);
			placeHolder4.RemoveFromSuperview (); 			// we are done with the place holder, remove it from the window
			
			#endregion
			
			#region segmented control
			
			buttonFrame = placeHolder5.Frame;
			codeBasedSegmentControl = new NSSegmentedControl(buttonFrame) {
				SegmentCount = 3,
				Target = this,
				Action = new Selector("segmentAction:")
			};
					
			codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth(0), 0);
			codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth (1), 1);
			codeBasedSegmentControl.SetWidth (nibBasedSegControl.GetWidth (2), 2);
			codeBasedSegmentControl.SetLabel ("One", 0);
			codeBasedSegmentControl.SetLabel ("Two", 1);
			codeBasedSegmentControl.SetLabel ("Three", 2);
			segmentBox.AddSubview (codeBasedSegmentControl);
			placeHolder5.RemoveFromSuperview ();
	
			// use a menu to the first segment (applied to both nib-based and code-based)
			codeBasedSegmentControl.SetMenu (buttonMenu, 0);
			nibBasedSegControl.SetMenu (buttonMenu, 0);
			
			// add icons to each segment (applied to both nib-based and code-based)
			NSImage segmentIcon1 = NSWorkspace.SharedWorkspace.IconForFileType(NSFileTypeForHFSTypeCode.ComputerIcon);
			segmentIcon1.Size = new SizeF(16, 16);
			nibBasedSegControl.SetImage (segmentIcon1, 0);
			codeBasedSegmentControl.SetImage (segmentIcon1, 0);
			
			NSImage segmentIcon2 = NSWorkspace.SharedWorkspace.IconForFileType (NSFileTypeForHFSTypeCode.DesktopIcon);
			segmentIcon2.Size = new SizeF (16, 16);
			nibBasedSegControl.SetImage (segmentIcon2, 1);
			codeBasedSegmentControl.SetImage (segmentIcon2, 1);
			
			NSImage segmentIcon3 = NSWorkspace.SharedWorkspace.IconForFileType (NSFileTypeForHFSTypeCode.FinderIcon);
			segmentIcon3.Size = new SizeF (16, 16);
			nibBasedSegControl.SetImage (segmentIcon3, 2);
			codeBasedSegmentControl.SetImage (segmentIcon3, 2);
		
			#endregion
			
			#region level indicator
			
			buttonFrame = placeHolder8.Frame;
			codeBasedIndicator = new NSLevelIndicator(buttonFrame) {
				MaxValue = 10,
				MajorTickMarkCount = 4,
				TickMarkCount = 7,
				WarningValue = 5,
				CriticalValue = 8,
				Action = new Selector("levelAction:")
			};
			codeBasedIndicator.Cell.LevelIndicatorStyle = NSLevelIndicatorStyle.DiscreteCapacity;
			indicatorBox.AddSubview(codeBasedIndicator);
			placeHolder8.RemoveFromSuperview();
			
			
			#endregion
		}
Esempio n. 16
0
		/// <summary>
		/// Arranges the Dock Menu with lastest change date.
		/// Last 10 modified Notes are shown up in the Dock Menu.
		/// </summary>
		void ArrangeDateWise () {
			if (Notes != null || Notes.Count > 0) {
				int count = Notes.Count;
				Dictionary<DateTime,Note> dateDict = new Dictionary<DateTime, Note>();

				for (int i = 0; i < count; i++) {
					Note temp = Notes.Values.ElementAt(i);
					if(!dateDict.ContainsKey(temp.ChangeDate))
						dateDict.Add(temp.ChangeDate, temp);
				}

				var dateList = dateDict.Keys.ToList();
				dateList.Sort();

				if (dateDict.Count >= MAXNOTES)
					for (int i = 0; i < MAXNOTES && dockMenuNoteCounter <= MAXNOTES; i++) {
						var item = new NSMenuItem();
						DateTime date = dateList.ElementAt(dateDict.Count - i - 1);
						item.Title = dateDict[date].Title;
						item.Activated += HandleActivated;
						dockMenu.AddItem(item);
						dockMenuNoteCounter += 1;
					}
				else
					for (int i = 0; i < dateDict.Count; i++) {
						var item = new NSMenuItem();
						DateTime date = dateList.ElementAt(dateDict.Count - i - 1);
						item.Title = dateDict[date].Title;
						item.Activated += HandleActivated;
						dockMenu.AddItem(item);
						dockMenuNoteCounter += 1;
					}

			}

		}
Esempio n. 17
0
		/// <summary>
		/// Handles the note added.
		/// </summary>
		/// <param name="note">Note.</param>
		void HandleNoteAdded (Note note) {
			Logger.Debug ("AppDelegate Handling Note Added {0}", note.Title);

			try {
				NSMenuItem item = new NSMenuItem ();
				item.Title = note.Title;
				item.Activated += HandleActivated;
				dockMenu.AddItem (item);
				dockMenuNoteCounter += 1;
				RefreshNotesWindowController();
			} catch (Exception e) {
				Logger.Error ("Failed to add item from Dock Menu {0}", e);
			}
		}
Esempio n. 18
0
        // Creates the menu that is popped up when the
        // user clicks the status icon
        public void CreateMenu()
        {
            Menu = new NSMenu ();

            StateMenuItem = new NSMenuItem () {
                Title = StateText
            };

            Menu.AddItem (StateMenuItem);
            Menu.AddItem (NSMenuItem.SeparatorItem);

            FolderMenuItem = new NSMenuItem () {
                Title = "SparkleShare"
            };

                FolderMenuItem.Activated += delegate {
                    SparkleShare.Controller.OpenSparkleShareFolder ();
                };

                string folder_icon_path = Path.Combine (NSBundle.MainBundle.ResourcePath,
                    "sparkleshare-mac.icns");

                FolderMenuItem.Image = new NSImage (folder_icon_path);
                FolderMenuItem.Image.Size = new SizeF (16, 16);

            Menu.AddItem (FolderMenuItem);

            if (SparkleShare.Controller.Folders.Count > 0) {
                FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count];
                Tasks = new EventHandler [SparkleShare.Controller.Folders.Count];

                int i = 0;
                foreach (string folder_name in SparkleShare.Controller.Folders) {
                    NSMenuItem item = new NSMenuItem ();

                    item.Title = folder_name;

                    if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name))
                        item.Image = NSImage.ImageNamed ("NSCaution");
                    else
                        item.Image = NSImage.ImageNamed ("NSFolder");

                    item.Image.Size = new SizeF (16, 16);
                    Tasks [i] = OpenFolderDelegate (folder_name);

                    FolderMenuItems [i] = item;
                    FolderMenuItems [i].Activated += Tasks [i];
                    Menu.AddItem (FolderMenuItems [i]);

                    i++;
                };

            } else {
                FolderMenuItems = new NSMenuItem [1];

                FolderMenuItems [0] = new NSMenuItem () {
                    Title = "No Remote Folders Yet"
                };

                Menu.AddItem (FolderMenuItems [0]);
            }

            Menu.AddItem (NSMenuItem.SeparatorItem);

            SyncMenuItem = new NSMenuItem () {
                Title = "Add Remote Folder…"
            };

                if (!SparkleShare.Controller.FirstRun) {
                    SyncMenuItem.Activated += delegate {
                        InvokeOnMainThread (delegate {
                            NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                            if (SparkleUI.Intro == null) {
                                SparkleUI.Intro = new SparkleIntro ();
                                SparkleUI.Intro.ShowServerForm (true);
                            }

                            if (!SparkleUI.Intro.IsVisible)
                                SparkleUI.Intro.ShowServerForm (true);

                            SparkleUI.Intro.OrderFrontRegardless ();
                            SparkleUI.Intro.MakeKeyAndOrderFront (this);
                        });
                    };
                }

            Menu.AddItem (SyncMenuItem);
            Menu.AddItem (NSMenuItem.SeparatorItem);

            RecentEventsMenuItem = new NSMenuItem () {
                Title = "Show Recent Events"
            };

                if (SparkleShare.Controller.Folders.Count > 0) {
                    RecentEventsMenuItem.Activated += delegate {
                        InvokeOnMainThread (delegate {
                            NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                            if (SparkleUI.EventLog == null)
                                SparkleUI.EventLog = new SparkleEventLog ();

                            SparkleUI.EventLog.OrderFrontRegardless ();
                            SparkleUI.EventLog.MakeKeyAndOrderFront (this);
                        });
                    };
                }

            Menu.AddItem (RecentEventsMenuItem);

            NotificationsMenuItem = new NSMenuItem ();

                if (SparkleShare.Controller.NotificationsEnabled)
                    NotificationsMenuItem.Title = "Turn Notifications Off";
                else
                    NotificationsMenuItem.Title = "Turn Notifications On";

                NotificationsMenuItem.Activated += delegate {
                    SparkleShare.Controller.ToggleNotifications ();

                    InvokeOnMainThread (delegate {
                        if (SparkleShare.Controller.NotificationsEnabled)
                            NotificationsMenuItem.Title = "Turn Notifications Off";
                        else
                            NotificationsMenuItem.Title = "Turn Notifications On";
                    });
                };

            Menu.AddItem (NotificationsMenuItem);
            Menu.AddItem (NSMenuItem.SeparatorItem);

            AboutMenuItem = new NSMenuItem () {
                Title = "About SparkleShare"
            };

                AboutMenuItem.Activated += delegate {
                    InvokeOnMainThread (delegate {
                        NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                        if (SparkleUI.About == null)
                            SparkleUI.About = new SparkleAbout ();

                        SparkleUI.About.OrderFrontRegardless ();
                        SparkleUI.About.MakeKeyAndOrderFront (this);
                        SparkleUI.About.CheckForNewVersion ();
                    });
                };

            Menu.AddItem (AboutMenuItem);

            StatusItem.Menu = Menu;
            StatusItem.Menu.Update ();
        }
Esempio n. 19
0
		// http://lists.apple.com/archives/cocoa-dev/2008/Apr/msg01696.html
		void FlashMenu ()
		{
			var f35 = ((char)0xF726).ToString ();
			var blink = new NSMenuItem ("* blink *") {
				KeyEquivalent = f35,
			};
			var f35Event = NSEvent.KeyEvent (
				NSEventType.KeyDown, System.Drawing.PointF.Empty, NSEventModifierMask.CommandKeyMask, 0, 0,
				NSGraphicsContext.CurrentContext, f35, f35, false, 0);
			AddItem (blink);
			PerformKeyEquivalent (f35Event);
			RemoveItem (blink);
		}
Esempio n. 20
0
		static void SetItemValues (NSMenuItem item, CommandInfo info)
		{
			item.SetTitleWithMnemonic (GetCleanCommandText (info));
			item.Enabled = !IsGloballyDisabled && info.Enabled;
			item.Hidden = !info.Visible;
			SetAccel (item, info.AccelKey);

			if (info.Checked) {
				item.State = NSCellStateValue.On;
			} else if (info.CheckedInconsistent) {
				item.State = NSCellStateValue.Mixed;
			} else {
				item.State = NSCellStateValue.Off;
			}
		}
Esempio n. 21
0
		static void SetAccel (NSMenuItem item, string accelKey)
		{
			uint modeKey;
			Gdk.ModifierType modeMod;
			uint key;
			Gdk.ModifierType mod;

			if (!KeyBindingManager.BindingToKeys (accelKey, out modeKey, out modeMod, out key, out mod)) {
				item.KeyEquivalent = "";
				item.KeyEquivalentModifierMask = (NSEventModifierMask) 0;
				return;
			}

			if (modeKey != 0) {
				LoggingService.LogWarning ("Mac menu cannot display accelerators with mode keys ({0})", accelKey);
				item.KeyEquivalent = "";
				item.KeyEquivalentModifierMask = (NSEventModifierMask) 0;
				return;
			}

			var keyEq = GetKeyEquivalent ((Gdk.Key) key);
			item.KeyEquivalent = keyEq;
			if (keyEq.Length == 0) {
				item.KeyEquivalentModifierMask = 0;
			}

			NSEventModifierMask outMod = 0;
			if ((mod & Gdk.ModifierType.Mod1Mask) != 0) {
				outMod |= NSEventModifierMask.AlternateKeyMask;
				mod ^= Gdk.ModifierType.Mod1Mask;
			}
			if ((mod & Gdk.ModifierType.ShiftMask) != 0) {
				outMod |= NSEventModifierMask.ShiftKeyMask;
				mod ^= Gdk.ModifierType.ShiftMask;
			}
			if ((mod & Gdk.ModifierType.ControlMask) != 0) {
				outMod |= NSEventModifierMask.ControlKeyMask;
				mod ^= Gdk.ModifierType.ControlMask;
			}
			if ((mod & Gdk.ModifierType.MetaMask) != 0) {
				outMod |= NSEventModifierMask.CommandKeyMask;
				mod ^= Gdk.ModifierType.MetaMask;
			}

			if (mod != 0) {
				LoggingService.LogWarning ("Mac menu cannot display accelerators with modifiers {0}", mod);
			}
			item.KeyEquivalentModifierMask = outMod;
		}
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool ())
            {
                StatusItem.Image               = AnimationFrames [0];
                StatusItem.AlternateImage      = AnimationFramesActive [0];
                StatusItem.Image.Size          = new SizeF (16, 16);
                StatusItem.AlternateImage.Size = new SizeF (16, 16);

                Menu = new NSMenu ();
                Menu.AutoEnablesItems = false;

                    StateMenuItem = new NSMenuItem () {
                        Title = StateText,
                        Enabled = false
                    };

                Menu.AddItem (StateMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                    FolderMenuItem = new NSMenuItem () {
                        Title = "SparkleShare"
                    };

                    FolderMenuItem.Activated += delegate {
                        Program.Controller.OpenSparkleShareFolder ();
                    };

                    FolderMenuItem.Image = SparkleShareImage;
                    FolderMenuItem.Image.Size = new SizeF (16, 16);
                    FolderMenuItem.Enabled = true;

                Menu.AddItem (FolderMenuItem);

                    FolderMenuItems = new NSMenuItem [Program.Controller.Folders.Count];

                    if (Controller.Folders.Length > 0) {
                        Tasks = new EventHandler [Program.Controller.Folders.Count];

                        int i = 0;
                        foreach (string folder_name in Program.Controller.Folders) {
                            NSMenuItem item = new NSMenuItem ();

                            item.Title = folder_name;

                            if (Program.Controller.UnsyncedFolders.Contains (folder_name))
                                item.Image = CautionImage;
                            else
                                item.Image = FolderImage;

                            item.Image.Size = new SizeF (16, 16);
                            Tasks [i] = OpenFolderDelegate (folder_name);

                            FolderMenuItems [i] = item;
                            FolderMenuItems [i].Activated += Tasks [i];
                            FolderMenuItem.Enabled = true;

                            i++;
                        };

                    } else {
                        FolderMenuItems = new NSMenuItem [1];

                        FolderMenuItems [0] = new NSMenuItem () {
                            Title   = "No projects yet",
                            Enabled = false
                        };
                    }

                foreach (NSMenuItem item in FolderMenuItems)
                    Menu.AddItem (item);

                Menu.AddItem (NSMenuItem.SeparatorItem);

                    SyncMenuItem = new NSMenuItem () {
                        Title = "Add Hosted Project…",
                        Enabled = true
                    };

                    if (!Program.Controller.FirstRun) {
                        SyncMenuItem.Activated += delegate {
                            InvokeOnMainThread (delegate {
                                NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                                if (SparkleUI.Setup == null) {
                                    SparkleUI.Setup = new SparkleSetup ();
                                    SparkleUI.Setup.Controller.ShowAddPage ();
                                }

                                if (!SparkleUI.Setup.IsVisible)
                                    SparkleUI.Setup.Controller.ShowAddPage ();

                                SparkleUI.Setup.OrderFrontRegardless ();
                                SparkleUI.Setup.MakeKeyAndOrderFront (this);
                            });
                        };
                    }

                Menu.AddItem (SyncMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                    RecentEventsMenuItem = new NSMenuItem () {
                        Title = "Open Recent Events",
                        Enabled = (Controller.Folders.Length > 0)
                    };

                    if (Controller.Folders.Length > 0) {
                        RecentEventsMenuItem.Activated += delegate {
                            InvokeOnMainThread (delegate {
                                NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                                if (SparkleUI.EventLog == null)
                                    SparkleUI.EventLog = new SparkleEventLog ();

                                SparkleUI.EventLog.OrderFrontRegardless ();
                                SparkleUI.EventLog.MakeKeyAndOrderFront (this);
                            });
                        };
                    }

                Menu.AddItem (RecentEventsMenuItem);

                    NotificationsMenuItem = new NSMenuItem () {
                        Enabled = true
                    };

                    if (Program.Controller.NotificationsEnabled)
                        NotificationsMenuItem.Title = "Turn Notifications Off";
                    else
                        NotificationsMenuItem.Title = "Turn Notifications On";

                    NotificationsMenuItem.Activated += delegate {
                        Program.Controller.ToggleNotifications ();

                        InvokeOnMainThread (delegate {
                            if (Program.Controller.NotificationsEnabled)
                                NotificationsMenuItem.Title = "Turn Notifications Off";
                            else
                                NotificationsMenuItem.Title = "Turn Notifications On";
                        });
                    };

                Menu.AddItem (NotificationsMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                    AboutMenuItem = new NSMenuItem () {
                        Title = "About SparkleShare",
                        Enabled = true
                    };

                    AboutMenuItem.Activated += delegate {
                        InvokeOnMainThread (delegate {
                            NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                            if (SparkleUI.About == null)
                                SparkleUI.About = new SparkleAbout ();
                            else
                                 SparkleUI.About.OrderFrontRegardless ();

                        });
                    };

                Menu.AddItem (AboutMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                QuitMenuItem = new NSMenuItem () {
                    Title   = "Quit",
                    Enabled = Controller.QuitItemEnabled
                };

                    QuitMenuItem.Activated += delegate {
                        Program.Controller.Quit ();
                    };

                Menu.AddItem (QuitMenuItem);

                StatusItem.Menu = Menu;
                StatusItem.Menu.Update ();
            }
        }
Esempio n. 23
0
		void PopulateArrayItems (CommandArrayInfo infos, NSMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			foreach (CommandInfo ci in infos) {
				if (ci.IsArraySeparator) {
					var n = NSMenuItem.SeparatorItem;
					n.Hidden = true;
					n.Target = this;
					lastSeparator = n;
					parent.InsertItem (n, index++);
					continue;
				}

				var item = new MDExpandedArrayItem {
					Info = ci,
					Target = this,
					Action = ActionSel,
				};

				if (ci is CommandInfoSet) {
					item.Submenu = new NSMenu ();
					int i = 0;
					NSMenuItem sep = null;
					PopulateArrayItems (((CommandInfoSet)ci).CommandInfos, item.Submenu, ref sep, ref i);
				}
				SetItemValues (item, ci);

				if (!item.Hidden)
					MDMenu.ShowLastSeparator (ref lastSeparator);
				parent.InsertItem (item, index++);
			}
		}
Esempio n. 24
0
        private void CreateContextualMenu()
        {
            _menuItems = new NSMenu("Song Browser");
            var menuItemPlaySong = new NSMenuItem("Play song(s)", PlaySongs);
            var menuItemAddToPlaylist = new NSMenuItem("Add to playlist", AddToPlaylist);

            _menuItems.AddItem(menuItemPlaySong);
            _menuItems.AddItem(menuItemAddToPlaylist);

            _menuHeader = new NSMenu();
            foreach (var column in _control.Columns)
            {
                var menuItem = new NSMenuItem(column.FieldName);
                _menuHeader.AddItem(menuItem);
            }
        }
Esempio n. 25
0
 public bool ValidateMenuItem(NSMenuItem item)
 {
     return Handler.Enabled;
 }
Esempio n. 26
0
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool ())
            {
                this.menu                  = new NSMenu ();
                this.menu.AutoEnablesItems = false;

                this.state_item = new NSMenuItem () {
                    Title   = Controller.StateText,
                    Enabled = false
                };

                this.folder_item = new NSMenuItem () {
                    Title = "SparkleShare"
                };

                this.folder_item.Activated += delegate {
                    Controller.SparkleShareClicked ();
                };

                this.folder_item.Image      = this.sparkleshare_image;
                this.folder_item.Image.Size = new SizeF (16, 16);
                this.folder_item.Enabled    = true;

                this.add_item = new NSMenuItem () {
                    Title   = "Add Hosted Project…",
                    Enabled = true
                };

                this.add_item.Activated += delegate {
                    Controller.AddHostedProjectClicked ();
                };

                this.recent_events_item = new NSMenuItem () {
                    Title   = "Recent Changes…",
                    Enabled = Controller.RecentEventsItemEnabled
                };

                if (Controller.Folders.Length > 0) {
                    this.recent_events_item.Activated += delegate {
                        Controller.RecentEventsClicked ();
                    };
                }

                this.notify_item = new NSMenuItem () {
                    Enabled = (Controller.Folders.Length > 0)
                };

                if (Program.Controller.NotificationsEnabled)
                    this.notify_item.Title = "Turn Notifications Off";
                else
                    this.notify_item.Title = "Turn Notifications On";

                this.notify_item.Activated += delegate {
                    Program.Controller.ToggleNotifications ();

                    InvokeOnMainThread (delegate {
                        if (Program.Controller.NotificationsEnabled)
                            this.notify_item.Title = "Turn Notifications Off";
                        else
                            this.notify_item.Title = "Turn Notifications On";
                    });
                };

                this.about_item = new NSMenuItem () {
                    Title   = "About SparkleShare",
                    Enabled = true
                };

                this.about_item.Activated += delegate {
                    Controller.AboutClicked ();
                };

                this.quit_item = new NSMenuItem () {
                    Title   = "Quit",
                    Enabled = Controller.QuitItemEnabled
                };

                this.quit_item.Activated += delegate {
                    Controller.QuitClicked ();
                };

                this.menu.AddItem (this.state_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.folder_item);

                this.folder_menu_items = new NSMenuItem [Controller.Folders.Length];
                this.submenu_items     = new NSMenuItem [Controller.OverflowFolders.Length];

                if (Controller.Folders.Length > 0) {
                    this.folder_tasks   = new EventHandler [Controller.Folders.Length];
                    this.overflow_tasks = new EventHandler [Controller.OverflowFolders.Length];

                    int i = 0;
                    foreach (string folder_name in Controller.Folders) {
                        NSMenuItem item = new NSMenuItem ();
                        item.Title      = folder_name;

                        if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
                            item.Image   = this.caution_image;
                            item.Submenu = new NSMenu ();

                            NSMenuItem error_item = new NSMenuItem () {
                                Title = Controller.FolderErrors [i]
                            };

                            item.Submenu.AddItem (error_item);

                        } else {
                            item.Image = this.folder_image;
                        }

                        item.Image.Size = new SizeF (16, 16);
                        this.folder_tasks [i] = OpenFolderDelegate (folder_name);

                        this.folder_menu_items [i] = item;
                        this.folder_menu_items [i].Activated += this.folder_tasks [i];

                        i++;
                    };

                    i = 0;
                    foreach (string folder_name in Controller.OverflowFolders) {
                        NSMenuItem item = new NSMenuItem ();
                        item.Title      = folder_name;

                        if (!string.IsNullOrEmpty (Controller.OverflowFolderErrors [i])) {
                            item.Image   = this.caution_image;
                            item.Submenu = new NSMenu ();

                            NSMenuItem error_item = new NSMenuItem () {
                                Title = Controller.OverflowFolderErrors [i]
                            };

                            item.Submenu.AddItem (error_item);

                        } else {
                            item.Image = this.folder_image;
                        }

                        item.Image.Size   = new SizeF (16, 16);
                        this.overflow_tasks [i] = OpenFolderDelegate (folder_name);

                        this.submenu_items [i] = item;
                        this.submenu_items [i].Activated += this.overflow_tasks [i];

                        i++;
                    };

                }

                foreach (NSMenuItem item in this.folder_menu_items)
                    this.menu.AddItem (item);

                if (this.submenu_items.Length > 0) {
                    this.submenu = new NSMenu ();

                    foreach (NSMenuItem item in this.submenu_items)
                        this.submenu.AddItem (item);

                    this.more_item = new NSMenuItem () {
                        Title = "More Projects",
                        Submenu = this.submenu
                    };

                    this.menu.AddItem (NSMenuItem.SeparatorItem);
                    this.menu.AddItem (this.more_item);
                }

                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.add_item);
                this.menu.AddItem (this.recent_events_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.notify_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.about_item);
                this.menu.AddItem (NSMenuItem.SeparatorItem);
                this.menu.AddItem (this.quit_item);

                this.menu.Delegate    = new SparkleStatusIconMenuDelegate ();
                this.status_item.Menu = this.menu;
            }
        }
        public void CreateMenu()
        {
            this.menu = new NSMenu () { AutoEnablesItems = false };

            this.state_item = new NSMenuItem () {
                Title   = Controller.StateText,
                Enabled = false
            };

            this.folder_item = new NSMenuItem () {
                Title   = "SparkleShare",
                Enabled = true
            };

            this.folder_item.Image      = this.sparkleshare_image;
            this.folder_item.Image.Size = new SizeF (16, 16);

            this.add_item = new NSMenuItem () {
                Title   = "Add Hosted Project…",
                Enabled = true
            };

            this.recent_events_item = new NSMenuItem () {
                Title   = "Recent Changes…",
                Enabled = Controller.RecentEventsItemEnabled
            };

            this.about_item = new NSMenuItem () {
                Title   = "About SparkleShare",
                Enabled = true
            };

            this.quit_item = new NSMenuItem () {
                Title   = "Quit",
                Enabled = Controller.QuitItemEnabled
            };

            this.folder_menu_items    = new NSMenuItem [Controller.Folders.Length];
            this.error_menu_items     = new NSMenuItem [Controller.Folders.Length];
            this.try_again_menu_items = new NSMenuItem [Controller.Folders.Length];

            if (Controller.Folders.Length > 0) {
                int i = 0;
                foreach (string folder_name in Controller.Folders) {
                    NSMenuItem item = new NSMenuItem () { Title = folder_name };
                    this.folder_menu_items [i] = item;

                    if (!string.IsNullOrEmpty (Controller.FolderErrors [i])) {
                        item.Image   = this.caution_image;
                        item.Submenu = new NSMenu ();

                        this.error_menu_items [i]       = new NSMenuItem ();
                        this.error_menu_items [i].Title = Controller.FolderErrors [i];

                        this.try_again_menu_items [i]           = new NSMenuItem ();
                        this.try_again_menu_items [i].Title     = "Try Again";
                        this.try_again_menu_items [i].Activated += Controller.TryAgainDelegate (folder_name);;

                        item.Submenu.AddItem (this.error_menu_items [i]);
                        item.Submenu.AddItem (NSMenuItem.SeparatorItem);
                        item.Submenu.AddItem (this.try_again_menu_items [i]);

                    } else {
                        item.Image = this.folder_image;
                        this.folder_menu_items [i].Activated += Controller.OpenFolderDelegate (folder_name);
                    }

                    item.Image.Size = new SizeF (16, 16);
                    i++;
                };
            }

            if (Controller.RecentEventsItemEnabled)
                this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked (); };

            this.add_item.Activated   += delegate { Controller.AddHostedProjectClicked (); };
            this.about_item.Activated += delegate { Controller.AboutClicked (); };
            this.quit_item.Activated  += delegate { Controller.QuitClicked (); };

            this.menu.AddItem (this.state_item);
            this.menu.AddItem (NSMenuItem.SeparatorItem);
            this.menu.AddItem (this.folder_item);

            this.submenu = new NSMenu ();

            this.submenu.AddItem (this.recent_events_item);
            this.submenu.AddItem (this.add_item);
            this.submenu.AddItem (NSMenuItem.SeparatorItem);
            this.submenu.AddItem (this.about_item);

            this.folder_item.Submenu = this.submenu;

            foreach (NSMenuItem item in this.folder_menu_items)
                this.menu.AddItem (item);

            this.menu.AddItem (NSMenuItem.SeparatorItem);
            this.menu.AddItem (this.quit_item);

            this.menu.Delegate    = new SparkleMenuDelegate ();
            this.status_item.Menu = this.menu;
        }
Esempio n. 28
0
        public void CreateMenu()
        {
            using (NSAutoreleasePool a = new NSAutoreleasePool ()) {
                StatusItem.Image               = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0.png");
                StatusItem.AlternateImage      = new NSImage (NSBundle.MainBundle.ResourcePath + "/Pixmaps/idle0-active.png");
                StatusItem.Image.Size          = new SizeF (16, 16);
                StatusItem.AlternateImage.Size = new SizeF (16, 16);

                Menu = new NSMenu ();

                    StateMenuItem = new NSMenuItem () {
                        Title = StateText
                    };

                Menu.AddItem (StateMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                    FolderMenuItem = new NSMenuItem () {
                        Title = "SparkleShare"
                    };

                    FolderMenuItem.Activated += delegate {
                        SparkleShare.Controller.OpenSparkleShareFolder ();
                    };

                    FolderMenuItem.Image = NSImage.ImageNamed ("sparkleshare-mac");
                    FolderMenuItem.Image.Size = new SizeF (16, 16);

                Menu.AddItem (FolderMenuItem);

                    FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count];

                    if (Controller.Folders.Length > 0) {
                        Tasks = new EventHandler [SparkleShare.Controller.Folders.Count];

                        int i = 0;
                        foreach (string folder_name in SparkleShare.Controller.Folders) {
                            NSMenuItem item = new NSMenuItem ();

                            item.Title = folder_name;

                            if (SparkleShare.Controller.UnsyncedFolders.Contains (folder_name))
                                item.Image = NSImage.ImageNamed ("NSCaution");
                            else
                                item.Image = NSImage.ImageNamed ("NSFolder");

                            item.Image.Size = new SizeF (16, 16);
                            Tasks [i] = OpenFolderDelegate (folder_name);

                            FolderMenuItems [i] = item;
                            FolderMenuItems [i].Activated += Tasks [i];

                            i++;
                        };

                    } else {
                        FolderMenuItems = new NSMenuItem [1];

                        FolderMenuItems [0] = new NSMenuItem () {
                            Title = "No Remote Folders Yet"
                        };
                    }

                foreach (NSMenuItem item in FolderMenuItems)
                    Menu.AddItem (item);

                Menu.AddItem (NSMenuItem.SeparatorItem);

                    SyncMenuItem = new NSMenuItem () {
                        Title = "Add Remote Folder…"
                    };

                    if (!SparkleShare.Controller.FirstRun) {
                        SyncMenuItem.Activated += delegate {
                            InvokeOnMainThread (delegate {
                                NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                                if (SparkleUI.Setup == null) {
                                    SparkleUI.Setup = new SparkleSetup ();
                                    SparkleUI.Setup.Controller.ShowAddPage ();
                                }

                                if (!SparkleUI.Setup.IsVisible)
                                    SparkleUI.Setup.Controller.ShowAddPage ();

                                SparkleUI.Setup.OrderFrontRegardless ();
                                SparkleUI.Setup.MakeKeyAndOrderFront (this);
                            });
                        };
                    }

                Menu.AddItem (SyncMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                    RecentEventsMenuItem = new NSMenuItem () {
                        Title = "Show Recent Events"
                    };

                    if (Controller.Folders.Length > 0) {
                        RecentEventsMenuItem.Activated += delegate {
                            InvokeOnMainThread (delegate {
                                NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                                if (SparkleUI.EventLog == null)
                                    SparkleUI.EventLog = new SparkleEventLog ();

                                SparkleUI.EventLog.OrderFrontRegardless ();
                                SparkleUI.EventLog.MakeKeyAndOrderFront (this);
                            });
                        };
                    }

                Menu.AddItem (RecentEventsMenuItem);

                    NotificationsMenuItem = new NSMenuItem ();

                    if (SparkleShare.Controller.NotificationsEnabled)
                        NotificationsMenuItem.Title = "Turn Notifications Off";
                    else
                        NotificationsMenuItem.Title = "Turn Notifications On";

                    NotificationsMenuItem.Activated += delegate {
                        SparkleShare.Controller.ToggleNotifications ();

                        InvokeOnMainThread (delegate {
                            if (SparkleShare.Controller.NotificationsEnabled)
                                NotificationsMenuItem.Title = "Turn Notifications Off";
                            else
                                NotificationsMenuItem.Title = "Turn Notifications On";
                        });
                    };

                Menu.AddItem (NotificationsMenuItem);
                Menu.AddItem (NSMenuItem.SeparatorItem);

                    AboutMenuItem = new NSMenuItem () {
                        Title = "About SparkleShare"
                    };

                    AboutMenuItem.Activated += delegate {
                        InvokeOnMainThread (delegate {
                            NSApplication.SharedApplication.ActivateIgnoringOtherApps (true);

                            if (SparkleUI.About == null)
                                SparkleUI.About = new SparkleAbout ();
                            else
                                 SparkleUI.About.OrderFrontRegardless ();

                        });
                    };

                Menu.AddItem (AboutMenuItem);

                StatusItem.Menu = Menu;
                StatusItem.Menu.Update ();
            }
        }
Esempio n. 29
0
 public override void MenuWillHighlightItem(NSMenu menu, NSMenuItem item)
 {
 }
		//strongly typed window accessor
		public override void AwakeFromNib ()
		{
			// add the searchMenu to this control, allowing recent searches to be added.
			//
			// note that we could build this menu inside our nib, but for clarity we're
			// building the menu in code to illustrate the use of tags:
			//		NSSearchFieldRecentsTitleMenuItemTag, NSSearchFieldNoRecentsMenuItemTag, etc.
			//			
			if (searchField.RespondsToSelector(new Selector("setRecentSearches:")))
			{
				NSMenu searchMenu = new NSMenu("Search Menu") {
					AutoEnablesItems = true
				};
				
				var item = new NSMenuItem("Custom","",(o,e) => actionMenuItem());
				searchMenu.InsertItem(item,0);
				
				var separator = NSMenuItem.SeparatorItem;
				searchMenu.InsertItem(separator,1);
				
				var recentsTitleItem = new NSMenuItem("Recent Searches","");
				// tag this menu item so NSSearchField can use it and respond to it appropriately
				recentsTitleItem.Tag = NSSearchFieldRecentsTitleMenuItemTag;
				searchMenu.InsertItem (recentsTitleItem,2);

				var norecentsTitleItem = new NSMenuItem("No recent searches","");
				// tag this menu item so NSSearchField can use it and respond to it appropriately
				norecentsTitleItem.Tag = NSSearchFieldNoRecentsMenuItemTag;
				searchMenu.InsertItem (norecentsTitleItem,3);
				
				var recentsItem = new NSMenuItem("Recents","");
				// tag this menu item so NSSearchField can use it and respond to it appropriately
				recentsItem.Tag = NSSearchFieldRecentsMenuItemTag;
				searchMenu.InsertItem (recentsItem,4);

				var separatorItem = NSMenuItem.SeparatorItem;
				// tag this menu item so NSSearchField can use it, by hiding/show it appropriately:
				separatorItem.Tag = NSSearchFieldRecentsTitleMenuItemTag;
				searchMenu.InsertItem (separatorItem,5);

				var clearItem = new NSMenuItem ("Clear", "");
				// tag this menu item so NSSearchField can use it
				clearItem.Tag = NSSearchFieldClearRecentsMenuItemTag;
				searchMenu.InsertItem (clearItem, 6);
				
				var searchCell = searchField.Cell;
				searchCell.MaximumRecents = 20;
				searchCell.SearchMenuTemplate = searchMenu;
				
				// with lamda
				//searchField.ControlTextDidChange += (o,e) => controlTextDidChange((NSNotification)o);
				// or delegate
				searchField.Changed += delegate (object sender, EventArgs e) {
					handleTextDidChange ((NSNotification) sender);
				};
				searchField.DoCommandBySelector = handleCommandSelectors;
				searchField.GetCompletions = handleFilterCompletions;
			}
				
			// build the list of keyword strings for our type completion dropdown list in NSSearchField
			builtInKeywords = new List<string>() {"Favorite", "Favorite1", "Favorite11", "Favorite3", "Vacations1", "Vacations2",
					"Hawaii", "Family", "Important", "Important2", "Personal"};
		}