Skip to content

Commit

Permalink
Renamed property CanInsertEverywhere to CanInsertAnywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
abbaye committed Feb 27, 2021
1 parent 9620600 commit e66bfc1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Margin="10,50,10,10"
AllowAutoHighLightSelectionByte="False"
AllowAutoSelectSameByteAtDoubleClick="False"
CanInsertEverywhere="True"
CanInsertAnywhere="True"
PreloadByteInEditorMode="MaxScreenVisibleLineAtDataLoad" />

<Button
Expand Down
24 changes: 12 additions & 12 deletions Sources/WPFHexaEditor/Core/Bytes/ByteProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public sealed class ByteProvider : IDisposable
private string _fileName = string.Empty;
private Stream _stream;
private bool _readOnlyMode;
private bool _canInsertEverywhere = false;
private bool _canInsertAnywhere = false;
private double _longProcessProgress;
private string _newfilename = string.Empty;
#endregion Globals variable
Expand All @@ -58,7 +58,7 @@ public sealed class ByteProvider : IDisposable
public event EventHandler FillWithByteCompleted;
public event EventHandler ReplaceByteCompleted;
public event EventHandler BytesAppendCompleted;
public event EventHandler CanInsertEverywhereChanged;
public event EventHandler CanInsertAnywhereChanged;

#endregion Events

Expand All @@ -77,19 +77,19 @@ public ByteProvider() { }
/// <summary>
/// Construct new ByteProvider with filename and try to open file
/// </summary>
public ByteProvider(string fileName, bool readOnlyMode, bool canInsertEverywhere)
public ByteProvider(string fileName, bool readOnlyMode, bool canInsertAnywhere)
{
CanInsertEverywhere = canInsertEverywhere;
CanInsertAnywhere = canInsertAnywhere;
ReadOnlyMode = readOnlyMode;
FileName = fileName;
}

/// <summary>
/// Constuct new ByteProvider with stream
/// </summary>
public ByteProvider(Stream stream, bool canInsertEverywhere)
public ByteProvider(Stream stream, bool canInsertAnywhere)
{
CanInsertEverywhere = canInsertEverywhere;
CanInsertAnywhere = canInsertAnywhere;
Stream = stream;
}

Expand Down Expand Up @@ -211,17 +211,17 @@ public bool ReadOnlyMode
}

/// <summary>
/// Give the possibility to inserts byte everywhere in the providers.
/// Give the possibility to inserts byte Anywhere in the providers.
/// </summary>
public bool CanInsertEverywhere
public bool CanInsertAnywhere
{
get => _canInsertEverywhere;
get => _canInsertAnywhere;
set
{
_canInsertEverywhere = value;
_canInsertAnywhere = value;

//Launch event
CanInsertEverywhereChanged?.Invoke(this, new EventArgs());
CanInsertAnywhereChanged?.Invoke(this, new EventArgs());
}
}

Expand Down Expand Up @@ -612,7 +612,7 @@ public void AddByteModified(byte? @byte, long bytePositionInStream, long undoLen
public void AddByteAdded(byte? @byte, long bytePositionInStream, long undoLength = 1)
{
if (ReadOnlyMode) return;
if (!CanInsertEverywhere) return;
if (!CanInsertAnywhere) return;

var (success, _) = CheckIfIsByteModified(bytePositionInStream, ByteAction.Added);

Expand Down
30 changes: 15 additions & 15 deletions Sources/WPFHexaEditor/HexEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,7 @@ private void OpenFile(string filename)
if (PreloadByteInEditorMode == PreloadByteInEditor.MaxScreenVisibleLineAtDataLoad)
BuildDataLines(MaxScreenVisibleLine, false);

_provider = new ByteProvider(filename, ReadOnlyMode, CanInsertEverywhere);
_provider = new ByteProvider(filename, ReadOnlyMode, CanInsertAnywhere);

_provider.With(p =>
{
Expand Down Expand Up @@ -2294,7 +2294,7 @@ private void OpenStream(Stream stream)
if (PreloadByteInEditorMode == PreloadByteInEditor.MaxScreenVisibleLineAtDataLoad)
BuildDataLines(MaxScreenVisibleLine, false);

_provider = new ByteProvider(stream, CanInsertEverywhere);
_provider = new ByteProvider(stream, CanInsertAnywhere);

_provider.With(p =>
{
Expand Down Expand Up @@ -2935,7 +2935,7 @@ private void UpdateViewers(bool controlResize)
if (AllowVisualByteAddress && startPosition < VisualByteAdressStart)
startPosition = VisualByteAdressStart;

#region read the data from the provider and warns if necessary to load the bytes that have been deleted
#region Read the data from the provider and warns if necessary to load the bytes that have been deleted
_provider.Position = startPosition;
var readSize = 0;
if (HideByteDeleted)
Expand Down Expand Up @@ -5638,27 +5638,27 @@ public ICommand SubmitChangesCommand

#endregion

#region Insert byte everywhere support (In early stage of development)
#region Insert byte Anywhere support (In early stage of development)

/// <summary>
/// Give the possibility to inserts byte everywhere.
/// Give the possibility to inserts byte Anywhere.
/// </summary>
public bool CanInsertEverywhere
public bool CanInsertAnywhere
{
get { return (bool)GetValue(CanInsertEverywhereProperty); }
set { SetValue(CanInsertEverywhereProperty, value); }
get { return (bool)GetValue(CanInsertAnywhereProperty); }
set { SetValue(CanInsertAnywhereProperty, value); }
}

public static readonly DependencyProperty CanInsertEverywhereProperty =
DependencyProperty.Register(nameof(CanInsertEverywhere), typeof(bool), typeof(HexEditor),
new FrameworkPropertyMetadata(false, Control_CanInsertEverywhereChanged));
public static readonly DependencyProperty CanInsertAnywhereProperty =
DependencyProperty.Register(nameof(CanInsertAnywhere), typeof(bool), typeof(HexEditor),
new FrameworkPropertyMetadata(false, Control_CanInsertAnywhereChanged));

private static void Control_CanInsertEverywhereChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
private static void Control_CanInsertAnywhereChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is not HexEditor ctrl || e.NewValue == e.OldValue) return;

if (CheckIsOpen(ctrl._provider))
ctrl._provider.CanInsertEverywhere = (bool)e.NewValue;
ctrl._provider.CanInsertAnywhere = (bool)e.NewValue;

ctrl.RefreshView();
}
Expand All @@ -5675,7 +5675,7 @@ public void InsertByte(byte @byte, long bytePositionInStream) =>
public void InsertByte(byte @byte, long bytePositionInStream, long length)
{
if (!CheckIsOpen(_provider)) return;
if (!CanInsertEverywhere) return;
if (!CanInsertAnywhere) return;

for (int i = 0; i <= length; i++)
_provider.AddByteAdded(@byte, bytePositionInStream + i);
Expand All @@ -5689,7 +5689,7 @@ public void InsertByte(byte @byte, long bytePositionInStream, long length)
public void InsertBytes(byte[] bytes, long bytePositionInStream)
{
if (!CheckIsOpen(_provider)) return;
if (!CanInsertEverywhere) return;
if (!CanInsertAnywhere) return;

foreach (byte @byte in bytes)
_provider.AddByteAdded(@byte, bytePositionInStream++);
Expand Down

0 comments on commit e66bfc1

Please sign in to comment.