コード例 #1
0
ファイル: NodeInfo.cs プロジェクト: 3dfxdev/3DGE_Builder
//comment
        private void SetComment(string comment)
        {
            UniFields fields = GetFields();

            if (comment.Length == 0)
            {
                if (fields.ContainsKey("comment"))
                {
                    General.Map.UndoRedo.CreateUndo("Remove comment");
                    fields.BeforeFieldsChange();
                    fields.Remove("comment");
                }
                return;
            }

            //create undo stuff
            General.Map.UndoRedo.CreateUndo("Set comment");
            fields.BeforeFieldsChange();

            if (!fields.ContainsKey("comment"))
            {
                fields.Add("comment", new UniValue((int)UniversalType.String, comment));
            }
            else
            {
                fields["comment"].Value = comment;
            }
        }
コード例 #2
0
 protected void Apply(UniFields other, string key)
 {
     if (uifields.ContainsKey(key))
     {
         other[key] = new UniValue(uifields[key]);
     }
     else if (other.ContainsKey(key))
     {
         other.Remove(key);
     }
 }
コード例 #3
0
        protected void ApplyCustomFields(UniFields other)
        {
            // Remove custom fields
            string[] keys = new string[other.Keys.Count];
            other.Keys.CopyTo(keys, 0);
            foreach (string key in keys)
            {
                if (!General.Map.FormatInterface.UIFields[elementtype].ContainsKey(key))
                {
                    other.Remove(key);
                }
            }

            // Replace with stored custom fields
            foreach (KeyValuePair <string, UniValue> group in fields)
            {
                other.Add(group.Key, new UniValue(group.Value));
            }
        }
コード例 #4
0
        //mxd
        public void ApplyUserVars(Dictionary <string, UniversalType> vars, UniFields tofields)
        {
            // Apply user variables when target map element contains user var definition and the value is not default
            foreach (DataGridViewRow row in fieldslist.Rows)
            {
                // Row is a field?
                if (row is FieldsEditorRow)
                {
                    FieldsEditorRow frow = row as FieldsEditorRow;
                    if (frow.RowType != FieldsEditorRowType.USERVAR || !vars.ContainsKey(frow.Name))
                    {
                        continue;
                    }

                    object oldvalue = (tofields.ContainsKey(frow.Name) ? tofields[frow.Name].Value : null);
                    object newvalue = frow.GetResult(oldvalue);

                    // Skip field when mixed values
                    if (newvalue == null)
                    {
                        continue;
                    }

                    // Remove field
                    if (newvalue.Equals(frow.TypeHandler.GetDefaultValue()))
                    {
                        if (tofields.ContainsKey(frow.Name))
                        {
                            tofields.Remove(frow.Name);
                        }
                    }
                    // Add field
                    else if (!newvalue.Equals(oldvalue))
                    {
                        tofields[frow.Name] = new UniValue(frow.TypeHandler.Index, newvalue);
                    }
                }
            }
        }
コード例 #5
0
        // This applies the current fields to a UniFields object
        public void Apply(UniFields tofields)
        {
            tofields.BeforeFieldsChange();

            // Go for all the fields
            UniFields tempfields = new UniFields(tofields);

            foreach (KeyValuePair <string, UniValue> f in tempfields)
            {
                if (uifields.ContainsKey(f.Key))
                {
                    continue;                                             //mxd
                }
                // Go for all rows
                bool foundrow = false;
                bool skiprow  = false;                //mxd
                foreach (DataGridViewRow row in fieldslist.Rows)
                {
                    // Row is a field and matches field name?
                    if ((row is FieldsEditorRow) && (row.Cells[0].Value.ToString() == f.Key))
                    {
                        FieldsEditorRow frow = row as FieldsEditorRow;

                        //mxd. User vars are stored separately
                        if (frow.RowType == FieldsEditorRowType.USERVAR)
                        {
                            skiprow = true;
                            break;
                        }

                        // Field is defined?
                        if (frow.IsDefined)
                        {
                            foundrow = true;
                            break;
                        }
                    }
                }

                //mxd. User vars are stored separately
                if (skiprow)
                {
                    continue;
                }

                // No such row?
                if (!foundrow)
                {
                    // Remove the definition from the fields
                    tofields.Remove(f.Key);
                }
            }

            // Go for all rows
            foreach (DataGridViewRow row in fieldslist.Rows)
            {
                // Row is a field?
                if (row is FieldsEditorRow)
                {
                    FieldsEditorRow frow = row as FieldsEditorRow;

                    // Field is defined and not empty?
                    if (frow.RowType != FieldsEditorRowType.USERVAR && frow.IsDefined && !frow.IsEmpty)
                    {
                        // Apply field
                        object oldvalue = null;
                        if (tofields.ContainsKey(frow.Name))
                        {
                            oldvalue = tofields[frow.Name].Value;
                        }
                        tofields[frow.Name] = new UniValue(frow.TypeHandler.Index, frow.GetResult(oldvalue));

                        // Custom row?
                        if (frow.RowType == FieldsEditorRowType.DYNAMIC)
                        {
                            // Write type to map configuration
                            General.Map.Options.SetUniversalFieldType(elementname, frow.Name, frow.TypeHandler.Index);
                        }
                    }
                }
            }
        }