public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     m_controller = controller;
     m_definition = definition;
     m_source     = definition == null ? null : definition.GetString("source");
     m_objectType = definition == null ? null : definition.GetString("objecttype");
 }
 public void AddChild(BeTreeNode node, IEditorControl parent)
 {
     NodeChildren.Add(node);
     node.NodeParent = this;
     node.FloorCount = FloorCount + 1;
     node.SetParent(parent);
 }
 public void ExcuteChildAdded(IEditorControl e)
 {
     foreach (var act in OnAddChild)
     {
         act(e);
     }
 }
 public void ExcuteChildRemove(IEditorControl e)
 {
     foreach (var act in OnRemoveChild)
     {
         act(e);
     }
 }
Example #5
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 #6
0
        public void SetEditor(IEditorControl editor)
        {
            try
            {
                _editor           = editor;
                tsbSearch.Visible = editor.SupportSearch;
                tscbKeyValue.Items.Clear();
                object[] skeys = editor.SearchKeys;
                if (skeys != null)
                {
                    tscbKeyValue.Items.AddRange(skeys);
                }

                dOpen.Filter = editor.OpenFileFilter;
                dSave.Filter = editor.SaveFileFilter;
                UpdateFileTitle();
                UpdateSearchBarVisibility();
                editor.DirtyChanged = _ => { UpdateFileTitle(); };
                if (_editor is Control c)
                {
                    c.Enabled = true;
                }

                EditorChanged?.Invoke(editor);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error encountered when setting up editor '{0}'.\n\nException: {1}\nMessage: {2}".F(_editor.GetType().Name, e.GetType(), e.Message), "Dune 2000 Editor", MessageBoxButtons.OK);
                _editor = null;
            }
        }
 public void DoUninitialise()
 {
     m_controller = null;
     m_definition = null;
     m_source     = null;
     m_objectType = null;
 }
Example #8
0
        public void Initialise(EditorController controller, IEditorControl controlData)
        {
            m_elementType = controlData.GetString("elementtype");
            m_objectType  = controlData.GetString("objecttype");
            m_filter      = controlData.GetString("listfilter");

            ctlListEditor.EditorDelegate = this;
            ctlListEditor.Style          = WFListEditor.ColumnStyle.OneColumn;
            ctlListEditor.UpdateList(null);
            m_controller = controller;
            m_controller.ElementsUpdated += m_controller_ElementsUpdated;
            m_controller.ElementMoved    += m_controller_ElementMoved;
            m_controlData = controlData;

            if (m_filter != null)
            {
                m_typeDesc = m_filter;
            }
            else if (m_objectType != null)
            {
                m_typeDesc = m_objectType;
            }
            else
            {
                m_typeDesc = m_elementType;
            }
        }
        public static T CreateEditorControl <T>() where T : IEditorControl
        {
            IEditorControl ctrl = Activator.CreateInstance <T>();

            InitControl(ctrl);
            return((T)ctrl);
        }
        private static void AttributeDeserialize(XmlNode node, IEditorControl ctrl, IEditorControl root)
        {
            Type type = ctrl.GetType();

            MemberInfo[] infos = type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            foreach (MemberInfo info in infos)
            {
                object       data;
                XmlAttribute attr = node.Attributes[info.Name];
                if (attr == null)
                {
                    continue;
                }
                switch (info.MemberType)
                {
                case MemberTypes.Field:
                    data = DeserializeXML(node.Attributes[info.Name], root);
                    (info as FieldInfo).SetValue(ctrl, data);
                    break;

                case MemberTypes.Property:
                    data = DeserializeXML(node.Attributes[info.Name], root);
                    (info as PropertyInfo).SetValue(ctrl, data);
                    break;
                }
            }
        }
        public static void InitControl(IEditorControl ctrl)
        {
            Type   type = ctrl.GetType();
            string path = $"Assets/Editor/ControlXmls/{type.Name}.xml";

            try
            {
                TextAsset ass = AssetDatabase.LoadAssetAtPath <TextAsset>(path);
                if (ass == null)
                {
                    (ctrl as EditorControl)?.InitFinish();
                    return;
                }

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(ass.text);

                XmlNode root = doc.ChildNodes[0];
                TreeDeserialize(ctrl, root, ctrl);
                AttributeDeserialize(root, ctrl, ctrl);
                (ctrl as EditorControl)?.InitFinish();
            }
            catch (Exception err)
            {
                Log.Error($"解析{type.Name}时候错误, {err}");
            }
        }
