コード例 #1
0
ファイル: Form1.cs プロジェクト: mdialogo/MVP_Tutorial
        public Form1()
        {
            InitializeComponent();

            _presenter = new DataPresenter(this);
            _presenter.Display("test.csv");
        }
コード例 #2
0
ファイル: DataStorage.cs プロジェクト: standy66/AlchemyGame
 public void LoadData(string fileName)
 {
     using (Stream stream = File.OpenRead(fileName))
     {
         BinaryFormatter deserializer = new BinaryFormatter();
         data = (DataPresenter)deserializer.Deserialize(stream);
     }
 }
コード例 #3
0
 private ICommandService GetCommandService(DataPresenter dataPresenter)
 {
     return(dataPresenter.GetService <ICommandService>());
 }
コード例 #4
0
        private void ExecLookup()
        {
            var lookupService = DataPresenter?.GetService <ILookupService>();

            lookupService.BeginLookup(this);
        }
コード例 #5
0
ファイル: InPlaceEditor.cs プロジェクト: xydoublez/RDO.Net
 public void Initialize(DataPresenter dataPresenter)
 {
     DataPresenter = dataPresenter;
 }
コード例 #6
0
        /// <summary>
        /// Creates and returns the <see cref="BaseItemsControlPage{TClass}.DataPresenter"/>
        /// </summary>
        /// <returns></returns>
        protected override IDataPresenter <DataGridPresenterMap> CreateDataPresenter()
        {
            var collapsibleDataGrid = new CollapsibleDataGrid <DataGridPresenterMap>()
            {
                Mapper = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value
            }
            .ShowData(x => x.Name)
            .ShowData(x => x.Description)
            .ShowData(x => x.DataGrids)

            .SetColorUIElement(x => x.Color)
            .SetDataPresenterSubElement(x => x.DataGrids, model => model.DataGrids.Count().ToString("grid", "grids", "No grids"), (model) =>
            {
                var dataGrid = new CollapsibleDataGrid <DataGridMap>()
                {
                    Translator = CeidDiplomatikiDataModelHelpers.DataGridMapTranslator.Value, Mapper = CeidDiplomatikiDataModelHelpers.DataGridMapMapper.Value
                }
                .ShowData(x => x.Type)
                .ShowData(x => x.AllowAdd)
                .ShowData(x => x.AllowEdit)
                .ShowData(x => x.AllowDelete)
                .ShowData(x => x.Columns)
                .ShowData(x => x.DateColumn)
                .ShowData(x => x.SearchColumns)

                .SetBooleanUIElement(x => x.AllowAdd)
                .SetBooleanUIElement(x => x.AllowEdit)
                .SetBooleanUIElement(x => x.AllowDelete)

                .SetCustomUIElement(x => x.DateColumn,
                                    (grid, row, model) =>
                {
                    return(new TextButton()
                    {
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment = VerticalAlignment.Center,
                        Text = model.DateColumn?.Name,
                        BorderThickness = new Thickness(VisibleBorderThickness),
                        Command = new RelayCommand(async() =>
                        {
                            // Show the dialog
                            var dialogResult = await DialogHelpers.ShowUniformGridSelectSingleDialogAsync(this, "Date column selection", null, model.Type.GetProperties().Where(x => x.PropertyType.IsDate()), (prop) => new InformationalButton()
                            {
                                Text = prop.Name
                            }, null, IconPaths.CalendarCheckPath);

                            // If we didn't get positive feedback...
                            if (!dialogResult.Feedback)
                            {
                                // Return
                                return;
                            }

                            // Update the model
                            model.DateColumn = dialogResult.Model;

                            var result = await CeidDiplomatikiDI.GetCeidDiplomatikiManager.SaveChangesAsync();

                            // If there was an error...
                            if (!result.Successful)
                            {
                                // Show the error
                                await result.ShowDialogAsync(this);

                                // Return
                                return;
                            }

                            // Update the grid
                            grid.Update(model);
                        })
                    });
                },
                                    (grid, row, model, element) => element.Text = model.DateColumn?.Name)

                .SetDataPresenterSubElement(propertySelector: x => x.Columns,
                                            textValueExtractor: model => model.Columns?.Count().ToString("column", "columns", "No columns"),
                                            presenterImplementationFactory: model =>
                {
                    return(new DataGrid <PropertyInfo>()
                           .ShowData(x => x.Name, RelationalAnalyzersHelpers.DbProviderColumnMapper.Value.GetTitle(x => x.ColumnName)));
                },
                                            optionButtonConfiguration: (p, m, b) =>
                {
                    b.VectorSource = IconPaths.EditPath;

                    b.Command = new RelayCommand(async() =>
                    {
                        // Create the form
                        var form = new OptionsSelectionForm <PropertyInfo>();

                        // For every column
                        foreach (var column in m.Type.GetProperties())
                        {
                            // Show it for selection
                            form.ShowOption(column, column.Name, null, null, m.Columns.Any(x => x.Equals(column)));
                        }

                        // Show the dialog
                        var dialogResult = await DialogHelpers.ShowSelectMultipleDialogAsync(this, "Columns selection", null, form);

                        // If we didn't get positive feedback...
                        if (!dialogResult.Feedback)
                        {
                            // Return
                            return;
                        }

                        // Update the columns
                        m.Columns = form.GetOptions();

                        // Get the manager
                        var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                        // Save the changes
                        var result = await manager.SaveChangesAsync();

                        // If there was an error...
                        if (!result.Successful)
                        {
                            // Show the error
                            await result.ShowDialogAsync(this);

                            // Return
                            return;
                        }

                        p.SetItemsSource(m.Columns);

                        DataPresenter.Update(model);
                    });
                })
                .SetDataPresenterSubElement(propertySelector: x => x.SearchColumns,
                                            textValueExtractor: model => model.SearchColumns?.Count().ToString("column", "columns", "No columns"),
                                            presenterImplementationFactory: model =>
                {
                    return(new DataGrid <PropertyInfo>()
                           .ShowData(x => x.Name, RelationalAnalyzersHelpers.DbProviderColumnMapper.Value.GetTitle(x => x.ColumnName)));
                },
                                            optionButtonConfiguration: (p, m, b) =>
                {
                    b.VectorSource = IconPaths.EditPath;

                    b.Command = new RelayCommand(async() =>
                    {
                        // Create the form
                        var form = new OptionsSelectionForm <PropertyInfo>();

                        // For every column
                        foreach (var column in m.Type.GetProperties().Where(x => x.PropertyType == typeof(string)))
                        {
                            // Show it for selection
                            form.ShowOption(column, column.Name, null, null, m.SearchColumns.Any(x => x.Equals(column)));
                        }

                        // Show the dialog
                        var dialogResult = await DialogHelpers.ShowSelectMultipleDialogAsync(this, "Search columns selection", null, form);

                        // If we didn't get positive feedback...
                        if (!dialogResult.Feedback)
                        {
                            // Return
                            return;
                        }

                        // Update the columns
                        m.SearchColumns = form.GetOptions();

                        // Get the manager
                        var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                        // Save the changes
                        var result = await manager.SaveChangesAsync();

                        // If there was an error...
                        if (!result.Successful)
                        {
                            // Show the error
                            await result.ShowDialogAsync(this);

                            // Return
                            return;
                        }

                        p.SetItemsSource(m.SearchColumns);

                        DataPresenter.Update(model);
                    });
                });
                dataGrid.ConfigureOptions((container, grid, row, model) =>
                {
                    container.AddEditOption("Data grid modification", null, () =>
                    {
                        return(new DataForm <DataGridMap>()
                        {
                            Mapper = CeidDiplomatikiDataModelHelpers.DataGridMapMapper.Value
                        }
                               .ShowInput(x => x.AllowAdd)
                               .ShowInput(x => x.AllowEdit)
                               .ShowInput(x => x.AllowDelete));
                    }, async model => await CeidDiplomatikiDI.GetCeidDiplomatikiManager.SaveChangesAsync());
                });

                return(dataGrid);
            });

            collapsibleDataGrid.ConfigureOptions((container, grid, row, model) =>
            {
                container.AddEditOption("Data grid presenter modification", null, () =>
                {
                    return(new DataForm <DataGridPresenterMap>()
                    {
                        Mapper = CeidDiplomatikiDataModelHelpers.DataGridPresenterMapMapper.Value
                    }
                           .ShowInput(x => x.Name, settings => settings.IsRequired = true)
                           .ShowInput(x => x.Description)
                           .ShowStringColorInput(x => x.Color));
                }, async model => await CeidDiplomatikiDI.GetCeidDiplomatikiManager.SaveChangesAsync());
                container.AddDeleteOption("Data grid presenter deletion", null, async model =>
                {
                    // Get the manager
                    var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                    // Unregister the data presenter
                    QueryMap.Remove(model);

                    // Save the changes
                    return(await manager.SaveChangesAsync());
                });
            });

            return(collapsibleDataGrid);
        }
