Пример #1
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);
            }
        }
Пример #2
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);
            }
        }