private void onAmountChanged(object sender, EventArgs e) { if (count.Value != 0 && selectedTrain != null) { TrainCarContribution[] cars = selectedTrain.Create((int)length.Value); if (cars != null) { buttonOK.Enabled = true; // TODO: non-linear price support totalPrice.Text = getTotalPrice().ToString(); int p = 0; foreach (TrainCarContribution car in cars) { p += car.Capacity; } passenger.Text = p.ToString() + " passengers/set"; //! passenger.Text = p.ToString()+" 人/編成"; using (PreviewDrawer pd = selectedTrain.CreatePreview(preview.ClientSize, (int)length.Value)) { preview.Image = pd.CreateBitmap(); } return; } } buttonOK.Enabled = false; totalPrice.Text = "---"; passenger.Text = "---"; }
/// <summary> /// /// </summary> protected void redrawPreview() { if (current.Current is VarHeightBuildingContribution) { using (PreviewDrawer drawer = ((VarHeightBuildingContribution)current.Current).CreatePreview(previewBox.Size, (int)numHeight.Value)) { if (previewBitmap != null) { previewBitmap.Dispose(); } previewBox.Image = previewBitmap = drawer.CreateBitmap(); } } else { using (PreviewDrawer drawer = current.Current.CreatePreview(previewBox.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } previewBox.Image = previewBitmap = drawer.CreateBitmap(); } } updateAlphaSprites(); if (bShowDetail) { labelInfo.Text = getDetailText(); } //描画異常がおこるため Invalidate(); Update(); }
/// <summary> /// Called when a selection of the structure has changed. /// </summary> public override void UpdatePreview() { using (PreviewDrawer drawer = currentContrib.CreatePreview(preview.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.CreateBitmap(); } }
/// <summary> /// /// </summary> public override void UpdatePreview() { LandBuilderContribution builder = (LandBuilderContribution)indexSelector.currentItem; using (PreviewDrawer drawer = builder.CreatePreview(preview.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.CreateBitmap(); } //currentController = builder.createBuilder(new ControllerSiteImpl(this)); }
/// <summary> /// /// </summary> public override void UpdatePreview() { using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(3, 3), 0)) { for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { drawer.Draw(LandPropertyVoxel.sprite, x, y); } } if (preview.Image != null) { preview.Image.Dispose(); } preview.Image = drawer.CreateBitmap(); } }
/// <summary> /// Called when a selection of the structure has changed. /// </summary> protected virtual void UpdatePreview(DummyCarContribution builder) { //DummyCarContribution builder = (DummyCarContribution)typeBox.SelectedItem; using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(10, 1), 0)) { drawer.Draw(builder.GetSprites(), 5, 0); if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.CreateBitmap(); } //if (isPlacing) //currentController = builder.createBuilder(this.siteImpl); //else //currentController = builder.createRemover(this.siteImpl); }
/// <summary> /// Called when a selection of the structure has changed. /// </summary> protected virtual void OnTypeChanged(object sender, System.EventArgs e) { RoadAccessoryContribution builder = (RoadAccessoryContribution)typeBox.SelectedItem; if (builder != null) { using (PreviewDrawer drawer = builder.CreatePreview(preview.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.CreateBitmap(); } //if (isPlacing) // currentController = builder.createBuilder(this.siteImpl); //else // currentController = builder.createRemover(this.siteImpl); } }
/// <summary> /// /// </summary> public void updatePreview() { length.Enabled = count.Enabled = buttonOK.Enabled = (selectedTrain != null); Image im = preview.Image; if (im != null) { preview.Image = null; im.Dispose(); } if (selectedTrain != null) { name.Text = selectedTrain.Name; author.Text = selectedTrain.Author; description.Text = selectedTrain.Description; speed.Text = selectedTrain.SpeedDisplayName; length.Maximum = selectedTrain.MaxLength; length.Minimum = selectedTrain.MinLength; //if (length.Value > selectedTrain.maxLength) length.Value = selectedTrain.maxLength; using (PreviewDrawer pd = selectedTrain.CreatePreview(preview.ClientSize, (int)length.Value)) { preview.Image = pd.CreateBitmap(); } if (count.Value == 0) { // if the user changes the type, s/he is going to buy another train. // thus change the value to 1. count.Value = 1; } onAmountChanged(null, null); } else { name.Text = author.Text = description.Text = speed.Text = ""; } }
/// <summary> /// /// </summary> public override void UpdatePreview() { PreviewDrawer drawer; // TODO: locations of the previews are uttely incorrect. fix them // direction N using (drawer = new PreviewDrawer(pictureN.ClientSize, new Size(2, 4), 0)) { drawer.Draw(RailPattern.getSlope(Direction.NORTH, 3), 1, -1); drawer.Draw(RailPattern.getSlope(Direction.NORTH, 2), 1, 0); drawer.Draw(RailPattern.getSlope(Direction.NORTH, 1), 0, 2); drawer.Draw(RailPattern.getSlope(Direction.NORTH, 0), 0, 3); if (pictureN.Image != null) { pictureN.Image.Dispose(); } pictureN.Image = drawer.CreateBitmap(); } // direction S using (drawer = new PreviewDrawer(pictureS.ClientSize, new Size(2, 4), 0)) { drawer.Draw(RailPattern.getSlope(Direction.SOUTH, 0), 0, 0); drawer.Draw(RailPattern.getSlope(Direction.SOUTH, 1), 0, 1); drawer.Draw(RailPattern.getSlope(Direction.SOUTH, 2), 1, 1); drawer.Draw(RailPattern.getSlope(Direction.SOUTH, 3), 1, 2); if (pictureS.Image != null) { pictureS.Image.Dispose(); } pictureS.Image = drawer.CreateBitmap(); } // direction E using (drawer = new PreviewDrawer(pictureE.ClientSize, new Size(4, 2), 0)) { drawer.Draw(RailPattern.getSlope(Direction.EAST, 3), 3, 0); drawer.Draw(RailPattern.getSlope(Direction.EAST, 2), 2, 0); drawer.Draw(RailPattern.getSlope(Direction.EAST, 1), 0, 1); drawer.Draw(RailPattern.getSlope(Direction.EAST, 0), -1, 1); if (pictureE.Image != null) { pictureE.Image.Dispose(); } pictureE.Image = drawer.CreateBitmap(); } // direction W using (drawer = new PreviewDrawer(pictureW.ClientSize, new Size(4, 2), 0)) { drawer.Draw(RailPattern.getSlope(Direction.WEST, 3), 1, 0); drawer.Draw(RailPattern.getSlope(Direction.WEST, 2), 2, 0); drawer.Draw(RailPattern.getSlope(Direction.WEST, 1), 2, 1); drawer.Draw(RailPattern.getSlope(Direction.WEST, 0), 3, 1); if (pictureW.Image != null) { pictureW.Image.Dispose(); } pictureW.Image = drawer.CreateBitmap(); } }