Пример #1
0
        public void WriteMultipleFl()
        {
            var vssd = DICOMForge.VirtualSourceAxisDistances();

            vssd.Data_ = new System.Collections.Generic.List <float>()
            {
                2538.4199f, 2541.00f
            };
            byte[] elBytes = null;
            using (var stream = new MemoryStream())
            {
                using (var dw = new DICOMBinaryWriter(stream))
                {
                    DICOMElementWriter.Write(dw, DICOMWriteSettings.DefaultExplicit(), vssd);
                    elBytes = stream.ToArray();
                }
            }

            AbstractElement <float> readVssd = null;

            using (var dr = new DICOMBinaryReader(elBytes))
            {
                readVssd = DICOMElementReader.ReadElementExplicitLittleEndian(dr) as AbstractElement <float>;
            }

            Assert.AreEqual(readVssd.Data_.Count, 2);
            Assert.AreEqual(readVssd.Data_[0], 2538.4199f);
            Assert.AreEqual(readVssd.Data_[1], 2541.00f);
        }
Пример #2
0
 public WriteTextComponent(ResolvedField field) : base(field)
 {
     Elements = new AbstractElement[] {
         new TextElement
         {
             Element = new Reference
             {
                 Codename = "field_details__name"
             },
             Value = field.Name
         },
         new TextElement
         {
             Element = new Reference
             {
                 Codename = "field_details__comment"
             },
             Value = field.Comment
         },
         new RichTextElement
         {
             Element = new Reference
             {
                 Codename = "default_text"
             },
             Value = field.DefaultText
         }
     };
 }
Пример #3
0
        public override bool Matches(AbstractElement element)
        {
            var parent = element.Parent;

            if (parent == null)
            {
                return(false);
            }

            var children = parent.ChildElements().ToList();
            // The position refers to an one based index
            // position = index + 1
            var position = children.IndexOf(element) + 1;

            if (position < Offset || position < 1)
            {
                return(false);
            }

            if (Step == 0)
            {
                return(position == Offset);
            }
            else
            {
                return((position - Offset) % Step == 0);
            }
        }
Пример #4
0
 /// <summary>
 ///     Replaces a current instance of the DICOM element in the DICOM object. If the object does not exist, this method
 ///     will add it to the object.
 /// </summary>
 /// <typeparam name="T">the type of the data the element holds (eg. double[], int, DataTime, etc)</typeparam>
 /// <param name="element">the instance of the element</param>
 public void ReplaceOrAdd <T>(AbstractElement <T> element)
 {
     if (!Replace(element))
     {
         Add(element);
     }
 }
Пример #5
0
        public MainWindow()
        {
            InitializeComponent();

            DependencyObjectTest c = new DependencyObjectTest();

            c.Dy.Age = "20";
            ((ObservableCollection <int>)c.Dy.Address).Add(1);
            ((ObservableCollection <int>)c.Dy.Address).Add(2);
            ((ObservableCollection <int>)c.Dy.Address).Remove(1);

            AsyncAwait.DoTaskWithAsync(delegate(string e)
            {
                Console.WriteLine(e);
            });

            for (int i = 0; i < 10; i++)
            {
                AbstractElement element = ElementFactory.GetInstance()["SignalMachine" + i % 2] as AbstractElement;
                element.Location = new Point(i * 100, 100);

                cc.AddChildElement(element);
            }

            AbstractElement element1 = ElementFactory.GetInstance()["CurveElement1"] as AbstractElement;

            element1.Location = new Point(10, 500);
            cc.AddChildElement(element1);
        }
Пример #6
0
            public override ErrorList Validate()
            {
                var result = new ErrorList();

                result.AddRange(base.Validate());

                if (CodeElement != null)
                {
                    result.AddRange(CodeElement.Validate());
                }
                if (AbstractElement != null)
                {
                    result.AddRange(AbstractElement.Validate());
                }
                if (DisplayElement != null)
                {
                    result.AddRange(DisplayElement.Validate());
                }
                if (DefinitionElement != null)
                {
                    result.AddRange(DefinitionElement.Validate());
                }
                if (Concept != null)
                {
                    Concept.ForEach(elem => result.AddRange(elem.Validate()));
                }

                return(result);
            }
