Ventuz.Remoting4
Posted: 20 Jan 2014, 15:54
				
				Hello.
I'm working with Ventuz.Remoting4. I want to get the animation(s) from a loaded scene. Because i don't know nothing about the scene and the machines, i need to discover all things.
For now, i'm using the Cluster class to discover the machines. This is ok.
Next i suppose i need the pipe info from a loaded scene to get the IID. The problem is LayoutIID from pipe info is null (there is a machine). The over problem is i don't know where to find the name of the scene.
For the next step, i suppose i should use "SceneModel.FromStream" to get the animations. I need the xaml Stream, but i don't really know how to get it from a specific scene. Perhaps i should use Cluster.SceneModel, but i need the IID.
Could you tell me the right way to do this ?
Here is some code i tried :
			I'm working with Ventuz.Remoting4. I want to get the animation(s) from a loaded scene. Because i don't know nothing about the scene and the machines, i need to discover all things.
For now, i'm using the Cluster class to discover the machines. This is ok.
Next i suppose i need the pipe info from a loaded scene to get the IID. The problem is LayoutIID from pipe info is null (there is a machine). The over problem is i don't know where to find the name of the scene.
For the next step, i suppose i should use "SceneModel.FromStream" to get the animations. I need the xaml Stream, but i don't really know how to get it from a specific scene. Perhaps i should use Cluster.SceneModel, but i need the IID.
Could you tell me the right way to do this ?
Here is some code i tried :
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Ventuz.Remoting4;
using Ventuz.Remoting4.SceneModel;
using System.Windows.Markup;
namespace VentuzDirectorTest
{
    /// <summary>
    /// Interaction logic for VentuzDirectorTest-Window
    /// </summary>
    public partial class Window : UserControl
    {
        VentuzDirectorTest.Plugin plugin;
        private Cluster m_Cluster = null;
        private VentuzInfo vtzInfo;
        public Window(VentuzDirectorTest.Plugin plugin)
        {
            this.plugin = plugin;
            this.DataContext = plugin;
            InitializeComponent();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (m_Cluster != null)
                return;
            try
            {
                m_Cluster = new Cluster();
                m_Cluster.Name = "Ventuz";
                //m_Cluster.VentuzInfo;
                //{ Name = "Ventuz" };
                m_Cluster.AddMachine(new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 19400));
                //m_Cluster.AddMachine(new System.Net.IPEndPoint(System.Net.IPAddress.Parse("10.0.0.8"), 19400));
                m_Cluster.Log += cluster_Log;
                m_Cluster.ClusterStateChanged += cluster_ClusterStateChanged;
                m_Cluster.VentuzInfoChanged += cluster_VentuzInfoChanged;
                m_Cluster.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Init : " + ex.Message);
            }
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (m_Cluster == null)
                return;
            try
            {
                m_Cluster.Shutdown();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error End : " + ex.Message);
            }
            finally
            {
                m_Cluster = null;
            }
        }
        private void cluster_Log(object sender, LogEventArgs e)
        {
            if(m_Cluster != null)
                TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("Log : {0}: {1} {2} {3}\r\n", m_Cluster.Name, e.Level, e.Module, e.Message); }));
        }
        private void cluster_ClusterStateChanged(object sender, EventArgs e)
        {
            if (m_Cluster != null){
                TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("ClusterState : {0}\r\n", m_Cluster.ClusterState); }));
                /*if (m_Cluster.ClusterState == ClusterState.Ok)
                {
                    DataModel projectDM = (DataModel)System.Windows.Markup.XamlReader.Parse(m_Cluster.DataModel(null).Result);
                    if (!projectDM.IsEmpty)
                    {
                        foreach (DataItem dt in projectDM.Items)
                        {
                            TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("{0}: {1} {2} {3} {4}\r\n", dt.Name, dt.Description, dt.Label, dt.Mode, dt.UserData); }));
                        }
                    }
                }*/
                if (m_Cluster.ClusterState == ClusterState.Ok)
                {
                    /*try
                    {
                        //DataModel liveOptionsDM = (DataModel)XamlReader.Parse(m_Cluster.OptionsDataModel(null).Result);
                        DataModel projectDM = (DataModel)System.Windows.Markup.XamlReader.Parse(m_Cluster.DataModel(null).Result);
                        MessageBox.Show(projectDM.ToString());
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }*/
                     PipeInfo pp = new PipeInfo();
                     bool bTest = m_Cluster.TryGetPipeInfo(0, 0, out pp);
                     if (bTest)
                     {
                         TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("LayoutIID : {0}\r\n", pp.LayoutIID); }));
                     }
                    /*IID[] iiis = m_Cluster.Scenes("0000", true, null).Result;
                    foreach (IID iii in iiis)
                    {
                        TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("{0}\r\n", iii.ToString()); }));
                    }*/
                }
                //string sm = m_Cluster.SceneModel(null).Result;
                //TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += sm; }));
            }
        }
        private void cluster_VentuzInfoChanged(object sender, VentuzInfoChangedEventArgs e)
        {
            vtzInfo = e.Info;
            TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("Info : {0}\r\n", vtzInfo); }));
            PipeInfo pp = new PipeInfo();
            bool bTest = m_Cluster.TryGetPipeInfo(0, 0, out pp);
            if (bTest)
            {
                TexBlock1.Dispatcher.BeginInvoke((Action)(() => { TexBlock1.Text += string.Format("LayoutIID 2 : {0}\r\n", pp.LayoutIID); }));
            }
            /*try
            {
                DataModel liveOptionsDM = (DataModel)XamlReader.Parse(m_Cluster.OptionsDataModel(null).Result);
                MessageBox.Show(liveOptionsDM.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }*/
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            TexBlock1.Text = "";
        }
    }
}