Subversion Repositories DevTools

Rev

Rev 2088 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2088 ghuddy 1
using System;
2
using System.Windows.Forms;
3
using System.IO;
2106 ghuddy 4
using System.Collections;
2088 ghuddy 5
 
6
 
7
namespace EA_DocGen
8
{
9
	/// <summary>
10
	/// Summary description for GUID_Clipboard.
11
	/// </summary>
12
	public class GUID_Clipboard
13
	{
2106 ghuddy 14
      struct a_guid_t
15
      {
16
         public string guid;
17
         public EA.ObjectType objType;
18
         public string name;
19
      };
20
 
2088 ghuddy 21
      // Data for the GUID copying/pasting menu items
2106 ghuddy 22
      public static string guid = "";
23
      public static EA.ObjectType objType = EA.ObjectType.otNone;
24
      public static string name = "";
2088 ghuddy 25
 
2106 ghuddy 26
      private static Stack guidStk = new Stack();
2088 ghuddy 27
 
2106 ghuddy 28
      public static void push()
29
      {
30
         a_guid_t a_guid = new a_guid_t();
31
         a_guid.guid = guid;
32
         a_guid.name = name;
33
         a_guid.objType = objType;
34
         guidStk.Push(a_guid);
35
      }
2088 ghuddy 36
 
2106 ghuddy 37
      public static void pop()
38
      {
39
         a_guid_t a_guid = (a_guid_t)guidStk.Pop();
40
         guid = a_guid.guid;
41
         name = a_guid.name;
42
         objType = a_guid.objType;
43
      }
44
 
45
 
2088 ghuddy 46
      /// <summary>
47
      /// Copies the GUID,name and type of the object to the clipboard data members.
48
      /// </summary>
49
      /// <param name="obj"></param>
50
      /// <param name="objType"></param>
51
      /// <param name="confirm"></param>
2106 ghuddy 52
      public static void copy(object obj, EA.ObjectType objtype, bool confirm)
2088 ghuddy 53
      {
54
         if (objtype == EA.ObjectType.otPackage)
55
         {
56
            guid = ((EA.Package)obj).PackageGUID.ToString();
57
            name = ((EA.Package)obj).Name;
2106 ghuddy 58
            name = EA_Utilities.GetPackagePath(((EA.Package)obj).ParentID, name);
2088 ghuddy 59
            objType = objtype;
60
            Clipboard.SetDataObject(guid);
61
            if (confirm)
62
               MessageBox.Show( "EA PackageGUID\n\n" + guid );
63
         }
64
         else if (objtype == EA.ObjectType.otDiagram)
65
         {
66
            guid = ((EA.Diagram)obj).DiagramGUID.ToString();
67
            name = ((EA.Diagram)obj).Name;
2106 ghuddy 68
            name = EA_Utilities.GetPackagePath(((EA.Diagram)obj).PackageID, name);
2088 ghuddy 69
            objType = objtype;
70
            Clipboard.SetDataObject(guid);
71
            if (confirm)
72
               MessageBox.Show( "EA DiagramGUID\n\n" + guid );
73
         }
74
         else if (objtype == EA.ObjectType.otElement)
75
         {
76
            guid = ((EA.Element)obj).ElementGUID.ToString();
77
            name = ((EA.Element)obj).Name;
2106 ghuddy 78
            name = EA_Utilities.GetPackagePath(((EA.Element)obj).PackageID, name);
2088 ghuddy 79
            objType = objtype;
80
            Clipboard.SetDataObject(guid);
81
            if (confirm)
82
               MessageBox.Show( "EA ElementGUID\n\n" + guid );
83
         }
84
         else if (objtype == EA.ObjectType.otAttribute)
85
         {
86
            guid = ((EA.Attribute)obj).AttributeGUID.ToString();
87
            name = ((EA.Attribute)obj).Name;
88
            objType = objtype;
89
            Clipboard.SetDataObject(guid);
90
            if (confirm)
91
               MessageBox.Show( "EA AttributeGUID\n\n" + guid );
92
         }
93
         else if (objtype == EA.ObjectType.otMethod)
94
         {
95
            guid = ((EA.Method)obj).MethodGUID.ToString();
96
            name = ((EA.Method)obj).Name;
97
            objType = objtype;
98
            Clipboard.SetDataObject(guid);
99
            if (confirm)
100
               MessageBox.Show( "EA MethodGUID\n\n" + guid );
101
         }
102
         else
103
         {
104
            MessageBox.Show( "Copying this object type is not supported" );
105
         }
106
      }
107
	}
108
}