Beispiel #1
0
            public bool DoHitTest(float x, float y, HitTestType hitTestType)
            {
                if (MovieID == -1 || mRenderTexture == null)
                {
                    return(false);
                }

                // Adjust according to viewport
                if (mRenderTexture)
                {
                    RaycastHit hit;
                    if (Camera.main != null && Physics.Raycast(Camera.main.ScreenPointToRay(new Vector2(x, y)), out hit))
                    {
                        Renderer     hitRenderer  = hit.collider.renderer;
                        MeshCollider meshCollider = hit.collider as MeshCollider;
                        if (!(hit.collider is MeshCollider) || hitRenderer == null || meshCollider == null)
                        {
                            return(false);
                        }

                        if (hit.collider.gameObject.GetComponent("SFMovie") == null)
                        {
                            return(false);
                        }
                        return(true);
                    }
                    return(false);
                }

                return(SF_DoHitTest(MovieID, x, y, (int)hitTestType));
            }
Beispiel #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="table">DataSource's table</param>
        public DatabaseDataGrid(DataTable table)
        {
            this.BeginInit();
            this.SuspendLayout();

            tooltipSelectedRow    = -1;
            tooltipSelectedColumn = -1;
            selectedDataGridRow   = -1;

            selectedType = HitTestType.None;

            deletedRows = new ArrayList();

            // creates DataGridTableStyle.
            DataGridTableStyle tableStyle = new DataGridTableStyle();

            tableStyle.MappingName = table.TableName;

            // creates DataGridColumnStyles.
            foreach (DataColumn column in table.Columns)
            {
                InitDataTableColumnAndStyle(tableStyle, column);
            }

            // registers new DataGridTableStyle.
            TableStyles.Clear();
            TableStyles.Add(tableStyle);

            // bounds the DataSource.
            DataSource = table;

            tableStyle.AlternatingBackColor = System.Drawing.Color.White;

            tableStyle.BackColor = System.Drawing.Color.White;
            tableStyle.ForeColor = System.Drawing.Color.Black;

            tableStyle.GridLineColor = System.Drawing.Color.Silver;

            tableStyle.HeaderBackColor = System.Drawing.Color.DarkSlateBlue;
            tableStyle.HeaderFont      = new System.Drawing.Font("Tahoma", 8F);
            tableStyle.HeaderForeColor = System.Drawing.Color.White;

            tableStyle.LinkColor = System.Drawing.Color.Purple;

            tableStyle.SelectionBackColor = System.Drawing.Color.Beige;
            tableStyle.SelectionForeColor = System.Drawing.Color.Brown;

            // sets the tool tip.
            imageToolTip = new ToolTip();
            imageToolTip.SetToolTip(this, ImageToolTipText);
            imageToolTip.AutoPopDelay = ImageToolTipAutoPopDelay;

            this.EndInit();
            this.ResumeLayout(false);
        }
Beispiel #3
0
        /// <summary>
        /// Performs a custom hit testing lookup for the specified mouse event args.
        /// </summary>
        public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface,
                                                HitTestType hitTestType)
        {
            DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;

            HitTest(mousePosition, testAdorners, testDesignSurface,
                    delegate(DesignPanelHitTestResult r)
            {
                result = r;
                return(false);
            }, hitTestType);

            return(result);
        }
Beispiel #4
0
        HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget,
                                                             HitTestType hitTestType)
        {
            UIElement element = potentialHitTestTarget as UIElement;

            if (element != null)
            {
                if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible))
                {
                    return(HitTestFilterBehavior.ContinueSkipSelfAndChildren);
                }

                var designItem = Context.Services.Component.GetDesignItem(element) as XamlDesignItem;

                if (hitTestType == HitTestType.ElementSelection)
                {
                    if (Keyboard.IsKeyDown(Key.LeftAlt))
                    {
                        if (designItem != null)
                        {
                            if (skippedHitTestElements.LastOrDefault() == designItem ||
                                (hitTestElements.Contains(designItem) && !skippedHitTestElements.Contains(designItem)))
                            {
                                skippedHitTestElements.Remove(designItem);
                                return(HitTestFilterBehavior.ContinueSkipSelfAndChildren);
                            }
                        }
                    }
                }
                else
                {
                    hitTestElements.Clear();
                    skippedHitTestElements.Clear();
                }

                if (designItem != null && designItem.IsDesignTimeLocked)
                {
                    return(HitTestFilterBehavior.ContinueSkipSelfAndChildren);
                }

                if (designItem != null && !hitTestElements.Contains(designItem))
                {
                    hitTestElements.Add(designItem);
                    skippedHitTestElements.Add(designItem);
                }
            }

            return(HitTestFilterBehavior.Continue);
        }
