public override bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode)
        {
            bool retVal = true;
            int  index;

            switch (mode)
            {
            case PasteMode.BEGINNING: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    trkpModel.Parent = this;
                    Trackpoints.Insert(0, trkpModel);
                }
                break;
            }

            case PasteMode.BEFORE: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    index = Trackpoints.IndexOf((GpxTrackpointModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        trkpModel.Parent = this;
                        Trackpoints.Insert(index, trkpModel);
                    }
                }
                break;
            }

            case PasteMode.AFTER: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    index            = Trackpoints.IndexOf((GpxTrackpointModel)oldModel);
                    trkpModel.Parent = this;
                    Trackpoints.Insert(index + 1, trkpModel);
                }
                break;
            }

            case PasteMode.END: {
                if (newModel is GpxTrackpointModel trkpModel)
                {
                    trkpModel.Parent = this;
                    Trackpoints.Add(trkpModel);
                }
                break;
            }
            }
            return(retVal);
        }
예제 #2
0
        public virtual void Set(Point dest, Rectangle source, Canvas canvas, PasteMode pasteMode = PasteMode.Normal)
        {
            Rectangle destRect = new Rectangle(dest, source.Size);

            destRect.Restrict(new Rectangle(Size));
            int offsetx = destRect.Left - dest.X;
            int offsety = destRect.Top - dest.Y;

            switch (pasteMode)
            {
            case PasteMode.Normal:
                for (int y = 0; y < destRect.Height; y++)
                {
                    SetLine(destRect.Left, destRect.Top + y, source.Left + offsetx, destRect.Width, canvas.GetLine(source.Top + y + offsety));
                }
                break;

            case PasteMode.Under:
                for (int y = 0; y < destRect.Height; y++)
                {
                    for (int x = 0; x < destRect.Width; x++)
                    {
                        var destPt = destRect.TopLeft + new Size(x, y);
                        var ce     = this[destPt];
                        if (ce.IsTransparent)
                        {
                            this[destPt] = canvas[source.TopLeft + new Size(x, y)];
                        }
                    }
                }
                break;

            case PasteMode.Transparent:
                for (int y = 0; y < destRect.Height; y++)
                {
                    for (int x = 0; x < destRect.Width; x++)
                    {
                        var destPt = destRect.TopLeft + new Size(x, y);
                        var ce     = canvas[source.TopLeft + new Size(x, y)];
                        if (!ce.IsTransparent)
                        {
                            this[destPt] = ce;
                        }
                    }
                }
                break;
            }
            OnUpdate(destRect);
        }
예제 #3
0
        void Do(Point position, PasteMode pasteMode, Canvas canvas, Rectangle?clearRect, Point?cursorPosition)
        {
            var handler = this.Handler as CharacterHandler;

            if (clearRect != null)
            {
                var cr = clearRect.Value;
                cr.Normalize();
                handler.Undo.Save(cursorPosition, position, cr, new Rectangle(position, canvas.Size));
                handler.CurrentPage.Canvas.Fill(cr, CanvasElement.Default);
                handler.InvalidateCharacterRegion(cr, true);
            }
            else
            {
                handler.Undo.Save(cursorPosition, position, new Rectangle(position, canvas.Size));
            }

            handler.CurrentPage.Canvas.Set(position, new Rectangle(canvas.Size), canvas, pasteMode);
            handler.InvalidateCharacterRegion(new Rectangle(position, canvas.Size), true);
        }
