private void LoadTexturesFromModel() { ListViewItem firstItem = null; var imgList = new ImageList(); // Clear Items ListViewEx1.Items.Clear(); colorImages.Clear(); realTextures.Clear(); // Setup Imagelist imgList.ImageSize = new Size(64, 64); ListViewEx1.LargeImageList = imgList; foreach (KeyValuePair <string, Material> mat in obj3d.Materials) { int imageIndex = imgList.Images.Count; var item = new ListViewItem() { Text = mat.Key, ImageIndex = imageIndex, Tag = mat }; if (mat.Value.Image is object) { var bmp = TextureManager.ResizeImage(mat.Value.Image, imgList.ImageSize, true, true); realTextures.Add(imageIndex, mat.Value.Image); imgList.Images.Add(bmp); } else { Image img = GetImageFromColor((Color)mat.Value.Color, new Size(32, 32)); colorImages.Add(item.ImageIndex); imgList.Images.Add(img); } if (firstItem is null) { firstItem = item; } ListViewEx1.Items.Add(item); } // Select First Item if (firstItem is object) { firstItem.Selected = true; } ListViewEx1.Refresh(); }
private void LoadTrajectory(Trajectory trac) { ListViewEx1.SuspendLayout(); ListViewEx1.Items.Clear(); foreach (Vector3 v in trac.Points) { var lvi = new ListViewItem(new string[] { "", v.X.ToString(), v.Y.ToString(), v.Z.ToString() }); lvi.Tag = v; ListViewEx1.Items.Add(lvi); } if (ListViewEx1.Items.Count > 0) { ListViewEx1.Items[0].Selected = true; } ListViewEx1.ResumeLayout(); }
private void MoveNode(int additor) { if (additor != 0 && SelectedTrajectory is object) { ListViewEx1.SuspendLayout(); var indicies = new int[ListViewEx1.SelectedIndices.Count]; ListViewEx1.SelectedIndices.CopyTo(indicies, 0); foreach (int index in additor < 0 ? indicies.OrderByDescending(n => n) : indicies.OrderBy(n => n)) { int newIndex = index + additor; if (newIndex >= 0 && newIndex < ListViewEx1.Items.Count) { var item = ListViewEx1.Items[index]; ListViewEx1.Items.RemoveAt(index); SelectedTrajectory.Points.RemoveAt(index); ListViewEx1.Items.Insert(newIndex, item); SelectedTrajectory.Points.Insert(newIndex, (Vector3)item.Tag); } } ListViewEx1.ResumeLayout(); } }