Example #12
0
        public void DoInitialise(EditorController controller, IEditorControl definition)
        {
            m_controller = controller;
            m_definition = definition;

            m_settingType = true;
            lstTypes.Items.Clear();
            m_settingType = false;

            m_types = new List <TypesListItem>();

            if (m_definition != null)
            {
                IDictionary <string, string> types = definition.GetDictionary("types");
                InitialiseTypesList(types);

                m_overrideControlTypesMap = definition.GetDictionary("editors");

                string selfCaption = definition.GetString("selfcaption");
                if (selfCaption != null)
                {
                    lblSelfCaption.Visibility = Visibility.Visible;
                    lblSelfCaption.Text       = selfCaption + ":";
                }
            }
        }
Example #13
0
        public void Initialise(EditorController controller, IEditorControl controlData)
        {
            m_elementType = controlData.GetString("elementtype");
            m_objectType = controlData.GetString("objecttype");
            m_filter = controlData.GetString("listfilter");

            ctlListEditor.EditorDelegate = this;
            ctlListEditor.Style = WFListEditor.ColumnStyle.OneColumn;
            ctlListEditor.UpdateList(null);
            m_controller = controller;
            m_controller.ElementsUpdated += m_controller_ElementsUpdated;
            m_controller.ElementMoved += m_controller_ElementMoved;
            m_controlData = controlData;

            if (m_filter != null)
            {
                m_typeDesc = m_filter;
            }
            else if (m_objectType != null)
            {
                m_typeDesc = m_objectType;
            }
            else
            {
                m_typeDesc = m_elementType;
            }
        }
Example #14
0
        private void AddControl(IEditorControl ctl, string expression)
        {
            Control newControl = ControlFactory.CreateEditorControl(Controller, ctl.ControlType);
            stackPanel.Children.Add(newControl);

            newControl.VerticalAlignment = VerticalAlignment.Top;
            if (newControl is LabelControl)
            {
                newControl.Padding = new Thickness(3, 3, 3, 0);
            }
            else
            {
                newControl.Padding = new Thickness(3, 0, 3, 0);
            }

            IElementEditorControl elementEditor = newControl as IElementEditorControl;
            if (elementEditor != null)
            {
                elementEditor.Helper.DoInitialise(Controller, ctl);
                elementEditor.Populate(m_data);
                elementEditor.Helper.Dirty += SubControl_Dirty;
                elementEditor.Helper.RequestParentElementEditorSave += SubControl_RequestParentElementEditorSave;
                m_controls.Add(elementEditor);
            }
        }
Example #15
0
        private void LoadGameData(string path)
        {
            foreach (TabPage tabPage in tabControl.TabPages)
            {
                IEditorControl editorControl = (IEditorControl)tabPage.Controls.OfType <Control>().FirstOrDefault(x => x is IEditorControl);
                if (editorControl != null && editorControl.IsInitialized())
                {
                    editorControl.Terminate();
                }
                tabPage.Tag = null;
            }

            gameDataManager.ReadGameDirectory(ApplicationConfig.Instance.LastDataPath = path);

            tableEntryEditor.Enabled = messageEditor.Enabled = floorMapEditor.Enabled = (gameDataManager != null && gameDataManager.IsInitialized);
            gameLanguageToolStripMenuItem.Enabled = (gameDataManager != null && gameDataManager.Version == GameDataManager.Versions.European);

            if (gameDataManager.IsInitialized)
            {
                SetFormTitle();
                InitializeTabPage(tabControl.SelectedTab);

                StatusText = "Data loaded";
                if (gameDataManager.Version != GameDataManager.Versions.Japanese)
                {
                    dumpMainFontToolStripMenuItem.Enabled = dumpSmallFontToolStripMenuItem.Enabled = true;
                }
            }
        }
        private void AddControl(IEditorControl ctl, string expression)
        {
            Control newControl = ControlFactory.CreateEditorControl(Controller, ctl.ControlType);

            stackPanel.Children.Add(newControl);

            newControl.VerticalAlignment = VerticalAlignment.Top;
            if (newControl is LabelControl)
            {
                newControl.Padding = new Thickness(3, 3, 3, 0);
            }
            else
            {
                newControl.Padding = new Thickness(3, 0, 3, 0);
            }

            IElementEditorControl elementEditor = newControl as IElementEditorControl;

            if (elementEditor != null)
            {
                elementEditor.Helper.DoInitialise(Controller, ctl);
                elementEditor.Populate(m_data);
                elementEditor.Helper.Dirty += SubControl_Dirty;
                elementEditor.Helper.RequestParentElementEditorSave += SubControl_RequestParentElementEditorSave;
                m_controls.Add(elementEditor);
            }
        }
