Example #1
0
 /// <summary>
 /// Creates the correct object based on the config
 /// </summary>
 private void InitInterface()
 {
     this.Cursor = Cursors.AppStarting;
     if (config.Mode == ModeConfig.Modes.Client)
     {
         try
         {
             pluginClient  = null;
             serverClient  = new FutureConcepts.Media.Client.CameraControl(config.ServerAddress);
             currentClient = serverClient;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Server Client failed.");
         }
     }
     else if (config.Mode == ModeConfig.Modes.Direct)
     {
         try
         {
             serverClient  = null;
             pluginClient  = new DirectCameraControl();
             currentClient = pluginClient;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString(), "Plugin Client failed.");
         }
     }
     this.Cursor = Cursors.Default;
 }
Example #2
0
        /// <summary>
        /// Deletes any/all created interfaces
        /// </summary>
        private void ClearInterface()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (serverClient != null)
                {
                    serverClient.Close();
                    serverClient.Opened          -= new EventHandler(cameraControlClient_Opened);
                    serverClient.PropertyChanged -= new PropertyChangedEventHandler(currentClient_PropertyChanged);
                    serverClient.Dispose();
                }
                if (pluginClient != null)
                {
                    pluginClient.Close();
                    pluginClient.PropertyChanged -= new PropertyChangedEventHandler(currentClient_PropertyChanged);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred while disconnecting the current interface. If you encounter further problems, restart this application." +
                                Environment.NewLine + Environment.NewLine + ex.ToString(),
                                "An error occured in ClearInterface()");
            }
            finally
            {
                serverClient  = null;
                pluginClient  = null;
                currentClient = null;
                this.Cursor   = Cursors.Default;
            }
        }