/// <summary>
        /// Called to preform a render of the current Markdown.
        /// </summary>
        private void RenderMarkdown()
        {
            if (_rootElement == null)
            {
                return;
            }

            if (_flowDocumentScrollViewer == null)
            {
                _flowDocumentScrollViewer = new FlowDocumentScrollViewer()
                {
                    VerticalScrollBarVisibility = ScrollBarVisibility.Auto
                };
                DataObject.AddCopyingHandler(_flowDocumentScrollViewer, OnCopy);
                _rootElement.Child = _flowDocumentScrollViewer;
            }

            UnhookListeners();
            _listeningHyperlinks.Clear();

            var markdownRenderedArgs = new MarkdownRenderedEventArgs(null);

            if (string.IsNullOrWhiteSpace(Text))
            {
                _flowDocumentScrollViewer.Document = null;
            }
            else
            {
                try
                {
                    MarkdownDocument markdown = new MarkdownDocument();
                    foreach (string str in SchemeList.Split(',').ToList())
                    {
                        if (!string.IsNullOrEmpty(str))
                        {
                            MarkdownDocument.KnownSchemes.Add(str);
                        }
                    }

                    markdown.Parse(Text);

                    if (!(Activator.CreateInstance(renderertype, markdown, this, this, this, this) is MarkdownRenderer renderer))
                    {
                        throw new Exception("Markdown Renderer was not of the correct type.");
                    }

                    renderer.FontFamily                = FontFamily;
                    renderer.FontSize                  = FontSize;
                    renderer.FontStretch               = FontStretch;
                    renderer.FontStyle                 = FontStyle;
                    renderer.FontWeight                = FontWeight;
                    renderer.Foreground                = Foreground;
                    renderer.Padding                   = Padding;
                    renderer.CodeBackground            = CodeBackground;
                    renderer.CodeBorderBrush           = CodeBorderBrush;
                    renderer.CodeBorderThickness       = CodeBorderThickness;
                    renderer.InlineCodeBorderThickness = InlineCodeBorderThickness;
                    renderer.InlineCodeBackground      = InlineCodeBackground;
                    renderer.InlineCodeBorderBrush     = InlineCodeBorderBrush;
                    renderer.InlineCodePadding         = InlineCodePadding;
                    renderer.InlineCodeFontFamily      = InlineCodeFontFamily;
                    renderer.InlineCodeForeground      = InlineCodeForeground;
                    renderer.CodeForeground            = CodeForeground;
                    renderer.CodeFontFamily            = CodeFontFamily;
                    renderer.CodePadding               = CodePadding;
                    renderer.CodeMargin                = CodeMargin;
                    renderer.EmojiFontFamily           = EmojiFontFamily;
                    renderer.Header1FontSize           = Header1FontSize;
                    renderer.Header1FontWeight         = Header1FontWeight;
                    renderer.Header1Margin             = Header1Margin;
                    renderer.Header1Foreground         = Header1Foreground;
                    renderer.Header2FontSize           = Header2FontSize;
                    renderer.Header2FontWeight         = Header2FontWeight;
                    renderer.Header2Margin             = Header2Margin;
                    renderer.Header2Foreground         = Header2Foreground;
                    renderer.Header3FontSize           = Header3FontSize;
                    renderer.Header3FontWeight         = Header3FontWeight;
                    renderer.Header3Margin             = Header3Margin;
                    renderer.Header3Foreground         = Header3Foreground;
                    renderer.Header4FontSize           = Header4FontSize;
                    renderer.Header4FontWeight         = Header4FontWeight;
                    renderer.Header4Margin             = Header4Margin;
                    renderer.Header4Foreground         = Header4Foreground;
                    renderer.Header5FontSize           = Header5FontSize;
                    renderer.Header5FontWeight         = Header5FontWeight;
                    renderer.Header5Margin             = Header5Margin;
                    renderer.Header5Foreground         = Header5Foreground;
                    renderer.Header6FontSize           = Header6FontSize;
                    renderer.Header6FontWeight         = Header6FontWeight;
                    renderer.Header6Margin             = Header6Margin;
                    renderer.Header6Foreground         = Header6Foreground;
                    renderer.HorizontalRuleBrush       = HorizontalRuleBrush;
                    renderer.HorizontalRuleMargin      = HorizontalRuleMargin;
                    renderer.HorizontalRuleThickness   = HorizontalRuleThickness;
                    renderer.ListMargin                = ListMargin;
                    renderer.ListBulletSpacing         = ListBulletSpacing;
                    renderer.ParagraphMargin           = ParagraphMargin;
                    renderer.ParagraphLineHeight       = ParagraphLineHeight;
                    renderer.QuoteBackground           = QuoteBackground;
                    renderer.QuoteBorderBrush          = QuoteBorderBrush;
                    renderer.QuoteBorderThickness      = QuoteBorderThickness;
                    renderer.QuoteForeground           = QuoteForeground;
                    renderer.QuoteMargin               = QuoteMargin;
                    renderer.QuotePadding              = QuotePadding;
                    renderer.TableBorderBrush          = TableBorderBrush;
                    renderer.TableBorderThickness      = TableBorderThickness;
                    renderer.YamlBorderBrush           = YamlBorderBrush;
                    renderer.YamlBorderThickness       = YamlBorderThickness;
                    renderer.TableCellPadding          = TableCellPadding;
                    renderer.TableMargin               = TableMargin;
                    renderer.LinkForeground            = LinkForeground;
                    renderer.ImageStretch              = ImageStretch;
                    renderer.ImageMaxHeight            = ImageMaxHeight;
                    renderer.ImageMaxWidth             = ImageMaxWidth;
                    renderer.FlowDirection             = FlowDirection;

                    _flowDocumentScrollViewer.IsSelectionEnabled = IsTextSelectionEnabled;
                    _flowDocumentScrollViewer.Document           = renderer.Render();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error while parsing and rendering: " + ex.Message);
                    if (Debugger.IsAttached)
                    {
                        Debugger.Break();
                    }

                    markdownRenderedArgs = new MarkdownRenderedEventArgs(ex);
                }
            }

            MarkdownRendered?.Invoke(this, markdownRenderedArgs);
        }