Beispiel #5
0
    public Movie DoHitTestEx(HitTestType _hitTestType = HitTestType.HitTest_ShapesNoInvisible)
    {
        if (SFMgr == null)
        {
            return(null);
        }

        Vector2 MouseLastPos = GetMousePos();

        Movie mouseIsOverUIElement = SFMgr.DoHitTestEx(MouseLastPos.x, MouseLastPos.y, _hitTestType);

        if (null != mouseIsOverUIElement)
        {
            //UI选择屏蔽血条,飘字,头顶名,箭头
            long movieId = mouseIsOverUIElement.GetID();
            if (IgnoreHitTestMovieList.Contains(movieId))
            {
                return(null);
            }
        }

        return(mouseIsOverUIElement);
    }
Beispiel #6
0
        /// <summary>
        /// OnMouseDown
        /// </summary>
        /// <remarks>
        ///		if the RowHeader hitted - unselect previouslySelectedDataGridRow and selects the new one.
        /// </remarks>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // finds the point on the client side.
            HitTestInfo info = this.HitTest(e.X, e.Y);

            // saves the last selected type.
            selectedType = info.Type;

            if (info.Type == HitTestType.RowHeader)
            {
                if (selectedDataGridRow != -1)
                {
                    this.UnSelect(selectedDataGridRow);
                }

                selectedDataGridRow = info.Row;
                this.Select(selectedDataGridRow);
            }

            else
            {
                base.OnMouseDown(e);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
        /// Hit testing continues while the callback returns true.
        /// </summary>
        public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback, HitTestType hitTestType)
        {
            if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height) {
                return;
            }
            // First try hit-testing on the adorner layer.

            bool continueHitTest = true;

            HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? (x => FilterHitTestInvisibleElements(x, hitTestType));
            CustomHitTestFilterBehavior = null;

            if (testAdorners) {

                RunHitTest(
                    _adornerLayer, mousePosition, filterBehavior,
                    delegate(HitTestResult result) {
                        if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
                            DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
                            DependencyObject obj = result.VisualHit;
                            while (obj != null && obj != _adornerLayer) {
                                AdornerPanel adorner = obj as AdornerPanel;
                                if (adorner != null) {
                                    customResult.AdornerHit = adorner;
                                }
                                obj = VisualTreeHelper.GetParent(obj);
                            }
                            continueHitTest = callback(customResult);
                            return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
                        } else {
                            return HitTestResultBehavior.Continue;
                        }
                    });
            }

            if (continueHitTest && testDesignSurface) {
                RunHitTest(
                    this.Child, mousePosition, filterBehavior,
                    delegate(HitTestResult result) {
                        if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
                            DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);

                            ViewService viewService = _context.Services.View;
                            DependencyObject obj = result.VisualHit;

                            while (obj != null) {
                                if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
                                    break;
                                obj = VisualTreeHelper.GetParent(obj);
                            }
                            if (customResult.ModelHit == null) {
                                customResult.ModelHit = _context.RootItem;
                            }

                            continueHitTest = callback(customResult);
                            return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
                        } else {
                            return HitTestResultBehavior.Continue;
                        }
                    }
                );
            }
        }
