public FigureStylePopup(int x, int y, Type figureClass, DAuthorProperties dap, bool antiAlias) : base(x, y) { this.figureClass = figureClass; this.dap = dap; // create the viewer vc = new WFViewerControl(); vc.Parent = this; vc.Dock = DockStyle.Fill; dv = new WFViewer(vc); dv.Preview = true; dv.AntiAlias = antiAlias; // create the DEngine de = new DEngine(null); de.AddViewer(dv); // set page height to viewer size de.UndoRedo.Start("blah"); de.PageSize = new DPoint(vc.Width, vc.Height); de.UndoRedo.Commit(); // add the figure WorkBookUtils.PreviewFigure(de, dv, figureClass, dap, new DPoint(vc.Width, vc.Height)); // buttons Panel pnlTop = new Panel(); pnlTop.Dock = DockStyle.Top; pnlTop.Height = 25; pnlTop.Parent = this; Button btnEdit = new Button(); btnEdit.FlatStyle = FlatStyle.Popup; btnEdit.Text = "Edit"; btnEdit.Location = new Point(1, 1); btnEdit.Parent = pnlTop; btnEdit.Click += new EventHandler(btnEdit_Click); }
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 Preview AddPreview(DEngine de, DViewer dv, DEngine sibling) { // suspend layout SuspendLayout(); // index of new preview int idx; if (sibling != null) idx = GetPreviewIndex(sibling) + 1; else idx = Controls.Count; // create preview Preview p = new Preview(de); p.Parent = this; Controls.SetChildIndex(p, idx); // set preview properties p.Height = PreviewHeight; SetPreviewPositions(); p.Click += new EventHandler(p_Click); p.PreviewContext += new PreviewContextHandler(p_PreviewContext); p.PreviewMove += new PreviewMoveHandler(p_PreviewMove); p.PreviewFigureDrop += new PreviewFigureDropHandler(p_PreviewFigureDrop); p.PreviewNameChanged += new PreviewNameChangedHandler(p_PreviewNameChanged); p.DragOver += new DragEventHandler(p_DragOver); // select it p.Selected = true; DoPreviewSelected(p); // resume layout ResumeLayout(); // return p return p; }
public AnnotationForm() { InitializeComponent(); // screen size Size screenSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); // get screen cap Bitmap bmp = new Bitmap(screenSize.Width, screenSize.Height); Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(0, 0, 0, 0, screenSize); g.Dispose(); // create dv & de dv = new WFViewer(wfViewerControl1); dv.Preview = true; dv.EditFigures = true; dv.AntiAlias = true; de = new DEngine(null); de.AddedFigure += new AddedFigureHandler(de_AddedFigure); de.AddViewer(dv); WorkBookUtils.SetupDEngine(de); // setup undo/redo sensitive stuff de.UndoRedo.Start("initial setup"); de.PageSize = new DPoint(screenSize.Width, screenSize.Height); BackgroundFigure bf = new BackgroundFigure(); // background figure bf.ImageData = WFHelper.ToImageData(bmp); bf.FileName = "screen_capture.png"; bf.BitmapPosition = DBitmapPosition.Normal; de.SetBackgroundFigure(bf, true); de.UndoRedo.Commit(); de.UndoRedo.ClearHistory(); // set form to full screen Location = new Point(0, 0); Size = screenSize; }
public void AddPageToEngine(XmlDocument page, DEngine de) { // svg namespace XmlNamespaceManager nsmgr = new XmlNamespaceManager(page.NameTable); nsmgr.AddNamespace("svg", svgNs); bool hasSvgNs = HasSvgNamespace(page); // set de page size int width; int height; int.TryParse(page.DocumentElement.Attributes.GetNamedItem("width").Value, out width); int.TryParse(page.DocumentElement.Attributes.GetNamedItem("height").Value, out height); if (width == 0 || height == 0) de.PageSize = new DPoint(800, 600); else de.PageSize = new DPoint(width, height); // node list XmlNodeList nl; // find page name if (hasSvgNs) nl = page.SelectNodes("/svg:svg/svg:title", nsmgr); else nl = page.SelectNodes("/svg/title"); if (nl.Count == 1 && nl[0].InnerText != null) de.PageName = nl[0].InnerText; // find background if (hasSvgNs) nl = page.SelectNodes("/svg:svg/svg:rect", nsmgr); else nl = page.SelectNodes("/svg/rect"); if (nl.Count == 1) { SvgElement rect = SvgFactory.LoadFromXML(page, (XmlElement)nl[0]); Figure f = SvgElementToFigure(rect); if (f is RectFigure) { BackgroundFigure bf = new BackgroundFigure(); bf.Fill = ((RectFigure)f).Fill; de.SetBackgroundFigure(bf, true); } } // try to find foreground group if (hasSvgNs) nl = page.SelectNodes("/svg:svg/svg:g[@class='foreground']", nsmgr); else nl = page.SelectNodes("/svg/g[@class='foreground']"); // convert svg elements to figures and add them to DEngine if (nl.Count == 1) { SvgElement root = SvgFactory.LoadFromXML(page, (XmlElement)nl[0]); foreach (SvgElement e in root.Children) { Figure f = SvgElementToFigure(e); if (f != null) de.AddFigure(f); } } }
public PtButtonForm() { InitializeComponent(); dv = new WFViewer(vcCustomFigure); dv.EditFigures = false; dv.AntiAlias = true; dv.Preview = true; de = new DEngine(null); de.AddViewer(dv); // set page height to viewer size de.UndoRedo.Start("blah"); de.PageSize = new DPoint(vcCustomFigure.Width, vcCustomFigure.Height); de.UndoRedo.Commit(); // default to toolbutton edit SetupToolButtonEdit(); }
public ExportForm(string docFileName, IList<DEngine> engines, DEngine current) { InitializeComponent(); LocalizeUI(); // this.docFileName = docFileName; this.engines = engines; this.current = current; // select starting options rbPDF.Checked = true; rbCurrent.Checked = true; // fill lbPageSelect lbPageSelect.Items.Clear(); for (int i = 1; i <= engines.Count; i++) lbPageSelect.Items.Add(i); lbPageSelect.Enabled = false; }
public PropertiesForm() { InitializeComponent(); LocalizeUI(); dv = new WFViewer(vc); dv.EditFigures = false; dv.AntiAlias = true; dv.Preview = true; de = new DEngine(null); de.AddViewer(dv); // set page height to viewer size de.UndoRedo.Start("blah"); de.PageSize = new DPoint(vc.Width, vc.Height); de.UndoRedo.Commit(); tsFigureProps.De = de; tsFigureProps.Dv = dv; }
void AnnoTools_ImportAnnotationsPage(DEngine de) { // progress form ProgressForm pf = new ProgressForm(); pf.Text = WbLocale.ImportingScreenAsPage; pf.Shown += delegate(object s, EventArgs e) { Application.DoEvents(); // import annotations undoRedoArea.Start(WbLocale.ImportAnnotations); CreateDEngine(this.de); this.de.PageSize = de.PageSize; this.de.SetBackgroundFigure(de.BackgroundFigure, true); foreach (Figure f in de.Figures) this.de.AddFigure(f); undoRedoArea.Commit(); // make sure previews line up properly previewBar1.ResetPreviewPositions(); // close dialog pf.Close(); }; pf.ShowDialog(); }
private void SetEnginePageSize(DEngine de, DPoint pageSize) { de.PageSize = pageSize; foreach (Figure fig in de.Figures) WorkBookUtils.PutInBounds(de, fig); }
private void actPrint_Execute(object sender, EventArgs e) { if (engines.Count > 0) { PrintDialog pf = new PrintDialog(); pf.UseEXDialog = true; pf.AllowSelection = false; if (engines.Count > 1) { pf.AllowCurrentPage = true; pf.AllowSomePages = true; pf.PrinterSettings.MinimumPage = 1; pf.PrinterSettings.MaximumPage = engines.Count; pf.PrinterSettings.FromPage = 1; pf.PrinterSettings.ToPage = engines.Count; } if (pf.ShowDialog() == DialogResult.OK) { DPrintViewer dvPrint = new DPrintViewer(); // page iteration vars IEnumerator<DEngine> engineEnumerator = engines.GetEnumerator(); engineEnumerator.MoveNext(); int pageIdx = pf.PrinterSettings.FromPage - 1; // print document settings PrintDocument pd = new PrintDocument(); pd.PrinterSettings = pf.PrinterSettings; pd.DocumentName = Path.GetFileNameWithoutExtension(fileName); pd.PrintPage += delegate(object s2, PrintPageEventArgs e2) { // set DEngine/page to print and whether we have more pages to go DEngine de = null; switch (pd.PrinterSettings.PrintRange) { case PrintRange.CurrentPage: e2.HasMorePages = false; de = this.de; break; case PrintRange.SomePages: de = engines[pageIdx]; pageIdx += 1; e2.HasMorePages = pageIdx < pd.PrinterSettings.ToPage; break; default: // PrintRange.AllPages de = engineEnumerator.Current; e2.HasMorePages = engineEnumerator.MoveNext(); break; } // print the page using the e2.Graphics GDI+ object dvPrint.SetPageSize(de.PageSize); WFPrintSettings dps = new WFPrintSettings(e2.PageSettings); DGraphics dg = WFHelper.MakePrintGraphics(e2.Graphics); dvPrint.Paint(dg, dps, de.BackgroundFigure, de.Figures); dg.Dispose(); }; // call print operation pd.Print(); } } }
void InitDEngine(DEngine de, bool showIt) { // DEngine settings WorkBookUtils.SetupDEngine(de); // DEngine events #if DEBUG de.DebugMessage += new DebugMessageHandler(DebugMessage); #endif de.HsmStateChanged += new HsmStateChangedHandler(de_HsmStateChanged); de.SelectedFiguresChanged += new SelectedFiguresHandler(de_SelectedFiguresChanged); de.FigureClick += new ClickHandler(de_FigureClick); de.FigureContextClick += new ClickHandler(de_ContextClick); de.FigureLockClick += new ClickHandler(de_FigureLockClick); de.ContextClick += new ClickHandler(de_ContextClick); de.DragFigureStart += new DragFigureHandler(de_DragFigureStart); de.DragFigureEvt += new DragFigureHandler(de_DragFigureEvt); de.DragFigureEnd += new DragFigureHandler(de_DragFigureEnd); de.MouseDown += new DMouseButtonEventHandler(de_MouseDown); de.AddedFigure += new AddedFigureHandler(de_AddedFigure); de.TextCopy += new HsmTextHandler(de_TextCopy); de.TextCut += new HsmTextHandler(de_TextCut); // add default properties to figures foreach (Figure f in de.Figures) AddDefaultProperties(f); // show it if (showIt) SetCurrentDe(de); }
private void SetCurrentDe(DEngine de) { if (this.de != null) { this.de.RemoveViewer(dvEditor); if (this.de.CurrentFigureClass != null) de.HsmSetStateByFigureClass(this.de.CurrentFigureClass); else de.HsmState = DHsmState.Select; } de.AddViewer(dvEditor); if (dvEditor.Zoom != Zoom.Custom) dvEditor.Zoom = dvEditor.Zoom; dvEditor.Update(); this.de = de; de_SelectedFiguresChanged(); UpdateUndoRedoActions(); // update toolstrips tsEngineState.De = de; tsPropState.De = de; // null textInsertionPoint textInsertionPoint = null; // personal toolbar tsPersonal.De = de; // set grid options SetGridOptionsForCurrentDe(); }
void de_ContextClick(DEngine de, Figure clickedFigure, DPoint pt) { // create popup Menu pop = new Menu(); MenuItem mi; if (clickedFigure == null) { // page zoom menu items mi = new MenuItem("Fit to Page"); mi.ButtonPressEvent += new ButtonPressEventHandler(miFitToPage_ButtonPressEvent); pop.Append(mi); mi = new MenuItem("Fit to Width"); mi.ButtonPressEvent += new ButtonPressEventHandler(miFitToWidth_ButtonPressEvent); pop.Append(mi); mi = new MenuItem("50%"); mi.ButtonPressEvent += new ButtonPressEventHandler(mi050pc_ButtonPressEvent); pop.Append(mi); mi = new MenuItem("100%"); mi.ButtonPressEvent += new ButtonPressEventHandler(mi100pc_ButtonPressEvent); pop.Append(mi); mi = new MenuItem("150%"); mi.ButtonPressEvent += new ButtonPressEventHandler(mi150pc_ButtonPressEvent); pop.Append(mi); mi = new MenuItem("Print"); mi.ButtonPressEvent += new ButtonPressEventHandler(miPrint_ButtonPressEvent); pop.Append(mi); } else { // group menu items List<Figure> figs = de.SelectedFigures; if (de.CanGroupFigures(figs)) { mi = new MenuItem("Group"); mi.ButtonPressEvent += new ButtonPressEventHandler(miGroup_ButtonPressEvent); pop.Append(mi); } else if (de.CanUngroupFigures(figs)) { mi = new MenuItem("Ungroup"); mi.ButtonPressEvent += new ButtonPressEventHandler(miUngroup_ButtonPressEvent); pop.Append(mi); } } // show popup if (pop.Children.Length > 0) { pop.Popup(); pop.ShowAll(); } }
void de_TextCut(DEngine de, string text) { if (text != null) Clipboard.SetText(text); }
void de_HsmStateChanged(DEngine de, DHsmState state) { // set button checked btnSelect.Checked = state == DHsmState.Select; btnPen.Checked = de.HsmCurrentFigClassIs(typeof(PolylineFigure)); btnRect.Checked = de.HsmCurrentFigClassIs(typeof(RectFigure)); btnEllipse.Checked = de.HsmCurrentFigClassIs(typeof(EllipseFigure)); btnTextBox.Checked = de.HsmCurrentFigClassIs(typeof(TextBoxFigure)); btnText.Checked = state == DHsmState.DrawText; btnClock.Checked = de.HsmCurrentFigClassIs(typeof(ClockFigure)); btnTriangle.Checked = de.HsmCurrentFigClassIs(typeof(TriangleFigure)); btnRATriangle.Checked = de.HsmCurrentFigClassIs(typeof(RightAngleTriangleFigure)); btnDiamond.Checked = de.HsmCurrentFigClassIs(typeof(DiamondFigure)); btnPentagon.Checked = de.HsmCurrentFigClassIs(typeof(PentagonFigure)); btnLine.Checked = de.HsmCurrentFigClassIs(typeof(LineFigure2)); btnEraser.Checked = state == DHsmState.Eraser; // update dap foreach (ToolStripButton btn in Items) if (btn.Checked) { dap = DapFromButton(btn); if (DapChanged != null) DapChanged(this, dap); break; } }
void de_AddedFigure(DEngine de, Figure fig, bool fromHsm) { if (fromHsm) dap.ApplyPropertiesToFigure(fig); }
void de_DragFigureEvt(DEngine de, Figure dragFigure, DPoint pt) { if (pt.X < 0 || pt.Y < 0 || pt.X > wfvcEditor.Width || pt.Y > wfvcEditor.Height) { de.CancelFigureDrag(); dvEditor.Update(); wfvcEditor.DoDragDrop(de.SelectedFigures, DragDropEffects.Move); } }
void De_HsmStateChanged(DEngine de, DHsmState state) { de.HsmStateChanged -= De_HsmStateChanged; btnImportArea.Checked = false; }
void de_DragFigureEnd(DEngine de, Figure dragFigure, DPoint pt) { }
void de_ContextClick(DEngine de, Figure clickedFigure, DPoint pt) { if (clickedFigure != null) cmsFigure.Show(wfvcEditor, new Point((int)pt.X, (int)pt.Y)); else cmsCanvas.Show(wfvcEditor, new Point((int)pt.X, (int)pt.Y)); }
void de_AddedFigure(DEngine de, Figure fig, bool fromHsm) { if (fromHsm) tsEngineState.Dap.ApplyPropertiesToFigure(fig); AddDefaultProperties(fig); }
void CreateDEngine(DEngine sibling) { DEngine de = new DEngine(undoRedoArea); if (sibling != null) { int idx = engines.IndexOf(sibling); if (idx >= 0) engines.Insert(idx + 1, de); else engines.Add(de); } else engines.Add(de); // page size and name de.PageSize = NewPageSize; de.PageName = engines.Count.ToString(); // background figure if (BackgroundFigure != null && !de.CustomBackgroundFigure) de.SetBackgroundFigure(BackgroundFigure, false); // InitDEngine(de, true); }
public MainWindow() : base("MainWindow") { // create the table and pack into the window Table table = new Table(2, 3, false); Add(table); // Initialze DGraphics GTKHelper.InitGraphics(); // create DViewerControl and attach to table GTKViewerControl dvc = new GTKViewerControl(); table.Attach(dvc, 0, 1, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill | AttachOptions.Expand, 0, 0); // create the scrollbars and pack into the table VScrollbar vsb = new VScrollbar(null); table.Attach(vsb, 1, 2, 0, 1, AttachOptions.Fill|AttachOptions.Shrink, AttachOptions.Fill|AttachOptions.Shrink, 0, 0); HScrollbar hsb = new HScrollbar(null); table.Attach(hsb, 0, 1, 1, 2, AttachOptions.Fill|AttachOptions.Shrink, AttachOptions.Fill|AttachOptions.Shrink, 0, 0); // tell the scrollbars to use the DViewerControl widget's adjustments vsb.Adjustment = dvc.Vadjustment; hsb.Adjustment = dvc.Hadjustment; // create debuging label l = new Label("debug"); table.Attach(l, 0, 1, 2, 3, AttachOptions.Fill|AttachOptions.Shrink, AttachOptions.Fill|AttachOptions.Shrink, 0, 0); // create DViewer and DEngine dv = new GTKViewer(dvc); dv.EditFigures = true; #if DEBUG dv.DebugMessage += new DebugMessageHandler(DebugMessage); #endif de = new DEngine(null); de.AddViewer(dv); de.HsmState = DHsmState.Select; #if DEBUG de.DebugMessage += new DebugMessageHandler(DebugMessage); #endif de.ContextClick += new ClickHandler(de_ContextClick); // add figures de.UndoRedo.Start("add initial figures"); de.AddFigure(new EllipseFigure(new DRect(20, 30, 100, 100), 0)); RectFigure rf = new RectFigure(new DRect(10, 20, 100, 100), 0); rf.Alpha = 0.7; rf.Fill = new DColor(80, 80, 80); de.AddFigure(rf); TextFigure tf = new TextFigure(new DPoint(150, 30), "hello", 0); tf.FontName = "Arial"; tf.Underline = true; tf.Strikethrough = true; tf.Italics = true; de.AddFigure(tf); // compositing figure Figure f = new CompositedExampleFigure(); f.Rect = new DRect(20, 150, 50, 50); de.AddFigure(f); // clock (IEditable) figure f = new ClockFigure(); f.Rect = new DRect(200, 200, 100, 100); de.AddFigure(f); // triangle figure f = new TriangleFigure(); f.Rect = new DRect(200, 100, 100, 100); ((TriangleFigure)f).StrokeWidth = 10; de.AddFigure(f); // line figure f = new LineFigure2(new DPoint(100, 100), new DPoint(200, 200)); ((LineFigure2)f).StrokeStyle = DStrokeStyle.DashDot; ((LineFigure2)f).StrokeWidth = 5; de.AddFigure(f); de.UndoRedo.Commit(); de.UndoRedo.ClearHistory(); // resize window Resize(400, 300); }
void de_HsmStateChanged(DEngine de, DHsmState state) { InitPropertyControlsToDEngine(state); }
void de_FigureLockClick(DEngine de, Figure clickedFigure, DPoint pt) { undoRedoArea.Start(WbLocale.UnlockFigure); clickedFigure.Locked = false; undoRedoArea.Commit(); dvEditor.Update(); }
void de_DragFigureStart(DEngine de, Figure dragFigure, DPoint pt) { }
void de_HsmStateChanged(DEngine de, DHsmState state) { if (state == DHsmState.TextEdit) { actCut.Enabled = true; actCopy.Enabled = true; } if (autoSaveOnSelectState && state == DHsmState.Select) Autosave(state); }
void De_MeasureRect(DEngine de, DRect rect) { de.MeasureRect -= De_MeasureRect; if (ImportAnnotationsArea != null && rect.Width > 0 && rect.Height > 0) { // set haveImportedAnnotations HaveImportedAnnotations = true; // call the ImportAnnotationsArea event passing it the cropped bitmap ImportAnnotationsArea(annotationForm.CaptureImage(rect)); } // select the selection tool annotationForm.De.HsmState = DHsmState.Select; }
void de_FigureClick(DEngine de, Figure clickedFigure, DPoint pt) { if (clickedFigure.UserAttrs.ContainsKey(Links.LinkBody)) ExecLink(clickedFigure); }