Example #1
0
        public void Update(MDMenu parent, ref int index)
        {
            var info = manager.GetCommandInfo(ce.CommandId, new CommandTargetRoute(initialCommandTarget));

            if (lastInfo != info)
            {
                if (lastInfo != null)
                {
                    lastInfo.CancelAsyncUpdate();
                }
                lastInfo = info;
                if (lastInfo.IsUpdatingAsynchronously)
                {
                    lastInfo.Changed += delegate {
                        var ind = FindMeInParent(parent);
                        if (info == lastInfo)
                        {
                            Update(parent, ref ind, info);
                            parent.UpdateSeparators();
                        }
                    };
                }
            }
            Update(parent, ref index, info);
        }
Example #2
0
        public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
        {
            var info = manager.GetCommandInfo(ce.CommandId, new CommandTargetRoute(initialCommandTarget));

            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);
        }
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			Enabled = true;
			Hidden = Submenu != NSApplication.SharedApplication.ServicesMenu;
			if (!Hidden)
				MDMenu.ShowLastSeparator (ref lastSeparator);
		}
Example #4
0
 public void Update(MDMenu parent, ref int index)
 {
     if (!string.IsNullOrEmpty(ce.OverrideLabel))
     {
         Title = ce.OverrideLabel;
     }
 }
Example #5
0
        void Update(MDMenu parent, ref int index, CommandInfo info)
        {
            if (!isArrayItem)
            {
                SetItemValues(this, info, ce.DisabledVisible, ce.OverrideLabel);
                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--;
                }
            }

            index++;
            PopulateArrayItems(info.ArrayInfo, parent, ref index);
        }
Example #6
0
        void PopulateArrayItems(CommandArrayInfo infos, NSMenu parent, ref NSMenuItem lastSeparator, ref int index)
        {
            if (infos == null)
            {
                return;
            }

            foreach (CommandInfo ci in infos)
            {
                if (ci.IsArraySeparator)
                {
                    var n = NSMenuItem.SeparatorItem;
                    n.Hidden      = true;
                    n.Target      = this;
                    lastSeparator = n;
                    if (parent.Count > index)
                    {
                        parent.InsertItem(n, index);
                    }
                    else
                    {
                        parent.AddItem(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, true);

                if (!item.Hidden)
                {
                    MDMenu.ShowLastSeparator(ref lastSeparator);
                }
                if (parent.Count > index)
                {
                    parent.InsertItem(item, index);
                }
                else
                {
                    parent.AddItem(item);
                }
                index++;
            }
            index--;
        }
 public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
 {
     Enabled = true;
     Hidden  = Submenu != NSApplication.SharedApplication.ServicesMenu;
     if (!Hidden)
     {
         MDMenu.ShowLastSeparator(ref lastSeparator);
     }
 }
		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);
			}
		}
Example #9
0
 int FindMeInParent(MDMenu parent)
 {
     for (int n = 0; n < parent.Count; n++)
     {
         if (parent.ItemAt(n) == this)
         {
             return(n);
         }
     }
     return(-1);
 }
Example #10
0
 public void Update(MDMenu parent, ref int index)
 {
     ((MDMenu)Submenu).UpdateCommands();
     if (ces.AutoHide)
     {
         Hidden = Submenu.ItemArray().All(item => item.Hidden);
     }
     else
     {
         Enabled = Submenu.ItemArray().Any(item => !item.Hidden);
     }
 }
Example #11
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);
     }
 }
Example #12
0
        public void Update(MDMenu parent, ref int index)
        {
            var info = manager.GetCommandInfo(ce.CommandId, new CommandTargetRoute(initialCommandTarget));

            if (lastInfo != info)
            {
                if (lastInfo != null)
                {
                    lastInfo.CancelAsyncUpdate();
                    lastInfo.Changed -= OnLastInfoChanged;
                }
                lastInfo = info;
                if (lastInfo.IsUpdatingAsynchronously)
                {
                    lastInfo.Changed += OnLastInfoChanged;
                }
            }
            Update(parent, ref index, info);
        }
Example #13
0
 public void Update(MDMenu parent, ref int index)
 {
     try {
         var info = manager.GetCommandInfo(ce.CommandId, new CommandTargetRoute(initialCommandTarget));
         if (lastInfo != info)
         {
             if (lastInfo != null)
             {
                 lastInfo.CancelAsyncUpdate();
                 lastInfo.Changed -= OnLastInfoChanged;
             }
             lastInfo = info;
             if (lastInfo.IsUpdatingAsynchronously)
             {
                 lastInfo.Changed += OnLastInfoChanged;
             }
         }
         Update(parent, ref index, info);
     } catch (Exception ex) {
         LoggingService.LogInternalError($"Updating MDMenu for {ce.CommandId} failed.", ex);
     }
 }
Example #14
0
 public void Update(MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
 {
     MDMenu.ShowLastSeparator(ref lastSeparator);
 }
Example #15
0
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			var info = manager.GetCommandInfo (ce.CommandId, new CommandTargetRoute (initialCommandTarget));

			if (!isArrayItem) {
				SetItemValues (this, info, ce.DisabledVisible, ce.OverrideLabel);
				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--;
				}
			}

			index++;
			PopulateArrayItems (info.ArrayInfo, parent, ref lastSeparator, ref index);
		}
Example #16
0
 public void Update(MDMenu parent, ref int index)
 {
 }
Example #17
0
 public void Update(MDMenu parent, ref int index)
 {
     Enabled = true;
     Hidden  = Submenu != NSApplication.SharedApplication.ServicesMenu;
 }
		public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index)
		{
			MDMenu.ShowLastSeparator (ref lastSeparator);
		}