示例#1
0
 public static List<DEngine> FromNotebook(string fileName, UndoRedoArea undoRedoArea, out Dictionary<string, byte[]> attachments)
 {
     List<DEngine> result = new List<DEngine>();
     // create notebook converter
     Notebook nbk = new Notebook(fileName);
     XmlDocument manifest = nbk.GetManifest();
     // create engine for each page
     List<string> pageEntries = nbk.GetPageEntries(manifest);
     foreach (string entry in pageEntries)
     {
         DEngine de = new DEngine(undoRedoArea);
         XmlDocument page = nbk.GetPage(entry);
         if (page != null)
         {
             nbk.AddPageToEngine(page, de);
             result.Add(de);
         }
     }
     // read attachments
     attachments = new Dictionary<string, byte[]>();
     List<string> attachmentEntries = nbk.GetAttachmentEntries(manifest);
     foreach (string entry in attachmentEntries)
     {
         byte[] attachmentData = nbk.GetAttachment(entry);
         if (attachmentData != null)
             attachments.Add(entry, attachmentData);
     }
     // free notebook
     nbk = null;
     GC.Collect();
     // return engine/pages
     return result;
 }
示例#2
0
		public Command(string caption, UndoRedoArea parentArea, bool visible)
        {
            Caption = caption;
			this.parentArea = parentArea;
			this.Visible = visible;
			changes = new Dictionary<IUndoRedoMember, IChange>();
        }
示例#3
0
        private IDisposable Start(bool visible)
        {
            currentArea = this;
            Command command = new Command(this, visible);

            PushCommand(command);
            return(command);
        }
示例#4
0
		private static void InitDefaultArea()
		{
			defaultArea = new UndoRedoArea("#Default");
			defaultArea.CommandDone += delegate(object sender, CommandDoneEventArgs type)
			{
				if (CommandDone != null)
					CommandDone(sender, type);
			};
		}
 private static void InitDefaultArea()
 {
     defaultArea              = new UndoRedoArea("#Default");
     defaultArea.CommandDone += delegate(object sender, CommandDoneEventArgs type)
     {
         if (CommandDone != null)
         {
             CommandDone(sender, type);
         }
     };
 }
示例#6
0
		public Command(UndoRedoArea parentArea, bool visible)
        {
			this.parentArea = parentArea;
			this.Visible = visible;
			changes = new Dictionary<IUndoRedoMember, IChange>();
        }
示例#7
0
 public DEngine(UndoRedoArea area)
 {
     // setup undo/redo manager
     if (area == null)
         undoRedoArea = new UndoRedoArea("");
     else
         undoRedoArea = area;
     undoRedoArea.CommandDone += new EventHandler<CommandDoneEventArgs>(undoRedoArea_CommandDone);
     // create viewer handler
     viewerHandler = new DViewerHandler();
     viewerHandler.MouseMove += new DMouseMoveEventHandler(viewerHandler_MouseMove);
     viewerHandler.MouseDown += new DMouseButtonEventHandler(viewerHandler_MouseDown);
     viewerHandler.MouseUp += new DMouseButtonEventHandler(viewerHandler_MouseUp);
     // create figure handler
     figureHandler = new DFigureHandler();
     figureHandler.SelectedFiguresChanged += new SelectedFiguresHandler(DoSelectedFiguresChanged);
     figureHandler.AddedFigure += delegate(DEngine de, Figure fig, bool fromHsm)
     {
         if (AddedFigure != null)
             AddedFigure(this, fig, fromHsm);
     };
     // create state machine
     hsm = new DHsm(undoRedoArea, viewerHandler, figureHandler);
     #if DEBUG
     hsm.DebugMessage += new DebugMessageHandler(hsm_DebugMessage);
     #endif
     hsm.FigureClick += new ClickHandler(hsm_FigureClick);
     hsm.FigureContextClick += new ClickHandler(hsm_FigureContextClick);
     hsm.FigureLockClick += new ClickHandler(hsm_FigureLockClick);
     hsm.ContextClick += new ClickHandler(hsm_ContextClick);
     hsm.DragFigureStart += new DragFigureHandler(hsm_DragFigureStart);
     hsm.DragFigureEvt += new DragFigureHandler(hsm_DragFigureEvt);
     hsm.DragFigureEnd += new DragFigureHandler(hsm_DragFigureEnd);
     hsm.MeasureRect += new SelectMeasureHandler(hsm_MeasureRect);
     hsm.StateChanged += new HsmStateChangedHandler(hsm_StateChanged);
     hsm.TextCut += new HsmTextHandler(hsm_TextCut);
     hsm.TextCopy += new HsmTextHandler(hsm_TextCopy);
 }
示例#8
0
 private IDisposable Start(string commandCaption, bool visible)
 {
     AssertNoCommand();
     currentArea = this;
     currentCommand = new Command(commandCaption, this, visible);
     return currentCommand;
 }
