internal Object GetValue()
        {
            if (HasParent)
            {
                ParentMeasure parent = (ParentMeasure)Plugin.Measures[ParentID];

                double countItem = 0;
                if (parent.Name == "mGcal" && parent.lastEvents != null)
                {
                    countItem = parent.lastEvents.Count;
                }
                else if (parent.lastMessages != null)
                {
                    countItem = parent.lastMessages.Count;
                }
                else
                {
                    return("");
                }

                if (countItem > ndx)
                {
                    try
                    {
                        object value = null;
                        if (parent.Name == "mGcal")
                        {
                            GCalEvent ge = parent.lastEvents[ndx];
                            value = Tools.getObjectProperty(ge, property);
                            if (value == null)
                            {
                                return("");
                            }

                            if (value is DateTime)
                            {
                                DateTime dt = (DateTime)value;

                                if (Tools.IsToday(dt))
                                {
                                    return(dt.ToString(todayDateFormat));
                                }

                                else if (Tools.IsInWeek(dt))
                                {
                                    return(dt.ToString(weekDateFormat));
                                }

                                else
                                {
                                    return(dt.ToString(dateFormat));
                                }
                            }

                            else if (value is Boolean)
                            {
                                return(((Boolean)value) ? "1" : "0"); // See Update
                            }

                            else
                            {
                                return(value.ToString());
                            }
                        }
                        else
                        {
                            GMessage gm = parent.lastMessages[ndx];
                            if (this.property == "EmailDate")
                            {
                                return(gm.EmailDate.ToShortDateString() + " " + gm.EmailDate.ToShortTimeString());
                            }
                            else
                            {
                                value = Tools.getObjectProperty(gm, property);
                                return(value.ToString());
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        API.Log(API.LogType.Error, "RainGoo.dll: Exception : " + e.Message);
                    }
                }
            }



            //  API.Log(API.LogType.Warning, "RainGoo.dll: Cannot get value with index [" + ndx + "] and property [" + property + "]");



            return("");
        }
        internal override void Reload(Rainmeter.API api, ref double maxValue)
        {
            base.Reload(api, ref maxValue);

            string parentName = api.ReadString(PARAM_PARENT_NAME, "");

            IntPtr skin = api.GetSkin();

            property = api.ReadString(PARAM_PROPERTY, "");


            String mesureName = api.GetMeasureName();

            if (mesureName.StartsWith(parentName))
            {
                String sndx = mesureName.Substring(parentName.Length);
                if (sndx.IndexOf("_") > 0)
                {
                    if (String.IsNullOrEmpty(property))
                    {
                        property = sndx.Substring(sndx.IndexOf("_") + 1);
                    }

                    sndx = sndx.Substring(0, sndx.IndexOf("_"));
                }

                ndx = int.Parse(sndx);
            }
            else
            {
                ndx = api.ReadInt(PARAM_INDEX, 1);
            }

            ndx--;


            // Find parent using name AND the skin handle to be sure that it's the right one
            RuntimeTypeHandle parentType = typeof(ParentMeasure).TypeHandle;

            foreach (KeyValuePair <uint, Measure> pair in Plugin.Measures)
            {
                if (System.Type.GetTypeHandle(pair.Value).Equals(parentType))
                {
                    ParentMeasure parentMeasure = (ParentMeasure)pair.Value;

                    if (parentMeasure.Name.Equals(parentName) &&
                        parentMeasure.Skin.Equals(skin))
                    {
                        HasParent = true;
                        ParentID  = pair.Key;

                        todayDateFormat = api.ReadString(ParentMeasure.PARAM_TODAY_FORMAT, parentMeasure.todayDateFormat);
                        weekDateFormat  = api.ReadString(ParentMeasure.PARAM_WEEK_DATE_FORMAT, parentMeasure.weekDateFormat);
                        dateFormat      = api.ReadString(ParentMeasure.PARAM_DATE_FORMAT, parentMeasure.dateFormat);

                        return;
                    }
                }
            }

            HasParent = false;
            API.Log(API.LogType.Error, "RainGoo.dll: ParentName=" + parentName + " not valid");
        }