Exemplo n.º 1
0
        private void RefreshViewers(bool silent)
        {
            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    GetActiveViewersResult result = client.GetActiveViewers();

                    ClearAllViewers();

                    foreach (Viewer viewer in result.ActiveViewers)
                    {
                        StudyItem study = GetStudy(viewer.PrimaryStudyInstanceUid);
                        if (study != null)
                        {
                            study.AddViewer(viewer.Identifier);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ClearAllViewers();
                    if (!silent)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void OnActivateViewer(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                MessageBox.Show("Select a single study item in the list.");
                return;
            }

            Guid?viewerId = GetSelectedViewer();

            if (viewerId == null)
            {
                MessageBox.Show("An active viewer must be selected.");
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    ActivateViewerRequest request = new ActivateViewerRequest();
                    request.Viewer            = new Viewer();
                    request.Viewer.Identifier = GetIdentifier(viewerId.Value);
                    client.ActivateViewer(request);
                }
                catch (Exception ex)
                {
                    study.RemoveViewer(viewerId.Value);
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
 private void ClearAllViewers()
 {
     foreach (DataGridViewRow row in _studyGrid.Rows)
     {
         StudyItem item = (StudyItem)row.DataBoundItem;
         item.ClearViewers();
     }
 }
Exemplo n.º 4
0
        private void OnOpenStudy(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    OpenStudiesRequest   request       = new OpenStudiesRequest();
                    List <OpenStudyInfo> studiesToOpen = new List <OpenStudyInfo>();
                    foreach (StudyItem s in GetSelectedStudies())
                    {
                        OpenStudyInfo info = new OpenStudyInfo();
                        info.StudyInstanceUid = s.StudyInstanceUid;
                        info.SourceAETitle    = s.RetrieveAETitle;
                        studiesToOpen.Add(info);
                    }

                    request.StudiesToOpen         = GetStudiesToOpen(studiesToOpen);
                    request.ActivateIfAlreadyOpen = _activateIfOpen.Checked;

                    OpenStudiesResult result = client.OpenStudies(request);
                    if (result.Viewer != null)
                    {
                        bool shouldExist = study.HasViewers && _activateIfOpen.Checked;
                        bool exists      = study.HasViewer(result.Viewer.Identifier);
                        if (shouldExist && !exists)
                        {
                            study.ClearViewers();
                        }

                        if (!exists)
                        {
                            study.AddViewer(result.Viewer.Identifier);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 5
0
        private void OnStudySelectionChanged(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                _openViewers.DataSource = null;
            }
            else
            {
                _openViewers.DataSource = study.ActiveViewers;
                if (study.HasViewers)
                {
                    _openViewers.SelectedIndex = 0;
                }
            }
        }
Exemplo n.º 6
0
        private void OnGetSelectedInfo(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                MessageBox.Show("Select a single study item in the list.");
                return;
            }

            Guid?selectedViewer = GetSelectedViewer();

            if (selectedViewer == null)
            {
                MessageBox.Show("An active viewer must be selected.");
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    GetViewerInfoRequest request = new GetViewerInfoRequest();
                    request.Viewer            = new Viewer();
                    request.Viewer.Identifier = GetIdentifier(selectedViewer.Value);
                    GetViewerInfoResult result = client.GetViewerInfo(request);

                    StringBuilder builder = new StringBuilder();
                    builder.AppendLine("Additional studies:");

                    foreach (string additionalStudyUid in result.AdditionalStudyInstanceUids)
                    {
                        builder.AppendLine(additionalStudyUid);
                    }

                    MessageBox.Show(builder.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }