Example #1
0
        private void managementGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_managementPack.Clear();
            Connection Connection = new Connection();
            Connection.ShowDialog();
            if (Connection.DialogResult != DialogResult.OK)
            {
                return;
            }
            this.ManagementGroup = Connection.Server;
            try
            {
                if (Connection.User != "")
                {
                    ManagementGroupConnectionSettings emgs = new ManagementGroupConnectionSettings(Connection.Server);
                    string[] user = Connection.User.Split('\\');
                    emgs.Domain = user[0];
                    emgs.UserName = user[1];
                    SecureString password = new SecureString();
                    foreach (char c in Connection.Password)
                    {
                        password.AppendChar(c);
                    }
                    emgs.Password = password;
                    emg = new ManagementGroup(emgs);

                }
                else
                {
                    emg = new ManagementGroup(Connection.Server);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            BackgroundWorker MGConnector = new BackgroundWorker();

            MGConnector.DoWork += MGConnector_DoWork;
            MGConnector.RunWorkerCompleted += MGConnector_RunWorkerCompleted;
            m_progressDialog = new ProgressDialog();
            MGConnector.RunWorkerAsync(MPLoadingProgress);

            m_progressDialog.ShowDialog();
            MultipleMPSelectionForm form = new MultipleMPSelectionForm(MPList);
            DialogResult r = form.ShowDialog();
            if (r != DialogResult.Cancel && form.ChosenMP.Count > 0)
            {
                foreach (ManagementPack item in form.ChosenMP)
                {
                    this.m_managementPack.Add(item.Name, item);
                }
                Mode = MPMode.ManagementGroup;
                ProcessManagementPacks();
            }
        }
Example #2
0
        private void fileToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            m_managementPack.Clear();
            m_openFileDialog = new OpenFileDialog();
            MPList = new List<ManagementPack>();
            ResourceList = new Dictionary<string, Stream>();
            m_openFileDialog.AddExtension = true;
            m_openFileDialog.CheckPathExists = true;
            m_openFileDialog.Multiselect = true;
            m_openFileDialog.DefaultExt = "mp";
            m_openFileDialog.Filter = "MultiSelect (*.mp;*.xml;*.mpb)|*.xml;*.mp;*.mpb|Sealed MP files (*.mp)|*.mp|Sealed MP bundles (*.mpb)|*.mpb|Unsealed MP files (*.xml)|*.xml";

            m_openFileDialog.InitialDirectory = (string)Application.UserAppDataRegistry.GetValue("MPFolder", (object)"C:\\");

            if (m_openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            ManagementPackFileStore store = Utilities.GetManagementPackStoreFromPath(m_openFileDialog.FileName);

                foreach (string FileName in m_openFileDialog.FileNames)
                {
                      if (System.IO.Path.GetExtension(FileName).Equals(".mpb", StringComparison.InvariantCultureIgnoreCase))
            {
                ManagementPackBundleReader reader = ManagementPackBundleFactory.CreateBundleReader();
                try {
                m_bundle = reader.Read(FileName, store);
                foreach (ManagementPack MP in m_bundle.ManagementPacks)
                {
                    m_managementPack.Add(MP.Name, MP);
                    IDictionary<string, Stream> streams = m_bundle.GetStreams(MP);
                    foreach (ManagementPackResource resource in MP.GetResources<ManagementPackResource>())
                    {
                        if (!resource.HasNullStream && streams[resource.Name] != null)
                        {
                            ResourceList.Add(resource.FileName, streams[resource.Name]);

                        }

                    }
                }

                } catch {}
                }

             else {
                try
                {
                    ManagementPack MP = new ManagementPack(FileName, store);
                    m_managementPack.Add(MP.Name, MP);
                }
                catch { }

                }

            }
            Mode = MPMode.File;

            MPPath = Path.GetDirectoryName(m_openFileDialog.FileNames[0]);

            ProcessManagementPacks();
        }