private void btnAddTextBlock_Click(object sender, RoutedEventArgs e)
 {
     Text lastTxt = Txt;
     Txt = Text.NewText();
     if (Txt != null)
     {
         preview.RemoveIObject(lastTxt);
         ObjectPositionOnSlide.ApplyTextModifications(Txt, preview);
         preview.AddIObject(Txt);
         _txtAdded = true;
     }
     else Txt = lastTxt;
     CheckIfAllComponentsAdded();
 }
        public AddTextWindow(Text txt)
        {
            InitializeComponent();
            Txt = txt.DeepCopyWithObjectId() as Text;
            foreach (ComAction action in txt.Actions)
                Txt.Actions.Add(action);
            RefreshActions();

            //set txt editor
            TextEditor.FontSize = txt.TextSize;
            TextEditor.FontStyle = txt.FontStyle;
            TextEditor.FontWeight = txt.FontWeight;
            TextEditor.Foreground = txt.TextColor;
            TextEditor.Focus();

            //set correct value in combo box
            bool matchFound = false;
            double fontSize = txt.TextSize;
            foreach (ComboBoxItem item in cbSize.Items)
            {
                if (Math.Abs(double.Parse(item.Content.ToString()) - fontSize) > Epsilon) continue;
                item.IsSelected = true;
                matchFound = true;
                break;
            }

            if (matchFound) return;

            List<double> tempList =
                (from ComboBoxItem item in cbSize.Items select double.Parse(item.Content.ToString())).ToList();
            tempList.Add(fontSize);
            tempList.Sort();
            cbSize.Items.Clear();
            foreach (double item in tempList)
            {
                var newItem = new ComboBoxItem {Content = item.ToString(CultureInfo.InvariantCulture)};
                if (Math.Abs(item - fontSize) < Epsilon)
                    newItem.IsSelected = true;
                cbSize.Items.Add(newItem);
            }
        }
Exemple #3
0
 public static void SetTxtWidthAndHeight(Text txt)
 {
     var formattedText = FormattedText(txt);
     txt.Width = formattedText.WidthIncludingTrailingWhitespace;
     txt.Height = formattedText.Height;
 }
Exemple #4
0
        public static Text NewText()
        {
            var tb = new Text();
            var w = new AddTextWindow(tb);

            if (w.ShowDialog() != true) return null;

            var mainWin = DesignerMainWindow.GetInstance();
            Point currentMousePosition = mainWin.GetCurrentMousePosition();

            tb.Txt.Text = w.Txt.Txt.Text;
            tb.Txt.FontSize = w.Txt.Txt.FontSize;
            tb.Txt.FontStyle = w.Txt.Txt.FontStyle;
            tb.Txt.FontWeight = w.Txt.Txt.FontWeight;
            tb.Txt.Foreground = w.Txt.Txt.Foreground;

            InkCanvas.SetTop(tb, currentMousePosition.Y);
            InkCanvas.SetLeft(tb, currentMousePosition.X);
            Panel.SetZIndex(tb, Practice.GetInstance().GetSlideByPosition(mainWin.GetCurrentSlideNr()).SlideObjects.Count);

            SetTxtWidthAndHeight(tb);

            tb.Actions.Clear();
            foreach (ComAction a in w.Txt.Actions)
                tb.Actions.Add(a);

            return tb;
        }
Exemple #5
0
 public static FormattedText FormattedText(Text txt)
 {
     return new FormattedText(txt.TextContent, CultureInfo.InvariantCulture, FlowDirection.LeftToRight,
                              txt.FontTypeface, txt.TextSize, Brushes.Black);
 }
Exemple #6
0
        public IObject DeepCopy()
        {
            var newTb = new Text
                {
                    Txt =
                        {
                            Text = Txt.Text,
                            FontSize = Txt.FontSize,
                            FontStyle = Txt.FontStyle,
                            FontWeight = Txt.FontWeight,
                            Foreground = Txt.Foreground
                        },
                    Visible = Visible,
                    Height = Height,
                    Width = Width
                };

            if (!newTb.Visible)
                newTb.Opacity = 0.3;

            return newTb;
        }
        private void LoadObjects()
        {
            var objects = entities[OBJECTS];
            var maxObjId = 0;
            foreach (var obj in objects)
            {
                IObject newObject = null;
                var attributes = ConvertXmlAttributes(obj.Attributes());

                switch (obj.Name.ToString())
                {
                    case "image":
                        newObject = new Picture();
                        break;
                    case "video":
                        newObject = new Video(false);
                        break;
                    case "sound":
                        newObject = new Sound(false);
                        break;
                    case "text":
                        newObject = new Text();
                        break;
                    case "flash":
                        newObject = new FlashAnimation();
                        break;
                    case "area":
                        newObject = new Area();
                        break;
                    case "dropContainer":
                        newObject = new DropContainer();
                        break;
                }

                if (newObject == null) return;
                newObject.Load(attributes);
                if (newObject.ObjectId > maxObjId) maxObjId = newObject.ObjectId;
                Practice.GetInstance().GetSlideById(newObject.SlideId).AddObject(newObject);
            }   
            Practice.SetObjectIdCounter(maxObjId + 1);
        }
        private Grid CreateDropForTxt(Text txt)
        {
            var childElement = txt.DeepCopy() as Text;
            childElement.RemoveObjectHandlers();
            var brdr = new Border {Background = Brushes.White, Child = childElement};

            if (double.IsNaN(childElement.Height) || double.IsNaN(childElement.Width))
                Viewbox.Stretch = Stretch.None;
            else
            {
                Height = Viewbox.Height = Viewbox.MaxHeight = childElement.Height + 15;
                Width = Viewbox.Width = Viewbox.MaxWidth = childElement.Width + 15;
            }

            Viewbox.Child = brdr;
            var grid = new Grid();
            grid.Children.Add(Viewbox);

            return grid;
        }