Example #1
0
        public MyBlogDialog(NewMainWindow suc, Shortcut shortcut, String url)
        {
            InitializeComponent();

            Title = "ThirdPartyPage";

            this.shortcut = shortcut;

            WebClientUtil.WebToModel(url, ref blogPageModel);
            InitData();
        }
Example #2
0
        private void LoadUrl(String url)
        {
            shortcut.url = url;

            WebClientUtil.WebToModel(url, ref blogContentModel);

            if (blogContentModel.Author.Equals(String.Empty))
            {
                tbAuthor.Visibility = Visibility.Collapsed;
            }
            else
            {
                tbAuthor.Text = blogContentModel.Author;
            }

            for (int i = 0; i < blogContentModel.Contacts.Count; i++)
            {
                TextBlock tb = new TextBlock();
                if (i != 0)
                {
                    tb.Margin = new Thickness(0, 10, 0, 0);
                }
                if (Application.Current.Resources[blogContentModel.Contacts[i].type] != null)
                {
                    tb.Text = (String)Application.Current.Resources[blogContentModel.Contacts[i].type];
                }
                else
                {
                    tb.Text = blogContentModel.Contacts[i].type;
                }
                tb.Foreground = new SolidColorBrush(Colors.White);
                spContacts.Children.Add(tb);

                TextBlock tb2 = new TextBlock();
                tb2.Text       = blogContentModel.Contacts[i].content;
                tb2.Foreground = new SolidColorBrush(Color.FromRgb(200, 200, 200));
                tb2.Margin     = new Thickness(0, 5, 0, 0);
                spContacts.Children.Add(tb2);
            }

            if (blogContentModel.Introduce.Equals(String.Empty))
            {
                tbIntroduce.Visibility = Visibility.Collapsed;
            }
            else
            {
                tbIntroduce.Text = blogContentModel.Introduce;
            }

            string         userHeadPic = blogContentModel.HeadPortrait;
            HttpWebRequest request     = (HttpWebRequest)WebRequest.Create(userHeadPic);
            WebResponse    response    = request.GetResponse();

            System.Drawing.Image  img    = System.Drawing.Image.FromStream(response.GetResponseStream());
            System.Drawing.Bitmap bitMap = new System.Drawing.Bitmap(img);
            iHead.Source = GetBitmapSource(bitMap);

            for (int i = 0; i < blogContentModel.Pages.Count; i++)
            {
                if (blogContentModel.Pages[i].type.Equals("ThirdPartyPage"))
                {
                    if (blogContentModel.Pages[i].url.StartsWith("/"))
                    {
                        AddContentUserControl(new MyBlogDialog(mw, shortcut, blogContentModel.BaseUrl + blogContentModel.Pages[i].url));
                    }
                }
            }

            InitData();
            //BlogConfigModel blogConfigModel = new BlogConfigModel();
            //Console.WriteLine("AAAAAAAAA");
            //XmlSerializerBusiness.Load(ref blogConfigModel, @"D:\Test\Matrix\xxx.");
            //Console.WriteLine(blogConfigModel.Buttons.Count);
            //Console.WriteLine("BBBBBBBBB");


            //调用WebClient对象的DownloadFile方法将指定网站的内容保存到文件中
            //wclient.DownloadFile(textBox1.Text, DateTime.Now.ToFileTime() + ".txt");
            //MessageBox.Show("保存到文件成功");
        }