public void Reset() { _running = false; _timer.Stop(); _timer.Interval = 0xfffffff; _timer.Tick -= TimerElapsed; if (_stillStartTimer.Enabled) { _stillStartTimer.Stop(); _stillStartTimer.Interval = 0xfffffff; _stillStartTimer.Tick -= StillStartElapsed; } if (Tick != null && _tickHandler != null) { Tick -= _tickHandler; _tickHandler = null; } _start.Reset(); _end.Reset(); _current.Reset(); _startTime = _endTime = DateTime.Now; _progress = 0.0f; _frameCount = 0; _rotation = 0.0f; _deltaWidth = _deltaHeight = 0; _translation = new Vector2(); }
// This runs on FileSystemWatcher thread public bool OnPageFileRenamed(FileInfoEx oldPath, FileInfoEx newPath) { ImageViewingParams ivp = new ImageViewingParams(); ivp.Reset(); BblPage oldPage = null; BblPage newPage = null; if (IsPopulated) { oldPage = _pages.Where(x => x.Path == oldPath.FullName).FirstOrDefault(); ivp = oldPage.Ivp; newPage = new BblPage(this); newPage.SetInfo(newPath); Application.Current.Dispatcher.BeginInvokeIfRequired( DispatcherPriority.Normal, new Action(() => { lock (_lock) { _pages.Remove(oldPage); int idx = 0; for (; idx < _pages.Count; idx++) { if (Utils.SafeNativeMethods.StrCmpLogicalW(_pages[idx].Filename, newPath.Name) >= 0) { break; } } _pages.Insert(idx, newPage); } })); } if ((ivp != null && ivp.isDirty) || (_ivps != null && _ivps.TryGetValue(oldPath.Name, out ivp))) { ivp.filename = newPath.Name; if (newPage != null) { lock (newPage._lock) newPage.Ivp = ivp; } if (_ivps != null) { _ivps.Remove(oldPath.Name); if (!_ivps.ContainsKey(newPath.Name)) { try { _ivps.Add(newPath.Name, ivp); } catch (System.ArgumentException e) { if ((UInt32)e.HResult != 0x80070057) { Console.WriteLine(e.Message); } } catch (Exception x) { Console.WriteLine(x.Message); } } } } return(false); }