private void EditApplicationLicense(ApplicationLicense theLicense, InstalledApplication aSelectedApplication) { FormLicenseProperties form = new FormLicenseProperties(aSelectedApplication.Name, theLicense); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { aSelectedApplication.LoadData(); // The license will have been added to the application already so we simply refresh the active tab view workItem.ExplorerView.RefreshView(); workItem.GetActiveTabView().RefreshView(); } }
/// <summary> /// Called to show the list of LICENSES for a specific APPLICATION /// </summary> public void ShowApplicationLicenses(Object licenseObject) { // Initialize the tab view InitializeTabView(); // Reject NULL passed in values if (licenseObject == null) { return; } // Save the license object passed in to us _licenseObject = licenseObject; // Set the header and image for the tab view if (licenseObject is InstalledApplication) { // Update the internal data for this InstalledApplication as we are refreshing it InstalledApplication theApplication = (InstalledApplication)licenseObject; theApplication.LoadData(); // ...then display it's attributes in the view tabView.HeaderText = theApplication.Name; tabView.HeaderImage = Properties.Resources.application_license_72; // Add the licenses to our tab view foreach (ApplicationLicense thisLicense in theApplication.Licenses) { tabView.AddApplicationLicense(thisLicense); } } else { // Update the internal data for this InstalledOS as we are refreshing it InstalledOS theOS = (InstalledOS)licenseObject; theOS.LoadData(); // ...then display it's attributes in the view tabView.HeaderText = theOS.Name; tabView.HeaderImage = Properties.Resources.application_license_72; // Add the licenses to our tab view foreach (ApplicationLicense thisLicense in theOS.Licenses) { tabView.AddApplicationLicense(thisLicense); } } }
/// <summary> /// Called to show the list of installed instances of the specified application / OS /// </summary> /// <param name="publisherName"></param> public void ShowApplicationInstances(Object instanceObject) { // First initialize the tab view InitializeTabView(); // Reject NULL passed in values if (instanceObject == null) { return; } // Set the header and image for the tab view if (instanceObject is InstalledApplication) { InstalledApplication theApplication = (InstalledApplication)instanceObject; theApplication.LoadData(); tabView.HeaderText = theApplication.Name + " - Instances"; tabView.HeaderImage = Properties.Resources.application_instance_72; // Add the instances to our dataset foreach (ApplicationInstance thisInstance in theApplication.Instances) { tabView.AddInstance(thisInstance); } } else { InstalledOS theOS = (InstalledOS)instanceObject; theOS.LoadData(); tabView.HeaderText = theOS.Name; tabView.HeaderImage = Properties.Resources.application_license_72; // Add the licenses to our tab view foreach (ApplicationInstance thisInstance in theOS.Instances) { tabView.AddInstance(thisInstance); } } }
/// <summary> /// Called to allow a new application license to be defined /// Note that this is only applicable if we are displaying the LicenseTabView or have selected an /// application in the explorer view /// </summary> /// <param name="theApplication"></param> public void NewLicense(InstalledApplication forApplication) { // Create a new license and then call the license form to define it ApplicationLicense newLicense = new ApplicationLicense(); newLicense.ApplicationID = forApplication.ApplicationID; newLicense.ApplicationName = forApplication.Name; // FormLicenseProperties form = new FormLicenseProperties(forApplication.Name, newLicense); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Update this installed application with the new license forApplication.LoadData(); // The license will have been added to the application already so we simply refresh the views workItem.ExplorerView.RefreshView(); workItem.GetActiveTabView().RefreshView(); ILaytonView applicationsTabView = WorkItem.Items[Layton.Cab.Interface.ViewNames.MainTabView] as ILaytonView; ((ApplicationsTabView)applicationsTabView).Presenter.DisplayPublishers(); } }
/// <summary> /// This function is called when we have selected a specific 'application' node below 'All Assets' /// In this case we need to display a list of assets for which this application has been installed /// </summary> /// <param name="displayedNode"></param> protected void DisplayAllAssets_Application(UltraTreeNode displayedNode) { // Ensure that the tree view is already populated for this branch NetworkExplorerView explorerView = workItem.ExplorerView as NetworkExplorerView; explorerView.ExpandNode(displayedNode); // We are displaying ALL publishers - add in columns for // Application Object and Publisher DataColumn column1 = new DataColumn("ApplicationObject", typeof(object)); DataColumn column2 = new DataColumn("Asset", typeof(string)); DataColumn column3 = new DataColumn("Version", typeof(string)); DataColumn column4 = new DataColumn("Serial Number", typeof(string)); DataColumn column5 = new DataColumn("CD Key", typeof(string)); // Add these columns to the DataSet applicationsDataSet.Tables[0].Columns.AddRange(new System.Data.DataColumn[] { column1, column2, column3, column4, column5 }); // Get a list of assets for which this application has AllAssets allAssets = displayedNode.Tag as AllAssets; InstalledApplication thisApplication = allAssets.Tag as InstalledApplication; // Read instances/licenses of this application thisApplication.LoadData(); // This will give us (any) instances foreach (ApplicationInstance instance in thisApplication.Instances) { // Note we save the UltraTreeNode tag with this row as this should relate to the application Asset asset = new Asset(); asset.Name = instance.InstalledOnComputer; asset.AssetID = instance.InstalledOnComputerID; asset.Icon = instance.InstalledOnComputerIcon; applicationsDataSet.Tables[0].Rows.Add(new object[] { asset, asset.Name, instance.Version, instance.Serial.ProductId, instance.Serial.CdKey }); } }
/// <summary> /// Called after we select a different node in the Explorer Tree /// This function deals with the firing of the appropriate event to inform interested parties /// of the change in selection so that they may update themselves accordingly. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void applicationTree_AfterSelect(object sender, SelectEventArgs e) { Cursor.Current = Cursors.WaitCursor; if (e.NewSelections.Count > 0) { UltraTreeNode node = e.NewSelections[0]; // check if the 'All Publishers' node is selected and fire the PublisherSelectedChanged event // to inform other interested parties if (node.Key == MiscStrings.AllPublishers) { List <ApplicationPublisher> allPublishers = new List <ApplicationPublisher>(); //allPublishers.Add(_presenter.FindPublisher(node.Key)); ApplicationPublisher thePublisher = new ApplicationPublisher(node.Key, 0); //thePublisher.Populate(true, false); allPublishers.Add(thePublisher); if (PublisherSelectionChanged != null) { PublisherSelectionChanged(this, new PublishersEventArgs(allPublishers)); } } // If we have clicked on the Operating systems node and fire the OperatingSystemSelecyionChanged // event to inform other interested parties else if (node.Key == MiscStrings.OperatingSystems) { List <InstalledOS> allPublishers = new List <InstalledOS>(); allPublishers.Add(null); if (OperatingSystemSelectionChanged != null) { OperatingSystemSelectionChanged(this, new OperatingSystemEventArgs(allPublishers)); } } // If we have clicked on the Actions node and fire the ActionsSelectionChanged // event to inform other interestted parties else if (node.Key == MiscStrings.Actions) { if (ActionsSelectionChanged != null) { ActionsSelectionChanged(this, new ActionsEventArgs()); } } // If the parent is the 'All Publishers' node, then we have selected a publisher in the tree // - populate the list of publishers in the tree and fire the PublisherSelectionChanged // event. else if (node.Parent == AllPublishersNode) { // fire PublisherSelectionChanged event List <ApplicationPublisher> allPublishers = new List <ApplicationPublisher>(); foreach (UltraTreeNode publisherNode in e.NewSelections) { ApplicationPublisher thePublisher = new ApplicationPublisher(publisherNode.Key, 0); //thePublisher.Populate(true, false); allPublishers.Add(thePublisher); } if (PublisherSelectionChanged != null) { PublisherSelectionChanged(this, new PublishersEventArgs(allPublishers)); } } // If the parent is the 'All Operating Systems' node, then we have selected an OS in the tree // Fire the OperatingSystemSelectionChanged event passing the selected OS. else if (node.Parent == AllOperatingSystemsNode) { List <InstalledOS> listOSs = new List <InstalledOS>(); foreach (UltraTreeNode osNode in e.NewSelections) { InstalledOS thisOS = osNode.Tag as InstalledOS; thisOS.LoadData(); listOSs.Add(thisOS); } if (OperatingSystemSelectionChanged != null) { OperatingSystemSelectionChanged(this, new OperatingSystemEventArgs(listOSs)); } //UltraTreeNode OSNode = e.NewSelections[0] as UltraTreeNode; //InstalledOS thisOS = OSNode.Tag as InstalledOS; //if (OperatingSystemSelectionChanged != null) // OperatingSystemSelectionChanged(this, new OperatingSystemEventArgs(thisOS)); } // Applications have a parent of publisher and grand-parent of the root node // So if our grand parent is the root node we know that we are an application else if (node.Parent.Parent == AllPublishersNode) { List <InstalledApplication> listApplications = new List <InstalledApplication>(); foreach (UltraTreeNode applicationNode in e.NewSelections) { InstalledApplication thisApplication = applicationNode.Tag as InstalledApplication; thisApplication.LoadData(); listApplications.Add(thisApplication); } // fire ApplicationSelectionChanged event if (ApplicationSelectionChanged != null) { ApplicationSelectionChanged(this, new ApplicationsEventArgs(listApplications)); } } // OK we must be right at the bottom of the heirarchy displaying application/OS instances // and licenses nodes - determine which by checking the last entry in the key // If we have selected the 'licenses' node beneath an application/OS then we fire the // 'ApplicationLicenseSelectionChanged' event else if (node.Key.EndsWith(MiscStrings.ApplicationLicenseNode)) { Object nodeTag = node.Tag; // fire ApplicationLicenseSelectionChanged event if (ApplicationLicenseSelectionChanged != null) { ApplicationLicenseSelectionChanged(this, new ApplicationLicenseEventArgs(nodeTag)); } } else if (node.Key.EndsWith(MiscStrings.ApplicationInstanceNode)) { Object nodeTag = node.Tag; // fire ApplicationLicenseSelectionChanged event if (ApplicationInstallsSelectionChanged != null) { ApplicationInstallsSelectionChanged(this, new ApplicationInstallsEventArgs(nodeTag)); } } } Cursor.Current = Cursors.Default; }