private void Process_OutputDataReceived(object sender, DataReceivedEventArgs e) { if (e.Data == null) { return; } Debug.WriteLine(e.Data); string data = e.Data.ToString(); if (data.Substring(0, 1) == "[") { data = data.Replace(" ", " ").Replace(".", "").Replace("[ ", "").Replace("[", "").Replace(" ]", "").Replace("]", ""); var numbers = data.Split(' '); int[] arr = Array.ConvertAll(numbers, s => int.Parse(s)); for (int i = 0; i < arr.Length; i++) { arr[i] = (arr[i] == -1) ? 0 : 255; } byte[] arrByte = Array.ConvertAll(arr, s => (byte)s); var arr2d = Make2DArray(arrByte, x, y); TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap)); Bitmap bm = new Bitmap(x * 100, y * 100); using (Graphics g = Graphics.FromImage(bm)) { for (int i = 0; i < arr2d.GetLength(0); i++) { for (int j = 0; j < arr2d.GetLength(1); j++) { if (arr2d[i, j] == 255) { g.FillRectangle(Brushes.Black, i * 10, j * 10, 10, 10); } else { g.FillRectangle(Brushes.White, i * 10, j * 10, 10, 10); } } } } if (pythonStatus == 0) { OriginalPictureBox.Invoke((MethodInvoker)(() => { OriginalPictureBox.Image = bm; } )); pythonStatus = 1; } else if (pythonStatus == 1) { MainPictureBox.Invoke((MethodInvoker)(() => { MainPictureBox.Image = bm; } )); } } }
private void reOrderImagesToolStripMenuItem_Click(object sender, EventArgs e) { int x = 0; int y = 0; MainPictureBox.SuspendLayout(); MainPictureBox.AutoScrollPosition = new Point(0, 0); foreach (PictureBox button in this.MainPictureBox.Controls) { //TODO: 优化算法,合理排列,防止图片重叠 if (x < 0) { x = 0; } if (y < 0) { y = 0; } Point point = new Point(x, y); button.Location = point; ImageItem tag = button.Tag as ImageItem; tag.SetLocation(point); x += button.Width; if ((x + button.Width) > this.MainPictureBox.Width) { x = 0; y += button.Height; } } MainPictureBox.ResumeLayout(); }
private void MainForm_Load(object sender, EventArgs e) { Card1RadioButton.Checked = true; Camera1RadioButton.Checked = true; _graphics = MainPictureBox.CreateGraphics(); }
/// <summary> /// Рисует все капли по КД /// </summary> /// <param name="obj"></param> /// <param name="e"></param> public void PaintDrops(object obj, EventArgs e) { g.Clear(Color.Black); g.DrawString(str, new Font(FontFamily.GenericSerif, 25), Brushes.White, new Point(Width / 2, 50)); for (int i = 0; i < rainDrops.Count; i++) { rainDrops[i].Draw(g); rainDrops[i].Update(); if (rainDrops[i].CheckCollision(Size)) { rainDrops.Remove(rainDrops[i]); rainDrops.Add(CreateRaindrop()); } } for (int i = 0; i < textDrops.Count; i++) { textDrops[i].Draw(g); textDrops[i].Update(); if (textDrops[i].CheckCollision(Size)) { textDrops.Remove(textDrops[i]); } } MainPictureBox.Refresh(); }
public Form1() { InitializeComponent(); MainPictureBox.Paint += MainPictureBox_Paint; MainPictureBox.Refresh(); hScrollBar1.Maximum = (GalaxyGenerator.galaxySize * renderer.cellSize); vScrollBar1.Maximum = (GalaxyGenerator.galaxySize * renderer.cellSize); vScrollBar1.Scroll += (sender, e) => { MainPictureBox.Invalidate(); }; hScrollBar1.Scroll += (sender, e) => { MainPictureBox.Invalidate(); }; KeyPress += Form1_KeyPress; MainPictureBox.MouseClick += View_MouseClick; MainPictureBox.MouseDown += View_MouseDown; MainPictureBox.MouseUp += View_MouseUp; MainPictureBox.MouseMove += View_MouseMove; MainPictureBox.MouseWheel += View_MouseWheel; Rand64 rand = new Rand64((ulong)new Random().Next()); int cellX = rand.Range(0, GalaxyGenerator.galaxySize); int cellY = rand.Range(0, GalaxyGenerator.galaxySize); GalaxyCell cell = galaxyGenerator.GetCell(cellX, cellY); if (cell != null) { StarSystem chosenSystem = cell.starSystems[rand.Range(0, cell.starSystems.Count)]; SelectSystem(chosenSystem); CenterOnSystem(chosenSystem); } }
private void MainWindow_Shown(object sender, EventArgs e) { Text = m_parent.Name + " v" + m_parent.Version; if (Editor.Settings.AssetDirPath == null) { // Try to auto-find directory string path = (string)Registry.GetValue( @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 211820", "InstallLocation", null); // If found if (path != null) { path = Path.Combine(path, "assets"); Editor.Settings.AssetDirPath = path; } // Otherwise prompt the user else { MessageBox.Show( "Could not find Starbound folder. Please navigate to Starbound's assets directory on the next screen."); DirPopup guiPopup = new DirPopup(m_parent); guiPopup.ShowDialog(); } } m_parent.SaveSettings(); OpenFile.InitialDirectory = Editor.Settings.AssetDirPath; MainPictureBox.Focus(); }
private void SupprimerCartoObj() { if (propertyGrid.SelectedObject != null) { if (propertyGrid.SelectedObject is POI) { foreach (Polyline tmpPolyline in listePolyline) { foreach (POI tmpPoi in tmpPolyline.LPOI) { if (tmpPoi.Id == (propertyGrid.SelectedObject as POI).Id) { tmpPolyline.LPOI.Remove(tmpPoi); break; } } } listePOI.Remove(propertyGrid.SelectedObject as POI); } if (propertyGrid.SelectedObject is Polyline) { listePolyline.Remove(propertyGrid.SelectedObject as Polyline); } if (propertyGrid.SelectedObject is Polygon) { listePolygon.Remove(propertyGrid.SelectedObject as Polygon); } propertyGrid.SelectedObject = null; MainPictureBox.Invalidate(); } }
protected void OnMultiValueChanged(object sender, EventArgs e) { if (QuickMode) { ImageGraphics.Save(); MainPictureBox.Invalidate(); } }
protected void OnSingleValueChanged(object sender, ProtoIntegerEditor.ProtoIntegerEditorValueChangedEventArgs e) { DrawSingleTextNew(e.Index); if (!QuickMode) { ImageGraphics.Save(); MainPictureBox.Invalidate(); } }
public void DrawPoint(int dInput, int xInput, bool invert) { DInputValueLabel.Text = (dInput + short.MinValue).ToString(); XInputValueLabel.Text = xInput.ToString(); _invert = invert; _dInput = dInput; _xInput = xInput; MainPictureBox.Refresh(); }
/// <summary> /// Called when the player wins the game /// </summary> private void Game_Victory() { GameWrapper.RemoveCellMarkFromMap(); MainPictureBox.Refresh(); MessageBox.Show(WINNER_MESSAGE); Close(); }
public void SetSelectedBrush(EditorBrush brush) { m_selectedBrush = brush; string colour = "r: " + m_selectedBrush.Colour[0] + " g: " + m_selectedBrush.Colour[1] + " b: " + m_selectedBrush.Colour[2]; // Tidy this display up at some point BottomBarBrushLabel.Text = "Selected Brush: " + m_selectedBrush.Comment; if (m_selectedBrush.FrontAsset != null) { BottomBarBrushLabel.Text += " front: " + m_selectedBrush.FrontAsset.AssetName; } if (m_selectedBrush.BackAsset != null) { BottomBarBrushLabel.Text += " back: " + m_selectedBrush.BackAsset.AssetName; } BottomBarBrushLabel.Text += " " + colour; VisualRgbaBrushDescLabel.Text = "r: " + m_selectedBrush.Colour[0] + " g: " + m_selectedBrush.Colour[1] + " b: " + m_selectedBrush.Colour[2]; // Populate the colour box VisualRgbaBrushImageBox.Image = EditorHelpers.GetGeneratedRectangle(1, 1, m_selectedBrush.Colour[0], m_selectedBrush.Colour[1], m_selectedBrush.Colour[2], m_selectedBrush.Colour[3]); Image assetImg = null; // Get the correct preview box asset if (m_selectedBrush.FrontAsset != null) { assetImg = m_selectedBrush.FrontAsset.Image; VisualGraphicBrushDescLabel.Text = m_selectedBrush.FrontAsset.AssetName; } else if (m_selectedBrush.BackAsset != null) { assetImg = m_selectedBrush.BackAsset.Image; VisualGraphicBrushDescLabel.Text = m_selectedBrush.BackAsset.AssetName; } // Populate the tile preview box if (assetImg != null) { VisualGraphicBrushImageBox.Image = assetImg; } MainPictureBox.SetSelectedBrush(m_selectedBrush); }
public void DrawPoint(int dInput, int xInput, bool invert, bool half) { DInputValueLabel.Text = dInput.ToString(); XInputValueLabel.Text = xInput.ToString(); _invert = invert; _half = half; _dInput = dInput; _xInput = xInput; MainPictureBox.Refresh(); }
private void showGridToolStripMenuItem_CheckStateChanged(object sender, EventArgs e) { var item = sender as ToolStripMenuItem; if (item != null) { Global.GridStyle.ShowGrid = item.Checked; tsbtnShowGrid.Checked = item.Checked; MainPictureBox.ChangeColor(Global.GridStyle); } }
private void easyTrackBar1_ValueChanged(EasyTrackBarValueChangedArgs e) { if (e.OldValue != e.NewValue) { Global.GridSizeNum = e.NewValue; tsslStatusGridSize.Text = CommonLib.GetLocalString("status_grid_size", e.NewValue.ToString()); if (Global.GridStyle.ShowGrid) { MainPictureBox.Invalidate(); } } }
private void AnimTick(object sender, EventArgs e) { ++m_FrameIndex; if (m_FrameIndex == m_Animation.Length) { m_FrameIndex = 0; } m_ImageInvalidated = true; MainPictureBox.Invalidate(); }
// Open a new dungeon private void OpenDungeonOrImageMap_FileOk(object sender, CancelEventArgs e) { if (!ConfirmExit()) { return; } CleanUp(); if (!Directory.Exists(Editor.Settings.AssetDirPath)) { MessageBox.Show("Invalid asset directory set. Please choose a valid asset directory " + "from the Starbound menu in the toolset.", "Error", MessageBoxButtons.OK); return; } if (Path.GetExtension(OpenFile.FileName) == ".dungeon") { StarboundDungeon.LoadFile(OpenFile.FileName, m_parent); } else if (Path.GetExtension(OpenFile.FileName) == ".structure") { StarboundShip.LoadFile(OpenFile.FileName, m_parent); } if (m_parent.ActiveFile == null) { MessageBox.Show("Unable to load!"); Close(); return; } m_parent.ActiveFile.FilePath = OpenFile.FileName; Text = m_parent.Name + " v" + m_parent.Version + " - " + m_parent.ActiveFile.FilePath; m_parent.ScanAssetDirectory(); m_parent.ActiveFile.GenerateBrushAndAssetMaps(m_parent); m_parent.ActiveFile.LoadParts(m_parent); PopulatePartTreeView(); PopulateBrushList(); if (PartTreeView.Nodes.Count > 0) { PartTreeView.SelectedNode = PartTreeView.Nodes[0]; } closeToolStripMenuItem.Enabled = true; saveToolStripMenuItem.Enabled = true; MainPictureBox.Focus(); }
private void WindowPrincipale_KeyDown(object sender, KeyEventArgs e) { if (descriptionInUse == true) { return; } else { switch (e.KeyCode) { #region key Delete case Keys.Delete: { SupprimerCartoObj(); break; } #endregion #region key & case Keys.D1: { POIButton_Click(this, new EventArgs()); break; } #endregion #region key é case Keys.D2: { PolylineButton_Click(this, new EventArgs()); break; } #endregion #region key & case Keys.D3: { PolygonButton_Click(this, new EventArgs()); break; } #endregion #region key enter case Keys.Space: { DescriptionTB.Focus(); break; } #endregion } } MainPictureBox.Invalidate(); }
private void PolygonLB_SelectedIndexChanged(object sender, EventArgs e) { //if (propertyGrid.SelectedObject != null) //(propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal; if (PolygonLB.SelectedItem != null) { unselectLB(3); propertyGrid.SelectedObject = PolygonLB.SelectedItem; //(propertyGrid.SelectedObject as CartoObj).Largeur += 5; } MainPictureBox.Invalidate(); }
private void POILB_SelectedIndexChanged(object sender, EventArgs e) { if (propertyGrid.SelectedObject != null) { (propertyGrid.SelectedObject as CartoObj).Largeur = largeurGlobal; } if (POILB.SelectedItem != null) { unselectLB(1); propertyGrid.SelectedObject = POILB.SelectedItem; (propertyGrid.SelectedObject as CartoObj).Largeur += 5; } MainPictureBox.Invalidate(); }
private void listView1_SelectedIndexChanged_1(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lvis = listView1.SelectedItems; if (lvis != null && lvis.Count == 1) { ListViewItem lvi = lvis[0]; ImageItem ii = lvi.Tag as ImageItem; if (ii != null) { MainPictureBox.SelectItem(ii.Id); MainPictureBox.Focus(); propertyGrid1.SelectedObject = ii; } } }
private void blackToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem tsmi = sender as ToolStripMenuItem; if (tsmi != null && tsmi.Tag != null) { GridStyle gridStyle = CommonLib.GetGridStyle(tsmi.Tag.ToString()); if (gridStyle != null) { gridStyle.ShowGrid = showGridToolStripMenuItem.Checked; Global.GridStyle = gridStyle; MainPictureBox.ChangeColor(gridStyle); } } }
private void DisplayBitBoards(params ulong[] bitboards) { var cells = bitboards.Select(x => BitboardToCells(x).ToList()).ToList(); var bmp = new Bitmap(MainPictureBox.Width, MainPictureBox.Height); var textBrush = new SolidBrush(Color.FromArgb(255, 255, 255)); var cellWidth = bmp.Width / 8; var cellHeight = bmp.Height / 8; var font = new Font(Font, FontStyle.Bold); var borderIncrement = (cellWidth / 2 - 5) / BitboardsTextBoxes.Count; using (var graphics = Graphics.FromImage(bmp)) { for (var i = 0; i < 64; i++) { var cellX = 7 - (i / 8); var cellY = i % 8; graphics.FillRectangle(EmptyBrush, cellY * cellWidth, cellX * cellHeight, cellWidth, cellHeight); var borderWidth = 0; for (var j = 0; j < cells.Count; j++) { if (cells[j][i]) { graphics.FillRectangle(Brushes[j], cellY * cellWidth + borderWidth + 1, cellX * cellHeight + borderWidth + 1, cellWidth - 2 * borderWidth - 1, cellHeight - 2 * borderWidth - 1); borderWidth += borderIncrement; } } var text = (char)(65 + (cellY)) + (8 - cellX).ToString(); graphics.DrawString(text, font, textBrush, cellY * cellWidth + cellWidth / 2 - 8, cellX * cellHeight + cellHeight / 2 - 10); graphics.DrawString(i.ToString().PadLeft(2, '0'), font, textBrush, cellY * cellWidth + cellWidth / 2 - 8, cellX * cellHeight + cellHeight / 2 + 2); } for (var i = 0; i < 9; i++) { graphics.DrawLine(Pens.Black, cellWidth * i, 0, cellWidth * i, bmp.Height); graphics.DrawLine(Pens.Black, 0, cellHeight * i, bmp.Width, cellHeight * i); } } MainPictureBox.Image = bmp; MainPictureBox.Invalidate(); }
private void UpdateImageBox(bool resetZoom, bool resetCamera) { // If no file is loaded, leave if (m_parent.ActiveFile == null || m_selectedMap == null) { return; } EditorMapPart part = GetSelectedPart(); // If we're displaying the graphic map if (BottomBarGfxCombo.SelectedIndex == 0) { m_gridFactor = 8; if (m_selectedMap is EditorMapPart) { part.UpdateLayerImage(); } else if (m_selectedMap is EditorMapLayer) { part.UpdateLayerImage(new List <EditorMapLayer> { (EditorMapLayer)m_selectedMap }); } MainPictureBox.SetImage(part.GraphicsMap, resetZoom, resetCamera, m_gridFactor); } // If we're displaying the colour map else if (BottomBarGfxCombo.SelectedIndex == 1) { m_gridFactor = 1; if (m_selectedMap is EditorMapPart) { MainPictureBox.SetImage(part.ColourMap, resetZoom, resetCamera, m_gridFactor); } else if (m_selectedMap is EditorMapLayer) { MainPictureBox.SetImage(GetSelectedLayer().ColourMap, resetZoom, resetCamera, m_gridFactor); } } MainPictureBox.Invalidate(); }
private void SwapImages(PictureBox inPictureBox) { string ProblemDescription = null; string Tester = inPictureBox.Tag.ToString(); switch (Tester) { case "Top": ProblemDescription = "High Tear\r\nPossible Corrections :\r\nMove nock point down\r\nMove rest up\r\nDecrease launcher stiffness\r\nShorten arrow length if possible"; break; case "Center": ProblemDescription = "Perfect!"; break; case "Bottom": ProblemDescription = "Low Tear\r\nPossible Corrections :\r\nRaise nocking point\r\nStiffen launcher stiffness"; break; case "Left": ProblemDescription = "Left Tear\r\nPossible Corrections :\r\nMove rest/center shot towards riser \r\n(right-handed bow)\r\nMove cable guard towards arrow (decrease load on cable guard)\r\nAdjust wheel lean\r\nUse stiffer arrow\r\nDecrease draw weight"; break; case "Right": ProblemDescription = "Right Tear\r\nPossible Corrections :\r\nMove rest/center shot away from riser \r\n(right-handed bow)\r\nMove cable guard away from arrow (increase load on cable guard)\r\n- Adjust wheel lean"; break; default: ProblemDescription = "Select the image that most closely resembles your current tear."; break; } if (!MainImage) { MainPictureBox.Image = inPictureBox.Image; MainPictureBox.BringToFront(); } else { MainPictureBox.Image = null; MainPictureBox.SendToBack(); } MainPictureBox.Enabled = !MainPictureBox.Enabled; MainImage = !MainImage; txtSysDescription.Text = ProblemDescription; }
private void DrawBars() { this.MainDrawer.Clear(Color.Transparent); foreach (ContestBar cb in ContestBarList) { cb.Draw(MainDrawer); } foreach (PointBar pb in PointBarList) { pb.Draw(MainDrawer); } JuryBarList[currentJury].Draw(MainDrawer); MainPictureBox.Invalidate(); }
private void FiniToolStripButton_Click(object sender, EventArgs e) { if (PolylineButton.Checked == true && tmpCreationPolyline != null) { //on fini la polyline listePolyline.Add(tmpCreationPolyline); tmpCreationPolyline = null; DescriptionTB.Text = ""; } if (PolygonButton.Checked == true && tmpCreationPolygon != null) { //on fini la polygon listePolygon.Add(tmpCreationPolygon); tmpCreationPolygon = null; DescriptionTB.Text = ""; } MainPictureBox.Invalidate(); }
private void exportImagesToolStripMenuItem_Click(object sender, EventArgs e) { if (MainPictureBox.ActiveControlTag == null) { MessageBox.Show(CommonLib.GetLocalString("no_object"), CommonLib.GetLocalString("alert_windows_title"), MessageBoxButtons.OK); return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.AddExtension = true; saveFileDialog.CheckFileExists = false; saveFileDialog.SupportMultiDottedExtensions = false; saveFileDialog.Filter = String.Format("Image File|{0}", MainPictureBox.ActiveControlTag.ImageType.ExtName); saveFileDialog.FileName = String.Format("{0}{1}", MainPictureBox.ActiveControlTag.ClassName, MainPictureBox.ActiveControlTag.ImageType.ExtName); if (saveFileDialog.ShowDialog() == DialogResult.OK) { MainPictureBox.SaveSingleImage(saveFileDialog.FileName); } }
private void SetPictureZoomSize() { ImageObject img = ImageList.GetCurrentImage(); if (img != null) { if (MainPictureBox.Image != null) { MainPictureBox.Image.Dispose(); } if (img.CanZoom()) { MainPictureBox.Image = img.GetImage(this.ZoomFactor); } else { MainPictureBox.ImageLocation = img.GetPath(); MainPictureBox.Load(); } SetPictureFieldSize(); } }
/// <summary> /// Called each time the player clicks on the main picture box /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainPictureBox_MouseClick(object sender, MouseEventArgs e) { var point = new Point { X = e.X, Y = e.Y }; if (GameWrapper.SelectedCell.HasValue) { GameWrapper.SwapSelectedCellOnMap(point); GameWrapper.RemoveCellMarkFromMap(); } else { var cell = GameWrapper.GetCellFromMap(point); if (cell.Type == CellTypes.Card) { GameWrapper.MarkCellOnMap(point); } } MainPictureBox.Refresh(); }