Beispiel #2
0
        private void CreateAndShowMainWindow()
        {
            // Create the application's main window
            mainWindow = new System.Windows.Window();

            // Create the parent viewer...
            tf1          = new FlowDocumentScrollViewer();
            tf1.Document = new FlowDocument();

            // Create the Table...
            table1 = new Table();
            // ...and add it as a content element of the TextFlow.
            tf1.Document.Blocks.Add(table1);
            // tf1.ContentStart.InsertTextElement(table1);

            // Set some global formatting properties for the table.
            table1.CellSpacing = 10;
            table1.Background  = Brushes.White;

            // Create 6 columns and add them to the table's Columns collection.
            int numberOfColumns = 6;

            for (int x = 0; x < numberOfColumns; x++)
            {
                table1.Columns.Add(new TableColumn());
            }

            // Set alternating background colors for the middle colums.
            table1.Columns[1].Background     =
                table1.Columns[3].Background =
                    Brushes.LightSteelBlue;
            table1.Columns[2].Background     =
                table1.Columns[4].Background =
                    Brushes.Beige;

            // Create and add an empty TableRowGroup to hold the table's Rows.
            table1.RowGroups.Add(new TableRowGroup());

            // Add the first (title) row.
            table1.RowGroups[0].Rows.Add(new TableRow());

            // Alias the current working row for easy reference.
            TableRow currentRow = table1.RowGroups[0].Rows[0];

            // Global formatting for the title row.
            currentRow.Background = Brushes.Silver;
            currentRow.FontSize   = 40;
            currentRow.FontWeight = System.Windows.FontWeights.Bold;

            // Add the header row with content,
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("2004 Sales Project"))));
            // and set the row to span all 6 columns.
            currentRow.Cells[0].ColumnSpan = 6;

            // Add the second (header) row.
            table1.RowGroups[0].Rows.Add(new TableRow());
            currentRow = table1.RowGroups[0].Rows[1];

            // Global formatting for the header row.
            currentRow.FontSize   = 18;
            currentRow.FontWeight = FontWeights.Bold;

            // Add cells with content to the second row.
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Product"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Quarter 1"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Quarter 2"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Quarter 3"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Quarter 4"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("TOTAL"))));

            table1.RowGroups[0].Rows.Add(new TableRow());
            currentRow = table1.RowGroups[0].Rows[2];

            // Global formatting for the row.
            currentRow.FontSize   = 12;
            currentRow.FontWeight = FontWeights.Normal;

            // Add cells with content to the third row.
            TableCell tc = new TableCell(new Paragraph(new Run("Widgets")));

            tc.RowSpan = 2;
            currentRow.Cells.Add(tc);
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$50,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$55,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$60,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$65,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$230,000"))));

            // Bold the first cell.
            currentRow.Cells[0].FontWeight = FontWeights.Bold;

            // Add the fourth row.
            table1.RowGroups[0].Rows.Add(new TableRow());
            currentRow = table1.RowGroups[0].Rows[3];

            // Global formatting for the row.
            currentRow.FontSize   = 12;
            currentRow.FontWeight = FontWeights.Normal;

            // Add cells with content to the third row.
            //currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Wickets"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$100,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$120,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$160,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$200,000"))));
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("$580,000"))));


            // Bold the first cell.
            currentRow.Cells[0].FontWeight = FontWeights.Bold;

            table1.RowGroups[0].Rows.Add(new TableRow());
            currentRow = table1.RowGroups[0].Rows[4];

            // Global formatting for the footer row.
            currentRow.Background = Brushes.LightGray;
            currentRow.FontSize   = 18;
            currentRow.FontWeight = System.Windows.FontWeights.Normal;

            // Add the header row with content,
            currentRow.Cells.Add(new TableCell(new Paragraph(new Run("Projected 2004 Revenue: $810,000"))));
            // and set the row to span all 6 columns.
            currentRow.Cells[0].ColumnSpan = 6;

            mainWindow.Title   = "Table Sample";
            mainWindow.Content = tf1;
            mainWindow.Show();
        }
Beispiel #3
0
 public FlowDocumentScrollViewerProxy(FlowDocumentScrollViewer proxied)
     : base(proxied)
 {
 }
Beispiel #4
0
 /// <summary>
 /// New instance.
 /// </summary>
 public FlowDocumentScrollViewerRunReader(FlowDocumentScrollViewer docViewer)
 {
     this.docViewer = docViewer;
 }
