Beispiel #1
0
        //列表同步响应
        private void OnListScrollChanged(object sender, ScrollChangedEventArgs e)
        {
            ListView list = sender as ListView;

            if (null == list)
            {
                return;
            }

            ListViewAutomationPeer lvapRemote = new ListViewAutomationPeer(list);
            var svaplvapRemote   = lvapRemote.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
            var scrolllvapRemote = svaplvapRemote.Owner as ScrollViewer;

            ListViewAutomationPeer lvap = null;

            if ("LocalListView" == list.Name)
            {
                lvap = new ListViewAutomationPeer(RemoteListView);
            }
            else if ("RemoteListView" == list.Name)
            {
                lvap = new ListViewAutomationPeer(LocalListView);
            }

            var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
            var scroll = svap.Owner as ScrollViewer;

            scroll.ScrollToVerticalOffset(scrolllvapRemote.VerticalOffset);
            scroll.ScrollToHorizontalOffset(scrolllvapRemote.HorizontalOffset);
        }
        //法师下一页预览
        private void DownPage_Button_Click(object sender, RoutedEventArgs e)
        {
            ListViewAutomationPeer lvap  =  new ListViewAutomationPeer(MonkInfo_ListView);
            var svap    =  lvap.GetPattern(PatternInterface.Scroll)  as ScrollViewerAutomationPeer;
            var scroll  =  svap.Owner as ScrollViewer;
            //scroll. .LineRight();

            if ((m_MonkList.Count > 2) && (scroll.HorizontalOffset / 532) <= (m_MonkList.Count - 3))
            {
                if ((scroll.HorizontalOffset / 532) == (m_MonkList.Count - 3))
                {
                    Image img = new Image();
                    img.Source = new BitmapImage(new Uri("pack://SiteOfOrigin:,,,/Res/btn03.png"));
                    this.DownPage_Button.Content = img;
                }

                Image img2 = new Image();
                img2.Source = new BitmapImage(new Uri("pack://SiteOfOrigin:,,,/Res/btn02.png"));
                this.UpPage_Button.Content = img2;

//                 dispatcherSrcollBarTimer.Tick += delegate
//                 {
//                     m_nScrollMove++;
//                     scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + 53 * m_nScrollMove);
//                     if (m_nScrollMove == 10)
//                     {
//                         m_nScrollMove = 0;
//                         dispatcherSrcollBarTimer.Stop();
//                         return;
//                     }
//                 };
//                 dispatcherSrcollBarTimer.Start();
                scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + 532);
            }
        }
        //法师上一页预览
        private void UpPage_Button_Click_1(object sender, RoutedEventArgs e)
        {
            try{
                ListViewAutomationPeer lvap = new ListViewAutomationPeer(MonkInfo_ListView);
                var    svap            = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                var    scroll          = svap.Owner as ScrollViewer;
                double nListViewOffset = scroll.ViewportWidth;
                if ((m_MonkList.Count > 1) && (scroll.HorizontalOffset / nListViewOffset) >= 0)
                {
                    int nPosOf = (int)(scroll.HorizontalOffset / nListViewOffset);
                    if ((scroll.HorizontalOffset < nListViewOffset) ||
                        (scroll.HorizontalOffset / nListViewOffset) == 1)
                    {
                        Image img = new Image();
                        img.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://SiteOfOrigin:,,,/Res/Page19/btn04.png"));
                    this.DownPage_Button.Content = img2;

                    if (nPosOf >= 0 && (nPosOf - 1) >= 0)
                    {
                        m_strMonkinfoDetail = m_MonkinfoDetail[nPosOf - 1];
                    }

                    scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset - nListViewOffset);
                }
            }
            catch (Exception ex) { }
        }
        private void Activity_Detail_Click(object sender, RoutedEventArgs e)
        {
            string strDetail = @"";

            if (pWebData != null)
            {
                ListViewAutomationPeer lvap = new ListViewAutomationPeer(ActivityInfo_ListView);
                var svap      = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                var scroll    = svap.Owner as ScrollViewer;
                int nSelIndex = (int)scroll.ContentHorizontalOffset / 922;

                int n = 0;
                foreach (ActivityList temp in m_pActivityListInfo)
                {
                    if (nSelIndex == n)
                    {
                        strDetail = temp.ActivityMainDetail;
                        break;
                    }
                    n++;
                }

                /*ActivityInfo_ListView.SelectedItems(nSelIndex);*/

                //strDetail = pWebData.m_pActivityInfoData.body.data.info.ToString();
            }

            Introduction IntroductionWin = new Introduction(strDetail, 2);

            //IntroductionWin.Owner = ParentWindow;
            IntroductionWin.ShowDialog();
        }
        private void Activity_Detail_Click(object sender, RoutedEventArgs e)
        {
            string strDetail = @"";

            if (pWebData != null)
            {
                ListViewAutomationPeer lvap = new ListViewAutomationPeer(ActivityInfo_ListView);
                var    svap            = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                var    scroll          = svap.Owner as ScrollViewer;
                double nListViewOffset = scroll.ViewportWidth;
                int    nSelIndex       = (int)scroll.ContentHorizontalOffset / (int)nListViewOffset;

                int n = 0;
                foreach (ActivityList temp in m_pActivityListInfo)
                {
                    if (nSelIndex == n)
                    {
                        strDetail = temp.ActivityMainDetail;
                        break;
                    }
                    n++;
                }
            }

            Introduction IntroductionWin = new Introduction(strDetail, 2);

            IntroductionWin.ShowDialog();
        }
