コード例 #1
0
        void View_SaveRule(object sender, SaveRuleEventArgs e)
        {
            string directory = GetRuleDirectory(e.RuleItem.Rule);

            if (!string.IsNullOrEmpty(directory))
            {
                string fileName = Path.Combine(directory, GetValidFileName(e.RuleItem.Rule.Name) + ".rule");

                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                if (fileName.ToLower() != e.RuleItem.FileName.ToLower())
                {
                    //
                    // Delete the previous file
                    //
                    if (File.Exists(e.RuleItem.FileName))
                    {
                        File.Delete(e.RuleItem.FileName);
                    }
                }
                SaveRule(e.RuleItem.Rule, fileName);
                e.RuleItem.FileName = fileName;
            }
        }
コード例 #2
0
        public bool OnSaveRule(RuleItem rule)
        {
            if (SaveRule != null)
            {
                SaveRuleEventArgs e = new SaveRuleEventArgs(rule);

                SaveRule(this, e);
                return(e.Cancel);
            }
            return(false);
        }