예제 #1
0
        public static BoolElement Cast(Element element)
        {
            global::System.IntPtr cPtr = SharingClientPINVOKE.BoolElement_Cast(Element.getCPtr(element));
            BoolElement           ret  = (cPtr == global::System.IntPtr.Zero) ? null : new BoolElement(cPtr, true);

            return(ret);
        }
예제 #2
0
        public virtual BoolElement CreateBoolElement(XString name, bool value)
        {
            System.IntPtr cPtr = SharingClientPINVOKE.ObjectElement_CreateBoolElement(swigCPtr, XString.getCPtr(name), value);
            BoolElement   ret  = (cPtr == System.IntPtr.Zero) ? null : new BoolElement(cPtr, true);

            return(ret);
        }
        public void TestUpacConfiguration()
        {
            SettingsSection settings = Upac.Configuration.ConfigurationManager.Settings;

            Assert.IsNotNull(settings);

            BoolElement element = settings.SetWidthOnRichTextEditorViaTemplateAlias;

            Assert.IsNotNull(element);

            Assert.IsTrue(element.Value);

            settings = Upac.Configuration.ConfigurationManager.Settings;
        }
예제 #4
0
 public override void AddFromRemote(Element remoteElement)
 {
     NetworkElement = remoteElement;
     element        = BoolElement.Cast(remoteElement);
     value          = element.GetValue();
 }
예제 #5
0
 public override void InitializeLocal(ObjectElement parentElement)
 {
     element        = parentElement.CreateBoolElement(XStringFieldName, value);
     NetworkElement = element;
 }
예제 #6
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BoolElement obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
예제 #7
0
 public override void AddFromRemote(Element element)
 {
     this.NetworkElement = element;
     this.element        = BoolElement.Cast(element);
     this.value          = this.element.GetValue();
 }
            public VisitDetailsView(VisitDetailsViewController parent)
            {
                Parent          = parent;
                BackgroundColor = UIColor.FromRGB(239, 239, 244);

                addVisitor = new UIButton
                {
                    Frame     = new RectangleF(0, 0, 150, 150),
                    TintColor = UIColor.White,
                    Layer     =
                    {
                        CornerRadius  =   75,
                        MasksToBounds = true,
                    }
                };
                addVisitor.SetTitle("Add a visitor", UIControlState.Normal);
                addVisitor.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill;;
                addVisitor.SetImage(Theme.UserImageDefaultLight.Value, UIControlState.Normal);
                addVisitor.TouchUpInside += (sender, args) => { if (Parent.PickVisitor != null)
                                                                {
                                                                    Parent.PickVisitor();
                                                                }
                };
                AddSubview(addVisitor);

                addEmployee = new UIButton
                {
                    Frame     = new RectangleF(0, 0, 150, 150),
                    TintColor = UIColor.White,
                    Layer     =
                    {
                        CornerRadius  =   75,
                        MasksToBounds = true,
                    }
                };
                addEmployee.SetTitle("Add an employee", UIControlState.Normal);
                addEmployee.ImageView.ContentMode = UIViewContentMode.ScaleAspectFill;;
                addEmployee.SetImage(Theme.UserImageDefaultLight.Value, UIControlState.Normal);
                addEmployee.TouchUpInside += (sender, args) => { if (Parent.PickEmployee != null)
                                                                 {
                                                                     Parent.PickEmployee();
                                                                 }
                };
                AddSubview(addEmployee);

                editButton = new UIButton(new RectangleF(0, 0, 40, 40));
                editButton.SetBackgroundImage(UIImage.FromBundle("edit"), UIControlState.Normal);
                editButton.TouchUpInside += (sender, args) =>
                {
                    var vc = new EditVisitorViewController
                    {
                        Visitor = new VMVisitor {
                            Visitor = visit.Visitor
                        }
                    };
                    this.Parent.NavigationController.PushViewController(vc, true);
                };

                visitorLabel = new UILabel {
                    Text = "Visitor", Font = UIFont.FromName(font2, 30), TextAlignment = UITextAlignment.Center, AdjustsFontSizeToFitWidth = true,
                };

                visitorLabel.SizeToFit();
                AddSubview(visitorLabel);

                employeeLabel = new UILabel {
                    Text = "Employee", Font = UIFont.FromName(font2, 30), TextAlignment = UITextAlignment.Center, AdjustsFontSizeToFitWidth = true,
                };
                employeeLabel.SizeToFit();
                AddSubview(employeeLabel);

                date             = new DateTimeElement("Date", DateTime.Now);
                comment          = new EntryElement("Reason: ", "Reason", "");
                comment.Changed += (sender, args) =>
                {
                    Console.WriteLine("Comment");
                };
                vehicle               = new BooleanElement("Vehicle", false);
                licensePlate          = new EntryElement("Lic Plate: ", "License Plate", "");
                licensePlate.Changed += (sender, args) =>
                {
                    Console.WriteLine("licensePlate");
                };
                vehicle.ValueChanged += (sender, args) =>
                {
                    if (vehicle.Value)
                    {
                        if (!section.Elements.Contains(licensePlate))
                        {
                            section.Add(licensePlate);
                        }
                        datadvc.ReloadData();
                    }
                    else
                    {
                        licensePlate.FetchValue();
                        section.Remove(licensePlate);
                    }
                };


                datadvc = new DialogViewController(new RootElement("visit")
                {
                    (section = new Section
                    {
                        date,
                        comment,
                        vehicle,
                        licensePlate
                    })
                });
                datadvc.TableView.SectionHeaderHeight = 0;
                datadvc.TableView.TableHeaderView     = null;
                datadvc.View.BackgroundColor          = UIColor.White;
                datadvc.View.Layer.CornerRadius       = 5f;
                var height = Enumerable.Range(0, datadvc.TableView.Source.RowsInSection(datadvc.TableView, 0)).Sum(x => datadvc.TableView.Source.GetHeightForRow(datadvc.TableView, NSIndexPath.FromRowSection(x, 0)));

                datadvc.View.Frame = new RectangleF(0, 0, 100, height);
                AddSubview(datadvc.View);
                this.Parent.AddChildViewController(datadvc);
            }
