Exemple #1
0
 public CustomFigureTool(string label, bool showLabel, Type figureClass, DAuthorProperties dap, string base64Icon)
     : base(label, showLabel)
 {
     FigureClass = figureClass;
     Dap = dap;
     Base64Icon = base64Icon;
 }
Exemple #2
0
 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);
 }
Exemple #3
0
 private void tsEngineState_DapChanged(object sender, DAuthorProperties dap)
 {
     tsPropState.Dap = dap;
     tsPersonal.Dap = dap;
     annotationForm.Dap = dap;
 }
Exemple #4
0
 void dap_PropertyChanged(DAuthorProperties dap)
 {
     UpdateToDap();
 }
Exemple #5
0
 private void ShowFigureStylePopup(ToolStripItem item, Type figureClass, DAuthorProperties dap)
 {
     Point pt = new Point(item.Bounds.Left, item.Bounds.Bottom);
     pt = item.Owner.PointToScreen(pt);
     FigureStylePopup pf = new FigureStylePopup(pt.X, pt.Y, figureClass, dap, true);
     pf.AutoHideTimeout = 2500;
     pf.AddToPersonalTools += new FigureStyleEvent(pf_AddToPersonalTools);
     pf.Show();
 }
Exemple #6
0
 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;
         }
 }
Exemple #7
0
 public void SetProperties(Type figureClass, DAuthorProperties dap)
 {
     if (typeof(IFillable).IsAssignableFrom(figureClass))
         this.fill = dap.Fill;
     if (typeof(IStrokeable).IsAssignableFrom(figureClass))
     {
         this.stroke = dap.Stroke;
         this.strokeWidth = dap.StrokeWidth;
         this.strokeStyle = dap.StrokeStyle;
     }
     if (typeof(IMarkable).IsAssignableFrom(figureClass))
     {
         this.startMarker = dap.StartMarker;
         this.endMarker = dap.EndMarker;
     }
     if (typeof(IAlphaBlendable).IsAssignableFrom(figureClass))
         this.alpha = dap.Alpha;
     if (typeof(ITextable).IsAssignableFrom(figureClass))
     {
         this.fontName = dap.FontName;
         this.fontSize = dap.FontSize;
         this.bold = dap.Bold;
         this.italics = dap.Italics;
         this.underline = dap.Underline;
         this.strikethrough = dap.Strikethrough;
     }
     DoPropertyChanged();
 }
Exemple #8
0
 public void SetProperties(DAuthorProperties dap)
 {
     this.fill = dap.Fill;
     this.stroke = dap.Stroke;
     this.strokeWidth = dap.StrokeWidth;
     this.strokeStyle = dap.StrokeStyle;
     this.startMarker = dap.StartMarker;
     this.endMarker = dap.EndMarker;
     this.alpha = dap.Alpha;
     this.fontName = dap.FontName;
     this.fontSize = dap.FontSize;
     this.bold = dap.Bold;
     this.italics = dap.Italics;
     this.underline = dap.Underline;
     this.strikethrough = dap.Strikethrough;
     DoPropertyChanged();
 }
Exemple #9
0
 public DAuthorProperties Clone()
 {
     DAuthorProperties dap = new DAuthorProperties();
     dap.SetProperties(this);
     return dap;
 }
Exemple #10
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 #11
0
 public static void WriteDapToConfig(DAuthorProperties dap, IConfig config)
 {
     config.Set(FILL_OPT, DColor.FormatToString(dap.Fill));
     config.Set(STROKE_OPT, DColor.FormatToString(dap.Stroke));
     config.Set(STROKEWIDTH_OPT, dap.StrokeWidth);
     config.Set(STROKESTYLE_OPT, dap.StrokeStyle.ToString());
     config.Set(ALPHA_OPT, dap.Alpha);
     config.Set(STARTMARKER_OPT, dap.StartMarker);
     config.Set(ENDMARKER_OPT, dap.EndMarker);
     config.Set(FONTNAME_OPT, dap.FontName);
     config.Set(BOLD_OPT, dap.Bold);
     config.Set(ITALICS_OPT, dap.Italics);
     config.Set(UNDERLINE_OPT, dap.Underline);
     config.Set(STRIKETHROUGH_OPT, dap.Strikethrough);
 }