Beispiel #8
0
        void DrawDropLine(Graphics g, int index, bool drawLine, HitTestType hit)
        {
            Brush brush = null;
            Pen pen = null;
            try
            {
                if (drawLine)
                {
                    droppedPosition = index;
                    lastDrawnLineIndex = index;
                    brush = SystemBrushes.ControlText;
                    pen = SystemPens.ControlText;
                }
                else
                {
                    // If there is nothing painted, no need to erase
                    if (lastDrawnLineIndex == -1)
                        return;

                    index = lastDrawnLineIndex;
                    brush = new SolidBrush(bands[currentBandIndex].Background);
                    pen = new Pen(bands[currentBandIndex].Background);
                    lastDrawnLineIndex = -1;
                }

                int itemsCount = bands[currentBandIndex].Items.Count;
                Rectangle itemRect = GetItemRect(g, bands[currentBandIndex], index, Rectangle.Empty);

                Rectangle viewPortRect = GetViewPortRect();
                int y;
                if (bands[currentBandIndex].IconView == IconView.Small)
                    y = itemRect.Top - Y_SMALLICON_SPACING / 2;
                else
                    y = itemRect.Top - Y_LARGEICON_SPACING;

                if (hit == HitTestType.DropLineLastItem)
                {
                    // use the bottom of the label if dealing with the last item
                    Rectangle labelRect = GetLabelRect(itemsCount - 1);
                    y = labelRect.Bottom + Y_LARGEICON_SPACING;
                    paintedDropLineLastItem = true;
                    // the none existing item index
                    droppedPosition = itemsCount;
                }
                else if (paintedDropLineLastItem)
                {
                    Rectangle labelRect = GetLabelRect(itemsCount - 1);
                    y = labelRect.Bottom + Y_LARGEICON_SPACING;
                    paintedDropLineLastItem = false;
                }

                // If we are using a bitmap background, erase
                // by painting the portion of the bitmap background
                if (backgroundBitmap != null && lastDrawnLineIndex == -1)
                {
                    Rectangle rcStrip = new Rectangle(viewPortRect.Left, y - 6, viewPortRect.Width, 12);
                    g.DrawImage(backgroundBitmap, rcStrip, rcStrip, GraphicsUnit.Pixel);
                    return;
                }

                // Draw horizontal line
                Point p1 = new Point(viewPortRect.Left + 11, y);
                Point p2 = new Point(viewPortRect.Right - 11, y);
                g.DrawLine(pen, p1, p2);

                // Draw left triangle
                Point top;
                Point bottom;
                if (index == firstItem)
                    top = new Point(viewPortRect.Left + 5, y);
                else
                    top = new Point(viewPortRect.Left + 5, y - 6);

                if (hit == HitTestType.DropLineLastItem)
                    bottom = new Point(viewPortRect.Left + 5, y + 1);
                else
                    bottom = new Point(viewPortRect.Left + 5, y + 6);

                Point middle = new Point(viewPortRect.Left + 11, y);
                Point[] points = new Point[3];
                points.SetValue(top, 0);
                points.SetValue(middle, 1);
                points.SetValue(bottom, 2);
                g.FillPolygon(brush, points);

                // Draw right triangle
                if (index == firstItem)
                    top = new Point(viewPortRect.Right - 5, y);
                else
                    top = new Point(viewPortRect.Right - 5, y - 6);

                if (hit == HitTestType.DropLineLastItem)
                    bottom = new Point(viewPortRect.Right - 5, y + 1);
                else
                    bottom = new Point(viewPortRect.Right - 5, y + 6);

                middle = new Point(viewPortRect.Right - 11, y);
                points.SetValue(top, 0);
                points.SetValue(middle, 1);
                points.SetValue(bottom, 2);
                g.FillPolygon(brush, points);
            }
            finally
            {
                if (!drawLine)
                {
                    brush.Dispose();
                    pen.Dispose();
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Performs a custom hit testing lookup for the specified mouse event args.
        /// </summary>
        public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, HitTestType hitTestType)
        {
            DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;
            HitTest(mousePosition, testAdorners, testDesignSurface,
                    delegate(DesignPanelHitTestResult r) {
                        result = r;
                        return false;
                    }, hitTestType);

            return result;
        }
Beispiel #10
0
		/// <summary>
		/// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
		/// Hit testing continues while the callback returns true.
		/// </summary>
		public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback, HitTestType hitTestType)
		{
			if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height) {
				return;
			}
			// First try hit-testing on the adorner layer.
			
			bool continueHitTest = true;
			
			hitTestElements.Clear();
			
			if (testAdorners) {
				RunHitTest(
					_adornerLayer, mousePosition, FilterHitTestInvisibleElements,
					delegate(HitTestResult result) {
						if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
							DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
							DependencyObject obj = result.VisualHit;
							while (obj != null && obj != _adornerLayer) {
								AdornerPanel adorner = obj as AdornerPanel;
								if (adorner != null) {
									customResult.AdornerHit = adorner;
								}
								obj = VisualTreeHelper.GetParent(obj);
							}
							continueHitTest = callback(customResult);
							return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
						} else {
							return HitTestResultBehavior.Continue;
						}
					});
			}
			
			if (continueHitTest && testDesignSurface) {
				RunHitTest(
					this.Child, mousePosition, FilterHitTestInvisibleElements,
					delegate(HitTestResult result) {
						if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
							DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
							
							ViewService viewService = _context.Services.View;
							DependencyObject obj = result.VisualHit;
							
							if (hitTestType == HitTestType.ElementSelection)
							{
								if (Keyboard.IsKeyDown(Key.LeftAlt))
								if (lastElement != null && lastElement != _context.RootItem.Component &&
									hitTestElements.Contains(lastElement))
								{
									var idx = hitTestElements.IndexOf(lastElement) - 1;
									if (idx >= 0)
										obj = hitTestElements[idx];
								}
							}
							
							while (obj != null) {
								if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
									break;
								obj = VisualTreeHelper.GetParent(obj);
							}
							if (customResult.ModelHit == null) {
								customResult.ModelHit = _context.RootItem;
							}
							
							if (hitTestType == HitTestType.ElementSelection)
							{
								lastElement = obj;
							}
							
							
							continueHitTest = callback(customResult);
							return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
						} else {
							return HitTestResultBehavior.Continue;
						}
					}
				);
			}
		}
