Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/22/10 00:44:01 (14 years ago)
Author:
swagner
Message:

Sorted usings and removed unused usings in entire solution (#1094)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/CopyTool.cs

    r2868 r4068  
    11using System;
    2 using System.Diagnostics;
    3 using System.Collections;
    42using System.Drawing;
    53using System.Windows.Forms;
    6 using System.IO;
    7 using System.Runtime.Serialization;
    8 using System.Runtime.Serialization.Formatters.Binary;
    9 namespace Netron.Diagramming.Core
    10 {
    11     // ----------------------------------------------------------------------
     4namespace Netron.Diagramming.Core {
     5  // ----------------------------------------------------------------------
     6  /// <summary>
     7  /// A tool that copies the selected entities to the clipboard.
     8  /// </summary>
     9  // ----------------------------------------------------------------------
     10  public class CopyTool : AbstractTool {
     11    #region Fields
     12    #endregion
     13
     14    #region Constructor
     15
     16    // ------------------------------------------------------------------
    1217    /// <summary>
    13     /// A tool that copies the selected entities to the clipboard.
     18    /// Initializes a new instance of the <see cref="T:CopyTool"/> class.
    1419    /// </summary>
    15     // ----------------------------------------------------------------------
    16     public class CopyTool : AbstractTool
    17     {
    18         #region Fields
    19         #endregion
     20    /// <param name="name">string: The name of the tool.</param>
     21    // ------------------------------------------------------------------
     22    public CopyTool(string name)
     23      : base(name) {
     24    }
     25    #endregion
    2026
    21         #region Constructor
     27    #region Methods
    2228
    23         // ------------------------------------------------------------------
    24         /// <summary>
    25         /// Initializes a new instance of the <see cref="T:CopyTool"/> class.
    26         /// </summary>
    27         /// <param name="name">string: The name of the tool.</param>
    28         // ------------------------------------------------------------------
    29         public CopyTool(string name)
    30             : base(name)
    31         {
    32         }
    33         #endregion
     29    // ------------------------------------------------------------------
     30    /// <summary>
     31    /// Called when the tool is activated.
     32    /// </summary>
     33    // ------------------------------------------------------------------
     34    protected override void OnActivateTool() {
     35      if (this.Controller.Model.Selection.SelectedItems.Count == 0)
     36        return;
    3437
    35         #region Methods
     38      try {
     39        //Clear the Anchors otherwise subsequent Copy operations will
     40        // raise an exception due to the fact that the Anchors class
     41        // is a static helper class.
     42        Anchors.Clear();
    3643
    37         // ------------------------------------------------------------------
    38         /// <summary>
    39         /// Called when the tool is activated.
    40         /// </summary>
    41         // ------------------------------------------------------------------
    42         protected override void OnActivateTool()
    43         {
    44           if (this.Controller.Model.Selection.SelectedItems.Count == 0)
    45                 return;
     44        // First add the image to the Windows Clipboard so it can be
     45        // pasted into other applications, like PowerPoint.
     46        Bitmap image = this.Controller.Model.Selection.ToBitmap();
     47        Clipboard.SetDataObject(image, true);
    4648
    47             try
    48             {
    49                 //Clear the Anchors otherwise subsequent Copy operations will
    50                 // raise an exception due to the fact that the Anchors class
    51                 // is a static helper class.
    52                 Anchors.Clear();
     49        // This will create a volatile collection of entities, but they
     50        // need to be unwrapped!  I never managed to get things
     51        // working by putting the serialized collection directly onto
     52        // the Clipboad. Thanks to Leppie's suggestion it works by
     53        // putting the Stream onto the Clipboard, which is weird but
     54        // it works.
     55        //MemoryStream copy = Selection.SelectedItems.ToStream();
     56        //DataFormats.Format format =
     57        //    DataFormats.GetFormat(typeof(CopyTool).FullName);
    5358
    54                 // First add the image to the Windows Clipboard so it can be
    55                 // pasted into other applications, like PowerPoint.
    56                 Bitmap image = this.Controller.Model.Selection.ToBitmap();
    57                 Clipboard.SetDataObject(image, true);
     59        //IDataObject dataObject = new DataObject();
     60        //dataObject.SetData(format.Name, false, copy);
     61        //Clipboard.SetDataObject(dataObject, false);
    5862
    59                 // This will create a volatile collection of entities, but they
    60                 // need to be unwrapped!  I never managed to get things
    61                 // working by putting the serialized collection directly onto
    62                 // the Clipboad. Thanks to Leppie's suggestion it works by
    63                 // putting the Stream onto the Clipboard, which is weird but
    64                 // it works.
    65                 //MemoryStream copy = Selection.SelectedItems.ToStream();
    66                 //DataFormats.Format format =
    67                 //    DataFormats.GetFormat(typeof(CopyTool).FullName);
     63        // Rather than placing the stream of entities on the Windows
     64        // Clipboard, we're using our custom clipboard to keep the
     65        // Windows clipboard for moving data across apps.
     66        NetronClipboard.Clear();
     67        NetronClipboard.Add(this.Controller.Model.Selection.SelectedItems.Copy());
    6868
    69                 //IDataObject dataObject = new DataObject();
    70                 //dataObject.SetData(format.Name, false, copy);
    71                 //Clipboard.SetDataObject(dataObject, false);
    72 
    73                 // Rather than placing the stream of entities on the Windows
    74                 // Clipboard, we're using our custom clipboard to keep the
    75                 // Windows clipboard for moving data across apps.
    76                 NetronClipboard.Clear();
    77                 NetronClipboard.Add(this.Controller.Model.Selection.SelectedItems.Copy());
    78                
    79             }
    80             catch (Exception exc)
    81             {
    82                 //throw new InconsistencyException(
    83                 //    "The Copy operation failed.", exc);
    84                 MessageBox.Show("Unable to copy the selection.\n\n" +
    85                     "Error Message: " + exc.Message);
    86             }
    87             finally
    88             {
    89                 DeactivateTool();
    90             }
    91         }
    92        
    93         #endregion
     69      }
     70      catch (Exception exc) {
     71        //throw new InconsistencyException(
     72        //    "The Copy operation failed.", exc);
     73        MessageBox.Show("Unable to copy the selection.\n\n" +
     74            "Error Message: " + exc.Message);
     75      }
     76      finally {
     77        DeactivateTool();
     78      }
    9479    }
    9580
     81    #endregion
     82  }
     83
    9684}
Note: See TracChangeset for help on using the changeset viewer.