Пример #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();
            }
        }
Пример #2
0
        //---------------------------------------------------------------------
        private void loadManagementPackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_openFileDialog = new OpenFileDialog();

            m_openFileDialog.AddExtension    = true;
            m_openFileDialog.CheckPathExists = true;
            m_openFileDialog.DefaultExt      = "mp";
            m_openFileDialog.Filter          = "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);


            if (System.IO.Path.GetExtension(m_openFileDialog.FileName).Equals(".mpb", StringComparison.InvariantCultureIgnoreCase))
            {
                ManagementPackBundleReader reader = ManagementPackBundleFactory.CreateBundleReader();
                m_bundle = reader.Read(m_openFileDialog.FileName, store);

                // 1 at the time is ok
                if (m_bundle.ManagementPacks.Count == 1)
                {
                    m_managementPack = m_bundle.ManagementPacks[0];
                }
                else
                {
                    // multiple MPs contained in this MPB! - can only open one at the time! Need to ask the user which one.
                    MultipleMPSelectionForm MPListForm = new MultipleMPSelectionForm(m_bundle.ManagementPacks);
                    MPListForm.ShowDialog();

                    //selected in the form
                    m_managementPack = MPListForm.ChosenMP;
                }
            }
            else // we are dealing with an MP or XML - the old stuff works as it did for 2007
            {
                m_managementPack = new ManagementPack(m_openFileDialog.FileName, store);
            }


            ClearViews();

            PopulateObjectTypeTree();


            Application.UserAppDataRegistry.SetValue("MPFolder",
                                                     Path.GetDirectoryName(m_openFileDialog.FileName));

            if (m_managementPack.KeyToken != null)
            {
                Text = string.Format("Management Pack Viewer 2012 - {0} {1} {2}",
                                     Utilities.GetBestManagementPackName(m_managementPack),
                                     m_managementPack.Version.ToString(),
                                     m_managementPack.KeyToken.ToString());
            }
            else
            {
                //TODO - Unsealed don't have keytoken!
                Text = string.Format("Management Pack Viewer 2012 - {0} {1} Unsealed",
                                     Utilities.GetBestManagementPackName(m_managementPack),
                                     m_managementPack.Version.ToString());
            }


            //loading dataset is memory expensive and can take time... so moved to a worker thread
            this.m_progressDialog = new ProgressDialog();
            this.m_progressDialog.Show(this);
            this.backgroundWorker.RunWorkerAsync();



            Cursor = Cursors.Default;

            // now that an MP is loaded, enable the menus
            saveToHTMLToolStripMenuItem.Enabled  = true;
            saveToExcelToolStripMenuItem.Enabled = true;

            //this might make sense or not, if we have loaded XML...
            if (System.IO.Path.GetExtension(m_openFileDialog.FileName).Equals(".mpb", StringComparison.InvariantCultureIgnoreCase) ||
                System.IO.Path.GetExtension(m_openFileDialog.FileName).Equals(".mp", StringComparison.InvariantCultureIgnoreCase))
            {
                unsealManagementPackToolStripMenuItem.Enabled = true;
            }
        }
Пример #3
0
        //---------------------------------------------------------------------
        private void loadManagementPackToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_openFileDialog = new OpenFileDialog();

            m_openFileDialog.AddExtension = true;
            m_openFileDialog.CheckPathExists = true;
            m_openFileDialog.DefaultExt = "mp";
            m_openFileDialog.Filter = "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);

            if (System.IO.Path.GetExtension(m_openFileDialog.FileName).Equals(".mpb", StringComparison.InvariantCultureIgnoreCase))
            {
                ManagementPackBundleReader reader = ManagementPackBundleFactory.CreateBundleReader();
                m_bundle = reader.Read(m_openFileDialog.FileName, store);

                // 1 at the time is ok
                if (m_bundle.ManagementPacks.Count == 1)
                {
                    m_managementPack = m_bundle.ManagementPacks[0];
                }
                else
                {
                    // multiple MPs contained in this MPB! - can only open one at the time! Need to ask the user which one.
                    MultipleMPSelectionForm MPListForm = new MultipleMPSelectionForm(m_bundle.ManagementPacks);
                    MPListForm.ShowDialog();

                    //selected in the form
                    m_managementPack = MPListForm.ChosenMP;
                }
            }
            else // we are dealing with an MP or XML - the old stuff works as it did for 2007
            {
                m_managementPack = new ManagementPack(m_openFileDialog.FileName, store);
            }

            ClearViews();

            PopulateObjectTypeTree();

            Application.UserAppDataRegistry.SetValue("MPFolder",
                                                        Path.GetDirectoryName(m_openFileDialog.FileName));

            if (m_managementPack.KeyToken != null)
            {
                Text = string.Format("Management Pack Viewer 2012 - {0} {1} {2}",
                                        Utilities.GetBestManagementPackName(m_managementPack),
                                        m_managementPack.Version.ToString(),
                                        m_managementPack.KeyToken.ToString());
            }
            else
            {
                //TODO - Unsealed don't have keytoken!
                Text = string.Format("Management Pack Viewer 2012 - {0} {1} Unsealed",
                                        Utilities.GetBestManagementPackName(m_managementPack),
                                        m_managementPack.Version.ToString());
            }

            //loading dataset is memory expensive and can take time... so moved to a worker thread
            this.m_progressDialog = new ProgressDialog();
            this.m_progressDialog.Show(this);
            this.backgroundWorker.RunWorkerAsync();

            Cursor = Cursors.Default;

            // now that an MP is loaded, enable the menus
            saveToHTMLToolStripMenuItem.Enabled = true;
            saveToExcelToolStripMenuItem.Enabled = true;

            //this might make sense or not, if we have loaded XML...
            if (System.IO.Path.GetExtension(m_openFileDialog.FileName).Equals(".mpb", StringComparison.InvariantCultureIgnoreCase) ||
                System.IO.Path.GetExtension(m_openFileDialog.FileName).Equals(".mp", StringComparison.InvariantCultureIgnoreCase))
            {
                unsealManagementPackToolStripMenuItem.Enabled = true;
            }
        }