Beispiel #11
0
        /// <summary>
        /// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
        /// Hit testing continues while the callback returns true.
        /// </summary>
        public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate <DesignPanelHitTestResult> callback, HitTestType hitTestType)
        {
            if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height)
            {
                return;
            }
            // First try hit-testing on the adorner layer.

            bool continueHitTest = true;

            hitTestElements.Clear();

            if (testAdorners)
            {
                RunHitTest(
                    _adornerLayer, mousePosition, FilterHitTestInvisibleElements,
                    delegate(HitTestResult result) {
                    if (result != null && result.VisualHit != null && result.VisualHit is Visual)
                    {
                        DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
                        DependencyObject obj = result.VisualHit;
                        while (obj != null && obj != _adornerLayer)
                        {
                            AdornerPanel adorner = obj as AdornerPanel;
                            if (adorner != null)
                            {
                                customResult.AdornerHit = adorner;
                            }
                            obj = VisualTreeHelper.GetParent(obj);
                        }
                        continueHitTest = callback(customResult);
                        return(continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop);
                    }
                    else
                    {
                        return(HitTestResultBehavior.Continue);
                    }
                });
            }

            if (continueHitTest && testDesignSurface)
            {
                RunHitTest(
                    this.Child, mousePosition, FilterHitTestInvisibleElements,
                    delegate(HitTestResult result) {
                    if (result != null && result.VisualHit != null && result.VisualHit is Visual)
                    {
                        DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);

                        ViewService viewService = _context.Services.View;
                        DependencyObject obj    = result.VisualHit;

                        if (hitTestType == HitTestType.ElementSelection)
                        {
                            if (Keyboard.IsKeyDown(Key.LeftAlt))
                            {
                                if (lastElement != null && lastElement != _context.RootItem.Component &&
                                    hitTestElements.Contains(lastElement))
                                {
                                    var idx = hitTestElements.IndexOf(lastElement) - 1;
                                    if (idx >= 0)
                                    {
                                        obj = hitTestElements[idx];
                                    }
                                }
                            }
                        }

                        while (obj != null)
                        {
                            if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
                            {
                                break;
                            }
                            obj = VisualTreeHelper.GetParent(obj);
                        }
                        if (customResult.ModelHit == null)
                        {
                            customResult.ModelHit = _context.RootItem;
                        }

                        if (hitTestType == HitTestType.ElementSelection)
                        {
                            lastElement = obj;
                        }


                        continueHitTest = callback(customResult);
                        return(continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop);
                    }
                    else
                    {
                        return(HitTestResultBehavior.Continue);
                    }
                }
                    );
            }
        }
Beispiel #12
0
        public HexEditor()
        {
            horizScrollBar = new HScrollBar();
            vertScrollBar = new VScrollBar();
            Width = 200;
            Height = 200;

            horizScrollBar.RightToLeft = RightToLeft.Inherit;
            horizScrollBar.Top = base.ClientRectangle.Height - horizScrollBar.Height;
            horizScrollBar.Left = 0;
            horizScrollBar.Visible = false;
            horizScrollBar.Scroll += new ScrollEventHandler(HexEditorHScroll);
            horizScrollBar.Cursor = Cursors.Arrow;
            base.Controls.Add(this.horizScrollBar);
            vertScrollBar.Top = 0;
            vertScrollBar.Left = base.ClientRectangle.Width - vertScrollBar.Width;
            vertScrollBar.Visible = false;
            vertScrollBar.Scroll += new ScrollEventHandler(HexEditorVScroll);
            vertScrollBar.Cursor = Cursors.Arrow;
            base.Controls.Add(this.vertScrollBar);
            memoryStream = new MemoryStream();
            colType = HitTestType.Hex;
            BackColor = SystemColors.Window;
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
        }
            public bool DoHitTest(float x, float y, HitTestType hitTestType)
            {
                if (MovieID == -1 || mRenderTexture == null)
                {
                return false;
                }

                // Adjust according to viewport
                if (mRenderTexture)
                {
                RaycastHit hit;
                if (Camera.main!=null && Physics.Raycast(Camera.main.ScreenPointToRay(new Vector2(x, y)), out hit))
                {
                Renderer hitRenderer = hit.collider.renderer;
                MeshCollider meshCollider = hit.collider as MeshCollider;
                if (!(hit.collider is MeshCollider) || hitRenderer == null || meshCollider == null)
                {
                    return false;
                }

                if (hit.collider.gameObject.GetComponent("SFMovie") == null)
                {
                    return false;
                }
                return true;
                }
                return false;
                }

                return SF_DoHitTest(MovieID, x, y, (int)hitTestType);
            }
