title: Open window in C# class library project
body: <p>I am still new and learning C# as I go. My question is generic, so let me know if I can be more specific in any way. I am moreover looking for guidance/examples to go off of or even a simple solution to build from.</p>
  
  <p>I have a class library that is currently working, but I want to display a window to the user. My class is for a program called Solidworks PDM and is a menu command. In the middle, I need the user to review and select "OK" or "Cancel".</p>
  
  <p>Basically, how do I get a window that contains two buttons "OK" and "Cancel" in the my class library? Thanks in advance!</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Collections.Generic;
  //using System.Linq;
  using System.Text;
  //using System.Threading.Tasks;
  using EdmLib;
  using Microsoft.VisualBasic;
  using System.Windows.Forms;
  namespace ClassLibrary2
  {
      public class Class1 : IEdmAddIn5
      {
          public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)
          {
              //Specify information to display in the add-in's Properties dialog box   
              poInfo.mbsAddInName = "Menu command sample";
              poInfo.mbsCompany = "SOLIDWORKS Corporation";
              poInfo.mbsDescription = "Adds menu command items";
              poInfo.mlAddInVersion = 1;
              //Specify the minimum required version of SOLIDWORKS Enterprise PDM  
              poInfo.mlRequiredVersionMajor = 10;
              poInfo.mlRequiredVersionMinor = 0;
              //Register a menu command  
              poCmdMgr.AddCmd(100, "Inspection Request (New C#)", (int)EdmMenuFlags.EdmMenu_OnlySingleSelection);
          }
          public void OnCmd(ref EdmCmd poCmd, ref Array ppoData)
          {
              if (poCmd.meCmdType == EdmCmdType.EdmCmd_Menu) //This makes sure the addin was called on a menu right click  
              {
                  if (poCmd.mlCmdID == 100) //This makes sure the menu command ID was 100, which means your addin was the one called  
                  {
                      //Let's get moving, it's our turn!  
                      IEdmVault12 myVault = (IEdmVault12)poCmd.mpoVault; //Cast the vault to an Iedmvault12 object for latest functionality  
                      string Mymessage = null;//instantiate a string message  
                      //string StrID = null;//instantiate the ID of the object  
                      if ((((EdmCmdData)ppoData.GetValue(0)).mlObjectID1) != 0) //mlObjectID1 will be 0 if a folder was selected and the ID of the file if a file was selected during a menu command  
                      {
                          //Mymessage = Mymessage + "File: (ID=";
                          IEdmFile5 myfile = (IEdmFile10)myVault.GetObject(EdmObjectType.EdmObject_File, (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1));//Get the file object  
  
                          string fileNoExt = Path.GetFileNameWithoutExtension(myfile.Name);
  
                          IEdmEnumeratorVariable10 myvars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                          myvars = (IEdmEnumeratorVariable10)myfile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
                          object CreatedBy = null; //Create a variable to hold the model no.  
                          object Desc1 = null;
                          object Desc2 = null;
                          object Rev = null;
  
                          myvars.GetVar("CreatedBy", "@", out CreatedBy); //Use the GetVar method  
                          myvars.GetVar("CAD_Description", "@", out Desc1);
                          myvars.GetVar("CAD_Description1", "@", out Desc2);
                          myvars.GetVar("CAD_Revision", "@", out Rev);
  
                          myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                                   //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID  
  
                          Mymessage = Mymessage + "CreatedBy: " + CreatedBy + System.Environment.NewLine; //Add the model no. variable  
                          Mymessage = Mymessage + "Description: " + Desc1 + System.Environment.NewLine;
                          Mymessage = Mymessage + "Description1: " + Desc2 + System.Environment.NewLine;
                          Mymessage = Mymessage + "Revision: " + Rev + System.Environment.NewLine;
  
                          MessageBox.Show(Mymessage); //Show the message box!  
  
                          MessageBox.Show("Get template path");
                          string templPath = @"C:\SeanVault\Templates\template.item.cvd";
                          string newPath = @"C:\SeanVault\Inspection Files";
                          string filename = fileNoExt + " Rev " + Rev.ToString() + ".insp";
                          IEdmFile5 templateFile = default(IEdmFile5);
                          IEdmFolder5 srcFolder = null;
                          templateFile = myVault.GetFileFromPath(templPath, out srcFolder);
  
                          MessageBox.Show("Get destination path");
                          IEdmFolder5 destFolder = default(IEdmFolder5);
                          destFolder = myVault.GetFolderFromPath(newPath);
                          if (destFolder == null)
                              return;
  
  
                          int fileID = 0;
                          fileID = destFolder.CopyFile(templateFile.ID, srcFolder.ID, 0, filename, (int)EdmCopyFlag.EdmCpy_Simple);
  
                          Interaction.MsgBox("Copied file successfully to new file with ID, " + fileID);
  
  
                          IEdmFile5 newFile = default(IEdmFile5);
                          IEdmFile5 itemFile = default(IEdmFile5);
  
                          newPath = newPath + "\\" + filename;
  
                          //Search for file with .item extension
                          IEdmSearch5 Search = default(IEdmSearch5);
                          Search = (IEdmSearch5)myVault.CreateUtility(EdmUtility.EdmUtil_Search);
  
                          Search.FindFiles = true;
                          //Search.StartFolderID = 102; //Regular Items ID
                          Search.FileName = fileNoExt + ".item";
                          IEdmSearchResult5 Result = default(IEdmSearchResult5);
  
  
                          Result = Search.GetFirstResult();
                          object StockingType = null; //Create a variable to hold the model no. 
                          if (Result != null)
                          {
                              MessageBox.Show("Result exists. Begin! Path = " + Result.Path);
                              itemFile = myVault.GetFileFromPath(Result.Path, out srcFolder);
                              IEdmEnumeratorVariable10 itemVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                              itemVars = (IEdmEnumeratorVariable10)itemFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
                              //breaks
                              itemVars.GetVar("ITEM_StockingType", "", out StockingType); //Use the GetVar method  
                              //itemVars.GetVar("CAD_Description", "@", out Desc1);
                              //itemVars.GetVar("CAD_Description1", "@", out Desc2);
                              //itemVars.GetVar("CAD_Revision", "@", out Rev);
                              MessageBox.Show("5");
                              myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                                       //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID  
                          }
  
                          newFile = myVault.GetFileFromPath(newPath, out srcFolder);
                          //update variables
                          IEdmEnumeratorVariable10 myNewVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                          myNewVars = (IEdmEnumeratorVariable10)newFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  
  
                          MessageBox.Show(Rev.ToString() + "," + StockingType.ToString());
  
                          myNewVars.SetVar("ITEM_RevisionNumber", "", Rev.ToString());
                          myNewVars.SetVar("ITEM_DescriptionLine1", "", Desc1.ToString());
                          myNewVars.SetVar("ITEM_DescriptionLine2", "", Desc2.ToString());
  
                          if (StockingType.ToString() != null)
                          {
                              myNewVars.SetVar("ITEM_StockingType", "", StockingType.ToString());
                          }
  
                          myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                                   //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID  
  
  
                          //Check-in new file
                          newFile.UnlockFile(0,"Created and checked-in with Sean's API.");
  
                          //myvars.SetVar("CAD_Weight","@", "This Worked");
  
                          //Mymessage = Mymessage + "File name: " + ((EdmCmdData)ppoData.GetValue(0)).mbsStrData1 + System.Environment.NewLine; //Add the file name  
  
                      }
                  }
              }
          }
      }
  }
  </code></pre>