Example #17
0
        public MainWindow(string path, Type editor)
        {
            if (!typeof(IEditorControl).IsAssignableFrom(editor))
            {
                MessageBox.Show("Editor type iCommandBinding_OnExecutednitialize");
                Close();
            }

            if (!File.Exists(path))
            {
                MessageBox.Show("Startup file does not exist!", "Failed to initialize");
                Close();
            }

            InitializeComponents();

            IEditorControl editorControl = OpenTab(editor);
            Exception      openResult    = editorControl.Open(path);

            if (!(openResult is null))
            {
                Logger.DumpException(openResult);
                TabController.Items.RemoveAt(TabController.Items.Count - 1);
                MessageBox.Show("Failed to load file.\nReason: " + openResult.Message, "Tabbed Editor - Failed to load file");
            }
Example #18
0
 public void Uninitialise()
 {
     m_controller.ElementsUpdated -= m_controller_ElementsUpdated;
     m_controller.ElementMoved -= m_controller_ElementMoved;
     m_controller = null;
     m_controlData = null;
     m_data = null;
 }
Example #19
0
 public void Initialise(EditorController controller, IEditorControl controlData)
 {
     string keyName = "Key";
     if (controlData != null) keyName = controlData.GetString("keyname") ?? keyName;
     m_manager.Initialise(controller, controlData, keyName, "Script");
     ctlListEditor.SetEditKeyButtonText("Edit " + keyName);
     ctlListEditor.SetEditButtonText("Edit Script");
 }
Example #20
0
 public void Uninitialise()
 {
     m_controller.ElementsUpdated -= m_controller_ElementsUpdated;
     m_controller.ElementMoved    -= m_controller_ElementMoved;
     m_controller  = null;
     m_controlData = null;
     m_data        = null;
 }
Example #21
0
 public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     Controller        = controller;
     ControlDefinition = definition;
     if (controller != null && Initialise != null)
     {
         Initialise();
     }
 }
Example #22
0
        public static IEnumerable<SelectListItem> GetDropDownTypesControlItems(IEditorControl ctl, EditorController controller, string element)
        {
            IDictionary<string, string> types = ctl.GetDictionary("types");

            // TO DO: If more than one type is inherited by the object, disable the control
            string selectedItem = controller.GetSelectedDropDownType(ctl, element);

            return types.Select(t => new SelectListItem { Value = t.Key, Text = t.Value, Selected = (selectedItem == t.Key) });
        }
Example #23
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 #24
0
 public void UpdateEditor(IEditorControl editor)
 {
     foreach (ToolStripButton tsb in _editors.GetKeys())
     {
         if (_editors[tsb] == editor)
         {
             UpdateEditor(tsb, editor);
             break;
         }
     }
 }
Example #25
0
 private void gameDataManager_SelectedLanguageChangedEvent(object sender, EventArgs e)
 {
     foreach (TabPage tabPage in tabControl.TabPages)
     {
         IEditorControl editorControl = (IEditorControl)tabPage.Controls.OfType <Control>().FirstOrDefault(x => x is IEditorControl);
         if (editorControl != null && editorControl.IsInitialized())
         {
             editorControl.Rebuild();
         }
     }
 }
Example #26
0
        public void Initialise(EditorController controller, IEditorControl controlData)
        {
            string keyName = "Key";

            if (controlData != null)
            {
                keyName = controlData.GetString("keyname") ?? keyName;
            }
            m_manager.Initialise(controller, controlData, keyName, "Script");
            // ctlListEditor.SetEditKeyButtonText("Edit " + keyName);
            // ctlListEditor.SetEditButtonText("Edit Script");
        }
Example #27
0
        private void OnWindowClose(IEditorControl obj)
        {
            TextNewECtrl ctrl = obj as TextNewECtrl;

            foreach (int id in ctrl.IncludeIds)
            {
                _paramsPath.Remove(_datas[id]);
                _datas.Remove(id);
                _id2Windows.Remove(id);
            }
            _ctrls.Remove(ctrl);
        }