コード例 #7
0
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Disable the button
                AddButton.IsEnabled = false;

                // Create a steps presenter
                var stepsPresenter = new StepsPresenter()
                {
                    AllowArbitraryNavigation = false
                };

                // Create a columns container
                var propertiesContainer = new UniformGridCollapsibleVerticalMenuCategorizingItemsControl <PropertyInfo, InformationalButton>()
                {
                    Columns            = 3,
                    CategoryNameGetter = (prop) => prop.DeclaringType.Name.Split("-").Last()
                };

                propertiesContainer.Linker = (prop) => new InformationalButton()
                {
                    MinWidth = 0,
                    Text     = prop.Name,
                    Command  = new RelayCommand(() =>
                    {
                        foreach (var element in propertiesContainer.Elements)
                        {
                            element.Selected = false;
                        }

                        propertiesContainer.GetElement(prop).Selected = true;
                    })
                };

                // Add the tables
                propertiesContainer.SetItemsSource(QueryMap.DataModelTypes.SelectMany(x => x.GetProperties().Where(y => !DataPresenter.Items.Any(z => z.PropertyInfo == y))).OrderBy(x => x.Name));

                // Add it to the steps presenter
                stepsPresenter.Add("Property", propertiesContainer, (element) => element.Elements.Any(x => x.Selected));

                // Create the form
                var form = new DataForm <PropertyMap>()
                {
                    Mapper = CeidDiplomatikiDataModelHelpers.PropertyMapMapper.Value
                }
                .ShowInput(x => x.Name, settings => settings.IsRequired = true)
                .ShowInput(x => x.Description)
                .ShowStringColorInput(x => x.Color)
                .ShowSelectMultipleOptionsInput(x => x.Attributes, (form, propertyInfo) => new DropDownMenuOptionsFormInput <ColumnAttribute>(form, propertyInfo, ColumnAttributes.Data.Value, x => x.Name), null, settings => settings.IsRequired = true)
                .ShowNumericInput(x => x.Order)
                .ShowInput(x => x.DefaultValue)
                .ShowInput(x => x.IsEditable)
                .ShowInput(x => x.IsRequired)
                .ShowInput(x => x.IsPreview);

                // Add it to the steps presenter
                stepsPresenter.Add("Info", form, (element) => element.Validate());

                // Show a dialog
                var dialogResult = await DialogHelpers.ShowStepsDialogAsync(this, "Property map creation", null, stepsPresenter, IconPaths.TableColumnPath);

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Get the selected property
                var property = propertiesContainer.Get(propertiesContainer.Elements.First(x => x.Selected));

                // Create the model
                var model = new PropertyMap(QueryMap, property.DeclaringType, property, QueryMap.GetColumnOrNull(property));

                // Set it to the form
                form.Model = model;

                // Update its values
                form.UpdateModelValues();

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register the model
                QueryMap.Add(model);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Add it to the presenter
                DataPresenter.Add(model);

                // Re enable the button
                AddButton.IsEnabled = true;
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }
コード例 #8
0
 public Presenter(DataPresenter target)
 {
     _target = target;
 }
