public AppInfoPage(AppButton button) { this.AppButton = button; InitializeComponent(); SetupWindow(); ApplyTheme(); }
/// <summary> /// A helper method for SortButtonsList. /// </summary> /// <returns></returns> private static AppButton[] GetAppButtonArray() { int len = MainScreen.Data.Apps.Count; AppButton[] apps = new AppButton[len]; for (int i = 0; i < len; i++) { apps[i] = new AppButton(MainScreen.Data.Apps[i]); } return(apps); }
public ButtonPage() { var content = new StackLayout(); foreach (var app in applications) { var button = new AppButton(app.Item1, app.Item2); button.Clicked += OnAppButtonclick; content.Children.Add(button); } Content = content; }
private void SetStyle() { MultiBinding multiBinding = new MultiBinding(); multiBinding.Converter = StyleConverter; multiBinding.Bindings.Add(new Binding { RelativeSource = RelativeSource.Self }); multiBinding.Bindings.Add(new Binding("State")); AppButton.SetBinding(StyleProperty, multiBinding); }
static void Main(string[] args) { ApplicationController controller = new ApplicationController(); AppButton button1 = new AppButton(50, 50, "Test Button", controller.ApplicationPanel); button1.Text = "asdas"; while (true) { Console.ReadKey(); } }
public static Frame BuildAcceptableFrame( string labelText, object buttonData, Action <object, EventArgs> acceptMethod, Action <object, EventArgs> rejectMethod, string acceptButtonText = "Zaakceptuj", string rejectButtonText = "Odrzuć") { var layout = new StackLayout { Orientation = StackOrientation.Horizontal }; var label = new Label { Text = labelText, HorizontalOptions = LayoutOptions.StartAndExpand, FontSize = NamedSize.Medium.GetFormattedLabelFontSize() }; var acceptButton = new AppButton { Text = acceptButtonText, HorizontalOptions = LayoutOptions.EndAndExpand, BackgroundColor = Color.Transparent }; var rejectButton = new AppButton { Text = rejectButtonText, BackgroundColor = Color.Transparent }; var acceptGesture = new TapGestureRecognizer { CommandParameter = buttonData }; var rejectGesture = new TapGestureRecognizer { CommandParameter = buttonData }; var frame = new Frame { Content = layout, BackgroundColor = Color.WhiteSmoke, Padding = 6, Margin = 2 }; acceptGesture.Tapped += (sender, args) => acceptMethod(sender, args); rejectGesture.Tapped += (sender, args) => rejectMethod(sender, args); acceptButton.GestureRecognizers.Add(acceptGesture); rejectButton.GestureRecognizers.Add(rejectGesture); layout.Children.Add(label); layout.Children.Add(acceptButton); layout.Children.Add(rejectButton); return(frame); }
protected ProfileAppViewModel(long groupId, AppButton appButton) { this._ownerId = -groupId; this._appButton = appButton; }
private void Initialize(EntityViewerViewModel <TEntity> viewModel) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } ViewModel = viewModel; viewModel.PropertyChanged += viewModel_PropertyChanged; viewModel.PageSize = 30; if (ViewModel.Items.Count == 0 && ViewModel.ParentModels == null) { viewModel.ParentModels = EntityParentSelectorViewModel.CreateModel <TEntity>(BussinessApplication.Current.ContextBuilder); } Grid grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Pixel) }); if (viewModel.ParentModels != null && viewModel.ParentModels.Length != 0) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(200, GridUnitType.Pixel) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ParentTree = new TreeView(); ParentTree.BorderThickness = new Thickness(); TreeViewItem item = new TreeViewItem(); item.Header = "全部"; item.IsExpanded = true; item.ItemsSource = GetParentItems(viewModel.ParentModels); ParentTree.Items.Add(item); ParentTree.SelectedItemChanged += ParentTree_SelectedItemChanged; item.Margin = new Thickness(0, 0, 8, 0); grid.Children.Add(ParentTree); GridSplitter splitter = new GridSplitter(); splitter.Width = 8; splitter.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; grid.Children.Add(splitter); } #region 列表显示 ListView dataGrid = new ListView(); dataGrid.MouseDoubleClick += dataGrid_MouseDoubleClick; dataGrid.BorderThickness = new Thickness(); if (viewModel.ParentModels != null && viewModel.ParentModels.Length != 0) { Grid.SetColumn(dataGrid, 1); } dataGrid.SelectionMode = SelectionMode.Extended; GridView view = new GridView(); view.AllowsColumnReorder = false; var entityType = typeof(TEntity); var viewBuilder = viewModel.ViewBuilder; var visableProperties = viewBuilder.VisableProperties; var hideProperties = viewBuilder.HideProperties; PropertyInfo[] properties; if (hideProperties == null) { properties = visableProperties.Select(v => entityType.GetProperty(v)).Where(t => t != null).ToArray(); } else { properties = visableProperties.Except(hideProperties).Select(v => entityType.GetProperty(v)).Where(t => t != null).ToArray(); } foreach (var property in properties) { GridViewColumn column = new GridViewColumn(); var display = property.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute; if (display == null) { column.Header = property.Name; } else { column.Header = new Label { Content = display.Name, ToolTip = display.Description } }; DataTemplate dt = new DataTemplate(); FrameworkElementFactory fef = new FrameworkElementFactory(typeof(Label)); Binding binding = new Binding(); binding.Path = new PropertyPath(property.Name); fef.SetBinding(Label.ContentProperty, binding); dt.VisualTree = fef; column.CellTemplate = dt; view.Columns.Add(column); } dataGrid.View = view; viewModel.UpdateSource(); dataGrid.DataContext = viewModel; dataGrid.SetBinding(DataGrid.ItemsSourceProperty, new Binding("ItemsSource")); grid.Children.Add(dataGrid); #endregion #region 钮显示 AppButtonPanel = new AppButtonPanel(); Grid.SetRow(AppButtonPanel, 1); if (viewModel.ParentModels != null && viewModel.ParentModels.Length != 0) { Grid.SetColumnSpan(AppButtonPanel, 2); } grid.Children.Add(AppButtonPanel); AppButton back = new AppButton(new CustomCommand(null, Back)); back.Text = "返回"; back.Image = (Canvas)Resources["appbar_arrow_left"]; AppButtonPanel.Items.Add(back); AppButton previousPage = new AppButton(new CustomCommand(CanPreviousPage, PreviousPage)); previousPage.Text = "上一页"; previousPage.Image = (Canvas)Resources["appbar_navigate_previous"]; AppButtonPanel.Items.Add(previousPage); AppButton nextPage = new AppButton(new CustomCommand(CanNextPage, NextPage)); nextPage.Text = "下一页"; nextPage.Image = (Canvas)Resources["appbar_navigate_next"]; AppButtonPanel.Items.Add(nextPage); AppButton ok = new AppItemButton(dataGrid, OK); ok.Text = "选择"; ok.Image = (Canvas)Resources["appbar_check"]; AppButtonPanel.Items.Add(ok); #endregion Content = grid; Loaded += Viewer_Loaded; }
public GroupProfileAppViewModel(long groupId, AppButton appButton) : base(groupId, appButton) { }
public CustomFont() { Grid grMain = new Grid { Padding = new Thickness(10, 40, 10, 40), RowSpacing = 20, BackgroundColor = Color.Black, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, RowDefinitions = { new RowDefinition { Height = GridLength.Auto }, new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }, new RowDefinition { Height = GridLength.Auto }, }, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, } }; lblFont = new Label { FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Center, Text = _fonts[0].Name, TextColor = Color.White }; int height = 6 * Convert.ToInt32(Device.GetNamedSize(NamedSize.Medium, typeof(Label))); AppButton btnChangeFont = new AppButton { HorizontalOptions = LayoutOptions.Center, BackgroundColor = Color.FromHex("#dfe30b"), TextColor = Color.Black, BorderWidth = 0, BorderRadius = height / 2, HeightRequest = height, MinimumHeightRequest = height, WidthRequest = height, MinimumWidthRequest = height, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), Text = "Change Font" }; btnChangeFont.Clicked += Change_Font; lvSentences = new ListView { BackgroundColor = Color.Black, SeparatorVisibility = SeparatorVisibility.None, ItemTemplate = new DataTemplate(typeof(SentenceCell)), ItemsSource = MakeSentences() }; grMain.Children.Add(lblFont, 0, 0); grMain.Children.Add(lvSentences, 0, 1); grMain.Children.Add(btnChangeFont, 0, 2); Content = grMain; }
static void HandleOnRecivedMessage(object sender, EventArgs args, string message) { var incomingMessage = JsonConvert.DeserializeObject <RecvWebSocketMessage>(message); Console.WriteLine(incomingMessage); if ((incomingMessage.action == "CREATE_MESSAGE") && (incomingMessage.data != null)) { // Console.WriteLine(incomingMessage.data.conversation_id); MixinApi callback = (MixinApi)sender; //send ack for every Create Message! callback.SendMessageResponse(incomingMessage.data.message_id).Wait(); if (incomingMessage.data.category == "PLAIN_TEXT") { byte[] strOriginal = Convert.FromBase64String(incomingMessage.data.data); string clearText = System.Text.Encoding.UTF8.GetString(strOriginal); Console.WriteLine(clearText); string thisMessageId = Guid.NewGuid().ToString(); System.Console.WriteLine("Send echo with message id:" + thisMessageId); if (clearText == "a") { AppCard appCard = new AppCard(); appCard.title = "Pay BTC 0.0001"; appCard.icon_url = "https://images.mixin.one/HvYGJsV5TGeZ-X9Ek3FEQohQZ3fE9LBEBGcOcn4c4BNHovP4fW4YB97Dg5LcXoQ1hUjMEgjbl1DPlKg1TW7kK6XP=s128"; appCard.description = "hi"; appCard.action = "https://mixin.one/pay?recipient=" + USRCONFIG.ClientId + "&asset=" + "c6d0c728-2624-429b-8e0d-d9d19b6592fa" + "&amount=" + "0.001" + "&trace=" + System.Guid.NewGuid().ToString() + "&memo="; callback.SendAppCardMessage(incomingMessage.data.conversation_id, appCard); } else if (clearText == "g") { List <AppButton> appBtnList = new List <AppButton>(); string payLinkEOS = "https://mixin.one/pay?recipient=" + USRCONFIG.ClientId + "&asset=" + "6cfe566e-4aad-470b-8c9a-2fd35b49c68d" + "&amount=" + "0.1" + "&trace=" + System.Guid.NewGuid().ToString() + "&memo="; string payLinkBTC = "https://mixin.one/pay?recipient=" + USRCONFIG.ClientId + "&asset=" + "c6d0c728-2624-429b-8e0d-d9d19b6592fa" + "&amount=" + "0.001" + "&trace=" + System.Guid.NewGuid().ToString() + "&memo="; AppButton btnBTC = new AppButton(); btnBTC.label = "Pay BTC 0.001"; btnBTC.color = "#0080FF"; btnBTC.action = payLinkBTC; AppButton btnEOS = new AppButton(); btnEOS.label = "Pay EOS 0.1"; btnEOS.color = "#8000FF"; btnEOS.action = payLinkEOS; appBtnList.Add(btnBTC); appBtnList.Add(btnEOS); callback.SendAppButtonGroupMessage(incomingMessage.data.conversation_id, appBtnList); } else { callback.SendTextMessage(incomingMessage.data.conversation_id, clearText, thisMessageId); } } if (incomingMessage.data.category == "SYSTEM_ACCOUNT_SNAPSHOT") { byte[] strOriginal = Convert.FromBase64String(incomingMessage.data.data); string clearText = System.Text.Encoding.UTF8.GetString(strOriginal); Console.WriteLine(clearText); Transfer trsInfo = JsonConvert.DeserializeObject <Transfer>(clearText); Console.WriteLine(trsInfo.asset_id); Console.WriteLine(trsInfo.opponent_id); Console.WriteLine(trsInfo.amount); if (Int32.Parse(trsInfo.amount) > 0) { Transfer reqInfo = callback.Transfer(trsInfo.asset_id, trsInfo.opponent_id, trsInfo.amount, USRCONFIG.PinCode, System.Guid.NewGuid().ToString(), ""); Console.WriteLine(reqInfo); } } } // Console.WriteLine(incomingMessage); if (incomingMessage.action == "ACKNOWLEDGE_MESSAGE_RECEIPT") { if (incomingMessage.data != null) { System.Console.WriteLine("The message delivery status: " + incomingMessage.data.message_id + " " + incomingMessage.data.status); } } if (incomingMessage.action == "LIST_PENDING_MESSAGES") { System.Console.WriteLine("The bot is listening!"); } }
private void PrepareGridElements() { var secondaryButtonStyles = new List <string> { "style-test" }; var loginLabel = new Label { Text = "Logowanie", StyleClass = secondaryButtonStyles, HorizontalOptions = LayoutOptions.StartAndExpand }; var registerLabel = new Label { Text = "Rejestracja", StyleClass = secondaryButtonStyles, HorizontalOptions = LayoutOptions.StartAndExpand }; var recoveryLabel = new Label { Text = "Przypomnienie hasła", StyleClass = secondaryButtonStyles, HorizontalOptions = LayoutOptions.StartAndExpand }; var submitButton = new AppButton { Text = "Zatwierdź" }; var loginGesture = new TapGestureRecognizer(); var registerGesture = new TapGestureRecognizer(); var recoveryGesture = new TapGestureRecognizer(); var submitGesture = new TapGestureRecognizer(); loginGesture.Tapped += OnLoginButtonClicked; registerGesture.Tapped += OnRegisterButtonClicked; recoveryGesture.Tapped += OnPasswordRecoveryButtonClicked; submitGesture.Tapped += OnSubmitButtonClicked; loginLabel.GestureRecognizers.Add(loginGesture); registerLabel.GestureRecognizers.Add(registerGesture); recoveryLabel.GestureRecognizers.Add(recoveryGesture); submitButton.GestureRecognizers.Add(submitGesture); preparedElements.Add(ElementType.Identifier, new Entry { Placeholder = "Identyfikator" }); preparedElements.Add(ElementType.Login, new Entry { Placeholder = "Login" }); preparedElements.Add(ElementType.Email, new Entry { Placeholder = "Email" }); preparedElements.Add(ElementType.Password, new Entry { Placeholder = "Hasło", IsPassword = true }); preparedElements.Add(ElementType.ConfirmedPassword, new Entry { Placeholder = "Powtórz hasło", IsPassword = true }); preparedElements.Add(ElementType.LoginLabel, loginLabel); preparedElements.Add(ElementType.RegisterLabel, registerLabel); preparedElements.Add(ElementType.RecoveryLabel, recoveryLabel); preparedElements.Add(ElementType.SubmitButton, submitButton); preparedElements.Add(ElementType.ErrorLabel, new Label()); var buttonsLayout = new StackLayout { Orientation = StackOrientation.Horizontal }; buttonsLayout.Children.Add(preparedElements[ElementType.LoginLabel]); buttonsLayout.Children.Add(preparedElements[ElementType.RegisterLabel]); buttonsLayout.Children.Add(preparedElements[ElementType.RecoveryLabel]); GridLayout.Children.Add(preparedElements[ElementType.Identifier]); GridLayout.Children.Add(preparedElements[ElementType.Login]); GridLayout.Children.Add(preparedElements[ElementType.Email]); GridLayout.Children.Add(preparedElements[ElementType.Password]); GridLayout.Children.Add(preparedElements[ElementType.ConfirmedPassword]); GridLayout.Children.Add(buttonsLayout); GridLayout.Children.Add(preparedElements[ElementType.SubmitButton]); GridLayout.Children.Add(preparedElements[ElementType.ErrorLabel]); }
protected override View CreateContent() { var logoWidth = MainPage.PageWidth / 4.4366; var logoHeight = MainPage.PageHeight / 7.3297; var logoTopOffset = MainPage.PageHeight / 6.0636; var welcomeTextOffset = MainPage.PageHeight / 17.1026; var buttonsOffset = MainPage.PageHeight / 6.2925; var facebookSize = MainPage.PageHeight / 26.6800; var facebookHOffset = MainPage.PageWidth / 5.0000; #region Logo var logo = new Image { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = logoWidth, HeightRequest = logoHeight, Source = "logo" }; var logoContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, logoTopOffset, 0, 0), Content = logo }; #endregion #region Welcome var welcome = new AppLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, FontSize = MainPage.PageHeight / 39.2353, TextColor = Color.White }; welcome.SetBinding(AppLabel.TextProperty, new Binding("StartPanelWelcomeText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); var welcomeContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, welcomeTextOffset, 0, 0), Content = welcome }; #endregion #region Buttons var logIn = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; logIn.SetBinding(AppButton.TextProperty, new Binding("StartPanelLogInButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); logIn.SetBinding(AppButton.CommandProperty, "LogInCommand"); var createAccount = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; createAccount.SetBinding(AppButton.TextProperty, new Binding("StartPanelCreateAccountButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); createAccount.SetBinding(AppButton.CommandProperty, "CreateAccountCommand"); var facebookLogin = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppButtonStyle = AppButtonStyles.Facebook, Image = "facebook_white", WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; facebookLogin.SetBinding(AppButton.TextProperty, new Binding("StartPanelFacebookLoginButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); facebookLogin.SetBinding(AppButton.CommandProperty, "FacebookLoginCommand"); var buttons = new StackLayout { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Spacing = MainPage.PageHeight / 29, Padding = new Thickness(0, buttonsOffset, 0, 0) }; buttons.Children.Add(logIn); buttons.Children.Add(createAccount); buttons.Children.Add(facebookLogin); #endregion var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, RowSpacing = 0, ColumnSpacing = 0, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } } }; grid.Children.Add(logoContent, 0, 0); grid.Children.Add(welcomeContent, 0, 1); grid.Children.Add(buttons, 0, 2); return(grid); }
private void Initialize(EntityEditorViewModel <TEntity> viewModel, EditorItemFactory factory) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } ViewModel = viewModel; Type type = typeof(TEntity); Grid grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Pixel) }); ParentAttribute parent = type.GetCustomAttributes(typeof(ParentAttribute), true).FirstOrDefault() as ParentAttribute; Grid dataGrid = new Grid(); dataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(200, GridUnitType.Pixel) }); dataGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); Items = new List <EditorItem>(); foreach (var property in viewModel.ViewBuilder.EditableProperties) { dataGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto), MinHeight = 32 }); var name = new Label(); name.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; name.VerticalAlignment = System.Windows.VerticalAlignment.Center; name.Margin = new Thickness(4); var display = type.GetProperty(property).GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute; if (display == null) { name.Content = property; } else { name.Content = display.Name; name.ToolTip = display.Description; } Grid.SetRow(name, dataGrid.RowDefinitions.Count - 1); dataGrid.Children.Add(name); EditorItem editor = factory.GetEditorItem(type.GetProperty(property)); editor.Title = (string)name.Content; editor.Tag = type.GetProperty(property); editor.Value = type.GetProperty(property).GetValue(viewModel.Item, null); Items.Add(editor); editor.Margin = new Thickness(4); editor.Initialized = true; Grid.SetRow(editor, dataGrid.RowDefinitions.Count - 1); Grid.SetColumn(editor, 1); dataGrid.Children.Add(editor); } ScrollViewer scroll = new ScrollViewer(); scroll.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; scroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; scroll.PanningMode = PanningMode.VerticalOnly; scroll.Content = dataGrid; grid.Children.Add(scroll); AppButtonPanel appButtonPanel = new AppButtonPanel(); Grid.SetRow(appButtonPanel, 1); grid.Children.Add(appButtonPanel); AppButton ok = new AppButton(new CustomCommand(null, Ok)); ok.Text = "确定"; ok.Image = (Canvas)Resources["appbar_check"]; appButtonPanel.Items.Add(ok); AppButton cancel = new AppButton(new CustomCommand(null, Cancel)); cancel.Text = "取消"; cancel.Image = (Canvas)Resources["appbar_close"]; appButtonPanel.Items.Add(cancel); Content = grid; }
private View CreateContent() { #region Content var converter = new TestResultToImageConverter(); var image = new Image { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Start, HeightRequest = 100, WidthRequest = 100, }; image.SetBinding(Image.SourceProperty, new Binding("Result", BindingMode.OneWay, converter, null, null, this)); var messageLabel = new Label { HorizontalOptions = LayoutOptions.Start, VerticalOptions = LayoutOptions.Center, FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), TextColor = Color.Black, }; messageLabel.SetBinding(Label.TextProperty, new Binding("Text", BindingMode.OneWay, null, null, null, this)); var content = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, ColumnSpacing = 10, ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } } }; content.Children.Add(image, 0, 0); content.Children.Add(messageLabel, 1, 0); #endregion #region Commands var continueCommand = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Text = "CONTINUE" }; continueCommand.SetBinding(AppButton.CommandProperty, new Binding("ContinueCommand", BindingMode.OneWay, null, null, null, this)); var commands = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, RowSpacing = 0, ColumnSpacing = 0 }; commands.Children.Add(continueCommand); #endregion var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Center, RowSpacing = 10, ColumnSpacing = 0, BackgroundColor = Color.Gray, Padding = new Thickness(20, 10, 20, 10), RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } } }; grid.Children.Add(content, 0, 1); grid.Children.Add(commands, 0, 2); return(grid); }
protected override View CreateContent() { var logoWidth = MainPage.PageWidth / 4.4366; var logoHeight = MainPage.PageHeight / 7.3297; var logoTopOffset = MainPage.PageHeight / 6.0636; var welcomeTextOffset = MainPage.PageHeight / 17.1026; var emailHeight = MainPage.PageHeight / 7.0211; var passwordHeight = MainPage.PageHeight / 8.2346; var errorHeight = MainPage.PageHeight / 12.5849; var errorBottomOffset = MainPage.PageHeight / 60.6363; var forgotTopOffset = MainPage.PageHeight / 95.2857; var signUpTopOffset = MainPage.PageHeight / 11.9107; var textFontSize = MainPage.PageHeight / 60.6364; var entryFontSize = MainPage.PageHeight / 39.2353; var signUpFontSize = MainPage.PageHeight / 55.5833; var horizontalPadding = MainPage.PageWidth / 7.8125; var color = Color.White; var placeholderColor = Color.White; var errorColor = Color.White; // Color.FromHex("#E27A73"); var commandColor = Color.FromHex("#61A8A1"); var imageSize = MainPage.PageWidth / 17.0455; var imageOffset = imageSize / 2; #region Logo var logo = new Image { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = logoWidth, HeightRequest = logoHeight, Source = "logo" }; var logoContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, logoTopOffset, 0, 0), Content = logo }; #endregion #region Welcome var welcome = new AppLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, FontSize = MainPage.PageHeight / 39.2353, TextColor = Color.White }; welcome.SetBinding(AppLabel.TextProperty, new Binding("LoginPanelWelcomeText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); var welcomeContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, welcomeTextOffset, 0, 0), Content = welcome }; #endregion #region Сontent #region Email _email = new AppEntryEditor { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, HeightRequest = emailHeight, AppFont = AppFonts.Quicksand, FontSize = entryFontSize, TextColor = color, ErrorTextColor = errorColor, PlaceholderColor = placeholderColor, ImageSource = "email_white", ErrorImageSource = "email_red", ImageSize = imageSize, ImageOffset = imageOffset, Keyboard = Keyboard.Email }; _email.SetBinding(AppEntryEditor.TextProperty, "Email", BindingMode.TwoWay); _email.SetBinding(AppEntryEditor.PlaceholderProperty, new Binding("LoginPanelEmailPlaceholderText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); _email.SetBinding(AppEntryEditor.IsErrorProperty, "IsErrorEmail"); #endregion #region Password _password = new AppEntryEditor { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, HeightRequest = passwordHeight, AppFont = AppFonts.Quicksand, FontSize = entryFontSize, TextColor = color, ErrorTextColor = errorColor, PlaceholderColor = placeholderColor, ImageSource = "lock_white", ErrorImageSource = "lock_red", ImageSize = imageSize, ImageOffset = imageOffset, Keyboard = Keyboard.Default, IsPassword = true }; _password.SetBinding(AppEntryEditor.TextProperty, "Password", BindingMode.TwoWay); _password.SetBinding(AppEntryEditor.PlaceholderProperty, new Binding("LoginPanelPasswordPlaceholderText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); _password.SetBinding(AppEntryEditor.IsErrorProperty, "IsErrorPassword"); #endregion #region Error var error = new AppLabel { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End, HorizontalTextAlignment = TextAlignment.Center, AppFont = AppFonts.Quicksand, FontSize = MainPage.PageHeight / 39.2353, TextColor = errorColor }; error.SetBinding(AppLabel.TextProperty, "ErrorText"); error.SetBinding(AppLabel.IsVisibleProperty, "IsError"); var errorContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, HeightRequest = errorHeight, Padding = new Thickness(0, 0, 0, errorBottomOffset), Content = error }; #endregion #region LogIn _logIn = new AppButton { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, WidthRequest = MainPage.PageWidth / 1.2458, HeightRequest = MainPage.PageHeight / 11.7018, FontSize = MainPage.PageHeight / 39.2353 }; _logIn.SetBinding(AppButton.TextProperty, new Binding("LoginPanelLogInButtonText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); _logIn.SetBinding(AppButton.CommandProperty, "LogInCommand"); var logInContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Content = _logIn }; #endregion #region Forgot Password var forgot = new AppCommand { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, IsUnderline = true, FontSize = 14, TextColor = commandColor, DisableTextColor = commandColor }; forgot.SetBinding(AppCommand.TextProperty, new Binding("LoginPanelForgotCommandText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); forgot.SetBinding(AppCommand.CommandProperty, "ForgotCommand"); var forgotContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, forgotTopOffset, 0, 0), Content = forgot }; #endregion #region SignUp var signUp = new AppCommand { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, AppFont = AppFonts.Quicksand, IsUnderline = true, FontSize = 14, TextColor = commandColor, DisableTextColor = commandColor }; signUp.SetBinding(AppCommand.TextProperty, new Binding("LoginPanelSignUpCommandText", BindingMode.OneWay, null, null, null, AppLanguages.CurrentLanguage)); signUp.SetBinding(AppCommand.CommandProperty, "SignUpCommand"); var signUpContent = new ContentView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(0, signUpTopOffset, 0, 0), Content = signUp }; #endregion var content = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Padding = new Thickness(horizontalPadding, 0, horizontalPadding, 0), RowSpacing = 0, ColumnSpacing = 0, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } } }; content.Children.Add(_email, 0, 0); content.Children.Add(_password, 0, 1); content.Children.Add(errorContent, 0, 2); content.Children.Add(logInContent, 0, 3); content.Children.Add(forgotContent, 0, 4); content.Children.Add(signUpContent, 0, 5); #endregion var grid = new Grid { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, RowSpacing = 0, ColumnSpacing = 0, RowDefinitions = { new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) } } }; grid.Children.Add(logoContent, 0, 0); grid.Children.Add(welcomeContent, 0, 1); grid.Children.Add(content, 0, 2); _email.Completed += (sender, args) => { _password.SetFocus(); }; _password.Completed += (sender, args) => { if ((_logIn.Command != null) && (_logIn.Command.CanExecute(_logIn.CommandParameter))) { _logIn.Command.Execute(_logIn.CommandParameter); } }; _scroll = new ScrollView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Content = grid }; return(_scroll); }
private void Initialize(EntityViewerViewModel <TEntity> viewModel) { if (viewModel == null) { throw new ArgumentNullException("viewModel"); } Buttons = new System.Collections.ObjectModel.ObservableCollection <AppButton>(); Buttons.CollectionChanged += Buttons_CollectionChanged; //Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml") }); //Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml") }); //Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml") }); //Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml") }); //Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml") }); //Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("pack://application:,,,/Wodsoft.ComBoost.Business.Remote;component/Resources/Icons.xaml") }); ViewModel = viewModel; viewModel.PropertyChanged += viewModel_PropertyChanged; viewModel.PageSize = 30; if (viewModel.AutoGenerateData && ViewModel.Items.Count == 0 && ViewModel.ParentModels == null) { viewModel.ParentModels = EntityParentSelectorViewModel.CreateModel <TEntity>(BussinessApplication.Current.ContextBuilder); } Grid grid = new Grid(); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(100, GridUnitType.Pixel) }); if (viewModel.ParentModels != null && viewModel.ParentModels.Length != 0) { grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(200, GridUnitType.Pixel) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); ParentTree = new TreeView(); ParentTree.BorderThickness = new Thickness(); TreeViewItem item = new TreeViewItem(); item.Header = "全部"; item.IsExpanded = true; item.ItemsSource = GetParentItems(viewModel.ParentModels); ParentTree.Items.Add(item); ParentTree.SelectedItemChanged += ParentTree_SelectedItemChanged; item.Margin = new Thickness(0, 0, 8, 0); grid.Children.Add(ParentTree); GridSplitter splitter = new GridSplitter(); splitter.Width = 8; splitter.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; grid.Children.Add(splitter); } #region 列表显示 View = new ListView(); View.BorderThickness = new Thickness(); if (viewModel.ParentModels != null && viewModel.ParentModels.Length != 0) { Grid.SetColumn(View, 1); } View.SelectionMode = SelectionMode.Single; GridView view = new GridView(); view.AllowsColumnReorder = false; var entityType = typeof(TEntity); var viewBuilder = viewModel.ViewBuilder; var visableProperties = viewBuilder.VisableProperties; var hideProperties = viewBuilder.HideProperties; PropertyInfo[] properties; if (hideProperties == null) { properties = visableProperties.Select(v => entityType.GetProperty(v)).Where(t => t != null).ToArray(); } else { properties = visableProperties.Except(hideProperties).Select(v => entityType.GetProperty(v)).Where(t => t != null).ToArray(); } foreach (var property in properties) { GridViewColumn column = new GridViewColumn(); var display = property.GetCustomAttributes(typeof(DisplayAttribute), false).FirstOrDefault() as DisplayAttribute; if (display == null) { column.Header = property.Name; } else { column.Header = new Label { Content = display.Name, ToolTip = display.Description } }; DataTemplate dt = new DataTemplate(); FrameworkElementFactory fef = new FrameworkElementFactory(typeof(Label)); Binding binding = new Binding(); binding.Path = new PropertyPath(property.Name); fef.SetBinding(Label.ContentProperty, binding); dt.VisualTree = fef; column.CellTemplate = dt; view.Columns.Add(column); } View.View = view; viewModel.UpdateSource(); View.DataContext = viewModel; View.SetBinding(DataGrid.ItemsSourceProperty, new Binding("ItemsSource")); grid.Children.Add(View); #endregion #region 钮显示 AppButtonPanel = new AppButtonPanel(); Grid.SetRow(AppButtonPanel, 1); if (viewModel.ParentModels != null && viewModel.ParentModels.Length != 0) { Grid.SetColumnSpan(AppButtonPanel, 2); } grid.Children.Add(AppButtonPanel); AppButton back = new AppButton(new CustomCommand(null, Back)); back.Text = "返回"; back.Image = (Canvas)Resources["appbar_arrow_left"]; AppButtonPanel.Items.Add(back); //AppButton firstPage = new AppButton(new CustomCommand(CanFirstPage, FirstPage)); //firstPage.Text = "第一页"; //firstPage.Image = (Canvas)Application.Current.Resources["appbar_navigate_previous"]; //AppButtonPanel.Items.Add(firstPage); AppButton previousPage = new AppButton(new CustomCommand(CanPreviousPage, PreviousPage)); previousPage.Text = "上一页"; previousPage.Image = (Canvas)Resources["appbar_navigate_previous"]; AppButtonPanel.Items.Add(previousPage); AppButton nextPage = new AppButton(new CustomCommand(CanNextPage, NextPage)); nextPage.Text = "下一页"; nextPage.Image = (Canvas)Resources["appbar_navigate_next"]; AppButtonPanel.Items.Add(nextPage); if (viewModel.ViewBuilder.AllowedAdd) { AppButton add = new AppButton(new CustomCommand(CanAdd, Add)); add.Text = "新增"; add.Image = (Canvas)Resources["appbar_add"]; AppButtonPanel.Items.Add(add); } if (viewModel.ViewBuilder.AllowedRemove) { AppButton remove = new AppItemButton(View, CanRemove, Remove); remove.Text = "删除"; remove.Image = (Canvas)Resources["appbar_delete"]; AppButtonPanel.Items.Add(remove); } if (viewModel.ViewBuilder.AllowedEdit) { AppButton edit = new AppItemButton(View, CanEdit, Edit); edit.Text = "编辑"; edit.Image = (Canvas)Resources["appbar_edit"]; AppButtonPanel.Items.Add(edit); } #endregion Content = grid; Loaded += Viewer_Loaded; }