ShowElement() private method

private ShowElement ( NodeModel e ) : void
e NodeModel
return void
Beispiel #1
0
        private void FindById(object id)
        {
            try
            {
                var node = DynamoViewModel.Model.CurrentWorkspace.Nodes.First(x => x.GUID.ToString() == id.ToString());

                if (node != null)
                {
                    //select the element
                    DynamoSelection.Instance.ClearSelection();
                    DynamoSelection.Instance.Selection.Add(node);

                    //focus on the element
                    DynamoViewModel.ShowElement(node);

                    return;
                }
            }
            catch
            {
                DynamoViewModel.Model.Logger.Log(Wpf.Properties.Resources.MessageFailedToFindNodeById);
            }

            try
            {
                var function =
                    (Function)DynamoViewModel.Model.CurrentWorkspace.Nodes.First(x => x is Function && ((Function)x).Definition.FunctionId.ToString() == id.ToString());

                if (function == null)
                {
                    return;
                }

                //select the element
                DynamoSelection.Instance.ClearSelection();
                DynamoSelection.Instance.Selection.Add(function);

                //focus on the element
                DynamoViewModel.ShowElement(function);
            }
            catch
            {
                DynamoViewModel.Model.Logger.Log(Wpf.Properties.Resources.MessageFailedToFindNodeById);
            }
        }