///<summary></summary>
		public static void Update(QuickPasteCat cat){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),cat);
				return;
			}
			Crud.QuickPasteCatCrud.Update(cat);
		}
		///<summary></summary>
		public static long Insert(QuickPasteCat cat) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				cat.QuickPasteCatNum=Meth.GetLong(MethodBase.GetCurrentMethod(),cat);
				return cat.QuickPasteCatNum;
			}
			return Crud.QuickPasteCatCrud.Insert(cat);
		}
Example #3
0
 private void butAddCat_Click(object sender, System.EventArgs e)
 {
     QuickPasteCat quickCat=new QuickPasteCat();
     if(listCat.SelectedIndex==-1){
         quickCat.ItemOrder=listCat.Items.Count;//one more than list will hold.
     }
     else{
         quickCat.ItemOrder=listCat.SelectedIndex;
     }
     QuickPasteCats.Insert(quickCat);
       FormQuickPasteCat FormQ=new FormQuickPasteCat(quickCat);
     FormQ.ShowDialog();
     if(FormQ.DialogResult==DialogResult.OK){
         if(listCat.SelectedIndex!=-1){
             //move other items down in list to make room for new one.
             for(int i=listCat.SelectedIndex;i<QuickPasteCats.List.Length;i++){
                 QuickPasteCats.List[i].ItemOrder++;
                 QuickPasteCats.Update(QuickPasteCats.List[i]);
             }
         }
         localChanged=true;
     }
     else{
         QuickPasteCats.Delete(quickCat);
     }
     QuickPasteCats.RefreshCache();
     FillCats();
     FillNotes();
 }
Example #4
0
        ///<summary>Called on KeyUp from various textBoxes in the program to look for a ?abbrev and attempt to substitute.  Substitutes the text if found.</summary>
        public static string Substitute(string text, QuickPasteType type)
        {
            //No need to check RemotingRole; no call to db.
            int                   typeIndex            = QuickPasteCats.GetDefaultType(type);
            QuickPasteCat         quickPasteCatDefault = QuickPasteCats.GetDeepCopy()[typeIndex];
            List <QuickPasteNote> listQuickPasteCats   = GetDeepCopy();

            for (int i = 0; i < listQuickPasteCats.Count; i++)
            {
                if (listQuickPasteCats[i].Abbreviation == "")
                {
                    continue;
                }
                if (listQuickPasteCats[i].QuickPasteCatNum != quickPasteCatDefault.QuickPasteCatNum)
                {
                    continue;
                }
                //We have to replace all $ chars with $$ because Regex.Replace allows "Substitutions" in the replacement parameter.
                //The replacement parameter specifies the string that is to replace each match in input. replacement can consist of any combination of literal
                //text and substitutions. For example, the replacement pattern a*${test}b inserts the string "a*" followed by the substring that is matched by
                //the test capturing group, if any, followed by the string "b".
                //The * character is not recognized as a metacharacter within a replacement pattern.
                //See https://msdn.microsoft.com/en-us/library/taz3ak2f(v=vs.110).aspx for more information.
                string quicknote = listQuickPasteCats[i].Note.Replace("$", "$$");
                //Techs were complaining about quick notes replacing text that was pasted into text boxes (e.g. when a URL happens to have ?... that matches a quick note abbr).
                //The easiest way to deal with this is to not allow the regular expression to replace strings that have a non-whitespace character before or after the abbr.
                //The regex of '...(?<!\S)...' is utilizing an optional space via a lookbehind and visa versa with '...(?!\S)...' as a lookahead.
                var pattern        = @"(?<spaceBefore>(?<!\S))\?" + Regex.Escape(listQuickPasteCats[i].Abbreviation) + @"(?<spaceAfter>(?!\S))";
                var replacePattern = "${spaceBefore}" + (quicknote) + "${spaceAfter}";
                text = Regex.Replace(text, pattern, replacePattern, RegexOptions.None);
            }
            return(text);
        }
Example #5
0
		///<summary></summary>
		public FormQuickPasteCat(QuickPasteCat quickCat){
			QuickCat=quickCat;
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			Lan.F(this);
		}
Example #6
0
 ///<summary></summary>
 public static void Update(QuickPasteCat cat)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), cat);
         return;
     }
     Crud.QuickPasteCatCrud.Update(cat);
 }
Example #7
0
 ///<summary></summary>
 public static long Insert(QuickPasteCat cat)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         cat.QuickPasteCatNum = Meth.GetLong(MethodBase.GetCurrentMethod(), cat);
         return(cat.QuickPasteCatNum);
     }
     return(Crud.QuickPasteCatCrud.Insert(cat));
 }
		///<summary></summary>
		public static void Delete(QuickPasteCat cat){
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),cat);
				return;
			}
			string command="DELETE from quickpastecat WHERE QuickPasteCatNum = '"
				+POut.Long(cat.QuickPasteCatNum)+"'";
 			Db.NonQ(command);
		}
Example #9
0
        ///<summary></summary>
        public static void Delete(QuickPasteCat cat)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), cat);
                return;
            }
            string command = "DELETE from quickpastecat WHERE QuickPasteCatNum = '"
                             + POut.Long(cat.QuickPasteCatNum) + "'";

            Db.NonQ(command);
        }
Example #10
0
        ///<summary>Returns a list of all categories for a single type. Will return an empty list if no type is selected.</summary>
        public static List <QuickPasteCat> GetCategoriesForType(QuickPasteType type)
        {
            //No need to check RemotingRole; no call to db.
            List <QuickPasteCat> listQuickCats = GetWhere(x => type.In(x.ListDefaultForTypes));

            if (listQuickCats.Count == 0)
            {
                QuickPasteCat quickCat = GetDeepCopy().FirstOrDefault();              //First category from db by item order
                if (quickCat != null)
                {
                    listQuickCats.Add(quickCat);
                }
            }
            return(listQuickCats);
        }