예제 #9
0
        private Element ConvertXElementToElement(XElement element)
        {
            var elementValues = new List <string>();

            if (!element.Elements().Any())
            {
                var tElem = _oldRoot.Descendants(element.Name).Where(x => GetParentsAsString(x, -1) == GetParentsAsString(element, -1) && !x.Elements().Any()).Select(e => e.Value);
                elementValues.AddRange(tElem);
            }

            var xElementList = _oldRoot.Descendants(element.Name).GroupBy(el => el.Parent).Select(g => new { g.Key, Count = g.Count() }).Where(x => x.Count > 1);

            Element returnElement;
            var     elementName = element.Name.LocalName;
            var     elementType = DataType.GetDataTypeFromList(elementValues, _dateFormat, _dateTimeFormat);

            switch (elementType.type)
            {
            case DataType.Type.Date:
                returnElement = new DateTimeElement(elementName, _dateFormat);
                break;

            case DataType.Type.DateTime:
                returnElement = new DateTimeElement(elementName, _dateTimeFormat);
                break;

            case DataType.Type.Bool:
                returnElement = new BoolElement(elementName, "True", "False");
                break;

            case DataType.Type.@bool:
                returnElement = new BoolElement(elementName, "true", "false");
                break;

            case DataType.Type.@int:
                returnElement = new IntElement(elementName);
                break;

            case DataType.Type.@decimal:
                returnElement = new DecimalElement(elementName);
                break;

            case DataType.Type.@string:
                returnElement = new StringElement(elementName);
                break;

            default:
                returnElement = new Element(elementName);
                break;
            }
            returnElement.Enumerable      = xElementList.Any();
            returnElement.Type            = elementType;
            returnElement.OriginalElement = element;

            foreach (var xElement in element.Elements())
            {
                returnElement.Elements.Add(ConvertXElementToElement(xElement));
            }

            foreach (var xAttribute in element.Attributes())
            {
                var tElements = _oldRoot.DescendantsAndSelf(element.Name).Where(x => GetParentsAsString(x, -1) == GetParentsAsString(element, -1)).ToList();

                var xAttr           = xAttribute;
                var attributeValues = tElements.Select(tElement => tElement.Attribute(xAttr.Name)).Select(attribute => attribute != null ? attribute.Value : "").ToList();

                Attribute thisAttribute;
                var       attributeName = xAttribute.Name.LocalName;

                if (xAttribute.IsNamespaceDeclaration)
                {
                    returnElement.NamespaceAttributes.Add(xAttribute);
                    continue;
                }

                if (attributeName == "schemaLocation")
                {
                    thisAttribute = new SchemaLocationAttribute(attributeName, xAttribute.Value);
                    returnElement.Attributes.Add(thisAttribute);
                    continue;
                }

                var attributeType = DataType.GetDataTypeFromList(attributeValues, _dateFormat, _dateTimeFormat);
                switch (attributeType.type)
                {
                case DataType.Type.Date:
                    thisAttribute = new DateTimeAttribute(attributeName, _dateFormat);
                    break;

                case DataType.Type.DateTime:
                    thisAttribute = new DateTimeAttribute(attributeName, _dateTimeFormat);
                    break;

                case DataType.Type.Bool:
                    thisAttribute = new BoolAttribute(attributeName, "True", "False");
                    break;

                case DataType.Type.@bool:
                    thisAttribute = new BoolAttribute(attributeName, "true", "false");
                    break;

                case DataType.Type.@int:
                    thisAttribute = new IntAttribute(attributeName);
                    break;

                case DataType.Type.@decimal:
                    thisAttribute = new DecimalAttribute(attributeName);
                    break;

                case DataType.Type.@string:
                    thisAttribute = new StringAttribute(attributeName);
                    break;

                default:
                    thisAttribute = new Attribute(attributeName);
                    break;
                }
                thisAttribute.Type = attributeType;

                returnElement.Attributes.Add(thisAttribute);
            }

            return(returnElement);
        }
