public void ShowView(IWin32Window owner, WorldModel model) { owner.ThrowIfNull(nameof(owner)); model.ThrowIfNull(nameof(model)); IEnumerable <WorldVariableViewModel> viewModels = model.Variables.Select( x => new WorldVariableViewModel { Category = x.Category, Name = x.Name, Type = x.Type, Value = x.Value?.ToString() }); if (View.ShowView(owner, viewModels) == DialogResult.OK) { model.Variables.Clear(); model.Variables.AddRange(View.Variables.Select(x => new WorldVariableModel { Category = x.Category, Name = x.Name, Type = x.Type, Value = x.TypedValue })); _messageBus.Publish <WorldChangedMessage>(); } SaveViewBounds(_configFile.Config.Views.WorldVariables.Bounds, false); _configFile.Config.Views.WorldVariables.ColumnWidths.Clear(); _configFile.Config.Views.WorldVariables.ColumnWidths.AddRange(View.VariablesListColumnWidths); }
public DialogResult ShowView(IWin32Window owner, WorldVariableViewModel viewModel, EditMode editMode) { owner.ThrowIfNull(nameof(owner)); _viewModel = viewModel.EnsureNotNull(nameof(viewModel)); Text = $"{(editMode == EditMode.New ? "New" : "Edit")} Variable"; return(ShowDialog(owner)); }
public DialogResult ShowView(IWin32Window owner, IEnumerable <WorldVariableViewModel> worldVariableViewModels) { owner.ThrowIfNull(nameof(owner)); _worldVariableViewModels = new List <WorldVariableViewModel>(worldVariableViewModels ?? Enumerable.Empty <WorldVariableViewModel>()); bindingSourceVariables.DataSource = _worldVariableViewModels; RefreshFilter(true); return(ShowDialog(owner)); }
public WorldVariableViewModel ShowNewView(IWin32Window owner, WorldVariableViewModel viewModel = null, string category = null) { owner.ThrowIfNull(nameof(owner)); viewModel = viewModel ?? new WorldVariableViewModel { Category = category, Type = WorldVariableType.String }; return(View.ShowView(owner, viewModel, EditMode.New) == DialogResult.OK ? viewModel : null); }
/// <summary> /// Creates a GlobalHotKey object. /// </summary> /// <param name="modifier">HotKey modifier keys</param> /// <param name="key">HotKey</param> /// <param name="window">The Window that the HotKey should be registered to</param> /// <param name="callback">The delegate to call when the HotKey is pressed.</param> /// <param name="registerImmediately"> </param> public GlobalHotKey(Modifiers modifier, Keys key, IWin32Window window, HotKeyCallback callback, bool registerImmediately = false) { window.ThrowIfNull("window", "You must provide a form or window to register the HotKey against."); callback.ThrowIfNull("callback", "You must specify a callback in order to do some useful work when your HotKey is pressed."); Modifier = modifier; Key = (int)key; hWnd = window.Handle; Id = GetHashCode(); Callback = callback; if (registerImmediately) { Register(); } }
public WorldModel ShowView(IWin32Window owner) { owner.ThrowIfNull(nameof(owner)); if (View.ShowView(owner, _viewModel) != DialogResult.OK) { return(null); } _configFile.Config.Views.NewWorld.DefaultAuthor = _viewModel.Author; _configFile.Save(); return(new WorldModel { Author = _viewModel.Author, CreatedTimestamp = _systemClock.LocalDateTime, Id = _viewModel.IdAsGuid, Name = _viewModel.WorldName, Resources = { Charactersets = { new WorldResourceCharactersetModel { Id = _guidFactory.Random(), Name = "standard", PngBase64 = CharactersetResources.standard.AsBase64Png() } } }, Versions = { FileFormat = "1.0", World = _viewModel.Version } }); }
public void ShowView(IWin32Window owner) { owner.ThrowIfNull(nameof(owner)); View.ShowView(owner); }