Page tree
Skip to end of metadata
Go to start of metadata

1.描述

6.1版本之前的活字格服务器基于Katana服务器,从6.1版本开始,活字格服务器从Katana迁移到ASP.NET Core,因此您需要升级单元格类型插件。

满足以下所有条件时无需升级插件:

  1. 单元类型未实现IDrawingHelper, ICellTypeChecker、IDependenceCells, ISupportPropertyInitialize, ISupportStyleInitialize接口。
  2. 单元格未重写(override) GetDrawingControl, GetEditorSetting 方法;
  3. 原始插件工程依赖.net Framework 4.7.2。

2.升级单元格类型插件

操作步骤

   检查项目属性,确认项目的Framework框架为.NET Framework 4.7.2。

  使用Visual Studio打开.csproj文件, 在解决方案资源管理器中将Forguncy.CellTypes和Forguncy.PluginCommon移除掉。

  在解决方案资源管理器中,“引用”上右击,选择添加引用。

  在右下角单击“浏览”,活字格安装文件所在的bin文件夹,如果是默认安装,则路径为"C:\Program Files (x86)\Forguncy\Website\designerbin",找到以下文件,选中打开后,单击“确定”将其添加到解决方案资源管理器中。

  • 如果您要自定义celltype designer或者要实现ICellTypeChecker 等接口,找到GrapeCity.Forguncy.CellTypes.dll、GrapeCity.Forguncy.CellTypes.Design.dll、GrapeCity.Forguncy.Plugin.dll、GrapeCity.Forguncy.Plugin.Design.dll 这四个文件;
  • 否则只需添加GrapeCity.Forguncy.CellTypes.dll 和 GrapeCity.Forguncy.Plugin.dll 这两个文件。

  为了确保最佳性能,请确保从Forguncy引用的所有程序集都的“复制本地”都设置为“false”。

  将PluginConfig.json的“ dependencyVersion”属性更改为“ 6.0.100.0”或更高。


  升级接口。 

  1.   GetDrawingControl, GetEditorSetting 方法升级。

    升级前

    升级后

      
        [Icon("pack://application:,,,/BDMapCellType;component/Resources/Icon.png")]
      public class BDMapCellType : CellType
      {
          public BDMapCellType()
          {
              Longitude = 116.404;
              Latitude = 39.915;
          }
           
          [OrderWeight(1)]
          [DefaultValue(116.404)]
          public double Longitude
          {
              get;
              set;
          }
       
          [OrderWeight(2)]
          [DefaultValue(39.915)]
          public double Latitude
          {
              get;
              set;
          }    
         
          public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
          {
              Grid grid = new Grid();
              Image image = new Image();
              image.Source = new BitmapImage(new Uri(
                  "pack://application:,,,/BDMapCellType;component/Resources/Preview.png",
                  UriKind.RelativeOrAbsolute));
              image.Stretch = Stretch.Uniform;
              image.VerticalAlignment = VerticalAlignment.Center;
              image.HorizontalAlignment = HorizontalAlignment.Center;
              grid.Children.Add(image);
              return grid;
          }

    public override EditorSetting GetEditorSetting(PropertyDescriptor property, IBuilderContext builderContext)
    {

    //Code....
    return null;
    }


          public override string ToString()
          {
              return Resource.BMapCellType_DisplayName;
          }

      }

    //此处标记了预览单元格类型的对应类。 

       [Designer("BDMapCellType.BDMapCellTypeDesigner, BDMapCellType")]//格式为 "Namespace.ClassName, AssemblyName"
      [Icon("pack://application:,,,/BDMapCellType;component/Resources/Icon.png")]
      public class BDMapCellType : CellType
      {
          public BDMapCellType()
          {
              Longitude = 116.404;
              Latitude = 39.915;
          }
           
          [OrderWeight(1)]
          [DefaultValue(116.404)]
          public double Longitude
          {
              get;
              set;
          }
       
          [OrderWeight(2)]
          [DefaultValue(39.915)]
          public double Latitude
          {
              get;
              set;
          }

          public override string ToString()
          {
              return Resource.BMapCellType_DisplayName;
          }
      }

      class BDMapCellTypeDesigner : CellTypeDesigner<BDMapCellType>
      {
          public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
          {
              Grid grid = new Grid();
              Image image = new Image();
              image.Source = new BitmapImage(new Uri("pack://application:,,,/BDMapCellType;component/Resources/Preview.png",
     UriKind.RelativeOrAbsolute));
              image.Stretch = Stretch.Uniform;
              image.VerticalAlignment = VerticalAlignment.Center;
              image.HorizontalAlignment = HorizontalAlignment.Center;

              grid.Children.Add(image);
              return grid;
          }

    public override EditorSetting GetEditorSetting(PropertyDescriptor property, IBuilderContext builderContext)
    {

    //Code....
    return null;
    }

       }



  2. IDrawingHelper, ICellTypeChecker、IDependenceCells, ISupportPropertyInitialize, ISupportStyleInitialize 接口升级。

    升级前

    升级后

      [Icon("pack://application:,,,/BDMapCellType;component/Resources/Icon.png")]
      public class BDMapCellType : CellType,ICellTypeChecker
      {
          public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
          {
              Grid grid = new Grid();
              Image image = new Image();
              image.Source = new BitmapImage(new Uri(
                  "pack://application:,,,/BDMapCellType;component/Resources/Preview.png",
                  UriKind.RelativeOrAbsolute));
              image.Stretch = Stretch.Uniform;
              image.VerticalAlignment = VerticalAlignment.Center;
              image.HorizontalAlignment = HorizontalAlignment.Center;
              grid.Children.Add(image);
              return grid;
          }
          public IEnumerable<ForguncyErrorInfo> CheckCellTypeErrors(IBuilderContext context)
          {
               return BDMapValidator.Validate();
          }
         
          public override string ToString()
          {
              return Resource.BMapCellType_DisplayName;
          }

      }
     ...
      class BDMapCellTypeDesigner : CellTypeDesigner<BDMapCellType>, ICellTypeChecker
      {
          public override FrameworkElement GetDrawingControl(ICellInfo cellInfo, IDrawingHelper drawingHelper)
          {
              Grid grid = new Grid();
              Image image = new Image();
              image.Source = new BitmapImage(new Uri("pack://application:,,,/BDMapCellType;component/Resources/Preview.png",
                   UriKind.RelativeOrAbsolute));
              image.Stretch = Stretch.Uniform;
              image.VerticalAlignment = VerticalAlignment.Center;
              image.HorizontalAlignment = HorizontalAlignment.Center;

              grid.Children.Add(image);
              return grid;
          }
         
          public IEnumerable<ForguncyErrorInfo> CheckCellTypeErrors(IBuilderContext context)
          {
               return BDMapValidator.Validate();
          }
      }  




  3. IDrawingHelper 接口升级
    ICellInfo

    旧属性

    新属性

    旧代码

    新代码

    Background (System.Windows.Media.Brush)BackgroundStr (string)textBlock.Background = cellInfo.Background textBlock.Background = drawingHelper.GetBrush(cellInfo.BackgroundStr);
    Foreground (System.Windows.Media.Brush)ForegroundStr (string)textBlock.Foreground = cellInfo.Foreground textBlock.Foreground = drawingHelper.GetBrush(cellInfo.ForegroundStr);
    FontFamily (System.Windows.Media.FontFamily)FontFamily (string) textBlock.FontFamily = cellInfo.FontFamilytextBlock.FontFamily = drawingHelper.GetFontFamily(cellInfo.FontFamily);
    FontStyle(System.Windows.FontStyle)FontStyle(string)textBlock.FontStyle = cellInfo.FontStyletextBlock.FontStyle = (FontStyle)new FontStyleConverter().ConvertFromString(cellInfo.FontStyle);
    FontWeight(System.Windows.FontWeight)FontStyle(string)textBlock.FontWeight = cellInfo.FontWeighttextBlock.FontWeight = (FontWeight)new FontWeightConverter().ConvertFromString(cellInfo.FontWeight);

  在插件名称上右击,选择“生成”或者“重新生成”。完成后重启活字格设计器,新建的插件就会安装到活字格设计器中。


回到顶部

  • No labels