コード例 #1
0
        private FlowDocument CloneCurrentReportDocument(bool convertInlineUiElements)
        {
            MemoryStream ms = new MemoryStream();

            XamlWriter.Save(this._textArea.DocumentAttached, ms);
            ms.Position = 0;
            FlowDocument new_fd = (FlowDocument)XamlReader.Load(ms);

            ms.Close();
            ms.Dispose();

            List <InsertBlock> blocksToInsert = new List <InsertBlock>();
            Block prev_Block = new_fd.Blocks.FirstBlock;

            foreach (Block oriBlock in new_fd.Blocks)
            {
                Paragraph p = oriBlock as Paragraph;
                if (p != null)
                {
                    Paragraph newParagraph = new Paragraph();
                    bool      AddP         = false;

                    foreach (Inline inL in p.Inlines)
                    {
                        if (inL is InlineUIContainer)
                        {
                            ReportQuoteBoxEX tb = ((InlineUIContainer)inL).Child as ReportQuoteBoxEX;
                            if (tb != null)
                            {
                                Run r = new Run(tb.QuoteTitle + "\n" + tb.QuoteContent);
                                r.Foreground = tb.Fill;
                                newParagraph.Inlines.Add(r);
                                AddP = true;
                            }
                        }
                    }

                    if (AddP)
                    {
                        blocksToInsert.Add(new InsertBlock()
                        {
                            blockToInsert = newParagraph, insertPoint = prev_Block
                        });
                    }
                }
                prev_Block = oriBlock;
            }

            if (convertInlineUiElements)
            {
                foreach (InsertBlock bI in blocksToInsert)
                {
                    new_fd.Blocks.InsertAfter(bI.insertPoint, bI.blockToInsert);
                }
            }

            return(new_fd);
        }
