private void SetAnimationsToFrame(int Frame) { if (activeSampler != null) { var keyFrame = activeSampler.GetKeyFrame(Frame); var tex = activeSampler.GetActiveTexture((int)keyFrame.Value); if (tex != null) { if (Images.ContainsKey(Frame)) { pictureBoxCustom1.Image = Images[Frame]; } } else { pictureBoxCustom1.Image = null; } } else { pictureBoxCustom1.Image = null; } }
private void LoadAniamtion(MaterialAnimation anim, MaterialAnimation.SamplerKeyGroup activeSampler) { if (activeSampler == null || IsLoading) { return; } int imageIndex = 0; imgList.Images.Clear(); Images.Clear(); KeyFrames.Clear(); listViewCustom1.SmallImageList = imgList; listViewCustom1.Items.Clear(); listViewCustom1.View = View.SmallIcon; Thread Thread = new Thread((ThreadStart)(() => { IsLoading = true; for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { string TextureKey = activeSampler.GetActiveTextureNameByIndex((int)keyFrame.Value); var tex = activeSampler.GetActiveTexture((int)keyFrame.Value); if (tex != null) { Bitmap temp = tex.GetBitmap(); Images.Add(Frame, temp); KeyFrames.Add(Frame); if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { // Running on the UI thread listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + tex.Text, imageIndex++); imgList.Images.Add(temp); var dummy = imgList.Handle; }); } else { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + tex.Text, imageIndex++); } } else { if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + TextureKey, imageIndex++); }); } else { listViewCustom1.Items.Add($"{Frame} / {anim.FrameCount} \n" + TextureKey, imageIndex++); } } } } IsLoading = false; })); Thread.Start(); }
private void LoadAniamtion(MaterialAnimation anim, MaterialAnimation.SamplerKeyGroup activeSampler) { if (activeSampler == null || IsLoading) { return; } imgList.Images.Clear(); Images.Clear(); KeyFrames.Clear(); listViewCustom1.SmallImageList = imgList; listViewCustom1.Items.Clear(); listViewCustom1.View = View.SmallIcon; int ImageIndex = 0; for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { AddKeyFrame((int)keyFrame.Value, Frame, ImageIndex++); } } if (Thread != null && Thread.IsAlive) { Thread.Abort(); } Thread = new Thread((ThreadStart)(() => { for (int Frame = 0; Frame <= anim.FrameCount; Frame++) { //Constants always show so break after first frame if (activeSampler.Constant && Frame != 0) { break; } var keyFrame = activeSampler.GetKeyFrame(Frame); if (keyFrame.IsKeyed || activeSampler.Constant) { AddKeyFrameImage((int)keyFrame.Value, Frame); } } IsLoading = true; if (listViewCustom1.InvokeRequired) { listViewCustom1.Invoke((MethodInvoker) delegate { if (listViewCustom1.Items.Count > 0) { listViewCustom1.Items[0].Selected = true; listViewCustom1.Select(); } }); } else { if (listViewCustom1.Items.Count > 0) { listViewCustom1.Items[0].Selected = true; listViewCustom1.Select(); } } IsLoading = false; })); Thread.Start(); }