Beispiel #1
0
        public Form1(string[] args)
        {
            InitializeComponent();

            Debug.WriteLine(args);

            liveView.Show();
            liveView.Hide();
            thisform = this;
            thisform.Width = thisform.Width - 300;
            this.Text = this.Text + " v" + APPVERSION.ToString();
            lmdPreset = new LMDPresetItem[numberOfLMDPresets];
            this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
            this.trackBarVolume.MouseUp += new MouseEventHandler(trackBarVolume_MouseUp);
            this.trackBarVolume.KeyUp += new KeyEventHandler(trackBarVolume_KeyUp);
            this.trackBarVolume.MouseDown += new MouseEventHandler(trackBarVolume_MouseDown);
            this.trackBarSleepMode.KeyUp += new KeyEventHandler(trackBarSleepMode_KeyUp);
            this.trackBarSleepMode.MouseUp += new MouseEventHandler(trackBarSleepMode_MouseUp);
            this.trackBarSubwooferLevel.KeyUp += new KeyEventHandler(trackBarSubwooferLevel_KeyUp);
            this.trackBarSubwooferLevel.MouseUp += new MouseEventHandler(trackBarSubwooferLevel_MouseUp);
            this.lockLMDpresets.MouseClick += new MouseEventHandler(lockLMDpresets_MouseClick);
            this.radioCD.MouseClick += new MouseEventHandler(radioCD_MouseClick);
            this.radioDVD.MouseClick += new MouseEventHandler(radioDVD_MouseClick);
            this.radioVideo1.MouseClick += new MouseEventHandler(radioVideo1_MouseClick);
            this.radioVideo2.MouseClick += new MouseEventHandler(radioVideo2_MouseClick);
            this.radioVideo3.MouseClick += new MouseEventHandler(radioVideo3_MouseClick);
            this.radioVideo4.MouseClick += new MouseEventHandler(radioVideo4_MouseClick);
            this.radioVideo5.MouseClick += new MouseEventHandler(radioVideo5_MouseClick);
            this.radioTape1.MouseClick += new MouseEventHandler(radioTape1_MouseClick);
            this.radioPhono.MouseClick += new MouseEventHandler(radioPhono_MouseClick);
            this.radioFM.MouseClick += new MouseEventHandler(radioFM_MouseClick);
            this.radioAM.MouseClick += new MouseEventHandler(radioAM_MouseClick);
            this.radioButtonSirius.MouseClick += new MouseEventHandler(radioButtonSirius_MouseClick);
            this.radioButtonXM.MouseClick += new MouseEventHandler(radioButtonXM_MouseClick);
            this.radioButtonMultiChannel.MouseClick += new MouseEventHandler(radioButtonMultiChannel_MouseClick);
            this.radioButtonUSB.MouseClick += new MouseEventHandler(radioButtonUSB_MouseClick);
            this.radioButtonMusicServer.MouseClick += new MouseEventHandler(radioButtonMusicServer_MouseClick);
            this.radioButtonInternetRadio.MouseClick += new MouseEventHandler(radioButtonInternetRadio_MouseClick);
            this.btNetFF.MouseDown += new MouseEventHandler(btNetFF_MouseDown);
            this.btNetREW.MouseDown += new MouseEventHandler(btNetREW_MouseDown);
            this.btNetFF.MouseUp += new MouseEventHandler(btNetFF_MouseUp);
            this.btNetREW.MouseUp += new MouseEventHandler(btNetREW_MouseUp);
            thisform.KeyDown += new KeyEventHandler(thisform_KeyDown);

            groupBoxNetworkControls.Enabled = false;

            Monitor.Enter(lockObject);
            //volumeThread = new Thread(new ThreadStart(getCurrentVolumeLoop));
            //volumeThread.Start();

            addLMDButtons(numberOfLMDPresets);
            getConfigurationData();
            showButtons(false);
            showLMDStoreButtons(false);
            txtIP.Text = address;
            txtPort.Text = onkyoIPPort.ToString();

            fillDeviceList();
            onkyoConnection = new OnkyoConnection(thisform, liveView);
            //openConnection();
            if (checkBoxAutoConnect.Checked) btConnect_Click(this, new EventArgs());
        }
Beispiel #2
0
        private void btConnect_Click(object sender, EventArgs e)
        {
            if (!onkyoConnection.isConnected())
            {
                onkyoConnection = new OnkyoConnection(thisform, liveView);
                onkyoConnection.setIPAddress(address);
                onkyoConnection.setIPPort(onkyoIPPort);
                onkyoConnection.createConnection();
                onkyoConnection.VolumeChanged += new OnkyoConnection.VolumeChangedHandler(onkyoConnection_VolumeChange);
                onkyoConnection.SleepModeChanged += new OnkyoConnection.SleepModeChangedHandler(onkyoConnection_SleepModeChange);
                onkyoConnection.InputDeviceChanged += new OnkyoConnection.InputDeviceChangedHandler(onkyoConnection_InputDeviceChange);
                onkyoConnection.NTMChanged += new OnkyoConnection.NTMChangedHandler(onkyoConnection_NTMChange);
                onkyoConnection.connect();

                if (onkyoConnection.isConnected())
                {
                    btConnect.Text = "Disconnect";
                    btConnect.BackColor = SystemColors.Control;
                    setStatus(address + ":" + onkyoIPPort);
                    getCurrentInput();
                    getCurrentVolume();
                    runAutorunBatchs();
                    showButtons(true); // at the end, because otherwise it enables the first radio button of input select, which triggers a "changed" event and sets the input...
                }
            }
            else
            {
                onkyoConnection.close();
                if (!onkyoConnection.isConnected()) 
                {
                    showButtons(false);
                    setStatus("Disconnected");
                    btConnect.Text = "Connect";
                    btConnect.BackColor = SystemColors.Highlight;
                }
                else
                {
                    MessageBox.Show("Error disconnecting (maybe connection was already disconnected?)");
                }
            }
        }