Exemple #1
0
        private void ComboBoxCreate_SelectionChangeCommitted(object sender, EventArgs e)
        {
            IFactory   factory = (IFactory)ComboBoxCreate.SelectedItem;
            BaseObject obj     = factory.CreateObject();

            obj.Update(applicationDataContext, true);
        }
Exemple #2
0
 private void GetProperties(Form form, BaseObject obj, ref int y, ApplicationDataContext applicationDataContext)
 {
     foreach (PropertyInfo property in obj.GetType().GetProperties())
     {
         LabelAttribute attribute = property.GetCustomAttributes(true).OfType <LabelAttribute>().First();
         Controls.AddLabel(form, y, 0, ControlWidth, ControlHeight, attribute.LabelText);
         if (property.PropertyType.IsGenericType)
         {
             IList list = (IList)property.GetValue(obj);
             Controls.AddComboBox(form, y, ControlWidth, ControlWidth, ControlHeight, list.Cast <object>().ToArray(), "");
         }
         else
         if (property.PropertyType.IsEnum)
         {
             Controls.AddComboBox(form, y, ControlWidth, ControlWidth, ControlHeight, property.PropertyType.GetEnumNames(), property.GetValue(obj).ToString());
         }
         else
         if (property.PropertyType == typeof(int) || property.PropertyType == typeof(string))
         {
             Controls.AddTextBox(form, y, ControlWidth, ControlWidth, ControlHeight, property.GetValue(obj)?.ToString());
         }
         else
         if (property.PropertyType.GetCustomAttributes(true).OfType <CommunicationTypeAttribute>().First().CommunicationType == "Композиция")
         {
             Button createObjectButton = Controls.AddButton(form, y, ControlWidth, ControlWidth, ControlHeight, "Посмотреть объект");
             createObjectButton.Click += (sender, e) =>
             {
                 BaseObject newObj = (BaseObject)property.GetValue(obj);
                 newObj.Update(applicationDataContext, false);
             };
         }
         else
         {
             List <BaseObject> list = new List <BaseObject>();
             foreach (BaseObject element in applicationDataContext.Objects)
             {
                 if (element.GetType() == property.PropertyType && element != property.GetValue(this))
                 {
                     list.Add(element);
                 }
             }
             Controls.AddComboBox(form, y, ControlWidth, ControlWidth, ControlHeight, list.Cast <object>().ToArray(), property.GetValue(this));
         }
         y += ControlHeight * 2;
     }
 }
Exemple #3
0
        private void ButtonUpdateObject_Click(object sender, EventArgs e)
        {
            BaseObject selectedItem = (BaseObject)this.ComboBoxObjects.SelectedItem;

            selectedItem.Update(applicationDataContext, false);
        }