/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.Windows.Input;
namespace dnSpy.Contracts.Hex.Editor {
///
/// Creates s
///
public abstract class HexCursorProviderFactory {
///
/// Constructor
///
protected HexCursorProviderFactory() { }
///
/// Creates a instance or returns null
///
/// Hex view
///
public abstract HexCursorProvider? Create(WpfHexView wpfHexView);
}
///
/// Cursor priorities
///
public static class PredefinedHexCursorPriorities {
///
/// Low priority
///
public static readonly double Low = -100000;
///
/// Normal priority
///
public static readonly double Normal = 0;
///
/// High priority
///
public static readonly double High = 100000;
///
/// Priority of the offset cursor (hand)
///
public static readonly double Offset = High;
}
///
/// Cursor info
///
public readonly struct HexCursorInfo : IEquatable {
///
/// Gets the cursor or null
///
public Cursor Cursor { get; }
///
/// Gets the priority, eg. . The highest priority cursor is used.
///
public double Priority { get; }
///
/// Constructor
///
/// Cursor or null
/// Priority, eg. . The highest priority cursor is used
public HexCursorInfo(Cursor cursor, double priority) {
Cursor = cursor;
Priority = priority;
}
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static bool operator ==(HexCursorInfo left, HexCursorInfo right) => left.Equals(right);
public static bool operator !=(HexCursorInfo left, HexCursorInfo right) => !left.Equals(right);
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
///
/// Equals()
///
///
///
public bool Equals(HexCursorInfo other) => Cursor == other.Cursor && Priority == other.Priority;
///
/// Equals()
///
///
///
public override bool Equals(object? obj) => obj is HexCursorInfo && Equals((HexCursorInfo)obj);
///
/// GetHashCode()
///
///
public override int GetHashCode() => (Cursor?.GetHashCode() ?? 0) ^ Priority.GetHashCode();
}
///
/// Hex editor provider
///
public abstract class HexCursorProvider {
///
/// Constructor
///
protected HexCursorProvider() { }
///
/// Raised after is changed
///
public abstract event EventHandler? CursorInfoChanged;
///
/// Gets the cursor and priority
///
public abstract HexCursorInfo CursorInfo { get; }
}
}