Ejemplo n.º 1
0
 public SketchForm( string path )
 {
     if ( !Path.IsPathRooted(path) ) path = Path.Combine(Application.UserAppDataPath,path);
     Book = Book.CreateOrLoad( path );
     BackColor       = Color.White;
     DoubleBuffered  = true;
     ForeColor       = Color.Gray;
     FormBorderStyle = FormBorderStyle.None;
     StartPosition   = FormStartPosition.CenterScreen;
     WindowState     = FormWindowState.Maximized;
     SMM = new StylusMouseMux(this);
 }
Ejemplo n.º 2
0
        public void BackgroundSaveToDisk()
        {
            var clone = new Book()
                { Pages = Pages.Select(page=>page.Clone()).ToList()
                , OpenPageIndex = OpenPageIndex
                , Path = Path
                , SizeInBytes = SizeInBytes
                };
            lock ( Background ) {
                bool spawn_bg_worker = SerializeNext==null;
                if ( spawn_bg_worker ) ThreadPool.QueueUserWorkItem(o=>{
                    Book book = null;
                    lock ( Background ) book = SerializeNext;
                    while ( book != null ) {
                        book.SaveToDisk();
                        lock ( Background ) {
                            SizeInBytes = book.SizeInBytes;
                            SerializeNext = book = (book==SerializeNext) ? null : SerializeNext;

                            if ( book==null ) {
                                foreach ( var d in ToDispose ) using ( d ) {}
                                ToDispose.Clear();
                            }
                        }
                    }
                });
                SerializeNext = clone;
                ToDispose.Add(clone);
            }
        }