Beispiel #5
0
        /*
         * private Int32 _iconType;
         * public Int32 IconType
         * {
         *  get { return _iconType; }
         *  set { _iconType = value; }
         *
         * }*/



        private void MessageBoxFactory()
        {
            if (String.IsNullOrEmpty(Title) == false)
            {
                Label label = new Label();
                Style style = Application.Current.FindResource("h4") as Style;
                label.Style               = style;
                label.Content             = Title;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                label.Padding             = new Thickness(15, 10, 15, 10);
                label.VerticalAlignment   = VerticalAlignment.Top;
                gridPanel.Children.Add(label);
            }



            Grid grid = new Grid();
            FlowDocumentScrollViewer flowDocumentScrollViewer = new FlowDocumentScrollViewer();

            flowDocumentScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            flowDocumentScrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            flowDocumentScrollViewer.IsToolBarVisible = false;
            if (String.IsNullOrEmpty(Title) == true)
            {
                flowDocumentScrollViewer.Padding = new Thickness(15, 15, 15, 10);
            }
            else
            {
                flowDocumentScrollViewer.Padding = new Thickness(15, 35, 15, 10);
            }
            FlowDocument flowDocument = new FlowDocument();

            flowDocument.FontFamily = new FontFamily("Segoe UI");
            flowDocument.FontSize   = 10;

            Paragraph paragraph;


            #region Image

            /*
             * try
             * {
             *
             *  IconImage.Height = 26;
             *  IconImage.Width = 26;
             *  Grid ImageGrid = new Grid();
             *  //ImageGrid.Background = Brushes.Red;
             *  ImageGrid.Width = 50;
             *  //ImageGrid.Margin = new Thickness(40);
             *  ImageGrid.Children.Add(IconImage);
             *  //ImageGrid.SetValue(Grid.ColumnProperty, 0);
             *  ImageGrid.HorizontalAlignment = HorizontalAlignment.Left;
             *  //ImageGrid.VerticalAlignment = VerticalAlignment.Top;
             *  grid.Children.Add(ImageGrid);
             *
             *  //InlineUIContainer inlineUiContainer = new InlineUIContainer(IconImage);
             *  //Span span = new Span(inlineUiContainer);
             *  //span.Inlines.Add(new Run(Body));
             *
             *  paragraph = new Paragraph(new Run(Body));
             *  paragraph.Margin = new Thickness(70);
             * }
             * catch (Exception)
             * {
             *   Console.WriteLine("I am getting exceptions in image");
             *
             *
             * }
             */
            #endregion


            paragraph = new Paragraph(new Run(Body));
            Style Parastyle = Application.Current.FindResource("parah4") as Style;
            paragraph.Style = Parastyle;



            flowDocument.Blocks.Add(paragraph);


            flowDocumentScrollViewer.Document = flowDocument;
            grid.Children.Add(flowDocumentScrollViewer);

            gridPanel.Children.Add(grid);


            //declaring a button grid..
            Grid btnGrid = new Grid();
            //Definging three buttons and their event..
            Button btnOk = new Button();
            btnOk.Click += btnOk_Click;
            Button btnCancel = new Button();
            btnCancel.Click += btnCancel_Click;


            Button btnYes = new Button();
            btnYes.Click += btnYes_Click;

            Button btnNo = new Button();
            btnNo.Click += btnNo_Click;

            StackPanel btnPanel = new StackPanel();
            Grid.SetRow(btnPanel, 2);
            btnPanel.Height      = 40;
            btnPanel.Margin      = new Thickness(35, 0, 35, 15);
            btnPanel.Orientation = Orientation.Horizontal;
            if (Type == OK)
            {
                btnOk.Width = 80;
                //btnOk.Height = 30;
                btnOk.Content = "OK";
                btnOk.Margin  = new Thickness(10, 0, 10, 0);

                btnPanel.Children.Add(btnOk);
                btnPanel.HorizontalAlignment = HorizontalAlignment.Center;


                gridPanel.Children.Add(btnPanel);
            }

            if (Type == OKCANCEL)
            {
                btnOk.Width = 80;

                btnOk.Content = "OK";

                btnCancel.Width = 80;

                btnCancel.Content = "Cancel";
                btnCancel.Margin  = new Thickness(20, 0, 0, 0);

                btnPanel.Children.Add(btnOk);
                btnPanel.Children.Add(btnCancel);
                btnPanel.HorizontalAlignment = HorizontalAlignment.Center;

                gridPanel.Children.Add(btnPanel);
            }

            if (Type == YESNO)
            {
                btnYes.Width = 80;

                btnYes.Content = "Yes";


                btnNo.Width = 80;

                btnNo.Content = "No";
                btnNo.Margin  = new Thickness(20, 0, 0, 0);


                btnPanel.Children.Add(btnYes);
                btnPanel.Children.Add(btnNo);
                btnPanel.HorizontalAlignment = HorizontalAlignment.Center;
                gridPanel.Children.Add(btnPanel);
            }

            if (Type == YESNOCANCEL)
            {
                btnYes.Width = 80;

                btnYes.Content = "Yes";


                btnNo.Width = 80;

                btnNo.Content             = "No";
                btnNo.Margin              = new Thickness(10, 0, 0, 0);
                btnNo.HorizontalAlignment = HorizontalAlignment.Center;
                btnCancel.Width           = 80;

                btnCancel.Content             = "Cancel";
                btnCancel.Margin              = new Thickness(10, 0, 0, 0);
                btnCancel.HorizontalAlignment = HorizontalAlignment.Right;

                btnPanel.Children.Add(btnYes);
                btnPanel.Children.Add(btnNo);
                btnPanel.Children.Add(btnCancel);
                btnPanel.HorizontalAlignment = HorizontalAlignment.Right;
                gridPanel.Children.Add(btnPanel);
            }

            if (Type == NONE)
            {
            }
        }
