コード例 #1
0
        protected virtual void ItemsListViewMouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (SelectedItem == null)
            {
                return;
            }
            DisplayerAttribute da =
                (DisplayerAttribute)_viewedType.GetCustomAttributes(typeof(DisplayerAttribute), false)
                .FirstOrDefault();

            if (da == null || da.DisplayerType == DisplayerType.Form)
            {
                Form form;
                if (SelectedItem is AircraftWorkerCategory)
                {
                    form = new AircraftWorkerCategoryForm((AircraftWorkerCategory)SelectedItem);
                }
                else if (SelectedItem is AccessoryDescription)
                {
                    form = new AccessoryDescriptionForm((AccessoryDescription)SelectedItem);
                }
                else if (SelectedItem is AccessoryRequired)
                {
                    form = new KitForm((AccessoryRequired)SelectedItem);
                }
                else
                {
                    form = new CommonEditorForm(SelectedItem);
                }
                if (form.ShowDialog() == DialogResult.OK)
                {
                    itemsListView.Items[itemsListView.Items.IndexOf(itemsListView.SelectedItems[0])] =
                        new ListViewItem(GetListViewSubItems(SelectedItem), null)
                    {
                        Tag = SelectedItem
                    };
                }
            }
            else if (da.DisplayerType == DisplayerType.Screen)
            {
                OnDisplayerRequested();
            }
        }
コード例 #2
0
        private void ButtonAddClick(object sender, EventArgs e)
        {
            try
            {
                Form form;

                if (ViewedType.Name == typeof(AircraftWorkerCategory).Name)
                {
                    form = new AircraftWorkerCategoryForm(new AircraftWorkerCategory());
                }
                else if (ViewedType.Name == typeof(AccessoryDescription).Name)
                {
                    form = new AccessoryDescriptionForm(new AccessoryDescription());
                }
                else if (ViewedType.Name == typeof(AccessoryRequired).Name)
                {
                    form = new KitForm(new AccessoryRequired());
                }
                else
                {
                    ConstructorInfo  ci   = ViewedType.GetConstructor(new Type[0]);
                    BaseEntityObject item = (BaseEntityObject)ci.Invoke(null);
                    form = new CommonEditorForm(item);
                }
                if (form.ShowDialog() == DialogResult.OK)
                {
                    itemsListView.Items[itemsListView.Items.IndexOf(itemsListView.SelectedItems[0])] =
                        new ListViewItem(GetListViewSubItems(SelectedItem), null)
                    {
                        Tag = SelectedItem
                    };
                }
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while building new object", ex);
                return;
            }
        }