コード例 #1
0
ファイル: MainForm.cs プロジェクト: milkmanmatty/Mappy
        public void SetModel(IMainFormViewModel model)
        {
            var gridSize = model.GridSize.CombineLatest(
                model.GridVisible,
                (size, visible) => visible ? new Size?(size) : null);

            gridSize.Subscribe(x => this.gridOffMenuItem.Checked  = x == null);
            gridSize.Subscribe(x => this.grid16MenuItem.Checked   = x == new Size(16, 16));
            gridSize.Subscribe(x => this.grid32MenuItem.Checked   = x == new Size(32, 32));
            gridSize.Subscribe(x => this.grid64MenuItem.Checked   = x == new Size(64, 64));
            gridSize.Subscribe(x => this.grid128MenuItem.Checked  = x == new Size(128, 128));
            gridSize.Subscribe(x => this.grid256MenuItem.Checked  = x == new Size(256, 256));
            gridSize.Subscribe(x => this.grid512MenuItem.Checked  = x == new Size(512, 512));
            gridSize.Subscribe(x => this.grid1024MenuItem.Checked = x == new Size(1024, 1024));

            // file menu bindings
            model.CanSave.Subscribe(x => this.saveMenuItem.Enabled      = x);
            model.CanSaveAs.Subscribe(x => this.saveAsMenuItem.Enabled  = x);
            model.CanCloseMap.Subscribe(x => this.closeMenuItem.Enabled = x);

            model.CanImportMinimap.Subscribe(x => this.importMinimapMenuItem.Enabled = x);
            model.CanExportMinimap.Subscribe(x => this.exportMinimapMenuItem.Enabled = x);

            model.CanImportHeightmap.Subscribe(x => this.importHeightmapMenuItem.Enabled = x);
            model.CanExportHeightmap.Subscribe(x => this.exportHeightmapMenuItem.Enabled = x);

            model.CanExportMapImage.Subscribe(x => this.exportMapImageMenuItem.Enabled           = x);
            model.CanImportCustomSection.Subscribe(x => this.importCustomSectionMenuItem.Enabled = x);

            // edit menu bindings
            model.CanUndo.Subscribe(x => this.undoMenuItem.Enabled   = x);
            model.CanRedo.Subscribe(x => this.redoMenuItem.Enabled   = x);
            model.CanCopy.Subscribe(x => this.copyMenuItem.Enabled   = x);
            model.CanCut.Subscribe(x => this.cutMenuItem.Enabled     = x);
            model.CanPaste.Subscribe(x => this.pasteMenuItem.Enabled = x);
            model.CanFill.Subscribe(x => this.fillMenuItem.Enabled   = x);

            model.CanGenerateMinimap.Subscribe(x => this.generateMinimapMenuItem.Enabled = x);
            model.CanGenerateMinimapHighQuality.Subscribe(x => this.generateMinimapHighQualityMenuItem.Enabled = x);

            model.CanOpenAttributes.Subscribe(x => this.mapAttributesMenuItem.Enabled = x);

            // view menu bindings
            model.MinimapVisible.Subscribe(x => this.toggleMinimapMenuItem.Checked     = x);
            model.HeightmapVisible.Subscribe(x => this.toggleHeightmapMenuItem.Checked = x);
            model.VoidsVisible.Subscribe(x => this.toggleVoidsMenuItem.Checked         = x);
            model.FeaturesVisible.Subscribe(x => this.toggleFeaturesMenuItem.Checked   = x);

            // sea level widget bindings
            model.CanChangeSeaLevel.Subscribe(x => this.seaLevelLabel.Enabled      = x);
            model.CanChangeSeaLevel.Subscribe(x => this.seaLevelValueLabel.Enabled = x);
            model.CanChangeSeaLevel.Subscribe(x => this.seaLevelTrackbar.Enabled   = x);

            model.SeaLevel.Subscribe(x => this.seaLevelTrackbar.Value = x);
            model.SeaLevel
            .Select(x => x.ToString(CultureInfo.CurrentCulture))
            .Subscribe(x => this.seaLevelValueLabel.Text = x);

            // title text bindings
            model.TitleText.Subscribe(x => this.Text = x);

            this.model = model;
        }
コード例 #2
0
        public MainForm(IPanelFactory panelFactory, IMainFormViewModel viewModel)
        {
            XamlReader.Load(this);

            Content = panelFactory.GetDirectoryScoperPanel();
        }