Beispiel #1
0
 public GnosisNavigatorFrameController(
     GnosisNavigatorFrame _navFrame,
     // IGnosisNavFrameImplementation _navFrameImplementation,
     GnosisInstanceController instanceController,
     GnosisNavTileController parent)
     : base(_navFrame, instanceController, parent)
 {
 }
Beispiel #2
0
        private bool EvaluateSequence(string input)
        {
            MatchCollection conditions = regexCondition.Matches(input);

            foreach (Match condition in conditions)
            {
                //Find the source control and evaluate the relevant property
                //We do not have the id of the source control. We find it by type.
                //It may reference the control on which the event was raised - ownerControl
                string propertyName             = regexPropertyName.Match(condition.ToString()).ToString();
                GnosisEventHandlerSource source = FindEventHandlerSource(propertyName);
                if (source == null)
                {
                    GlobalData.Singleton.ErrorHandler.HandleError("Could not find event handler source for " + propertyName, "GnosisBooleanHelper.EvaluateSequence");
                }

                bool   result            = false;
                string sourceControlType = source.ControlType;
                if (ownerControl.ControlType.Equals(sourceControlType))
                {
                    //check property of ownerControl
                    PropertyInfo prop = ownerControl.GetType().GetProperty(propertyName);
                    result = (bool)prop.GetValue(ownerControl, null);
                }
                else if (sourceControlType.Equals("Connection"))
                {
                    GnosisConnection connection = GlobalData.Singleton.Connection;
                    PropertyInfo     propInfo   = connection.GetType().GetProperty(propertyName);
                    result = (bool)propInfo.GetValue(connection, null);
                }
                else if (sourceControlType.Equals("Generic Menu Item"))
                {
                    GnosisGenericMenuItemController target = GnosisGenericMenuItemController.CurrentMenuItemController;
                    PropertyInfo propInfo = target.GetType().GetProperty(propertyName);
                    result = (bool)propInfo.GetValue(target, null);
                }
                else if (sourceControlType.Equals("Navigator Tile"))
                {
                    GnosisNavTileController target   = GlobalData.Singleton.PrimarySplitController.NavTileController;
                    PropertyInfo            propInfo = target.GetType().GetProperty(propertyName);
                    result = (bool)propInfo.GetValue(target, null);
                }
                else
                {
                    //Look for the GenericControlController
                    GnosisGenericControlController genericControlController = GlobalData.Singleton.FindGenericControllerByType(sourceControlType);
                    if (genericControlController != null)
                    {
                        GnosisVisibleController target   = genericControlController.CurrentInstance;
                        PropertyInfo            propInfo = target.GetType().GetProperty(propertyName);
                        result = (bool)propInfo.GetValue(target, null);
                    }
                    else
                    {
                        GlobalData.Singleton.ErrorHandler.HandleError("GenericControl not found of type " + sourceControlType.ToString(),
                                                                      "GnosisBooleanHelper.EvaluateSequence");
                    }
                }

                if (condition.ToString().Contains("Not"))
                {
                    result = !result;
                }
                input = input.Replace(condition.ToString(), result.ToString());
            }


            bool sequenceResult = Eval(input);

            //MatchCollection booleans = regexBooleans.Matches(input);
            //List<bool> results = new List<bool>();
            //foreach (Match m in booleans)
            //{
            //    results.Add(Boolean.Parse(m.ToString()));
            //}
            //if (input.Contains("and"))
            //{
            //    if (results.Any(x => x == false))
            //    {
            //        sequenceResult = false;
            //    }
            //    else
            //    {
            //        sequenceResult = true;
            //    }

            //}
            //else if (input.Contains("or"))
            //{
            //    if (results.Any(x => x == true))
            //    {
            //        sequenceResult = true;
            //    }
            //    else
            //    {
            //        sequenceResult = false;
            //    }
            //}
            //else //only one condition
            //{
            //    if (input.Contains("True"))
            //    {
            //        sequenceResult = true;
            //    }
            //    else
            //    {
            //        sequenceResult = false;
            //    }
            //}

            return(sequenceResult);
        }