/// <summary> /// Uses a memory stream to turn a byte array into a BitmapImage via helper method, BytesToImage, then passes the image /// to UpdateImage(BitmapImage) /// </summary> /// <param name="data"> /// </param> public void UpdateImage(byte[] data) { if (_image != null) { _image.Dispose(); _image = null; } //TheImage= DrawMap.BytesToBitmap(data); _image = DrawMap.BytesToBitmap(data); }
private void MainForm_Load(object sender, EventArgs e) { //if (!Ros_CSharp.ROS.()) //{ // MessageBox.Show("主机连接失败!请检查配置。"); // Application.Exit(); // return; //} // Create draw area drawArea = new DrawArea(); drawArea.Location = new Point(0, 0); drawArea.Size = new Size(10, 10); drawArea.Owner = this; Controls.Add(drawArea); // Helper objects (DocManager and others) InitializeHelperObjects(); drawArea.Initialize(this, docManager); ResizeDrawArea(); LoadSettingsFromRegistry(); // Submit to Idle event to set controls state at idle time Application.Idle += delegate { SetStateOfControls(); }; // Open file passed in the command line if (ArgumentFile.Length > 0) { OpenDocument(ArgumentFile); } // Subscribe to DropDownOpened event for each popup menu // (see details in MainForm_DropDownOpened) foreach (ToolStripItem item in menuStrip1.Items) { if (item.GetType() == typeof(ToolStripMenuItem)) { ((ToolStripMenuItem)item).DropDownOpened += MainForm_DropDownOpened; } } timer1.Start(); //增加地图图元 drawMap = new ROS.DrawMap(drawArea); //drawMap.GetStaticMap("static_map"); drawMap.SubscribeToMap("/map"); AddNewObject(drawArea, drawMap); }