public SelectedViewModel(Xamarin.Forms.Page _element, Action Recalc, Action RecalcPaidPrice, Xamarin.Forms.StackLayout spSelectedList, Xamarin.Forms.ControlTemplate ctSelectedControlTemplate, Xamarin.Forms.StackLayout spRequestList, Xamarin.Forms.ControlTemplate ctRequestControlTemplate, Xamarin.Forms.StackLayout spBalanceList, Xamarin.Forms.ControlTemplate ctBalanceControlTemplate) { this._element = _element; this._spSelectedList = spSelectedList; this._ctSelectedControlTemplate = ctSelectedControlTemplate; // 列表变化时重置一下编号 CurrentSelectedList.CollectionChanged += (sender, args) => { ResetNo(); }; RequestView = new RequestViewModel(null, this, spRequestList, ctRequestControlTemplate); ChangeCountView = new ChangeCountViewModel(null, this, Recalc); ChangePriceView = new ChangePriceViewModel(null, this, Recalc); ChangePaidPriceView = new ChangePaidPriceViewModel(null, RecalcPaidPrice, spBalanceList, ctBalanceControlTemplate); ChangeTimeView = new ChangeTimeViewModel(null, this, Recalc); foreach (var item in Res.Instance.AllLangList.OrderBy(x => x.Value.LangOrder)) { Dict dict = new Dict() { Name = Res.Instance.GetString("LangName", item.Value.Culture), Value = item.Value.LangIndex }; AllLang.Add(dict); } }
internal RequestViewModel(Xamarin.Forms.View element, SelectedViewModel SelectedViewModel, Xamarin.Forms.StackLayout spList, Xamarin.Forms.ControlTemplate ctControlTemplate) { this._element = element; this.SelectedViewModel = SelectedViewModel; this._spList = spList; this._ctControlTemplate = ctControlTemplate; }
private static void AddMessageView(DateTime Timestamp, DataType Type, Byte[] Data, bool IsMyMessage) { Xamarin.Forms.Device.BeginInvokeOnMainThread(delegate { var MessageLocalTime = Timestamp.ToLocalTime(); var PaddingLeft = 5; var PaddingRight = 5; Xamarin.Forms.Color Background; if (IsMyMessage) { PaddingLeft = 20; Background = Settings.Graphics.BackgroundMyMessage; } else { Background = Settings.Graphics.BackgroundMessage; PaddingRight = 20; } var Frame = new Xamarin.Forms.Frame() { CornerRadius = 10, BackgroundColor = Background, Padding = 0 }; var Box = new Xamarin.Forms.StackLayout() { Padding = new Xamarin.Forms.Thickness(PaddingLeft, 5, PaddingRight, 5) }; Frame.Content = Box; Container.Children.Insert(0, Frame); var TimeLabel = new Xamarin.Forms.Label(); TimeSpan Difference = DateTime.Now - MessageLocalTime; if (Difference.TotalDays < 1) { TimeLabel.Text = MessageLocalTime.ToLongTimeString(); } else { TimeLabel.Text = MessageLocalTime.ToLongDateString() + " - " + MessageLocalTime.ToLongTimeString(); } TimeLabel.FontSize = 8; Box.Children.Add(TimeLabel); switch (Type) { case DataType.Text: var Label = new Xamarin.Forms.Label(); Label.Text = Encoding.Unicode.GetString(Data); Box.Children.Add(Label); break; case DataType.Image: break; case DataType.Audio: break; default: break; } }); }
/// <summary> /// 重新加载页 /// </summary> /// <param name="_element"></param> /// <param name="spProductTypeList"></param> internal void ReLoadProductsViewModel(Xamarin.Forms.Page _element, Xamarin.Forms.StackLayout spProductTypeList) { this._element = _element; this._spProductTypeList = spProductTypeList; // 重新打开产品类型 foreach (var item in ProductTypeList) { AddProductTypeItem(item); } }
/// <summary> /// This function starts the messaging chat room /// </summary> /// <param name="PublicKeys">A string containing all the participants' public keys</param> public static void CreateChatRoom(string PublicKeys, Xamarin.Forms.StackLayout Container) { new System.Threading.Thread(() => { string MyPublicKey = GetMyPublicKey(); if (!PublicKeys.Contains(MyPublicKey)) { PublicKeys += MyPublicKey; } PublicKeys = PublicKeys.Replace("==", "== "); var Keys = PublicKeys.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); CreateChatRoom(new List <string>(Keys), Container); }).Start(); }
public ProductsViewModel(Xamarin.Forms.Page _element, Xamarin.Forms.StackLayout spProductTypeList, Xamarin.Forms.StackLayout spProductList, Xamarin.Forms.ControlTemplate ctProductControlTemplate, bool IsImport = false) { this._element = _element; this._spProductTypeList = spProductTypeList; Notification.Instance.NotificationLanguage += (obj, value, args) => { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { SetCurrentName(); }); }; this.IsImport = IsImport; this._spProductList = spProductList; this._ctProductControlTemplate = ctProductControlTemplate; // 设置语言 SetCurrentName(); InitialProductType(); }
private static void AddMessageView(DataType Type, Byte[] Data, bool IsMyMessage) { var Container = cryptogram.Views.ItemDetailPage.Messages; var PaddingLeft = 5; var PaddingRight = 5; Xamarin.Forms.Color Background; if (IsMyMessage) { PaddingLeft = 20; Background = Settings.Graphics.BackgroundMyMessage; } else { Background = Settings.Graphics.BackgroundMessage; PaddingRight = 20; } var Frame = new Xamarin.Forms.Frame() { CornerRadius = 10, BackgroundColor = Background, Padding = 0 }; var Box = new Xamarin.Forms.StackLayout() { Padding = new Xamarin.Forms.Thickness(PaddingLeft, 5, PaddingRight, 5) }; Frame.Content = Box; Container.Children.Insert(0, Frame); switch (Type) { case DataType.Text: var Label = new Xamarin.Forms.Label(); Label.Text = Encoding.Unicode.GetString(Data); Box.Children.Add(Label); break; case DataType.Image: break; case DataType.Audio: break; default: break; } }
private void SizeChanged_Event(object sender, EventArgs e) { if (Element.Width > 0 && Element.Height > 0) { InitAndroidView((int)Element.Width, (int)Element.Height); s = new Xamarin.Forms.StackLayout(); s.IsEnabled = false; s.InputTransparent = true; Element.InputTransparent = true; Element.ZoomEvent -= OnZoomView; Element.ZoomEvent += OnZoomView; Element.IsEnabled = false; s.HorizontalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand; s.VerticalOptions = Xamarin.Forms.LayoutOptions.FillAndExpand; captureCamera.SetOnTouchListener(null); s.Children.Add(captureCamera); Element.Content = s; } }
public static void CreateChatRoom(List <string> Partecipants, Xamarin.Forms.StackLayout Container) { RunningCreateChatRool += 1; if (RunningCreateChatRool == 1) { new System.Threading.Thread(() => { if (Partecipants.Count > MaxPartecipants) { Functions.Alert(Resources.Dictionary.TooManyParticipants); RunningCreateChatRool = 0; return; } foreach (var MemberKey in Partecipants) { if (!ValidateKey(MemberKey)) { Functions.Alert(Resources.Dictionary.InvalidKey); RunningCreateChatRool = 0; return; } } Messaging.Container = Container; Partecipants.Sort(); _Participants = Partecipants; string PtsStr = string.Join(" ", _Participants.ToArray()); System.Security.Cryptography.HashAlgorithm hashType = new System.Security.Cryptography.SHA256Managed(); byte[] hashBytes = hashType.ComputeHash(Converter.StringToByteArray((PtsStr))); BlockChainName = Convert.ToBase64String(hashBytes); Blockchain = new Blockchain("cryptogram", BlockChainName, Blockchain.BlockchainType.Binary, Blockchain.BlockSynchronization.SendToTheNetworkBuffer, false, 8192); var BlockchainLen = ReadBlockchain(); new System.Threading.Thread(() => { Blockchain.RequestAnyNewBlocks(); ReadBlockchain(BlockchainLen); RunningCreateChatRool = 0; }).Start(); }).Start(); } return; }
protected override void Init() { var span = new Span { Text = " Mi augue molestie ligula lobortis enim Velit, in. \n Imperdiet eu dignissim odio. Massa erat Hac inceptos facilisis nibh " + " Interdum massa Consectetuer risus sociis molestie facilisi enim. Class gravida. \n Gravida sociosqu cras Quam velit, suspendisse" + " leo auctor odio integer primis dui potenti dolor faucibus augue justo morbi ornare sem. " }; var formattedString = new FormattedString(); formattedString.Spans.Add(span); var label = new Xamarin.Forms.Label { LineBreakMode = LineBreakMode.TailTruncation, VerticalOptions = LayoutOptions.Start, FormattedText = formattedString, MaxLines = 3 //max line is less than the text reproduce and textViewExtensions couldn't identify when //it's already pass the MaxLines range because of the paragraph('\n' character). }; var labelDescription = new Label { Text = "If you opened this page, the app didn't crash and you can read three lines in the label above, this test has passed", VerticalOptions = LayoutOptions.StartAndExpand }; var layout = new Xamarin.Forms.StackLayout(); layout.Children.Add(label); layout.Children.Add(labelDescription); Content = layout; }
public void LoadInformationAsync(Xamarin.Forms.StackLayout coreLayout) { if (Rows == null) { Rows = new System.Collections.ObjectModel.ObservableCollection <Models.DisplayImageRowModel>(); } else { Rows.Clear(); } int i = 0, j = 0; Xamarin.Forms.ImageSource source1, source2, source3; string tempName1, tempName2, tempName3; int rotation1, rotation2, rotation3; rotation1 = rotation2 = rotation3 = 0; for (i = 0; (j + i) < ItemsMatching.Count;) { tempName1 = tempName2 = tempName3 = null; source1 = source2 = source3 = ""; System.Diagnostics.Debug.WriteLineIf(App.OutputVerbose, "ResourceName: " + ItemsMatching[i].ImageInformation); System.Diagnostics.Debug.WriteLineIf(App.OutputVerbose, "Width: " + ItemsMatching[i].ImageInformation); for (j = 0; j < 3 && (j + i) < ItemsMatching.Count; j++) { System.Diagnostics.Debug.WriteLineIf(App.OutputVerbose, "ResourceName: " + ItemsMatching[j + i].Text + " Local: " + ItemsMatching[j + i].LocalImage); if (j == 0) { tempName1 = ItemsMatching[j + i].Text; if (ItemsMatching[j + i].LocalImage) { source1 = Xamarin.Forms.ImageSource.FromResource(ItemsMatching[j + i].ImageInformation); rotation1 = 0; } else { byte[] data = System.Convert.FromBase64String(ItemsMatching[j + i].ImageInformation); source1 = Xamarin.Forms.ImageSource.FromStream(() => new System.IO.MemoryStream(data)); if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS) { rotation1 = 180; } } } else if (j == 1) { tempName2 = ItemsMatching[j + i].Text; if (ItemsMatching[j + i].LocalImage) { source2 = Xamarin.Forms.ImageSource.FromResource(ItemsMatching[j + i].ImageInformation); rotation2 = 0; } else { byte[] data = System.Convert.FromBase64String(ItemsMatching[j + i].ImageInformation); source2 = Xamarin.Forms.ImageSource.FromStream(() => new System.IO.MemoryStream(data)); if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS) { rotation2 = 180; } } } else if (j == 2) { tempName3 = ItemsMatching[j + i].Text; if (ItemsMatching[j + i].LocalImage) { source3 = Xamarin.Forms.ImageSource.FromResource(ItemsMatching[j + i].ImageInformation); rotation3 = 0; } else { byte[] data = System.Convert.FromBase64String(ItemsMatching[j + i].ImageInformation); source3 = Xamarin.Forms.ImageSource.FromStream(() => new System.IO.MemoryStream(data)); if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS) { rotation3 = 180; } } } } j = 0; Rows.Add(CreateModel(tempName1, source1, rotation1, tempName2, source2, rotation2, tempName3, source3, rotation3, coreLayout.Width / 4)); i += 3; } }