예제 #4
0
        // TODO: For nice flexibility this should be a wrapper with plug-in provider support.
        // Since the base provider API doesn't support any modifications at all, we need custom implementations for every modification.
        // The UnifiedFile and UnifiedDirectory provides abstract API for modifications, but it's likely that the individual inheritors
        // are incompatible with each other. Meaning that moving a file between different providers are likely to fail.



        /// <summary>
        /// Pastes the files in the source collection to the supplied target directory.
        /// </summary>
        /// <param name="sourceItems">A collection of source items to paste.</param>
        /// <param name="targetDirectory">The destination directory.</param>
        /// <param name="pasteMode">
        /// Determines how the source files are treated when the paste operation is performed.
        /// <list type="table">
        ///     <listheader>
        ///         <term>pasteMode</term><description>Result</description>
        ///     </listheader>
        ///     <item>
        ///         <term><see cref="PasteMode.Copy"/></term>
        ///         <description>The source items are copied to the new location.</description>
        ///     </item>
        ///     <item>
        ///         <term><see cref="PasteMode.Cut"/></term>
        ///         <description>The source items are moved from their original location to the new location.</description>
        ///     </item>
        /// </list>
        /// </param>
        public static void PasteFiles(VirtualFileBaseCollection sourceItems, UnifiedDirectory targetDirectory, PasteMode pasteMode)
        {
            // Have to assume unified file
            // The Versioning VPP has copy/move support built in, but only for operations inside the Versioning file systems.
            foreach (VirtualFileBase sourceItem in sourceItems)
            {
                try
                {
                    if (pasteMode == PasteMode.Copy)
                    {
                        CopyItem(sourceItem, targetDirectory);
                    }
                    else if (pasteMode == PasteMode.Cut)
                    {
                        MoveItem(sourceItem, targetDirectory);
                    }
                }
                catch (FileIsCheckedOutException)
                {
                    continue;
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Adds a new model
 /// </summary>
 /// <param name="oldModel">Used for locating the place in the list to
 /// put the new model. Can be null for PasteMode.BEGINNING
 /// or PasteMode.End.</param>
 /// <param name="newModelThe model to be added."></param>
 /// <param name="mode">PasteMode specifying where in the list to
 /// place the new model relative to the old model.</param>
 /// <returns></returns>
 public abstract bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode);
예제 #6
0
 public virtual ISitecoreItem PasteItem(string xml, bool changeIDs, PasteMode mode)
 {
     return ItemFactory.BuildItem(_item.PasteItem(xml, changeIDs, mode));
 }
예제 #7
0
 public virtual void Paste(string xml, bool changeIDs, PasteMode mode)
 {
     _item.Paste(xml, changeIDs, mode);
 }
예제 #8
0
 public virtual ISitecoreItem PasteItem(string xml, bool changeIDs, PasteMode mode)
 {
     return(ItemFactory.BuildItem(_item.PasteItem(xml, changeIDs, mode)));
 }
예제 #9
0
 public virtual void Paste(string xml, bool changeIDs, PasteMode mode)
 {
     _item.Paste(xml, changeIDs, mode);
 }
예제 #10
0
 public static void PasteInt16ToByteArray(short val, byte[] target, int startIndex, PasteMode mode)
 {
     byte[] b = BitConverter.GetBytes(val);
     if (mode == PasteMode.LOW_HIGH)
     {
         for (int i = 0; i < b.Length; i++)
         {
             target[startIndex + i] = b[i];
         }
     }
     else
     {
         int targetIndex = b.Length - 1;
         for (int i = 0; i < b.Length; i++)
         {
             target[startIndex + targetIndex] = b[i];
             targetIndex--;
         }
     }
 }
예제 #11
0
 public override bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode)
 {
     throw new NotImplementedException();
 }
예제 #12
0
        public override bool add(GpxModel oldModel, GpxModel newModel, PasteMode mode)
        {
            bool retVal = true;
            int  index  = -1;

            switch (mode)
            {
            case PasteMode.BEGINNING: {
                if (newModel is GpxTrackModel trkModel)
                {
                    trkModel.Parent = this;
                    Tracks.Insert(0, trkModel);
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    rteModel.Parent = this;
                    Routes.Insert(0, rteModel);
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    wptModel.Parent = this;
                    Waypoints.Insert(0, wptModel);
                }
                break;
            }

            case PasteMode.BEFORE: {
                if (newModel is GpxTrackModel trkModel)
                {
                    index = Tracks.IndexOf((GpxTrackModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        trkModel.Parent = this;
                        Tracks.Insert(index, trkModel);
                    }
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    index = Routes.IndexOf((GpxRouteModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        rteModel.Parent = this;
                        Routes.Insert(index, rteModel);
                    }
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    index = Waypoints.IndexOf((GpxWaypointModel)oldModel);
                    if (index == -1)
                    {
                        retVal = false;
                    }
                    else
                    {
                        wptModel.Parent = this;
                        Waypoints.Insert(index, wptModel);
                    }
                }
                break;
            }

            case PasteMode.AFTER: {
                if (newModel is GpxTrackModel trkModel)
                {
                    index           = Tracks.IndexOf((GpxTrackModel)oldModel);
                    trkModel.Parent = this;
                    Tracks.Insert(index + 1, trkModel);
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    index           = Routes.IndexOf((GpxRouteModel)oldModel);
                    rteModel.Parent = this;
                    Routes.Insert(index + 1, rteModel);
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    index           = Waypoints.IndexOf((GpxWaypointModel)oldModel);
                    wptModel.Parent = this;
                    Waypoints.Insert(index + 1, wptModel);
                }
                break;
            }

            case PasteMode.END: {
                if (newModel is GpxTrackModel trkModel)
                {
                    trkModel.Parent = this;
                    Tracks.Add(trkModel);
                }
                if (newModel is GpxRouteModel rteModel)
                {
                    rteModel.Parent = this;
                    Routes.Add(rteModel);
                }
                if (newModel is GpxWaypointModel wptModel)
                {
                    wptModel.Parent = this;
                    Waypoints.Add(wptModel);
                }
                break;
            }
            }
            return(retVal);
        }
예제 #13
0
        private void ContextMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            string currentFolder = txtPath.Text;

            if (e.ClickedItem.Text == "Copy")
            {
                pasteMode = PasteMode.Copy;
                copyList.Clear();
                foreach (ListViewItem item in listView1.SelectedItems)
                {
                    CopyItem copyItem = new CopyItem();
                    copyItem.ItemPath = item.Name;
                    copyItem.ItemName = item.Text;
                    copyList.Add(copyItem);
                }
            }
            else if (e.ClickedItem.Text == "Cut")
            {
                pasteMode = PasteMode.Cut;
                copyList.Clear();
                foreach (ListViewItem item in listView1.SelectedItems)
                {
                    CopyItem copyItem = new CopyItem();
                    copyItem.ItemPath = item.Name;
                    copyItem.ItemName = item.Text;
                    copyList.Add(copyItem);
                }
            }
            else if (e.ClickedItem.Text == "Delete")
            {
                if (listView1.SelectedItems.Count > 0)
                {
                    foreach (ListViewItem item in listView1.SelectedItems)
                    {
                        File.Delete(item.Name);
                    }
                }
                ListViewRefresh(currentFolder);
            }
            else if (e.ClickedItem.Text == "Paste")
            {
                if (pasteMode == PasteMode.Copy)
                {
                    foreach (var item in copyList)
                    {
                        if (File.Exists(currentFolder + "\\" + item.ItemName))
                        {
                            FileInfo fi       = new FileInfo(currentFolder + "\\" + item.ItemName);
                            string   fileName = Path.GetFileNameWithoutExtension(currentFolder + "\\" + item.ItemName);
                            item.ItemName = fileName + " (1)" + fi.Extension;
                        }
                        File.Copy(item.ItemPath, currentFolder + "\\" + item.ItemName, false);
                        ListViewRefresh(currentFolder);
                    }
                }
                else if (pasteMode == PasteMode.Cut)
                {
                    foreach (var item in copyList)
                    {
                        if (File.Exists(currentFolder + "\\" + item.ItemName))
                        {
                            FileInfo fi       = new FileInfo(currentFolder + "\\" + item.ItemName);
                            string   fileName = Path.GetFileNameWithoutExtension(currentFolder + "\\" + item.ItemName);
                            item.ItemName = fileName + " (1)" + fi.Extension;
                        }
                        File.Copy(item.ItemPath, currentFolder + "\\" + item.ItemName, false);
                        File.Delete(item.ItemPath);
                        ListViewRefresh(currentFolder);
                    }

                    copyList.Clear();
                }
            }
            else if (e.ClickedItem.Text == "Refresh")
            {
                ListViewRefresh(currentFolder);
            }
            else if (e.ClickedItem.Text == "Open")
            {
                OpenFile();
            }
        }
예제 #14
0
        private void handlePaste(
            PasteMode pasteMode)
        {
            if (Document != null)
            {
                var doc = (HTMLDocument)Document.DomDocument;

                if (IsControlSelection)
                {
                    doc.execCommand(@"Delete", false, null);
                }

                string html;

                if (Clipboard.ContainsImage() &&
                    // 2014-08-19, Uwe Keim: Excel hat HTML _und_ Bild, deshalb hier prüfen, sonst
                    //                       wird Excel auch als Bild eingefügt.
                    !Clipboard.ContainsText(TextDataFormat.Html))
                {
                    var image = Clipboard.GetImage();
                    var file  = Path.Combine(_tmpFolderPath, _objectID.ToString(CultureInfo.InvariantCulture));
                    if (image != null)
                    {
                        image.Save(file, image.RawFormat);
                    }

                    _objectID++;

                    if (Configuration.AllowEmbeddedImages)
                    {
                        var data         = File.ReadAllBytes(file);
                        var imageContent = Convert.ToBase64String(data, 0, data.Length);
                        File.Delete(file);

                        html = string.Format(@"<img src=""data:image;base64,{0}"" />", imageContent);
                    }
                    else
                    {
                        html = string.Format(@"<img src=""{0}"" id=""Img{1}"" />", file, DateTime.Now.Ticks);
                    }
                }
                else
                {
                    if (pasteMode != PasteMode.Text && Clipboard.ContainsText(TextDataFormat.Html))
                    {
                        // only body from fragment
                        html = HtmlClipboardHelper.GetHtmlFromClipboard().GetBodyFromHtmlCode().CheckCompleteHtmlTable();

                        // images save or load from web
                        html = checkImages(
                            HtmlConversionHelper.FindImgs(html),
                            html,
                            HtmlClipboardHelper.GetSourceUrlFromClipboard());

                        if (pasteMode == PasteMode.MsWord)
                        {
                            html = html.CleanMsWordHtml();
                        }
                    }
                    else if (Clipboard.ContainsText(TextDataFormat.UnicodeText))
                    {
                        html = Clipboard.GetText(TextDataFormat.UnicodeText);

                        if (pasteMode == PasteMode.Text)
                        {
                            html = html.GetOnlyTextFromHtmlCode();
                        }

                        html = PathHelper.HtmlEncode(html);
                        html = HtmlStringHelper.AddNewLineToText(html);
                    }
                    else if (Clipboard.ContainsText(TextDataFormat.Text))
                    {
                        html = Clipboard.GetText(TextDataFormat.Text);

                        if (pasteMode == PasteMode.Text)
                        {
                            html = html.GetOnlyTextFromHtmlCode();
                        }

                        html = PathHelper.HtmlEncode(html);
                        html = HtmlStringHelper.AddNewLineToText(html);
                    }
                    else
                    {
                        html = string.Empty;
                    }
                }

                var selection = doc.selection;
                var range     = (IHTMLTxtRange)selection.createRange();
                range.pasteHTML(html);
            }
        }
        private void handlePaste(
            PasteMode pasteMode)
        {
            if (Document != null)
            {
                var doc = (HTMLDocument)Document.DomDocument;

                if (IsControlSelection)
                {
                    doc.execCommand(@"Delete", false, null);
                }

                string html;

                if (Clipboard.ContainsImage() &&
                    // 2014-08-19, Uwe Keim: Excel hat HTML _und_ Bild, deshalb hier prüfen, sonst
                    //                       wird Excel auch als Bild eingefügt.
                    !Clipboard.ContainsText(TextDataFormat.Html)) 
                {
                    var image = Clipboard.GetImage();
                    var file = Path.Combine(_tmpFolderPath, _objectID.ToString(CultureInfo.InvariantCulture));
                    if (image != null)
                    {
                        image.Save(file, image.RawFormat);
                    }

                    _objectID++;

                    if (Configuration.AllowEmbeddedImages)
                    {
                        var data = File.ReadAllBytes(file);
                        var imageContent = Convert.ToBase64String(data, 0, data.Length);
                        File.Delete(file);

                        html = string.Format(@"<img src=""data:image;base64,{0}"" />", imageContent);
                    }
                    else
                    {
                        html = string.Format(@"<img src=""{0}"" id=""Img{1}"" />", file, DateTime.Now.Ticks);
                    }
                }
                else
                {
                    if (pasteMode != PasteMode.Text && Clipboard.ContainsText(TextDataFormat.Html))
                    {
                        // only body from fragment
                        html = HtmlClipboardHelper.GetHtmlFromClipboard().GetBodyFromHtmlCode().CheckCompleteHtmlTable();

                        // images save or load from web
                        html = checkImages(
                            HtmlConversionHelper.FindImgs(html),
                            html,
                            HtmlClipboardHelper.GetSourceUrlFromClipboard());

                        if (pasteMode == PasteMode.MsWord)
                        {
                            html = html.CleanMsWordHtml();
                        }
                    }
                    else if (Clipboard.ContainsText(TextDataFormat.UnicodeText))
                    {
                        html = Clipboard.GetText(TextDataFormat.UnicodeText);

                        if (pasteMode == PasteMode.Text)
                        {
                            html = html.GetOnlyTextFromHtmlCode();
                        }

                        html = PathHelper.HtmlEncode(html);
                        html = HtmlStringHelper.AddNewLineToText(html);
                    }
                    else if (Clipboard.ContainsText(TextDataFormat.Text))
                    {
                        html = Clipboard.GetText(TextDataFormat.Text);

                        if (pasteMode == PasteMode.Text)
                        {
                            html = html.GetOnlyTextFromHtmlCode();
                        }

                        html = PathHelper.HtmlEncode(html);
                        html = HtmlStringHelper.AddNewLineToText(html);
                    }
                    else
                    {
                        html = string.Empty;
                    }
                }

                var selection = doc.selection;
                var range = (IHTMLTxtRange)selection.createRange();
                range.pasteHTML(html);
            }
        }