Need to find a suitable json schema for dynamic controls on windows forms

166 views Asked by At

I am in the process of developing an application that places dynamic controls on a Windows forms. Intension is to read controls definitions from json file and place them windows form , specifically into a table layout panel. Is there pre defined json schema like column-formatting .schema but specific to windows forms.

1

There are 1 answers

0
TonyP On

I have created this basic schema for defining Windows form controls, it is not complete but may be used as base for creating your own.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "parent": {
      "type": "string"
    },
    "controls": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/Control"
      }
    }
  },
  "definitions": {
    "Properties": {
      "type": "object",
      "properties": {
        "Type": {
          "enum": [ "Label", "TextBox" ]
        },
        "Font": {
          "$ref": "#/definitions/Font"
        },
        "Cell": {
          "$ref": "#/definitions/Cell"
        },
        "TextAlign": {
          "$ref": "#/definitions/TextAlign"
        }
      }
    },
    "Font": {
      "type": "object",
      "properties": {
        "Name": {
          "enum": [ "consolas", "arial" ]
        },
        "Size": {
          "type": "integer"
        },
        "Bold": {
          "type": "string"
        }
      }
    },
    "TextAlign": {
      "enum": [
        "Left",
        "Right",
        "TopLeft",
        "TopCenter",
        "TopRight",
        "MiddleLeft",
        "MiddleCenter",
        "MiddleRight",
        "BottomLeft",
        "BottomCenter",
        "BottomRight"
      ]
    },
    "Cell": {
      "type": "object",
      "properties": {
        "Row": {
          "type": "integer"
        },
        "Column": {
          "type": "integer"
        }
      }
    },
    "Control": {
      "type": "object",
      "properties": {
        "properties": {
          "$ref": "#/definitions/Properties"
        }
      }
    }
  }
}