Beispiel #1
0
        internal void AddItem()
        {
            if (this.CurrentFileType != FileType.Unknown)
            {
                switch (this.CurrentFileType)
                {
                case FileType.Categories:
                    CategoryEditorView formCategory = new CategoryEditorView();
                    formCategory.ShowDialog();
                    break;

                case FileType.Manufacturers:
                    ManufacturerEditorView formManufacturer = new ManufacturerEditorView();
                    formManufacturer.ShowDialog();
                    break;

                case FileType.Stores:
                    StoreEditorView formStore = new StoreEditorView();
                    formStore.ShowDialog();
                    break;

                case FileType.Gauges:
                    GaugeEditorView formScale = new GaugeEditorView();
                    formScale.ShowDialog();
                    break;

                case FileType.Decoders:
                    DecoderEditorView formDecoder = new DecoderEditorView();
                    formDecoder.ShowDialog();
                    break;

                case FileType.RailwayCompanies:
                    CompanyEditorView formAdmin = new CompanyEditorView();
                    formAdmin.ShowDialog();
                    break;

                default:
                    break;
                }
            }
            else if (this.CurrentCategory != null)
            {
                StudioContext.OpenPluginModule(ModelModuleDescriptor.MODULE_GUID, null);
            }

            this.Refresh();
        }
Beispiel #2
0
        internal void EditItem()
        {
            if (grdDataView.SelectedRowsCount <= 0)
            {
                MessageBox.Show("You must select the row you want to edit.",
                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // Get the current row
            int[] rows = grdDataView.GetSelectedRows();
            ORMIdentifiableEntity row = grdDataView.GetRow(rows[0]) as ORMIdentifiableEntity;

            if (row == null)
            {
                return;
            }

            if (this.CurrentFileType != FileType.Unknown)
            {
                switch (this.CurrentFileType)
                {
                case FileType.Categories:
                    Category category = Category.Get(row.ID);
                    if (category != null)
                    {
                        CategoryEditorView formCategoryEditor = new CategoryEditorView(category);
                        formCategoryEditor.ShowDialog();
                    }
                    break;

                case FileType.Manufacturers:
                    Manufacturer manufacturer = Manufacturer.Get(row.ID);
                    if (manufacturer != null)
                    {
                        ManufacturerEditorView formStore = new ManufacturerEditorView(manufacturer);
                        formStore.ShowDialog();
                    }
                    break;

                case FileType.Stores:
                    Store store = Store.Get(row.ID);
                    if (store != null)
                    {
                        StoreEditorView formStore = new StoreEditorView(store);
                        formStore.ShowDialog();
                    }
                    break;

                case FileType.Gauges:
                    Rwm.Otc.Trains.Gauge scale = Rwm.Otc.Trains.Gauge.Get(row.ID);
                    if (scale != null)
                    {
                        GaugeEditorView formScale = new GaugeEditorView(scale);
                        formScale.ShowDialog();
                    }
                    break;

                case FileType.Decoders:
                    TrainDecoder decoder = TrainDecoder.Get(row.ID);
                    if (decoder != null)
                    {
                        DecoderEditorView formDecoder = new DecoderEditorView(decoder);
                        formDecoder.ShowDialog();
                    }
                    break;

                case FileType.RailwayCompanies:
                    Company admin = Company.Get(row.ID);
                    if (admin != null)
                    {
                        CompanyEditorView formAdmin = new CompanyEditorView(admin);
                        formAdmin.ShowDialog();
                    }
                    break;

                default:
                    break;
                }
            }
            else if (this.CurrentCategory != null)
            {
                StudioContext.OpenPluginModule(ModelModuleDescriptor.MODULE_GUID, row.ID);
            }

            this.Refresh();
        }