Example #1
0
        void UpdateCurrentValue()
        {
            if (wpfHexView.IsClosed)
            {
                return;
            }
            if (!enabled)
            {
                return;
            }

            var  bufferLines = wpfHexView.BufferLines;
            var  pos         = wpfHexView.Caret.Position.Position;
            bool isValues    = pos.ActiveColumn == HexColumnType.Values;
            var  bufferPos   = bufferLines.FilterAndVerify(pos.ActivePosition.BufferPosition);
            var  line        = wpfHexView.Caret.ContainingHexViewLine.BufferLine;
            var  cell        = isValues ? line.ValueCells.GetCell(bufferPos) : line.AsciiCells.GetCell(bufferPos);

            if (savedValue == null || savedValue.Column != pos.ActiveColumn || savedValue.ValuesFormat != bufferLines.ValuesFormat)
            {
                savedValue = new SavedValue(bufferLines.ValuesFormat, isValues ? bufferLines.BytesPerValue : 1, pos.ActivePosition, cell?.BufferSpan ?? new HexBufferSpan(bufferLines.BufferSpan.Start, bufferLines.BufferSpan.Start));
            }
            else if (!savedValue.TryUpdate(pos.ActivePosition, line, cell))
            {
                return;
            }
            RefreshAll();
        }
        // PERF: delay refreshing the changed value to speed up scrolling up/down
        // by eg. holding down PgDown/PgUp.
        void DelayUpdateCurrentValue()
        {
            int delayMs = wpfHexView.Options.GetHighlightCurrentValueDelayMilliSeconds();

            if (delayMs <= 0)
            {
                StopTimer();
                UpdateCurrentValue();
                return;
            }

            if (delayDispatcherTimer == null)
            {
                if (savedValue != null && !TryUpdateCurrentValue())
                {
                    return;
                }
                savedValue = null;
                // Make sure old highlighting gets cleared immediately
                RefreshAll();
            }
            // Always stop and restart the timer so nothing is highlighted if eg. PgDown is held down
            StopTimer();
            delayDispatcherTimer = new DispatcherTimer(DispatcherPriority.Normal, wpfHexView.VisualElement.Dispatcher);
            if (delayMs < 20 || delayMs > 2000)
            {
                delayMs = DefaultHexViewOptions.DefaultHighlightCurrentValueDelayMilliSeconds;
            }
            delayDispatcherTimer.Interval = TimeSpan.FromMilliseconds(delayMs);
            delayDispatcherTimer.Tick    += Timer_Tick;
            delayDispatcherTimer.Start();
        }
Example #3
0
 void Awake() 
 {
     if(instance == null)
     {
         instance = this;
         DontDestroyOnLoad(transform.gameObject);
     }
     else if(instance != this)
     {
         Destroy(this.gameObject);
     }
 }
Example #4
0
 public bool Equals(SavedValue obj)
 {
     return(!(obj == null) && obj.name == name && obj.m_FileName == m_FileName);
 }
Example #5
0
 void UninitializeCurrentValue() => savedValue = null;
Example #6
0
 // Start is called before the first frame update
 void Start()
 {
     Instance   = this;
     Web        = GetComponent <Web>();
     SavedValue = GetComponent <SavedValue>();
 }