Exemplo n.º 1
0
        public AddInMenuItem( AddInManager manager, AddIn addIn, uint appId )
        {
            addInManager = manager;
            this.addIn = addIn;

            this.appId = appId;

            this.Text = addIn.DisplayName;
        }
Exemplo n.º 2
0
        void TryLoadAddIn( string path )
        {

            Assembly asm = null;
            try
            {
                asm = Assembly.ReflectionOnlyLoadFrom( path );
            }
            catch ( Exception ex )
            {
                DebugLog.AppendText( "Unable to load \"{0}\" to check AddIn attribute: {1}", path, ex.Message );
                return;
            }

            string displayName = null;
            try
            {
                var cadList = CustomAttributeData.GetCustomAttributes( asm );

                foreach ( var cad in cadList )
                {
                    if ( cad.Constructor.ReflectedType.FullName == "SAPIBase.AddInAttribute" )
                    {
                        displayName = ( string )cad.NamedArguments[ 0 ].TypedValue.Value;
                    }
                }
            }
            catch ( Exception ex )
            {
                DebugLog.AppendText( "Unable to get \"{0}\" attribs: {1}", path, ex.Message );
                return;
            }

            if ( displayName == null )
                return;

            if ( IsAdded( displayName ) )
            {
                DebugLog.AppendText( "Unable to load \"{0}\", already loaded as \"{1}\"", path, displayName );
                return;
            }

            AddIn adn = new AddIn()
            {
                DisplayName = displayName,
                Path = path,
            };

            loadedAddins.Add( adn );

        }
Exemplo n.º 3
0
        public void LaunchAddIn( AddIn addIn, uint appId )
        {
            if ( !IsAdded( addIn.DisplayName ) )
            {
                DebugLog.AppendText( "AddInManager::LaunchAddIn( \"{0}\" ) Failed: Not loaded!" );
                return;
            }

            string args = string.Format( "-appid={0}", appId );

            try
            {
                ProcessStartInfo psi = new ProcessStartInfo()
                {
                    Arguments = args,
                    FileName = addIn.Path,

                    UseShellExecute = false,
                };

                Process.Start( psi );
            }
            catch ( Exception ex )
            {
                Util.MsgBox( Form.ActiveForm, string.Format( "Unable to launch addin: {0}", ex.Message ) );
            }
        }