Exemplo n.º 1
0
        void cmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox      cmb = sender as ComboBox;
            IAudioSession a   = (IAudioSession)cmb.SelectedItem;

            if (a == null)
            {
                return;
            }

            DialViewHolder view = dialViewHolders.Single(s => s.combobox == cmb); // Get viewholder of correct dial

            view.image.Source = a.imageSource;
        }
Exemplo n.º 2
0
        private void Read()
        {
            while (_continue)
            {
                try
                {
                    if (_serialPort.BytesToRead < 8)
                    {
                        continue;
                    }

                    byte[] buffer = new byte[8];
                    _serialPort.Read(buffer, 0, 8);

                    VMPacket packet = new VMPacket(buffer);

                    if (packet.isPing || packet.knobId - 1 < 0 || packet.knobId - 1 >= _dialViewHolders.Count)
                    {
                        continue;
                    }

                    _dispatcher.Invoke(() =>
                    {
                        try
                        {
                            Debug.WriteLineIf(packet.knobId == 1, packet.value);
                            DialViewHolder view    = _dialViewHolders[packet.knobId - 1];
                            view.progressbar.Value = packet.value;
                            IAudioSession a        = (IAudioSession)view.combobox.SelectedItem;

                            if (a == null)
                            {
                                return;
                            }

                            Debug.WriteLineIf(packet.knobId == 1, a.ToString());
                            a.Volume = (float)packet.value / (float)127;
                            Debug.WriteLineIf(packet.knobId == 1, a.Volume.ToString() + " " + packet.value);
                        }
                        catch (Exception)
                        {
                        }
                    });
                }
                catch (IOException e) {
                    MessageBox.Show(e.Message);
                    MessageBox.Show(e.InnerException.Message);
                }
            }
        }