コード例 #1
0
        void pasteMenu_Click(object sender, EventArgs e)
        {
            Undo.Push(new UndoTourSlidelistChange(Language.GetLocalizedText(544, "Paste Object"), tour));

            IDataObject dataObject = Clipboard.GetDataObject();

            if (dataObject.GetDataPresent(Overlay.ClipboardFormat))
            {
                // add try catch block
                string xml = dataObject.GetData(Overlay.ClipboardFormat) as string;
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.LoadXml(xml);
                ClearSelection();
                System.Xml.XmlNode parent = doc["Overlays"];
                foreach (XmlNode child in parent.ChildNodes)
                {
                    Overlay copy = Overlay.FromXml(tour.CurrentTourStop, child);
                    if (copy.AnimationTarget != null)
                    {
                        copy.Id = Guid.NewGuid().ToString();
                        copy.AnimationTarget.TargetID = copy.Id;
                        tour.CurrentTourStop.AnimationTargets.Add(copy.AnimationTarget);
                    }
                    bool found = false;
                    float maxX = 0;
                    float maxY = 0;
                    foreach (Overlay item in tour.CurrentTourStop.Overlays)
                    {
                        if (item.Id == copy.Id && item.GetType() == copy.GetType())
                        {
                            found = true;
                            if (maxY < item.Y || maxX < item.X)
                            {
                                maxX = item.X;
                                maxY = item.Y;
                            }
                        }
                    }

                    if (found)
                    {
                        copy.X = maxX + 20;
                        copy.Y = maxY + 20;
                    }

                    tour.CurrentTourStop.AddOverlay(copy);
                    Focus = copy;
                    selection.AddSelection(Focus);
                    OverlayList.UpdateOverlayList(tour.CurrentTourStop, Selection);
                }
            }
            else if (UiTools.IsMetaFileAvailable())
            {
                Image img = UiTools.GetMetafileFromClipboard();
                if (img != null)
                {
                    BitmapOverlay bmp = new BitmapOverlay( tour.CurrentTourStop, img);
                    tour.CurrentTourStop.AddOverlay(bmp);
                    bmp.X = contextPoint.X;
                    bmp.Y = contextPoint.Y;
                    Focus = bmp;
                    selection.SetSelection(Focus);
                    OverlayList.UpdateOverlayList(tour.CurrentTourStop, Selection);
                }
            }
            else if (Clipboard.ContainsText() && Clipboard.GetText().Length > 0)
            {
                TextObject temp = TextEditor.DefaultTextobject;
                temp.Text = Clipboard.GetText();

                TextOverlay text = new TextOverlay( temp);
                //text.X = Earth3d.MainWindow.ClientRectangle.Width / 2;
                //text.Y = Earth3d.MainWindow.ClientRectangle.Height / 2;
                text.X = contextPoint.X;
                text.Y = contextPoint.Y;
                tour.CurrentTourStop.AddOverlay(text);
                Focus = text;
                selection.SetSelection(Focus);
                OverlayList.UpdateOverlayList(tour.CurrentTourStop, Selection);
            }
            else if (Clipboard.ContainsImage())
            {
                Image img = Clipboard.GetImage();
                BitmapOverlay bmp = new BitmapOverlay( tour.CurrentTourStop, img);
                tour.CurrentTourStop.AddOverlay(bmp);
                bmp.X = contextPoint.X;
                bmp.Y = contextPoint.Y;
                Focus = bmp;
                selection.SetSelection(Focus);
                OverlayList.UpdateOverlayList(tour.CurrentTourStop, Selection);
            }
        }
コード例 #2
0
        public bool AddText(string p, TextObject textObject)
        {
            if (tour == null || tour.CurrentTourStop == null)
            {
                return false;
            }

            TextOverlay text = new TextOverlay( textObject);
            text.Color = textObject.ForegroundColor;
            text.X = 960;
            text.Y = 600;
            //todo localize
            Undo.Push(new UndoTourStopChange(Language.GetLocalizedText(547, "Insert Text"), tour));
            tour.CurrentTourStop.AddOverlay(text);
            OverlayList.UpdateOverlayList(tour.CurrentTourStop, Selection);
            return true;
        }
コード例 #3
0
 public Overlay AddOverlay(Overlay ol)
 {
     if (tour == null || tour.CurrentTourStop == null)
     {
         return null;
     }
     if(ol.GetType() == typeof(ShapeOverlay))
     {
         ShapeOverlay srcShapeOverlay = (ShapeOverlay)ol;
         if (srcShapeOverlay != null)
         {
             ShapeOverlay shape = new ShapeOverlay(tour.CurrentTourStop, srcShapeOverlay.ShapeType);
             shape.Width = srcShapeOverlay.Width;
             shape.Height = srcShapeOverlay.Height;
             shape.X = contextPoint.X;
             shape.Y = contextPoint.Y;
             shape.Color = srcShapeOverlay.Color;
             shape.RotationAngle = srcShapeOverlay.RotationAngle;
             if (ol.AnimationTarget != null)
             {
                 shape.AnimationTarget = ol.AnimationTarget.Clone(shape);
             }
             tour.CurrentTourStop.AddOverlay(shape);
             return shape;
         }
     }
     else if (ol.GetType() == typeof(TextOverlay))
     {
         TextOverlay srcTxtOverlay = (TextOverlay)ol;
         if (srcTxtOverlay != null)
         {
             TextOverlay text = new TextOverlay(srcTxtOverlay.TextObject);
             text.X = contextPoint.X;
             text.Y = contextPoint.Y;
             text.Color = srcTxtOverlay.Color;
             if (ol.AnimationTarget != null)
             {
                 text.AnimationTarget = ol.AnimationTarget.Clone(text);
             }
             tour.CurrentTourStop.AddOverlay(text);
             return text;
         }
     }
     else if (ol.GetType() == typeof(BitmapOverlay))
     {
         BitmapOverlay srcBmpOverlay = (BitmapOverlay)ol;
         if (srcBmpOverlay != null)
         {
             BitmapOverlay bitmap = srcBmpOverlay.Copy(tour.CurrentTourStop);
             bitmap.X = contextPoint.X;
             bitmap.Y = contextPoint.Y;
             if (ol.AnimationTarget != null)
             {
                 bitmap.AnimationTarget = ol.AnimationTarget.Clone(bitmap);
             }
             tour.CurrentTourStop.AddOverlay(bitmap);
             return bitmap;
         }
     }
     else if (ol.GetType() == typeof(FlipbookOverlay))
     {
         FlipbookOverlay srcFlipbookOverlay = (FlipbookOverlay)ol;
         if (srcFlipbookOverlay != null)
         {
             FlipbookOverlay bitmap = srcFlipbookOverlay.Copy(tour.CurrentTourStop);
             bitmap.X = contextPoint.X;
             bitmap.Y = contextPoint.Y;
             if (ol.AnimationTarget != null)
             {
                 bitmap.AnimationTarget = ol.AnimationTarget.Clone(bitmap);
             }
             tour.CurrentTourStop.AddOverlay(bitmap);
             return bitmap;
         }
     }
     return null;
 }