Example #28
0
 private void Select(object sender, EventArgs e)
 {
     if (sender is ToolStripButton tsb)
     {
         IEditorControl editor = _editors[tsb];
         if (tsb != null && tsb != _current)
         {
             UpdateEditor(editor);
             EditorChanged?.Invoke(editor);
         }
     }
 }
 public void Initialise(EditorController controller, IEditorControl controlData, string keyHeader, string valueHeader)
 {
     m_controller = controller;
     ctlListEditor.EditorDelegate = this;
     ctlListEditor.Style          = WFListEditor.ColumnStyle.TwoColumns;
     ctlListEditor.SetHeader(1, keyHeader);
     ctlListEditor.SetHeader(2, valueHeader);
     ctlListEditor.UpdateList(null);
     m_controller    = controller;
     m_attributeName = controlData == null ? null : controlData.Attribute;
     m_controlData   = controlData;
 }
Example #30
0
        public object Deserialize(XmlAttribute data, IEditorControl ctrl)
        {
            string[]     types  = data.InnerText.Replace(" ", "").Split(',');
            EditorAnchor anchor = 0;

            foreach (string type in types)
            {
                EditorAnchor anchorType = EnumHelper.FromString <EditorAnchor>(type);
                anchor |= anchorType;
            }
            return(anchor);
        }
        private void RemoveChild(IEditorControl obj)
        {
            EditorControl ec = obj as EditorControl;

            if (ec == null)
            {
                return;
            }
            ec.OnSizeChange.Remove(OnReCaluSize);
            ec.OnActiveChange.Remove(OnReCaluSizeActive);
            ReCaluSize();
        }
Example #32
0
 private void InitializeTabPage(TabPage tabPage)
 {
     if ((gameDataManager != null && gameDataManager.IsInitialized) && tabPage.Tag == null)
     {
         IEditorControl editorControl = (IEditorControl)tabPage.Controls.OfType <Control>().FirstOrDefault(x => x is IEditorControl);
         if (editorControl != null && !editorControl.IsInitialized())
         {
             editorControl.Initialize(gameDataManager);
         }
         tabPage.Tag = gameDataManager;
     }
 }
Example #33
0
        public object Deserialize(XmlAttribute data, IEditorControl ctrl)
        {
            string v = data.InnerText;

            if (string.IsNullOrEmpty(v))
            {
                return(new Vector2());
            }

            Regex gex    = new Regex("[0-9]+");
            var   matchs = gex.Matches(v);

            return(new Vector2(float.Parse(matchs[0].Value), float.Parse(matchs[1].Value)));
        }
Example #34
0
 public static IEnumerable<string> GetObjectListNames(IEditorControl ctl, EditorController controller)
 {
     string source = ctl.GetString("source");
     if (source != null)
     {
         return controller.GetElementNames(source);
     }
     else
     {
         string objectType = ctl.GetString("objecttype");
         IEnumerable<string> objectNames = controller.GetObjectNames(objectType ?? "object");
         return new List<string> { "" }.Union(objectNames);
     }
 }
Example #35
0
 public void Initialise(EditorController controller, IEditorControl controlData)
 {
     m_controller = controller;
     ctlListEditor.EditorDelegate = this;
     ctlListEditor.Style = WFListEditor.ColumnStyle.TwoColumns;
     ctlListEditor.SetHeader(1, "Key");
     ctlListEditor.SetHeader(2, "Value");
     ctlListEditor.UpdateList(null);
     m_controller = controller;
     m_attributeName = controlData.Attribute;
     m_controlData = controlData;
 }
Example #36
0
        private ElementSaveData.ScriptSaveData BindStringDictionary(IValueProvider provider, EditorController controller, string ignoreExpression, IEditableDictionary<string> dictionary, string key, IEditorControl ctl)
        {
            ElementSaveData.ScriptSaveData result = new ElementSaveData.ScriptSaveData();
            if (dictionary != null)
            {
                int dictionaryCount = 0;
                foreach (var item in dictionary.Items)
                {
                    string keyValue;
                    if (string.IsNullOrEmpty(ctl.GetString("source")))
                    {
                        keyValue = GetValueProviderString(provider, string.Format("{0}-key{1}", key, dictionaryCount));
                    }
                    else
                    {
                        // key is not editable when a source is specified
                        keyValue = item.Key;
                    }
                    result.Attributes.Add(string.Format("key{0}", dictionaryCount), keyValue);

                    string valueValue = GetValueProviderString(provider, string.Format("{0}-value{1}", key, dictionaryCount));
                    result.Attributes.Add(string.Format("value{0}", dictionaryCount), valueValue);

                    dictionaryCount++;
                }
            }
            return result;
        }
