예제 #1
0
 private void tryDeleteType()
 {
     if (this.lbTypes.SelectedIndex >= 0)
     {
         MetaList <MetaType> types = this.model.Types;
         if (types.Count == 1)
         {
             MetaType metaType = (MetaType)this.lbTypes.SelectedItem;
             MessageBox.Show(string.Format(errorLastTypeDelete, metaType.Name), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MetaType metaType = (MetaType)this.lbTypes.SelectedItem;
             if (!types.Contains(metaType))
             {
                 MessageBox.Show(string.Format(errorClassDelete, metaType.Name), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 this.model.DeleteTypeAt(this.lbTypes.SelectedIndex);
                 this.RefreshData();
             }
         }
     }
 }
예제 #2
0
 private void onFormClosing(object sender, FormClosingEventArgs e)
 {
     MetaList<MetaValue> keys = new MetaList<MetaValue>();
     foreach (MetaValue key in this.vdValues.Keys)
     {
         if (keys.Contains(key))
         {
             e.Cancel = true;
             MessageBox.Show(ERROR_DUPLICATE_KEYS, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             break;
         }
         keys.Add(key);
     }
 }
예제 #3
0
        private void onFormClosing(object sender, FormClosingEventArgs e)
        {
            MetaList <MetaValue> keys = new MetaList <MetaValue>();

            foreach (MetaValue key in this.vdValues.Keys)
            {
                if (keys.Contains(key))
                {
                    e.Cancel = true;
                    MessageBox.Show(ERROR_DUPLICATE_KEYS, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
                keys.Add(key);
            }
        }
예제 #4
0
        public override bool Update(Model model)
        {
            this.model = model;
            if (this.visibleClasses == null)
            {
                this.visibleClasses = new MetaList <MetaClass>(model.LeafClasses);
            }
            MetaList <MetaClass> oldVisibleClasses = new MetaList <MetaClass>(this.visibleClasses);

            this.visibleClasses.Clear();
            MetaList <MetaClass> keys    = this.values.GetKeys();
            MetaList <MetaClass> classes = new MetaList <MetaClass>(model.LeafClasses);
            MetaClass            keyClass;
            MetaList <MetaValue> values;

            foreach (MetaClass metaClass in classes)
            {
                // cannot use "ContainsKey" because "GetHashCode" was not implemented
                // and ContainsKey seems to use it to determine object identity rather than "Equals"
                if (!keys.Contains(metaClass))
                {
                    this.values[metaClass] = new MetaList <MetaValue>();
                    this.visibleClasses.Add(metaClass);
                }
                else
                {
                    keyClass = keys[keys.IndexOf(metaClass)];
                    values   = this.values[keyClass];
                    this.values.Remove(keyClass);
                    this.values[metaClass] = values;
                    if (oldVisibleClasses.Contains(keyClass))
                    {
                        this.visibleClasses.Add(metaClass);
                    }
                }
            }
            foreach (KeyValuePair <MetaClass, MetaList <MetaValue> > pair in this.values)
            {
                foreach (MetaValue value in pair.Value)
                {
                    if (!value.Update(model))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }