/// <summary>
        /// Provides startup services
        /// </summary>
        protected override void StartMyServices()
        {
            base.StartMyServices();

            try
            {
                // assimilate the proprties of the starting executable
                this.MorphAttributesToReflectStartingExecutable();

                // use the window positioning engine to manage our state
                WindowPositioningEngine.WindowPositioningEngineSnapIn.Instance.Manage(this, WindowPositioningEngineKey);

                // wire up to previous instance events
                SnapInHostingEngine.GetExecutingInstance().InstanceManager.CommandLineReceivedFromAnotherInstance += new ApplicationInstanceManagerEventHandler(OnCommandLineReceivedFromAnotherInstance);

                // add ourself as a top level window to the hosting engine's application context
                SnapInHostingEngine.Instance.ApplicationContext.AddTopLevelWindow(this);

                // show ourself
                this.Show();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
        /// <summary>
        /// Provides shutdown services
        /// </summary>
        protected override void StopMyServices()
        {
            base.StopMyServices();

            // wire up to previous instance events
            SnapInHostingEngine.GetExecutingInstance().InstanceManager.CommandLineReceivedFromAnotherInstance -= new ApplicationInstanceManagerEventHandler(OnCommandLineReceivedFromAnotherInstance);

            // close ourself
            this.Close();
        }
        public SnapInDescriptorsWindow(SnapInDescriptor[] descriptors)
        {
            this.InitializeComponent();
            this.InitializesSortManagers();
            this.DisplayDescriptors(descriptors);
//			this.SelectFirstItem();

            SnapInHostingEngine.GetExecutingInstance().SnapInStarted     += new SnapInDescriptorEventHandler(SnapInDescriptorsWindow_SnapInStarted);
            SnapInHostingEngine.GetExecutingInstance().SnapInStopped     += new SnapInDescriptorEventHandler(SnapInDescriptorsWindow_SnapInStopped);
            SnapInHostingEngine.GetExecutingInstance().SnapInInstalled   += new SnapInDescriptorEventHandler(SnapInDescriptorsWindow_SnapInInstalled);
            SnapInHostingEngine.GetExecutingInstance().SnapInUninstalled += new SnapInDescriptorEventHandler(SnapInDescriptorsWindow_SnapInUninstalled);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Returns an instance of the ISnapIn that supports the Type specified by the SubClass of this SnapInProxy.
 /// </summary>
 /// <param name="instance"></param>
 /// <param name="hostingEngine"></param>
 /// <returns></returns>
 public bool GetInstance(out object instance)
 {
     instance = null;
     try
     {
         SnapInDescriptor descriptor = SnapInHostingEngine.GetExecutingInstance().FindDescriptorByType(this.GetTypeForReferenceInternal());
         if (descriptor != null)
         {
             instance = descriptor.SnapIn;
             return(true);
         }
     }
     catch (System.Exception systemException)
     {
         _lastException = systemException;
     }
     return(false);
 }
 private void DisplayReferencesFor(TreeNodeCollection nodes, SnapInDescriptor descriptor)
 {
     foreach (Type t in descriptor.Dependencies)
     {
         SnapInDescriptor dependencyDescriptor = SnapInHostingEngine.GetExecutingInstance().FindDescriptorByType(t);
         if (dependencyDescriptor != null)
         {
             TreeNode node = new TreeNode(dependencyDescriptor.MetaData.Title);
             node.Tag = dependencyDescriptor;
             if (dependencyDescriptor.IsUninstalled)
             {
                 node.ForeColor = SystemColors.GrayText;
             }
             node.Nodes.Add(string.Empty);
             nodes.Add(node);
         }
     }
 }
        private void DisplayReferencesTo(TreeNodeCollection nodes, SnapInDescriptor descriptor)
        {
            SnapInDescriptor[] descriptors = SnapInHostingEngine.GetExecutingInstance().SnapInDescriptors;

            foreach (SnapInDescriptor otherDescriptor in descriptors)
            {
                foreach (Type t in otherDescriptor.Dependencies)
                {
                    if (t == descriptor.Type)
                    {
                        TreeNode node = new TreeNode(otherDescriptor.MetaData.Title);
                        node.Tag = otherDescriptor;
                        if (otherDescriptor.IsUninstalled)
                        {
                            node.ForeColor = SystemColors.GrayText;
                        }
                        node.Nodes.Add(string.Empty);
                        nodes.Add(node);
                    }
                }
            }
        }
        /// <summary>
        /// Reflect upon the starting executable and snag it's properties
        /// </summary>
        protected void MorphAttributesToReflectStartingExecutable()
        {
            try
            {
                Assembly assembly = SnapInHostingEngine.GetExecutingInstance().StartingExecutable;
                if (assembly != null)
                {
                    // snag the name of the file minus path and extention and set it as the heading
                    string filename = System.IO.Path.GetFileName(assembly.Location);
                    filename = filename.Replace(System.IO.Path.GetExtension(assembly.Location), null);

                    AssemblyAttributeReader reader = new AssemblyAttributeReader(assembly);

                    // snag the company that made the assembly, and set it in the title
                    System.Reflection.AssemblyCompanyAttribute[] companyAttributes = reader.GetAssemblyCompanyAttributes();
                    if (companyAttributes != null)
                    {
                        if (companyAttributes.Length > 0)
                        {
                            if (companyAttributes[0].Company != null && companyAttributes[0].Company != string.Empty)
                            {
                                this.Text = filename;                                 // companyAttributes[0].Company + " " + filename;
                            }
                        }
                    }
                    // snag the image from the assembly, it should be an executable so...
                    Icon icon = ShellInformation.GetIconFromPath(assembly.Location, IconSizes.SmallIconSize, IconStyles.NormalIconStyle, FileAttributes.Normal);
                    if (icon != null)
                    {
                        this.Icon = icon;
                    }
                }
            }
            catch (System.Exception systemException)
            {
                System.Diagnostics.Trace.WriteLine(systemException);
            }
        }
 /// <summary>
 /// Occurs when the Options menu item is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnOptionsClicked(object sender, EventArgs e)
 {
     SnapInHostingEngine.GetExecutingInstance().ShowConfigurationWindow(this);
 }
 /// <summary>
 /// Occurs when the SnapIns menu item is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnSnapInsClicked(object sender, EventArgs e)
 {
     SnapInHostingEngine.GetExecutingInstance().ShowSnapInsWindow(this);
 }
 /// <summary>
 /// Occurs when the Features menu item is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnFeaturesClicked(object sender, EventArgs e)
 {
     FeatureEngine.ShowFeatureWindow(this, SnapInHostingEngine.GetExecutingInstance());
 }
Exemplo n.º 11
0
 /// <summary>
 /// Occurs when a window position listener needs a configuration to read/write to/from
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnListenerNeedsConfiguration(object sender, XmlConfigurationEventArgs e)
 {
     /// save everything to the local user configuration
     e.Element = SnapInHostingEngine.GetExecutingInstance().LocalUserConfiguration;
 }