Example #37
0
 public void Initialise(EditorController controller, IEditorControl controlData)
 {
     m_controller = controller;
 }
Example #38
0
 private bool IsControlVisible(IEditorControl ctl)
 {
     bool visible;
     if (SimpleMode && !ctl.IsControlVisibleInSimpleMode)
     {
         visible = false;
     }
     else
     {
         visible = ctl.IsControlVisible(m_data);
     }
     return visible;
 }
Example #39
0
        private void BindControl(ModelBindingContext bindingContext, ElementSaveData result, int gameId, string ignoreExpression, Dictionary<int, Services.EditorService> editorDictionary, Models.Element originalElement, IEditorControl ctl, string controlType, string attribute = null)
        {
            object saveValue = null;
            bool addSaveValueToResult = true;
            if (attribute == null) attribute = ctl.Attribute;

            // check to see if attribute changes from attribute editor is being passed along
            // if so, use the attribute editor value

            if (bindingContext.ValueProvider.ContainsPrefix("attr_" + attribute))
            {
                attribute = "attr_" + attribute;
            }

            switch (controlType)
            {
                case "textbox":
                case "dropdown":
                case "file":
                    saveValue = GetValueProviderString(bindingContext.ValueProvider, attribute);
                    break;
                case "number":
                    string stringValue = GetValueProviderString(bindingContext.ValueProvider, attribute);
                    int intValue;
                    int.TryParse(stringValue, out intValue);
                    int? min = ctl.GetInt("minimum");
                    int? max = ctl.GetInt("maximum");
                    if (min.HasValue && intValue < min) intValue = min.Value;
                    if (max.HasValue && intValue > max) intValue = max.Value;
                    saveValue = intValue;
                    break;
                case "numberdouble":
                    string stringDoubleValue = GetValueProviderString(bindingContext.ValueProvider, attribute);
                    double doubleValue;
                    double.TryParse(stringDoubleValue, System.Globalization.NumberStyles.AllowDecimalPoint | System.Globalization.NumberStyles.AllowLeadingSign, System.Globalization.CultureInfo.InvariantCulture, out doubleValue);
                    double? doubleMin = ctl.GetDouble("minimum");
                    double? doubleMax = ctl.GetDouble("maximum");
                    if (doubleMin.HasValue && doubleValue < doubleMin) doubleValue = doubleMin.Value;
                    if (doubleMax.HasValue && doubleValue > doubleMax) doubleValue = doubleMax.Value;
                    saveValue = doubleValue;
                    break;
                case "richtext":
                    // Replace all new line characters with a <Br/> tag here
                    string richtextValue = GetValueProviderString(bindingContext.ValueProvider, attribute);
                    saveValue = StripHTMLComments(HttpUtility.HtmlDecode(richtextValue.Replace(Environment.NewLine, "<br/>")));
                    break;
                case "checkbox":
                    ValueProviderResult value = bindingContext.ValueProvider.GetValue(attribute);
                    if (value == null)
                    {
                        Logging.Log.ErrorFormat("Expected true/false value for '{0}', but got null", attribute);
                        saveValue = false;
                    }
                    else
                    {
                        saveValue = value.ConvertTo(typeof(bool));
                    }
                    break;
                case "script":
                    saveValue = BindScript(bindingContext.ValueProvider, attribute, originalElement.EditorData, editorDictionary[gameId].Controller, ignoreExpression);
                    break;
                case "multi":
                    string type = WebEditor.Views.Edit.ControlHelpers.GetTypeName(originalElement.EditorData.GetAttribute(attribute));
                    string subControlType = WebEditor.Views.Edit.ControlHelpers.GetEditorNameForType(type, ctl.GetDictionary("editors"));
                    BindControl(bindingContext, result, gameId, ignoreExpression, editorDictionary, originalElement, ctl, subControlType);
                    addSaveValueToResult = false;
                    break;
                case "objects":
                    saveValue = new ElementSaveData.ObjectReferenceSaveData
                    {
                        Reference = GetValueProviderString(bindingContext.ValueProvider, "dropdown-" + attribute)
                    };
                    break;
                case "verbs":
                    IEditorDataExtendedAttributeInfo extendedData = (IEditorDataExtendedAttributeInfo)originalElement.EditorData;
                    foreach (IEditorAttributeData attr in extendedData.GetAttributeData().Where(a => !a.IsInherited))
                    {
                        if (editorDictionary[gameId].Controller.IsVerbAttribute(attr.AttributeName))
                        {
                            object attrValue = extendedData.GetAttribute(attr.AttributeName);
                            string attrStringValue = attrValue as string;
                            IEditableScripts attrScriptValue = attrValue as IEditableScripts;
                            IEditableDictionary<IEditableScripts> attrDictionaryValue = attrValue as IEditableDictionary<IEditableScripts>;
                            if (attrStringValue != null)
                            {
                                BindControl(bindingContext, result, gameId, ignoreExpression, editorDictionary, originalElement, ctl, "textbox", attr.AttributeName);
                            }
                            else if (attrScriptValue != null)
                            {
                                BindControl(bindingContext, result, gameId, ignoreExpression, editorDictionary, originalElement, ctl, "script", attr.AttributeName);
                            }
                            else if (attrDictionaryValue != null)
                            {
                                BindControl(bindingContext, result, gameId, ignoreExpression, editorDictionary, originalElement, ctl, "scriptdictionary", attr.AttributeName);
                            }
                        }
                    }
                    addSaveValueToResult = false;
                    break;
                case "list":
                    addSaveValueToResult = false;
                    break;
                case "pattern":
                    saveValue = new ElementSaveData.PatternSaveData
                    {
                        Pattern = GetValueProviderString(bindingContext.ValueProvider, attribute)
                    };
                    break;
                case "scriptdictionary":
                    var originalDictionary = originalElement.EditorData.GetAttribute(attribute) as IEditableDictionary<IEditableScripts>;
                    saveValue = BindScriptDictionary(bindingContext.ValueProvider, editorDictionary[gameId].Controller, ignoreExpression, originalDictionary, attribute);
                    break;
                case "stringdictionary":
                case "gamebookoptions":
                    var originalStringDictionary = originalElement.EditorData.GetAttribute(attribute) as IEditableDictionary<string>;
                    saveValue = BindStringDictionary(bindingContext.ValueProvider, editorDictionary[gameId].Controller, ignoreExpression, originalStringDictionary, attribute, ctl);
                    break;
                default:
                    if (attribute == null || controlType == null)
                    {
                        addSaveValueToResult = false;
                    }
                    else
                    {
                        throw new ArgumentException(string.Format("Save data model binder not implemented for control type {0}", controlType));
                    }
                    break;
            }

            if (addSaveValueToResult)
            {
                if (result.Values.ContainsKey(attribute))
                {
                    Logging.Log.ErrorFormat("SaveData already contains attribute \"{0}\" - saveValue (\"{1}\") discarded", attribute, saveValue);
                }
                else
                {
                    // remove attr prefix if it is in the attribute name:
                    if (attribute.StartsWith("attr_"))
                    {
                        attribute = attribute.Substring(5);
                    }

                    result.Values.Add(attribute, saveValue);
                }
            }
        }
