Focusing relevant event node after rebuilding our tree view.
authorStephaneLenclud
Mon, 25 Jul 2016 17:48:12 +0200
changeset 218c466f72a834f
parent 217 94f91d446339
child 219 99c407831232
Focusing relevant event node after rebuilding our tree view.
Server/MainForm.cs
     1.1 --- a/Server/MainForm.cs	Mon Jul 25 17:14:45 2016 +0200
     1.2 +++ b/Server/MainForm.cs	Mon Jul 25 17:48:12 2016 +0200
     1.3 @@ -300,7 +300,7 @@
     1.4  		}
     1.5  
     1.6          /// <summary>
     1.7 -        /// 
     1.8 +        /// Populate tree view with events and actions
     1.9          /// </summary>
    1.10          private void SetupEvents()
    1.11          {
    1.12 @@ -308,6 +308,8 @@
    1.13              buttonAddAction.Enabled = false;
    1.14              buttonDeleteAction.Enabled = false;
    1.15  
    1.16 +            Event currentEvent = CurrentEvent();
    1.17 +
    1.18              //Reset our tree
    1.19              iTreeViewEvents.Nodes.Clear();
    1.20              //Populate registered events
    1.21 @@ -328,6 +330,7 @@
    1.22              }
    1.23  
    1.24              iTreeViewEvents.ExpandAll();
    1.25 +            SelectEvent(currentEvent);
    1.26  
    1.27          }
    1.28  
    1.29 @@ -2642,6 +2645,27 @@
    1.30              SetupCecLogLevel();
    1.31          }
    1.32  
    1.33 +       
    1.34 +        /// <summary>
    1.35 +        /// 
    1.36 +        /// </summary>
    1.37 +        /// <param name="aEvent"></param>
    1.38 +        private void SelectEvent(Event aEvent)
    1.39 +        {
    1.40 +            if (aEvent == null)
    1.41 +            {
    1.42 +                return;
    1.43 +            }
    1.44 +
    1.45 +            string key = aEvent.GetType().Name;
    1.46 +            TreeNode[] res=iTreeViewEvents.Nodes.Find(key, false);
    1.47 +            if (res.Length > 0)
    1.48 +            {                
    1.49 +                iTreeViewEvents.SelectedNode = res[0];
    1.50 +                iTreeViewEvents.Focus();
    1.51 +            }
    1.52 +        }
    1.53 +
    1.54          /// <summary>
    1.55          /// 
    1.56          /// </summary>