private ListReader <ITerminalAction> GetActions(MyToolbarType?type)
        {
            if (m_block == null)
            {
                return(ListReader <ITerminalAction> .Empty);
            }

            m_tmpEnabledActions.Clear();
            foreach (var action in MyTerminalControlFactory.GetActions(m_block.GetType()))
            {
                if (action.IsEnabled(m_block))
                {
                    if (type == null || action.IsValidForToolbarType(type.Value))
                    {
                        m_tmpEnabledActions.Add(action);
                    }
                }
            }

            return(m_tmpEnabledActionsReader);
        }
Exemple #2
0
        public WebTerminalBlock(MyTerminalBlock block, bool includeProperties = true)
        {
            this.Name = block.CustomName.ToString();
            this.Type = block.GetType().ToString().Split('.').LastOrDefault();
            this.Id   = block.EntityId;

            if (includeProperties)
            {
                List <ITerminalProperty> props = new List <ITerminalProperty>();
                block.GetProperties(props);

                this.Properties = new Dictionary <string, string>(props.Count);

                foreach (var prop in props)
                {
                    switch (prop.TypeName)
                    {
                    case "Boolean":
                        this.Properties.Add(prop.Id, prop.AsBool().GetValue(block).ToString());
                        break;

                    case "Single":
                        this.Properties.Add(prop.Id, prop.AsFloat().GetValue(block).ToString());
                        break;

                    case "Color":
                        this.Properties.Add(prop.Id, prop.AsColor().GetValue(block).ToString());
                        break;
                    }
                }
            }
            else
            {
                this.Properties = null;
            }
        }