Esempio n. 1
0
        private void OnButtonClick(object sender, EventArgs e)
        {
            if (ItemOrButtonClick != null)
            {
                PEDCalcValue pcv;
                PEDC         unit = PEDC.Days;
                PEDCListItem i    = m_cbUnit.Items[m_cbUnit.SelectedIndex] as PEDCListItem;
                unit = i.Unit;
                int dummy = -1;
                if (!int.TryParse(m_tbValue.Text, out dummy) || (dummy == -1))
                {
                    pcv = new PEDCalcValue(PEDC.Inherit);
                    PluginDebug.AddInfo("Converted expiry value", 0, "Given: " + m_tbValue.Text, "Converted: " + pcv.unit.ToString());
                }
                else if (dummy <= 0)
                {
                    pcv = new PEDCalcValue(PEDC.Off);
                    PluginDebug.AddInfo("Converted expiry value", 0, "Given: " + m_tbValue.Text, "Converted: " + pcv.unit.ToString());
                }
                else
                {
                    pcv = new PEDCalcValue(unit, dummy);
                }

                QuickActionEventArgs qe = new QuickActionEventArgs(pcv);
                ItemOrButtonClick(this, qe);
            }
        }
Esempio n. 2
0
        public static string GetTranslatedUnit(PEDC unit)
        {
            string sTranslated = string.Empty;

            if (m_dTranslatedUnits.TryGetValue(unit, out sTranslated))
            {
                return(sTranslated);
            }
            sTranslated = unit.ToString();
            m_dTranslatedUnits[unit] = sTranslated;
            return(sTranslated);
        }
Esempio n. 3
0
        private void SetValue(PEDC newUnit, int newValue, bool ValueChanged, bool Force)
        {
            if (ValueChanged && !Specific)
            {
                newUnit = PEDC.Days;
            }
            if (!Force && (m_unit == newUnit) && (m_value == newValue))
            {
                return;
            }
            m_unit  = newUnit;
            m_value = newValue;
            if (m_unit == PEDC.Inherit)
            {
                m_value = -1;
            }
            if (m_unit == PEDC.Off)
            {
                m_value = 0;
            }
            if (m_value == -1)
            {
                m_unit = PEDC.Inherit;
            }
            if (m_value == 0)
            {
                m_unit = PEDC.Off;
            }
            if ((m_unit == PEDC.Inherit) || (m_unit == PEDC.Off))
            {
                NewExpiryDateUtc = UnixStart.ToUniversalTime();
                return;
            }
            double days = ConvertToDays();

            if (m_unit == PEDC.Hours)
            {
                NewExpiryDateUtc = DateTime.Now.AddHours(days).ToUniversalTime();
                return;
            }
            NewExpiryDateUtc = DateTime.Now.AddDays(days + 1);
            NewExpiryDateUtc = NewExpiryDateUtc.Date;
            TimeSpan x = new TimeSpan(0, 0, 1);

            NewExpiryDateUtc = NewExpiryDateUtc.Subtract(new TimeSpan(0, 0, 1));
            NewExpiryDateUtc = NewExpiryDateUtc.ToUniversalTime();
        }
Esempio n. 4
0
        public static PEDCalcValue ConvertFromString(string stringValue)
        {
            PEDCalcValue result = new PEDCalcValue(PEDC.Inherit);

            if (string.IsNullOrEmpty(stringValue))
            {
                return(result);
            }
            string[] s   = stringValue.Split(m_Sep);
            int      val = 0;

            if (s.Count() < 1)
            {
                return(result);
            }
            if (!int.TryParse(s[0], out val))
            {
                //Ok, it's nothing like '5 days'
                //So it better is one of the defined values for enum PEDC
                try
                {
                    PEDC unit = (PEDC)Enum.Parse(typeof(PEDC), s[0], true);
                    result.unit = unit;
                }
                catch { }
                return(result);
            }
            result.value = val;
            try
            {
                PEDC unit = (PEDC)Enum.Parse(typeof(PEDC), s[1], true);
                result.unit = unit;
            }
            catch { }
            return(result);
        }
Esempio n. 5
0
 public PEDCalcValue(PEDC unit, int value)
 {
     m_unit  = unit;
     m_value = value;
     SetValue(m_unit, m_value, false, true);
 }
Esempio n. 6
0
 public PEDCalcValue(PEDC unit)
 {
     m_unit = unit;
     SetValue(m_unit, m_value, false, false);
 }
Esempio n. 7
0
 internal PEDCListItem(PEDC pedc)
 {
     Unit = pedc;
 }