Beispiel #6
0
            protected override AutomationPeer OnCreateAutomationPeer()
            {
                var automationPeer = new ListViewAutomationPeer(this);

                // skip this renderer from automationPeer tree to avoid infinity loop
                automationPeer.SetParent(new FrameworkElementAutomationPeer(Parent as FrameworkElement));
                return(automationPeer);
            }
Beispiel #7
0
        public void SelectedIndex(int index)
        {
            _radarAreas.SelectedIndex        = index;
            radarAreasListView.SelectedIndex = index;
            var lvap = new ListViewAutomationPeer(radarAreasListView);
            var svap = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;

            //////////////////////////此处添加你想要对TreeView自身滚动条的操作///////////////////////////
            (svap.Owner as ScrollViewer).ScrollToVerticalOffset(index);    //向下调节垂直滚动条的位置;
        }
        /// <summary>Defines an <see cref="T:System.Windows.Automation.Peers.AutomationPeer" /> for the <see cref="T:System.Windows.Controls.ListView" /> control.</summary>
        /// <returns>Returns a <see cref="T:System.Windows.Automation.Peers.ListViewAutomationPeer" /> object for the <see cref="T:System.Windows.Controls.ListView" /> control.</returns>
        // Token: 0x0600516E RID: 20846 RVA: 0x0016D398 File Offset: 0x0016B598
        protected override AutomationPeer OnCreateAutomationPeer()
        {
            ListViewAutomationPeer listViewAutomationPeer = new ListViewAutomationPeer(this);

            if (listViewAutomationPeer != null && this.View != null)
            {
                listViewAutomationPeer.ViewAutomationPeer = this.View.GetAutomationPeer(this);
            }
            return(listViewAutomationPeer);
        }
        /// <summary>Responds to an <see cref="M:System.Windows.Controls.ItemsControl.OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs)" />. </summary>
        /// <param name="e">The event arguments.</param>
        // Token: 0x0600516D RID: 20845 RVA: 0x0016D360 File Offset: 0x0016B560
        protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsChanged(e);
            ListViewAutomationPeer listViewAutomationPeer = UIElementAutomationPeer.FromElement(this) as ListViewAutomationPeer;

            if (listViewAutomationPeer != null && listViewAutomationPeer.ViewAutomationPeer != null)
            {
                listViewAutomationPeer.ViewAutomationPeer.ItemsChanged(e);
            }
        }
        private void ActivityInfo_Next_Button_Click(object sender, RoutedEventArgs e)
        {
            ListViewAutomationPeer lvap = new ListViewAutomationPeer(ActivityInfo_ListView);
            var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
            var scroll = svap.Owner as ScrollViewer;

            if ((m_pActivityListInfo.Count > 1) && (scroll.HorizontalOffset / 926) <= (m_pActivityListInfo.Count - 2))
            {
                scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + 926);
            }
        }
        public static ScrollViewer GetListVIewScrollView(ListView listView)
        {
            //对于ListView而言:
            ListViewAutomationPeer lvap = new ListViewAutomationPeer(listView);
            var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
            var scroll = svap?.Owner as ScrollViewer;

            return(scroll);
            //////////////////////////此处添加你想要对TreeView自身滚动条的操作///////////////////////////
            //scroll.ScrollToVerticalOffset(scroll.VerticalOffset+1);    //向下调节垂直滚动条的位置;
        }
        private GridViewCellAutomationPeer CreateCellAutomationPeer(Visual owner, ListViewAutomationPeer peer)
        {
            GridViewCellAutomationPeer cellPeer = null;

            ConstructorInfo[] infos = typeof(GridViewCellAutomationPeer).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            if (infos != null && infos.Length == 2)
            {
                cellPeer = infos[1].Invoke(new Object[] { owner, peer }) as GridViewCellAutomationPeer;
            }

            return(cellPeer);
        }
