예제 #1
0
 void De_HsmStateChanged(DEngine de, DHsmState state)
 {
     de.HsmStateChanged -= De_HsmStateChanged;
     btnImportArea.Checked = false;
 }
예제 #2
0
 void de_HsmStateChanged(DEngine de, DHsmState state)
 {
     InitPropertyControlsToDEngine(state);
 }
예제 #3
0
 void InitPropertyControlsToDEngine(DHsmState state)
 {
     // set default (blank) values for property controls
     DefaultControlProperties();
     // deselect controls
     DeselectControls();
     // update controls based on the state of DEngine
     switch (state)
     {
         case DHsmState.Select:
             // get selected figures
             List<Figure> figs = WorkBookUtils.FlatFigureList(de.SelectedFigures);
             // test to enable property controls
             foreach (Figure f in figs)
                 if (f is IFillable)
                     btnFill.Enabled = true;
             foreach (Figure f in figs)
                 if (f is IStrokeable)
                 {
                     btnStroke.Enabled = true;
                     btnStrokeWidth.Enabled = true;
                     btnStrokeStyle.Enabled = true;
                 }
             foreach (Figure f in figs)
                 if (f is IMarkable)
                 {
                     btnStartMarker.Enabled = true;
                     btnEndMarker.Enabled = true;
                 }
             foreach (Figure f in figs)
                 if (f is IAlphaBlendable)
                     btnAlpha.Enabled = true;
             foreach (Figure f in figs)
                 if (f is ITextable)
                 {
                     btnFontName.Enabled = true;
                     btnFontSize.Enabled = true;
                     btnBold.Enabled = true;
                     btnItalic.Enabled = true;
                     btnUnderline.Enabled = true;
                     btnStrikethrough.Enabled = true;
                 }
             // set property controls to match selected figure/s
             if (figs.Count > 0)
             {
                 btnFill.Color = GetFillMatch(figs);
                 btnStroke.Color = GetStrokeMatch(figs);
                 btnStrokeWidth.Value = (int)Math.Round(GetStrokeWidthMatch(figs));
                 btnStrokeStyle.Value = GetStrokeStyleMatch(figs);
                 btnStartMarker.Value = GetMarkerMatch(figs, true);
                 btnEndMarker.Value = GetMarkerMatch(figs, false);
                 btnAlpha.Value = GetAlphaMatch(figs);
                 btnFontName.Value = GetFontNameMatch(figs);
                 btnFontSize.Value = GetFontSizeMatch(figs);
                 btnBold.Checked = GetBoldMatch(figs);
                 btnItalic.Checked = GetItalicMatch(figs);
                 btnUnderline.Checked = GetUnderlineMatch(figs);
                 btnStrikethrough.Checked = GetStrikethroughMatch(figs);
             }
             break;
         case DHsmState.Eraser:
             break;
         case DHsmState.SelectMeasure:
             break;
         case DHsmState.TextEdit:
             break;
         case DHsmState.FigureEdit:
             break;
         default:
             System.Diagnostics.Debug.Assert(dap != null, "ERROR: \"dap\" is not assigned");
             // enable relavant controls and update values to match dap
             if (de.HsmCurrentFigClassImpls(typeof(IFillable)))
             {
                 btnFill.Enabled = true;
                 btnFill.Color = WFHelper.MakeColor(dap.Fill);
             }
             if (de.HsmCurrentFigClassImpls(typeof(IStrokeable)))
             {
                 btnStroke.Enabled = true;
                 btnStroke.Color = WFHelper.MakeColor(dap.Stroke);
                 btnStrokeWidth.Enabled = true;
                 btnStrokeWidth.Value = (int)dap.StrokeWidth;
                 btnStrokeStyle.Enabled = true;
                 btnStrokeStyle.Value = dap.StrokeStyle;
             }
             if (de.HsmCurrentFigClassImpls(typeof(IMarkable)))
             {
                 btnStartMarker.Enabled = true;
                 btnStartMarker.Value = dap.StartMarker;
                 btnEndMarker.Enabled = true;
                 btnEndMarker.Value = dap.EndMarker;
             }
             if (de.HsmCurrentFigClassImpls(typeof(IAlphaBlendable)))
             {
                 btnAlpha.Enabled = true;
                 btnAlpha.Value = dap.Alpha;
             }
             if (de.HsmCurrentFigClassImpls(typeof(ITextable)))
             {
                 btnFontName.Enabled = true;
                 btnFontName.Value = dap.FontName;
                 btnFontSize.Enabled = true;
                 btnFontSize.Value = dap.FontSize;
                 btnBold.Enabled = true;
                 btnBold.Checked = dap.Bold;
                 btnItalic.Enabled = true;
                 btnItalic.Checked = dap.Italics;
                 btnUnderline.Enabled = true;
                 btnUnderline.Checked = dap.Underline;
                 btnStrikethrough.Enabled = true;
                 btnStrikethrough.Checked = dap.Strikethrough;
             }
             break;
     }
 }
예제 #4
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;
         }
 }
예제 #5
0
파일: MainForm.cs 프로젝트: djpnewton/ddraw
 void Autosave(DHsmState state)
 {
     if (state == DHsmState.Select)
     {
         autoSaveOnSelectState = false;
         _Save(autoSaveFileName);
         autoSaveTimer.Start();
     }
     else
     {
         autoSaveOnSelectState = true;
         autoSaveTimer.Stop();
     }
 }
예제 #6
0
파일: MainForm.cs 프로젝트: djpnewton/ddraw
 void de_HsmStateChanged(DEngine de, DHsmState state)
 {
     if (state == DHsmState.TextEdit)
     {
         actCut.Enabled = true;
         actCopy.Enabled = true;
     }
     if (autoSaveOnSelectState && state == DHsmState.Select)
         Autosave(state);
 }
예제 #7
0
파일: DEngine.cs 프로젝트: djpnewton/ddraw
 void hsm_StateChanged(DEngine de, DHsmState state)
 {
     if (HsmStateChanged != null)
         HsmStateChanged(this, state);
 }
예제 #8
0
 void De_HsmStateChanged(DEngine de, DHsmState state)
 {
     if (state != DHsmState.SelectMeasure)
     {
         de.HsmStateChanged -= De_HsmStateChanged;
         CloseAnnotationForm();
     }
 }