Exemplo n.º 1
0
 public void Save()
 {
     if (CurrentElementEditor != null)
     {
         CurrentElementEditor.Save();
     }
 }
Exemplo n.º 2
0
        private void GetOrCreateEditorControl(string editorName)
        {
            if (string.IsNullOrEmpty(editorName))
            {
                CurrentEditor = null;
            }
            else
            {
                if (!m_loadedEditors.ContainsKey(editorName))
                {
                    Control newControl = InitialiseEditorControl(editorName);
                    Grid.SetRow(newControl, 1);
                    grid.Children.Add(newControl);

                    CurrentEditor = newControl;

                    m_loadedEditors.Add(editorName, newControl);
                }
                else
                {
                    CurrentEditor = m_loadedEditors[editorName];
                }

                if (CurrentEditor != null)
                {
                    GridUnitType controlRowGridUnit = GridUnitType.Auto;

                    if (CurrentElementEditor != null)
                    {
                        CurrentElementEditor.Helper.DoInitialise(m_controller, m_definition);
                        CurrentElementEditor.Populate(m_data);
                        if (CurrentElementEditor.Helper.Options.Resizable || m_definition.Expand)
                        {
                            controlRowGridUnit = GridUnitType.Star;
                        }
                    }

                    CurrentEditor.Visibility = Visibility.Visible;
                    controlRow.Height        = new GridLength(1, controlRowGridUnit);
                }
            }

            HideOtherEditors();
            SetEditorAttributes();
        }
Exemplo n.º 3
0
        public void Populate(IEditorData data)
        {
            m_data = data;
            m_storedValues.Clear();

            if (m_data == null)
            {
                if (CurrentElementEditor != null)
                {
                    CurrentElementEditor.Populate(m_data);
                }
                CurrentEditor = null;
                HideOtherEditors();
                return;
            }

            object value = m_data.GetAttribute(m_definition.Attribute);

            bool canEdit = CanEditType(value) && m_definition.Attribute != "type" && m_definition.Attribute != "elementtype";

            lstTypes.IsEnabled = canEdit && !data.ReadOnly && m_definition.Attribute != "name";

            if (canEdit)
            {
                string typeName   = GetTypeName(value);
                string editorName = GetEditorNameForType(typeName);
                SetSelectedType(typeName);
                GetOrCreateEditorControl(editorName);
                if (!string.IsNullOrEmpty(typeName))
                {
                    m_storedValues[typeName] = value;
                }
            }
            else
            {
                CurrentEditor = null;
                HideOtherEditors();
            }
        }