示例#1
0
        private static void AddPrefixForAccNo(String strAccPrefix, MElementList elmlist, String accNoOrg)
        {
            using (MElementRef element = elmlist.get_Element(tag_t.kAccessionNumber))
            {
                string accNoNew = strAccPrefix + accNoOrg;

                //delete special char
                string          accNoNew_temp = "";
                Regex           re            = new Regex(@"[a-zA-Z0-9-_]+", RegexOptions.None);
                MatchCollection collection    = re.Matches(accNoNew);
                foreach (Match ma in collection)
                {
                    accNoNew_temp += ma.ToString();
                }
                accNoNew = accNoNew_temp;

                if (element == null || (element != null && element.value_count <= 0))
                {
                    MElement ele = new MElement(tag_t.kAccessionNumber, vr_t.LO);
                    ele.set_string(0, accNoNew);
                    elmlist.addElement(ele);
                }
                else
                {
                    element.set_string(0, accNoNew);
                }
            }
        }
示例#2
0
        private static void SetTSN(MElementList elmlist)
        {
            string str_tsn = "";

            using (MElementRef element = elmlist.get_Element(tag_t.kTransferSyntaxUID))
            {
                if (element != null && element.value_count > 0)
                {
                    str_tsn = element.get_string(0);
                    if (str_tsn == "")
                    {
                        str_tsn = "1.2.840.10008.1.2";
                        kdt_managed.UID tsn = new kdt_managed.UID(str_tsn);
                        element.set_uid(0, tsn);
                    }
                }
            }

            if (str_tsn == "")
            {
                MElement        tsnUid = new MElement(tag_t.kTransferSyntaxUID, vr_t.UI);
                kdt_managed.UID tsn    = new kdt_managed.UID("1.2.840.10008.1.2");
                tsnUid.set_uid(0, tsn);
                elmlist.addElement(tsnUid);
            }
        }
示例#3
0
        private static string AddPrefix(String strAccPrefix, MElementList elmlist, String accNoOrg, String patIDOrg, int PrefixLength)
        {
            AddPrefixForAccNo(strAccPrefix, elmlist, accNoOrg);
            //Modify PatientID
            if (patIDOrg.Length > PrefixLength)
            {
                patIDOrg = patIDOrg.Remove(PrefixLength);
            }
            using (MElementRef element = elmlist.get_Element(tag_t.kPatientID))
            {
                string patIDNew = strAccPrefix + patIDOrg;

                //delete special char
                string          patIDNew_temp = "";
                Regex           re            = new Regex(@"[a-zA-Z0-9-_]+", RegexOptions.None);
                MatchCollection collection    = re.Matches(patIDNew);
                foreach (Match ma in collection)
                {
                    patIDNew_temp += ma.ToString();
                }
                patIDNew = patIDNew_temp;

                if (element == null || (element != null && element.value_count <= 0))
                {
                    MElement ele = new MElement(tag_t.kPatientID, vr_t.LO);
                    ele.set_string(0, patIDNew);
                    elmlist.addElement(ele);
                }
                else
                {
                    element.set_string(0, patIDNew);
                }
            }
            return(patIDOrg);
        }
        /// <summary>
        /// Connect input stream to scene element
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLinkWithInputStram_Click(object sender, EventArgs e)
        {
            if (dataGridViewStreams.SelectedRows != null && dataGridViewStreams.SelectedRows.Count > 0 && mElementsTree.SelectedElement != null)
            {
                // Get selected stream id
                string sStreamID;
                ((IMProps)dataGridViewStreams.SelectedRows[0].Tag).PropsGet("stream_id", out sStreamID);

                MElement pRoot = mElementsTree.SelectedElement;
                if (pRoot != null)
                {
                    MElement pChild;
                    ((IMElements)pRoot).ElementsAdd("", "video", "stream_id=" + sStreamID + " h=0.5 w=0.5 show=1", out pChild, 0);//(double)numericTimeForChange.Value);
                    mElementsTree.UpdateTree(true);
                    mElementsTree.SelectedElement = pChild;

                    if (pChild == null)
                    {
                        return;
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pChild);
                    GC.Collect();
                }
            }
        }
