Example #1
0
        internal void OnInit(Connection connection, WidgetContext context, Widget widget)
        {
            ID = widget.ID;

            Connection = connection;
            Context    = context;

            object objConfig = widget.Config.ToObject(ConfigType) !;

            widget.Config = StdJson.ObjectToJObject(objConfig);
            SetConfig(objConfig);

            Type   type   = GetType();
            string prefix = RequestMethodNamePrefix;
            int    N      = prefix.Length;

            MethodInfo[] methods =
                type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)
                .Where(m => m.Name.StartsWith(prefix))
                .ToArray();

            foreach (MethodInfo m in methods)
            {
                ParameterInfo[] parameters = m.GetParameters();

                UIReqDelegate theDelegate = (object?[] args) => {
                    return((Task <ReqResult>)m.Invoke(this, args) !);
                };

                UiReqPara[] uiReqParameters = parameters.Select(MakeParameter).ToArray();

                string key = m.Name.Substring(N);
                mapUiReqMethods[key] = new UiReqMethod(theDelegate, uiReqParameters);
            }
        }
Example #2
0
        private static Page PageFromTab(View_HistoryPlots.TabConfig tab, View_HistoryPlots.DataExport dataExport)
        {
            var hc = new Widgets.HistoryPlotConfig()
            {
                PlotConfig = MapPlotConfig(tab.PlotConfig),
                Items      = tab.Items.Select(MapItemConfig).ToArray(),
                DataExport = MapDataExport(dataExport)
            };

            JObject config = StdJson.ObjectToJObject(hc, indented: true);

            return(new Page()
            {
                ID = tab.Name,
                Name = tab.Name,
                Rows = new Row[] {
                    new Row()
                    {
                        Columns = new Column[] {
                            new Column()
                            {
                                Width = ColumnWidth.Fill,
                                Widgets = new Widget[] {
                                    new Widget("w1", "HistoryPlot", width: "100%", height: "600px", config: config)
                                }
                            }
                        }
                    }
                }
            });
        }
Example #3
0
        internal async Task SaveWidgetConfiguration(string pageID, Widget widget, object newWidgetConfig)
        {
            JObject objNewWidgetConfig = StdJson.ObjectToJObject(newWidgetConfig);

            widget.Config = objNewWidgetConfig;
            DataValue newViewConfig = DataValue.FromObject(configuration, indented: true);
            await Context.SaveViewConfiguration(newViewConfig);

            var msg = new {
                PageID   = pageID,
                WidgetID = widget.ID,
                Config   = widget.Config,
            };
            await Context.SendEventToUI("WidgetConfigChanged", msg);
        }