Beispiel #1
0
//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;
            }
        }
Beispiel #2
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);
                        }
                    }
                }
            }
        }