Beispiel #14
0
        HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget, HitTestType hitTestType)
        {
            UIElement element = potentialHitTestTarget as UIElement;

            if (element != null) {
                if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible)) {
                    return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
                }

                var designItem = Context.Services.Component.GetDesignItem(element) as XamlDesignItem;

                if (hitTestType == HitTestType.ElementSelection)
                {
                    if (Keyboard.IsKeyDown(Key.LeftAlt))
                    {
                        if (designItem != null)
                        {
                            if (skippedHitTestElements.LastOrDefault() == designItem ||
                                (hitTestElements.Contains(designItem) && !skippedHitTestElements.Contains(designItem)))
                            {
                                skippedHitTestElements.Remove(designItem);
                                return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
                            }
                        }
                    }
                }
                else
                {
                    hitTestElements.Clear();
                    skippedHitTestElements.Clear();
                }

                if (designItem != null && designItem.IsDesignTimeLocked) {
                    return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
                }

                if (designItem != null && !hitTestElements.Contains(designItem))
                {
                    hitTestElements.Add(designItem);
                    skippedHitTestElements.Add(designItem);
                }
            }

            return HitTestFilterBehavior.Continue;
        }
Beispiel #15
0
 /// <summary>
 /// ��ȡ�������ַ�λ�á�
 /// </summary>
 /// <param name="type">��������</param>
 /// <param name="col">����</param>
 /// <returns>�����������ַ�λ��</returns>
 private int XFromCol(HitTestType type, int col)
 {
     switch (type)
     {
         case HitTestType.Char:
             return 60 + col;
         case HitTestType.Hex:
             return 10 + col * 3 + (col < 8 ? 0 : 1);
         default: return 0;
     }
 }
Beispiel #16
0
 public HitTestInfo(HitTestType type, int columnIndex, int rowIndex)
 {
     this.columnIndex = columnIndex;
     this.rowIndex    = rowIndex;
     this.type        = type;
 }
Beispiel #17
0
 public HitTestInfo(HitTestType type)
 {
     this.type = type;
 }
