Example #1
0
        protected override void OnStart(string[] args)
        {
            _defaultBalloonTipText = "{0} is running...".FormatString(ChoGlobalApplicationSettings.Me.ApplicationName);

            try
            {
                ChoShellExtension.Register();
                ChoTrace.WriteLine("Shell Extensions registered successfully.");
            }
            catch (Exception ex)
            {
                ChoTrace.WriteLine("Failed to register Shell Extensions. {0}".FormatString(ex.Message));
            }
            try
            {
                ChoShellFileAssociation.Register();
                ChoTrace.WriteLine("File Associations registered successfully.");
            }
            catch (Exception ex)
            {
                ChoTrace.WriteLine("Failed to register File Associations. {0}".FormatString(ex.Message));
            }

            if (ChoApplication.ApplicationMode == ChoApplicationMode.Console)
            {
                ChoAppCmdLineArgs cmdLineArgs = new ChoAppCmdLineArgs();
                cmdLineArgs.StartFileCopy();
            }
            base.OnStart(args);
        }
        protected override void OnAfterCommandLineArgObjectLoaded(string[] commandLineArgs)
        {
            ChoShellExtensionActionMode?sem = GetShellExtensionActionMode();

            if (DisplayAvailProperties || DisplayAvailTypeParsersNFormatters)
            {
                if (DisplayAvailProperties)
                {
                    ChoApplication.DisplayMsg(ChoPropertyManagerSettings.Me.GetHelpText(), null, ConsoleColor.Yellow);
                }
                if (DisplayAvailTypeParsersNFormatters)
                {
                    ChoApplication.DisplayMsg(ChoTypesManager.GetHelpText(), null, ConsoleColor.Green);
                }
                if (!ConfigObjectTypeName.IsNullOrWhiteSpace())
                {
                    ChoApplication.DisplayMsg(ChoConfigurationManager.GetHelpText(ChoType.GetType(ConfigObjectTypeName)), null, ConsoleColor.Green);
                }
                Environment.Exit(0);
            }
            else if (!ConfigObjectTypeName.IsNullOrWhiteSpace())
            {
                ChoApplication.DisplayMsg(ChoConfigurationManager.GetHelpText(ChoType.GetType(ConfigObjectTypeName)), null, ConsoleColor.Green);
                Environment.Exit(0);
            }
            else if (sem != null)
            {
                if (sem.Value == ChoShellExtensionActionMode.Register)
                {
                    ChoShellExtension.Register();
                    ChoTrace.WriteLine("Shell Extensions registered successfully.");

                    ChoShellFileAssociation.Register();
                    ChoTrace.WriteLine("File Associations registered successfully.");

                    Environment.Exit(0);
                }
                else if (sem.Value == ChoShellExtensionActionMode.Unregister)
                {
                    ChoShellExtension.Unregister();
                    ChoTrace.WriteLine("Shell Extensions unregistered successfully.");

                    ChoShellFileAssociation.Unregister();
                    ChoTrace.WriteLine("File Associations unregistered successfully.");

                    Environment.Exit(0);
                }
            }

            if (ChoShellExtension.ExecuteShellExtensionMethodIfAnySpecified(commandLineArgs))
            {
                ChoTrace.WriteLine("Shell Extension ran successfully.");
                Environment.Exit(0);
            }

            base.OnAfterCommandLineArgObjectLoaded(commandLineArgs);
        }
Example #3
0
 public static void UnregisterShellExtensions()
 {
     try
     {
         ChoShellExtension.Unregister();
         ChoTrace.WriteLine("Shell Extensions unregistered successfully.");
     }
     catch (Exception ex)
     {
         ChoTrace.WriteLine("Failed to unregister Shell Extensions. {0}".FormatString(ex.Message));
     }
     try
     {
         ChoShellFileAssociation.Unregister();
         ChoTrace.WriteLine("File Associations unregistered successfully.");
     }
     catch (Exception ex)
     {
         ChoTrace.WriteLine("Failed to unregister File Associations. {0}".FormatString(ex.Message));
     }
 }