Example #40
0
 public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     wpfMultiControl.DoInitialise(controller, definition);
 }
Example #41
0
        private void AddControlToGrid(Grid grid, IEditorControl ctl, bool firstControl)
        {
            m_controlUIElements.Add(ctl, new List<UIElement>());

            // Add row
            int currentRow = AddRowToGrid(grid, ctl.Expand);
            bool controlDisplaysOwnCaption = false;
            bool resizableRow = false;
            bool scrollableControl = false;

            Control newControl = InitialiseEditorControl(ctl);
            m_controlUIElements[ctl].Add(newControl);
            newControl.Padding = new Thickness(5);

            if (ctl.ControlType == "title" && !firstControl)
            {
                newControl.Margin = new Thickness(0, 8, 0, 0);
            }

            IElementEditorControl elementEditorControl = newControl as IElementEditorControl;
            if (elementEditorControl != null)
            {
                controlDisplaysOwnCaption = elementEditorControl.Helper.Options.DisplaysOwnCaption;
                resizableRow = elementEditorControl.Helper.Options.Resizable;
                scrollableControl = elementEditorControl.Helper.Options.Scrollable;
            }

            if (!controlDisplaysOwnCaption && !string.IsNullOrEmpty(ctl.Caption))
            {
                Label newLabel = new Label();
                m_controlUIElements[ctl].Add(newLabel);
                newLabel.Content = ctl.Caption + ":";
                newLabel.Target = newControl;

                if (ctl.Caption.Length > 15)
                {
                    newLabel.Padding = new Thickness(5, 5, 5, 0);
                    newControl.Padding = new Thickness(5, 3, 5, 5);

                    // Create StackPanel, label at top and control underneath
                    Grid subGrid = new Grid();
                    AddRowToGrid(subGrid, false);
                    AddRowToGrid(subGrid, ctl.Expand || resizableRow);

                    m_controlUIElements[ctl].Add(subGrid);

                    // Add label and new control to subgrid
                    Grid.SetRow(newLabel, 0);
                    Grid.SetRow(newControl, 1);
                    subGrid.Children.Add(newLabel);
                    subGrid.Children.Add(newControl);

                    // Add subgrid to parent editor grid
                    Grid.SetColumn(subGrid, 0);
                    Grid.SetRow(subGrid, currentRow);
                    Grid.SetColumnSpan(subGrid, 2);
                    grid.Children.Add(subGrid);
                }
                else
                {
                    newLabel.Padding = new Thickness(5, 7, 5, 5);

                    // Add label to first column
                    Grid.SetColumn(newLabel, 0);
                    Grid.SetRow(newLabel, currentRow);
                    grid.Children.Add(newLabel);

                    // Add control to second column
                    Grid.SetColumn(newControl, 1);
                    Grid.SetRow(newControl, currentRow);
                    grid.Children.Add(newControl);
                }
            }
            else
            {
                // Add control to grid row, colspan=2
                Grid.SetColumn(newControl, 0);
                Grid.SetRow(newControl, currentRow);
                Grid.SetColumnSpan(newControl, 2);
                grid.Children.Add(newControl);
            }

            if (resizableRow)
            {
                // TO DO: Enforce minimum height for resizable rows

                int gridRow = AddRowToGrid(grid);
                GridSplitter splitter = new GridSplitter();
                splitter.Height = 3;
                splitter.HorizontalAlignment = HorizontalAlignment.Stretch;
                splitter.VerticalAlignment = VerticalAlignment.Center;
                Grid.SetColumnSpan(splitter, 2);
                Grid.SetRow(splitter, gridRow);
                grid.Children.Add(splitter);
                m_controlUIElements[ctl].Add(splitter);
            }

            m_lastRowIsResizable = resizableRow;
            m_lastRowIsScrollableAndExpands = scrollableControl && ctl.Expand;
        }
