Exemple #1
0
 public void Paint(DGraphics dg, DPrintSettings dps, Figure backgroundFigure, IList<Figure> figures)
 {
     // margin
     dg.Translate(dps.MarginLeft, dps.MarginTop);
     // scale & center
     double pgAreaX = dps.PageWidth - dps.MarginLeft - dps.MarginRight;
     double pgAreaY = dps.PageHeight - dps.MarginTop - dps.MarginBottom;
     double sx = pgAreaX / PageSize.X;
     double sy = pgAreaY / PageSize.Y;
     if (sx > sy)
     {
         dg.Translate(pgAreaX / 2, 0);
         dg.Scale(sy, sy);
         dg.Translate(- PageSize.X / 2, 0);
     }
     else
     {
         dg.Translate(0, pgAreaY / 2);
         dg.Scale(sx, sx);
         dg.Translate(0, - PageSize.Y / 2);
     }
     // paint figures
     base.Paint(dg, backgroundFigure, figures);
     // paint outline
     dg.DrawRect(0, 0, pageSize.X, pageSize.Y, DColor.Black);
 }
Exemple #2
0
 public static DAuthorProperties FromFigure(Figure f)
 {
     DAuthorProperties dap = new DAuthorProperties();
     if (f is IFillable)
         dap.Fill = ((IFillable)f).Fill;
     if (f is IStrokeable)
     {
         dap.Stroke = ((IStrokeable)f).Stroke;
         dap.StrokeWidth = ((IStrokeable)f).StrokeWidth;
         dap.StrokeStyle = ((IStrokeable)f).StrokeStyle;
     }
     if (f is IMarkable)
     {
         dap.StartMarker = ((IMarkable)f).StartMarker;
         dap.EndMarker = ((IMarkable)f).EndMarker;
     }
     if (f is IAlphaBlendable)
         dap.Alpha = ((IAlphaBlendable)f).Alpha;
     if (f is ITextable)
     {
         dap.FontName = ((ITextable)f).FontName;
         dap.FontSize = ((ITextable)f).FontSize;
         dap.Bold = ((ITextable)f).Bold;
         dap.Italics = ((ITextable)f).Italics;
         dap.Underline = ((ITextable)f).Underline;
         dap.Strikethrough = ((ITextable)f).Strikethrough;
     }
     return dap;
 }
Exemple #3
0
 public override void Paint(DGraphics dg, Figure f, double scale)
 {
     dg.DrawBitmap(bmp, GetRect(Position, f.GetSelectRect(), scale));
 }
Exemple #4
0
 public DHitTest HitTest(DPoint pt, Figure f, double scale)
 {
     if (IsVisible(f.Selected))
     {
         if (DGeom.PointInRect(pt, GetRect(pos, f.GetSelectRect(), scale)))
             return DHitTest.Glyph;
     }
     return DHitTest.None;
 }
Exemple #5
0
 void AddDefaultProperties(Figure fig)
 {
     // show context handle
     fig.ContextHandle = true;
     // make sure fig.Glyphs is assigned
     if (fig.Glyphs == null)
         fig.Glyphs = new List<IGlyph>();
     // add link glyph if needed
     CheckLinkGlyph(fig);
     // add behavoiurs
     AddBehaviours(fig);
     // recurse into child figures
     if (fig is GroupFigure)
         foreach (Figure child in ((GroupFigure)fig).ChildFigures)
             AddDefaultProperties(child);
 }
Exemple #6
0
 void linkGlyph_Clicked(IGlyph glyph, Figure figure, DPoint pt)
 {
     ExecLink(figure);
 }
Exemple #7
0
 void de_FigureLockClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     undoRedoArea.Start(WbLocale.UnlockFigure);
     clickedFigure.Locked = false;
     undoRedoArea.Commit();
     dvEditor.Update();
 }
Exemple #8
0
 void de_DragFigureStart(DEngine de, Figure dragFigure, DPoint pt)
 {
 }
Exemple #9
0
 void hsm_FigureLockClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (FigureLockClick != null)
         FigureLockClick(this, clickedFigure, pt);
 }
Exemple #10
0
 void hsm_DragFigureStart(DEngine de, Figure dragFigure, DPoint pt)
 {
     if (DragFigureStart != null)
         DragFigureStart(this, dragFigure, pt);
 }
Exemple #11
0
 void hsm_DragFigureEnd(DEngine de, Figure dragFigure, DPoint pt)
 {
     if (DragFigureEnd != null)
         DragFigureEnd(this, dragFigure, pt);
 }
Exemple #12
0
 void hsm_ContextClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (ContextClick != null)
         ContextClick(this, clickedFigure, pt);
 }
Exemple #13
0
 public void RemoveFigure(Figure f)
 {
     figureHandler.Remove(f);
 }
