private void ToolStripDropDownButton1_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {
        if (e.ClickedItem is ToolStripSeparator)
        {
            return;
        }

        CustomToolStripMenuItem toolStripItem = ((CustomToolStripMenuItem)e.ClickedItem);

        toolStripDropDownButton1.Text = toolStripItem.Text;

        ResetAll();

        if (toolStripItem.Index == 0)
        {
            SetLastGroupValues("", true);
            deleteToolStripButton.Enabled = false;
        }
        else
        {
            string xml = SavedSearchesHandler.Load(toolStripItem.Text, _registryName);
            LoadSavedSearch(xml);
        }

        _selectedSavedSearchIndex = toolStripItem.Index;

        if (toolStripItem.Text == _defaultSavedSearch)
        {
            defaultToolStripButton.Image = Resources.star;
        }
        else
        {
            defaultToolStripButton.Image = Resources.star1;
        }
    }
Exemple #2
0
    private void SaveToolStripButton_Click(object sender, EventArgs e)
    {
        if (!ConfigHandler.RegistryModifyAccess)
        {
            if (ConfigHandler.UseTranslation)
            {
                MessageBox.Show(Translator.GetText("SaveSearchNoAccess"));
            }
            else
            {
                MessageBox.Show("Logged in user does not have necessary rights to save the search.\r\n\r\nUser needs modify access to HKLM in RegEdit.", GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return;
        }

        if (!filter1ContentUserControl1.IsDataValid())
        {
            return;
        }

        string savedSearchName = toolStripDropDownButton1.Text;

        if (_selectedSavedSearchIndex == 0)
        {
            savedSearchName = "";
        }

        string savedSearchesXml        = filter1ContentUserControl1.GetSavedSearchesXml();
        string returnedSavedSearchName = SavedSearchesHandler.SaveAs(savedSearchesXml, _registryName, savedSearchName);

        if (returnedSavedSearchName != null && returnedSavedSearchName != toolStripDropDownButton1.Text)
        {
            PopulateSavedSearchesToolStrip();
        }

        if (returnedSavedSearchName != null)
        {
            deleteToolStripButton.Enabled = true;
            toolStripDropDownButton1.Text = returnedSavedSearchName;

            if (toolStripDropDownButton1.Text == _defaultSavedSearch)
            {
                defaultToolStripButton.Image = Resources.star;
            }
            else
            {
                defaultToolStripButton.Image = Resources.star1;
            }

            for (int i = 2; i < toolStripDropDownButton1.DropDown.Items.Count; i++)
            {
                if (toolStripDropDownButton1.DropDown.Items[i].Text == toolStripDropDownButton1.Text)
                {
                    _selectedSavedSearchIndex = i;
                    break;
                }
            }
        }
    }
    private void DeleteToolStripButton_Click(object sender, EventArgs e)
    {
        if (!ConfigHandler.RegistryModifyAccess)
        {
            if (ConfigHandler.UseTranslation)
            {
                MessageBox.Show(Translator.GetText("DeleteSearchNoAccess"));
            }
            else
            {
                MessageBox.Show("Logged in user does not have necessary rights to delete the saved search.\r\n\r\nUser needs modify access to HKLM in RegEdit.", GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return;
        }

        string savedSearchName = toolStripDropDownButton1.Text;

        if (SavedSearchesHandler.IsSystemObject(savedSearchName, _registryName))
        {
            string text1 = "The selected search is a system object and can not be deleted.";

            if (ConfigHandler.UseTranslation)
            {
                text1 = Translator.GetText("CanNotDeleteSystemObject");
            }

            OutputHandler.Show(text1, GenericHelper.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);

            return;
        }

        string text = "Delete search \"{0}\"?";

        if (ConfigHandler.UseTranslation)
        {
            text = Translator.GetText("DeleteSearch");
        }

        DialogResult result = OutputHandler.Show(string.Format(text, savedSearchName), GenericHelper.ApplicationName, MessageBoxButtons.YesNo, MessageBoxIcon.Information);

        if (result == DialogResult.Yes)
        {
            SavedSearchesHandler.Delete(savedSearchName, _registryName);
            deleteToolStripButton.Enabled = false;
            PopulateSavedSearchesToolStrip();

            if (savedSearchName == _defaultSavedSearch)
            {
                RegistryHandler.Delete(string.Format("DefaultSavedSearch_{0}", _registryName));
                defaultToolStripButton.Image = Resources.star1;
                _defaultSavedSearch          = "";
            }
        }
    }
    public bool InitializeSavedSearch(string name)
    {
        PopulateSavedSearchesToolStrip();

        bool nameExist = false;

        for (int i = 2; i < toolStripDropDownButton1.DropDown.Items.Count; i++)
        {
            if (toolStripDropDownButton1.DropDown.Items[i].Text == name)
            {
                nameExist = true;
                break;
            }
        }

        if (!nameExist)
        {
            return(false);
        }

        if (name != "")
        {
            toolStripDropDownButton1.Text = name;

            for (int i = 2; i < toolStripDropDownButton1.DropDown.Items.Count; i++)
            {
                if (toolStripDropDownButton1.DropDown.Items[i].Text == toolStripDropDownButton1.Text)
                {
                    _selectedSavedSearchIndex = i;
                    break;
                }
            }

            string xml = SavedSearchesHandler.Load(name, _registryName);
            ResetAll();
            LoadSavedSearch(xml);

            if (xml != "")
            {
                deleteToolStripButton.Enabled = true;
            }
        }

        if (toolStripDropDownButton1.Text == _defaultSavedSearch)
        {
            defaultToolStripButton.Image = Resources.star;
        }
        else
        {
            defaultToolStripButton.Image = Resources.star1;
        }

        return(true);
    }
    private void PopulateSavedSearchesToolStrip()
    {
        toolStripDropDownButton1.DropDown.Items.Clear();

        string emptyText = "Empty";

        if (ConfigHandler.UseTranslation)
        {
            emptyText = Translator.GetText("Empty");
        }

        toolStripDropDownButton1.Text = emptyText;

        CustomToolStripMenuItem toolStripItem = new CustomToolStripMenuItem();

        toolStripItem.Text  = emptyText;
        toolStripItem.Index = 0;

        if (toolStripItem.Text == _defaultSavedSearch)
        {
            toolStripItem.Image = Resources.star;
        }

        toolStripDropDownButton1.DropDownItems.Add(toolStripItem);

        List <string> savedSearchesNames = SavedSearchesHandler.GetNames(_registryName);

        if (savedSearchesNames.Count > 0)
        {
            toolStripDropDownButton1.DropDown.Items.Add(new ToolStripSeparator());
        }

        for (int i = 0; i < savedSearchesNames.Count; i++)
        {
            toolStripItem       = new CustomToolStripMenuItem();
            toolStripItem.Text  = savedSearchesNames[i];
            toolStripItem.Index = i + 1;

            if (toolStripItem.Text == _defaultSavedSearch)
            {
                toolStripItem.Image = Resources.star;
            }

            toolStripDropDownButton1.DropDownItems.Add(toolStripItem);
        }
    }
Exemple #6
0
    private void ToolStripDropDownButton1_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
    {
        if (e.ClickedItem is ToolStripSeparator)
        {
            return;
        }

        CustomToolStripMenuItem toolStripItem = ((CustomToolStripMenuItem)e.ClickedItem);

        toolStripDropDownButton1.Text = toolStripItem.Text;

        if (toolStripItem.Index == 0)
        {
            filter1ContentUserControl1.FillDefaultTraceDataValues();
            filter1ContentUserControl1.DisableAllCheckBoxes();
            deleteToolStripButton.Enabled = false;
        }
        else
        {
            string xml = SavedSearchesHandler.Load(toolStripItem.Text, _registryName);
            filter1ContentUserControl1.LoadSavedSearch(xml);

            if (xml != "")
            {
                deleteToolStripButton.Enabled = true;
            }
        }

        _selectedSavedSearchIndex = toolStripItem.Index;

        if (toolStripItem.Text == _defaultSavedSearch)
        {
            defaultToolStripButton.Image = Resources.star;
        }
        else
        {
            defaultToolStripButton.Image = Resources.star1;
        }
    }