Beispiel #13
0
        private static void OnViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ListView listView = (ListView)d;

            ViewBase oldView = (ViewBase)e.OldValue;
            ViewBase newView = (ViewBase)e.NewValue;

            if (newView != null)
            {
                if (newView.IsUsed)
                {
                    throw new InvalidOperationException(SR.Get(SRID.ListView_ViewCannotBeShared));
                }
                newView.IsUsed = true;
            }

            // In ApplyNewView ListView.ClearContainerForItemOverride will be called for each item.
            // Should use old view to do clear item.
            listView._previousView = oldView;
            listView.ApplyNewView();
            // After ApplyNewView, if item is removed, ListView.ClearContainerForItemOverride will be called.
            // Then should use new view to do clear item.
            listView._previousView = newView;

            //Switch ViewAutomationPeer in ListViewAutomationPeer
            ListViewAutomationPeer lvPeer = UIElementAutomationPeer.FromElement(listView) as ListViewAutomationPeer;

            if (lvPeer != null)
            {
                if (lvPeer.ViewAutomationPeer != null)
                {
                    lvPeer.ViewAutomationPeer.ViewDetached();
                }

                if (newView != null)
                {
                    lvPeer.ViewAutomationPeer = newView.GetAutomationPeer(listView);
                }
                else
                {
                    lvPeer.ViewAutomationPeer = null;
                }
                //Invalidate the ListView automation tree because the view has been changed
                lvPeer.InvalidatePeer();
            }

            if (oldView != null)
            {
                oldView.IsUsed = false;
            }
        }
 private void ActivityInfo_Prev_Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         ListViewAutomationPeer lvap = new ListViewAutomationPeer(ActivityInfo_ListView);
         var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
         var scroll = svap.Owner as ScrollViewer;
         if ((m_pActivityListInfo.Count > 1) && (scroll.HorizontalOffset / 926) >= 0)
         {
             scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset - 926);
         }
     }
     catch (Exception ex) { }
 }