Пример #7
0
    public static object GetPropertiesOfChain(AbstractElement beginning, string meta, DoSomethingWithList func = null)
    {
        if (func == null)
        {
            func = objectsList => (from element in objectsList select(double) (element)).ToList().Sum();
        }
        switch (meta)
        {
        case "resistance":
        {
            var objects = new List <object>();
            for (var i = beginning; i != null; i = i.NextElement)
            {
                objects.Add(i.Properties.Resistance);
            }
            return(func(objects));
        }

        case "current":
        {
            var objects = new List <object>();
            for (var i = beginning; i != null; i = i.NextElement)
            {
                objects.Add(i.Properties.Current);
            }
            return(func(objects));
        }

        default:
            return(null);
        }
    }
Пример #8
0
 // compute and solve system matrix in profile format with status vector *****************************************************
 private void SetProfile()
 {
     foreach (var item in modell.Elemente)
     {
         element = item.Value;
         systemEquations.SetProfile(element.SystemIndicesOfElement);
     }
     systemEquations.AllocateMatrix();
     profile = true;
 }
Пример #9
0
        /// <summary>
        /// Replaces a current instance of the DICOM element in the DICOM object. If the object does not exist, this method
        /// exits. For this scenario, please use ReplaceOrAdd().
        /// </summary>
        /// <typeparam name="T">the type of the data the element holds (eg. double[], int, DataTime, etc)</typeparam>
        /// <param name="element">the instance of the element</param>
        /// <returns>bool indicating whether or not the element was replaced</returns>
        private bool Replace <T>(AbstractElement <T> element)
        {
            var toReplace = FindFirst(element.Tag) as AbstractElement <T>;

            if (toReplace == null)
            {
                return(false);
            }
            toReplace.DataContainer = element.DataContainer;
            return(true);
        }
Пример #10
0
 public static void DoWithChain(AbstractElement beginning, DoSomethingWithElement func, CheckFunction isNotTheEnd = null)
 {
     if (isNotTheEnd == null)
     {
         isNotTheEnd = x => x != null;
     }
     for (var i = beginning; isNotTheEnd(i); i = i.NextElement)
     {
         func(i);
     }
 }
Пример #11
0
 private void ReComputeSystemMatrix()
 {
     // traverse the elements to assemble the stiffness coefficients
     systemEquations.InitializeMatrix();
     foreach (var item in modell.Elemente)
     {
         element = item.Value;
         var indices       = element.SystemIndicesOfElement;
         var elementMatrix = element.ComputeMatrix();
         systemEquations.AddMatrix(indices, elementMatrix);
     }
 }
Пример #12
0
        public override bool Matches(AbstractElement element)
        {
            var parent = element.Parent;

            if (parent is null)
            {
                return(false);
            }

            var parentNodes = parent.ChildElements();

            return(parentNodes.LastOrDefault() == element);
        }
Пример #13
0
    public ElementController GetControllerByElement(AbstractElement element)
    {
        var r =
            (from element2 in realElements where element2.ElementName == element.Name select element2).ToList()
            .FirstOrDefault();

        if (r != null)
        {
            return(r);
        }
        Debug.LogError("No such object");
        return(null);
    }
        /// <summary>
        /// Visits the specified element.
        /// </summary>
        /// <param name="abstractElement">The abstract element.</param>
        public void Visit(AbstractElement abstractElement)
        {
            ConcreteEmployee concreteEmployee = abstractElement as ConcreteEmployee;

            if (concreteEmployee != null)
            {
                concreteEmployee.Income *= 1.10;

                /*Console.WriteLine("{0} {1}'s new income: {2:C}",
                 *  concreteEmployee.GetType().Name,
                 *  concreteEmployee.Name,
                 *  concreteEmployee.Income);*/
            }
        }
