Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd68fd9

Browse files
committed
#31 Working ont the HexEditor. UpdateViewers() methods for added the abbility to insert anywhere... courage is on the way !!
1 parente66bfc1 commitdd68fd9

File tree

2 files changed

+53
-30
lines changed

2 files changed

+53
-30
lines changed

‎Sources/Samples/WpfHexEditor.Sample.InsertByteAnywhere/MainWindow.xaml.cs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ private void OpenButton_Click(object sender, RoutedEventArgs e) =>
3838
privatevoidAddByteButton_Click(objectsender,RoutedEventArgse)=>
3939
HexEditor.With(c=>
4040
{
41-
c.InsertByte(224,15);
42-
c.InsertByte(245,16);
43-
c.InsertByte(226,17);
41+
c.InsertByte(255,15);
42+
c.InsertByte(255,16);
43+
c.InsertByte(255,17);
44+
c.InsertByte(255,18);
45+
c.InsertByte(255,19);
46+
c.InsertByte(255,20);
47+
c.InsertByte(255,21);
4448

4549
//Actually the visual not show the result. I'm working on this :)
4650
c.RefreshView();

‎Sources/WPFHexaEditor/HexEditor.xaml.cs‎

Lines changed: 46 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2938,10 +2938,23 @@ private void UpdateViewers(bool controlResize)
29382938
#region Read the data from the provider and warns if necessary to load the bytes that have been deleted
29392939
_provider.Position=startPosition;
29402940
varreadSize=0;
2941-
if(HideByteDeleted)
2941+
if(HideByteDeleted||CanInsertAnywhere)
29422942
for(inti=0;i<_viewBuffer.Length;i++)
29432943
{
2944-
if(!_provider.CheckIfIsByteModified(_provider.Position,ByteAction.Deleted).success)
2944+
//BYTE INSERT ANYWHERE IS IN DEVELOPMENT!! ///////////
2945+
//DOES NOT WORK CLEANLY! BE PATIENT
2946+
if(_provider.CheckIfIsByteModified(_provider.Position,ByteAction.Added).success)
2947+
{
2948+
if(_provider.Eof)continue;
2949+
2950+
var(success,val)=_provider.CheckIfIsByteModified(_provider.Position,ByteAction.Added);
2951+
2952+
_viewBuffer[readSize]=val.Byte.Value;
2953+
_viewBufferBytePosition[readSize]=val.BytePositionInStream;
2954+
readSize++;
2955+
}
2956+
/////////////////////////////////////////////////////
2957+
elseif(!_provider.CheckIfIsByteModified(_provider.Position,ByteAction.Deleted).success)
29452958
{
29462959
if(_provider.Eof)continue;
29472960

@@ -2968,11 +2981,11 @@ private void UpdateViewers(bool controlResize)
29682981

29692982
#region HexByte panel refresh
29702983

2971-
TraverseHexBytes(ctrl=>
2984+
TraverseHexBytes(c=>
29722985
{
2973-
ctrl.Action=ByteAction.Nothing;
2974-
ctrl.ReadOnlyMode=ReadOnlyMode;
2975-
ctrl.InternalChange=true;
2986+
c.Action=ByteAction.Nothing;
2987+
c.ReadOnlyMode=ReadOnlyMode;
2988+
c.InternalChange=true;
29762989

29772990
varnextPos=startPosition+index;
29782991

@@ -2981,24 +2994,30 @@ private void UpdateViewers(bool controlResize)
29812994
while(_provider.CheckIfIsByteModified(nextPos,ByteAction.Deleted).success)
29822995
nextPos++;
29832996

2997+
//Insert byte
2998+
//if (CanInsertAnywhere)
2999+
//{
3000+
// var (success, val) = _provider.CheckIfIsByteModified(nextPos, ByteAction.Added);
3001+
//}
3002+
29843003
if(index<readSize&&_priLevel==curLevel)
29853004
{
2986-
ctrl.Byte=ByteSizeswitch
3005+
c.Byte=ByteSizeswitch
29873006
{
29883007
ByteSizeType.Bit8=>newByte_8bit(_viewBuffer[index]),
29893008
ByteSizeType.Bit16=>newByte_16bit(newbyte[]{_viewBuffer[index],_viewBuffer[index+1]}),
29903009
ByteSizeType.Bit32=>newByte_32bit(newbyte[]{_viewBuffer[index],_viewBuffer[index+1],_viewBuffer[index+2],_viewBuffer[index+3]}),
29913010
_=>thrownewNotImplementedException()
29923011
};
2993-
ctrl.BytePositionInStream=!HideByteDeleted?nextPos:_viewBufferBytePosition[index];
3012+
c.BytePositionInStream=!HideByteDeleted?nextPos:_viewBufferBytePosition[index];
29943013

29953014
if(AllowVisualByteAddress&&nextPos>VisualByteAdressStop)
2996-
ctrl.Clear();
3015+
c.Clear();
29973016
}
29983017
else
2999-
ctrl.Clear();
3018+
c.Clear();
30003019

3001-
ctrl.InternalChange=false;
3020+
c.InternalChange=false;
30023021
index+=ByteSizeRatio;
30033022
});
30043023

@@ -3009,13 +3028,13 @@ private void UpdateViewers(bool controlResize)
30093028
#region StringByte / Barchart panel refresh
30103029

30113030
varskipNextIsMTE=false;
3012-
TraverseStringBytes(ctrl=>
3031+
TraverseStringBytes(c=>
30133032
{
3014-
ctrl.Action=ByteAction.Nothing;
3015-
ctrl.ReadOnlyMode=ReadOnlyMode;
3016-
ctrl.InternalChange=true;
3017-
ctrl.TblCharacterTable=_tblCharacterTable;
3018-
ctrl.TypeOfCharacterTable=TypeOfCharacterTable;
3033+
c.Action=ByteAction.Nothing;
3034+
c.ReadOnlyMode=ReadOnlyMode;
3035+
c.InternalChange=true;
3036+
c.TblCharacterTable=_tblCharacterTable;
3037+
c.TypeOfCharacterTable=TypeOfCharacterTable;
30193038

30203039
varnextPos=startPosition+index;
30213040

@@ -3028,37 +3047,37 @@ private void UpdateViewers(bool controlResize)
30283047
{
30293048
if(!skipNextIsMTE)
30303049
{
3031-
ctrl.BytePositionInStream=!HideByteDeleted?nextPos:_viewBufferBytePosition[index];
3050+
c.BytePositionInStream=!HideByteDeleted?nextPos:_viewBufferBytePosition[index];
30323051

30333052
#region Load ByteNext for TBL MTE matching
30343053
if(_tblCharacterTableis notnull)
30353054
{
3036-
var(singleByte,succes)=_provider.GetByte(ctrl.BytePositionInStream+1);
3037-
ctrl.ByteNext=succes?singleByte:null;
3055+
var(singleByte,succes)=_provider.GetByte(c.BytePositionInStream+1);
3056+
c.ByteNext=succes?singleByte:null;
30383057
}
30393058
#endregion
30403059

30413060
//update byte
3042-
ctrl.Byte=newByte_8bit(_viewBuffer[index]);
3061+
c.Byte=newByte_8bit(_viewBuffer[index]);
30433062

30443063
//Bar chart value
3045-
ctrl.PercentValue=_viewBuffer[index]*100/256;
3064+
c.PercentValue=_viewBuffer[index]*100/256;
30463065

3047-
skipNextIsMTE=ctrl.IsMTE;
3066+
skipNextIsMTE=c.IsMTE;
30483067

30493068
if(AllowVisualByteAddress&&nextPos>VisualByteAdressStop)
3050-
ctrl.Clear();
3069+
c.Clear();
30513070
}
30523071
else
30533072
{
30543073
skipNextIsMTE=false;
3055-
ctrl.Clear();
3074+
c.Clear();
30563075
}
30573076
}
30583077
else
3059-
ctrl.Clear();
3078+
c.Clear();
30603079

3061-
ctrl.InternalChange=false;
3080+
c.InternalChange=false;
30623081
index++;
30633082
});
30643083

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp