Пример #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);
            }
        }
Пример #2
0
 private void OnItemClick(object sender, EventArgs e)
 {
     if (ItemOrButtonClick != null)
     {
         PEDCalcValue         value = new PEDCalcValue(((sender as ToolStripMenuItem).Tag as PEDCalcValue).unit);
         QuickActionEventArgs qe    = new QuickActionEventArgs(value);
         ItemOrButtonClick(this, qe);
     }
 }
Пример #3
0
        private void OnPEDCalcEntryForm(object sender, QuickActionEventArgs e)
        {
            ToolStripDropDown tsdd = (sender as PEDValue_QuickAction).DropDown;

            if (tsdd == null)
            {
                return;
            }

            m_pweForm.EntryStrings.Remove(Configuration.DaysField);
            if (e.Value.Inherit)
            {
                m_pweForm.EntryStrings.Remove(Configuration.Interval);
            }
            else if (e.Value.unit != PEDC.SetExpired)
            {
                m_pweForm.EntryStrings.Set(Configuration.Interval, new ProtectedString(false, e.Value.ToString()));
            }
            m_pweForm.UpdateEntryStrings(false, true);
            if (e.Value.Off)
            {
                return;
            }
            ExpiryControlGroup ecg = (ExpiryControlGroup)Tools.GetField("m_cgExpiry", m_pweForm);
            PEDCalcValue       pcv = e.Value;

            if (!e.Value.Specific)
            {
                pcv = m_pweForm.EntryRef.GetPEDValueInherit();
            }
            if (!pcv.Off)
            {
                ecg.Checked = true;
                if (e.Value.unit == PEDC.SetExpired)
                {
                    ecg.Value = PEDCalcValue.UnixStart;
                }
                else
                {
                    ecg.Value = pcv.NewExpiryDateUtc;
                }
            }
        }
Пример #4
0
        private void OnPerformPEDAction(object sender, QuickActionEventArgs e)
        {
            ToolStripDropDown tsdd = (sender as PEDValue_QuickAction).DropDown;

            if (tsdd == null)
            {
                return;
            }

            bool bEntry = (m_ContextMenuEntry.DropDown == tsdd) || (m_MainMenuEntry.DropDown == tsdd);
            bool bGroup = (m_ContextMenuGroup.DropDown == tsdd) || (m_MainMenuGroup.DropDown == tsdd);

            if (!bEntry && !bGroup)
            {
                return;
            }
            //PEDCalcValue pcv = tsmiAction != null ? tsmiAction.Tag as PEDCalcValue : (sender as PEDValue_QuickAction).PEDValue;

            if (bGroup)
            {
                if (e.Value.unit == PEDC.SetNeverExpires)
                {
                    e.Value.unit = PEDC.Off;
                }
                PwGroup pg = m_host.MainWindow.GetSelectedGroup();
                if (e.Value.unit == PEDC.SetExpired)
                {
                    bool bExpireAll = CheckExpireAll(pg);
                    pg.Expire(bExpireAll);
                }
                else
                {
                    pg.SavePEDCString(e.Value);
                    if (Configuration.Active && !e.Value.Off && (Tools.AskYesNo(PluginTranslate.AskRecalcAll) == DialogResult.Yes))
                    {
                        pg.RecalcExpiry();
                    }
                    pg.Touch(true, false);
                }
                Tools.RefreshEntriesList(true);
            }
            else if (bEntry)
            {
                List <PwEntry> lEntries = m_host.MainWindow.GetSelectedEntries().ToList();
                if (e.Value.unit == PEDC.SetExpired)
                {
                    bool bExpireAll = CheckExpireAll(lEntries);
                    foreach (PwEntry entry in lEntries)
                    {
                        entry.Expire(bExpireAll);
                    }
                }
                else
                {
                    if (e.Value.unit != PEDC.SetNeverExpires)
                    {
                        foreach (PwEntry entry in lEntries)
                        {
                            entry.SavePEDCString(e.Value);
                        }
                        if (Configuration.Active && !e.Value.Off && (Tools.AskYesNo(lEntries.Count() > 1 ? PluginTranslate.AskRecalcAll : PluginTranslate.AskRecalcSingle) == DialogResult.Yes))
                        {
                            foreach (PwEntry entry in lEntries)
                            {
                                entry.Expires = true;
                                entry.RecalcExpiry(true);
                            }
                        }
                    }
                    foreach (PwEntry entry in lEntries)
                    {
                        Configuration.SkipRecalc = true;
                        if (e.Value.unit == PEDC.SetNeverExpires)
                        {
                            entry.Expires = false;
                        }
                        entry.Touch(true, false);
                    }
                }
                Tools.RefreshEntriesList(true);
            }
        }