Example #1
0
        public static IEnumerable<SelectListItem> GetDropdownValues(IEditorControl ctl, string currentValue, EditorController controller)
        {
            IEnumerable<string> valuesList = ctl.GetListString("validvalues");
            IDictionary<string, string> valuesDictionary = ctl.GetDictionary("validvalues");
            string source = ctl.GetString("source");

            // TO DO: Need a way of allowing free text entry

            if (source == "basefonts")
            {
                valuesList = controller.AvailableBaseFonts();
            }
            else if (source == "webfonts")
            {
                valuesList = controller.AvailableWebFonts();
            }

            if (valuesList != null)
            {
                if (string.IsNullOrEmpty(currentValue))
                {
                    valuesList = new List<string> { "" }.Union(valuesList);
                }

                return valuesList.Select(v => new SelectListItem { Text = v, Value = v, Selected = (v == currentValue) });
            }
            else if (valuesDictionary != null)
            {
                return valuesDictionary.Select(kvp => new SelectListItem { Text = kvp.Value, Value = kvp.Key, Selected = (kvp.Key == currentValue) });
            }
            else
            {
                throw new Exception("Unknown source list for dropdown");
            }
        }
Example #2
0
        public void DoInitialise(EditorController controller, IEditorControl definition)
        {
            m_controller = controller;
            m_controller.ElementsUpdated += m_controller_ElementsUpdated;
            m_controller.ElementMoved += m_controller_ElementMoved;
            m_controller.SimpleModeChanged += m_controller_SimpleModeChanged;

            m_directionNames = new List<string>(definition.GetListString("compass"));
            m_compassTypes = definition.GetDictionary("compasstypes");
        }
Example #3
0
        public void DoInitialise(EditorController controller, IEditorControl definition)
        {
            m_controller = controller;
            m_controller.ElementsUpdated += m_controller_ElementsUpdated;

            m_directionNames = new List<string>(definition.GetListString("compass"));
        }