Example #1
0
        private void getDataFromDataBase()
        {
            i = 0;
            foreach (HeroTable item in db.heroTable)
            {
                i++;
                Image image = new Image();
                image.Width  = 60;
                image.Height = 60;
                image.Margin = new Thickness(5, 5, 5, 5);
                image.Source = new BitmapImage()
                {
                    UriSource = new Uri(item.AvatarUri, UriKind.Relative)
                };
                System.Windows.Interactivity.EventTrigger ev = new System.Windows.Interactivity.EventTrigger("Tap");
                NavigateToPageAction action = new NavigateToPageAction();
                action.TargetPage = "/Views/SingleHero.xaml?id=" + item.Id;
                ev.Actions.Add(action);
                Interaction.GetTriggers(image).Add(ev);

                if (i <= 38)
                {
                    heroPanel1.Children.Add(image);
                }
                if (i > 38 && i <= 72)
                {
                    heroPanel2.Children.Add(image);
                }
                if (i > 72)
                {
                    heroPanel3.Children.Add(image);
                }
            }
        }
Example #2
0
        private void callback(string htmlStr)
        {
            if (htmlStr.Equals("NO"))
            {
                MessageBoxResult result = MessageBox.Show("检测到当前没有网络,请联上网络重启程序", "提醒", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    ((MainPage)this.Parent).Exit();
                }
            }

            string        heropart = htmlhelp.GetUniqTag(htmlStr, "div", "class=\"BG_Block\"");
            List <string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", "");

            foreach (var item in allheros)
            {
                i++;
                Hero   hero   = new Hero(item);
                string gif    = hero.Src;
                int    start  = gif.LastIndexOf('/');
                int    length = gif.Length - start;
                string name   = gif.Substring(start + 1);
                string name1  = " /Heros/" + name.Substring(0, name.Length - 4) + ".png";
                Image  image  = new Image();
                image.Width  = 60;
                image.Height = 60;
                image.Margin = new Thickness(5, 5, 5, 5);
                image.Source = new BitmapImage()
                {
                    UriSource = new Uri(name1, UriKind.Relative)
                };
                System.Windows.Interactivity.EventTrigger ev = new System.Windows.Interactivity.EventTrigger("Tap");
                NavigateToPageAction action = new NavigateToPageAction();

                ev.Actions.Add(action);
                Interaction.GetTriggers(image).Add(ev);
                if (i <= 38)
                {
                    heroPanel1.Children.Add(image);
                }
                if (i > 38 && i <= 72)
                {
                    heroPanel2.Children.Add(image);
                }
                if (i > 72)
                {
                    heroPanel3.Children.Add(image);
                }
                HeroTable heroItem = new HeroTable()
                {
                    AvatarUri = name1,
                    Name      = hero.Alt,
                    Link      = hero.Href
                };
                db.heroTable.InsertOnSubmit(heroItem);
                db.SubmitChanges();
                action.TargetPage = "/Views/SingleHero.xaml?id=" + heroItem.Id;
            }
            waiting.WaitingEnd();
        }
        public void Execute_SenderImplementsINavigate_NavigatesToSender()
        {
            // Arrange
            TestVisualTreeHelper visualTreeHelper = new TestVisualTreeHelper();
            NavigateToPageAction action           = new NavigateToPageAction(visualTreeHelper);

            action.TargetPage = NavigateToPageActionTest.TestPageName;
            NavigableStub navigateTarget = new NavigableStub();

            // Act
            bool success = (bool)action.Execute(navigateTarget, null);

            // Assert
            Assert.IsTrue(success);
            Assert.AreEqual(NavigateToPageActionTest.TestPageName, navigateTarget.NavigatedTypeFullName);
        }
        public void Execute_NoAncestorImplementsINavigate_Fails()
        {
            // Arrange
            TestVisualTreeHelper visualTreeHelper = new TestVisualTreeHelper();
            NavigateToPageAction action           = new NavigateToPageAction(visualTreeHelper);

            action.TargetPage = NavigateToPageActionTest.TestPageName;
            DependencyObject sender = new SimpleDependencyObject();
            DependencyObject parent = new SimpleDependencyObject();

            visualTreeHelper.AddChild(parent, sender);

            // Act
            bool success = (bool)action.Execute(sender, null);

            // Assert
            Assert.IsFalse(success);
        }
        public void Execute_SenderDoesNotImplementINavigate_NavigatesToAncestor()
        {
            // Arrange
            TestVisualTreeHelper visualTreeHelper = new TestVisualTreeHelper();
            NavigateToPageAction action           = new NavigateToPageAction(visualTreeHelper);

            action.TargetPage = NavigateToPageActionTest.TestPageName;
            DependencyObject sender         = new SimpleDependencyObject();
            NavigableStub    navigateTarget = new NavigableStub();

            visualTreeHelper.AddChild(navigateTarget, sender);

            // Act
            bool success = (bool)action.Execute(sender, null);

            // Assert
            Assert.IsTrue(success);
            Assert.AreEqual(NavigateToPageActionTest.TestPageName, navigateTarget.NavigatedTypeFullName);
        }