Пример #15
0
        public static LineNode GetDefaultGlue(AbstractElement element)
        {
            var font       = element.Font ?? throw new ArgumentException("Specified element missing font");
            var size       = element.FontSize;
            var spaceWidth = GetWidth(" ");
            var stretch    = Math.Max(0, spaceWidth / 2);
            var shrink     = Math.Max(0, spaceWidth / 3);

            return(LineNode.Glue(spaceWidth, stretch, shrink));

            double GetWidth(string value)
            {
                return(font.GetWidth(value, size, element.FontWeight));
            }
        }
Пример #16
0
        public bool Matches(AbstractElement element)
        {
            if (Operator == StyleOperator.Or)
            {
                return(Left.Matches(element) || Right.Matches(element));
            }

            var parent = element.Parent;

            if (parent is null || !Right.Matches(element))
            {
                return(false);
            }

            if (Operator == StyleOperator.Child)
            {
                return(Left.Matches(parent));
            }
            else if (Operator == StyleOperator.Descendant)
            {
                while (parent != null)
                {
                    if (Left.Matches(parent))
                    {
                        return(true);
                    }
                    parent = parent.Parent;
                }
                return(false);
            }

            var children = parent.ChildElements().ToList();
            var index    = children.IndexOf(element);

            if (Operator == StyleOperator.Previous && index > 0)
            {
                return(Left.Matches(children[index - 1]));
            }
            else if (Operator == StyleOperator.Next && index < children.Count - 1)
            {
                return(Left.Matches(children[index + 1]));
            }
            else
            {
                return(false);
            }
        }
Пример #17
0
        public StyleContainer Compute(AbstractElement element)
        {
            BitArray array;

            lock (computedStyles)
            {
                if (selectorCount < 0)
                {
                    selectorCount = styles.Count();
                }

                array = new BitArray(selectorCount);
            }

            int index = 0;

            foreach (var container in styles)
            {
                array.Set(index++, container.Selector.Matches(element));
            }

            if (computedStyles.TryGetValue(array, out var computedContainer))
            {
                return(computedContainer);
            }
            else
            {
                var container = new StyleContainer(AllStyleSelector.Singleton);

                foreach (var styleContainer in styles)
                {
                    if (styleContainer.Selector.Matches(element))
                    {
                        foreach (var(key, value) in styleContainer)
                        {
                            container.Set(key, value);
                        }
                    }
                }

                computedStyles[array] = container;
                return(container);
            }
        }
Пример #18
0
        /// <summary>
        ///     Replaces a current instance of the DICOM element in the DICOM object. If the object does not exist, this method
        ///     exits. For this scenario, please use ReplaceOrAdd().
        /// </summary>
        /// <typeparam name="T">the type of the data the element holds (eg. double[], int, DataTime, etc)</typeparam>
        /// <param name="element">the instance of the element</param>
        /// <returns>bool indicating whether or not the element was replaced</returns>
        private bool Replace <T>(AbstractElement <T> element)
        {
            if (element.Tag == null)
            {
                return(false);
            }
            var toReplace = FindFirst(element.Tag) as AbstractElement <T>;

            if (toReplace == null)
            {
                return(false);
            }
            toReplace.DataContainer = element.DataContainer;
            if (element is RangeableDateTime)
            {
                (toReplace as RangeableDateTime).IsRange = (element as RangeableDateTime).IsRange;
            }
            return(true);
        }
Пример #19
0
 public void ComputeSystemMatrix()
 {
     if (!setDimension)
     {
         DetermineDimension();
     }
     if (!profile)
     {
         SetProfile();
     }
     // traverse the elements to assemble the stiffness coefficients
     foreach (var item in modell.Elemente)
     {
         element = item.Value;
         var elementMatrix = element.ComputeMatrix();
         systemEquations.AddMatrix(element.SystemIndicesOfElement, elementMatrix);
     }
     SetStatusVector();
 }