Example #42
0
 public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     m_controller = controller;
     m_definition = definition;
     ctlAttributes.Initialise(controller, definition);
 }
Example #43
0
 public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     m_controller = controller;
     ctlElementsList.Initialise(controller, definition);
 }
Example #44
0
 private void AddEditorControl(IElementEditorControl control, ListBoxItem listItem, IEditorControl ctl)
 {
     m_subControls.Add(control);
     ((Control)control).Tag = listItem;
     ((Control)control).GotFocus += SubControl_GotFocus;
     control.Helper.Dirty += SubControl_Dirty;
     control.Helper.RequestParentElementEditorSave += SubControl_RequestParentElementEditorSave;
     control.Helper.DoInitialise(m_controller, ctl);
 }
Example #45
0
 public void Initialise(EditorController controller, IEditorControl controlData)
 {
     m_controller = controller;
     m_manager.Initialise(controller, controlData, "Page", "Link text");
 }
Example #46
0
        public void CreateControlPropertyWindow(IEditorControl xmlControl)
        {
            XMLPropertyControlBase newPropertyWindow = null;
            if (_propertyWindowPlace != null)
            {
                newPropertyWindow = xmlControl.GetPropertyWindow();
                newPropertyWindow.OnDataSourceChanged += delegate { ApplyDataSource(_currentPropertyWindow); };

                newPropertyWindow.Parent = _propertyWindowPlace;
                newPropertyWindow.Dock = DockStyle.Top;
                newPropertyWindow.Show();
            }

            if (_currentPropertyWindow != null)
            {
                _currentPropertyWindow.Hide();
                _currentPropertyWindow.Dispose();
            }

            _currentPropertyWindow = newPropertyWindow;
        }
