Bubbles3/Models/BblBook.cs
/// <summary>
/// Restore image viewing parameters from
/// serialized file.
/// </summary>
Restore image viewing parameters from
serialized file.
Restore image viewing parameters from serialized file .
public virtual void DeserializeIVP()
        {
            if (_ivps != null) throw new InvalidOperationException();
            lock (_lock) {
                _ivps = new Dictionary<string, ImageViewingParams>();
                foreach (var p in _pages)
                {
                    ImageViewingParams ivp = new ImageViewingParams();
                    ivp.filename = p.Filename;
                    if(!_ivps.ContainsKey(p.Filename)) _ivps.Add(p.Filename, ivp);
                }
            }
            if (File.Exists(IvpPath))
            {
                var deserializer = new System.Xml.Serialization.XmlSerializer(typeof(IvpCollection));
                TextReader reader = null;
                IvpCollection XmlData = null;
                object obj = null;
                try
                {
                    reader = new StreamReader(IvpPath);
                    obj = deserializer.Deserialize(reader);
                }
                catch
                {
                    if (reader != null) reader.Close();
                    reader = null;
                    File.Delete(IvpPath);
                }
                finally
                {
                    if (obj != null) XmlData = (IvpCollection)obj;
                    List<ImageViewingParams> ivps = null;
                    if (XmlData != null) ivps = new List<ImageViewingParams>(XmlData.Collection);
                    if (reader != null) reader.Close();
                    if (ivps != null)
                    {
                        lock(_lock)
                        {
                            foreach (var ivp in ivps)
                            {
                                if (ivp.filename == null)
                                    continue;
                                _ivps[ivp.filename] = ivp;
                            }
                        }
                    }
                }
            }
        }
public virtual void DeserializeIVP ( ) { if ( _ivps != null ) throw new InvalidOperationException ( ) ; lock ( _lock ) { _ivps = new Dictionary < string , ImageViewingParams > ( ) ; foreach ( var p in _pages ) { ImageViewingParams ivp = new ImageViewingParams ( ) ; ivp . filename = p . Filename ; if ( ! _ivps . ContainsKey ( p . Filename ) ) _ivps . Add ( p . Filename , ivp ) ; } } if ( File . Exists ( IvpPath ) ) { var deserializer = new System . Xml . Serialization . XmlSerializer ( typeof ( IvpCollection ) ) ; TextReader reader = null ; IvpCollection XmlData = null ; object obj = null ; try { reader = new StreamReader ( IvpPath ) ; obj = deserializer . Deserialize ( reader ) ; } catch { if ( reader != null ) reader . Close ( ) ; reader = null ; File . Delete ( IvpPath ) ; } finally { if ( obj != null ) XmlData = ( IvpCollection ) obj ; List < ImageViewingParams > ivps = null ; if ( XmlData != null ) ivps = new List < ImageViewingParams > ( XmlData . Collection ) ; if ( reader != null ) reader . Close ( ) ; if ( ivps != null ) { lock ( _lock ) { foreach ( var ivp in ivps ) { if ( ivp . filename == null ) continue ; _ivps [ ivp . filename ] = ivp ; } } } } } }
Restore image viewing parameters from
serialized file.
Restore image viewing parameters from serialized file .