IFluentElementRule IFluentElementRule.Convert(HtmlElementConverter converter)
        {
            foreach (IFluentElementRule rule in this)
            {
                rule.Convert(converter);
            }

            return(this);
        }
Ejemplo n.º 2
0
        private void ShowArticleText(ArticleData data)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke(() => ShowArticleText(data));
                return;
            }

            Contents.Children.Clear();

            // VirtualizingStackPanel을 쓰는 리스트 박스
            var panel = new ListBox();

            panel.ItemContainerStyle     = Resources["ListBoxItemStyle"] as Style;
            panel.ItemsPanel             = Resources["ListBoxItemsPanelTemplate"] as ItemsPanelTemplate;
            panel.ManipulationCompleted += (o, e) => this.Focus();

            // * 제목 title
            var title = new TextBlock();

            title.TextWrapping = TextWrapping.Wrap;
            title.Style        = Application.Current.Resources["DCViewTextMediumStyle"] as Style;
            title.Text         = HttpUtility.HtmlDecode(article.Title);
            title.FontWeight   = FontWeights.Bold;
            title.Margin       = new Thickness(0, 12, 0, 12);
            panel.Items.Add(title);

            // * 그림 불러오기 버튼
            List <Grid> imgContainers   = new List <Grid>();
            var         loadImageButton = CreateLoadImageButton(panel, imgContainers);

            panel.Items.Add(loadImageButton);

            // 그림 들어갈 자리에 Grid 하나씩 넣기..
            foreach (Picture pic in article.Pictures)
            {
                var grid = new Grid();
                grid.Tag    = pic;
                grid.Margin = new Thickness(0, 3, 0, 0);

                imgContainers.Add(grid);
                panel.Items.Add(grid);
            }

            // * 12픽셀을 띄기 위해서 마진이 12인 텍스트 블럭 삽입
            var margin = new TextBlock();

            margin.Margin = new Thickness(0, 0, 0, 12);
            panel.Items.Add(margin);

            // * 본문
            foreach (var elem in HtmlElementConverter.GetUIElementFromString(data.Text, tapAction))
            {
                panel.Items.Add(elem);

                if (elem is Grid && elem.Tag is Picture)
                {
                    imgContainers.Add((Grid)elem);
                }
            }

            // * 글쓴이 정보
            var status = new ArticleStatusView();

            status.DataContext         = new ArticleViewModel(article);
            status.HorizontalAlignment = HorizontalAlignment.Right;
            panel.Items.Add(status);

            // * 댓글
            foreach (var cmt in data.Comments)
            {
                var commentView = new CommentView();
                commentView.DataContext = new CommentViewModel(cmt);

                foreach (var grid in HtmlElementConverter.GetUIElementFromString(cmt.Text, tapAction))
                {
                    commentView.Contents.Children.Add(grid);

                    if (grid is Grid && grid.Tag is Picture)
                    {
                        imgContainers.Add((Grid)grid);
                    }
                }

                panel.Items.Add(commentView);
            }

            // * 댓글을 달 수 있으면 ReplyTextBox 넣기
            if (article.CanWriteComment)
            {
                // ReplyTextBox를 새로 만듦
                replyTextBox = CreateReplyTextBox(panel);
                panel.Items.Add(replyTextBox);
            }


            bool bPassiveLoading = (bool)IsolatedStorageSettings.ApplicationSettings["DCView.passive_loadimg"] && imgContainers.Count != 0;

            // * 수동읽기가 설정이 되어있으면 버튼을 활성화
            if (!bPassiveLoading)
            {
                loadImageButton.Visibility = Visibility.Collapsed;
                LoadImagesAsync(panel, imgContainers);
            }

            // Contents에 panel을 추가.
            Contents.Children.Add(panel);

            // *스크롤을 처음으로 되돌림
            panel.ScrollIntoView(title);
        }
Ejemplo n.º 3
0
 IFluentElementRule IFluentElementRule.Convert(HtmlElementConverter converter)
 {
     _converter = converter;
     return this;
 }
Ejemplo n.º 4
0
 IFluentElementRule IFluentElementRule.Convert(HtmlElementConverter converter)
 {
     _converter = converter;
     return(this);
 }