コード例 #1
0
        public string ShowDialog(EyeshotClient client, TransformationType transformationType)
        {
            _eyeshotClient = client;

            // Locks the popup size
            MinimumSize = MaximumSize = Size;

            switch (transformationType)
            {
            case TransformationType.Rotate:
                grpTranslate.Enabled = grpScale.Enabled = false;
                break;

            case TransformationType.Translate:
                grpRotate.Enabled = grpScale.Enabled = false;
                break;

            case TransformationType.Scale:
                grpRotate.Enabled = grpTranslate.Enabled = false;
                break;
            }

            if (ShowDialog() != DialogResult.OK)
            {
                _transformationText = String.Empty;
            }
            return(_transformationText);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the client and establishes a new connection to the Eyeshot Web Service.
        /// </summary>
        /// <remarks>The client must support the callback for listening the web service replies.</remarks>
        private void ClientConnect()
        {
            btnConnect.Enabled = false;

            if (_client != null)
            {
                try
                {
                    _client.Close();
                }
                catch
                {
                    _client.Abort();
                }
                finally
                {
                    _client = null;
                }
            }

            _callback = new EyeshotCallback();
            CallbackEventSubscription(true);

            var instanceContext = new InstanceContext(_callback);

            _client = new EyeshotClient(instanceContext);
            ClientEventSubscription(true);

            bool opened = false;

            try
            {
                _client.Open();
                opened = true;
            }
            catch (Exception ex)
            {
                if (ex is PlatformNotSupportedException)
                {
                    AppendToLog("This platform does not support client side WebSockets natively. Please try with a more recent Windows version (Windows 8 or higher)");
                }
                else
                {
                    AppendToLog(ex.Message);
                }
                btnConnect.Enabled = true;
            }

            if (!opened)
            {
                return;
            }

            _connectionId = _client.Connect(accessKey);
            if (_connectionId > 0)
            {
                lblConnectionId.Text = "Id: " + _connectionId;

                _downloadFolder = System.IO.Path.Combine(_rootDownloadFolder, String.Format(@"{0}\", _connectionId));

                if (!Directory.Exists(_downloadFolder))
                {
                    Directory.CreateDirectory(_downloadFolder);
                }

                InitReadingSettings();

                btnInputFile.Enabled  = btnUpdateSettings.Enabled = txtInput.Enabled = btnUpload.Enabled = trackUpload.Enabled = true;
                btnExtraFiles.Enabled = false;
                btnDisconnect.Enabled = true;

                AppendToLog("Connection established.", true);
            }
            else
            {
                AppendToLog("Connection failed.", true);

                if (_connectionId == -1)
                {
                    AppendToLog("Invalid access key. Get it here: https://www.devdept.com/Account");
                }
                else if (_connectionId == -2)
                {
                    AppendToLog("The access key has been suspended.");
                }
                else if (_connectionId == -3)
                {
                    AppendToLog("Error while opening the connection.");
                }

                ClientShutdown();
                btnConnect.Enabled = true;
            }
        }