Exemple #1
0
        private static void Main(string[] args)
        {
            WFAppHost.ConfigureBootstrap(false);
            AppHost.CheckPortable(args);
            Logger.Init(AppHost.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 = (WFAppHost)AppHost.Instance;
                        appHost.Init(args, false);

                        Application.Run(appHost.AppContext);
                    } finally {
                        AppHost.DoneSettings();
                    }
                }
                else
                {
                    tracker.SendMessageToFirstInstance(args);
                }
            }
        }
Exemple #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 WFAppHost();
            IContainer container = AppHost.Container;

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

            container.Reset();

            // controls and other
            container.Register <IStdDialogs, WFStdDialogs>(LifeCycle.Singleton);
            container.Register <IGraphicsProviderEx, WFGfxProvider>(LifeCycle.Singleton);
            container.Register <IProgressController, ProgressController>(LifeCycle.Singleton);
            container.Register <ITreeChart, TreeChartBox>(LifeCycle.Transient);

            // dialogs
            container.Register <IAboutDlg, AboutDlg>(LifeCycle.Transient);
            container.Register <IAddressEditDlg, AddressEditDlg>(LifeCycle.Transient);
            container.Register <IAssociationEditDlg, AssociationEditDlg>(LifeCycle.Transient);
            container.Register <IBaseWindow, BaseWinSDI>(LifeCycle.Transient);
            container.Register <ICircleChartWin, CircleChartWin>(LifeCycle.Transient);
            container.Register <ICommunicationEditDlg, CommunicationEditDlg>(LifeCycle.Transient);
            container.Register <ICommonFilterDlg, CommonFilterDlg>(LifeCycle.Transient);
            container.Register <IDayTipsDlg, DayTipsDlg>(LifeCycle.Transient);
            container.Register <IEventEditDlg, EventEditDlg>(LifeCycle.Transient);
            container.Register <IFamilyEditDlg, FamilyEditDlg>(LifeCycle.Transient);
            container.Register <IFilePropertiesDlg, FilePropertiesDlg>(LifeCycle.Transient);
            container.Register <IFragmentSearchDlg, TTFamilyGroupsDlg>(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 <IMapsViewerWin, MapsViewerWin>(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 <IOptionsDlg, OptionsDlg>(LifeCycle.Transient);
            container.Register <IOrganizerWin, OrganizerWin>(LifeCycle.Transient);
            container.Register <IParentsEditDlg, ParentsEditDlg>(LifeCycle.Transient);
            container.Register <IPatriarchsSearchDlg, TTPatSearchDlg>(LifeCycle.Transient);
            container.Register <IPatriarchsViewer, PatriarchsViewerWin>(LifeCycle.Transient);
            container.Register <IPersonsFilterDlg, PersonsFilterDlg>(LifeCycle.Transient);
            container.Register <IPlacesManagerDlg, TTPlacesManagerDlg>(LifeCycle.Transient);
            container.Register <IPersonalNameEditDlg, PersonalNameEditDlg>(LifeCycle.Transient);
            container.Register <IPersonEditDlg, PersonEditDlg>(LifeCycle.Transient);
            container.Register <IPortraitSelectDlg, PortraitSelectDlg>(LifeCycle.Transient);
            container.Register <IRecMergeDlg, TTRecMergeDlg>(LifeCycle.Transient);
            container.Register <IRecordSelectDialog, RecordSelectDlg>(LifeCycle.Transient);
            container.Register <IRelationshipCalculatorDlg, RelationshipCalculatorDlg>(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 <IScriptEditWin, ScriptEditWin>(LifeCycle.Transient);
            container.Register <ISlideshowWin, SlideshowWin>(LifeCycle.Transient);
            container.Register <IStatisticsWin, StatisticsWin>(LifeCycle.Transient);
            container.Register <ITaskEditDlg, TaskEditDlg>(LifeCycle.Transient);
            container.Register <ITreeChartWin, TreeChartWin>(LifeCycle.Transient);
            container.Register <ITreeCheckDlg, TTTreeCheckDlg>(LifeCycle.Transient);
            container.Register <ITreeCompareDlg, TTTreeCompareDlg>(LifeCycle.Transient);
            container.Register <ITreeFilterDlg, TreeFilterDlg>(LifeCycle.Transient);
            container.Register <ITreeMergeDlg, TTTreeMergeDlg>(LifeCycle.Transient);
            container.Register <ITreeSplitDlg, TTTreeSplitDlg>(LifeCycle.Transient);
            container.Register <IUserRefEditDlg, UserRefEditDlg>(LifeCycle.Transient);
            container.Register <IRecordInfoDlg, RecordInfoDlg>(LifeCycle.Transient);

            ControlsManager.RegisterHandlerType(typeof(Button), typeof(ButtonHandler));
            ControlsManager.RegisterHandlerType(typeof(CheckBox), typeof(CheckBoxHandler));
            ControlsManager.RegisterHandlerType(typeof(ComboBox), typeof(ComboBoxHandler));
            ControlsManager.RegisterHandlerType(typeof(Label), typeof(LabelHandler));
            ControlsManager.RegisterHandlerType(typeof(MaskedTextBox), typeof(MaskedTextBoxHandler));
            ControlsManager.RegisterHandlerType(typeof(NumericUpDown), typeof(NumericBoxHandler));
            ControlsManager.RegisterHandlerType(typeof(ProgressBar), typeof(ProgressBarHandler));
            ControlsManager.RegisterHandlerType(typeof(RadioButton), typeof(RadioButtonHandler));
            ControlsManager.RegisterHandlerType(typeof(TabControl), typeof(TabControlHandler));
            ControlsManager.RegisterHandlerType(typeof(TextBox), typeof(TextBoxHandler));
            ControlsManager.RegisterHandlerType(typeof(TreeView), typeof(TreeViewHandler));
            ControlsManager.RegisterHandlerType(typeof(ToolStripMenuItem), typeof(MenuItemHandler));
            ControlsManager.RegisterHandlerType(typeof(ToolStripComboBox), typeof(ToolStripComboBoxHandler));

            ControlsManager.RegisterHandlerType(typeof(GKComboBox), typeof(ComboBoxHandler));
            ControlsManager.RegisterHandlerType(typeof(LogChart), typeof(LogChartHandler));
            ControlsManager.RegisterHandlerType(typeof(GKDateBox), typeof(DateBoxHandler));
        }