示例#9
0
 public static List<DEngine> Load(string fileName, UndoRedoArea undoRedoArea, out DPoint pageSize, out BackgroundFigure bf, string[] extraEntryDirs, out Dictionary<string, byte[]> extraEntries)
 {
     System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
     pageSize = null;
     bf = null;
     extraEntries = null;
     List<DEngine> res = new List<DEngine>();
     // load zipfile
     using (ZipFile zf = new ZipFile(fileName))
     {
         // find pages ini file entry
         byte[] data = Read(zf, PAGES_INI);
         if (data != null)
         {
             // read general background figure
             byte[] genBkgndFigureData = Read(zf, GENBKGNDFIGURE);
             if (genBkgndFigureData != null)
             {
                 List<Figure> figs = FigureSerialize.FromXml(encoding.GetString(genBkgndFigureData));
                 if (figs.Count == 1 && figs[0] is BackgroundFigure)
                 {
                     LoadImage(zf, figs[0]);
                     bf = (BackgroundFigure)figs[0];
                     // read page size from background figure
                     if (bf.Width > 0 && bf.Height > 0)
                         pageSize = new DPoint(bf.Width, bf.Height);
                 }
             }
             // create Nini config source from pages ini entry stream
             IniConfigSource source = new IniConfigSource(new MemoryStream(data));
             // load each page info mentioned in ini entry
             foreach (IConfig config in source.Configs)
             {
                 // create new DEngine for page
                 DEngine de = new DEngine(undoRedoArea);
                 // set page size
                 if (config.Contains(PAGESIZE))
                     de.PageSize = DPoint.FromString(config.Get(PAGESIZE));
                 if (config.Contains(PAGENAME))
                     de.PageName = config.Get(PAGENAME);
                 // set the figures
                 if (config.Contains(FIGURELIST))
                 {
                     string figureListEntryName = config.Get(FIGURELIST);
                     data = Read(zf, figureListEntryName);
                     if (data != null)
                     {
                         List<Figure> figs = FigureSerialize.FromXml(encoding.GetString(data));
                         foreach (Figure f in figs)
                         {
                             de.AddFigure(f);
                             LoadImage(zf, f);
                         }
                     }
                 }
                 // set the background figure
                 if (config.Contains(BACKGROUNDFIGURE))
                 {
                     string backgroundFigureEntryName = config.Get(BACKGROUNDFIGURE);
                     data = Read(zf, backgroundFigureEntryName);
                     if (data != null)
                     {
                         List<Figure> figs = FigureSerialize.FromXml(encoding.GetString(data));
                         if (figs.Count == 1 && figs[0] is BackgroundFigure)
                         {
                             LoadImage(zf, figs[0]);
                             de.SetBackgroundFigure((BackgroundFigure)figs[0], true);
                         }
                     }
                 }
                 else if (bf != null)
                     de.SetBackgroundFigure(bf, false);
                 // add to list of DEngines
                 res.Add(de);
             }
             // read extra entries
             if (extraEntryDirs != null)
             {
                 extraEntries = new Dictionary<string, byte[]>();
                 foreach (string dir in extraEntryDirs)
                 {
                     IEnumerator en = zf.GetEnumerator();
                     en.Reset();
                     while (en.MoveNext())
                     {
                         ZipEntry entry = (ZipEntry)en.Current;
                         if (entry.Name.IndexOf(dir) == 0)
                             extraEntries.Add(entry.Name, Read(zf, entry.Name));
                     }
                 }
             }
         }
     }
     return res;
 }
示例#10
0
 public IImage()
 {
     Manager = new UndoRedoArea("IImage");
 }
示例#11
0
 public Command(UndoRedoArea parentArea, bool visible)
 {
     this.parentArea = parentArea;
     this.Visible    = visible;
     changes         = new Dictionary <IUndoRedoMember, IChange>();
 }
示例#12
0
文件: DHsm.cs 项目: djpnewton/ddraw
 public DHsm(UndoRedoArea undoRedoArea, DViewerHandler viewerHandler, DFigureHandler figureHandler)
     : base()
 {
     // undo redo manager
     this.undoRedoArea = undoRedoArea;
     // viewer handler
     this.viewerHandler = viewerHandler;
     viewerHandler.NeedRepaint += new DPaintEventHandler(dv_NeedRepaint);
     viewerHandler.MouseDown += new DMouseButtonEventHandler(dv_MouseDown);
     viewerHandler.MouseMove += new DMouseMoveEventHandler(dv_MouseMove);
     viewerHandler.MouseUp += new DMouseButtonEventHandler(dv_MouseUp);
     viewerHandler.DoubleClick += new DMouseMoveEventHandler(dv_DoubleClick);
     viewerHandler.KeyDown += new DKeyEventHandler(dv_KeyDown);
     viewerHandler.KeyPress += new DKeyPressEventHandler(dv_KeyPress);
     viewerHandler.KeyUp += new DKeyEventHandler(dv_KeyUp);
     // figure handler
     this.figureHandler = figureHandler;
     // QHsm Init
     Init();
 }
示例#13
0
 private IDisposable Start(string commandCaption, bool visible)
 {
     _currentArea = this;
     Command command = new Command(commandCaption, this, visible);
     PushCommand(command);
     return command;
 }
示例#14
0
		private IDisposable Start(bool visible)
		{
            
			currentArea = this;
			Command command = new Command(this, visible);
			PushCommand(command);
			return command;
		}
示例#15
0
 public Command(string caption, UndoRedoArea parentArea, bool visible)
 {
     Caption = caption;
     this.parentArea = parentArea;
     this.Visible = visible;
 }