﻿using System.Windows.Forms;
using System.Runtime.InteropServices;

public class Form1
{

    private void MapMFKAttributtesToFileProperties_Click(object sender, EventArgs e)
    {
        SolidEdgeFramework.Application objSEApplication = null;
        SolidEdgeFramework.SolidEdgeTCE objTCE = null;
        object majorVersion = null;
        object completeVersion = null;
        string UserName = null;
        string Password = null;
        string Group = null;
        string Role = null;
        string URL = null;
        bool bTeamCenterMode = false;
        object ListOfItemTypes = null;
        string FilePath = "C:\\Test.dft";
        try
        {
            objSEApplication = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
            objSEApplication.DisplayAlerts = false;

            objTCE = objSEApplication.SolidEdgeTCE;
            objTCE.GetTeamCenterMode(bTeamCenterMode);
            if (bTeamCenterMode == false)
            {
                objTCE.SetTeamCenterMode(true);
            }
            //Specify Server Credentials
            UserName = "abc";
            Password = "abc";
            Group = "";
            Role = "";
            URL = "http://Servername:8085/tc";

            objTCE.ValidateLogin(UserName, Password, Group, Role, URL);
            objTCE.GetItemTypesInfoEx(FilePath, ListOfItemTypes);


        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            Clipboard.SetText(ex.ToString());
        }
    }

    public Form1()
    {
    	SubscribeToEvents();
    }

	private bool EventsSubscribed = false;
	private void SubscribeToEvents()
	{
		if (EventsSubscribed)
			return;
		else
			EventsSubscribed = true;

		MapMFKAttributtesToFileProperties.Click += MapMFKAttributtesToFileProperties_Click;
	}

}