Example #47
0
        public void DoInitialise(EditorController controller, IEditorControl definition)
        {
            m_controller = controller;
            m_definition = definition;

            m_settingType = true;
            lstTypes.Items.Clear();
            m_settingType = false;

            m_types = new List<TypesListItem>();

            if (m_definition != null)
            {
                IDictionary<string, string> types = definition.GetDictionary("types");
                InitialiseTypesList(types);

                m_overrideControlTypesMap = definition.GetDictionary("editors");

                string selfCaption = definition.GetString("selfcaption");
                if (selfCaption != null)
                {
                    lblSelfCaption.Visibility = Visibility.Visible;
                    lblSelfCaption.Text = selfCaption + ":";
                }
            }
        }
Example #48
0
 public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     m_controller = controller;
     ctlChild.Initialise(controller);
     ctlElse.Initialise(controller);
 }
Example #49
0
 public PartialViewResult EditGameBookOptions(int id, string key, IEditorControl control)
 {
     return PartialView("StringDictionaryEditor", EditorDictionary[id].GetStringDictionaryModel(id, key, control, ModelState, true));
 }
Example #50
0
        public string GetSelectedDropDownType(IEditorControl ctl, string element)
        {
            const string k_noType = "*";

            IDictionary<string, string> types = ctl.GetDictionary("types");
            List<string> inheritedTypes = new List<string>();

            // The inherited types look like:
            // *=default; typename1=Type 1; typename2=Type2

            // Find out which of the handled types are inherited by the object

            foreach (var item in types.Where(i => i.Key != k_noType))
            {
                if (DoesElementInheritType(element, item.Key))
                {
                    inheritedTypes.Add(item.Key);
                }
            }

            switch (inheritedTypes.Count)
            {
                case 0:
                    // Default - no types inherited
                    return k_noType;
                case 1:
                    return inheritedTypes[0];
                default:
                    return null;
            }
        }
Example #51
0
 public PartialViewResult EditScriptScriptDictionary(int id, string key, string path, IEditorControl control)
 {
     return PartialView("ScriptDictionaryEditor", EditorDictionary[id].GetScriptScriptDictionaryModel(id, key, path, control, ModelState));
 }
Example #52
0
 public void DoUninitialise()
 {
     m_controller = null;
     m_definition = null;
     ctlAttributes.Initialise(null, null);
 }
Example #53
0
 public virtual void Initialise(EditorController controller, IEditorControl controlData)
 {
     m_controller = controller;
     m_controlData = controlData;
 }
Example #54
0
        private Control InitialiseEditorControl(IEditorControl ctl)
        {
            Control newControl = ControlFactory.CreateEditorControl(m_controller, ctl.ControlType);

            IElementEditorControl newElementEditorControl = newControl as IElementEditorControl;
            if (newElementEditorControl != null)
            {
                m_controls.Add(newElementEditorControl);
                newElementEditorControl.Helper.Dirty += Control_Dirty;
                newElementEditorControl.Helper.RequestParentElementEditorSave += Control_RequestParentElementEditorSave;
                newElementEditorControl.Helper.DoInitialise(m_controller, ctl);
            }

            return (Control)newControl;
        }
Example #55
0
 public void DoInitialise(EditorController controller, IEditorControl definition)
 {
     ctlScript.Helper.DoInitialise(controller, definition);
 }
Example #56
0
        public static void PopulateRichTextControlModel(IEditorControl ctl, EditorController controller, RichTextControl model)
        {
            if (ctl.GetBool("notextprocessor")) return;

            var commandDataList = controller.GetElementDataAttribute("_RichTextControl_TextProcessorCommands", "data") as IEnumerable;

            model.TextProcessorCommands = (from IDictionary<string, string> commandData in commandDataList
                                           select new RichTextControl.TextProcessorCommand
                                           {
                                               Command = GetDictionaryValue(commandData, "command"),
                                               Info = GetDictionaryValue(commandData, "info"),
                                               InsertBefore = GetDictionaryValue(commandData, "insertbefore"),
                                               InsertAfter = GetDictionaryValue(commandData, "insertafter"),
                                               Source = GetDictionaryValue(commandData, "source"),
                                               Extensions = GetExtensions(commandData)
                                           });

        }