Exemple #12
0
 public static void ReadConfigToDap(IConfig config, DAuthorProperties dap)
 {
     dap.Fill = DColor.FromString(config.Get(FILL_OPT));
     dap.Stroke = DColor.FromString(config.Get(STROKE_OPT));
     dap.StrokeWidth = config.GetInt(STROKEWIDTH_OPT, 1);
     dap.StrokeStyle = (DStrokeStyle)Enum.Parse(typeof(DStrokeStyle),
         config.Get(STROKESTYLE_OPT, DStrokeStyle.Solid.ToString()), true);
     dap.Alpha = config.GetDouble(ALPHA_OPT, 1);
     dap.StartMarker = (DMarker)Enum.Parse(typeof(DMarker),
         config.Get(STARTMARKER_OPT, DMarker.None.ToString()), true);
     dap.EndMarker = (DMarker)Enum.Parse(typeof(DMarker),
         config.Get(ENDMARKER_OPT, DMarker.None.ToString()), true);
     dap.FontName = config.Get(FONTNAME_OPT, "Arial");
     dap.Bold = config.GetBoolean(BOLD_OPT, false);
     dap.Italics = config.GetBoolean(ITALICS_OPT, false);
     dap.Underline = config.GetBoolean(UNDERLINE_OPT, false);
     dap.Strikethrough = config.GetBoolean(STRIKETHROUGH_OPT, false);
 }
Exemple #13
0
 public static void PreviewFigure(DEngine de, DTkViewer dv, Type figureClass, DAuthorProperties dap, DPoint viewerSize)
 {
     // add figure de so it shows on the viewer
     de.UndoRedo.Start("blah");
     de.ClearPage();
     Figure f = (Figure)Activator.CreateInstance(figureClass);
     dap.ApplyPropertiesToFigure(f);
     if (f is PolylineFigure)
     {
         DPoints pts = new DPoints();
         pts.Add(new DPoint(viewerSize.X / 4.0, viewerSize.Y / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.25 / 4.0, viewerSize.Y * 1.10 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.50 / 4.0, viewerSize.Y * 1.25 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 1.75 / 4.0, viewerSize.Y * 1.50 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.00 / 4.0, viewerSize.Y * 1.75 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.25 / 4.0, viewerSize.Y * 2.00 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.50 / 4.0, viewerSize.Y * 2.25 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 2.75 / 4.0, viewerSize.Y * 2.50 / 4.0));
         pts.Add(new DPoint(viewerSize.X * 3 / 4.0, viewerSize.Y * 3 / 4.0));
         ((PolylineFigure)f).Points = pts;
     }
     else if (f is ITextable)
         ((ITextable)f).Text = "Aa";
     f.Left = viewerSize.X / 4.0;
     f.Top = viewerSize.Y / 4.0;
     f.Width = viewerSize.X / 2.0;
     f.Height = viewerSize.Y / 2.0;
     if (f is TextFigure)
     {
         f.Left = viewerSize.X / 8.0;
         f.Width = viewerSize.X * 3 / 4.0;
     }
     de.AddFigure(f);
     de.UndoRedo.Commit();
     dv.Update();
 }
Exemple #14
0
 public static void LoadPersonalToolsFromSource(PersonalToolStrip ts, IConfigSource source)
 {
     ts.Clear();
     foreach (IConfig config in source.Configs)
         if (config.Contains(TYPE_OPT))
         {
             PersonalToolButtonType type = (PersonalToolButtonType)Enum.Parse(
                 typeof(PersonalToolButtonType), config.Get(TYPE_OPT), true);
             string label = config.Get(LABEL_OPT, "");
             bool showLabel = config.GetBoolean(SHOWLABEL_OPT, false);
             switch (type)
             {
                 case PersonalToolButtonType.CustomFigure:
                     Type figureClass = Type.GetType(config.Get(FIGURECLASS_OPT));
                     if (figureClass != null)
                     {
                         DAuthorProperties dap = new DAuthorProperties();
                         WorkBookUtils.ReadConfigToDap(config, dap);
                         string base64Icon = config.Get(BASE64ICON_OPT);
                         ts.Items.Add(new CustomFigureToolButton(new CustomFigureTool(label, showLabel, figureClass, dap, base64Icon)));
                     }
                     break;
                 case PersonalToolButtonType.RunCmd:
                     ts.Items.Add(new RunCmdToolButton(new RunCmdTool(label, showLabel, config.Get(RUNCMD_OPT),
                         config.Get(ARGS_OPT))));
                     break;
                 case PersonalToolButtonType.ShowDir:
                     ts.Items.Add(new ShowDirToolButton(new ShowDirTool(label, showLabel, config.Get(DIR_OPT))));
                     break;
                 case PersonalToolButtonType.WebLink:
                     ts.Items.Add(new WebLinkToolButton(new WebLinkTool(label, showLabel, config.Get(WEBLINK_OPT))));
                     break;
                 case PersonalToolButtonType.ModeSelect:
                     ts.Items.Add(new ModeSelectToolButton(new ModeSelectTool(label, showLabel,
                         (ModeSelectType)Enum.Parse(typeof(ModeSelectType), config.Get(MODESELECT_OPT), true))));
                     break;
             }
         }
 }
Exemple #15
0
 void Dap_PropertyChanged(DAuthorProperties dap)
 {
     WorkBookUtils.PreviewFigure(de, dv, tsCustomFigureProps.FigureClass, dap,
         new DPoint(vcCustomFigure.Width, vcCustomFigure.Height));
 }