Exemple #14
0
 // Public Functions //
 public void AddFigure(Figure f)
 {
     figureHandler.Add(f, false);
 }
Exemple #15
0
 public void ApplyPropertiesToFigure(Figure f)
 {
     if (f is IFillable)
         ((IFillable)f).Fill = Fill;
     if (f is IStrokeable)
     {
         ((IStrokeable)f).Stroke = Stroke;
         ((IStrokeable)f).StrokeWidth = StrokeWidth;
         ((IStrokeable)f).StrokeStyle = StrokeStyle;
     }
     if (f is IMarkable)
     {
         ((IMarkable)f).StartMarker = StartMarker;
         ((IMarkable)f).EndMarker = EndMarker;
     }
     if (f is IAlphaBlendable)
         ((IAlphaBlendable)f).Alpha = Alpha;
     if (f is ITextable)
     {
         ((ITextable)f).FontName = FontName;
         ((ITextable)f).FontSize = FontSize;
         ((ITextable)f).Bold = Bold;
         ((ITextable)f).Italics = Italics;
         ((ITextable)f).Underline = Underline;
         ((ITextable)f).Strikethrough = Strikethrough;
     }
 }
Exemple #16
0
 void de_DragFigureEnd(DEngine de, Figure dragFigure, DPoint pt)
 {
 }
Exemple #17
0
 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);
     }
 }
Exemple #18
0
 public void Paint(DGraphics dg, Figure backgroundFigure, IList<Figure> figures, Figure[] controlFigures)
 {
     // set antialias value
     dg.AntiAlias = AntiAlias;
     // draw backround and transform canvas accordind to the pagesize
     if (Preview)
         dg.Scale(Width / PageSize.X, Height / PageSize.Y); // scale to width & height as this is a preview viewer
     else
     {
         dg.FillRect(0, 0, Width, Height, DColor.LightGray, 1); // gray background
         DPoint offset = CanvasOffset();
         dg.Translate(offset.X, offset.Y); // center drawing
         dg.Scale(scale, scale); // scale canvas
         dg.FillRect(SHADOW_OFFSET, SHADOW_OFFSET, PageSize.X, PageSize.Y, DColor.Black, 1); // draw black canvas shadow
     }
     // paint figures
     if (backgroundFigure != null)
     {
         backgroundFigure.Width = PageSize.X;
         backgroundFigure.Height = PageSize.Y;
         backgroundFigure.Paint(dg);
     }
     if (!Preview && Grid > 0)
     {
         for (int i = 1; i < (PageSize.X / Grid); i++)
             dg.DrawLine(new DPoint(i * grid, 0), new DPoint(i * grid, PageSize.Y), DColor.LightGray, 1, DStrokeStyle.Solid, 1, DStrokeCap.Butt);
         for (int i = 1; i < (PageSize.Y / Grid); i++)
             dg.DrawLine(new DPoint(0, i * grid), new DPoint(PageSize.X, i * grid), DColor.LightGray, 1, DStrokeStyle.Solid, 1, DStrokeCap.Butt);
     }
     double invScale = 1 / scale;
     foreach (Figure figure in figures)
     {
         figure._controlScale = invScale;
         figure.GlyphsVisible = editFigures;
         figure.Paint(dg);
     }
     if (editFigures)
     {
         foreach (Figure figure in figures)
             figure.PaintSelectionChrome(dg);
         if (controlFigures != null)
             foreach (Figure figure in controlFigures)
             {
                 figure._controlScale = invScale;
                 figure.Paint(dg);
             }
     }
 }
Exemple #19
0
 void de_FigureClick(DEngine de, Figure clickedFigure, DPoint pt)
 {
     if (clickedFigure.UserAttrs.ContainsKey(Links.LinkBody))
         ExecLink(clickedFigure);
 }
Exemple #20
0
 public void Paint(DGraphics dg, Figure backgroundFigure, IList<Figure> figures)
 {
     // paint figures
     if (backgroundFigure != null)
         backgroundFigure.Paint(dg);
     foreach (Figure figure in figures)
     {
         figure.GlyphsVisible = false;
         figure.Paint(dg);
     }
 }