Beispiel #18
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     base.OnKeyDown(e);
     switch (e.KeyCode)
     {
         case Keys.F2:
             #region ������ǩ
             if (e.Control)
             {
                 if (bookmarks.Contains(RowIndex))
                     bookmarks.Remove(RowIndex);
                 else bookmarks.Add(RowIndex);
                 Invalidate();
             }
             else
             {
                 if (bookmarks.Count <= 0) return;
                 if (e.Shift)
                 {
                     if (bookmarkIndex <= 0)
                         bookmarkIndex = bookmarks.Count - 1;
                     else bookmarkIndex--;
                 }
                 else
                 {
                     if (bookmarkIndex >= bookmarks.Count - 1)
                         bookmarkIndex = 0;
                     else bookmarkIndex++;
                 }
                 RowIndex = bookmarks[bookmarkIndex];
                 modifyHex = '\x00';
                 ScrollIntoView();
                 UpdateCaret();
                 Invalidate();
             }
             break;
             #endregion ������ǩ
         case Keys.Tab:
             #region �������
             if (colType == HitTestType.Hex)
                 colType = HitTestType.Char;
             else colType = HitTestType.Hex;
             modifyHex = '\x00';
             ScrollIntoView();
             UpdateCaret();
             Invalidate();
             break;
             #endregion �������
         case Keys.Up:
         case Keys.Down:
         case Keys.Left:
         case Keys.PageDown:
         case Keys.PageUp:
         case Keys.Right:
         case Keys.Home:
         case Keys.End:
             #region �������
             int A = caretFirst ? selStart : selStart + selLength;
             int B = caretFirst ? selStart + selLength : selStart;
             switch (e.KeyCode)
             {
                 case Keys.PageUp:
                     if (RowIndex <= 0) return;
                     A -= Math.Max(1, 16 * (viewRowCount - 1));
                     break;
                 case Keys.PageDown:
                     if (RowIndex >= lineCount) return;
                     A += Math.Max(1, 16 * (viewRowCount - 1));
                     break;
                 case Keys.Up:
                     if (RowIndex <= 0) return;
                     A -= 16;
                     break;
                 case Keys.Down:
                     if (RowIndex >= lineCount) return;
                     A += 16;
                     break;
                 case Keys.Left:
                     A--;
                     endCaret = false;
                     break;
                 case Keys.Right:
                     A++;
                     endCaret = false;
                     break;
                 case Keys.Home:
                     if (e.Control)
                         A = 0;
                     else
                     {
                         if (endCaret)
                         {
                             A = A - A % 16 - 16;
                         }
                         else A = A - A % 16;
                     }
                     endCaret = false;
                     break;
                 case Keys.End:
                     if (e.Control)
                         A = (int)memoryStream.Length;
                     else
                     {
                         if (!endCaret) A = A - A % 16 + 16;
                     }
                     if (A > memoryStream.Length)
                         A = (int)memoryStream.Length;
                     endCaret = A % 16 == 0;
                     break;
             }
             if (e.Shift)
                 SelectData(B, A);
             else SelectData(A, A);
             break;
             #endregion �������
         case Keys.Back:
         case Keys.Delete:
             #region �����˸��ɾ��
             if (fixedSize) return;
             if (selLength > 0)
             {
                 StreamEngine.Delete(memoryStream, selStart, selLength);
                 selLength = 0;
             }
             else
             {
                 switch (e.KeyCode)
                 {
                     case Keys.Back:
                         if (selStart <= 0) return;
                         StreamEngine.Delete(memoryStream, selStart - 1, 1);
                         selStart--;
                         break;
                     case Keys.Delete:
                         StreamEngine.Delete(memoryStream, selStart, 1);
                         break;
                 }
             }
             DoChange();
             if (DataChanged != null) DataChanged(this, EventArgs.Empty);
             if (SelectionChanged != null) SelectionChanged(this, EventArgs.Empty);
             break;
             #endregion �����˸��ɾ��
     }
 }
Beispiel #19
0
 /// <summary>
 /// ����ѡ��
 /// </summary>
 /// <param name="type">��������</param>
 /// <param name="g">����</param>
 /// <param name="line">������</param>
 /// <param name="buf">����</param>
 /// <param name="len">���ݳ���</param>
 /// <param name="x">��������</param>
 /// <param name="y">��������</param>
 protected virtual void DrawSelection(HitTestType type, Graphics g, int line,
     byte[] buf, int len, int x, int y)
 {
     #region ����ѡ����
     if (selLength <= 0) return;
     Point vSelStart = CoordinateFromPosistion(selStart);
     Point vSelEnd = CoordinateFromPosistion(selStart + selLength - 1);
     string vViewText = string.Empty;
     if (colType == type)
     {
         if (line == vSelStart.Y && line == vSelEnd.Y)
         {
             Point vPoint = PointFromColRow(type, vSelStart.X, line);
             vViewText = ViewText(type, buf, len, vSelStart.X, vSelEnd.X);
             TextRenderer.DrawText(g, vViewText, Font,
                 vPoint, SystemColors.HighlightText, SystemColors.Highlight);
         }
         else if (line == vSelStart.Y)
         {
             Point vPoint = PointFromColRow(type, vSelStart.X, line);
             vViewText = ViewText(type, buf, len, vSelStart.X, len);
             TextRenderer.DrawText(g, vViewText, Font,
                 vPoint, SystemColors.HighlightText, SystemColors.Highlight);
         }
         else if (line == vSelEnd.Y)
         {
             Point vPoint = PointFromColRow(type, 0, line);
             vViewText = ViewText(type, buf, len, 0, vSelEnd.X);
             TextRenderer.DrawText(g, vViewText, Font,
                 vPoint, SystemColors.HighlightText, SystemColors.Highlight);
         }
         else if (line > vSelStart.Y && line < vSelEnd.Y)
         {
             vViewText = ViewText(type, buf, len, 0, len);
             TextRenderer.DrawText(g, vViewText, Font,
                 new Point(x, y), SystemColors.HighlightText, SystemColors.Highlight);
         }
     }
     else
     {
         int vSpace = type == HitTestType.Hex ? 2 : 1;
         if (line == vSelStart.Y && line == vSelEnd.Y)
         {
             Point A = PointFromColRow(type, vSelStart.X, line);
             Point B = PointFromColRow(type, vSelEnd.X, line);
             g.DrawRectangle(Pens.Black, A.X, A.Y,
                 B.X - A.X + itemWidth * vSpace, itemHeight);
         }
         else if (line == vSelStart.Y)
         {
             Point A = PointFromColRow(type, vSelStart.X, line);
             Point B = PointFromColRow(type, 15, line);
             g.DrawLine(Pens.Black, A.X, A.Y, A.X, B.Y + itemHeight);
             g.DrawLine(Pens.Black,
                 B.X + itemWidth * vSpace, A.Y,
                 B.X + itemWidth * vSpace, B.Y + itemHeight);
             g.DrawLine(Pens.Black,
                 A.X, A.Y,
                 B.X + itemWidth * vSpace, A.Y);
             B = PointFromColRow(type, 0, line);
             g.DrawLine(Pens.Black,
                 B.X, B.Y + itemHeight,
                 A.X, B.Y + itemHeight);
         }
         else if (line == vSelEnd.Y)
         {
             Point A = PointFromColRow(type, 0, line);
             Point B = PointFromColRow(type, vSelEnd.X, line);
             g.DrawLine(Pens.Black, A.X, A.Y, A.X, A.Y + itemHeight);
             g.DrawLine(Pens.Black,
                 B.X + itemWidth * vSpace, A.Y,
                 B.X + itemWidth * vSpace, A.Y + itemHeight);
             g.DrawLine(Pens.Black,
                 A.X, A.Y + itemHeight,
                 B.X + itemWidth * vSpace, A.Y + itemHeight);
             A = PointFromColRow(type, 15, line);
             g.DrawLine(Pens.Black,
                 B.X + itemWidth * vSpace, A.Y,
                 A.X + itemWidth * vSpace, A.Y);
         }
         else if (line > vSelStart.Y && line < vSelEnd.Y)
         {
             Point A = PointFromColRow(type, 0, line);
             Point B = PointFromColRow(type, 15, line);
             g.DrawLine(Pens.Black,
                 A.X, A.Y,
                 A.X, A.Y + itemHeight);
             g.DrawLine(Pens.Black,
                 B.X + itemWidth * vSpace, A.Y,
                 B.X + itemWidth * vSpace, A.Y + itemHeight);
         }
     }
     #endregion ����ѡ����
 }
