Beispiel #1
0
 public void MoveLeft()
 {
     ParaBox        para;
     RootBox        root = ParaBuilderTests.MakeTestParaSimpleString(m_gm.VwGraphics, ParaBuilderTests.MockBreakOption.ThreeFullLines, out para);
     InsertionPoint ip   = root.SelectAtEnd();
     // Todo: try moving left. Eventualy cover various options, such as from start of paragraph, over diacritics, etc.
 }
Beispiel #2
0
        internal override void InsertText(InsertionPoint ip, string input)
        {
            MultiAccessor.set_String(m_ws, ((MlsClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Tss);
            var bldr = MultiAccessor.get_String(m_ws).GetBldr();
            // Where there is a choice, we want the new text to have the properties of the neighbor
            // character that the IP is most closely associated with.
            ITsTextProps props;

            if (ip.StringPosition > 0 && ip.AssociatePrevious)
            {
                props = bldr.get_PropertiesAt(ip.StringPosition - 1);
            }
            else
            {
                props = bldr.get_PropertiesAt(ip.StringPosition);                 // might be the lim, but that's OK.
            }
            if (ip.StyleToBeApplied != null)
            {
                var propsBldr = props.GetBldr();
                propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, ip.StyleToBeApplied.Name);
                props = propsBldr.GetTextProps();
            }

            // Enhance JohnT: there may possibly be some special caes, e.g., where the indicated character
            // is an ORC linked to certain kinds of data or a verse number, where we don't want to copy all
            // the properties.
            bldr.Replace(ip.StringPosition, ip.StringPosition, input, props);
            MultiAccessor.set_String(m_ws, bldr.GetString());
        }
Beispiel #3
0
        internal void DrawIp(InsertionPoint ip, IVwGraphics vg, PaintTransform ptrans)
        {
            PaintTransform segTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            Segment.DrawInsertionPoint(IchMin, vg, segTrans.SourceRect, segTrans.DestRect,
                                       ip.RenderParaPosition, ip.AssociatePrevious, true, LgIPDrawMode.kdmNormal);
        }
Beispiel #4
0
        public void DrawIP()
        {
            ParaBox        para;
            RootBox        root = ParaBuilderTests.MakeTestParaSimpleString(m_gm.VwGraphics, ParaBuilderTests.MockBreakOption.ThreeFullLines, out para);
            InsertionPoint ip   = root.SelectAtEnd();

            ip.Install();
            Assert.AreEqual(ip, root.Selection);
            Assert.AreEqual(para, ip.Para, "IP should know about the paragraph it is in");
            Assert.AreEqual(para.Source.Length, ip.StringPosition, "the IP should be at the end of the paragraph");
            Assert.AreEqual(true, ip.AssociatePrevious, "selection at end should always associate previous in non-empty para");


            StringBox third = para.FirstBox.Next.Next as StringBox;

            Assert.IsNotNull(third, "para with three simple lines should have three string boxes");
            MockSegment seg3 = third.Segment as MockSegment;

            Assert.IsNotNull(seg3);
            PaintTransform ptrans = new PaintTransform(2, 4, 96, 100, 0, -10, 120, 128);

            ip.Draw(m_gm.VwGraphics, ptrans);
            StringBox first  = para.FirstBox as StringBox;
            StringBox second = para.FirstBox.Next as StringBox;
            // All three segments should be invited to draw it, though only one will.
            var seg1 = first.Segment as MockSegment;

            VerifySegmentDrawing(para, first, seg1, -4);
            var seg2 = second.Segment as MockSegment;

            VerifySegmentDrawing(para, second, seg2, -14);
            VerifySegmentDrawing(para, third, seg3, -24);

            seg1.NextPosIpResult             = new MockSegment.PositionsOfIpResults();
            seg1.NextPosIpResult.PrimaryHere = false;
            seg2.NextPosIpResult             = new MockSegment.PositionsOfIpResults();
            seg2.NextPosIpResult.PrimaryHere = false;
            seg3.NextPosIpResult             = new MockSegment.PositionsOfIpResults();
            seg3.NextPosIpResult.RectPrimary = new Rect(5, 6, 7, 9);
            seg3.NextPosIpResult.PrimaryHere = true;
            Rectangle selRect = ip.GetSelectionLocation(m_gm.VwGraphics, ptrans);

            // All three should be asked for the position, though only the third returns a useful one.
            VerifySelLocation(para, first, seg1, -4);
            VerifySelLocation(para, second, seg2, -14);
            VerifySelLocation(para, third, seg3, -24);
            Assert.AreEqual(new Rectangle(5, 6, 2, 3), selRect);

            // The final thing that goes into drawing IPs is the Invalidate call.
            MockSite site = new MockSite();

            site.m_transform  = ptrans;
            site.m_vwGraphics = m_gm.VwGraphics;
            root.Site         = site;
            ip.Invalidate();
            Assert.IsNotNull(site.GraphicsHolder, "Invalidate should have created a Graphics holder");
            Assert.IsTrue(site.GraphicsHolder.WasDisposed, "invalidate should have disposed of the Graphics Holder");
            Assert.AreEqual(1, site.RectsInvalidated.Count, "invalidate should have invalidated one rectangle");
            Assert.AreEqual(new Rectangle(5, 6, 2, 3), site.RectsInvalidated[0], "invalidate should have invalidated the selection rectangle");
        }
Beispiel #5
0
        internal override void InsertText(InsertionPoint ip, string input)
        {
            string oldValue = ((StringClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Contents;
            string newValue = oldValue.Insert(ip.StringPosition, input);

            Writer(newValue);
        }
Beispiel #6
0
        /// <summary>
        /// Get the location of the primary insertion point.
        /// Review JohnT: is it possible that more than one segment contains this, and we need to combine them?
        /// Or that none does?
        /// </summary>
        public Rectangle GetIpLocation(InsertionPoint ip, IVwGraphics vg, PaintTransform ptrans)
        {
            PaintTransform childTrans = ChildTransformFromRootTransform(ptrans);
            int            ichMin     = ip.RenderParaPosition;
            int            ichLim     = ip.LastRenderParaPosition;

            if (ichLim > ichMin)
            {
                // Displaying a substitute string.
                var  bounds = new Rect();
                bool first  = true;
                DoRangePaintingOp(ichMin, ichLim, vg, childTrans, (box, vg1, childTrans1, top, bottom, ichMin1, ichLim1) =>
                                  { first = GetRangeLocationInBox(box, vg1, childTrans1, top, bottom, ichMin1, ichLim1, first, ref bounds); });
                return(new Rectangle(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top));
            }
            for (Box current = FirstBox; current != null; current = current.Next)
            {
                var sb = current as StringBox;
                if (sb == null)
                {
                    continue;
                }
                bool      fLocHere;
                Rectangle temp = sb.GetIpLocation(ip, vg, childTrans, out fLocHere);
                if (fLocHere)
                {
                    return(temp);
                }
            }
            throw new ApplicationException("No paragraph segment has the location of the primary IP");
        }
Beispiel #7
0
        public void MakeSimpleRange()
        {
            ParaBox        para;
            RootBox        root  = ParaBuilderTests.MakeTestParaSimpleString(m_gm.VwGraphics, ParaBuilderTests.MockBreakOption.ThreeFullLines, out para);
            InsertionPoint ip    = root.SelectAtEnd();
            InsertionPoint ip2   = new InsertionPoint(ip.Hookup, ip.StringPosition - 2, false);
            RangeSelection range = new RangeSelection(ip, ip2);

            Assert.AreEqual(ip, range.Anchor);
            Assert.AreEqual(ip2, range.DragEnd);
            Assert.That(range.EndBeforeAnchor, Is.True);
            Assert.That(range.Start, Is.EqualTo(ip2));
            Assert.That(range.End, Is.EqualTo(ip));
            StringBox   first  = para.FirstBox as StringBox;
            StringBox   second = para.FirstBox.Next as StringBox;
            StringBox   third  = second.Next as StringBox;
            MockSegment seg3   = third.Segment as MockSegment;

            seg3.DrawRangeLeft  = 17;
            seg3.DrawRangeRight = 23;

            PaintTransform ptrans = new PaintTransform(2, 4, 96, 100, 0, 10, 120, 128);

            range.Draw(m_gm.VwGraphics, ptrans);

            // All three segments should be invited to draw it, though only one will.
            // The top of rsSrc gets more negative each line; the destination rectangle where we actually draw keeps getting lower.
            // Remember the effect of 10 pixels of scroll offset.
            VerifyRangeSegmentDrawing(para, first, first.Segment as MockSegment, range, -4, -6, 4);
            VerifyRangeSegmentDrawing(para, second, second.Segment as MockSegment, range, -14, 4, 14);
            VerifyRangeSegmentDrawing(para, third, seg3, range, -24, 14, 24);
        }
        static void CheckStartPoint(TextDocument doc, InsertionPoint point, bool isEndPoint)
        {
            DocumentLine line = doc.GetLine(point.Location.Line);

            if (line == null)
            {
                return;
            }
            if (doc.GetLineIndent(line).Length + 1 == point.Location.Column)
            {
                int lineNr = point.Location.Line;
                while (lineNr > 1 && doc.GetLineIndent(lineNr - 1).Length == doc.GetLine(lineNr - 1).Length)
                {
                    lineNr--;
                }
                line           = doc.GetLine(lineNr);
                point.Location = new DocumentLocation(lineNr, doc.GetLineIndent(line).Length + 1);
            }

            if (doc.GetLineIndent(line).Length + 1 < point.Location.Column)
            {
                point.LineBefore = NewLineInsertion.Eol;
            }
            if (point.Location.Column < line.Length + 1)
            {
                point.LineAfter = isEndPoint ? NewLineInsertion.Eol : NewLineInsertion.BlankLine;
            }
        }
Beispiel #9
0
        protected override async Task <InsertionPoint> GetInsertionPointAsync(SemanticDocument document, int position, CancellationToken cancellationToken)
        {
            Contract.ThrowIfFalse(position >= 0);

            var root = await document.Document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var basePosition = root.FindToken(position);

            var memberNode = basePosition.GetAncestor <MemberDeclarationSyntax>();

            Contract.ThrowIfNull(memberNode);
            Contract.ThrowIfTrue(memberNode.Kind() == SyntaxKind.NamespaceDeclaration);

            if (memberNode is GlobalStatementSyntax globalStatement)
            {
                // check whether we are extracting whole global statement out
                if (this.OriginalSelectionResult.FinalSpan.Contains(memberNode.Span))
                {
                    return(await InsertionPoint.CreateAsync(document, globalStatement.Parent, cancellationToken).ConfigureAwait(false));
                }

                return(await InsertionPoint.CreateAsync(document, globalStatement.Statement, cancellationToken).ConfigureAwait(false));
            }

            return(await InsertionPoint.CreateAsync(document, memberNode, cancellationToken).ConfigureAwait(false));
        }
 public ExpressionCodeGenerator(
     InsertionPoint insertionPoint,
     SelectionResult selectionResult,
     AnalyzerResult analyzerResult) :
     base(insertionPoint, selectionResult, analyzerResult)
 {
 }
Beispiel #11
0
            private static CSharpCodeGenerator Create(
                InsertionPoint insertionPoint,
                SelectionResult selectionResult,
                AnalyzerResult analyzerResult,
                CSharpCodeGenerationOptions options,
                NamingStylePreferencesProvider namingPreferences,
                bool localFunction)
            {
                if (ExpressionCodeGenerator.IsExtractMethodOnExpression(selectionResult))
                {
                    return(new ExpressionCodeGenerator(insertionPoint, selectionResult, analyzerResult, options, namingPreferences, localFunction));
                }

                if (SingleStatementCodeGenerator.IsExtractMethodOnSingleStatement(selectionResult))
                {
                    return(new SingleStatementCodeGenerator(insertionPoint, selectionResult, analyzerResult, options, namingPreferences, localFunction));
                }

                if (MultipleStatementsCodeGenerator.IsExtractMethodOnMultipleStatements(selectionResult))
                {
                    return(new MultipleStatementsCodeGenerator(insertionPoint, selectionResult, analyzerResult, options, namingPreferences, localFunction));
                }

                throw ExceptionUtilities.UnexpectedValue(selectionResult);
            }
 public MultipleStatementsCodeGenerator(
     InsertionPoint insertionPoint,
     SelectionResult selectionResult,
     AnalyzerResult analyzerResult) :
     base(insertionPoint, selectionResult, analyzerResult)
 {
 }
Beispiel #13
0
        /// <summary>
        /// 在指定位置上使用输入的二维数组插入图表
        /// </summary>
        /// <param name="type">插入的方式 (文件开始或文件结束位置)</param>
        /// <param name="value">二维数组</param>
        /// <param name="chartType">图表类型</param>
        /// <param name="rowHeader">行标题(null表示显示index值)</param>
        /// <param name="colHeader">列标题 (null表示显示Column1, Column2值)</param>
        public void InsertGraph(InsertionPoint type, double[,] value, WordChartStyle chartType = null, string[] rowHeader = null, string[] colHeader = null)
        {
            try
            {
                Word.Range     r = GetRange(type);
                dynamic        oShape;
                WordChartStyle style = chartType == null ? _chartStyle : chartType;
                if (_version > 12.0)
                {
                    oShape = _wordShapes.AddChart2(-1, (XlChartType)style.ChartStyle, r);
                }
                else
                {
                    oShape = _wordShapes.AddChart((XlChartType)style.ChartStyle, r);
                }

                //Demonstrate use of late bound oChart and oChartApp objects to
                //manipulate the chart object with MSGraph.
                Word.Chart oChart = oShape.Chart;

                //object oChartApp = oChart.Application;

                ArrayDataToGraphData(value, oChart, rowHeader, colHeader, style.FirstColumnAsXAxis);
            }
            catch (Exception ex)
            {
                ErrorParser(ex);
                return;
            }
        }
Beispiel #14
0
 /// <summary>
 /// 在指定位置上插入表格
 /// </summary>
 /// <param name="type">插入类型</param>
 /// <param name="value">二维字符串数组</param>
 /// <param name="wordStyle">文字外观</param>
 public void WriteTableToDoc <T>(InsertionPoint type, T[,] value, WordTableStyle wordStyle = WordTableStyle.LightGrid)
 {
     try
     {
         int        rowCount = value.GetLength(0);
         int        colCount = value.GetLength(1);
         Word.Range r        = GetRange(type);
         Word.Table tab      = _wordTables.Add(r, rowCount, colCount);
         tab.set_Style(wordStyle);
         tab.Select();
         for (int i = 0; i < rowCount; i++)
         {
             for (int j = 0; j < colCount; j++)
             {
                 tab.Cell(i + 1, j + 1).Select();
                 _engine.Selection.TypeText(value[i, j].ToString());
             }
         }
     }
     catch (Exception ex)
     {
         ErrorParser(ex);
         return;
     }
 }
Beispiel #15
0
 public VariableToDeclare(ILVariable variable, bool defaultInitialization, InsertionPoint insertionPoint, int sourceOrder)
 {
     this.ILVariable            = variable;
     this.DefaultInitialization = defaultInitialization;
     this.InsertionPoint        = insertionPoint;
     this.SourceOrder           = sourceOrder;
 }
Beispiel #16
0
        internal override void InsertText(InsertionPoint ip, ITsString input)
        {
            var bldr = ((TssClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Tss.GetBldr();

            bldr.ReplaceTsString(ip.StringPosition, ip.StringPosition, input);
            MultiAccessor.set_String(m_ws, bldr.GetString());
        }
 public SingleStatementCodeGenerator(
     InsertionPoint insertionPoint,
     SelectionResult selectionResult,
     AnalyzerResult analyzerResult,
     bool localFunction)
     : base(insertionPoint, selectionResult, analyzerResult, localFunction)
 {
 }
Beispiel #18
0
        /// <summary>
        /// Insert a new paragraph, after the user types Enter, where the previous selection
        /// is an insertion point at the end of the paragraph.
        /// </summary>
        public virtual bool InsertFollowingParagraph(InsertionPoint ip, out Action makeSelection)
        {
            int index = ItemIndex(ip) + 1;

            MakeListItem(index, false);
            makeSelection = () => SelectionBuilder.In(Hookup)[index].Offset(0).Install();
            return(true);
        }
 public VariableToDeclare(IType type, string name, bool defaultInitialization, InsertionPoint insertionPoint, int sourceOrder)
 {
     this.Type = type;
     this.Name = name;
     this.DefaultInitialization = defaultInitialization;
     this.InsertionPoint        = insertionPoint;
     this.SourceOrder           = sourceOrder;
 }
Beispiel #20
0
        public Rectangle GetRect()
        {
            InsertionPoint ip = this.lastInsertionPoint;

            Rectangle rect = ip.Rectangles.Add(miss, idLocationOptions.idAtEnd, miss);

            return(rect);
        }
Beispiel #21
0
        internal override void Delete(InsertionPoint start, InsertionPoint end)
        {
            var bldr   = ((TssClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Tss.GetBldr();
            int newPos = start.StringPosition;

            bldr.Replace(newPos, end.StringPosition, "", null);
            Writer(bldr.GetString());
        }
Beispiel #22
0
 public VariableToDeclare(ILVariable variable, bool defaultInitialization, InsertionPoint insertionPoint, IdentifierExpression firstUse, int sourceOrder)
 {
     this.ILVariable            = variable;
     this.DefaultInitialization = defaultInitialization;
     this.InsertionPoint        = insertionPoint;
     this.FirstUse    = firstUse;
     this.SourceOrder = sourceOrder;
 }
Beispiel #23
0
 public ExpressionCodeGenerator(
     InsertionPoint insertionPoint,
     SelectionResult selectionResult,
     AnalyzerResult analyzerResult,
     bool localFunction)
     : base(insertionPoint, selectionResult, analyzerResult, localFunction)
 {
 }
 public static Task<GeneratedCode> GenerateAsync(
     InsertionPoint insertionPoint,
     SelectionResult selectionResult,
     AnalyzerResult analyzerResult,
     CancellationToken cancellationToken)
 {
     var codeGenerator = Create(insertionPoint, selectionResult, analyzerResult);
     return codeGenerator.GenerateAsync(cancellationToken);
 }
 /// <summary>
 /// Initialize a new instance of the <see cref="ConfigurationUICommand"/> class.
 /// </summary>
 /// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
 /// <param name="text">The text for the command.</param>
 /// <param name="longText">The text that will be in the status bar.</param>
 /// <param name="commandState">One of the <see cref="CommandState"/> values.</param>
 /// <param name="command">The command to execute.</param>
 /// <param name="shortcut">A short cut for the command.</param>
 /// <param name="insertionPoint">One of the <see cref="InsertionPoint"/> values.</param>
 /// <param name="icon">The icon for the command.</param>
 public ConfigurationUICommand(IServiceProvider serviceProvider, string text,
                               string longText, CommandState commandState,
                               ConfigurationNodeCommand command, Shortcut shortcut,
                               InsertionPoint insertionPoint, Icon icon)
     : this(serviceProvider,
            text, longText, commandState, NodeMultiplicity.Allow, command, null,
            shortcut, insertionPoint, icon)
 {
 }
		/// <summary>
		/// Initialize a new instance of the <see cref="ConfigurationUICommand"/> class.
		/// </summary>		
		/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
		/// <param name="text">The text for the command.</param>
		/// <param name="longText">The text that will be in the status bar.</param>
		/// <param name="commandState">One of the <see cref="CommandState"/> values.</param>		
		/// <param name="command">The command to execute.</param>		
		/// <param name="shortcut">A short cut for the command.</param>
		/// <param name="insertionPoint">One of the <see cref="InsertionPoint"/> values.</param>
		/// <param name="icon">The icon for the command.</param>
		public ConfigurationUICommand(IServiceProvider serviceProvider, string text,
			string longText, CommandState commandState,
			ConfigurationNodeCommand command, Shortcut shortcut,
			InsertionPoint insertionPoint, Icon icon) 
			: this(serviceProvider,
			text, longText, commandState, NodeMultiplicity.Allow, command, null,
			shortcut, insertionPoint, icon)
		{			
		}
		string CreateInsertionPoint (string input, string text, NewLineInsertion before, NewLineInsertion after)
		{
			int idx = input.IndexOf ('$');
			Assert.Greater (idx, -1);
			TextEditorData data = new TextEditorData (new TextDocument (input.Substring (0, idx) + input.Substring (idx + 1)));
			InsertionPoint point = new InsertionPoint (data.Document.OffsetToLocation (idx), before, after);
			point.Insert (data, text);
			return data.Document.Text;
		}
Beispiel #28
0
 public MultipleStatementsCodeGenerator(
     InsertionPoint insertionPoint,
     SelectionResult selectionResult,
     AnalyzerResult analyzerResult,
     OptionSet options,
     bool localFunction)
     : base(insertionPoint, selectionResult, analyzerResult, options, localFunction)
 {
 }
Beispiel #29
0
        public virtual bool InsertPrecedingParagraph(InsertionPoint ip, out Action makeSelection)
        {
            int index = ItemIndex(ip);

            MakeListItem(index, true);
            // The selection is still at the start of the original paragraph. No makeSelection action is needed.
            makeSelection = () => DoNothing();
            return(true);
        }
Beispiel #30
0
        protected override async Task <InsertionPoint> GetInsertionPointAsync(SemanticDocument document, CancellationToken cancellationToken)
        {
            var originalSpanStart = OriginalSelectionResult.OriginalSpan.Start;

            Contract.ThrowIfFalse(originalSpanStart >= 0);

            var root = await document.Document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            var basePosition = root.FindToken(originalSpanStart);

            if (LocalFunction)
            {
                // If we are extracting a local function and are within a local function, then we want the new function to be created within the
                // existing local function instead of the overarching method.
                var localFunctionNode = basePosition.GetAncestor <LocalFunctionStatementSyntax>(node => (node.Body != null && node.Body.Span.Contains(OriginalSelectionResult.OriginalSpan)) ||
                                                                                                (node.ExpressionBody != null && node.ExpressionBody.Span.Contains(OriginalSelectionResult.OriginalSpan)));
                if (localFunctionNode is object)
                {
                    return(await InsertionPoint.CreateAsync(document, localFunctionNode, cancellationToken).ConfigureAwait(false));
                }
            }

            var memberNode = basePosition.GetAncestor <MemberDeclarationSyntax>();

            Contract.ThrowIfNull(memberNode);
            Contract.ThrowIfTrue(memberNode.Kind() == SyntaxKind.NamespaceDeclaration);

            if (LocalFunction && memberNode is BasePropertyDeclarationSyntax propertyDeclaration)
            {
                var accessorNode = basePosition.GetAncestor <AccessorDeclarationSyntax>();
                if (accessorNode is object)
                {
                    return(await InsertionPoint.CreateAsync(document, accessorNode, cancellationToken).ConfigureAwait(false));
                }
            }

            if (memberNode is GlobalStatementSyntax globalStatement)
            {
                // check whether we are extracting whole global statement out
                if (OriginalSelectionResult.FinalSpan.Contains(memberNode.Span))
                {
                    return(await InsertionPoint.CreateAsync(document, globalStatement.Parent, cancellationToken).ConfigureAwait(false));
                }

                // check whether the global statement is a statement container
                if (!globalStatement.Statement.IsStatementContainerNode() && !root.SyntaxTree.IsScript())
                {
                    // The extracted function will be a new global statement
                    return(await InsertionPoint.CreateAsync(document, globalStatement.Parent, cancellationToken).ConfigureAwait(false));
                }

                return(await InsertionPoint.CreateAsync(document, globalStatement.Statement, cancellationToken).ConfigureAwait(false));
            }

            return(await InsertionPoint.CreateAsync(document, memberNode, cancellationToken).ConfigureAwait(false));
        }
Beispiel #31
0
            public static async Task <GeneratedCode> GenerateAsync(
                InsertionPoint insertionPoint,
                SelectionResult selectionResult,
                AnalyzerResult analyzerResult,
                CancellationToken cancellationToken)
            {
                var codeGenerator = Create(insertionPoint, selectionResult, analyzerResult);

                return(await codeGenerator.GenerateAsync(cancellationToken).ConfigureAwait(false));
            }
Beispiel #32
0
 internal override void Delete(InsertionPoint start, InsertionPoint end)
 {
     if (CanDelete(start, end))
     {
         string oldValue = ((StringClientRun)ParaBox.Source.ClientRuns[ClientRunIndex]).Contents;
         int    newPos   = start.StringPosition;
         string newValue = oldValue.Remove(newPos, end.StringPosition - newPos);
         Writer(newValue);
     }
 }
		string CreateInsertionPoint (string input, string text, NewLineInsertion before, NewLineInsertion after)
		{
			int idx = input.IndexOf ('$');
			Assert.Greater (idx, -1);
			TextEditor editor = new TextEditor ();
			editor.Document.Text = input.Substring (0, idx) + input.Substring (idx + 1);
			InsertionPoint point = new InsertionPoint (editor.Document.OffsetToLocation (idx), before, after);
			Console.WriteLine (point);
			point.Insert (editor, text);
			return editor.Document.Text;
			
		}
 /// <summary>
 /// <para>Initializes a new instance of the class with a specified caption, event handler, associated shortcut key, icon, status bar text, and the insertion point for the menu item.</para>
 /// </summary>
 /// <param name="text">
 /// <para>The caption for the menu item.</para>
 /// </param>
 /// <param name="command">
 /// <para>The <see cref="ConfigurationNodeCommand"/> to execute.</para>
 /// </param>
 /// <param name="node">
 /// <para>The <see cref="ConfigurationNode"/> to execute the command upon.</para>
 /// </param>
 /// <param name="shortcut">
 /// <para>One of the <see cref="Shortcut"/> values.</para>
 /// </param>
 /// <param name="statusBarText">
 /// <para>The text for the status bar.</para>
 /// </param>
 /// <param name="insertionPoint">
 /// <para>One of the <see cref="InsertionPoint"/> values.</para>
 /// </param>
 public ConfigurationMenuItem(string text, ConfigurationNodeCommand command, ConfigurationNode node, Shortcut shortcut, string statusBarText, InsertionPoint insertionPoint)
     : base(text, null, shortcut)
 {
     if (command == null)
     {
         throw new ArgumentNullException("command");
     }
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     this.statusBarText = statusBarText;
     this.insertionPoint = insertionPoint;
     this.command = command;
     this.node = node;
 }
		/// <summary>
		/// Initialize a new instance of the <see cref="ConfigurationUICommand"/> class.
		/// </summary>		
		/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
		/// <param name="text">The text for the command.</param>
		/// <param name="longText">The text that will be in the status bar.</param>
		/// <param name="commandState">One of the <see cref="CommandState"/> values.</param>		
		/// <param name="multiplicity">One of the <see cref="NodeMultiplicity"/> values.</param>
		/// <param name="command">The command to execute.</param>		
		/// <param name="nodeType">The node type that will be created when the command is executed.</param>
		/// <param name="shortcut">A short cut for the command.</param>
		/// <param name="insertionPoint">One of the <see cref="InsertionPoint"/> values.</param>
		/// <param name="icon">The icon for the command.</param>
		public ConfigurationUICommand(IServiceProvider serviceProvider, string text,
			string longText, CommandState commandState, NodeMultiplicity multiplicity,
			ConfigurationNodeCommand command, Type nodeType, Shortcut shortcut, 
			InsertionPoint insertionPoint, Icon icon)
		{
			this.text = text;
			this.longText = longText;
			this.commandState = commandState;
			this.command = command;
			this.nodeType = nodeType;
			this.insertionPoint = insertionPoint;
			this.shortcut = shortcut;
			this.icon = icon;
			this.serviceProvider = serviceProvider;
			this.multiplicity = multiplicity;
		}
Beispiel #36
0
 /// <summary>Moves this block to the specified insertion point on the target block.</summary>
 public ScriptBlock MoveTo(ScriptBlock target, InsertionPoint insertionPoint) {
    var sourceIndex = this.Index;
    var sourceParent = this.ParentBlock;
    var targetIndex = target.Index;
    var targetParent = target.ParentBlock;
    Remove();
    if (sourceParent == targetParent && targetParent != null) {
       // adjust for move in same parent
       if (targetIndex >= sourceIndex) targetIndex--;
    }
    switch (insertionPoint) {
       case InsertionPoint.Before:
          if (targetParent != null && targetIndex >= 0) {
             targetParent.Items.Insert(targetIndex, this);
             targetParent._raiseScriptChangedEvent();
          }
          break;
       case InsertionPoint.After:
          if (targetParent != null && targetIndex >= 0) {
             targetParent.Items.Insert(targetIndex + 1, this);
             targetParent._raiseScriptChangedEvent();
          }
          break;
       case InsertionPoint.Inside:
          target.Items.Add(this);
          target._raiseScriptChangedEvent();
          break;
    }
    return this;
 }
Beispiel #37
0
 /// <summary>Copies this block to the specified insertion point on the target block.</summary>
 public ScriptBlock CopyTo(ScriptBlock target, InsertionPoint insertionPoint) {
    var clonedBlock = Clone(true);
    if (clonedBlock != null) {
       clonedBlock.MoveTo(target, insertionPoint);
    }
    return clonedBlock;
 }
Beispiel #38
0
 public void UpdateInsertionPoint(DragEventArgs e) {
    InsertionPoint = Target._computeInsertionPoint(e);
    InvalidateVisual();
 }