private void OnJniorMonitorNotify(Jnior jnior, MonitorArgs args) { StringBuilder sbInputs = new StringBuilder(); StringBuilder sbOutputs = new StringBuilder(); int inputs = jnior.GetInputs(); int outputs = jnior.GetOutputs(); for (int i = 7; i >= 0; i--) { sbInputs.Append(jnior.GetInput(i)); sbOutputs.Append(jnior.GetOutput(i)); } DateTime jniorTime = Jnior.EPOCH.AddMilliseconds(args.Monitor.jniorTime); string timeString = jniorTime.ToLocalTime().ToString("dd.MM.yyyy HH:mm:ss.fff"); this.Invoke((MethodInvoker)delegate { if (jniorInputs.IsDisposed || jniorOutputs.IsDisposed || lastUpdated.IsDisposed) return; jniorInputs.Text = sbInputs.ToString(); jniorOutputs.Text = sbOutputs.ToString(); lastUpdated.Text = timeString; }); //Console.WriteLine("Inputs: " + sbInputs.ToString() + ", Outputs: " + sbOutputs.ToString() + ", Time : " + timeString); // Don't do the bridging, if the box is unchecked. // The jnior API fails to stop sending monitor packets after DisableMonitorPackets :P if (!monitorInputs.Checked) return; // Handle volume inputs // TODO: Don't increase when multiple monitor events come in without setting this back to 0. if (jnior.GetInput(JNIOR_INCREASE_INPUT) == 1) { dolby_.IncreaseVolume(); } else if (jnior.GetInput(JNIOR_DECREASE_INPUT) == 1) { dolby_.DecreaseVolume(); } }
private void OnJniorConnectionNotify(Jnior jnior, StatusArgs args) { updateIcon(); updateMonitorStatus(); // Don't spam if (args.Status == jnior_dll_calls.STATUS_CONNECTING || args.Status == jnior_dll_calls.STATUS_RECONNECTING) return; Console.WriteLine("Jnior > " + args.Message); this.Invoke((MethodInvoker)delegate { if (jniorStatus.IsDisposed) return; jniorStatus.Text = args.Message; }); if (args.Status == jnior_dll_calls.STATUS_CONNECTED) { // Login to jnior box! LoginProperties lp = new LoginProperties(JNIOR_USER, JNIOR_PASSWORD); jnior_.LoginAsync(lp); } else if (args.Status == jnior_dll_calls.STATUS_CONNECTION_FAILED || args.Status == jnior_dll_calls.STATUS_DISCONNECTED) { // Reconnect right away. ConnectJnior(); } }
private void OnJniorLoginNotify(Jnior jnior, StatusArgs args) { Console.WriteLine("Jnior > " + args.Message); this.Invoke((MethodInvoker)delegate { if (jniorStatus.IsDisposed) return; jniorStatus.Text = args.Message; }); }
private void Form1_Load(object sender, EventArgs e) { // Setup Dolby CP750 wrapper dolby_ = new DolbyCP750(); dolby_.DisconnectedEvent += OnDolbyConnectionChanged; // Access the jnior box! jnior_ = new Jnior(); jnior_.AddConnectionCallback(new jnior_dll_calls.StatusCallback(OnJniorConnectionNotify)); jnior_.AddLoginCallback(new jnior_dll_calls.StatusCallback(OnJniorLoginNotify)); jnior_.AddMonitorCallback(new jnior_dll_calls.MonitorCallback(OnJniorMonitorNotify)); // Connect to Dolby dolby_.Connect(); // Instantiate the writer ConsoleRedirection.TextBoxStreamWriter _writer = new ConsoleRedirection.TextBoxStreamWriter(textBox1); // Redirect the out Console stream Console.SetOut(_writer); // Connect to jnior ConnectJnior(); }