示例#1
0
        private void richEditControl1_MouseClick(object sender, MouseEventArgs e)
        {
            PageLayoutPosition pageLayoutPosition = richEditControl1.ActiveView.GetDocumentLayoutPosition(e.Location);

            if (pageLayoutPosition == null)
            {
                return;
            }
            int                   pageIndex  = pageLayoutPosition.PageIndex;
            Point                 point      = pageLayoutPosition.Position;
            LayoutPage            layoutPage = richEditControl1.DocumentLayout.GetPage(pageIndex);
            HitTestManager        hitTest    = new HitTestManager(richEditControl1.DocumentLayout);
            RichEditHitTestResult result     = hitTest.HitTest(layoutPage, point);

            if (result.LayoutElement is CharacterBox && richEditControl1.Document.Selection.Length == 0)
            {
                CharacterBox     character     = (CharacterBox)result.LayoutElement;
                DocumentPosition caretPosition = richEditControl1.Document.CaretPosition;
                SubDocument      document      = caretPosition.BeginUpdateDocument();
                if (document.GetSubDocumentType() == GetLocation(character.Parent))
                {
                    DocumentRange characterRange = document.CreateRange(character.Range.Start, 1);
                    UpdateCheckState(document, characterRange, character.Text);
                }
                caretPosition.EndUpdateDocument(document);
            }
        }
        void ToolTipController_GetActiveObjectInfo(object sender, ToolTipControllerGetActiveObjectInfoEventArgs e)
        {
            #region #HitTest
            if (!e.SelectedControl.Equals(richEditControl1))
            {
                return;
            }

            //Obtain the mouse cursor's layout position on the page and the current page index:
            PageLayoutPosition pageLayoutPosition = richEditControl1.ActiveView.GetDocumentLayoutPosition(e.ControlMousePosition);
            if (pageLayoutPosition == null)
            {
                return;
            }

            Point      point      = pageLayoutPosition.Position;
            int        pageIndex  = pageLayoutPosition.PageIndex;
            LayoutPage layoutPage = richEditControl1.DocumentLayout.GetPage(pageIndex);

            //Create a HitTestManager instance:
            HitTestManager hitTest = new HitTestManager(richEditControl1.DocumentLayout);

            //Perform the hit test and pass the result to the RichEditHitTestResult object:
            RichEditHitTestResult result = hitTest.HitTest(layoutPage, point);
            if (result != null)
            {
                //Retrieve the current layout element type:
                LayoutElement element = result.LayoutElement;
                string        text    = element.Type.ToString();

                //Obtain the the text character and its bounds under the mouse position
                if (element.Type == LayoutType.CharacterBox)
                {
                    text += String.Format(" : \"{0}\"", (element as CharacterBox).Text);
                    text += GetBounds(element);
                    if (element.Parent.Type == LayoutType.PlainTextBox)
                    {
                        text += String.Format("\r\nPlainTextBox : \"{0}\"", (element.Parent as PlainTextBox).Text);
                        text += GetBounds(element.Parent);
                    }
                }
                else
                {
                    //Get the hovered element's bounds:
                    text += GetBounds(element);
                }

                //Get the element's location:
                string title = GetLocation(element);

                //Display all retrieved information in the tooltip:
                e.Info = new ToolTipControlInfo(element.Bounds, text, title, ToolTipIconType.Information);
            }
            #endregion #HitTest
        }
        private void RichEditControl_MouseMove(object sender, MouseEventArgs e)
        {
            #region #HitTest
            //Obtain the mouse cursor's layout position on the page and the current page index:
            Point wPoint = e.GetPosition(richEditControl1);

            PageLayoutPosition pageLayoutPosition = richEditControl1.ActiveView.GetDocumentLayoutPosition
                                                        (new System.Drawing.Point((int)wPoint.X, (int)wPoint.Y));
            if (pageLayoutPosition == null)
            {
                return;
            }

            System.Drawing.Point point = pageLayoutPosition.Position;
            int        pageIndex       = pageLayoutPosition.PageIndex;
            LayoutPage layoutPage      = richEditControl1.DocumentLayout.GetPage(pageIndex);

            //Create a HitTestManager instance:
            HitTestManager hitTest = new HitTestManager(richEditControl1.DocumentLayout);

            //Perform the hit test and pass the result to the RichEditHitTestResult object:
            RichEditHitTestResult result = hitTest.HitTest(layoutPage, point);
            if (result != null)
            {
                //Retrieve the current layout element type:
                LayoutElement element = result.LayoutElement;
                string        text    = element.Type.ToString();

                //Obtain the the text character and its bounds under the mouse position
                if (element.Type == LayoutType.CharacterBox)
                {
                    text += String.Format(" : \"{0}\"", (element as CharacterBox).Text);
                    text += GetBounds(element);
                    if (element.Parent.Type == LayoutType.PlainTextBox)
                    {
                        text += String.Format("\r\nPlainTextBox : \"{0}\"", (element.Parent as PlainTextBox).Text);
                        text += GetBounds(element.Parent);
                    }
                }
                else
                {
                    //Get the hovered element's bounds:
                    text += GetBounds(element);
                }

                //Get the element's location:
                string title = GetLocation(element);

                //Display all retrieved information in the tooltip:
                toolTip.IsOpen  = true;
                toolTip.Content = text + "\r\n" + title;
            }
            #endregion #HitTest
        }
示例#4
0
        public static List <GameTrigger> ConvertTriggers(List <LineTrigger> triggers, Track track)
        {
            List <GameTrigger> gametriggers = new List <GameTrigger>();
            const int          minute       = 40 * 60;
            int         lasthit             = 0;
            var         rider         = track.GetStart();
            var         hittest       = new HitTestManager();
            int         i             = 1;
            int         hitframe      = -1;
            LineTrigger activetrigger = null;
            float       zoom          = track.StartZoom;
            GameTrigger newtrigger    = null;

            do
            {
                var collisions = new LinkedList <int>();
                rider = rider.Simulate(
                    track.Grid,
                    track.Bones,
                    collisions);
                hittest.AddFrame(collisions);
                LineTrigger hittrigger = null;
                foreach (var lineid in collisions)
                {
                    foreach (var trigger in triggers)
                    {
                        if (trigger.LineID == lineid)
                        {
                            hittrigger = trigger;
                        }
                    }
                }
                if (hittrigger != null &&
                    hittrigger != activetrigger)
                {
                    if (activetrigger != null)
                    {
                        newtrigger.ZoomTarget = zoom;
                        newtrigger.End        = i;
                        gametriggers.Add(newtrigger);
                    }
                    hitframe      = i;
                    activetrigger = hittrigger;
                    newtrigger    = new GameTrigger()
                    {
                        TriggerType = TriggerType.Zoom, Start = i
                    };
                }
                if (activetrigger != null)
                {
                    var delta = i - hitframe;
                    if (!activetrigger.Activate(delta, ref zoom))
                    {
                        newtrigger.ZoomTarget = zoom;
                        newtrigger.End        = i;
                        gametriggers.Add(newtrigger);
                        activetrigger = null;
                    }
                }
                if (hittest.HasUniqueCollisions(i))
                {
                    lasthit = i;
                }
                i++;
            }while (i - lasthit < (minute * 2)); // be REALLY sure, 2 minutes.
            return(gametriggers);
        }