예제 #1
0
        public GroupLabelWpfControl(List <AimTemplateTreeNode> treeNodes)
        {
            TreeNodes = treeNodes;

            NodeControls = new List <IValidTreeControl>();

            InitializeComponent();

            var visible = false;

            foreach (var treeNode in TreeNodes)
            {
                if (treeNode.ShouldDisplay)
                {
                    visible = true;
                }

                if (treeNode is AimTemplateTreeAnatomicEntityNode)
                {
                    var anatomicEntityControl =
                        new AnatomicEntityWpfControl((AimTemplateTreeAnatomicEntityNode)treeNode);
                    _stackPanel.Children.Add(anatomicEntityControl);
                    NodeControls.Add(anatomicEntityControl);
                }
                if (treeNode is AimTemplateTreeImagingObservationNode)
                {
                    var imagingObservationControl =
                        new ImagingObservationWpfControl((AimTemplateTreeImagingObservationNode)treeNode);
                    _stackPanel.Children.Add(imagingObservationControl);
                    NodeControls.Add(imagingObservationControl);
                }
                if (treeNode is AimTemplateTreeInferenceNode)
                {
                    var inferenceControl =
                        new InferenceWpfControl((AimTemplateTreeInferenceNode)treeNode);
                    _stackPanel.Children.Add(inferenceControl);
                    NodeControls.Add(inferenceControl);
                }
                if (treeNode is AimTemplateTreeGeometricShapeNode)
                {
                    var geometricShapeControl =
                        new GeometricShapeWpfControl((AimTemplateTreeGeometricShapeNode)treeNode);
                    _stackPanel.Children.Add(geometricShapeControl);
                    NodeControls.Add(geometricShapeControl);
                }
                if (treeNode is AimTemplateTreeCalculationNode)
                {
                    var calculationControl =
                        new CalculationWpfControl((AimTemplateTreeCalculationNode)treeNode);
                    _stackPanel.Children.Add(calculationControl);
                    NodeControls.Add(calculationControl);
                }
                if (treeNode is AimTemplateTreeAnatomicEntityCharacteristicNode)
                {
                    var aecControl =
                        new AnatomicEntityCharacteristicWpfControl(
                            (AimTemplateTreeAnatomicEntityCharacteristicNode)treeNode);
                    _stackPanel.Children.Add(aecControl);
                    NodeControls.Add(aecControl);
                }
                if (treeNode is AimTemplateTreeImagingObservationCharacteristicNode)
                {
                    var iocControl =
                        new ImagingObservationCharacteristicWpfControl(
                            (AimTemplateTreeImagingObservationCharacteristicNode)treeNode);
                    _stackPanel.Children.Add(iocControl);
                    NodeControls.Add(iocControl);
                }
            }

            if (!visible)
            {
                Visibility = Visibility.Hidden;
                Height     = 0;
            }
        }
        public int NumberOfMissingMarkupRequiredByControl(GeometricShapeWpfControl geometricShapeControl)
        {
            for (int i = 0; i < geometricShapeControl.GeometricShape.MinCardinality; i++)
            {
                switch (geometricShapeControl.GeometricShape.GeometricShape)
                {
                case AimTemplateTreeGeometricShapeNode.GeometricShapes.MultiPoint:
                    if (_unusedMarkup.OfType <MarkupLinear>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupLinear>().FirstOrDefault());
                    }
                    else if (_unusedMarkup.OfType <MarkupProtractor>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupProtractor>().FirstOrDefault());
                    }
                    else
                    {
                        return(geometricShapeControl.GeometricShape.MinCardinality - i);
                    }
                    break;

                case AimTemplateTreeGeometricShapeNode.GeometricShapes.Polyline:
                    if (_unusedMarkup.OfType <MarkupRectangle>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupRectangle>().FirstOrDefault());
                    }
                    else if (_unusedMarkup.OfType <MarkupPolygonal>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupPolygonal>().FirstOrDefault());
                    }
                    else
                    {
                        return(geometricShapeControl.GeometricShape.MinCardinality - i);
                    }
                    break;

                case AimTemplateTreeGeometricShapeNode.GeometricShapes.Circle:
                    if (_unusedMarkup.OfType <MarkupEllipse>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupEllipse>().FirstOrDefault());
                    }
                    else
                    {
                        return(geometricShapeControl.GeometricShape.MinCardinality - i);
                    }
                    break;

                case AimTemplateTreeGeometricShapeNode.GeometricShapes.Ellipse:
                    if (_unusedMarkup.OfType <MarkupEllipse>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupEllipse>().FirstOrDefault());
                    }
                    else
                    {
                        return(geometricShapeControl.GeometricShape.MinCardinality - i);
                    }
                    break;

                case AimTemplateTreeGeometricShapeNode.GeometricShapes.Point:
                    if (_unusedMarkup.OfType <MarkupPoint>().Any())
                    {
                        _unusedMarkup.Remove(_unusedMarkup.OfType <MarkupPoint>().FirstOrDefault());
                    }
                    else
                    {
                        return(geometricShapeControl.GeometricShape.MinCardinality - i);
                    }
                    break;
                }
            }
            return(0);
        }
        public TemplateWpfControl(AimAnnotationComponent component, AimAnnotationComponentWpfControl parentComponentControl)
        {
            Component = component;

            NodeControls = new List <IValidTreeControl>();

            if (component.AimTemplateTree != null)
            {
                TreeNodes = new List <AimTemplateTreeNode>(component.AimTemplateTree.TemplateNodes);
                TreeNodes.Sort(new TemplateTreeNodeOrderComparer());
            }
            else
            {
                TreeNodes = new List <AimTemplateTreeNode>();
            }

            InitializeComponent();

            _stackPanel.Children.Add(new AnnotationNameWpfControl(Component));

            var groupedNodes = new List <AimTemplateTreeNode>();

            foreach (AimTemplateTreeNode treeNode in TreeNodes)
            {
                // Start or add to group label control
                if (!String.IsNullOrEmpty(treeNode.GroupLabel))
                {
                    if (groupedNodes.Count > 0 && treeNode.GroupLabel == groupedNodes[0].GroupLabel)
                    {
                        groupedNodes.Add(treeNode);
                    }
                    else
                    {
                        // Finish and add the group label control
                        if (groupedNodes.Count > 0)
                        {
                            var groupLabel = new GroupLabelWpfControl(groupedNodes)
                            {
                                Header = groupedNodes[0].GroupLabel
                            };
                            _stackPanel.Children.Add(groupLabel);
                            NodeControls.Add(groupLabel);
                        }

                        groupedNodes = new List <AimTemplateTreeNode> {
                            treeNode
                        };
                    }
                }
                else
                {
                    // Finish and add the group label control
                    if (groupedNodes.Count > 0)
                    {
                        var groupLabel = new GroupLabelWpfControl(groupedNodes)
                        {
                            Header = groupedNodes[0].GroupLabel
                        };
                        groupedNodes.Clear();
                        _stackPanel.Children.Add(groupLabel);
                        NodeControls.Add(groupLabel);
                    }

                    if (treeNode is AimTemplateTreeAnatomicEntityNode)
                    {
                        var anatomicEntityControl =
                            new AnatomicEntityWpfControl((AimTemplateTreeAnatomicEntityNode)treeNode);
                        _stackPanel.Children.Add(anatomicEntityControl);
                        NodeControls.Add(anatomicEntityControl);
                    }
                    if (treeNode is AimTemplateTreeImagingObservationNode)
                    {
                        var imagingObservationControl =
                            new ImagingObservationWpfControl((AimTemplateTreeImagingObservationNode)treeNode);
                        _stackPanel.Children.Add(imagingObservationControl);
                        NodeControls.Add(imagingObservationControl);
                    }
                    if (treeNode is AimTemplateTreeInferenceNode)
                    {
                        var inferenceControl =
                            new InferenceWpfControl((AimTemplateTreeInferenceNode)treeNode);
                        _stackPanel.Children.Add(inferenceControl);
                        NodeControls.Add(inferenceControl);
                    }
                    if (treeNode is AimTemplateTreeGeometricShapeNode)
                    {
                        var geometricShapeControl =
                            new GeometricShapeWpfControl((AimTemplateTreeGeometricShapeNode)treeNode);
                        _stackPanel.Children.Add(geometricShapeControl);
                        NodeControls.Add(geometricShapeControl);
                    }
                    if (treeNode is AimTemplateTreeCalculationNode)
                    {
                        var calculationControl =
                            new CalculationWpfControl((AimTemplateTreeCalculationNode)treeNode);
                        _stackPanel.Children.Add(calculationControl);
                        NodeControls.Add(calculationControl);
                    }
                }
            }

            // Finish and add the group label control
            if (groupedNodes.Count > 0)
            {
                var groupLabel = new GroupLabelWpfControl(groupedNodes)
                {
                    Header = groupedNodes[0].GroupLabel
                };
                _stackPanel.Children.Add(groupLabel);
                NodeControls.Add(groupLabel);
            }
        }
        public GroupLabelWpfControl(List<AimTemplateTreeNode> treeNodes)
        {
            TreeNodes = treeNodes;

            NodeControls = new List<IValidTreeControl>();

            InitializeComponent();

            var visible = false;

            foreach (var treeNode in TreeNodes)
            {
                if (treeNode.ShouldDisplay)
                    visible = true;

                if (treeNode is AimTemplateTreeAnatomicEntityNode)
                {
                    var anatomicEntityControl =
                        new AnatomicEntityWpfControl((AimTemplateTreeAnatomicEntityNode)treeNode);
                    _stackPanel.Children.Add(anatomicEntityControl);
                    NodeControls.Add(anatomicEntityControl);
                }
                if (treeNode is AimTemplateTreeImagingObservationNode)
                {
                    var imagingObservationControl =
                        new ImagingObservationWpfControl((AimTemplateTreeImagingObservationNode)treeNode);
                    _stackPanel.Children.Add(imagingObservationControl);
                    NodeControls.Add(imagingObservationControl);
                }
                if (treeNode is AimTemplateTreeInferenceNode)
                {
                    var inferenceControl =
                        new InferenceWpfControl((AimTemplateTreeInferenceNode)treeNode);
                    _stackPanel.Children.Add(inferenceControl);
                    NodeControls.Add(inferenceControl);
                }
                if (treeNode is AimTemplateTreeGeometricShapeNode)
                {
                    var geometricShapeControl =
                        new GeometricShapeWpfControl((AimTemplateTreeGeometricShapeNode)treeNode);
                    _stackPanel.Children.Add(geometricShapeControl);
                    NodeControls.Add(geometricShapeControl);
                }
                if (treeNode is AimTemplateTreeCalculationNode)
                {
                    var calculationControl =
                        new CalculationWpfControl((AimTemplateTreeCalculationNode)treeNode);
                    _stackPanel.Children.Add(calculationControl);
                    NodeControls.Add(calculationControl);
                }
                if (treeNode is AimTemplateTreeAnatomicEntityCharacteristicNode)
                {
                    var aecControl =
                        new AnatomicEntityCharacteristicWpfControl(
                            (AimTemplateTreeAnatomicEntityCharacteristicNode) treeNode);
                    _stackPanel.Children.Add(aecControl);
                    NodeControls.Add(aecControl);
                }
                if (treeNode is AimTemplateTreeImagingObservationCharacteristicNode)
                {
                    var iocControl =
                        new ImagingObservationCharacteristicWpfControl(
                            (AimTemplateTreeImagingObservationCharacteristicNode)treeNode);
                    _stackPanel.Children.Add(iocControl);
                    NodeControls.Add(iocControl);
                }
            }

            if (!visible)
            {
                Visibility = Visibility.Hidden;
                Height = 0;
            }
        }