/// <summary>
        /// Called when [startup].
        /// </summary>
        /// <param name="uiCtrlApp">The UI control application.</param>
        /// <returns></returns>
        /// ReSharper disable once ParameterHidesMember
        public Result OnStartup(UIControlledApplication uiCtrlApp)
        {
            uiControlledApplication = uiCtrlApp;

#if REVIT2017
            // A workaround for a bug with UI culture in Revit 2017.1.1
            // More info here: https://forums.autodesk.com/t5/revit-api-forum/why-the-language-key-switches-currentculture-instead-of/m-p/6843557/highlight/true#M20779
            var language = uiCtrlApp.ControlledApplication.Language.ToString();
            Thread.CurrentThread.CurrentUICulture = CultureInfo
                                                    .GetCultures(CultureTypes.SpecificCultures)
                                                    .FirstOrDefault(c => language.Contains(c.EnglishName)) ?? Thread.CurrentThread.CurrentUICulture;
#endif

            RibbonHelper.AddButtons(uiCtrlApp);

            try
            {
                // Idling and initialization
                uiControlledApplication.Idling += OnIdling;
                uiControlledApplication.ControlledApplication.ApplicationInitialized += OnApplicationInitialized;
                // Open / change
                uiControlledApplication.ControlledApplication.DocumentOpened  += OnDocumentOpened;
                uiControlledApplication.ControlledApplication.DocumentChanged += OnDocumentChanged;
                // Save / SaveAs
                uiControlledApplication.ControlledApplication.DocumentSaved   += OnDocumentSaved;
                uiControlledApplication.ControlledApplication.DocumentSavedAs += OnDocumentSavedAs;
                // Progress & Failure
                uiControlledApplication.ControlledApplication.ProgressChanged    += OnProgressChanged;
                uiControlledApplication.ControlledApplication.FailuresProcessing += OnFailuresProcessing;
                // Closing
                uiControlledApplication.ControlledApplication.DocumentClosing += OnDocumentClosing;
                uiControlledApplication.ControlledApplication.DocumentClosed  += OnDocumentClosed;

                // TODO: add you code here
            }
            catch (Exception ex)
            {
                TaskDialog.Show($"Error in {nameof(OnStartup)} method", ex.ToString());
                return(Result.Failed);
            }

            return(Result.Succeeded);
        }