private String GetProperty(IPropertyType aProperty, Control aControl)
 {
     String result = aProperty.Get();
     result = result.Replace("$ControlClass", aControl.ControlClass());
     result = result.Replace("$ControlName", aControl.ControlName);
     return result;
 }
        public String AssignmentStatement(Control aControl, IPropertyType aProperty, String aValue)
        {
            String result = aProperty.Set();
            if (aValue.EndsWith(";"))
                aValue = aValue.Remove(aValue.Length - 1, 1);

            result = result.Replace("$ControlClass", aControl.ControlClass());
            result = result.Replace("$ControlName", aControl.ControlName);
            result = result.Replace("$Value", aValue);
            return result;
        }
        public List<String> GetEventHandler(Control aControl)
        {
            List<String> result = new List<String>(); ;
            Control mainForm = ControlAction.Instance.GetMainForm();

            bool foundEventHandler = false;

            FileInfo[] pascalSourceFiles = AppUtils.GetFiles(AppConfiguration.Instance.InputPath, "*.pas", "Pascal source");
            foreach (FileInfo file in pascalSourceFiles)
            {
                List<String> sourceCodeList = GetSourceCode(file.FullName);
                bool afterBegin = false;
                foreach (String code in sourceCodeList)
                {
                    if (afterBegin && code.Trim().StartsWith("end"))
                        break;

                    if (afterBegin && !code.Trim().StartsWith("end"))
                    {
                        // TODO: This should actually be done by the Object Pascal language compiler (thats still outstanding)
                        result.Add(Parse(code));
                    }

                    if (code.IndexOf(mainForm.ControlName + "." + aControl.Prop_OnClick) > -1)
                        foundEventHandler = true;

                    if (foundEventHandler && code.Trim().StartsWith("begin"))
                        afterBegin = true;
                }
            }

            if (!foundEventHandler)
                throw new ArgumentException("Can't find event handler '" + aControl.Prop_OnClick + "' for control: " + aControl.ControlName);

            return result;
        }
        /// <summary>
        /// Return the property for the given control
        /// </summary>
        /// <param name="aControl"></param>
        /// <param name="aPropertyName"></param>
        /// <returns></returns>
        public IPropertyType GetProperty(Control aControl, String aPropertyName)
        {
            IPropertyType[] controlProperties = aControl.Properties();
            if (controlProperties == null || controlProperties.Length == 0)
                throw new CompileErrorException("Control '" + aControl.ControlClass() + "' doesn't have any properties");

            IPropertyType property = (from c in controlProperties
                                                where c.GetType().Name.CompareTo(aPropertyName) == 0
                                                select c).FirstOrDefault();

            return property;
        }