Example #6
0
        private void callback(string htmlStr)
        {
            if(htmlStr.Equals("NO"))
               {
               MessageBoxResult result = MessageBox.Show("检测到当前没有网络,请联上网络重启程序", "提醒", MessageBoxButton.OK);
               if (result==MessageBoxResult.OK)
               {
                   ((MainPage)this.Parent).Exit();
               }
              }

            string heropart = htmlhelp.GetUniqTag(htmlStr, "div", "class=\"BG_Block\"");
            List<string> allheros = htmlhelp.GetTagCollectByCharacter(heropart, "li", "");

            foreach (var item in allheros)
            {
                i++;
                Hero hero = new Hero(item);
                string gif = hero.Src;
                int start = gif.LastIndexOf('/');
                  int length = gif.Length - start;
                  string name = gif.Substring(start + 1);
                  string name1 = " /Heros/" + name.Substring(0, name.Length - 4) + ".png";
                  Image image = new Image();
                  image.Width = 60;
                  image.Height = 60;
                  image.Margin = new Thickness(5, 5, 5, 5);
                  image.Source = new BitmapImage() { UriSource = new Uri(name1, UriKind.Relative) };
                  System.Windows.Interactivity.EventTrigger ev = new System.Windows.Interactivity.EventTrigger("Tap");
                  NavigateToPageAction action = new NavigateToPageAction();

                  ev.Actions.Add(action);
                    Interaction.GetTriggers(image).Add(ev);
                    if (i <= 38)
                    {
                        heroPanel1.Children.Add(image);
                    }
                    if (i > 38 && i <= 72)
                    {
                        heroPanel2.Children.Add(image);
                    }
                    if (i > 72)
                    {
                        heroPanel3.Children.Add(image);
                    }
                    HeroTable heroItem = new HeroTable()
                    {
                        AvatarUri = name1,
                        Name = hero.Alt,
                        Link = hero.Href
                    };
                    db.heroTable.InsertOnSubmit(heroItem);
                    db.SubmitChanges();
                    action.TargetPage = "/Views/SingleHero.xaml?id=" + heroItem.Id;
                  }
            waiting.WaitingEnd();
        }
Example #7
0
        private void getDataFromDataBase()
        {
            i=0;
            foreach (HeroTable item in db.heroTable)
            {
                i++;
                    Image image = new Image();
                    image.Width = 60;
                    image.Height = 60;
                    image.Margin = new Thickness(5, 5, 5, 5);
                    image.Source = new BitmapImage() { UriSource = new Uri(item.AvatarUri, UriKind.Relative) };
                    System.Windows.Interactivity.EventTrigger ev = new System.Windows.Interactivity.EventTrigger("Tap");
                    NavigateToPageAction action = new NavigateToPageAction();
                    action.TargetPage = "/Views/SingleHero.xaml?id=" + item.Id;
                    ev.Actions.Add(action);
                    Interaction.GetTriggers(image).Add(ev);

                    if (i <= 38)
                    {
                        heroPanel1.Children.Add(image);
                    }
                    if (i > 38 && i <= 72)
                    {
                        heroPanel2.Children.Add(image);
                    }
                    if (i > 72)
                    {
                        heroPanel3.Children.Add(image);
                    }
            }
        }