using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace RevitEstimate.PlumbingModule
{
    [Transaction(TransactionMode.Manual)]
    public class PlumbingCommand : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                // License Verification Check
                if (!LicenseManager.IsLicensed())
                {
                    ActivationWindow actWindow = new ActivationWindow();
                    actWindow.ShowDialog();

                    if (!actWindow.IsActivated)
                    {
                        return Result.Cancelled;
                    }
                }

                Document doc = commandData.Application.ActiveUIDocument.Document;
                PlumbingEstimateWindow window = new PlumbingEstimateWindow(doc);
                window.ShowDialog();
                return Result.Succeeded;
            }
            catch (System.Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
        }
    }
}