Beispiel #1
0
        private bool SplitParagraph(MultiLineInsertData input, out Action makeSelection)
        {
            int index = ItemIndex(input.Selection as InsertionPoint);

            MakeListItem(index + 1, false);
            var newItem = List[index + 1];
            var sel     = input.Selection as InsertionPoint;

            if (input.TsStrAppendToFirstPara == null || input.TsStrPrependToLastPara == null)
            {
                MoveMaterialAfterIpToStart(sel, input.StringAppendToFirstPara, input.StringPrependToLastPara, newItem);
            }
            else
            {
                MoveMaterialAfterIpToStart(sel, input.TsStrAppendToFirstPara, input.TsStrPrependToLastPara, newItem);
            }
            if (input.ParaStyles != null)
            {
                if (input.ParaStyles.First() != null)
                {
                    ApplyParagraphStyle(index, 1, input.ParaStyles.First().Name);
                }
                if (input.ParaStyles.Last() != null)
                {
                    ApplyParagraphStyle(index + 1, 1, input.ParaStyles.Last().Name);
                }
            }

            makeSelection = () => SelectionBuilder.In(Hookup)[index].Offset(0).Install();
            return(true);
        }
Beispiel #2
0
        public bool InsertLines(MultiLineInsertData input, out Action makeSelection)
        {
            var selection = input.Selection as InsertionPoint;
            int index     = ItemIndex(selection) + 1;

            if (input.InsertedTsStrLines != null)
            {
                var styles = new IStyle[input.InsertedTsStrLines.Count + 1];
                if (input.ParaStyles != null)
                {
                    styles = input.ParaStyles.ToArray();
                }
                SplitParagraph(input, out makeSelection);

                for (int i = 0; i < input.InsertedTsStrLines.Count; i++)
                {
                    ITsString str   = input.InsertedTsStrLines[i];
                    IStyle    style = styles[i + 1];
                    var       item  = MakeListItem(index, false);
                    SetString(item, str);
                    if (style != null)
                    {
                        ApplyParagraphStyle(index, 1, style.Name);
                    }
                    index++;
                }
            }
            else
            {
                var styles = new IStyle[input.InsertedStringLines.Count + 1];
                if (input.ParaStyles != null)
                {
                    styles = input.ParaStyles.ToArray();
                }
                SplitParagraph(input, out makeSelection);

                for (int i = 0; i < input.InsertedStringLines.Count; i++)
                {
                    string str   = input.InsertedStringLines[i];
                    IStyle style = styles[i + 1];
                    var    item  = MakeListItem(index, false);
                    SetString(item, str);
                    if (style != null)
                    {
                        ApplyParagraphStyle(index, 1, style.Name);
                    }
                    index++;
                }
            }
            return(true);
        }
 /// <summary>
 /// Insert the specified text at the insertion point.
 /// Enhance JohnT: normalize the string after the edit, maintaining the posititon of the IP correctly.
 /// </summary>
 public override bool InsertText(string input)
 {
     if (!CanInsertText)
     {
         return(false);        // cannot modify; should we report this somehow?
     }
     Invalidate();             // Hide the old selection while we still know where it is.
     if (input.Contains("\r") || input.Contains("\n"))
     {
         MultiLineInsertData inputInsertData = new MultiLineInsertData(this, input, null);
         Action makeSelection;
         ParagraphOperations.InsertLines(inputInsertData, out makeSelection);
         RootBox.Site.PerformAfterNotifications(makeSelection);
         return(true);
     }
     Hookup.InsertText(this, input);
     StringPosition += input.Length;
     return(true);
 }
Beispiel #4
0
		/// <summary>
		/// Insert the specified text at the insertion point.
		/// Enhance JohnT: normalize the string after the edit, maintaining the posititon of the IP correctly.
		/// </summary>
		public override bool InsertText(string input)
		{
			if (!CanInsertText)
				return false; // cannot modify; should we report this somehow?
			Invalidate(); // Hide the old selection while we still know where it is.
			if (input.Contains("\r") || input.Contains("\n"))
			{
				MultiLineInsertData inputInsertData = new MultiLineInsertData(this, input, null);
				Action makeSelection;
				ParagraphOperations.InsertLines(inputInsertData, out makeSelection);
				RootBox.Site.PerformAfterNotifications(makeSelection);
				return true;
			}
			Hookup.InsertText(this, input);
			StringPosition += input.Length;
			return true;
		}