private IdentityPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity Identity, bool Personal) { this.xmppConfiguration = XmppConfiguration; this.owner = Owner; this.identity = Identity; this.personal = Personal; this.BindingContext = this; InitializeComponent(); byte[] Png = QR.GenerateCodePng("iotid:" + Identity.Id, (int)this.QrCode.WidthRequest, (int)this.QrCode.HeightRequest); this.QrCode.Source = ImageSource.FromStream(() => new MemoryStream(Png)); this.QrCode.IsVisible = true; this.CompromizedButton.IsVisible = Personal; this.RevokeButton.IsVisible = Personal; if (!Personal) { this.IdentitySection.Remove(this.NetworkView); this.ButtonSection.Remove(this.CompromizedButtonView); this.ButtonSection.Remove(this.RevokeButtonView); } this.LoadPhotos(); }
private IdentityPage(XmppConfiguration XmppConfiguration, Page Owner, LegalIdentity Identity, bool Personal, SignaturePetitionEventArgs Review) { this.xmppConfiguration = XmppConfiguration; this.owner = Owner; this.identity = Identity; this.personal = Personal; this.review = Review; this.BindingContext = this; InitializeComponent(); byte[] Png = QR.GenerateCodePng("iotid:" + Identity.Id, (int)this.QrCode.WidthRequest, (int)this.QrCode.HeightRequest); this.QrCode.Source = ImageSource.FromStream(() => new MemoryStream(Png)); this.QrCode.IsVisible = true; if (!Personal) { this.IdentitySection.Remove(this.NetworkView); this.ButtonSection.Remove(this.CompromizedCell); this.ButtonSection.Remove(this.RevokeCell); } if (this.review is null) { this.ButtonSection.Remove(this.CarefulReviewCell); this.ButtonSection.Remove(this.ApprovePiiCell); this.ButtonSection.Remove(this.PinCell); this.ButtonSection.Remove(this.ApproveReviewCell); this.ButtonSection.Remove(this.RejectReviewCell); } this.LoadPhotos(); }
public ViewContractPage(XmppConfiguration XmppConfiguration, Page Owner, Contract Contract, bool ReadOnly) { this.xmppConfiguration = XmppConfiguration; this.owner = Owner; this.contract = Contract; this.BindingContext = this; InitializeComponent(); // General Information AddTag(this.GeneralInformation, "Created", Contract.Created.ToString()); if (Contract.Updated != DateTime.MinValue) { AddTag(this.GeneralInformation, "Updated", Contract.Updated.ToString()); } AddTag(this.GeneralInformation, "State", Contract.State.ToString()); AddTag(this.GeneralInformation, "Visibility", Contract.Visibility.ToString()); AddTag(this.GeneralInformation, "Duration", Contract.Duration.ToString()); AddTag(this.GeneralInformation, "From", Contract.From.ToString()); AddTag(this.GeneralInformation, "To", Contract.To.ToString()); AddTag(this.GeneralInformation, "Archiving (optional)", Contract.ArchiveOptional.ToString()); AddTag(this.GeneralInformation, "Archiving (required)", Contract.ArchiveRequired.ToString()); AddTag(this.GeneralInformation, "Can act as template", Contract.CanActAsTemplate.ToString()); // QR Code byte[] Png = QR.GenerateCodePng("iotsc:" + Contract.ContractId, (int)this.QrCode.WidthRequest, (int)this.QrCode.HeightRequest); this.QrCode.Source = ImageSource.FromStream(() => new MemoryStream(Png)); this.QrCode.IsVisible = true; // Parts bool HasSigned = false; bool AcceptsSignatures = (Contract.State == ContractState.Approved || Contract.State == ContractState.BeingSigned) && (!Contract.SignAfter.HasValue || Contract.SignAfter.Value < DateTime.Now) && (!Contract.SignBefore.HasValue || Contract.SignBefore.Value > DateTime.Now); Dictionary <string, int> NrSignatures = new Dictionary <string, int>(); if (!(Contract.ClientSignatures is null)) { foreach (ClientSignature Signature in Contract.ClientSignatures) { if (Signature.LegalId == this.xmppConfiguration.LegalIdentity.Id) { HasSigned = true; } if (!NrSignatures.TryGetValue(Signature.Role, out int Count)) { Count = 0; } NrSignatures[Signature.Role] = Count + 1; } } if (Contract.SignAfter.HasValue) { AddTag(this.Parts, "Sign after", Contract.SignAfter.Value.ToString()); } if (Contract.SignBefore.HasValue) { AddTag(this.Parts, "Sign before", Contract.SignBefore.Value.ToString()); } AddTag(this.Parts, "Mode", Contract.PartsMode.ToString()); if (!(Contract.Parts is null)) { TapGestureRecognizer OpenLegalId = new TapGestureRecognizer(); OpenLegalId.Tapped += this.ShowLegalId; foreach (Part Part in Contract.Parts) { AddTag(this.Parts, Part.Role, Part.LegalId, false, Part.LegalId, OpenLegalId); if (!ReadOnly && AcceptsSignatures && !HasSigned && Part.LegalId == this.xmppConfiguration.LegalIdentity.Id) { Button Button; this.Parts.Add(new ViewCell() { View = Button = new Button() { Text = "Sign as " + Part.Role, StyleId = Part.Role } }); Button.Clicked += SignButton_Clicked; } } } // Roles if (!(Contract.Roles is null)) { foreach (Role Role in Contract.Roles) { string Html = Role.ToHTML(Contract.DefaultLanguage, Contract); Html = Waher.Content.Html.HtmlDocument.GetBody(Html); AddTag(this.Roles, Role.Name, Html + CountString(Role.MinCount, Role.MaxCount), true, string.Empty, null); if (!ReadOnly && AcceptsSignatures && !HasSigned && this.contract.PartsMode == ContractParts.Open && (!NrSignatures.TryGetValue(Role.Name, out int Count) || Count < Role.MaxCount)) { Button Button; this.Roles.Add(new ViewCell() { View = Button = new Button() { Text = "Sign as " + Role.Name, StyleId = Role.Name } }); Button.Clicked += SignButton_Clicked; } } } // Parameters if (!(Contract.Parameters is null)) { foreach (Parameter Parameter in Contract.Parameters) { AddTag(this.Parameters, Parameter.Name, Parameter.ObjectValue?.ToString()); } } // Human-readable text string Xaml = Contract.ToXamarinForms(Contract.DefaultLanguage); StackLayout HumanReadable = new StackLayout().LoadFromXaml(Xaml); List <View> Children = new List <View>(); Children.AddRange(HumanReadable.Children); foreach (View Element in Children) { this.HumanReadableText.Children.Add(Element); } // Machine-readable information AddTag(this.MachineReadableSection, "Contract ID", Contract.ContractId.ToString()); if (!string.IsNullOrEmpty(Contract.TemplateId)) { AddTag(this.MachineReadableSection, "Template ID", Contract.TemplateId); } AddTag(this.MachineReadableSection, "Digest", Convert.ToBase64String(Contract.ContentSchemaDigest)); AddTag(this.MachineReadableSection, "Hash Function", Contract.ContentSchemaHashFunction.ToString()); AddTag(this.MachineReadableSection, "Local Name", Contract.ForMachinesLocalName.ToString()); AddTag(this.MachineReadableSection, "Namespace", Contract.ForMachinesNamespace.ToString()); // Client signatures if (!(Contract.ClientSignatures is null)) { TapGestureRecognizer OpenClientSignature = new TapGestureRecognizer(); OpenClientSignature.Tapped += this.ShowClientSignature; foreach (ClientSignature Signature in Contract.ClientSignatures) { string Sign = Convert.ToBase64String(Signature.DigitalSignature); AddTag(this.ClientSignatures, Signature.Role, Signature.LegalId + ", " + Signature.BareJid + ", " + Signature.Timestamp.ToString() + ", " + Sign, false, Sign, OpenClientSignature); } } // Server signature if (!(Contract.ServerSignature is null)) { TapGestureRecognizer OpenServerSignature = new TapGestureRecognizer(); OpenServerSignature.Tapped += this.ShowServerSignature; AddTag(this.ServerSignature, Contract.Provider, Contract.ServerSignature.Timestamp.ToString() + ", " + Convert.ToBase64String(Contract.ServerSignature.DigitalSignature), false, Contract.ContractId, OpenServerSignature); } // Buttons if (!ReadOnly && !Contract.IsLegallyBinding(true)) { Button Button; this.ButtonSection.Insert(0, new ViewCell() { View = Button = new Button() { Text = "Obsolete Contract" } }); Button.Clicked += ObsoleteButton_Clicked; this.ButtonSection.Insert(1, new ViewCell() { View = Button = new Button() { Text = "Delete Contract" } }); Button.Clicked += DeleteButton_Clicked; } this.LoadPhotos(); }