Esempio n. 1
0
        public static void SetDock(object target, object value)
        {
            ILayoutElement AsElement = (ILayoutElement)target;
            Dock           Dock;

            if (value is string AsString)
            {
                if (AsString.ToLower() == "left")
                {
                    Dock = Dock.Left;
                }
                else if (AsString.ToLower() == "top")
                {
                    Dock = Dock.Top;
                }
                else if (AsString.ToLower() == "right")
                {
                    Dock = Dock.Right;
                }
                else if (AsString.ToLower() == "bottom")
                {
                    Dock = Dock.Bottom;
                }
                else
                {
                    throw new ParsingException(158, AsElement.Source, $"Unknown dock value '{AsString}'.");
                }
            }
            else
            {
                throw new ParsingException(159, AsElement.Source, "Missing or invalid dock value.");
            }

            if (DockTargets.ContainsKey(AsElement))
            {
                throw new ParsingException(160, AsElement.Source, "Dock value already specified for this element.");
            }
            else
            {
                DockTargets.Add(AsElement, Dock);
            }
        }