Beispiel #1
0
 private void HandleItemRegister(ItemRegister itemRegister)
 {
     if (itemRegisters.Add(itemRegister))
     {
         AddItemRegister?.Invoke(this, itemRegister);
     }
 }
Beispiel #2
0
 public Registers RegisterMethod(ItemRegister methodRegister)
 {
     methodRegisters.Add(methodRegister);
     //new Thread(() =>
     ItemRegistered?.Invoke(methodRegister);
     //).Start();
     return(this);
 }
Beispiel #3
0
        public void AddRegister(ItemRegister itemRegister)
        {
            MenuItem current = this;

            foreach (var item in itemRegister.Directory.Concat(new[] { itemRegister.Name }))
            {
                LocaleString?ls = item is LocaleString
                    ? (LocaleString?)item
                    : null;

                string key = ls.HasValue
                    ? ls.Value.Key
                    : (string)item;

                if (current.childs.TryGetValue(key, out MenuItem methodItem))
                {
                    current = methodItem;
                }
                else
                {
                    MenuItem newItem = new MenuItem
                    {
                        Name         = key,
                        Parent       = current,
                        LocaleString = ls,
                    };
                    current.childs.Add(key, newItem);
                    int counter = 0;
                    while (PlatformRegister.Instance == null || PlatformRegister.Instance.MainMenuElement == null)
                    {
                        Thread.Sleep(500);
                        if (counter++ == 15)
                        {
                            break;
                        }
                    }
                    newItem.MenuElement = PlatformRegister.Instance.CreateMenuItem(current.MenuElement, newItem);
                    current.AddChild?.Invoke(current, newItem);
                    current = newItem;
                }
            }
            //current.AddItem(itemRegister);
            current.HandleItemRegister(itemRegister);
        }
Beispiel #4
0
 private static void Registers_MethodRegistered(ItemRegister obj)
 {
     RootMethodItem.AddRegister(obj);
 }