示例#5
0
        internal static TableColumnInfo Create(MElement element, MarkdownStringWriter writer, int index = 0)
        {
            HorizontalAlignment alignment = (element as MTableColumn)?.Alignment ?? HorizontalAlignment.Left;

            int length = writer.Length - index;

            return(new TableColumnInfo(alignment, length, writer.GetStringBuilder().IsWhiteSpace(index, length)));
        }
        internal override void ValidateElement(MElement element)
        {
            if (element.Kind == MarkdownKind.OrderedItem)
            {
                return;
            }

            base.ValidateElement(element);
        }
示例#7
0
        internal override void ValidateElement(MElement element)
        {
            switch (element.Kind)
            {
            case MarkdownKind.TableColumn:
                return;
            }

            base.ValidateElement(element);
        }
        /// <summary>
        /// Remove scene element
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonRemoveSceneElement_Click(object sender, EventArgs e)
        {
            MElement pRemove = mElementsTree.SelectedElement;

            if (pRemove != null)
            {
                pRemove.ElementDetach((double)numericTimeForChange.Value);
                mElementsTree.UpdateTree(false);
            }
        }
 internal override void ValidateElement(MElement element)
 {
     switch (element.Kind)
     {
     case MarkdownKind.TableColumn:
     case MarkdownKind.TableRow:
     case MarkdownKind.Document:
     {
         Error.InvalidContent(this, element);
         break;
     }
     }
 }
 private void panelPreview_MouseUp(object sender, MouseEventArgs e)
 {
     // End element move/resize
     m_objMixer.PreviewSetCursor("", eMCursorType.eMCT_ARROW);
     pEditElement   = null;
     isMoving       = false;
     isResizingHor  = false;
     isResizingVert = false;
     isLeftBound    = false;
     isTopBound     = false;
     mElementsTree.UpdateTree(true);
     UpdateAttributesList();
 }
示例#11
0
        internal static Matrix CreateMatrix(this IEnumerable <MatrixRow> rows)
        {
            var(colCount, rowCount) = (rows.Min(row => row.Size), rows.Count());
            var mat  = new MElement[rowCount, colCount];
            var list = rows.ToList();

            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < colCount; j++)
                {
                    mat[i, j] = list[i][j];
                }
            }
            return(new Matrix(mat));
        }
示例#12
0
        public void UpdateTree(bool bKeepSel)
        {
            MElement pSel = GetSelectedElement();

            Nodes.Clear();

            UpdateTree_R(Nodes, m_pElementsRoot);

            if (pSel != null && bKeepSel)
            {
                SetSelectedElement(pSel);
            }

            ExpandAll();
        }
