Beispiel #1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            m_menuOptionsView = (ScrollViewer)GetTemplateChild("MenuOptionsView");

            m_resultsSpinner        = (Grid)GetTemplateChild("SearchResultsSpinner");
            m_resultsCount          = (TextBlock)GetTemplateChild("SearchResultCount");
            m_resultsCountContainer = (Grid)GetTemplateChild("SearchResultCountContainer");
            m_menuViewContainer     = (Grid)GetTemplateChild("SearchMenuViewContainer");
            m_backgroundRectangle   = (Rectangle)GetTemplateChild("BackgroundRect");
            m_searchBox             = (Grid)GetTemplateChild("SearchBox");
            m_searchArrow           = (FrameworkElement)GetTemplateChild("SearchArrow");
            m_resultsSeparator      = (FrameworkElement)GetTemplateChild("ResultsListSeparator");
            m_searchResultsFade     = (Image)GetTemplateChild("SearchResultsFade");
            m_searchResultsButtonAndFadeContainer = (Grid)GetTemplateChild("SearchResultsButtonAndFadeContainer");

            m_searchResultsScrollButton                    = (RepeatButton)GetTemplateChild("SearchResultsScrollButton");
            m_searchResultsScrollButton.Click             += OnResultsScrollButtonMouseDown;
            m_searchResultsScrollButton.PreviewMouseWheel += OnResultsMenuScrollWheel;
            m_searchResultsScrollButton.MouseUp           += OnResultsScrollButtonMouseUp;
            m_searchResultsScrollButton.MouseLeave        += OnResultsScrollButtonMouseLeave;

            m_resultsClearButton        = (Button)GetTemplateChild("SearchClear");
            m_resultsClearButton.Click += OnResultsClear;

            m_list = (ListBox)GetTemplateChild("SecondaryMenuItemList");
            m_menuListClickHandler    = new ControlClickHandler(OnMenuListItemSelected, m_list);
            m_list.PreviewMouseWheel += OnMenuScrollWheel;

            m_resultsList                    = (ListBox)GetTemplateChild("SearchResultsList");
            m_resultsList.TouchDown         += new EventHandler <TouchEventArgs>(OnSearchResultsListTouchDown);
            m_resultsList.TouchUp           += new EventHandler <TouchEventArgs>(OnSearchResultsListTouchUp);
            m_resultsList.TouchLeave        += new EventHandler <TouchEventArgs>(OnSearchResultsListTouchLeave);
            m_resultsList.LostTouchCapture  += new EventHandler <TouchEventArgs>(OnSearchResultsListLostTouchCapture);
            m_resultsListClickHandler        = new ControlClickHandler(OnResultsListItemsSelected, m_resultsList);
            m_resultsList.PreviewMouseWheel += OnResultsMenuScrollWheel;

            m_menuIcon     = (Button)GetTemplateChild("SecondaryMenuDragTabView");
            m_menuIconGrid = (Grid)GetTemplateChild("SearchIconGrid");

            m_menuIcon.Click += OnIconClick;

            m_editText              = (TextBox)GetTemplateChild("SearchInputBox");
            m_editText.KeyDown     += OnKeyDown;
            m_editText.GotFocus    += OnSearchBoxSelected;
            m_editText.LostFocus   += OnSearchBoxUnSelected;
            m_editText.TextChanged += OnSearchBoxTextChanged;


            m_mainContainer = (Grid)GetTemplateChild("SerchMenuMainContainer");

            var itemShutterOpenStoryboard  = ((Storyboard)Template.Resources["ItemShutterOpen"]).Clone();
            var itemShutterCloseStoryboard = ((Storyboard)Template.Resources["ItemShutterClose"]).Clone();

            var slideInItemStoryboard  = ((Storyboard)Template.Resources["SlideInNewItems"]).Clone();
            var slideOutItemStoryboard = ((Storyboard)Template.Resources["SlideOutOldItems"]).Clone();

            string searchAnimString = "SearchAnim";

            string openMenuViewIconString = "OpenSearchViewIcon";

            m_openMenuIconAnim = ((Storyboard)Template.Resources[openMenuViewIconString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_openMenuIconAnim, searchAnimString + openMenuViewIconString);
            string closeMenuViewIconString = "CloseSearchViewIcon";

            m_closeMenuIconAnim = ((Storyboard)Template.Resources[closeMenuViewIconString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_closeMenuIconAnim, searchAnimString + closeMenuViewIconString);

            string openMenuContainerString = "OpenSearchContainer";

            m_openMenuContainerAnim = ((Storyboard)Template.Resources[openMenuContainerString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_openMenuContainerAnim, searchAnimString + openMenuContainerString);
            string closeMenuContainerString = "CloseSearchContainer";

            m_closeMenuContainerAnim = ((Storyboard)Template.Resources[closeMenuContainerString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_closeMenuContainerAnim, searchAnimString + closeMenuContainerString);

            string openBackgroundRectString = "OpenBackgroundRect";

            m_openBackgroundRect = ((Storyboard)Template.Resources[openBackgroundRectString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_openBackgroundRect, searchAnimString + openBackgroundRectString);
            string closeBackgroundRectString = "CloseBackgroundRect";

            m_closeBackgroundRect = ((Storyboard)Template.Resources[closeBackgroundRectString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_closeBackgroundRect, searchAnimString + closeBackgroundRectString);

            string openSearchInputBoxString = "OpenSearchInputBox";

            m_searchInputOpen = ((Storyboard)Template.Resources[openSearchInputBoxString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_searchInputOpen, searchAnimString + openSearchInputBoxString);
            m_searchInputClose = ((Storyboard)Template.Resources["CloseSearchInputBox"]).Clone();

            m_searchInputTextOpen  = ((Storyboard)Template.Resources["OpenSearchInputBoxText"]).Clone();
            m_searchInputTextClose = ((Storyboard)Template.Resources["CloseSearchInputBoxText"]).Clone();

            string openSearchArrowString = "OpenSearchArrow";

            m_searchArrowOpen = ((Storyboard)Template.Resources[openSearchArrowString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_searchArrowOpen, searchAnimString + openSearchArrowString);
            string closeSearchArrowString = "CloseSearchArrow";

            m_searchArrowClosed = ((Storyboard)Template.Resources[closeSearchArrowString]).Clone();
            XamlHelpers.UpdateThicknessAnimationMarginValue(m_searchArrowClosed, searchAnimString + closeSearchArrowString);

            m_adapter           = new MenuListAdapter(false, m_list, slideInItemStoryboard, slideOutItemStoryboard, itemShutterOpenStoryboard, itemShutterCloseStoryboard, "SubMenuItemPanel", m_isInKioskMode);
            m_resultListAdapter = new MenuListAdapter(false, m_resultsList, slideInItemStoryboard, slideOutItemStoryboard, itemShutterOpenStoryboard, itemShutterCloseStoryboard, "SearchResultPanel", m_isInKioskMode);

            m_scrollSpeed = (double)Application.Current.Resources["ScrollViewButtonScrollSpeed"];

            m_searchIconOffImageSource   = (ImageSource)Application.Current.Resources["ButtonSearchOffImage"];
            m_searchIconOnImageSource    = (ImageSource)Application.Current.Resources["ButtonSearchOnImage"];
            m_closeIconOffImageSource    = (ImageSource)Application.Current.Resources["ButtonSearchCloseOffImage"];
            m_closeIconOnImageSource     = (ImageSource)Application.Current.Resources["ButtonSearchCloseOnImage"];
            SearchMenuIconOffImageSource = m_searchIconOffImageSource;
            SearchMenuIconOnImageSource  = m_searchIconOnImageSource;
        }