Exemplo n.º 1
0
 bool SetFavoriteIcon(ItemData value, SubMenuItem subItem)
 {
     if (value == subItem.DataContext)
     {
         if (value.IsFavorited)
         {
             subItem.Type = SubMenuItemIconType.Heart;
         }
         else
         {
             subItem.Type = SubMenuItemIconType.HeartEmpty;
         }
         subItem.NotifyDataSource();
         return(true);
     }
     return(false);
 }
Exemplo n.º 2
0
        void BuildQueryResult(List <ItemData> queryResult)
        {
            StackPanelContent3.Children.Clear();
            foreach (var item in queryResult)
            {
                var menuItem3 = new SubMenuItem {
                    Text = item.Name, DataContext = item
                };
                if (item.IsFavorited)
                {
                    menuItem3.Type = SubMenuItemIconType.Heart;
                }
                else
                {
                    menuItem3.Type = SubMenuItemIconType.HeartEmpty;
                }

                menuItem3.ClickICON = (obj, args) =>
                {
                    ((ItemData)menuItem3.DataContext).IsFavorited = !((ItemData)menuItem3.DataContext).IsFavorited;
                    if (((ItemData)menuItem3.DataContext).IsFavorited)
                    {
                        menuItem3.Type = SubMenuItemIconType.Heart;
                    }
                    else
                    {
                        menuItem3.Type = SubMenuItemIconType.HeartEmpty;
                    }
                    NotifyMenuArea((ItemData)menuItem3.DataContext);
                };
                menuItem3.ClickItem = (obj, args) =>
                {
                    if (Navigating != null)
                    {
                        Navigating(this, new NavigateArgs {
                            Data = (ItemData)menuItem3.DataContext
                        });
                    }
                };
                StackPanelContent3.Children.Add(menuItem3);
            }
        }
Exemplo n.º 3
0
 private void Bind(ItemData value)
 {
     SubMenuItemTitle.Text        = value.Name;
     SubMenuItemTitle.DataContext = value;
     SubMenuItemTitle.Menu        = Menu;
     SubMenuItemTitle.SubPanel    = this;
     SubMenuItemTitle.Tag         = StackPanelContent;
     SubMenuItemTitle.ParentNode  = ParentNode;
     if (value.SubItems != null && value.SubItems.Count > 0)
     {
         SubMenuItemTitle.Type       = SubMenuItemIconType.Folder;
         SubMenuItemTitle.ParentNode = ParentNode;
         foreach (var item in value.SubItems)
         {
             var subMenuItem = new SubMenuItem {
                 Text = item.Name, DataContext = item, Menu = Menu, SubPanel = this, ParentNode = SubMenuItemTitle
             };
             subMenuItem.ClickICON = (obj, args) =>
             {
                 var itemInner = subMenuItem.DataContext as ItemData;
                 itemInner.IsFavorited = !itemInner.IsFavorited;
                 if (itemInner.IsFavorited)
                 {
                     subMenuItem.Type = SubMenuItemIconType.Heart;
                 }
                 else
                 {
                     subMenuItem.Type = SubMenuItemIconType.HeartEmpty;
                 }
                 NotifyQuickSearchArea(itemInner);
             };
             subMenuItem.ClickItem = (obj, args) =>
             {
                 if (Menu.Navigating != null)
                 {
                     Menu.Navigating(this, new NavigateArgs {
                         Data = (ItemData)subMenuItem.DataContext
                     });
                 }
                 ComponentFactory.GetComponent <IUserProfile>().Set(UserProfileKey.Key_TabStatus, true);
             };
             StackPanelContent.Children.Add(subMenuItem);
             if (item.IsFavorited)
             {
                 subMenuItem.Type = SubMenuItemIconType.Heart;
             }
             if (s_lastMenuItemData != null && s_lastMenuItemData.Id == item.Id)
             {
                 Menu.LastSubMenuItemInAll = subMenuItem;
                 subMenuItem.SetSelected(true);
             }
         }
         SubMenuItemTitle.ClickICON = (obj, args) =>
         {
             if (StackPanelContent.Visibility == Visibility.Visible)
             {
                 StackPanelContent.Visibility = System.Windows.Visibility.Collapsed;
                 SubMenuItemTitle.Type        = SubMenuItemIconType.Folder;
             }
             else
             {
                 SubMenuItemTitle.Type        = SubMenuItemIconType.FolderOpen;
                 StackPanelContent.Visibility = System.Windows.Visibility.Visible;
             }
         };
         SubMenuItemTitle.ClickItem = (obj, args) =>
         {
             if (StackPanelContent.Visibility == Visibility.Visible)
             {
                 StackPanelContent.Visibility = System.Windows.Visibility.Collapsed;
                 SubMenuItemTitle.Type        = SubMenuItemIconType.Folder;
             }
             else
             {
                 StackPanelContent.Visibility = System.Windows.Visibility.Visible;
                 SubMenuItemTitle.Type        = SubMenuItemIconType.FolderOpen;
             }
         };
     }
     else
     {
         SubMenuItemTitle.ClickICON = (obj, args) =>
         {
             m_itemBinding.IsFavorited = !m_itemBinding.IsFavorited;
             if (m_itemBinding.IsFavorited)
             {
                 SubMenuItemTitle.Type = SubMenuItemIconType.Heart;
             }
             else
             {
                 SubMenuItemTitle.Type = SubMenuItemIconType.HeartEmpty;
             }
             NotifyQuickSearchArea(m_itemBinding);
         };
         SubMenuItemTitle.ClickItem = (obj, args) =>
         {
             if (Menu.Navigating != null)
             {
                 Menu.Navigating(this, new NavigateArgs {
                     Data = m_itemBinding
                 });
             }
             ComponentFactory.GetComponent <IUserProfile>().Set(UserProfileKey.Key_TabStatus, true);
         };
         if (m_itemBinding.IsFavorited)
         {
             SubMenuItemTitle.Type = SubMenuItemIconType.Heart;
         }
     }
     if (s_lastMenuItemData != null && s_lastMenuItemData.Id == value.Id)
     {
         Menu.LastSubMenuItemInAll = SubMenuItemTitle;
         SubMenuItemTitle.SetSelected(true);
     }
 }