コード例 #9
0
 private void Select(RowPresenter rowPresenter, SelectionMode selectionMode, bool ensureVisible = true)
 {
     DataPresenter.Select(rowPresenter, selectionMode, ensureVisible);
 }
コード例 #10
0
ファイル: ColumnHeader.cs プロジェクト: xydoublez/RDO.Net
 private void UpdateVisualState(DataPresenter dataPresenter)
 {
     UpdateVisualState(dataPresenter, true);
 }
コード例 #11
0
ファイル: DataForm.cs プロジェクト: bug8975/FET
 private DataForm()
 {
     InitializeComponent();
     dataPresenter = new DataPresenter(this);
 }
コード例 #12
0
        /// <summary>
        /// Creates and adds the required GUI elements
        /// </summary>
        private void CreateGUI()
        {
            // Create the add button
            AddButton = ControlsFactory.CreateStandardAddCircularButton();

            AddButton.Command = new RelayCommand(async() =>
            {
                // Create the component
                var component = new DatabaseOptionComponentsContainer();

                // Add the options
                component.Add(new SQLiteOptionsComponent(new SQLiteOptionsDataModel()));
                component.Add(new MySQLOptionsComponent(new MySQLOptionsDataModel()));
                component.Add(new SQLServerOptionsComponent(new SQLServerOptionsDataModel()));
                component.Add(new PostgreSQLOptionsComponent(new PostgreSQLOptionsDataModel()));

                // Show the dialog
                var dialogResult = await DialogHelpers.ShowValidationDialogAsync(this, "Database addition", null, component, (element) =>
                {
                    // TODO: Make sure that the database exists
                    if (!element.Validate())
                    {
                        return(false);
                    }

                    element.UpdateOptionData();

                    return(true);
                });

                // If we didn't get positive feedback...
                if (!dialogResult.Feedback)
                {
                    // Return
                    return;
                }

                // Get the options
                var options = component.SelectedOptions;

                // Get the manager
                var manager = CeidDiplomatikiDI.GetCeidDiplomatikiManager;

                // Register the options
                manager.Register(options);

                // Save the changes
                var result = await manager.SaveChangesAsync();

                // If there was an error...
                if (!result.Successful)
                {
                    // Show the error
                    await result.ShowDialogAsync(this);

                    // Re enable the button
                    AddButton.IsEnabled = true;

                    // Return
                    return;
                }

                // Add them to the presenter
                DataPresenter.Add(options);
            });

            // Add it to the content grid
            ContentGrid.Children.Add(AddButton);
        }