Beispiel #20
0
 /// <summary>
 /// �������м��������������ꡣ
 /// </summary>
 /// <param name="type">������</param>
 /// <param name="col">��</param>
 /// <param name="row">��</param>
 /// <returns>��������������������</returns>
 public Point PointFromColRow(HitTestType type, int col, int row)
 {
     Point vResult = new Point();
     switch (type)
     {
         case HitTestType.Address:
             vResult.X = 0;
             vResult.Y = row * itemHeight;
             break;
         case HitTestType.Char:
         case HitTestType.Hex:
             vResult.X = XFromCol(type, col) * itemWidth;
             vResult.Y = row * itemHeight;
             break;
         default: return Point.Empty;
     }
     vResult.X -= leftOffset * itemWidth;
     vResult.Y -= topOffset * itemHeight;
     return vResult;
 }
Beispiel #21
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (!Focused && CanFocus) Focus();
     if (e.Button != MouseButtons.Left) return;
     downHitInfo = HitTest(e.X, e.Y);
     switch (downHitInfo.type)
     {
         case HitTestType.Hex:
         case HitTestType.Char:
             colType = downHitInfo.type;
             selLength = 0;
             selStart = downHitInfo.row * 16 + downHitInfo.col;
             endCaret = false;
             modifyHex = '\x00';
             if (SelectionChanged != null) SelectionChanged(this, EventArgs.Empty);
             UpdateCaret();
             Invalidate();
             break;
         case HitTestType.Bookmark:
             if (bookmarks.Contains(downHitInfo.row))
                 bookmarks.Remove(downHitInfo.row);
             else bookmarks.Add(downHitInfo.row);
             Invalidate();
             break;
     }
 }
