Browse Source

Merge branch 'master' of https://github.com/daltskin/gui.cs

Jamie D 5 years ago
parent
commit
b9b3886c67
2 changed files with 37 additions and 7 deletions
  1. 27 5
      UICatalog/Scenarios/Scrolling.cs
  2. 10 2
      UICatalog/UICatalog.cs

+ 27 - 5
UICatalog/Scenarios/Scrolling.cs

@@ -203,19 +203,41 @@ namespace UICatalog {
 				X = Pos.X(scrollView),
 				Y = Pos.Bottom(scrollView) + 1,
 			};
-			hCheckBox.Toggled += (previousChecked) => {
-				scrollView.ShowHorizontalScrollIndicator = hCheckBox.Checked;
-			};
 			Win.Add (hCheckBox);
 
 			var vCheckBox = new CheckBox ("Vertical Scrollbar", scrollView.ShowVerticalScrollIndicator) {
 				X = Pos.Right (hCheckBox) + 3,
 				Y = Pos.Bottom (scrollView) + 1,
 			};
+			Win.Add (vCheckBox);
+
+			var t = "Auto Hide Scrollbars";
+			var ahCheckBox = new CheckBox (t, scrollView.AutoHideScrollBars) {
+				X = Pos.Left (scrollView) + scrollView.Bounds.Width / 2 - t.Length / 2,
+				Y = Pos.Bottom (scrollView) + 3,
+			};
+			hCheckBox.Toggled += (previousChecked) => {
+				if (!ahCheckBox.Checked) {
+					scrollView.ShowHorizontalScrollIndicator = hCheckBox.Checked;
+				} else {
+					hCheckBox.Checked = true;
+					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
+				}
+			};
 			vCheckBox.Toggled += (previousChecked) => {
-				scrollView.ShowVerticalScrollIndicator = vCheckBox.Checked;
+				if (!ahCheckBox.Checked) {
+					scrollView.ShowVerticalScrollIndicator = vCheckBox.Checked;
+				} else {
+					vCheckBox.Checked = true;
+					MessageBox.Query ("Message", "Disable Auto Hide Scrollbars first.", "Ok");
+				}
 			};
-			Win.Add (vCheckBox);
+			ahCheckBox.Toggled += (previousChecked) => {
+				scrollView.AutoHideScrollBars = ahCheckBox.Checked;
+				hCheckBox.Checked = true;
+				vCheckBox.Checked = true;
+			};
+			Win.Add (ahCheckBox);
 
 			var scrollView2 = new ScrollView (new Rect (55, 2, 20, 8)) {
 				ContentSize = new Size (20, 50),

+ 10 - 2
UICatalog/UICatalog.cs

@@ -56,6 +56,8 @@ namespace UICatalog {
 		private static StatusItem _capslock;
 		private static StatusItem _numlock;
 		private static StatusItem _scrolllock;
+		private static int _categoryListViewItem;
+		private static int _scenarioListViewItem;
 
 		private static Scenario _runningScenario = null;
 		private static bool _useSystemConsole = false;
@@ -191,7 +193,7 @@ namespace UICatalog {
 			_scenarioListView.OpenSelectedItem += _scenarioListView_OpenSelectedItem;
 			_rightPane.Add (_scenarioListView);
 
-			_categoryListView.SelectedItem = 0;
+			_categoryListView.SelectedItem = _categoryListViewItem;
 			_categoryListView.OnSelectedChanged ();
 
 			_capslock = new StatusItem (Key.CharMask, "Caps", null);
@@ -300,6 +302,7 @@ namespace UICatalog {
 		private static void _scenarioListView_OpenSelectedItem (EventArgs e)
 		{
 			if (_runningScenario is null) {
+				_scenarioListViewItem = _scenarioListView.SelectedItem;
 				var source = _scenarioListView.Source as ScenarioListDataSource;
 				_runningScenario = (Scenario)Activator.CreateInstance (source.Scenarios [_scenarioListView.SelectedItem]);
 				Application.RequestStop ();
@@ -396,6 +399,10 @@ namespace UICatalog {
 
 		private static void CategoryListView_SelectedChanged (ListViewItemEventArgs e)
 		{
+			if (_categoryListViewItem != _categoryListView.SelectedItem) {
+				_scenarioListViewItem = 0;
+			}
+			_categoryListViewItem = _categoryListView.SelectedItem;
 			var item = _categories [_categoryListView.SelectedItem];
 			List<Type> newlist;
 			if (item.Equals ("All")) {
@@ -405,7 +412,8 @@ namespace UICatalog {
 				newlist = _scenarios.Where (t => Scenario.ScenarioCategory.GetCategories (t).Contains (item)).ToList ();
 			}
 			_scenarioListView.Source = new ScenarioListDataSource (newlist);
-			_scenarioListView.SelectedItem = 0;
+			_scenarioListView.SelectedItem = _scenarioListViewItem;
+
 		}
 	}
 }