Exemple #1
0
 /// <summary>
 /// 设置当前页面是否选中
 /// </summary>
 /// <param name="isSelected"></param>
 public void SetSelected(bool isSelected)
 {
     m_isSelected = isSelected;
     if (Type == SubMenuItemIconType.Folder || Type == SubMenuItemIconType.FolderOpen)
     {
         if (isSelected)
         {
             ((StackPanel)this.Tag).Visibility = System.Windows.Visibility.Visible;
             Type = SubMenuItemIconType.FolderOpen;
             ((MenuItem)this.ParentNode).IsSelected = true;
             ((MenuItem)((MenuItem)this.ParentNode).ParentNode).IsSelected = true;
         }
         else
         {
             ((StackPanel)this.Tag).Visibility = System.Windows.Visibility.Collapsed;
             Type = SubMenuItemIconType.Folder;
             ((MenuItem)this.ParentNode).IsSelected = false;
             ((MenuItem)((MenuItem)this.ParentNode).ParentNode).IsSelected = false;
         }
     }
     else
     {
         if (isSelected)
         {
             TextBlockItem_MouseEnter(null, null);
             if (this.ParentNode is SubMenuItem)
             {
                 ((SubMenuItem)this.ParentNode).SetSelected(isSelected);
                 ((MenuItem)((SubMenuItem)this.ParentNode).ParentNode).IsSelected = true;
                 ((MenuItem)((MenuItem)((SubMenuItem)this.ParentNode).ParentNode).ParentNode).IsSelected = true;
             }
             else
             {
                 ((MenuItem)this.ParentNode).IsSelected = true;
                 ((MenuItem)((MenuItem)this.ParentNode).ParentNode).IsSelected = true;
             }
         }
         else
         {
             TextBlockItem_MouseLeave(null, null);
             if (this.ParentNode is SubMenuItem)
             {
                 ((SubMenuItem)this.ParentNode).SetSelected(isSelected);
                 ((MenuItem)((SubMenuItem)this.ParentNode).ParentNode).IsSelected = false;
                 ((MenuItem)((MenuItem)((SubMenuItem)this.ParentNode).ParentNode).ParentNode).IsSelected = false;
             }
             else
             {
                 ((MenuItem)this.ParentNode).IsSelected = false;
                 ((MenuItem)((MenuItem)this.ParentNode).ParentNode).IsSelected = false;
             }
         }
     }
 }
Exemple #2
0
        void SetIconImage(SubMenuItemIconType type)
        {
            if (ImageHeart != null)
            {
                switch (type)
                {
                case SubMenuItemIconType.Folder:
                {
                    ImageHeart.Visibility      = System.Windows.Visibility.Collapsed;
                    ImageHeartEmpty.Visibility = System.Windows.Visibility.Collapsed;
                    ImageFolder.Visibility     = System.Windows.Visibility.Visible;
                    ImageFolderOpen.Visibility = System.Windows.Visibility.Collapsed;
                }
                break;

                case SubMenuItemIconType.FolderOpen:
                {
                    ImageHeart.Visibility      = System.Windows.Visibility.Collapsed;
                    ImageHeartEmpty.Visibility = System.Windows.Visibility.Collapsed;
                    ImageFolder.Visibility     = System.Windows.Visibility.Collapsed;
                    ImageFolderOpen.Visibility = System.Windows.Visibility.Visible;
                }
                break;

                case SubMenuItemIconType.Heart:
                {
                    ImageHeart.Visibility      = System.Windows.Visibility.Visible;
                    ImageHeartEmpty.Visibility = System.Windows.Visibility.Collapsed;
                    ImageFolder.Visibility     = System.Windows.Visibility.Collapsed;
                    ImageFolderOpen.Visibility = System.Windows.Visibility.Collapsed;
                }
                break;

                case SubMenuItemIconType.HeartEmpty:
                {
                    ImageHeart.Visibility      = System.Windows.Visibility.Collapsed;
                    ImageHeartEmpty.Visibility = System.Windows.Visibility.Visible;
                    ImageFolder.Visibility     = System.Windows.Visibility.Collapsed;
                    ImageFolderOpen.Visibility = System.Windows.Visibility.Collapsed;
                }
                break;
                }
            }
        }