예제 #1
0
        public override void GoToPosition(PositionKind positionKind)
        {
            var origPos   = HexView.Caret.Position.Position.ActivePosition.BufferPosition;
            var selectPos = HexView.Selection.IsEmpty ? origPos :
                            HexView.Selection.AnchorPoint < HexView.Selection.ActivePoint ?
                            HexView.Selection.AnchorPoint : HexView.Selection.AnchorPoint - 1;
            var data = new GoToPositionVM(HexView.Buffer.ReadUInt32(origPos));

            data.PositionKind = positionKind;
            var win = new GoToPositionDlg();

            win.DataContext = data;
            win.Owner       = OwnerWindow;
            if (win.ShowDialog() != true)
            {
                return;
            }

            var pos    = Filter(ToBufferPosition(origPos, data.OffsetVM.Value, data.PositionKind));
            var newPos = new HexBufferPoint(HexView.Buffer, pos);

            if (!data.SelectToNewPosition)
            {
                MoveTo(newPos, newPos, newPos, select: false);
            }
            else
            {
                var info = UserValueToSelection(selectPos, newPos);
                MoveTo(new HexBufferPoint(HexView.Buffer, info.Anchor), new HexBufferPoint(HexView.Buffer, info.Active), new HexBufferPoint(HexView.Buffer, info.Caret), select: true);
            }
        }
예제 #2
0
        public override void GoToPosition()
        {
            var curr   = HexView.BufferLines.ToLogicalPosition(HexView.Caret.Position.Position.ActivePosition.BufferPosition);
            var minPos = HexView.BufferLines.ToLogicalPosition(HexView.BufferLines.StartPosition);
            var maxPos = HexView.BufferLines.ToLogicalPosition(HexView.BufferLines.EndPosition);

            if (HexView.BufferLines.BufferSpan.IsEmpty)
            {
            }
            else if (maxPos == HexPosition.Zero)
            {
                maxPos = HexPosition.MaxEndPosition - 1;
            }
            else
            {
                maxPos = maxPos - 1;
            }
            var data = new GoToPositionVM(curr, minPos, maxPos);
            var win  = new GoToPositionDlg();

            win.DataContext = data;
            win.Owner       = OwnerWindow;
            if (HexView.Buffer.IsMemory)
            {
                win.Title = dnSpy_Resources.GoToOffset_Title_Address;
                win.offsetLabel.Content = dnSpy_Resources.GoToOffset_Address_Label;
            }
            else
            {
                win.Title = dnSpy_Resources.GoToOffset_Title;
                win.offsetLabel.Content = dnSpy_Resources.GoToOffset_Offset_Label;
            }
            if (win.ShowDialog() != true)
            {
                return;
            }

            var newPos = new HexBufferPoint(HexView.Buffer, HexView.BufferLines.ToPhysicalPosition(data.OffsetVM.Value));

            MoveTo(newPos, newPos, newPos);
        }
예제 #3
0
		public override void GoToPosition() {
			var curr = HexView.BufferLines.ToLogicalPosition(HexView.Caret.Position.Position.ActivePosition.BufferPosition);
			var minPos = HexView.BufferLines.ToLogicalPosition(HexView.BufferLines.StartPosition);
			var maxPos = HexView.BufferLines.ToLogicalPosition(HexView.BufferLines.EndPosition);
			if (HexView.BufferLines.BufferSpan.IsEmpty) {
			}
			else if (maxPos == HexPosition.Zero)
				maxPos = HexPosition.MaxEndPosition - 1;
			else
				maxPos = maxPos - 1;
			var data = new GoToPositionVM(curr, minPos, maxPos);
			var win = new GoToPositionDlg();
			win.DataContext = data;
			win.Owner = OwnerWindow;
			if (HexView.Buffer.IsMemory) {
				win.Title = dnSpy_Resources.GoToOffset_Title_Address;
				win.offsetLabel.Content = dnSpy_Resources.GoToOffset_Address_Label;
			}
			else {
				win.Title = dnSpy_Resources.GoToOffset_Title;
				win.offsetLabel.Content = dnSpy_Resources.GoToOffset_Offset_Label;
			}
			if (win.ShowDialog() != true)
				return;

			var newPos = new HexBufferPoint(HexView.Buffer, HexView.BufferLines.ToPhysicalPosition(data.OffsetVM.Value));
			MoveTo(newPos, newPos, newPos);
		}