Exemple #21
0
 void ExecLink(Figure figure)
 {
     if (figure.UserAttrs.ContainsKey(Links.Link) && figure.UserAttrs.ContainsKey(Links.LinkType))
     {
         string link = figure.UserAttrs[Links.Link];
         LinkType linkType = Links.StringToLinkType(figure.UserAttrs[Links.LinkType]);
         switch (linkType)
         {
             case LinkType.WebPage:
                 try
                 {
                     UriBuilder ub = new UriBuilder(link);
                     System.Diagnostics.Process.Start(ub.Uri.AbsoluteUri);
                 }
                 catch (Exception e)
                 { MessageBox.Show(e.Message, WbLocale.WebLinkError, MessageBoxButtons.OK, MessageBoxIcon.Error); }
                 break;
             case LinkType.File:
                 if (File.Exists(link))
                     try
                     {
                         System.Diagnostics.Process.Start(link);
                     }
                     catch (Exception e)
                     { MessageBox.Show(e.Message, WbLocale.FileLinkError, MessageBoxButtons.OK, MessageBoxIcon.Error); }
                 else
                     MessageBox.Show(string.Format("{0} \"{1}\"", WbLocale.CouldNotFindFile, link), WbLocale.FileLinkError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 break;
             case LinkType.Page:
                 LinkPage lp = (LinkPage)Enum.Parse(typeof(LinkPage), link, true);
                 switch (lp)
                 {
                     case LinkPage.First:
                         previewBar1.SetPreviewSelected(engines[0]);
                         break;
                     case LinkPage.Last:
                         previewBar1.SetPreviewSelected(engines[engines.Count - 1]);
                         break;
                     case LinkPage.Next:
                         int idx = engines.IndexOf(de) + 1;
                         if (idx < engines.Count)
                             previewBar1.SetPreviewSelected(engines[idx]);
                         else
                             goto case LinkPage.First;
                         break;
                     case LinkPage.Previous:
                         int idx2 = engines.IndexOf(de) - 1;
                         if (idx2 > 0)
                             previewBar1.SetPreviewSelected(engines[idx2]);
                         else
                             goto case LinkPage.Last;
                         break;
                     default:
                         int n = 0;
                         int.TryParse(link, out n);
                         if (n >= 0 && n < engines.Count)
                             previewBar1.SetPreviewSelected(engines[n]);
                         else
                             MessageBox.Show(string.Format("{0} \"{1}\" {2}", WbLocale.Page, n + 1, WbLocale.DoesNotExist), WbLocale.PageLinkError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                         break;
                 }
                 break;
             case LinkType.Attachment:
                 try
                 {
                     attachmentView1.ExecuteAttachment(link);
                 }
                 catch (Exception e)
                 { MessageBox.Show(e.Message, WbLocale.AttachmentLinkError, MessageBoxButtons.OK, MessageBoxIcon.Error); }
                 break;
         }
     }
 }
Exemple #22
0
 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();
     }
 }
Exemple #23
0
 private void AddBehaviours(Figure fig)
 {
     #if BEHAVIOURS
     if (fig is IBehaviours)
     {
         DBehaviour b = new DBehaviour();
         if (highlightSelection)
         {
             b.SetFill = true;
             b.SetStroke = true;
             b.SetAlpha = true;
             if (fig is IFillable)
             {
                 b.Fill = DColor.Blue50Pc;
                 b.Stroke = DColor.Blue;
             }
             else
                 b.Stroke = DColor.Blue50Pc;
             b.Alpha = 1;
         }
         ((IBehaviours)fig).MouseOverBehaviour = b;
     }
     #endif
 }
Exemple #24
0
 void CheckLinkGlyph(Figure fig)
 {
     if (fig.UserAttrs.ContainsKey(Links.Link) && !fig.UserAttrs.ContainsKey(Links.LinkBody))
     {
         if (!fig.Glyphs.Contains(linkGlyph))
             fig.Glyphs.Insert(0, linkGlyph);
     }
     else
     {
         if (fig.Glyphs.Contains(linkGlyph))
             fig.Glyphs.Remove(linkGlyph);
     }
     fig.ClickEvent = fig.UserAttrs.ContainsKey(Links.LinkBody);
 }
Exemple #25
0
 public void CallClicked(Figure f, DPoint pt)
 {
     if (Clicked != null)
         Clicked(this, f, pt);
 }
Exemple #26
0
 void de_AddedFigure(DEngine de, Figure fig, bool fromHsm)
 {
     if (fromHsm)
         tsEngineState.Dap.ApplyPropertiesToFigure(fig);
     AddDefaultProperties(fig);
 }
Exemple #27
0
 public abstract void Paint(DGraphics dg, Figure f, double scale);
Exemple #28
0
 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));
 }
Exemple #29
0
 void de_AddedFigure(DEngine de, Figure fig, bool fromHsm)
 {
     if (fromHsm)
         dap.ApplyPropertiesToFigure(fig);
 }
Exemple #30
0
 public static void PutInBounds(DEngine de, Figure f)
 {
     // make sure figure is within page bounds
     if (f.Left < 0)
         f.Left = 0;
     else if (f.Right > de.PageSize.X)
         f.Left = de.PageSize.X - f.Width;
     if (f.Top < 0)
         f.Top = 0;
     else if (f.Bottom > de.PageSize.Y)
         f.Top = de.PageSize.Y - f.Height;
 }