Beispiel #22
0
 /// <summary>
 /// ��ȡ�ڱ༭����ʾ�ַ���
 /// </summary>
 /// <param name="type">��������</param>
 /// <param name="buf">����</param>
 /// <param name="start">��ʼλ��</param>
 /// <param name="end">�����</param>
 /// <returns>���ر༭����ʾ�ַ�</returns>
 protected virtual string ViewText(HitTestType type, byte[] buf, int len, int start, int end)
 {
     if (len <= 0) return string.Empty;
     const string vCharHexs = "0123456789ABCDEF";
     StringBuilder vBuffer = new StringBuilder(128);
     start = Math.Max(0, start);
     end = Math.Min(len - 1, end);
     for (int i = start; i <= end; i++)
     {
         switch (type)
         {
             case HitTestType.Hex:
                 if (i == 8) vBuffer.Append(" ");
                 vBuffer.Append(vCharHexs[buf[i] >> 4]);
                 vBuffer.Append(vCharHexs[buf[i] & 0x0F]);
                 vBuffer.Append(" ");
                 break;
             case HitTestType.Char:
                 if (buf[i] >= 32 && buf[i] <= 126)
                     vBuffer.Append((char)buf[i]);
                 else vBuffer.Append('.');
                 break;
         }
     }
     if (type == HitTestType.Hex)
         return vBuffer.ToString().Trim();
     else return vBuffer.ToString();
 }
Beispiel #23
0
        /// <summary>
        /// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
        /// Hit testing continues while the callback returns true.
        /// </summary>
        public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate <DesignPanelHitTestResult> callback, HitTestType hitTestType)
        {
            if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height)
            {
                return;
            }
            // First try hit-testing on the adorner layer.

            bool continueHitTest = true;

            HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? (x => FilterHitTestInvisibleElements(x, hitTestType));

            CustomHitTestFilterBehavior = null;

            if (testAdorners)
            {
                RunHitTest(
                    _adornerLayer, mousePosition, filterBehavior,
                    delegate(HitTestResult result) {
                    if (result != null && result.VisualHit != null && result.VisualHit is Visual)
                    {
                        DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
                        DependencyObject obj = result.VisualHit;
                        while (obj != null && obj != _adornerLayer)
                        {
                            AdornerPanel adorner = obj as AdornerPanel;
                            if (adorner != null)
                            {
                                customResult.AdornerHit = adorner;
                            }
                            obj = VisualTreeHelper.GetParent(obj);
                        }
                        continueHitTest = callback(customResult);
                        return(continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop);
                    }
                    else
                    {
                        return(HitTestResultBehavior.Continue);
                    }
                });
            }

            if (continueHitTest && testDesignSurface)
            {
                RunHitTest(
                    this.Child, mousePosition, filterBehavior,
                    delegate(HitTestResult result) {
                    if (result != null && result.VisualHit != null && result.VisualHit is Visual)
                    {
                        DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);

                        ViewService viewService = _context.Services.View;
                        DependencyObject obj    = result.VisualHit;

                        while (obj != null)
                        {
                            if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
                            {
                                break;
                            }
                            obj = VisualTreeHelper.GetParent(obj);
                        }
                        if (customResult.ModelHit == null)
                        {
                            customResult.ModelHit = _context.RootItem;
                        }


                        continueHitTest = callback(customResult);
                        return(continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop);
                    }
                    else
                    {
                        return(HitTestResultBehavior.Continue);
                    }
                }
                    );
            }
        }
Beispiel #24
0
            /// <summary>
            /// Checks if the (x,y) lies on this movie, according to HitTestType. Transforms (x,y) to render texture space if the movie is a render-to-texture. 
            /// </summary>
            /// <param name="x">x coordinate.</param>
            /// <param name="y">y coordinate.</param>
            /// <param name="hitTestType">See doc for HitTestType enum for details.</param>
            /// <returns>True if hit test succeeded, false otherwise.</returns>
            public bool DoHitTest(float x, float y, HitTestType hitTestType)
            {
                if (MovieID == 0)
                {
                return false;
                }
                float xx = x; float yy = y;
                // Adjust according to viewport
                if (mRenderTexture)
                {
                RaycastHit hit;
                if (Camera.main!=null && Physics.Raycast(Camera.main.ScreenPointToRay(new Vector2(xx, yy)), out hit))
                {
                Renderer hitRenderer = hit.collider.renderer;
                MeshCollider meshCollider = hit.collider as MeshCollider;
                if (!(hit.collider is MeshCollider) || hitRenderer == null || meshCollider == null)
                {
                    return false;
                }

                if (hit.collider.gameObject.GetComponent("SFMovie") == null)
                {
                    return false;
                }
                return true;
                }
                return false;
                }
                else
                {
                GetViewport(out ViewPort);

                #if UNITY_EDITOR
                xx -= ViewPort.OX;
                yy -= ViewPort.OY + 24;// HACK, This value is from the real viewport(bigger than game screen) and the tool bar on top.
                #endif
                }
                #if UNITY_WP8
                return sf_doHitTest(MovieID, xx, yy, (int)hitTestType);
                #else
                return SF_DoHitTest(MovieID, xx, yy, (int)hitTestType);
                #endif
            }