Example #1
0
        private static void Main(string[] args)
        {
            WinFormsAppHost.ConfigureBootstrap(false);
            Logger.LogInit(WinFormsAppHost.GetLogFilename());
            LogSysInfo();

            Application.ThreadException += ExExceptionHandler;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionsHandler;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (SingleInstanceTracker tracker = new SingleInstanceTracker(GKData.APP_TITLE, GetSingleInstanceEnforcer))
            {
                if (tracker.IsFirstInstance)
                {
                    AppHost.InitSettings();
                    try
                    {
                        var appHost = (WinFormsAppHost)AppHost.Instance;
                        appHost.Init(args, false);

                        Application.Run(appHost.AppContext);
                    } finally {
                        AppHost.DoneSettings();
                    }
                }
                else
                {
                    tracker.SendMessageToFirstInstance(args);
                }
            }
        }
Example #2
0
        /// <summary>
        /// This function implements initialization of IoC-container for WinForms presentation.
        /// </summary>
        public static void ConfigureBootstrap(bool mdi)
        {
            if (mdi)
            {
                throw new ArgumentException("MDI obsolete");
            }

            var        appHost   = new WinFormsAppHost();
            IContainer container = AppHost.Container;

            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            container.Reset();

            container.Register <IStdDialogs, WinFormsStdDialogs>(LifeCycle.Singleton);
            container.Register <IGraphicsProvider, WinFormsGfxProvider>(LifeCycle.Singleton);
            container.Register <IProgressController, ProgressController>(LifeCycle.Singleton);

            // controls and other
            container.Register <ITreeChartBox, TreeChartBox>(LifeCycle.Transient);

            // dialogs
            container.Register <IRecordSelectDialog, RecordSelectDlg>(LifeCycle.Transient);
            container.Register <IAddressEditDlg, AddressEditDlg>(LifeCycle.Transient);
            container.Register <IAssociationEditDlg, AssociationEditDlg>(LifeCycle.Transient);
            container.Register <ICommunicationEditDlg, CommunicationEditDlg>(LifeCycle.Transient);
            container.Register <IEventEditDlg, EventEditDlg>(LifeCycle.Transient);
            container.Register <IFamilyEditDlg, FamilyEditDlg>(LifeCycle.Transient);
            container.Register <IGroupEditDlg, GroupEditDlg>(LifeCycle.Transient);
            container.Register <ILanguageEditDlg, LanguageEditDlg>(LifeCycle.Transient);
            container.Register <ILanguageSelectDlg, LanguageSelectDlg>(LifeCycle.Transient);
            container.Register <ILocationEditDlg, LocationEditDlg>(LifeCycle.Transient);
            container.Register <IMediaEditDlg, MediaEditDlg>(LifeCycle.Transient);
            container.Register <INameEditDlg, NameEditDlg>(LifeCycle.Transient);
            container.Register <INoteEditDlg, NoteEditDlg>(LifeCycle.Transient);
            container.Register <INoteEditDlgEx, NoteEditDlgEx>(LifeCycle.Transient);
            container.Register <IPersonalNameEditDlg, PersonalNameEditDlg>(LifeCycle.Transient);
            container.Register <IPersonEditDlg, PersonEditDlg>(LifeCycle.Transient);
            container.Register <IRepositoryEditDlg, RepositoryEditDlg>(LifeCycle.Transient);
            container.Register <IResearchEditDlg, ResearchEditDlg>(LifeCycle.Transient);
            container.Register <ISexCheckDlg, SexCheckDlg>(LifeCycle.Transient);
            container.Register <ISourceCitEditDlg, SourceCitEditDlg>(LifeCycle.Transient);
            container.Register <ISourceEditDlg, SourceEditDlg>(LifeCycle.Transient);
            container.Register <ITaskEditDlg, TaskEditDlg>(LifeCycle.Transient);
            container.Register <IUserRefEditDlg, UserRefEditDlg>(LifeCycle.Transient);
            container.Register <IFilePropertiesDlg, FilePropertiesDlg>(LifeCycle.Transient);
            container.Register <IPortraitSelectDlg, PortraitSelectDlg>(LifeCycle.Transient);
            container.Register <IDayTipsDlg, DayTipsDlg>(LifeCycle.Transient);
            container.Register <IBaseWindow, BaseWinSDI>(LifeCycle.Transient);
        }