コード例 #1
0
 private void dlgParagraphFormatcs_Load(object sender, EventArgs e)
 {
     if (_CommandParameter == null)
     {
         _CommandParameter = new ParagraphFormatCommandParameter();
     }
     this.txtLeftIndent.Value          = ( decimal )(GraphicsUnitConvert.ToTwips(_CommandParameter.LeftIndent, GraphicsUnit.Document) / 210.0);
     txtFirstLineIndent.Value          = (decimal)(GraphicsUnitConvert.Convert(_CommandParameter.FirstLineIndent, GraphicsUnit.Document, GraphicsUnit.Millimeter) / 10.0);
     txtSpacingBefore.Value            = (decimal)(GraphicsUnitConvert.ToTwips(_CommandParameter.SpacingBefore, GraphicsUnit.Document) / 312.0);
     txtSpacingAfter.Value             = (decimal)(GraphicsUnitConvert.ToTwips(_CommandParameter.SpacingAfter, GraphicsUnit.Document) / 312.0);
     cboLineSpacingStyle.SelectedIndex = (int)_CommandParameter.LineSpacingStyle;
     cboLineSpacingStyle_SelectedIndexChanged(null, null);
 }
コード例 #2
0
 protected void ParagraphFormat(object sender, WriterCommandEventArgs args)
 {
     if (args.Mode == WriterCommandEventMode.QueryState)
     {
         args.Enabled = args.DocumentControler != null &&
                        args.DocumentControler.Snapshot.CanModifySelection;
     }
     else if (args.Mode == WriterCommandEventMode.Invoke)
     {
         args.Result = false;
         ParagraphFormatCommandParameter parameter = args.Parameter
                                                     as ParagraphFormatCommandParameter;
         if (parameter == null)
         {
             parameter = new ParagraphFormatCommandParameter();
             parameter.Read(args.Document.CurrentParagraphStyle);
         }
         if (args.ShowUI)
         {
             using (dlgParagraphFormatcs dlg = new dlgParagraphFormatcs())
             {
                 dlg.CommandParameter = parameter;
                 if (dlg.ShowDialog(args.EditorControl) != DialogResult.OK)
                 {
                     // 用户取消操作
                     return;
                 }
             }
         }//if
         DocumentContentStyle ns = new DocumentContentStyle();
         ns.DisableDefaultValue = true;
         parameter.Save(ns);
         args.Document.BeginLogUndo();
         DomElementList list = args.Document.Selection.SetParagraphStyle(ns);
         if (list != null && list.Count > 0)
         {
             args.Result = true;
         }
         args.Document.EndLogUndo();
         args.Document.OnSelectionChanged();
         args.Document.OnDocumentContentChanged();
         args.RefreshLevel = UIStateRefreshLevel.All;
     }
 }