Пример #1
0
        private bool TryUpdateOtherMeasure(string name, Rainmeter.Settings.InstanceSettings Instance, out MeasureResult result)
        {
            string section = name;

            if (section.StartsWith("["))
            {
                section = section.Substring(1, section.Length - 2);
            }
            Rainmeter.Settings.InstanceSettings other = Instance.GetSection(section);
            if (other == null)
            {
                result = null;
                return(false);
            }

            // a measure that is not directly used by a meter does not age,
            // we have to work around this
            int age = Math.Max((int)other.GetTempValue("Age", 0), (int)Instance.GetTempValue("Age", 0));

            other.SetTempValue("Age", age);

            result = Measure(other);
            Instance.SetTempValue("Base", other);
            return(true);
        }
Пример #2
0
        private MeasureResult GetCached(Rainmeter.Settings.InstanceSettings Instance)
        {
            MeasureResult cached;

            cached = (MeasureResult)Instance.GetTempValue("Cached", null);
            if (cached == null || !cached.checkAge(Instance))
            {
                return(null);
            }
            return(cached);
        }
Пример #3
0
        public bool checkAge(Rainmeter.Settings.InstanceSettings Instance)
        {
            int myResetId = (int)Instance.GetTempValue("resetId", OutlookPlugin.resetId);

            if (myResetId != OutlookPlugin.resetId)
            {
                return(false);
            }

            string strUpdateRate = virtual_INI_value(Instance, "UpdateRate");
            int    updateRate;

            if (!int.TryParse(strUpdateRate, out updateRate))
            {
                updateRate = 300;
            }

            int age = (int)Instance.GetTempValue("Age", (int)0);

            return(age < updateRate);
        }
Пример #4
0
 private MeasureResult Measure(Rainmeter.Settings.InstanceSettings Instance)
 {
     lock (Instance)
     {
         MeasureResult cached = GetCached(Instance);
         if (cached != null)
         {
             int age = (int)Instance.GetTempValue("Age", 0);
             Instance.SetTempValue("Age", age + 1);
             return(cached);
         }
         return(Evaluate(Instance));
     }
 }
Пример #5
0
        protected string virtual_INI_value(Rainmeter.Settings.InstanceSettings Instance, String key)
        {
            string r = Instance.INI_Value(key);

            if (r.Length > 0)
            {
                return(r);
            }
            if (Instance.INI_Value("Override") == "1")
            {
                return("");
            }
            Rainmeter.Settings.InstanceSettings other = (Rainmeter.Settings.InstanceSettings)Instance.GetTempValue("Base", null);
            if (other == null)
            {
                return("");
            }
            return(virtual_INI_value(other, key));
        }