示例#13
0
        bool SetSelectedElement_R(TreeNodeCollection tvNodes, MElement pSel)
        {
            for (int i = 0; i < tvNodes.Count; i++)
            {
                if (tvNodes[i].Tag.Equals(pSel))
                {
                    SelectedNode = tvNodes[i];
                    return(true);
                }

                if (SetSelectedElement_R(tvNodes[i].Nodes, pSel))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#14
0
        private void MElementsTree_AfterCheck(object sender, TreeViewEventArgs e)
        {
            MElement pSelElement = (MElement)e.Node.Tag;

            if (pSelElement != null)
            {
                if (e.Node.Checked)
                {
                    // Show item
                    pSelElement.ElementBoolSet("show", 1, m_dblTimeForChange);
                }
                else
                {
                    // Hide item
                    pSelElement.ElementBoolSet("show", 0, m_dblTimeForChange);
                }
            }
        }
示例#15
0
        private void MElementsTree_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            MElement pSelElement = SelectedElement;

            if (pSelElement != null)
            {
                int    bHave = 0;
                string sSelected;
                pSelElement.AttributesHave("selected", out bHave, out sSelected);
                if (bHave == 0 || sSelected != "true")
                {
                    pSelElement.ElementReorder(1000); // Move to top
                }
                // Note:
                // ElementInvoke("select", "true", m_dblTimeForChange); - > select element (by default - full screen)
                // ElementInvoke("select", "false", m_dblTimeForChange); - > unselect element (restore original)
                // ElementInvoke("select", "", m_dblTimeForChange) -> chnage selected <-> normal state
                pSelElement.ElementInvoke("select", "", m_dblTimeForChange);
            }
        }
示例#16
0
 public bool SetSelectedElement(MElement pSel)
 {
     return(SetSelectedElement_R(Nodes, pSel));
 }
示例#17
0
 private void OutputPanel_MouseUp(object sender, MouseEventArgs e)
 {
     // End element move/resize
     _Mixer.PreviewSetCursor("", eMCursorType.eMCT_ARROW);
     pEditElement = null;
     isMoving = false;
     isResizingHor = false;
     isResizingVert = false;
     isLeftBound = false;
     isTopBound = false;
     //mElementsTree.UpdateTree(true);
 }
示例#18
0
        private void OutputPanel_MouseDown(object sender, MouseEventArgs e)
        {
            double XMouse;
            double YMouse;
            XMouse = (PointToRelative(e.Location)).X;
            YMouse = (PointToRelative(e.Location)).Y;

            GetNewXY(ref XMouse, ref YMouse);

            // Select element in element tree
            MElement pElement = null;
            _Mixer.ScenesElementGetByPos(XMouse, YMouse, 0, out pElement);
            if (pElement != null)
            {
                Console.WriteLine("pElement not null");
                pEditElement = pElement;
                try
                {
                    // Could be exception - if scene not rendred yet
                    double x, y, w, h;
                    pEditElement.ElementAbsolutePosGet(out x, out y, out w, out h);
                    rcOriginal.X = (float)x;
                    rcOriginal.Y = (float)y;
                    rcOriginal.Width = (float)w;
                    rcOriginal.Height = (float)h;
                    ptOriginal = new PointF((float)XMouse, (float)YMouse); ;

                    double deltax = 0.04;
                    double deltay = 0.04;
                    if (XMouse > x && XMouse < x + deltax)
                    {
                        _Mixer.PreviewSetCursor("", eMCursorType.eMCT_SIZEWE);
                        isResizingHor = true;
                        isLeftBound = true;
                    }
                    else if (XMouse < x + w && XMouse > x + w - deltax)
                    {
                        _Mixer.PreviewSetCursor("", eMCursorType.eMCT_SIZEWE);
                        isResizingHor = true;
                    }
                    else if (YMouse > y && YMouse < y + deltay)
                    {
                        _Mixer.PreviewSetCursor("", eMCursorType.eMCT_SIZENS);
                        isResizingVert = true;
                        isTopBound = true;
                    }
                    else if (YMouse < y + h && YMouse > y + h - deltay)
                    {
                        _Mixer.PreviewSetCursor("", eMCursorType.eMCT_SIZENS);
                        isResizingVert = true;
                    }
                    else
                    {
                        _Mixer.PreviewSetCursor("", eMCursorType.eMCT_SIZEALL);
                        isMoving = true;
                    }
                    // Make element topmost
                    pEditElement.ElementReorder(10000);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine("Exception: {0}", ex);
                }

            }
        }
        private void panelPreview_MouseDown(object sender, MouseEventArgs e)
        {
            double XMouse;
            double YMouse;

            XMouse = (PointToRelative(e.Location)).X;
            YMouse = (PointToRelative(e.Location)).Y;

            if (checkBoxAR.Checked)
            {
                GetNewXY(ref XMouse, ref YMouse);
            }

            // Select element in element tree
            MElement pElement = null;

            m_objMixer.ScenesElementGetByPos(XMouse, YMouse, 0, out pElement);
            if (pElement != null)
            {
                pEditElement = pElement;
                try
                {
                    // Could be exception - if scene not rendred yet
                    double x, y, w, h;
                    pEditElement.ElementAbsolutePosGet(out x, out y, out w, out h);
                    rcOriginal.X      = (float)x;
                    rcOriginal.Y      = (float)y;
                    rcOriginal.Width  = (float)w;
                    rcOriginal.Height = (float)h;
                    ptOriginal        = new PointF((float)XMouse, (float)YMouse);;

                    double deltax = 0.04;
                    double deltay = 0.04;
                    if (XMouse > x && XMouse < x + deltax)
                    {
                        m_objMixer.PreviewSetCursor("", eMCursorType.eMCT_SIZEWE);
                        isResizingHor = true;
                        isLeftBound   = true;
                    }
                    else if (XMouse < x + w && XMouse > x + w - deltax)
                    {
                        m_objMixer.PreviewSetCursor("", eMCursorType.eMCT_SIZEWE);
                        isResizingHor = true;
                    }
                    else if (YMouse > y && YMouse < y + deltay)
                    {
                        m_objMixer.PreviewSetCursor("", eMCursorType.eMCT_SIZENS);
                        isResizingVert = true;
                        isTopBound     = true;
                    }
                    else if (YMouse < y + h && YMouse > y + h - deltay)
                    {
                        m_objMixer.PreviewSetCursor("", eMCursorType.eMCT_SIZENS);
                        isResizingVert = true;
                    }
                    else
                    {
                        m_objMixer.PreviewSetCursor("", eMCursorType.eMCT_SIZEALL);
                        isMoving = true;
                    }
                    // Make element topmost
                    pEditElement.ElementReorder(10000);
                }
                catch (System.Exception)
                {
                }
            }
            if (pElement == null)
            {
                return;
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pElement);
            GC.Collect();
        }
示例#20
0
 public static void InvalidContent(MContainer container, MElement element)
 {
     throw new InvalidOperationException($"Element '{container.Kind}' cannot contain element '{element.Kind}'.");
 }
示例#21
0
        /// <summary>
        /// Save DICOM file
        /// </summary>
        /// <param name="dataset"></param>
        /// <param name="baseTsn"></param>
        /// <param name="implClassUid"></param>
        /// <param name="versionName"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        private bool SaveDICOMFile(MElementList dataset, ts_t baseTsn, string implClassUid, string versionName, string filePath)
        {
            try
            {
                // add the following group 2 element for writing pt10 files
                string str_tsn = "1.2.840.10008.1.2";
                switch (baseTsn)
                {
                case ts_t.ImplicitVRLittleEndian: str_tsn = "1.2.840.10008.1.2"; break;

                case ts_t.ExplicitVRBigEndian: str_tsn = "1.2.840.10008.1.2.2"; break;

                case ts_t.ExplicitVRLittleEndian: str_tsn = "1.2.840.10008.1.2.1"; break;

                case ts_t.JPEGLosslessNonHierarchical_14: str_tsn = "1.2.840.10008.1.2.4.57"; break;

                case ts_t.JPEGLosslessNonHierarchicalFirstOrderPrediction: str_tsn = "1.2.840.10008.1.2.4.70"; break;

                default: str_tsn = "1.2.840.10008.1.2"; break;
                }
                MElement tsnUid = new MElement(tag_t.kTransferSyntaxUID, vr_t.UI);
                UID      tsn    = new UID(str_tsn);
                tsnUid.set_uid(0, tsn);
                dataset.addElement(tsnUid);

                MElement implUid = new MElement(tag_t.kImplementationClassUID, vr_t.UI);
                UID      uid     = new UID(implClassUid);
                implUid.set_uid(0, uid);
                dataset.addElement(implUid);

                MElement implVer = new MElement(tag_t.kImplementationVersionName, vr_t.SH);
                string   version = versionName;
                implVer.set_string(0, version);
                dataset.addElement(implVer);

                // Note: in the current version,saving file will use a large size of memory,this is a limitation
                // of the managed class in KDT,in the later version,if the limitation is resolved,we will use
                // the MDecoder to save files,not the MEncoder.wirte_pt10_file
                if (MEncoder.write_pt10_file
                    (
                        filePath,
                        dataset,
                        true, // item length is explicit
                        false // do not check group 2 items
                    ))
                {
                    _logger.Info("DAPStoreService.SaveFile(): " + "save file:" + filePath + "OK.");
                    return(true);
                }
                else
                {
                    _logger.Info("DAPStoreService.SaveFile(): " + "save file:" + filePath + "failed.");
                    return(false);
                }
            }
            catch (Exception e)
            {
                _logger.Info("DAPStoreService.SaveFile(): " + "error occurred while trying to write part-10 file " + e.Message);
                return(false);
            }
        }