Beispiel #6
0
 public WhiteFlowDocumentScrollViewerPeer(FlowDocumentScrollViewer owner) : base(owner)
 {
     whitePeer = WhitePeer.Create(this, owner);
 }
 private void document_Loaded(object sender, RoutedEventArgs e)
 {
     flowDocument = sender as FlowDocumentScrollViewer;
 }
Beispiel #8
0
        private void MessageBoxFactory(String body, String title = "", Int32 type = OK)
        {
            if (String.IsNullOrEmpty(title) == false)
            {
                Label label = new Label();
                Style style = Application.Current.FindResource("h3") as Style;
                label.Style               = style;
                label.Content             = title;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                label.Padding             = new Thickness(15, 10, 15, 10);
                //Adding grid child..
                gridPanel.Children.Add(label);
                Console.WriteLine(label.Content);
            }

            Grid grid = new Grid();
            FlowDocumentScrollViewer flowDocumentScrollViewer = new FlowDocumentScrollViewer();

            flowDocumentScrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
            flowDocumentScrollViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Auto;
            flowDocumentScrollViewer.IsToolBarVisible = false;
            flowDocumentScrollViewer.Padding          = new Thickness(15, 35, 15, 10);
            FlowDocument flowDocument = new FlowDocument();
            Paragraph    paragraph    = new Paragraph(new Run(body));
            Style        Parastyle    = Application.Current.FindResource("parah5") as Style;

            paragraph.Style = Parastyle;
            flowDocument.Blocks.Add(paragraph);
            flowDocumentScrollViewer.Document = flowDocument;

            grid.Children.Add(flowDocumentScrollViewer);
            gridPanel.Children.Add(grid);


            //declaring a button grid..
            Grid btnGrid = new Grid();

            //Definging three buttons and their event..
            Button btnOk = new Button();

            btnOk.Click += btnOk_Click;

            Button btnCancel = new Button();

            btnCancel.Click += btnCancel_Click;


            Button btnYes = new Button();

            btnYes.Click += btnYes_Click;

            Button btnNo = new Button();

            btnNo.Click += btnNo_Click;

            StackPanel btnPanel = new StackPanel();

            btnPanel.Height            = 40;
            btnPanel.Margin            = new Thickness(0, 0, 0, 20);
            btnPanel.Background        = Brushes.Red;
            btnPanel.VerticalAlignment = VerticalAlignment.Bottom;
            btnPanel.Orientation       = Orientation.Horizontal;

            if (Type == OK)
            {
                btnOk.Width   = 80;
                btnOk.Height  = 40;
                btnOk.Content = "OK";
                btnPanel.Children.Add(btnOk);
                btnPanel.HorizontalAlignment = HorizontalAlignment.Center;
                gridPanel.Children.Add(btnPanel);
            }
        }
 public static void Clear(this FlowDocumentScrollViewer flowDocumentScrollViewer)
 {
     flowDocumentScrollViewer.Document.Blocks.Clear();
 }
 public static void AppendText(this FlowDocumentScrollViewer flowDocumentScrollViewer, string data, int fontSize = 11)
 {
     AppendText(flowDocumentScrollViewer, data, flowDocumentScrollViewer.FindResource(Microsoft.VisualStudio.PlatformUI.CommonControlsColors.TextBoxTextBrushKey) as SolidColorBrush, fontSize);
 }
        public void init_show()
        {
            //small_title.Width = content_stackpanel.ActualWidth;
            //newtimer.Elapsed += new System.Timers.ElapsedEventHandler(newtimer_Elapsed);
            //newtimer.Interval = 1000;
            //newtimer.Start();
            // if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            // {
            //  //在此处加载数据并将结果指派给 CollectionViewSource。
            //  System.Windows.Data.CollectionViewSource myCollectionViewSource = (System.Windows.Data.CollectionViewSource)this.Resources["Resource Key for CollectionViewSource"];
            //  myCollectionViewSource.Source = your data
            // }


            //MediaElement newmedia = new MediaElement();

            //newmedia.Source = new Uri(Directory.GetCurrentDirectory() + "\\image\\" + "weicheng.mp4", UriKind.Absolute);

            //abc.Children.Add(newmedia);



            //Thread newthread = new Thread(new ThreadStart(() =>
            //{
            //    Dispatcher.Invoke(new Action(() =>
            //    {



            fcb_public.publicDataSet publicDataSet = ((fcb_public.publicDataSet)(this.FindResource("publicDataSet")));
            fcb_public.publicDataSetTableAdapters.elementTableAdapter     elpublicDataSetTableAdapters      = new publicDataSetTableAdapters.elementTableAdapter();
            fcb_public.publicDataSetTableAdapters.element_setTableAdapter elsetpublicDataSetTableAdapters   = new fcb_public.publicDataSetTableAdapters.element_setTableAdapter();
            fcb_public.publicDataSetTableAdapters.InitializeTableAdapter  initpublicDataSetTableAdapters    = new fcb_public.publicDataSetTableAdapters.InitializeTableAdapter();
            fcb_public.publicDataSetTableAdapters.el_elsetTableAdapter    publicDataSetel_elsetTableAdapter = new fcb_public.publicDataSetTableAdapters.el_elsetTableAdapter();
            publicDataSetel_elsetTableAdapter.Fill(publicDataSet.el_elset);

            elpublicDataSetTableAdapters.Fill(publicDataSet.element);
            elsetpublicDataSetTableAdapters.Fill(publicDataSet.element_set);
            initpublicDataSetTableAdapters.Fill(publicDataSet.Initialize);


            if (elset_id > -1 && init_publicdataset == false)
            {
                var show_el = from el in publicDataSet.element join el_set in publicDataSet.el_elset on el.ID equals el_set.element_ID where elset_id == el_set.element_set_ID select el;
                element_count      = show_el.Count();
                init_publicdataset = true;
                //newtimer.Interval = 1000;
            }

            if (element_count > 0)
            {
                var show_el = from el in publicDataSet.element join el_set in publicDataSet.el_elset on el.ID equals el_set.element_ID where el.status == true && el.start_time <= DateTime.Now && el.end_time >= DateTime.Now  where el_set.element_set_ID == elset_id select el;
                // int temp_step = 0;
                foreach (var t in show_el)
                {
                    //if (step == temp_step)
                    //{
                    var show_el_set = from el_set in publicDataSet.element_set join el_elset in publicDataSet.el_elset on el_set.ID equals el_elset.element_ID where el_elset.element_ID == t.ID select el_elset;
                    foreach (var st in show_el_set)
                    {
                        //var sst = from c in publicDataSet.element_set where c.ID == st.element_set_ID select c;
                        //var sst = from c in publicDataSet.element join el in publicDataSet.el_elset on c.ID equals el.element_ID where el.element_set_ID == elset_id select c;
                        var sst = from c in publicDataSet.element_set where c.ID == elset_id select c;
                        foreach (var ssst in sst)
                        {
                            big_title.Text = ssst.elset_name;
                            // break;
                        }
                    }

                    small_title.Text = t.title;
                    titlename.Add(t.ID + "|" + t.title);


                    //10000;
                    if (t.type == "文档")
                    {
                        small_title.Visibility = Visibility.Hidden;
                        RichTextBox  newRTB            = new RichTextBox();
                        TextRange    documentTextRange = new TextRange(newRTB.Document.ContentStart, newRTB.Document.ContentEnd);
                        MemoryStream stream            = new MemoryStream();
                        StreamWriter sw = new StreamWriter(stream);
                        sw.Write(t.content);
                        sw.Flush();
                        stream.Seek(0, SeekOrigin.Begin);
                        documentTextRange.Load(stream, DataFormats.Xaml);
                        string               xw  = XamlWriter.Save(newRTB.Document);
                        StringReader         sr  = new StringReader(xw);
                        System.Xml.XmlReader xr  = System.Xml.XmlReader.Create(sr);
                        FlowDocument         doc = XamlReader.Load(xr) as FlowDocument;

                        //var showel = from el in publicDataSet.element join el_set in publicDataSet.el_elset on el.ID equals el_set.element_ID where el.status == true where el_set.element_set_ID == elset_id select el;
                        //foreach (var s in showel)
                        //{
                        FlowDocumentScrollViewer deldoc = content_stackpanel.FindName("newdoc" + t.ID) as FlowDocumentScrollViewer;
                        if (deldoc != null)
                        {
                            content_stackpanel.Children.Remove(deldoc);
                            content_stackpanel.UnregisterName("newdoc" + t.ID);
                        }

                        FlowDocumentScrollViewer newdoc = new FlowDocumentScrollViewer();
                        newdoc.Document = doc;
                        // newdoc.Effect = da;
                        //newdoc.Padding = new Thickness(10);
                        newdoc.IsEnabled  = false;
                        newdoc.Foreground = Brushes.White;
                        newdoc.Opacity    = 0;
                        newdoc.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
                        newdoc.Margin = new Thickness(0, 0, 0, 0);
                        newdoc.Width  = content_stackpanel.ActualWidth;
                        newdoc.UpdateLayout();
                        content_stackpanel.Children.Add(newdoc);
                        content_stackpanel.RegisterName("newdoc" + t.ID, newdoc);
                        //newdoc.Name = "newdoc" + t.ID;
                        //Storyboard newstoryboard = new Storyboard();
                        //ThicknessAnimation txt_animation = new ThicknessAnimation();
                        //txt_animation.From = new Thickness(0, 0, 0, 0);
                        //txt_animation.To = new Thickness(0, -800, 0, 0);
                        //// newdoc.Visibility = Visibility.Visible;
                        //txt_animation.Duration = TimeSpan.FromSeconds(t.show_time);
                        //newstoryboard.Children.Add(txt_animation);
                        //Storyboard.SetTargetName(txt_animation, newdoc.Name);
                        //Storyboard.SetTargetProperty(txt_animation, new PropertyPath(MarginProperty));
                        //newstoryboard.Stop(content_stackpanel);
                        //newstoryboard.Begin(content_stackpanel);

                        //DoubleAnimation newadouble = new DoubleAnimation();
                        //newadouble.From = 1;
                        //newadouble.To = 0;
                        //newadouble.Duration = TimeSpan.FromSeconds(1);
                        //newstoryboard.Children.Add(newadouble);
                        //Storyboard.SetTargetName(newadouble, newdoc.Name);
                        //Storyboard.SetTargetProperty(newadouble, new PropertyPath(OpacityProperty));
                        //newstoryboard.Begin(content_stackpanel);

                        //DoubleAnimation newadouble = new DoubleAnimation();
                        //newadouble.From = 1;
                        //newadouble.To = 0;
                        //newadouble.Duration = TimeSpan.FromSeconds(1);
                        //newstoryboard.Children.Add(newadouble);
                        //Storyboard.SetTargetName(txt_animation, newdoc.Name);
                        //Storyboard.SetTargetProperty(newadouble, new PropertyPath(OpacityProperty));
                        //newstoryboard.Begin(content_stackpanel);



                        //}



                        //show_video.Width = 0;
                        //show_video.Height = 0;
                        //show_image.Width = 0;
                        //show_image.Height = 0;
                        //text_content.Document = doc;
                        //newtimer.Interval = t.show_time * 1000;
                        // newtimer.Stop();
                        //newtimer.Start();

                        // PublicClass.show_hight = text_content.Height;
                        //text_content.UpdateLayout();
                        //content_stackpanel.UpdateLayout();

                        //ThicknessAnimation wait_animation = new ThicknessAnimation();
                        //wait_animation.From = new Thickness(0, 0, 0, 0);
                        //wait_animation.To = new Thickness(0, 0, 0, 0);
                        //wait_animation.Duration = TimeSpan.FromSeconds(t.show_time/2);

                        //text_content.BeginAnimation(TextBlock.MarginProperty, wait_animation);

                        // newtimer.Start();
                        //ThicknessAnimation txt_margin_animation = new ThicknessAnimation();
                        //txt_margin_animation.From = new Thickness(0, 0, 0, 0);
                        //txt_margin_animation.To = new Thickness(0, -(text_content.ActualHeight), 0, 0);
                        //txt_margin_animation.Duration = TimeSpan.FromSeconds(t.show_time);

                        //text_content.BeginAnimation(FlowDocumentScrollViewer.MarginProperty, txt_margin_animation);
                        // txt_margin_animation.RepeatBehavior = RepeatBehavior.Forever;

                        // newtimer.Interval = t.show_time * 1000;
                    }
                    else if (t.type == "图片")
                    {
                        //text_content.Width = 0;
                        //text_content.Height = 0;
                        //show_video.Width = 0;
                        //show_video.Height = 0;
                        //show_image.Source = new BitmapImage(new Uri(t.content, UriKind.Absolute));

                        //small_title.Text = t.title;
                        Image delimg = content_stackpanel.FindName("newimage" + t.ID) as Image;
                        if (delimg != null)
                        {
                            content_stackpanel.Children.Remove(delimg);
                            content_stackpanel.UnregisterName("newimage" + t.ID);
                        }
                        content_stackpanel.UpdateLayout();
                        Image newimage = new Image();
                        newimage.Opacity = 0;

                        newimage.Source = new BitmapImage(new Uri(t.content, UriKind.Absolute));
                        newimage.Width  = content_stackpanel.ActualWidth;
                        newimage.Height = this.ActualHeight;
                        //newimage.Width = content_stackpanel.Width;
                        //newimage.Height = content_stackpanel.Height;
                        content_stackpanel.Children.Add(newimage);
                        content_stackpanel.RegisterName("newimage" + t.ID, newimage);

                        //Label backlable = new Label();
                        //small_title.Background = new SolidColorBrush(Color.FromArgb(50, 0, 0, 0));
                        small_title.Margin = new Thickness(0, content_back.ActualHeight - 150, 0, 0);
                        //backlable.Height = 200;
                        small_title.Width = content_stackpanel.ActualWidth;

                        //Panel.SetZIndex(backlable, 2);
                        //content_stackpanel.Children.Add(backlable);
                        //TextBlock newtextblock = new TextBlock();
                    }
                    else if (t.type == "视频")
                    {
                        mvlist.Add(t.content);
                        //text_content.Height = 0;
                        //text_content.Width = 0;
                        //show_image.Width = 0;
                        //show_image.Height = 0;
                        //show_video.Source = new Uri(t.content, UriKind.Absolute);
                        // newtimer.Interval = t.show_time * 1000;
                        small_title.Visibility = Visibility.Hidden;
                    }

                    //}
                    //temp_step++;
                }


                if (mvlist.Count > 0)
                {
                    //foreach (var v in show_el)
                    //{
                    //MediaElement delmedia = content_stackpanel.FindName("newmeida" + v.ID) as MediaElement;
                    //if (delmedia != null)
                    //{
                    //    content_stackpanel.Children.Remove(delmedia);
                    //    content_stackpanel.UnregisterName("newmeida" + v.ID);
                    //}

                    MediaElement newmeida = new MediaElement();


                    content_stackpanel.Children.Add(newmeida);
                    //content_stackpanel.RegisterName("newmeida" + v.ID, newmeida);
                    newmeida.LoadedBehavior   = MediaState.Manual;
                    newmeida.UnloadedBehavior = MediaState.Manual;



                    newmeida.MediaEnded += new RoutedEventHandler(newmeida_MediaEnded);
                    newmeida.Source      = new Uri(mvlist[0], UriKind.Absolute);
                    content_stackpanel.UpdateLayout();
                    newmeida.Width = content_stackpanel.ActualWidth;
                    //newmeida.Height = content_stackpanel.ActualHeight;
                    // newmeida.UpdateLayout();
                    newmeida.Play();
                    //newmeida.Loaded += new RoutedEventHandler(newmeida_Loaded);
                    //newmeida.Unloaded += new RoutedEventHandler(newmeida_Unloaded);
                    //newmeida.MediaOpened += new RoutedEventHandler(newmeida_MediaOpened);
                    //}
                }



                //var showel = from el in publicDataSet.element join el_set in publicDataSet.el_elset on el.ID equals el_set.element_ID where el.status == true where el_set.element_set_ID == elset_id select el;
                //Storyboard newstoryboard = new Storyboard();
                int startanimation = 0;
                foreach (var s in show_el)
                {
                    if (s.type == "文档")
                    {
                        //ThicknessAnimation txt_animation = new ThicknessAnimation();
                        FlowDocumentScrollViewer new_fld = content_stackpanel.FindName("newdoc" + s.ID) as FlowDocumentScrollViewer;
                        new_fld.Name = "newdoc" + s.ID;

                        new_fld.UpdateLayout();

                        Storyboard newstoryboard1 = new Storyboard();
                        newstoryboard1.Name = "t" + s.ID;
                        DoubleAnimation newadoubleop = new DoubleAnimation();
                        newadoubleop.From     = 0;
                        newadoubleop.To       = 1;
                        newadoubleop.Duration = TimeSpan.FromSeconds(5);
                        newstoryboard1.Children.Add(newadoubleop);
                        Storyboard.SetTargetName(newadoubleop, new_fld.Name);
                        Storyboard.SetTargetProperty(newadoubleop, new PropertyPath(OpacityProperty));
                        newstoryboard1.Completed += new EventHandler(newstoryboard_Completed);
                        alist.Add(newstoryboard1);
                        if (startanimation == 0)
                        {
                            newstoryboard1.Begin(content_stackpanel);
                            startanimation = 1;
                        }

                        Storyboard newstoryboard2 = new Storyboard();
                        newstoryboard2.Name = "m" + s.ID;
                        ThicknessAnimation txt_animation = new ThicknessAnimation();
                        txt_animation.From = new Thickness(0, 0, 0, 0);
                        if (PublicClass.show_hight - new_fld.ActualHeight >= 0)
                        {
                            txt_animation.To = new Thickness(0, 0, 0, 0);
                        }
                        else
                        {
                            txt_animation.To = new Thickness(0, (PublicClass.show_hight - new_fld.ActualHeight), 0, 0);
                        }
                        // newdoc.Visibility = Visibility.Visible;
                        txt_animation.Duration = TimeSpan.FromSeconds(s.show_time);
                        newstoryboard2.Children.Add(txt_animation);
                        Storyboard.SetTargetName(txt_animation, new_fld.Name);
                        Storyboard.SetTargetProperty(txt_animation, new PropertyPath(MarginProperty));
                        newstoryboard2.Completed += new EventHandler(newstoryboard_Completed);
                        alist.Add(newstoryboard2);
                        //newstoryboard.Stop(content_stackpanel);
                        //newstoryboard.Begin(content_stackpanel);

                        Storyboard newstoryboard3 = new Storyboard();

                        DoubleAnimation newadouble = new DoubleAnimation();
                        newadouble.From     = 1;
                        newadouble.To       = 0;
                        newadouble.Duration = TimeSpan.FromSeconds(5);
                        newstoryboard3.Children.Add(newadouble);
                        Storyboard.SetTargetName(newadouble, new_fld.Name);
                        Storyboard.SetTargetProperty(newadouble, new PropertyPath(OpacityProperty));
                        newstoryboard3.Completed += new EventHandler(newstoryboard_Completed);
                        alist.Add(newstoryboard3);


                        Storyboard newstoryboard4 = new Storyboard();
                        //newstoryboard2.Name = "m" + s.ID;
                        ThicknessAnimation txt_animation4 = new ThicknessAnimation();
                        //txt_animation4.From = new Thickness(0, 0, 0, 0);
                        txt_animation4.To = new Thickness(0, 0, 0, 0);
                        // newdoc.Visibility = Visibility.Visible;
                        txt_animation4.Duration = TimeSpan.FromSeconds(0.1);
                        newstoryboard4.Children.Add(txt_animation4);
                        Storyboard.SetTargetName(txt_animation4, new_fld.Name);
                        Storyboard.SetTargetProperty(txt_animation4, new PropertyPath(MarginProperty));
                        newstoryboard4.Completed += new EventHandler(newstoryboard_Completed);
                        alist.Add(newstoryboard4);
                    }
                    else if (s.type == "图片")
                    {
                        Image new_img = content_stackpanel.FindName("newimage" + s.ID) as Image;
                        new_img.Name = "newimage" + s.ID;

                        //  new_img.UpdateLayout();

                        Storyboard newstoryboard_img1 = new Storyboard();
                        newstoryboard_img1.Name = "t1" + s.ID;
                        DoubleAnimation newadoubleop = new DoubleAnimation();
                        newadoubleop.From     = 0;
                        newadoubleop.To       = 1;
                        newadoubleop.Duration = TimeSpan.FromSeconds(0.5);
                        newstoryboard_img1.Children.Add(newadoubleop);
                        Storyboard.SetTargetName(newadoubleop, new_img.Name);
                        Storyboard.SetTargetProperty(newadoubleop, new PropertyPath(OpacityProperty));
                        newstoryboard_img1.Completed += new EventHandler(newstoryboard_img1_Completed);
                        alist.Add(newstoryboard_img1);
                        if (startanimation == 0)
                        {
                            newstoryboard_img1.Begin(content_stackpanel);
                            startanimation = 1;
                        }
                        //newstoryboard_img1.Begin(content_stackpanel);



                        Storyboard newstoryboard_img3 = new Storyboard();
                        newstoryboard_img3.Name = "t3" + s.ID;
                        DoubleAnimation newadoubleop3 = new DoubleAnimation();
                        newadoubleop3.From     = 1;
                        newadoubleop3.To       = 1;
                        newadoubleop3.Duration = TimeSpan.FromSeconds(10);
                        newstoryboard_img3.Children.Add(newadoubleop3);
                        Storyboard.SetTargetName(newadoubleop3, new_img.Name);
                        Storyboard.SetTargetProperty(newadoubleop3, new PropertyPath(OpacityProperty));
                        newstoryboard_img3.Completed += new EventHandler(newstoryboard_img1_Completed);
                        alist.Add(newstoryboard_img3);



                        Storyboard newstoryboard_img2 = new Storyboard();
                        newstoryboard_img1.Name = "t2" + s.ID;
                        DoubleAnimation newadoubleop2 = new DoubleAnimation();
                        newadoubleop2.From     = 1;
                        newadoubleop2.To       = 0;
                        newadoubleop2.Duration = TimeSpan.FromSeconds(0.5);
                        newstoryboard_img2.Children.Add(newadoubleop2);
                        Storyboard.SetTargetName(newadoubleop2, new_img.Name);
                        Storyboard.SetTargetProperty(newadoubleop2, new PropertyPath(OpacityProperty));
                        newstoryboard_img2.Completed += new EventHandler(newstoryboard_img1_Completed);
                        alist.Add(newstoryboard_img2);
                        //newstoryboard_img2.Begin(content_stackpanel);
                    }
                }


                //newstoryboard.Begin(content_stackpanel);

                //step++;
                //if (step > element_count)
                //{
                //    step = 0;
                //}
            }



            //    }));



            //}));
            //newthread.SetApartmentState(ApartmentState.MTA);
            //newthread.IsBackground = true;
            ////newthread.Priority = ThreadPriority.AboveNormal;
            //newthread.Start();
        }
