Exemplo n.º 1
0
 /// <summary>
 /// Event for clicking the add button
 /// </summary>
 /// <param name="sender">object that fired the event</param>
 /// <param name="e">event arguments</param>
 private void BtnAdd_Click(object sender, EventArgs e)
 {
     using (var form = new SledTtyFilterNameForm())
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             TryAddTtyFilter(
                 new SledTtyFilter(
                     form.FilterName,
                     form.FilterResult,
                     form.TextColor,
                     form.BackgroundColor));
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Event for clicking the add button
 /// </summary>
 /// <param name="sender">object that fired the event</param>
 /// <param name="e">event arguments</param>
 private void BtnAdd_Click(object sender, EventArgs e)
 {
     using (var form = new SledTtyFilterNameForm())
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             TryAddTtyFilter(
                 new SledTtyFilter(
                     form.FilterName,
                     form.FilterResult,
                     form.TextColor,
                     form.BackgroundColor));
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Event for clicking the edit button
        /// </summary>
        /// <param name="sender">object that fired the event</param>
        /// <param name="e">event arguments</param>
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            if (m_lstBoxFilters.SelectedItem == null)
            {
                return;
            }

            var selection =
                m_lstBoxFilters.SelectedItem as SledTtyFilter;

            if (selection == null)
            {
                return;
            }

            using (var form = new SledTtyFilterNameForm())
            {
                form.FilterName      = selection.Filter;
                form.TextColor       = selection.TextColor;
                form.BackgroundColor = selection.BackgroundColor;
                form.FilterResult    = selection.Result;

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

                var bCanEdit = true;

                // Grab name
                var szFilterName = form.FilterName;

                // Check if the name was changed (no duplicate names!)
                if (szFilterName != selection.Filter)
                {
                    // Name changed, verify its not a duplicate
                    var bFound =
                        m_lstTtyFilters.Any(
                            filter => filter.Filter == szFilterName);

                    if (bFound)
                    {
                        bCanEdit = false;
                    }
                }

                if (!bCanEdit)
                {
                    return;
                }

                // Make the edit
                var editedFilter =
                    new SledTtyFilter(
                        form.FilterName,
                        form.FilterResult,
                        form.TextColor,
                        form.BackgroundColor);

                // Remove selected item
                m_lstBoxFilters.Items.Remove(selection);
                m_lstTtyFilters.Remove(selection);

                // Add new item
                m_lstBoxFilters.Items.Add(editedFilter);
                m_lstTtyFilters.Add(editedFilter);

                // Select new item
                m_lstBoxFilters.SelectedItem = editedFilter;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Event for clicking the edit button
        /// </summary>
        /// <param name="sender">object that fired the event</param>
        /// <param name="e">event arguments</param>
        private void BtnEdit_Click(object sender, EventArgs e)
        {
            if (m_lstBoxFilters.SelectedItem == null)
                return;

            var selection =
                m_lstBoxFilters.SelectedItem as SledTtyFilter;

            if (selection == null)
                return;

            using (var form = new SledTtyFilterNameForm())
            {
                form.FilterName = selection.Filter;
                form.TextColor = selection.TextColor;
                form.BackgroundColor = selection.BackgroundColor;
                form.FilterResult = selection.Result;
                
                if (form.ShowDialog(this) != DialogResult.OK)
                    return;

                var bCanEdit = true;

                // Grab name
                var szFilterName = form.FilterName;

                // Check if the name was changed (no duplicate names!)
                if (szFilterName != selection.Filter)
                {
                    // Name changed, verify its not a duplicate
                    var bFound =
                        m_lstTtyFilters.Any(
                            filter => filter.Filter == szFilterName);

                    if (bFound)
                        bCanEdit = false;
                }

                if (!bCanEdit)
                    return;

                // Make the edit
                var editedFilter =
                    new SledTtyFilter(
                        form.FilterName,
                        form.FilterResult,
                        form.TextColor,
                        form.BackgroundColor);

                // Remove selected item
                m_lstBoxFilters.Items.Remove(selection);
                m_lstTtyFilters.Remove(selection);

                // Add new item
                m_lstBoxFilters.Items.Add(editedFilter);
                m_lstTtyFilters.Add(editedFilter);

                // Select new item
                m_lstBoxFilters.SelectedItem = editedFilter;
            }
        }