Пример #20
0
    public void CreatePairForElement(AbstractElement element)
    {
        var type = element.GetType().ToString();

        Debug.LogFormat("Type is {0}", type);
        var pairElement =
            ResourcesManager.Instance.entries.FirstOrDefault(
                x => String.Equals(x.name, type, StringComparison.CurrentCultureIgnoreCase));

        if (pairElement == null)
        {
            return;
        }

        var gameTemp           = Instantiate(pairElement.prefab);
        var gameTempController = gameTemp.GetComponentInChildren <ElementController>();

        gameTemp.transform.position    = new Vector3(HelperClass.myRandom.Next(-1, 1), HelperClass.myRandom.Next(-1, 1), 4);
        gameTempController.ElementName = element.Name;
    }
Пример #21
0
 public UploadFileComponent(ResolvedField field) : base(field)
 {
     Elements = new AbstractElement[] {
         new TextElement
         {
             Element = new Reference
             {
                 Codename = "field_details__name"
             },
             Value = field.Name
         },
         new TextElement
         {
             Element = new Reference
             {
                 Codename = "field_details__comment"
             },
             Value = field.Comment
         }
     };
 }
Пример #22
0
        public override bool Matches(AbstractElement element)
        {
            var parent = element.Parent;

            if (parent is null)
            {
                return(false);
            }

            var parentNodes = parent.ChildElements();

            using var en = parentNodes.GetEnumerator();
            AbstractElement?result = null;

            if (en.MoveNext())
            {
                result = en.Current;
            }
            if (en.MoveNext())
            {
                result = null;
            }
            return(result == element);
        }
Пример #23
0
 public bool Replace(AbstractElement <short> element)
 {
     return(Replace <short>(element));
 }
Пример #24
0
 public bool Replace(AbstractElement <Tag> element)
 {
     return(Replace <Tag>(element));
 }
Пример #25
0
 public bool Replace(AbstractElement <DICOMObject> element)
 {
     return(Replace <DICOMObject>(element));
 }
Пример #26
0
 public bool Replace(AbstractElement <float> element)
 {
     return(Replace <float>(element));
 }
Пример #27
0
 public void ReplaceOrAdd(AbstractElement <DateTime?> element)
 {
     ReplaceOrAdd <DateTime?>(element);
 }
Пример #28
0
 public void ReplaceOrAdd(AbstractElement <byte> element)
 {
     ReplaceOrAdd <byte>(element);
 }
    public void CreatePairForElement(AbstractElement element)
    {
        var type = element.GetType().ToString();
        Debug.LogFormat("Type is {0}", type);
        var pairElement =
            ResourcesManager.Instance.entries.FirstOrDefault(
                x => String.Equals(x.name, type, StringComparison.CurrentCultureIgnoreCase));
        if (pairElement == null) return;

        var gameTemp = Instantiate(pairElement.prefab);
        var gameTempController = gameTemp.GetComponentInChildren<ElementController>();
        gameTemp.transform.position = new Vector3(HelperClass.myRandom.Next(-1, 1), HelperClass.myRandom.Next(-1, 1), 4);
        gameTempController.ElementName = element.Name;
    }
 public ElementController GetControllerByElement(AbstractElement element)
 {
     var r =
         (from element2 in realElements where element2.ElementName == element.Name select element2).ToList()
             .FirstOrDefault();
     if (r != null) return r;
     Debug.LogError("No such object");
     return null;
 }
 public void SetMeasuredSubcircuit(AbstractElement abstractElement)
 {
     measuredSubcircuit = abstractElement;
 }
Пример #32
0
 public bool Replace(AbstractElement <byte> element)
 {
     return(Replace <byte>(element));
 }
Пример #33
0
 public bool Replace(AbstractElement <DateTime?> element)
 {
     return(Replace <DateTime?>(element));
 }
Пример #34
0
 public void endElement()
 {
     IConstructor constructor = m_registeredElements[m_activeElementType];
     m_activeElement = constructor.getInstance(m_activeSequence.getStream());
     m_activeElement.addInterface(m_activeElementType);
     m_activeElement.setOwner(m_activeGameObject);
     m_activeGameObject.addElement(m_activeElement);
     m_activeElement = null;
 }