예제 #10
0
        private void ConsolidateElements(Element newElement, Element currentElement)
        {
            // compare current element elements with new element elements and add unique missing to new element
            foreach (var cElement in currentElement.Elements)
            {
                var tempElement = newElement.Elements.FirstOrDefault(e => e.Name == cElement.Name);

                if (tempElement == null)                 // element missing, add it
                {
                    var elementName = cElement.Name;
                    switch (cElement.Type.type)
                    {
                    case DataType.Type.Date:
                        tempElement = new DateTimeElement(elementName, _dateFormat);
                        break;

                    case DataType.Type.DateTime:
                        tempElement = new DateTimeElement(elementName, _dateTimeFormat);
                        break;

                    case DataType.Type.Bool:
                        tempElement = new BoolElement(elementName, "True", "False");
                        break;

                    case DataType.Type.@bool:
                        tempElement = new BoolElement(elementName, "true", "false");
                        break;

                    case DataType.Type.@int:
                        tempElement = new IntElement(elementName);
                        break;

                    case DataType.Type.@decimal:
                        tempElement = new DecimalElement(elementName);
                        break;

                    case DataType.Type.@string:
                        tempElement = new StringElement(elementName);
                        break;

                    default:
                        tempElement = new Element(elementName);
                        break;
                    }

                    tempElement.Enumerable          = cElement.Enumerable;
                    tempElement.Type                = cElement.Type;
                    tempElement.OriginalElement     = cElement.OriginalElement;
                    tempElement.NamespaceAttributes = cElement.NamespaceAttributes;

                    newElement.Elements.Add(tempElement);
                }

                foreach (var attribute in cElement.Attributes)
                {
                    // Check Attribute Exists
                    if (tempElement.Attributes.Any(a => a.Name == attribute.Name))
                    {
                        continue;
                    }

                    var sameAttributes = cElement.Attributes.Where(a => a.Name == attribute.Name).ToList();
                    var dataType       = sameAttributes.Aggregate <Attribute, DataType>(null, (current, sameAttribute) => current == null ? sameAttribute.Type : DataType.GetBestType(current, sameAttribute.Type));
                    attribute.Type = dataType;
                    tempElement.Attributes.Add(attribute);
                }

                ConsolidateElements(tempElement, cElement);
            }
        }
예제 #11
0
        private bool GenerateBool(BoolElement boolElement)
        {
            var randomInt = _random.Next(0, 2);

            return(randomInt == 0);
        }
예제 #12
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BoolElement obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }