Exemplo n.º 1
0
        private static void editFraction(RichTextEditor editor)
        {
            RichTextBox richTextBox       = editor.RichTextBox;
            TextPointer insertionPosition = richTextBox.Selection.End;

            Image          image = Helper.GetImageAncestor(insertionPosition);
            FractionDialog dlg   = new FractionDialog();

            if (image != null)
            {
                dlg.FractionPart = editor.GetQuestionContentPart(image.Tag as string) as QuestionFractionPart;
            }

            if (dlg.ShowDialog().Value)
            {
                PictureCommands.InsertMathPicture(editor, dlg.FractionImage, dlg.FractionPart.PlaceHolder);
                if (image != null)
                {
                    foreach (var temp in editor.Parts)
                    {
                        if (temp.PlaceHolder == (image.Tag as string))
                        {
                            editor.Parts.Remove(temp);
                            break;
                        }
                    }
                }

                editor.Parts.Add(dlg.FractionPart);
            }
        }
Exemplo n.º 2
0
        private static void insertFraction(RichTextEditor editor)
        {
            FractionDialog dlg = new FractionDialog();

            if (dlg.ShowDialog().Value)
            {
                PictureCommands.InsertMathPicture(editor, dlg.FractionImage, dlg.FractionPart.PlaceHolder);
                editor.Parts.Add(dlg.FractionPart);
            }
        }
Exemplo n.º 3
0
        public static void OnInsertPicture(object sender, ExecutedRoutedEventArgs e)
        {
            RichTextEditor control     = (RichTextEditor)sender;
            RichTextBox    richTextBox = control.RichTextBox;

            //###
            TextPointer textPosition = richTextBox.Selection.Start;

            Image image = Helper.GetImageAncestor(textPosition);

            if (null != image)
            {
                if (image.Tag is string)
                {
                    string tag = image.Tag as string;
                    if (!tag.StartsWith("_$FRACTION_"))
                    {
                        PictureCommands.OnEditPictureProperties(sender, e);
                        return;
                    }
                }
                else
                {
                    PictureCommands.OnEditPictureProperties(sender, e);
                    return;
                }
            }
            //###

            if (!richTextBox.Selection.IsEmpty)
            {
                richTextBox.Selection.Text = String.Empty;
            }

            TextPointer insertionPosition = richTextBox.Selection.Start;

            ImagePropertiesDialog imageProperties = new ImagePropertiesDialog(null);

            imageProperties.ShowDialog();

            if (true == imageProperties.DialogResult)
            {
                try
                {
                    Paragraph paragraph = insertionPosition.Paragraph;

                    // Split current paragraph at insertion position
                    //    insertionPosition = insertionPosition.InsertParagraphBreak();
                    //    paragraph = insertionPosition.Paragraph;
                    //paragraph.Inlines.Add("Some ");

                    //AcmBitmapImageHolder acmBitmapImageHolder = new AcmBitmapImageHolder(new Uri(@"http://www.cetelem.cz/images/cetelem2/cetelem_logo_cl_small.gif"));
                    AcmBitmapImageHolder acmBitmapImageHolder = new AcmBitmapImageHolder(new Uri(imageProperties.ImagePath));

                    //acmBitmapImageHolder.Image.Style= sender.
                    paragraph.Inlines.Add(acmBitmapImageHolder.Image);
                    paragraph.Inlines.LastInline.BaselineAlignment = BaselineAlignment.Center;

                    if (!String.IsNullOrEmpty(imageProperties.ImageHyperlink))
                    {
                        //### Set hyperlink
                        //    acmBitmapImageHolder.Image.Tag = imageProperties.ImageHyperlink;
                        //    Hyperlink hyperlink = new Hyperlink(paragraph.Inlines.LastInline, insertionPosition);
                        //    hyperlink.NavigateUri = new Uri(imageProperties.ImageHyperlink);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format("{0} ({1}) :\n\r{2}", SoonLearning.Assessment.Player.Properties.Resources.txtLoadPictureFailed, imageProperties.ImageHyperlink, ex),
                                    SoonLearning.Assessment.Player.Properties.Resources.txtEditorName);
                }
            }
        }