コード例 #13
0
ファイル: RowSelector.cs プロジェクト: xydoublez/RDO.Net
 public void Initialize(DataPresenter dataPresenter)
 {
     DataPresenter = dataPresenter;
     SynchronizeSelection();
     DataPresenter.ViewInvalidating += OnViewInvalidating;
 }
コード例 #14
0
ファイル: RowSelector.cs プロジェクト: xydoublez/RDO.Net
            public static void EnsureInitialized(DataPresenter dataPresenter)
            {
                var service = dataPresenter.GetRegisteredService <CurrentRowSynchronizer>();

                Debug.Assert(service != null);
            }
コード例 #15
0
ファイル: DataStorage.cs プロジェクト: standy66/AlchemyGame
        public void LoadDefaults()
        {
            data = new DataPresenter();
            data["water"] = true;
            data["earth"] = true;
            data["fire"] = true;
            data["air"] = true;

            data.Links["-1", "-2"] = "water";
            data.Links["-2", "-3"] = "earth";
            data.Links["-3", "-4"] = "fire";
            data.Links["-4", "-6"] = "air";

            data.Links["earth", "fire"] = "lava";
            data.Links["earth", "water"] = "swamp";
            data.Links["earth", "earth"] = "stone";
            data.Links["earth", "air"] = "dust";
            data.Links["fire", "water"] = "steam";
            data.Links["fire", "steam"] = "alcohol";
            data.Links["fire", "energy"] = "1UP";
            data.Links["fire", "air"] = "energy";
            data.Links["stone", "1UP"] = "mount";
            data.Links["swamp", "energy"] = "life";
            data.Links["life", "stone"] = "egg";
            data.Links["water", "alcohol"] = "vodka";
            data.Links["egg", "life"] = "chicken";
            data.Links["chicken", "fire"] = "McDonalds";
            data.Links["chicken", "1UP"] = "dragon";

            data.Links["mount", "mount"] = "country";
            data.Links["country", "vodka"] = "Russia";
            data.Links["country", "McDonalds"] = "US";
            data.Links["US", "Russia"] = "bomb";

            /*data.Links[2, 3] = data.Links[3, 2] = 47;
            //обсидиан
            data.Links[4, 2] = data.Links[2, 4] = 10;
            //energy
            data.Links[1, 3] = data.Links[3, 1] = 5;
            //lava
            data.Links[0, 1] = data.Links[1, 0] = 4;
            //boloto
            data.Links[0, 2] = data.Links[2, 0] = 14;
            //steam
            data.Links[2, 1] = data.Links[1, 2] = 7;
            //grass
            data.Links[6, 0] = data.Links[0, 6] = 8;
            //1UP
            data.Links[5, 1] = data.Links[1, 5] = 9;
            //MineCraft
            data.Links[9, 10] = data.Links[10, 9] = 11;
            //alco
            data.Links[7, 1] = data.Links[1, 7] = 12;
            //vodka
            data.Links[12, 2] = data.Links[2, 12] = 13;
            //life
            data.Links[14, 5] = data.Links[5, 14] = 6;
            //bacteria
            data.Links[14, 6] = data.Links[6, 14] = 15;
            //stone
            data.Links[0, 0] = 16;
            //egg
            data.Links[16, 6] = data.Links[6, 16] = 17;
            //chichen
            data.Links[17, 6] = data.Links[6, 17] = 18;
            //MakDak
            data.Links[9, 18] = data.Links[18, 9] = 19;
            //Earth
            data.Links[9, 0] = data.Links[0, 9] = 20;
            //ash
            data.Links[3, 0] = data.Links[0, 3] = 21;
            //dino
            data.Links[0, 17] = data.Links[17, 0] = 22;
            //dragon
            data.Links[22, 1] = data.Links[1, 22] = 23;
            //job
            data.Links[16, 16] = 29;
            //animal
            data.Links[9, 15] = data.Links[15, 9] = 24;
            //human
            data.Links[29, 24] = data.Links[24, 29] = 25;
            data.Links[28, 6] = data.Links[6, 28] = 25;
            //sand
            data.Links[16, 2] = data.Links[2, 16] = 27;
            //clay
            data.Links[27, 2] = data.Links[2, 27] = 30;
            //golem
            data.Links[30, 6] = data.Links[6, 30] = 28;
            //dovakhiin
            data.Links[25, 23] = data.Links[23, 25] = 26;
            //obsession
            data.Links[19, 25] = data.Links[25, 19] = 31;
            //alconaut
            data.Links[13, 25] = data.Links[25, 13] = 32;
            //sex
            data.Links[25, 25] = 33;
            //tools
            data.Links[29, 25] = data.Links[25, 29] = 34;
            //diamonds
            data.Links[34, 16] = data.Links[16, 34] = 35;
            //ukrashenia
            data.Links[35, 34] = data.Links[34, 35] = 36;
            //mountains
            data.Links[16, 9] = data.Links[9, 16] = 37;
            //country
            data.Links[37, 37] = 38;
            //Russia
            data.Links[38, 13] = data.Links[13, 38] = 39;
            //USA
            data.Links[19, 38] = data.Links[38, 19] = 40;
            //nuke
            data.Links[40, 39] = data.Links[39, 40] = 41;
            //tree
            data.Links[8, 9] = data.Links[9, 8] = 42;
             			//paper
            data.Links[42, 34] = data.Links[34, 42] = 43;
            //books
            data.Links[43, 43] = 44;
            //shelf
            data.Links[44, 44] = 45;
            //metal
            data.Links[0, 34] = data.Links[34, 0] = 46;*/
        }