/// <summary> /// create BeamSystemParam's subclass according to LayoutMethod /// </summary> /// <param name="layoutType">LayoutMethod</param> /// <returns>created BeamSystemParam's subclass</returns> public static BeamSystemParam CreateInstance(LayoutMethod layoutType) { BeamSystemParam param = null; switch (layoutType) { case LayoutMethod.ClearSpacing: param = new ClearSpacingParam(); break; case LayoutMethod.FixedDistance: param = new FixedDistanceParam(); break; case LayoutMethod.FixedNumber: param = new FixedNumberParam(); break; case LayoutMethod.MaximumSpacing: param = new MaximumSpacingParam(); break; default: break; } // it is absolutely impossible unless layoutType is wrong Debug.Assert(null != param); return(param); }
private void PopulateLayoutList() { this.BackColor = SystemColors.Control; _layoutChoices.Controls.Clear(); _layoutChoices.RowCount = 0; _layoutChoices.RowStyles.Clear(); foreach (LayoutMethod choice in _model.GetLayoutChoices()) { var button = new Button(); button.Tag = choice; button.Text = choice.ToString(); button.Image = choice.GetImage(LayoutMethod.IsLandscape(_model.InputPdf)); button.FlatStyle = FlatStyle.Flat; button.FlatAppearance.BorderSize = 0; // item.Enabled = choice.GetIsEnabled(_model.IsLandscape); button.Click += new EventHandler((object sender, EventArgs e) => OnLayoutButtonClick((LayoutMethod)((Button)sender).Tag)); button.Height = 100; button.Width = 80;// _layoutChoices.GetColumnWidths()[0] - 20; button.TextImageRelation = TextImageRelation.ImageAboveText; button.TabIndex = _layoutChoices.RowCount; _layoutChoices.Controls.Add(button); _layoutChoices.RowCount++; _layoutChoices.RowStyles.Add(new RowStyle(SizeType.Absolute, button.Height)); } }
/// <summary> /// clone BeamSystemParam to one of its subclass according to LayoutMethod /// </summary> /// <param name="layoutType">LayoutMethod</param> /// <returns>cloned BeamSystemParam's subclass</returns> public BeamSystemParam CloneInstance(LayoutMethod layoutType) { // create a BeamSystemParam instance and set its properties BeamSystemParam param = CreateInstance(layoutType); param.m_fixedSpacing = m_fixedSpacing; param.m_justifyType = m_justifyType; param.m_numberOfLines = m_numberOfLines; param.m_beamType = m_beamType; return param; }
/// <summary> /// layout rule of beam system has changed /// </summary> /// <param name="layoutMethod">changed method</param> private void LayoutRuleChanged(ref LayoutMethod layoutMethod) { // create BeamSystemParams instance according to changed LayoutMethod m_param = m_param.CloneInstance(layoutMethod); // raise DataUpdated event OnParamsUpdated(new EventArgs()); // rebind delegate m_param.LayoutRuleChanged += new LayoutRuleChangedHandler(LayoutRuleChanged); }
// public void Print() // { // try // { // PdfSharp.Pdf.PdfDocument x; // PdfFilePrinter y = new PdfFilePrinter(_pathToCurrentlyDisplayedPdf); // PdfFilePrinter.AdobeReaderPath = // y.Print(); // } // catch(Exception e) // { // ErrorReport.NotifyUserOfProblem(e, "Could not print"); // } // } public void SetLayoutMethod(LayoutMethod method) { SelectedMethod = method; if (HaveIncomingPdf) { // Handle NullLayoutMethod the same as the others to allow testing crop marks. _view.ClearThenContinue(ContinueConversionAndNavigation); } if (!string.IsNullOrEmpty(_incomingPath) && Settings.Default.PreviousIncomingPath != _incomingPath) { Settings.Default.PreviousIncomingPath = _incomingPath; Settings.Default.Save(); } _view.UpdateDisplay(); }
public void UpdateDisplay() { /*_showCropMarks.Enabled=*/ _mirrorBox.Enabled = _paperSizeCombo.Enabled = _model.SelectedMethod != null && _model.SelectedMethod.GetType() != typeof(NullLayoutMethod); _overBrowserPanel.Visible = !_model.ShowBrowser; foreach (Button button in _layoutChoices.Controls) { var method = ((LayoutMethod)button.Tag); if (method.ImageIsSensitiveToOrientation) { button.Image = method.GetImage(LayoutMethod.IsLandscape(_model.InputPdf)); } button.Enabled = _model.HaveIncomingPdf && method.GetIsEnabled(_model.InputPdf); button.FlatAppearance.BorderSize = _model.SelectedMethod != null && method.GetType() == _model.SelectedMethod.GetType() ? 2 : 0; } SetupPreviousLink(); }
// public void Print() // { // try // { // PdfSharp.Pdf.PdfDocument x; // PdfFilePrinter y = new PdfFilePrinter(_pathToCurrentlyDisplayedPdf); // PdfFilePrinter.AdobeReaderPath = // y.Print(); // } // catch(Exception e) // { // ErrorReport.NotifyUserOfProblem(e, "Could not print"); // } // } public void SetLayoutMethod(LayoutMethod method) { SelectedMethod = method; if (HaveIncomingPdf) { if (method is NullLayoutMethod) { _pathToCurrentlyDisplayedPdf = _incomingPath; _view.ClearThenContinue(() => _view.Navigate(_incomingPath)); } else { _view.ClearThenContinue(ContinueConversionAndNavigation); } } if (!string.IsNullOrEmpty(_incomingPath) && Settings.Default.PreviousIncomingPath != _incomingPath) { Settings.Default.PreviousIncomingPath = _incomingPath; Settings.Default.Save(); } _view.UpdateDisplay(); }
void OnLayoutButtonClick(LayoutMethod method) { _model.SetLayoutMethod(method); }
private bool _check(LayoutMethod method) { return LayoutMethod == method; }
/// <summary> /// create BeamSystemParam's subclass according to LayoutMethod /// </summary> /// <param name="layoutType">LayoutMethod</param> /// <returns>created BeamSystemParam's subclass</returns> public static BeamSystemParam CreateInstance(LayoutMethod layoutType) { BeamSystemParam param = null; switch (layoutType) { case LayoutMethod.ClearSpacing: param = new ClearSpacingParam(); break; case LayoutMethod.FixedDistance: param = new FixedDistanceParam(); break; case LayoutMethod.FixedNumber: param = new FixedNumberParam(); break; case LayoutMethod.MaximumSpacing: param = new MaximumSpacingParam(); break; default: break; } // it is absolutely impossible unless layoutType is wrong Debug.Assert(null != param); return param; }
private void _load(string path) { var ns = (XNamespace)GetType().Namespace; var root = XElement.Load(path); // read viewport var viewport = root.Element(ns + "Viewport"); if (viewport != null) { Func<XName, string, string> get = (xname, dflt) => (viewport.Element(xname) != null ? viewport.Element(xname).Value : dflt); _scale = Double.Parse(get(ns + "Scale", "0.0")); _origin = Point.Parse(get(ns + "Origin", "0,0")); Scope |= DiagramSnapshotScope.Viewport; } // read settings var settings = root.Element(ns + "Settings"); if (settings != null) { Func<XName, string, string> get = (xname, dflt) => (settings.Element(xname) != null ? settings.Element(xname).Value : dflt); _displayOptions = (DisplayOptions)Enum.Parse(typeof(DisplayOptions), get(ns + "Display", "Default")); _layoutMethod = (LayoutMethod)Enum.Parse(typeof(LayoutMethod), get(ns + "Layout", "Hierarchic")); _layoutOrientation = (LayoutOrientation)Enum.Parse(typeof(LayoutOrientation), get(ns + "Orientation", "TopToBottom")); _layoutRatio = (LayoutRatio)Enum.Parse(typeof(LayoutRatio), get(ns + "Ratio", "Compress")); Scope |= DiagramSnapshotScope.Settings; } // read filter var filter = root.Element(ns + "Filter"); if (filter != null) { // read class filter var classes = new List<BplClass>(); var classSection = filter.Element(ns + "Classes"); if (classSection != null) { foreach (var elem in classSection.Elements(ns + "Class")) { var bplClass = BplClass.Get(elem.Value); if (bplClass != null) { classes.Add(bplClass); } } } _classes = classes.ToArray(); Scope |= DiagramSnapshotScope.Filter; } }
private void _resetSettings() { _displayOptions = DisplayOptions.Default; _layoutMethod = LayoutMethod.Hierarchic; _layoutOrientation = LayoutOrientation.TopToBottom; _layoutRatio = LayoutRatio.Compress; }
private void _captureSettings(DiagramViewer view) { var diagram = view.DiagramCanvas; _displayOptions = diagram.DisplayOptions; _layoutMethod = diagram.LayoutMethod; _layoutOrientation = diagram.LayoutOrientation; _layoutRatio = diagram.LayoutRatio; }
void SetGraphViewModel(LayoutMethod method) { Model.ViewMode = method; Model.RedoLayout(); }