/[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/08 14:13:19	61
+++ trunk/xmltv_parser/main.cs	2013/03/08 14:26:48	63
@@ -28,6 +28,8 @@
         public main()
         {
             InitializeComponent();
+            ListViewSorter Sorter = new ListViewSorter();
+            lstPrograms.ListViewItemSorter = Sorter;
             string log_path = Application.StartupPath;
             string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
             gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
@@ -266,29 +268,16 @@
 
         private void lstPrograms_ColumnClick(object sender, ColumnClickEventArgs e)
         {
-            ListViewSorter Sorter = new ListViewSorter();
-            lstPrograms.ListViewItemSorter = Sorter;
-            if (!(lstPrograms.ListViewItemSorter is ListViewSorter))
-                return;
-            Sorter = (ListViewSorter)lstPrograms.ListViewItemSorter;
-
-            //if (Sorter.LastSort == e.Column)
-            //{
-            //    if (lstPrograms.Sorting == SortOrder.Ascending)
-            //        lstPrograms.Sorting = SortOrder.Descending;
-            //    else
-            //        lstPrograms.Sorting = SortOrder.Ascending;
-            //}
-            //else
-            //{
-            //    lstPrograms.Sorting = SortOrder.Descending;
-            //}
-            if (lstPrograms.Sorting == SortOrder.Ascending)
-                lstPrograms.Sorting = SortOrder.Descending;
-            else
-                lstPrograms.Sorting = SortOrder.Ascending;
-            Sorter.ByColumn = e.Column;
-
+            if (!(lstPrograms.ListViewItemSorter is ListViewSorter)) return;
+            ListViewSorter Sorter = (ListViewSorter)lstPrograms.ListViewItemSorter;
+            Sorter.LastColumn = Sorter.CurrentColumn;
+            Sorter.CurrentColumn = e.Column;
+            if (Sorter.LastColumn == e.Column)
+            {
+                if (lstPrograms.Sorting == SortOrder.Ascending) { lstPrograms.Sorting = SortOrder.Descending; }
+                else { lstPrograms.Sorting = SortOrder.Ascending; }
+            }
+            else { lstPrograms.Sorting = SortOrder.Descending; }
             lstPrograms.Sort();
         }
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22