コード例 #2
0
        /// <summary>
        /// Handles the actual drop.
        /// </summary>
        private void _textArea_PreviewDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (this.IsEditingLocked)
                {
                    MessageBox.Show("このリポートは、現在編集出来ません",
                                    "レポートがロックされている。", MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }

                bool isKMEntity = false;
                foreach (string format in e.Data.GetFormats())
                {
                    if (format.Contains("KnowledgeMapTextEntity"))
                    {
                        isKMEntity = true;
                    }
                }

                if (isKMEntity)
                {
                    KnowledgeMapTextEntity t = (KnowledgeMapTextEntity)e.Data.GetData(typeof(KnowledgeMapTextEntity));
                    string id    = t.Id.ToString();
                    string body  = t.Body;
                    string title = t.SourceReference.DocumentTitle + " (p." + t.SourceReference.PageNumber.ToString() + ")";

                    using (this._textArea.DeclareChangeBlock())
                    {
                        Point       point    = e.GetPosition(this._textArea);
                        TextPointer position = this._textArea.GetPositionFromPoint(point, true);
                        //080731
                        TextPointer insP = position.InsertParagraphBreak();

                        //080805
                        ReportQuoteBoxEX rqb = new ReportQuoteBoxEX();
                        rqb.Fill = new SolidColorBrush(
                            Color.FromArgb(255, t.Color.Color.R, t.Color.Color.G, t.Color.Color.B));
                        rqb.QuoteContent      = body;
                        rqb.QuoteTitle        = title;
                        rqb.PreviewMouseDown += new MouseButtonEventHandler(tb_PreviewMouseDown);
                        rqb.Margin            = new Thickness(25, 16, 25, 16);
                        InlineUIContainer container = new InlineUIContainer(rqb, position);

                        //080731
                        insP.InsertParagraphBreak();
                    }
                    e.Handled = true;
                }
            }
            catch (Exception ex)
            {
                //TODO: Fix message...
                MessageBox.Show("この位置に引用出来ませんでした。もう一度他の位置で試して見て下さい。\n\n"
                                + "(別の引用の上には駄目ですよ)", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #3
0
        private void UpdateLetterCount()
        {
            int total  = 0;
            int copied = 0;

            foreach (Block bl in this._textArea.Document.Blocks)
            {
                Paragraph p = bl as Paragraph;
                if (p != null)
                {
                    foreach (Inline inL in p.Inlines)
                    {
                        if (inL is Run)
                        {
                            total += ((Run)inL).Text.Length;
                        }
                        else if (inL is InlineUIContainer)
                        {
                            ReportQuoteBoxEX rqb = ((InlineUIContainer)inL).Child as ReportQuoteBoxEX;
                            if (rqb != null)
                            {
                                total  += (rqb.QuoteContent.Length + rqb.QuoteTitle.Length);
                                copied += rqb.QuoteContent.Length;
                            }
                        }
                    }
                }
            }

            if (total == 0)
            {
                this._l_LinkPercentage.Content = "0%";
            }
            else
            {
                double p  = (double)copied / (double)total;
                int    p2 = (int)(p * 100);
                if (p2 == 0)
                {
                    this._l_LinkPercentage.Content = ">1%";
                }
                else
                {
                    this._l_LinkPercentage.Content = p2.ToString() + "%";
                }
            }

            this._l_MojiCount.Content = total.ToString() + Application.Current.Resources["Str_UiLbl_CharacterLiteral"] as string;
        }
コード例 #4
0
        /// <summary>
        /// Handles the actual drop.
        /// </summary>
        private void _textArea_PreviewDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (this.IsEditingLocked)
                {
                    MessageBox.Show(Application.Current.Resources["ERR_ReportEditFailed_Locked"] as string,
                                    Application.Current.Resources["Str_MsgTitle_ReportLocked"] as string, MessageBoxButton.OK, MessageBoxImage.Stop);
                    return;
                }

                bool isKMEntity = false;
                foreach (string format in e.Data.GetFormats())
                {
                    if (format.Contains("KnowledgeMapTextEntity"))
                    {
                        isKMEntity = true;
                    }
                }

                if (isKMEntity)
                {
                    KnowledgeMapTextEntity t       = (KnowledgeMapTextEntity)e.Data.GetData(typeof(KnowledgeMapTextEntity));
                    string          id             = t.Id.ToString();
                    string          body           = t.Body;
                    string          title          = "";
                    SolidColorBrush titleFillBrush = Brushes.White;

                    //090220
                    if (t.EntityType == KnowledgeMapEntityType.ConnectedToDocument)
                    {
                        title          = t.SourceReference.DocumentTitle + " (p." + t.SourceReference.PageNumber.ToString() + ")";
                        titleFillBrush = new SolidColorBrush(
                            Color.FromArgb(255, t.Color.Color.R, t.Color.Color.G, t.Color.Color.B));
                    }
                    else
                    {
                        title          = Application.Current.Resources["Str_UiLbl_ReportReferencedSelfNodeTitle"] as string + " " + t.Title;
                        titleFillBrush = Brushes.DarkGray;
                    }

                    using (this._textArea.DeclareChangeBlock())
                    {
                        Point       point    = e.GetPosition(this._textArea);
                        TextPointer position = this._textArea.GetPositionFromPoint(point, true);
                        //080731
                        TextPointer insP = position.InsertParagraphBreak();

                        //080805
                        ReportQuoteBoxEX rqb = new ReportQuoteBoxEX();
                        rqb.Fill              = titleFillBrush;
                        rqb.QuoteContent      = body;
                        rqb.QuoteTitle        = title;
                        rqb.PreviewMouseDown += new MouseButtonEventHandler(tb_PreviewMouseDown);
                        rqb.Margin            = new Thickness(25, 16, 25, 16);
                        InlineUIContainer container = new InlineUIContainer(rqb, position);

                        //080731
                        insP.InsertParagraphBreak();
                    }
                    e.Handled = true;
                }
            }
            catch (Exception)
            {
                //TODO: Fix message...
                MessageBox.Show(Application.Current.Resources["EX_ReportReferenceAddFailed"] as string, Application.Current.Resources["Str_ErrorDlgTitle"] as string, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }