/// <summary>
        /// Sets new values to this cursor pos
        /// </summary>
        /// <returns>true, when values where other than before</returns>
        public bool SetPos(System.Xml.XmlNode actualNode, XmlCursorPositions posAtNode, int posInTextNode = 0)
        {
            bool changed;

            if (actualNode != this.ActualNode)
            {
                changed = true;
            }
            else
            {
                if (posAtNode != this.PosOnNode)
                {
                    changed = true;
                }
                else
                {
                    if (posInTextNode != this.PosInTextNode)
                    {
                        changed = true;
                    }
                    else
                    {
                        changed = false;
                    }
                }
            }
            this.ActualNode    = actualNode;
            this.PosOnNode     = posAtNode;
            this.PosInTextNode = posInTextNode;
            return(changed);
        }
Beispiel #2
0
 public async Task SetPositions(XmlNode bothNodes, XmlCursorPositions posAtBothNodes, int textPosInBothNodes, bool throwChangedEventWhenValuesChanged)
 {
     await this.SetPositions(
         bothNodes, posAtBothNodes, textPosInBothNodes,
         bothNodes, posAtBothNodes, textPosInBothNodes,
         throwChangedEventWhenValuesChanged);
 }
Beispiel #3
0
        /// <summary>
        /// Sets node and position simultaneously and thus triggers only one Changed-Event instead of two
        /// </summary>
        public async Task SetBothPositionsAndFireChangedEventIfChanged(XmlNode node, XmlCursorPositions posOnNode, int posInTextnode)
        {
            bool changed =
                node != StartPos.ActualNode || posOnNode != StartPos.PosOnNode || posInTextnode != StartPos.PosInTextNode ||
                node != EndPos.ActualNode || posOnNode != EndPos.PosOnNode || posInTextnode != EndPos.PosInTextNode;

            this.SetBotPositionsWithoutChangedEvent(node, posOnNode, posInTextnode);
            if (changed)
            {
                await this.ChangedEvent.Trigger(EventArgs.Empty);
            }
        }
Beispiel #4
0
        public async Task SetPositions(
            XmlNode startNode, XmlCursorPositions posAtStartNode, int textPosInStartNode,
            XmlNode endNode, XmlCursorPositions posAtEndNode, int textPosInEndNode, bool throwChangedEventWhenValuesChanged)
        {
            var changed = false;

            if (throwChangedEventWhenValuesChanged)
            {
                changed = (startNode != this.StartPos.ActualNode || posAtStartNode != this.StartPos.PosOnNode || textPosInStartNode != this.StartPos.PosInTextNode ||
                           endNode != this.EndPos.ActualNode || posAtEndNode != this.EndPos.PosOnNode || textPosInEndNode != this.EndPos.PosInTextNode);
            }
            this.StartPos.SetPos(startNode, posAtStartNode, textPosInStartNode);
            this.EndPos.SetPos(endNode, posAtEndNode, textPosInEndNode);
            if (changed)
            {
                await ChangedEvent.Trigger(EventArgs.Empty);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Sets the cursor positions for corresponding mouse actions: For MouseDown StartAndEndpos, for Move and Up only the endpos
        /// </summary>
        public async Task SetCursorByMouseAction(XmlNode xmlNode, XmlCursorPositions cursorPos, int posInLine, MouseClickActions action)
        {
            switch (action)
            {
            case MouseClickActions.MouseDown:
                // move the cursor to the new position
                await SetPositions(xmlNode, cursorPos, posInLine, throwChangedEventWhenValuesChanged : true);

                break;

            case MouseClickActions.MouseDownMove:
            case MouseClickActions.MouseUp:
                // Set end of the select cursor
                if (EndPos.SetPos(xmlNode, cursorPos, posInLine))
                {
                    await this.ForceChangedEvent();
                }
                break;
            }
        }
Beispiel #6
0
 public void SetBotPositionsWithoutChangedEvent(XmlNode node, XmlCursorPositions posAmNode, int posImTextnode)
 {
     this.StartPos.SetPos(node, posAmNode, posImTextnode);
     this.EndPos.SetPos(node, posAmNode, posImTextnode);
 }
Beispiel #7
0
 /// <summary>
 /// Sets the cursor positions for corresponding mouse actions: For MausDown StartUndEndpos, for Move and Up only the endpos
 /// </summary>
 public async Task SetCursorByMouseAction(XmlNode xmlNode, XmlCursorPositions cursorPos, MouseClickActions action)
 {
     await SetCursorByMouseAction(xmlNode, cursorPos, 0, action);
 }
Beispiel #8
0
 /// <summary>
 /// Sets node and position simultaneously and thus triggers only one Changed-Event instead of two
 /// </summary>
 public async Task SetBothPositionsAndFireChangedEventIfChanged(XmlNode node, XmlCursorPositions posAmNode)
 {
     await SetBothPositionsAndFireChangedEventIfChanged(node, posAmNode, 0);
 }
 public XmlCursorPos()
 {
     this.ActualNode    = null; // no node selected
     this.PosOnNode     = XmlCursorPositions.CursorOnNodeStartTag;
     this.PosInTextNode = 0;
 }