Example #1
0
        ///<summary>Works for a new table and for an existing table.</summary>
        private void Table_Click()
        {
            int idx = textContent.SelectionStart;

            if (TableOrDoubleClick(idx))
            {
                return;                //so it was already handled with an edit table dialog
            }
            //User did not click inside a table, so they must want to add a new table.
            FormWikiTableEdit FormWTE = new FormWikiTableEdit();

            FormWTE.Markup = @"{|
!Width=""100""|Heading1!!Width=""100""|Heading2!!Width=""100""|Heading3
|-
|||||
|-
|||||
|}";
            FormWTE.IsNew  = true;
            FormWTE.ShowDialog();
            if (FormWTE.DialogResult != DialogResult.OK)
            {
                return;
            }
            textContent.SelectionLength = 0;
            textContent.Paste(FormWTE.Markup);
            textContent.SelectionLength = 0;
            textContent.Focus();
        }
Example #2
0
        ///<summary>This is called both when a user double clicks anywhere in the edit box, or when the click the Table button in the toolbar.  This ONLY handles popping up an edit window for an existing table.  If the cursor was not in an existing table, then this returns false.  After that, the behavior in the two areas differs.  Returns true if it popped up.</summary>
        private bool TableOrDoubleClick(int charIdx)
        {
            //there is some code clutter in this method from when we used TableViews.  It seems harmless, but can be removed whenever.
            MatchCollection matches;
            //Tables-------------------------------------------------------------------------------
            string strTableClicked = "";
            string strTableFirst   = "";
            int    countTable      = 0;

            matches    = Regex.Matches(textContent.Text, @"\{\|(.+?)\|\}", RegexOptions.Singleline);
            countTable = matches.Count;
            for (int i = 0; i < matches.Count; i++)
            {
                if (i == 0)
                {
                    strTableFirst = matches[i].Value;
                }
                if (charIdx > matches[i].Index &&
                    charIdx < matches[i].Index + matches[i].Length)
                {
                    strTableClicked = matches[i].Value;
                }
            }
            //handle the clicks----------------------------------------------------------------------------
            string strTableLoad = "";

            if (strTableClicked != "")          //clicked in a table
            {
                strTableLoad = strTableClicked;
            }
            else
            {
                return(false);               //did not click inside a table
            }
            textContent.SelectionLength = 0; //otherwise we get an annoying highlight
            FormWikiTableEdit formT = new FormWikiTableEdit();

            formT.Markup            = strTableLoad;
            formT.CountTablesInPage = countTable;
            formT.IsNew             = false;
            formT.ShowDialog();
            if (formT.DialogResult != DialogResult.OK)
            {
                return(true);
            }
            if (formT.Markup == null)           //indicates delete
            {
                textContent.Text            = textContent.Text.Replace(strTableLoad, "");
                textContent.SelectionLength = 0;
                return(true);
            }
            textContent.Text            = textContent.Text.Replace(strTableLoad, formT.Markup);
            textContent.SelectionLength = 0;
            return(true);
        }
Example #3
0
		///<summary>Works for a new table and for an existing table.</summary>
		private void Table_Click() {
			int idx=textContent.SelectionStart;
			if(TableOrDoubleClick(idx)) {
				return;//so it was already handled with an edit table dialog
			}
			//User did not click inside a table, so they must want to add a new table.
			FormWikiTableEdit FormWTE=new FormWikiTableEdit();
			FormWTE.Markup=@"{|
!Width=""100""|Heading1!!Width=""100""|Heading2!!Width=""100""|Heading3
|-
|||||
|-
|||||
|}";
			FormWTE.IsNew=true;
			FormWTE.ShowDialog();
			if(FormWTE.DialogResult!=DialogResult.OK){
				return;
			}
			textContent.SelectionLength=0;
			textContent.Paste(FormWTE.Markup);
			textContent.SelectionLength=0;
			textContent.Focus();
		}
Example #4
0
		///<summary>This is called both when a user double clicks anywhere in the edit box, or when the click the Table button in the toolbar.  This ONLY handles popping up an edit window for an existing table.  If the cursor was not in an existing table, then this returns false.  After that, the behavior in the two areas differs.  Returns true if it popped up.</summary>
		private bool TableOrDoubleClick(int charIdx){
			//there is some code clutter in this method from when we used TableViews.  It seems harmless, but can be removed whenever.
			MatchCollection matches;
			//Tables-------------------------------------------------------------------------------
			string strTableClicked="";
			string strTableFirst="";
			int countTable=0;
			matches=Regex.Matches(textContent.Text,@"\{\|(.+?)\|\}",RegexOptions.Singleline);
			countTable=matches.Count;
			for(int i=0;i<matches.Count;i++) {
				if(i==0){
					strTableFirst=matches[i].Value;
				}
				if(charIdx >	matches[i].Index
					&& charIdx <	matches[i].Index+matches[i].Length) 
				{
					strTableClicked=matches[i].Value;
				}
			}
			//handle the clicks----------------------------------------------------------------------------
			string strTableLoad="";
			if(strTableClicked!=""){//clicked in a table
				strTableLoad=strTableClicked;
			}
			else{
				return false;//did not click inside a table
			}
			textContent.SelectionLength=0;//otherwise we get an annoying highlight
			FormWikiTableEdit formT=new FormWikiTableEdit();
			formT.Markup=strTableLoad;
			formT.CountTablesInPage=countTable;
			formT.IsNew=false;
			formT.ShowDialog();
			if(formT.DialogResult!=DialogResult.OK) {
				return true;
			}
			if(formT.Markup==null) {//indicates delete
				textContent.Text=textContent.Text.Replace(strTableLoad,"");
				textContent.SelectionLength=0;
				return true;
			}
			textContent.Text=textContent.Text.Replace(strTableLoad,formT.Markup);
			textContent.SelectionLength=0;
			return true;
		}