Beispiel #12
0
 private static void AddParagraph(string line, FlowDocumentScrollViewer viewer)
 {
     viewer.Document.Blocks.Add(new Paragraph(new Run(line)));
 }
Beispiel #13
0
 public LicensesViewModel(Window view, FlowDocumentScrollViewer licenseReaderForQuilt, FlowDocumentScrollViewer licenseReaderDirectShowNet)
 {
     _licenseReaderForQuilt      = licenseReaderForQuilt;
     _licenseReaderDirectShowNet = licenseReaderDirectShowNet;
     CloseViewCommand            = new CloseViewCommand(view);
     view.Loaded += ViewOnLoaded;
 }
        public FrameworkElement CreateContentCardPropertyExpositor(string Title, object Value,
                                                                   TextFormat TitleFormat, Brush TitleBackground,
                                                                   TextFormat ValueFormat = null, Brush ValueBackground = null,
                                                                   double MaxValueWidth   = double.PositiveInfinity,
                                                                   double MaxValueHeight  = double.PositiveInfinity)
        {
            var Result = new Border();

            Result.BorderBrush       = Configuration.FmtCardLinesForeground;
            Result.BorderThickness   = new Thickness(LINES_CARD_THICKNESS);
            Result.VerticalAlignment = VerticalAlignment.Stretch;
            // NO! it becomes very ugly... Result.HorizontalAlignment = HorizontalAlignment.Left;

            var Frame = new DockPanel();

            FrameworkElement TitleLabel = null;

            if (!Title.IsAbsent())
            {
                TitleLabel = CreateText(Title, TitleFormat, HorizontalAlignment.Stretch, VerticalAlignment.Top,
                                        TitleBackground);
            }

            FrameworkElement ValueLabel = null;

            if (Value is ImageSource)
            {
                var PictureValue = this.CurrentWorker.AtOriginalThreadGetFrozen((ImageSource)Value);

                var PictureLabel = new Border();
                var SquareSize   = Math.Min(PictureValue.Width, PictureValue.Height);
                var Picture      = new Image();
                Picture.MaxWidth   = SquareSize;
                Picture.MaxHeight  = SquareSize;
                Picture.Source     = PictureValue;
                Picture.Stretch    = Stretch.Uniform;
                PictureLabel.Child = Picture;

                ValueLabel = PictureLabel;
            }
            else
            if (Value is FlowDocument)
            {
                var DocViewer = new FlowDocumentScrollViewer();
                DocViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
                DocViewer.VerticalScrollBarVisibility   = ScrollBarVisibility.Disabled;
                DocViewer.VerticalAlignment             = VerticalAlignment.Top;
                DocViewer.VerticalContentAlignment      = VerticalAlignment.Top;
                DocViewer.Document = (FlowDocument)Value;
                ValueLabel         = DocViewer;
            }
            else
            {
                ValueLabel = CreateText(Value.ToStringAlways(), ValueFormat.NullDefault(TitleFormat), HorizontalAlignment.Stretch, VerticalAlignment.Top,
                                        ValueBackground.NullDefault(TitleBackground));
            }

            ValueLabel.MaxWidth  = MaxValueWidth;
            ValueLabel.MaxHeight = MaxValueHeight;

            if (TitleLabel != null)
            {
                Frame.Children.Add(TitleLabel);
            }

            Frame.Children.Add(ValueLabel);

            if (TitleLabel != null)
            {
                DockPanel.SetDock(TitleLabel, Dock.Top);
            }

            Result.Child = Frame;

            return(Result);
        }
Beispiel #15
0
        public void UpdateGlyph()
        {
            FlowDocumentScrollViewer doc = this.TextNoteGlyph;

            doc.Document = TextNote.Load(this.Note);
        }