Ejemplo n.º 1
0
        public XmlFormatingSettings Clone()
        {
            XmlFormatingSettings clone = (XmlFormatingSettings)MemberwiseClone();

            clone.scope = new List <string> (scope);
            return(clone);
        }
        string GetName(XmlFormatingSettings format)
        {
            if (format == policy.DefaultFormat)
            {
                return(GettextCatalog.GetString("Default"));
            }

            string name = "";

            foreach (string s in format.ScopeXPath)
            {
                if (name.Length != 0)
                {
                    name += ", ";
                }
                name += s;
            }
            if (name.Length != 0)
            {
                return(name);
            }
            else
            {
                int i = policy.Formats.IndexOf(format) + 1;
                return(string.Format(GettextCatalog.GetString("Format #{0}"), i));
            }
        }
        protected virtual void OnButtonAddClicked(object sender, System.EventArgs e)
        {
            XmlFormatingSettings format = new XmlFormatingSettings();

            policy.Formats.Add(format);
            TreeIter it = AppendSettings(format);

            listView.Selection.SelectIter(it);
        }
        void UpdateCurrentName()
        {
            TreeIter it;

            if (listView.Selection.GetSelected(out it))
            {
                XmlFormatingSettings s = (XmlFormatingSettings)store.GetValue(it, 1);
                store.SetValue(it, 0, GetName(s));
            }
        }
 void CleanScopes(XmlFormatingSettings format)
 {
     for (int n = format.ScopeXPath.Count - 1; n >= 0; n--)
     {
         if (format.ScopeXPath [n].Length == 0)
         {
             format.ScopeXPath.RemoveAt(n);
         }
     }
 }
 void FillFormat(XmlFormatingSettings format)
 {
     currentFormat = format;
     if (currentFormat != null && currentFormat.ScopeXPath.Count == 0)
     {
         currentFormat.ScopeXPath.Add("");
     }
     propertyGrid.CurrentObject = format;
     UpdateScopes();
     propertyGrid.Sensitive = currentFormat != null;
 }
        void UpdateButtons()
        {
            TreeIter it;

            if (listView.Selection.GetSelected(out it))
            {
                XmlFormatingSettings s = (XmlFormatingSettings)store.GetValue(it, 1);
                buttonAdd.Sensitive    = true;
                buttonRemove.Sensitive = s != policy.DefaultFormat;
            }
            else
            {
                buttonAdd.Sensitive = buttonRemove.Sensitive = false;
            }
        }
        void HandleListViewSelectionChanged(object sender, EventArgs e)
        {
            TreeIter it;

            if (listView.Selection.GetSelected(out it))
            {
                XmlFormatingSettings s = (XmlFormatingSettings)store.GetValue(it, 1);
                FillFormat(s);
            }
            else
            {
                FillFormat(null);
            }
            UpdateButtons();
        }
        protected virtual void OnButtonRemoveClicked(object sender, System.EventArgs e)
        {
            TreeIter it;

            if (listView.Selection.GetSelected(out it))
            {
                XmlFormatingSettings s = (XmlFormatingSettings)store.GetValue(it, 1);
                policy.Formats.Remove(s);
                TreePath p = store.GetPath(it);
                store.Remove(ref it);
                if (store.IterIsValid(it))
                {
                    listView.Selection.SelectIter(it);
                }
                else
                {
                    if (p.Prev())
                    {
                        store.GetIter(out it, p);
                        listView.Selection.SelectIter(it);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public bool Equals(XmlFormatingSettings other)
        {
            if (scope.Count != other.scope.Count)
            {
                return(false);
            }
            List <string> list = new List <string> (other.scope.Count);

            foreach (string s in scope)
            {
                int n = list.IndexOf(s);
                if (n == -1)
                {
                    return(false);
                }
                list.RemoveAt(n);
            }

            return(NewLineChars == other.NewLineChars &&
                   OmitXmlDeclaration == other.OmitXmlDeclaration &&
                   IndentContent == other.IndentContent &&
                   ContentIndentString == other.ContentIndentString &&
                   AttributesInNewLine == other.AttributesInNewLine &&
                   MaxAttributesPerLine == other.MaxAttributesPerLine &&
                   AttributesIndentString == other.AttributesIndentString &&
                   AlignAttributes == other.AlignAttributes &&
                   WrapAttributes == other.WrapAttributes &&
                   AlignAttributeValues == other.AlignAttributeValues &&
                   SpacesBeforeAssignment == other.SpacesBeforeAssignment &&
                   SpacesAfterAssignment == other.SpacesAfterAssignment &&
                   QuoteChar == other.QuoteChar &&
                   EmptyLinesBeforeStart == other.EmptyLinesBeforeStart &&
                   EmptyLinesAfterStart == other.EmptyLinesAfterStart &&
                   EmptyLinesBeforeEnd == other.EmptyLinesBeforeEnd &&
                   EmptyLinesAfterEnd == other.EmptyLinesAfterEnd);
        }
 TreeIter AppendSettings(XmlFormatingSettings format)
 {
     return(store.AppendValues(GetName(format), format));
 }