Ejemplo n.º 1
0
        public RequestStatus RequestHighlightChange(ChangeHighlightRequestFromPreviewTool changeHighlightRequest)
        {
            lock (this)
            {
                assertPreviewToolIsAlreadyConnected();

                return(protocolWrapper.RequestHighlightChange(connectedPreviewToolId, changeHighlightRequest));
            }
        }
Ejemplo n.º 2
0
        public RequestStatus ConnectAndRequestHighlightChange(Guid previewToolId, ChangeHighlightRequestFromPreviewTool changeHighlightRequest)
        {
            lock (this)
            {
                assertPreviewToolIsNotYetConnected();

                var requestStatus = protocolWrapper.RequestHighlightChange(previewToolId, changeHighlightRequest);
                if (requestStatus.RequestAccepted)
                {
                    connectedPreviewToolId = previewToolId;
                }

                return(requestStatus);
            }
        }
Ejemplo n.º 3
0
        public async void RequestHighlightChange(SegmentPart segmentPart)
        {
            Log.Instance.WriteMessage($"Requesting highlight from memoQ.", SeverityOption.Info);
            var sourceFocusedRange = new FocusedRange(0, segmentPart.SourceContent.Length);
            var targetFocusedRange = new FocusedRange(0, segmentPart.TargetContent.Length);
            var request            = new ChangeHighlightRequestFromPreviewTool(segmentPart.PreviewPartId, segmentPart.SourceLangCode, segmentPart.TargetLangCode,
                                                                               segmentPart.SourceContent, segmentPart.TargetContent, sourceFocusedRange, targetFocusedRange);

            var requestStatus = await ConnectViewModel.CallProxyMethod(new Func <RequestStatus>(() => previewServiceProxy?.RequestHighlightChange(request)));

            if (requestStatus == null || !requestStatus.RequestAccepted)
            {
                ConnectViewModel.IsConnected = false;
            }
        }
        private bool tryGetRequest(out Guid previewToolId, out ChangeHighlightRequestFromPreviewTool request)
        {
            request = null;

            if (!Guid.TryParse(tbPreviewToolId.Text, out previewToolId))
            {
                MessageBox.Show(this, "The preview tool id is missing or it is not a valid GUID.", "Demo preview tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (string.IsNullOrWhiteSpace(tbPreviewPartId.Text))
            {
                MessageBox.Show(this, "The preview part id cannot be empty.", "Demo preview tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (cbSendSourceFocusedRange.Checked)
            {
                if (nudSourceFocusedRangeStart.Value < 0 || nudSourceFocusedRangeLength.Value < 0 || !cbSendSourceContent.Checked ||
                    nudSourceFocusedRangeStart.Value + nudSourceFocusedRangeLength.Value > tbSourceContent.Text.Length)
                {
                    MessageBox.Show(this, "The source focused range is not valid.", "Demo preview tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            if (cbSendTargetFocusedRange.Checked)
            {
                if (nudTargetFocusedRangeStart.Value < 0 || nudTargetFocusedRangeLength.Value < 0 || !cbSendTargetContent.Checked ||
                    nudTargetFocusedRangeStart.Value + nudTargetFocusedRangeLength.Value > tbTargetContent.Text.Length)
                {
                    MessageBox.Show(this, "The target focused range is not valid.", "Demo preview tool", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }

            request = new ChangeHighlightRequestFromPreviewTool(
                tbPreviewPartId.Text,
                string.IsNullOrWhiteSpace(tbSourceLangCode.Text) ? null : tbSourceLangCode.Text,
                string.IsNullOrWhiteSpace(tbTargetLangCode.Text) ? null : tbTargetLangCode.Text,
                cbSendSourceContent.Checked ? tbSourceContent.Text : null,
                cbSendTargetContent.Checked ? tbTargetContent.Text : null,
                cbSendSourceFocusedRange.Checked ? new FocusedRange((int)nudSourceFocusedRangeStart.Value, (int)nudSourceFocusedRangeLength.Value) : null,
                cbSendTargetFocusedRange.Checked ? new FocusedRange((int)nudTargetFocusedRangeStart.Value, (int)nudTargetFocusedRangeLength.Value) : null);
            return(true);
        }
Ejemplo n.º 5
0
 public abstract RequestStatus RequestHighlightChange(Guid previewToolId, ChangeHighlightRequestFromPreviewTool changeHighlightRequest);
Ejemplo n.º 6
0
 public override RequestStatus RequestHighlightChange(Guid previewToolId, ChangeHighlightRequestFromPreviewTool changeHighlightRequest)
 {
     sendCommand(PipeCommandTypes.ChangeHighlightRequestFromPreviewTool, changeHighlightRequest.Convert(previewToolId), changeHighlightReponseReceived);
     return(changeHighlightRequestStatus);
 }
Ejemplo n.º 7
0
        public override RequestStatus RequestHighlightChange(Guid previewToolId, ChangeHighlightRequestFromPreviewTool changeHighlightRequest)
        {
            var request = changeHighlightRequest.Convert();

            return(sendRequest("highlight", HttpMethod.Post, previewToolId, JsonConvert.SerializeObject(request, request.GetType(), serializerSettings)));
        }