Beispiel #15
0
 private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Down)
     {
         if (txtFilter.IsFocused)
         {
             if (listFilter.SelectedIndex < listFilter.Items.Count - 1)
             {
                 ListViewAutomationPeer lvap = new ListViewAutomationPeer(listFilter);
                 var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                 var scroll = svap.Owner as ScrollViewer;
                 //Console.WriteLine("1VOffset:{0},Index:{1},H:{2}", scroll.VerticalOffset, listFilter.SelectedIndex, scroll.ViewportHeight);
                 listFilter.SelectedIndex++;
                 if (listFilter.SelectedIndex - scroll.VerticalOffset >= scroll.ViewportHeight)
                 {
                     scroll.LineDown();
                 }
             }
         }
     }
     else if (e.Key == Key.Up)
     {
         if (txtFilter.IsFocused)
         {
             if (listFilter.SelectedIndex > 0)
             {
                 ListViewAutomationPeer lvap = new ListViewAutomationPeer(listFilter);
                 var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                 var scroll = svap.Owner as ScrollViewer;
                 //Console.WriteLine("1VOffset:{0},Index:{1},H:{2}", scroll.VerticalOffset, listFilter.SelectedIndex, scroll.ViewportHeight);
                 if (listFilter.SelectedIndex - scroll.VerticalOffset == 0)
                 {
                     scroll.LineUp();
                 }
                 listFilter.SelectedIndex--;
             }
         }
     }
     else if (e.Key == Key.Enter)
     {
         Student stu = listFilter.SelectedItem as Student;
         if (stu != null)
         {
             System.Console.WriteLine("{0},{1},{2}", stu.Name, stu.Age, stu.UserName);
         }
     }
 }
        //法师上一页预览
        private void UpPage_Button_Click_1(object sender, RoutedEventArgs e)
        {
            try{
                ListViewAutomationPeer lvap = new ListViewAutomationPeer(MonkInfo_ListView);
                var svap   = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                var scroll = svap.Owner as ScrollViewer;
                //scroll.LineLeft();
                //m_nScrollMove = scroll.HorizontalOffset / 530;
                m_nScrollUpMove = 0;
                if ((m_MonkList.Count > 2) && (scroll.HorizontalOffset / 532) >= 0)
                {
                    if ((scroll.HorizontalOffset / 532) == 1)
                    {
                        Image img = new Image();
                        img.Source = new BitmapImage(new Uri(@"pack://*****:*****@"pack://SiteOfOrigin:,,,/Res/btn04.png"));
                    this.DownPage_Button.Content = img2;


                    //                 dispatcherSrcollBarTimer.Tick += delegate
                    //                 {
                    //                     m_nScrollUpMove++;
                    //                     scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset - 53 * m_nScrollUpMove);
                    //                     if (m_nScrollUpMove == 10)
                    //                     {
                    //                         m_nScrollUpMove = 0;
                    //                         dispatcherSrcollBarTimer.Stop();
                    //                         return;
                    //                     }
                    //                 };
                    //                 dispatcherSrcollBarTimer.Start();
                    scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset - 532);
                }
            }
            catch (Exception ex) { }
        }
        // Token: 0x06005168 RID: 20840 RVA: 0x0016D250 File Offset: 0x0016B450
        private static void OnViewChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ListView listView  = (ListView)d;
            ViewBase viewBase  = (ViewBase)e.OldValue;
            ViewBase viewBase2 = (ViewBase)e.NewValue;

            if (viewBase2 != null)
            {
                if (viewBase2.IsUsed)
                {
                    throw new InvalidOperationException(SR.Get("ListView_ViewCannotBeShared"));
                }
                viewBase2.IsUsed = true;
            }
            listView._previousView = viewBase;
            listView.ApplyNewView();
            listView._previousView = viewBase2;
            ListViewAutomationPeer listViewAutomationPeer = UIElementAutomationPeer.FromElement(listView) as ListViewAutomationPeer;

            if (listViewAutomationPeer != null)
            {
                if (listViewAutomationPeer.ViewAutomationPeer != null)
                {
                    listViewAutomationPeer.ViewAutomationPeer.ViewDetached();
                }
                if (viewBase2 != null)
                {
                    listViewAutomationPeer.ViewAutomationPeer = viewBase2.GetAutomationPeer(listView);
                }
                else
                {
                    listViewAutomationPeer.ViewAutomationPeer = null;
                }
                listViewAutomationPeer.InvalidatePeer();
            }
            if (viewBase != null)
            {
                viewBase.IsUsed = false;
            }
        }
        private void ActivityInfo_Next_Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (m_pActivityListInfo.Count == 0)
                {
                    return;
                }

                ListViewAutomationPeer lvap = new ListViewAutomationPeer(ActivityInfo_ListView);
                var    svap            = lvap.GetPattern(PatternInterface.Scroll) as ScrollViewerAutomationPeer;
                var    scroll          = svap.Owner as ScrollViewer;
                double nListViewOffset = scroll.ViewportWidth;
                if ((m_pActivityListInfo.Count > 1) &&
                    (scroll.HorizontalOffset / nListViewOffset) <= (m_pActivityListInfo.Count - 2))
                {
                    int nPosOf = (int)(scroll.HorizontalOffset / nListViewOffset);
                    if ((scroll.HorizontalOffset / nListViewOffset) == (m_pActivityListInfo.Count - 2))
                    {
                        Image img = new Image();
                        img.Source = new BitmapImage(new Uri("pack://SiteOfOrigin:,,,/Res/Page19/btn03.png"));
                        this.ActivityInfo_Next_Button.Content = img;
                    }

                    if (nPosOf >= 0 && (nPosOf) < m_pActivityListInfo.Count())
                    {
                        m_strActivityinfoDetail = m_pActivityListInfo[nPosOf + 1].ActivityMainDetail;
                    }
                    Image img2 = new Image();
                    img2.Source = new BitmapImage(new Uri("pack://SiteOfOrigin:,,,/Res/Page19/btn02.png"));
                    this.ActivityInfo_Prev_Button.Content = img2;
                    scroll.ScrollToHorizontalOffset(scroll.HorizontalOffset + nListViewOffset);
                }
            }
            catch (Exception ex) { }
        }
        ItemAutomationPeer IViewAutomationPeer.CreateItemAutomationPeer(Object item)
        {
            ListViewAutomationPeer lvAP = UIElementAutomationPeer.FromElement(m_lv) as ListViewAutomationPeer;

            return(new ListBoxItemAutomationPeer(item, lvAP));
        }
 public CustomGridViewItemAutomationPeer(object owner, ListViewAutomationPeer listviewAP) : base(owner, listviewAP)
 {
     this.listviewAP = listviewAP;
 }