public OptionDialog( Bho trixie )
        {
            if ( TranslationManager.Instance.TranslationProvider == null )
            {
                // setup Translator because COM is created without calling App.OnStartup()
                var xml = Trixie.Properties.Resources.Localizer;
                var tx = new XmlTranslationProvider( xml );
                TranslationManager.Instance.TranslationProvider = tx;
            }

            Settings = new ObservableCollection<ScriptSetting>();
            mTrixie = trixie;

            InitializeComponent();

            DataContext = this;
        }
Example #2
0
        /// <summary>
        /// セルフレジスタ
        /// アプリケーションとしてはここだけ実行して終わる
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnStartup( object sender , StartupEventArgs e )
        {
            if ( TranslationManager.Instance.TranslationProvider == null )
            {
                // setup Translator
                var xml = Trixie.Properties.Resources.Localizer;
                var tx = new XmlTranslationProvider( xml );
                TranslationManager.Instance.TranslationProvider = tx;
            }

            // Register
            Assembly asm = Assembly.GetExecutingAssembly();
            RegistrationServices reg = new RegistrationServices();

            var args = Environment.GetCommandLineArgs();
            if ( args.Length > 2 )
            {
                if ( args[1].Equals( "/u" ) )
                {
                    // Unregister with COM
                    if ( reg.UnregisterAssembly( asm ) )
                    {
                        Console.Write( TranslationManager.Instance.Translate( "Unregistered" ) );
                    }
                    else
                    {
                        Console.Write( TranslationManager.Instance.Translate( "UnregisterFail" ) );
                    }
                }
                else if ( args[1].Equals( "/r" ) )
                {
                    // Register with COM
                    if ( reg.RegisterAssembly( asm , AssemblyRegistrationFlags.SetCodeBase ) )
                    {
                        Console.Write( TranslationManager.Instance.Translate( "Registered" ) );
                    }
                    else
                    {
                        Console.Write( TranslationManager.Instance.Translate( "RegisterFail" ) );
                    }
                }
                Shutdown();
                return;
            }

            Type installed = Type.GetTypeFromProgID( "Trixie.Bho" );
            if ( installed != null )
            {
                var result = MessageBox.Show( (string)TranslationManager.Instance.Translate( "Unregistering" ) , "Trixie" , MessageBoxButton.YesNo );
                if ( result == MessageBoxResult.Yes )
                {
                    // Unregister with COM
                    if ( reg.UnregisterAssembly( asm ) )
                    {
                        MessageBox.Show( (string)TranslationManager.Instance.Translate( "Unregistered" ) , "Trixie" );
                    }
                    else
                    {
                        MessageBox.Show( (string)TranslationManager.Instance.Translate( "UnregisterFail" ) , "Trixie" );
                    }
                }
            }
            else
            {
                var result = MessageBox.Show( (string)TranslationManager.Instance.Translate( "Registering" ) , "Trixie" , MessageBoxButton.YesNo );
                if ( result == MessageBoxResult.Yes )
                {
                    // Register with COM
                    if ( reg.RegisterAssembly( asm , AssemblyRegistrationFlags.SetCodeBase ) )
                    {
                        MessageBox.Show( (string)TranslationManager.Instance.Translate( "Registered" ) , "Trixie" );
                    }
                    else
                    {
                        MessageBox.Show( (string)TranslationManager.Instance.Translate( "RegisterFail" ) , "Trixie" );
                    }
                }
            }
            Shutdown();
        }