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; }
public Command(string caption, UndoRedoArea parentArea, bool visible) { Caption = caption; this.parentArea = parentArea; this.Visible = visible; changes = new Dictionary<IUndoRedoMember, IChange>(); }
private IDisposable Start(bool visible) { currentArea = this; Command command = new Command(this, visible); PushCommand(command); return(command); }
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); } }; }
public Command(UndoRedoArea parentArea, bool visible) { this.parentArea = parentArea; this.Visible = visible; changes = new Dictionary<IUndoRedoMember, IChange>(); }
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); }
private IDisposable Start(string commandCaption, bool visible) { AssertNoCommand(); currentArea = this; currentCommand = new Command(commandCaption, this, visible); return currentCommand; }
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; }
public IImage() { Manager = new UndoRedoArea("IImage"); }
public Command(UndoRedoArea parentArea, bool visible) { this.parentArea = parentArea; this.Visible = visible; changes = new Dictionary <IUndoRedoMember, IChange>(); }
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(); }
private IDisposable Start(string commandCaption, bool visible) { _currentArea = this; Command command = new Command(commandCaption, this, visible); PushCommand(command); return command; }
private IDisposable Start(bool visible) { currentArea = this; Command command = new Command(this, visible); PushCommand(command); return command; }
public Command(string caption, UndoRedoArea parentArea, bool visible) { Caption = caption; this.parentArea = parentArea; this.Visible = visible; }