/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Diff of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/xmltv_parser/main.cs	2013/03/13 15:50:07	134
+++ trunk/xmltv_parser/main.cs	2013/03/13 16:15:48	135
@@ -200,7 +200,7 @@
             catch (Exception ex) { gLog.Error.WriteLine(ex.ToString()); }
         }
 
-        
+
         void CreatControlsFromType(Type data_type)
         {
 #if USE_DYNAMIC_SORTING_FILTERING_CONTROLS
@@ -244,7 +244,7 @@
         {
             gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
         }
-        #endregion     
+        #endregion
 
 
         #region Column Sorting Support
@@ -331,7 +331,97 @@
             dataGrid.DataSource = data;
         }
 
-       
+        private void dataGrid_SelectionChanged(object sender, EventArgs e)
+        {
+            try
+            {
+                DataGridView dgv = (DataGridView)sender;
+                //var row = dgv.SelectedRows[0]; // the row that was selected
+                //var cell = dgv.SelectedCells[0];
+                DataGridViewRow row = null;
+                string data = string.Empty;
+                if (dgv.SelectedCells.Count > 0)
+                {
+                    var cell = dgv.SelectedCells[0];
+                    row = dgv.Rows[cell.RowIndex];
+                }
+                if (dgv.SelectedRows.Count > 0)
+                {
+                    row = dgv.SelectedRows[0];
+                }
+                if (radio_filter_channelname.Checked)
+                {
+                    data = row.Cells[0].Value.ToString();
+                }
+                else if (radio_filter_title.Checked)
+                {
+                    data = row.Cells[3].Value.ToString();
+                }
+                else if (radio_filter_subtitle.Checked)
+                {
+                    data = row.Cells[4].Value.ToString();
+                }
+                else if (radio_filter_description.Checked)
+                {
+                    data = row.Cells[5].Value.ToString();
+                }
+                else
+                {
+                    // unknown filter
+                    gLog.Warn.WriteLine("Unkown filter value used.  Was not: channelname, title, subtitle, or description.");
+                }
+
+                txtFilterText.Text = data;
+            }
+            catch (Exception ex)
+            {
+                gLog.Verbose.Error.WriteLine(ex.ToString());
+            }
+        }
+
+
+        private void UpdateFilterText(RadioButton radio, DataGridView dgv, int cellindex)
+        {
+            if (radio.Checked)
+            {
+                DataGridViewRow row = null;
+                string data = string.Empty;
+                if (dgv.SelectedCells.Count > 0)
+                {
+                    var cell = dgv.SelectedCells[0];
+                    row = dgv.Rows[cell.RowIndex];
+                }
+                if (dgv.SelectedRows.Count > 0)
+                {
+                    row = dgv.SelectedRows[0];
+                }
+                data = row.Cells[cellindex].Value.ToString();
+                txtFilterText.Text = data;
+            }
+        }
+        private void radio_filter_channelname_CheckedChanged(object sender, EventArgs e)
+        {
+            RadioButton radio = (sender as RadioButton);
+            UpdateFilterText(radio, dataGrid, 0);
+        }
+
+        private void radio_filter_title_CheckedChanged(object sender, EventArgs e)
+        {
+            RadioButton radio = (sender as RadioButton);
+            UpdateFilterText(radio, dataGrid, 3);
+        }
+
+        private void radio_filter_subtitle_CheckedChanged(object sender, EventArgs e)
+        {
+            RadioButton radio = (sender as RadioButton);
+            UpdateFilterText(radio, dataGrid,4);
+        }
+
+        private void radio_filter_description_CheckedChanged(object sender, EventArgs e)
+        {
+            RadioButton radio = (sender as RadioButton);
+            UpdateFilterText(radio, dataGrid,5);
+        }
     }
 }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22