Beispiel #1
0
 public void SetFunction(string formula)
 {
     try
     {
         function = GetFunctionHandle(formula);
     }
     catch
     {
         MessageBox.Show("The Expression contains errors!");
     }
 }
 public void SetMesh(double[,] mesh)
 {
     function      = null;
     m_defaultMesh = mesh;
 }
 public void SetFunction(string formula)
 {
     function      = GetFunctionHandle(formula);
     m_defaultMesh = null;
 }
 public void SetFunction(string formula)
 {
     function = GetFunctionHandle(formula);
 }
 public void SetFunction(string formula)
 {
     function = GetFunctionHandle(formula);
 }
Beispiel #6
0
        public virtual ColumnBase CreateColumn()
        {
            ColumnBase column;

            if (HasChildren)
            {
                column = new Column {
                    Text = Header
                };

                if (ConfigureColumnHandler != null)
                {
                    ConfigureColumnHandler(column);
                }

                return(column);
            }

            var editor = CreateEditor();

            if (CreateColumnHandler != null)
            {
                column = CreateColumnHandler(this);
                if (editor != null)
                {
                    column.Editor.Add(editor);
                }

                if (ConfigureColumnHandler != null)
                {
                    ConfigureColumnHandler(column);
                }

                return(column);
            }

            if (IsTreeColumn)
            {
                column = new TreeColumn
                {
                    DataIndex = ColumnNameIndex,
                    Text      = Header,
                    Width     = new Unit(Width),
                    Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                    Sortable  = !string.IsNullOrEmpty(Sort),
                };
            }
            else
            {
                switch (ModelFieldType)
                {
                case ModelFieldType.Auto:
                    column = new Column
                    {
                        DataIndex = ColumnNameIndex,
                        Text      = Header,
                        Width     = new Unit(Width),
                        Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                        Hidden    = DefaultHidden,
                        Sortable  = !string.IsNullOrEmpty(Sort),
                    };
                    break;

                case ModelFieldType.String:
                    column = new Column
                    {
                        DataIndex = ColumnNameIndex,
                        Text      = Header,
                        Width     = new Unit(Width),
                        Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                        Hidden    = DefaultHidden,
                        Wrap      = Wrap ?? true,
                        Sortable  = !string.IsNullOrEmpty(Sort),
                    };
                    break;

                case ModelFieldType.Int:
                    var intColumn = new NumberColumn
                    {
                        DataIndex = ColumnNameIndex,
                        Text      = Header,
                        Width     = new Unit(Width),
                        Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                        Hidden    = DefaultHidden,
                        Sortable  = !string.IsNullOrEmpty(Sort),
                    };
                    if (!string.IsNullOrEmpty(Format))
                    {
                        intColumn.Format = GetIntFormat();
                    }
                    intColumn.Align = Alignment.Right;
                    //intColumn.Renderer.Handler = "debugger;return record.raw[metadata.column.dataIndex] == null && !value ? '' : value;";
                    column = intColumn;
                    break;

                case ModelFieldType.Float:
                    var floatColumn = new NumberColumn
                    {
                        DataIndex = ColumnNameIndex,
                        Text      = Header,
                        Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                        Hidden    = DefaultHidden,
                        Sortable  = !string.IsNullOrEmpty(Sort),
                    };
                    if (!string.IsNullOrEmpty(Format))
                    {
                        floatColumn.Format = GetFloatFormat();
                    }
                    floatColumn.Align = Alignment.Right;
                    //floatColumn.Renderer.Handler = "debugger;return record.raw[metadata.column.dataIndex] == null && !value ? '' : value;";
                    column = floatColumn;
                    break;

                case ModelFieldType.Boolean:
                    if (EditModeForBool && CanEdit)
                    {
                        column = new CheckColumn
                        {
                            DataIndex     = ColumnNameIndex,
                            Text          = Header,
                            StopSelection = false,
                            Editable      = CanEdit,
                            Width         = new Unit(Width),
                            Flex          = string.IsNullOrEmpty(Width) ? Flex : 0,
                            Hidden        = DefaultHidden,
                            Sortable      = !string.IsNullOrEmpty(Sort),
                        };

                        if (column.Renderer == null)
                        {
                            column.Renderer = new Renderer();
                        }
                        column.Renderer.Handler = string.Format(
                            "if (!record.data.CanEdit) return '<span style=\"font-size:11px\">' + (record.data.{0} ? {1} : {2}) + '</span>'; return (new Ext.ux.CheckColumn()).renderer(record.data.{0});",
                            ColumnNameIndex,
                            JSON.Serialize(TrueText),
                            JSON.Serialize(FalseText));
                    }
                    else
                    {
                        column = new BooleanColumn
                        {
                            DataIndex = ColumnNameIndex,
                            Text      = Header,
                            TrueText  = TrueText,
                            FalseText = FalseText,
                            Width     = new Unit(Width),
                            Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                            Hidden    = DefaultHidden,
                            Sortable  = !string.IsNullOrEmpty(Sort),
                        };
                    }

                    break;

                case ModelFieldType.Date:
                    column = new DateColumn
                    {
                        DataIndex = ColumnNameIndex,
                        Text      = Header,
                        Format    = GetDateFormat(),
                        Width     = new Unit(Width),
                        Flex      = string.IsNullOrEmpty(Width) ? Flex : 0,
                        Hidden    = DefaultHidden,
                        Sortable  = !string.IsNullOrEmpty(Sort),
                    };
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (SummaryType != null)
                {
                    column.SummaryType     = SummaryType.Value;
                    column.SummaryRenderer = new Renderer {
                        Handler = SummaryRendererHandler
                    };
                    column.CustomSummaryType = CustomSummaryType;
                }
            }

            if (editor != null)
            {
                column.Editor.Add(editor);
            }

            if (!string.IsNullOrEmpty(RendererFunction))
            {
                var handler = RendererFunction.Contains(" ") ?
                              $"function (value, metadata, record, rowIndex, colIndex, store, view) {{\n{RendererFunction}\n}}"
                    : RendererFunction;
                column.Renderer = new Renderer {
                    Handler = handler,
                };
            }

            if (Locked)
            {
                column.Locked = true;
            }

            ConfigureColumnHandler?.Invoke(column);

            return(column);
        }