public override void updatePreview() { RailPattern rp = RailPattern.get(currentDirection, currentDirection.opposite); using (PreviewDrawer drawer = new PreviewDrawer(preview.Size, new Size(1, 1), 0)) { // draw the rail for (int i = -5; i < 5; i++) { if (currentDirection.isParallelToX) { drawer.draw(rp, i, 0); } else { drawer.draw(rp, 0, i); } } // draw the signal drawer.draw(rp, 0, 0); drawer.draw(currentType.getSprite(currentDirection), 0, 0); // draw the arrow currentDirection.drawArrow(drawer.surface, drawer.getPoint(-currentDirection.offsetX, -currentDirection.offsetY)); preview.Image = drawer.createBitmap(); } }
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(); }
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(); } }
/// <summary> /// Called when a selection of the structure has changed. /// </summary> protected virtual void updatePreview() { using (PreviewDrawer drawer = currentContrib.createPreview(preview.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.createBitmap(); } }
public override void updatePreview() { using (PreviewDrawer drawer = selectedType.createPreview(preview.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.createBitmap(); } updateAlphaSprites(); }
/// <summary> /// Called when a selection of the structure has changed. /// </summary> protected virtual void onTypeChanged(object sender, System.EventArgs e) { ElectricPoleContribution contrib = (ElectricPoleContribution)typeBox.SelectedItem; using (PreviewDrawer drawer = contrib.createPreview(preview.Size)) { if (previewBitmap != null) { previewBitmap.Dispose(); } preview.Image = previewBitmap = drawer.createBitmap(); } recreateController(); }
public override void updatePreview() { using (PreviewDrawer drawer = new PreviewDrawer(picture.Size, new Size(1, 10), 0)) { for (int i = 0; i < 10; i++) { drawer.draw(RailPattern.get(Direction.NORTH, Direction.SOUTH), 0, i); } if (picture.Image != null) { picture.Image.Dispose(); } picture.Image = drawer.createBitmap(); } }
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)); }
private void buttonOK_Click(object sender, System.EventArgs e) { string dir = output.Text; if (!Directory.Exists(dir)) { MessageBox.Show(this, "The output directory does not exist"); //! MessageBox.Show(this,"指定された出力先は存在しません"); return; } // initialize the progress bar progressBar.Minimum = 0; progressBar.Maximum = Core.plugins.trains.Length; progressBar.Value = 0; // prepare the XML writer TextWriter xml = new StreamWriter( new FileStream(Path.Combine(dir, "index.xml"), FileMode.Create)); xml.WriteLine("<?xml version='1.0'?>"); xml.WriteLine("<trainList>"); xml.WriteLine("<companies>"); foreach (string company in listCompanies()) { writeElement(xml, company, "company"); } xml.WriteLine("</companies>"); foreach (TrainContribution contrib in Core.plugins.trains) { using (PreviewDrawer pd = contrib.createPreview(new Size(150, 75))) { using (Bitmap bmp = pd.createBitmap()) { string fileName = Path.Combine(dir, contrib.id + ".png"); bmp.Save(fileName, ImageFormat.Png); } } outputManifest(contrib, xml); progressBar.Value++; Application.DoEvents(); } xml.WriteLine("</trainList>"); xml.Close(); }
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 station has changed. /// </summary> private void onStationChanged(object sender, EventArgs e) { // Builds a new preview bitmap and set it to the picture box PreviewDrawer drawer; drawer = new PreviewDrawer(stationPicture.ClientSize, selectedStation.size); drawer.drawCenter(selectedStation.sprites); if (stationPreviewBitmap != null) { stationPreviewBitmap.Dispose(); } stationPicture.Image = stationPreviewBitmap = drawer.createBitmap(); drawer.Dispose(); updateAlphaSprites(); }
/// <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); } }
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; using (PreviewDrawer pd = selectedTrain.createPreview(preview.ClientSize)) { 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> /// 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); } } }