public Button() { DrawLayerNumber += 1; // (button design image) Padding = new Thickness(10, 5, 10, 7); MouseOverStateChanged += (sender, args) => InvalidateButtonImage(); }
public StackLayoutGallery () { Device.OnPlatform (iOS: () => { if (Device.Idiom == TargetIdiom.Tablet) { Padding = new Thickness (0, 0, 0, 60); } }); var stack = new StackLayout { Orientation = StackOrientation.Vertical }; Button b1 = new Button { Text = "Boring", HeightRequest = 500, MinimumHeightRequest = 50 }; Button b2 = new Button { Text = "Exciting!", VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; Button b3 = new Button { Text = "Amazing!", VerticalOptions = LayoutOptions.FillAndExpand }; Button b4 = new Button { Text = "Meh", HeightRequest = 400, MinimumHeightRequest = 50 }; b1.Clicked += (sender, e) => { b1.Text = "clicked1"; }; b2.Clicked += (sender, e) => { b2.Text = "clicked2"; }; b3.Clicked += (sender, e) => { b3.Text = "clicked3"; }; b4.Clicked += (sender, e) => { b4.Text = "clicked4"; }; stack.Children.Add (b1); stack.Children.Add (b2); stack.Children.Add (b3); stack.Children.Add (b4); Content = stack; }
/// <summary> /// Extension of the Panel which has Button to close itself and Label with title. /// Position is calculate from given width and height (1/4 of the width and 1/5 of the height). /// Also panel width and height is calculate as 1/2 of the width and 4/7 of the hight. /// </summary> /// <param name="screenWidth">The width od screen.</param> /// <param name="screenHeight">The height od screen.</param> /// <param name="text">The title text.</param> /// <param name="name">The name of the panel.</param> /// <param name="rowHeight">The height of the title label.</param> /// <param name="panelSkin">The skin of the creating panel.</param> /// <param name="buttonSkin">The skin of the the closing button.</param> public PopUpPanel(int screenWidth, int screenHeight, string text, string name, int rowHeight, Skin panelSkin, Skin buttonSkin) { Width = screenWidth / 2; Height = screenHeight * 4 / 7; Location = new Point(screenWidth / 4, screenHeight / 5); Skin = panelSkin; ResizeMode = ResizeModes.None; Padding = new Thickness(5, 10, 0, 0); Name = name; // Title label var label = new Label() { Size = new Size(Width / 2, rowHeight), Text = text, Location = new Point(Width / 4, 0), TextStyle = { Alignment = Miyagi.Common.Alignment.TopCenter } }; Controls.Add(label); Button closeButton = new CloseButton(name) { Size = new Size(Width / 3, Height / 12), Location = new Point(Width * 5 / 8, Height * 7 / 8), Skin = buttonSkin, Text = "Cancel", TextStyle = new TextStyle { Alignment = Alignment.MiddleCenter } }; Controls.Add(closeButton); }
public ImageLoadingGallery () { Padding = new Thickness (20); var source = new UriImageSource { Uri = new Uri ("http://www.nasa.gov/sites/default/files/styles/1600x1200_autoletterbox/public/images/298773main_EC02-0282-3_full.jpg"), CachingEnabled = false }; var image = new Image { Source = source, WidthRequest = 200, HeightRequest = 200, }; var indicator = new ActivityIndicator {Color = new Color (.5),}; indicator.SetBinding (ActivityIndicator.IsRunningProperty, "IsLoading"); indicator.BindingContext = image; var grid = new Grid(); grid.RowDefinitions.Add (new RowDefinition()); grid.RowDefinitions.Add (new RowDefinition()); grid.Children.Add (image); grid.Children.Add (indicator); var cancel = new Button { Text = "Cancel" }; cancel.Clicked += (s, e) => source.Cancel(); Grid.SetRow (cancel, 1); grid.Children.Add (cancel); Content = grid; }
public CMSearchTextBox() : base() { BorderThickness = new Thickness(0, 0, 0, 0); Padding = new Thickness(10, 5, 5, 0); var valueTip = Custom_UC.UC_AddressBook.ResourcesStringLoader.GetString("STATIC-Textbox-Search-Tooltip-Value"); ToolTipService.SetToolTip(this, valueTip); }
public static ShapeDescription DrawFullRectangle(Vector3 position, Size size, IGradientShader linearShader, Color4 fillColor, Thickness borderSize, BorderStyle borderStyle, Color4 borderColor) { Color4[] shadedColors = linearShader.Method(linearShader, 4,Shape.Rectangle); Color4[] borderColors; switch (borderStyle) { case BorderStyle.None: borderColors = LinearShader.FillColorArray(new Color4(0), 4); break; case BorderStyle.Flat: borderColors = LinearShader.FillColorArray(borderColor, 4); break; case BorderStyle.Raised: borderColors = LinearShader.BorderRaised(borderColor, 4); break; case BorderStyle.Sunken: borderColors = LinearShader.BorderSunken(borderColor, 4); break; default: throw new ArgumentOutOfRangeException("borderStyle"); } ShapeDescription inside = DrawRectangle(position, size, shadedColors); ShapeDescription outline = DrawRectangularOutline(position, size, borderSize.All, borderColors, borderStyle, Borders.All); ShapeDescription result = ShapeDescription.Join(inside, outline); result.Shape = Shape.RectangleWithOutline; return result; }
protected override void DefaultValues() { base.DefaultValues(); velocity = new Vector2(0.3f, FALLSPEED); MARGIN = new Thickness(200, -40, 200, 40); }
public override void Render (ConsoleBuffer buffer) { if (buffer == null) throw new ArgumentNullException(nameof(buffer)); Rect renderRectWithoutShadow = new Rect(RenderSize).Deflate(Thickness.Max(Shadow, 0)); //base.Render(buffer); if (Background != null) buffer.FillBackgroundRectangle(renderRectWithoutShadow, Background.Value); buffer.FillForegroundRectangle(new Rect(RenderSize), EffectiveColor); if (!Shadow.IsEmpty) { // 3 2 2 1: -1 -1 2 3: // ▄▄▄▄▄▄▄▄▄ oooo▄▄ // █████████ oooo██ // ███oooo██ █████ // ███oooo██ █████ // ▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀ Thickness shadowLineDelta = new Thickness(0, 1); Thickness shadowOffset = Thickness.Max(-Shadow - shadowLineDelta, 0); Rect shadowRect = new Rect(RenderSize).Deflate(shadowOffset); if (Shadow.Top != 0) buffer.FillForegroundLine(shadowRect.TopLine, ShadowColor, Chars.LowerHalfBlock); if (Shadow.Bottom != 0) buffer.FillForegroundLine(shadowRect.BottomLine, ShadowColor, Chars.UpperHalfBlock); buffer.FillForegroundRectangle(shadowRect.Deflate(shadowLineDelta), ShadowColor, Chars.FullBlock); if (ShadowColor == null && ShadowColorMap != null) buffer.ApplyColorMap(shadowRect, ShadowColorMap, (ref ConsoleChar c) => c.ForegroundColor = ShadowColorMap[(int)c.BackgroundColor]); } buffer.FillForegroundRectangle(renderRectWithoutShadow, EffectiveColor); buffer.DrawRectangle(renderRectWithoutShadow, EffectiveColor, Stroke); }
public MaterialEditWindow(Screen screen) : base(screen) { DataContext = new MaterialEdit(); ShadowOffset = new Vector2(4); Padding = new Thickness(16); HorizontalAlignment = HorizontalAlignment.Left; VerticalAlignment = VerticalAlignment.Top; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; diffuseColorButton = new LightColorButton(screen); diffuseColorButton.NameTextBlock.Text = "Diffuse color"; diffuseColorButton.Click += OnDiffuseColorButtonClick; stackPanel.Children.Add(diffuseColorButton); specularColorButton = new LightColorButton(screen); specularColorButton.NameTextBlock.Text = "Specular color"; specularColorButton.Click += OnSpecularColorButtonClick; stackPanel.Children.Add(specularColorButton); }
public MARGINS(Thickness t) { Left = (int)t.Left; Right = (int)t.Right; Top = (int)t.Top; Bottom = (int)t.Bottom; }
public BoxSetupWizardDialog(Screen screen) : base(screen) { viewModel = new BoxSetupViewModel(screen.Game); DataContext = viewModel; // 開く際に openAnimation で Width を設定するので 0 で初期化します。 Width = 0; ShadowOffset = new Vector2(4); Padding = new Thickness(16); Overlay.Opacity = 0.5f; tabControl = new TabControl(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; Content = tabControl; attentionTabItem = new AttentionTabItem(Screen); attentionTabItem.FocusToDefault(); attentionTabItem.AgreeSelected += OnAttentionTabItemAgreeSelected; attentionTabItem.CancelSelected += OnAttentionTabItemCancelSelected; tabControl.Items.Add(attentionTabItem); tabControl.SelectedIndex = 0; authorizationTabItem = new AuthorizationTabItem(Screen); authorizationTabItem.NextSelected += OnAuthorizationTabItemNextSelected; authorizationTabItem.BackSelected += OnAuthorizationTabItemBackSelected; tabControl.Items.Add(authorizationTabItem); accessTabItem = new AccessTabItem(Screen); accessTabItem.NextSelected += OnAccessTabItemNextSelected; accessTabItem.BackSelected += OnAccessTabItemBackSelected; tabControl.Items.Add(accessTabItem); prepareFolderTreeTabItem = new PrepareFolderTreeTabItem(Screen); prepareFolderTreeTabItem.CreateSelected += OnPrepareFolderTreeTabItemCreateSelected; prepareFolderTreeTabItem.CancelSelected += OnPrepareFolderTreeTabItemCancelSelected; tabControl.Items.Add(prepareFolderTreeTabItem); saveSettingsTabItem = new SaveSettingsTabItem(Screen); saveSettingsTabItem.YesSelected += OnSaveSettingsTabItemYesSelected; saveSettingsTabItem.NoSelected += OnSaveSettingsTabItemNoSelected; tabControl.Items.Add(saveSettingsTabItem); finishTabItem = new FinishTabItem(Screen); finishTabItem.UploadSelected += OnFinishTabItemUploadSelected; finishTabItem.CancelSelected += OnFinishTabItemCancelSelected; tabControl.Items.Add(finishTabItem); openAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 0, To = 480, Duration = TimeSpan.FromSeconds(0.1f) }; Animations.Add(openAnimation); }
/// <summary> /// Creates a new EasingThicknessKeyFrame. /// </summary> public EasingThicknessKeyFrame(Thickness value, KeyTime keyTime, IEasingFunction easingFunction) : this() { Value = value; KeyTime = keyTime; EasingFunction = easingFunction; }
public ConfirmationDialog(Screen screen) : base(screen) { ShadowOffset = new Vector2(4); Padding = new Thickness(16); var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; messageContainer = new DialogMessageContainer(screen) { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }; stackPanel.Children.Add(messageContainer); var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); var okButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.OKButton); stackPanel.Children.Add(okButton); RegisterOKButton(okButton); cancelButton = ControlUtil.CreateDefaultDialogButton(screen, Strings.CancelButton); stackPanel.Children.Add(cancelButton); RegisterCancelButton(cancelButton); }
public ImageGallery () { Padding = new Thickness (20); var normal = new Image { Source = ImageSource.FromFile ("cover1.jpg") }; var disabled = new Image { Source = ImageSource.FromFile ("cover1.jpg") }; var rotate = new Image { Source = ImageSource.FromFile ("cover1.jpg") }; var transparent = new Image { Source = ImageSource.FromFile ("cover1.jpg") }; var embedded = new Image { Source = ImageSource.FromResource ("Xamarin.Forms.Controls.ControlGalleryPages.crimson.jpg", typeof (ImageGallery)) }; // let the stack shrink the images normal.MinimumHeightRequest = normal.MinimumHeightRequest = 10; disabled.MinimumHeightRequest = disabled.MinimumHeightRequest = 10; rotate.MinimumHeightRequest = rotate.MinimumHeightRequest = 10; transparent.MinimumHeightRequest = transparent.MinimumHeightRequest = 10; embedded.MinimumHeightRequest = 10; disabled.IsEnabled = false; rotate.GestureRecognizers.Add (new TapGestureRecognizer { Command = new Command (o => rotate.RelRotateTo (180))}); transparent.Opacity = .5; Content = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { new StackLayout { //MinimumWidthRequest = 20, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { normal, disabled, transparent, rotate, embedded, new StackLayout { HeightRequest = 30, Orientation = StackOrientation.Horizontal, Children = { new Image {Source = "cover1.jpg"}, new Image {Source = "cover1.jpg"}, new Image {Source = "cover1.jpg"}, new Image {Source = "cover1.jpg"} } } } }, new StackLayout { WidthRequest = 30, Children = { new Image {Source = "cover1.jpg"}, new Image {Source = "cover1.jpg"}, new Image {Source = "cover1.jpg"}, new Image {Source = "cover1.jpg"} } } } }; }
public SelectLanguageDialog(Screen screen) : base(screen) { // 開く際に openAnimation で Width を設定するので 0 で初期化します。 Width = 0; ShadowOffset = new Vector2(4); Padding = new Thickness(16); Overlay.Opacity = 0.5f; var stackPanel = new StackPanel(screen) { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Stretch }; Content = stackPanel; var title = new TextBlock(screen) { Text = Strings.SelectLanguageTitle, Padding = new Thickness(4), ForegroundColor = Color.Yellow, BackgroundColor = Color.Black, HorizontalAlignment = HorizontalAlignment.Stretch, TextHorizontalAlignment = HorizontalAlignment.Left, ShadowOffset = new Vector2(2) }; stackPanel.Children.Add(title); var separator = ControlUtil.CreateDefaultSeparator(screen); stackPanel.Children.Add(separator); var jaButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.JaButton); jaButton.Click += OnJaButtonClick; stackPanel.Children.Add(jaButton); var enButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.EnButton); enButton.Click += OnEnButtonClick; stackPanel.Children.Add(enButton); var defaultButton = ControlUtil.CreateDefaultMenuButton(screen, Strings.DefaultButton); defaultButton.Click += OnDefaultButtonClick; stackPanel.Children.Add(defaultButton); var cancelButon = ControlUtil.CreateDefaultMenuButton(screen, Strings.CancelButton); cancelButon.Click += (Control s, ref RoutedEventContext c) => Close(); stackPanel.Children.Add(cancelButon); openAnimation = new FloatLerpAnimation { Action = (current) => { Width = current; }, From = 0, To = 240, Duration = TimeSpan.FromSeconds(0.1f) }; Animations.Add(openAnimation); cancelButon.Focus(); }
public UnevenListGallery () { Padding = new Thickness (0, 20, 0, 0); var list = new ListView { HasUnevenRows = true }; bool next = true; list.ItemTemplate = new DataTemplate (() => { bool tall = next; next = !next; var cell = new TextCell { Height = (tall) ? 88 : 44 }; cell.SetBinding (TextCell.TextProperty, "."); return cell; }); list.ItemsSource = new[] { "Tall", "Short", "Tall", "Short" }; var listViewCellDynamicHeight = new ListView { HasUnevenRows = true, AutomationId= "unevenCellListGalleryDynamic" }; listViewCellDynamicHeight.ItemsSource = new [] { @"That Flesh is heir to? 'Tis a consummation Devoutly to be wished. To die, to sleep, To sleep, perchance to Dream; Aye, there's the rub, For in that sleep of death, what dreams may come,That Flesh is heir to? 'Tis a consummation Devoutly to be wished. To die, to sleep, To sleep, perchance to Dream; Aye, there's the rub, For in that sleep of death, what dreams may come", }; listViewCellDynamicHeight.ItemTemplate = new DataTemplate (typeof(UnevenRowsCell)); listViewCellDynamicHeight.ItemTapped += (sender, e) => { if (e == null) return; // has been set to null, do not 'process' tapped event ((ListView)sender).SelectedItem = null; // de-select the row }; var grd = new Grid (); grd.RowDefinitions.Add (new RowDefinition ()); grd.RowDefinitions.Add (new RowDefinition ()); grd.Children.Add (listViewCellDynamicHeight); grd.Children.Add (list); Grid.SetRow (list, 1); Content = grd; }
/// <summary> /// インスタンスを生成します。 /// </summary> /// <param name="screen">Screen。</param> internal Desktop(Screen screen) : base(screen) { var viewportBounds = screen.GraphicsDevice.Viewport.TitleSafeArea; BackgroundColor = Color.CornflowerBlue; Margin = new Thickness(viewportBounds.Left, viewportBounds.Top, 0, 0); Width = viewportBounds.Width; Height = viewportBounds.Height; }
public TextBlock() : base() { Border = new Border() {WidthAll = 0, Color = new Color(0,0,0)}; FontName = "Helvetica"; FontColor = new Color(0,0,0); FontSize = 12; FieldName = String.Empty; Padding = new Thickness(1,1,1,1); CanGrow = true; }
/// <summary> /// Deflates the rectangle by the border thickness. /// </summary> /// <param name="bounds">Rectangle.</param> /// <param name="borderThickness">Border thickness</param> /// <returns>Rectangle deflated by the border thickness</returns> public static RectangleF Deflate(RectangleF bounds, Thickness borderThickness) { if (borderThickness.IsZero) return bounds; bounds.X += (float)borderThickness.Left; bounds.Width -= (float)(borderThickness.Left + borderThickness.Right); bounds.Y += (float)borderThickness.Top; bounds.Height -= (float)(borderThickness.Top + borderThickness.Bottom); return bounds; }
/// <summary> /// Converts a <see cref="Thickness"/> value with dimensions in display independent pixels to a <see cref="Thickness"/> /// value with dimensions in display pixels. /// </summary> /// <param name="this">The <see cref="IUltravioletDisplay"/> with which to perform the conversion.</param> /// <param name="dips">The <see cref="Thickness"/> in display independent pixels to convert.</param> /// <returns>The converted <see cref="Thickness"/> in display pixels.</returns> public static Thickness DipsToPixels(this IUltravioletDisplay @this, Thickness dips) { Contract.Require(@this, "this"); var left = @this.DipsToPixels(dips.Left); var top = @this.DipsToPixels(dips.Top); var right = @this.DipsToPixels(dips.Right); var bottom = @this.DipsToPixels(dips.Bottom); return new Thickness(left, top, right, bottom); }
public TextBlock() : base() { Border = new Border( 0, new Color(0,0,0)); FontName = "Tahoma"; FontColor = new Color(0,0,0); FontSize = 11; FieldName = String.Empty; Padding = new Thickness(2,2,0,0); CanGrow = true; Size = new Size(20.mm(),11.pt() + 4); }
/// <summary> /// Creates a new SplineThicknessKeyFrame. /// </summary> public SplineThicknessKeyFrame(Thickness value, KeyTime keyTime, KeySpline keySpline) : this() { if (keySpline == null) { throw new ArgumentNullException("keySpline"); } Value = value; KeyTime = keyTime; KeySpline = keySpline; }
public HtmlTextBlock() { #if !WINRT InnerMargin = new Thickness(24, 0, 24, 0); FontSize = (double)Resources["PhoneFontSizeNormal"]; #else #endif Margin = new Thickness(0); SizeChanged += OnSizeChanged; SizeDependentControls = new List<ISizeDependentControl>(); }
public TextCellTablePage () { Title = "TextCell Table Gallery - Legacy"; Device.OnPlatform (iOS: () => { if (Device.Idiom == TargetIdiom.Tablet) { Padding = new Thickness (0, 0, 0, 60); } }); var tableSection = new TableSection ("Section One") { new TextCell { Text = "Text 1" }, new TextCell { Text = "Text 2", Detail = "Detail 1" }, new TextCell { Text = "Text 3" }, new TextCell { Text = "Text 4", Detail = "Detail 2" }, new TextCell { Text = "Text 5" }, new TextCell { Text = "Text 6", Detail = "Detail 3" }, new TextCell { Text = "Text 7" }, new TextCell { Text = "Text 8", Detail = "Detail 4" }, new TextCell { Text = "Text 9" }, new TextCell { Text = "Text 10", Detail = "Detail 5" }, new TextCell { Text = "Text 11" }, new TextCell { Text = "Text 12", Detail = "Detail 6" } }; var tableSectionTwo = new TableSection ("Section Two") { new TextCell { Text = "Text 13" }, new TextCell { Text = "Text 14", Detail = "Detail 7" }, new TextCell { Text = "Text 15" }, new TextCell { Text = "Text 16", Detail = "Detail 8" }, new TextCell { Text = "Text 17" }, new TextCell { Text = "Text 18", Detail = "Detail 9" }, new TextCell { Text = "Text 19" }, new TextCell { Text = "Text 20", Detail = "Detail 10" }, new TextCell { Text = "Text 21" }, new TextCell { Text = "Text 22", Detail = "Detail 11" }, new TextCell { Text = "Text 23" }, new TextCell { Text = "Text 24", Detail = "Detail 12" } }; var root = new TableRoot ("Text Cell table") { tableSection, tableSectionTwo }; var table = new TableView { Root = root, }; Content = table; }
protected override void Init () { s_mdp = this; _slidingPage = new SliderMenuPage { Title = "Menu", BackgroundColor = Color.FromHex ("1e1e1e") }; _slidingPage.MenuListView.ItemTapped += (sender, e) => OnMenuSelected (e.Item as SliderMenuItem); Padding = new Thickness (0); Master = _slidingPage; OnMenuSelected (_slidingPage.MenuListView.SelectedItem as SliderMenuItem); }
public ImageCellListPage () { Title = "ImageCell List Gallery - Legacy"; Device.OnPlatform (iOS: () => { if (Device.Idiom == TargetIdiom.Tablet) { Padding = new Thickness (0, 0, 0, 60); } }); var dataTemplate = new DataTemplate (typeof (ImageCell)); var stringToImageSourceConverter = new GenericValueConverter ( obj => new FileImageSource { File = (string) obj } ); dataTemplate.SetBinding (TextCell.TextProperty, new Binding ("Text")); dataTemplate.SetBinding (TextCell.TextColorProperty, new Binding ("TextColor")); dataTemplate.SetBinding (TextCell.DetailProperty, new Binding ("Detail")); dataTemplate.SetBinding (TextCell.DetailColorProperty, new Binding ("DetailColor")); dataTemplate.SetBinding (ImageCell.ImageSourceProperty, new Binding ("Image", converter: stringToImageSourceConverter)); Random rand = new Random(250); var albums = new [] { "crimsonsmall.jpg", "oasissmall.jpg", "cover1small.jpg" }; var label = new Label { Text = "I have not been selected" }; var listView = new ListView { AutomationId = "ImageCellListView", ItemsSource = Enumerable.Range (0, 100).Select (i => new ImageCellTest { Text = "Text " + i, TextColor = i % 2 == 0 ? Color.Red : Color.Blue, Detail = "Detail " + i, DetailColor = i % 2 == 0 ? Color.Red : Color.Blue, Image = albums[rand.Next(0,3)] }), ItemTemplate = dataTemplate }; listView.ItemSelected += (sender, args) => label.Text = "I was selected"; Content = new StackLayout { Children = { label, listView } }; }
static void UpdateChildMargin(Panel panel, Thickness? oldValue = null) { var childrenWithoutExplicitMargin = panel.Children .OfType<FrameworkElement>() .Where(x => MarginNotSet(x, oldValue)); var margin = GetMargin(panel) ?? DependencyProperty.UnsetValue; foreach (var child in childrenWithoutExplicitMargin) { child.SetValue(FrameworkElement.MarginProperty, margin); } }
/// <summary> /// Gets borders coordinates of current Map's view in form of LocationRectangle. /// </summary> /// <param name="thickness">Offset of map's view for adjusting borders.</param> public static LocationRectangle GetBounds(this Map map, Thickness thickness) { var topLeft = map.ConvertViewportPointToGeoCoordinate(new Point(thickness.Left, thickness.Top)); var topRight = map.ConvertViewportPointToGeoCoordinate(new Point(map.ActualWidth - thickness.Right, thickness.Top)); var bottomRight = map.ConvertViewportPointToGeoCoordinate(new Point(map.ActualWidth - thickness.Right, map.ActualHeight - thickness.Bottom)); var bottomLeft = map.ConvertViewportPointToGeoCoordinate(new Point(thickness.Left, map.ActualHeight - thickness.Bottom)); if ((topLeft != null) && (topRight != null) && (bottomRight != null) && (bottomLeft != null)) { return LocationRectangle.CreateBoundingRectangle(topLeft, topRight, bottomRight, bottomLeft); } return null; }
public DynamoTextBox(string initialText) { //turn off the border Background = clear; BorderThickness = new Thickness(1); GotFocus += OnGotFocus; LostFocus += OnLostFocus; LostKeyboardFocus += OnLostFocus; Padding = new Thickness(3); base.Text = initialText; this.Pending = false; Style = (Style)SharedDictionaryManager.DynamoModernDictionary["SZoomFadeTextBox"]; MinHeight = 20; }
/// <summary> /// Implemented to linearly interpolate between the baseValue and the /// Value of this KeyFrame using the keyFrameProgress. /// </summary> protected override Thickness InterpolateValueCore(Thickness baseValue, double keyFrameProgress) { if (keyFrameProgress == 0.0) { return baseValue; } else if (keyFrameProgress == 1.0) { return Value; } else { return AnimatedTypeHelpers.InterpolateThickness(baseValue, Value, keyFrameProgress); } }
public button() { Padding = new Thickness(4); MinWidth = 120; }
public void Create(Canvas p, Thickness m) { Create(p); }
static void CreateBar(Canvas p) { if (PSB.canA != null) { return; } Canvas can = new Canvas(); PSB.canA = can; p.Children.Add(can); can = new Canvas(); p.Children.Add(can); PSB.canB = can; can.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)); can.Width = screenW; can.Height = 70; can.Margin = new Thickness(0, screenH - 70, 0, 0); ProgressBar pb = new ProgressBar(); pb.PointerReleased += ProgressChange; pb.Background = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0)); pb.Foreground = new SolidColorBrush(Color.FromArgb(128, 0, 250, 18)); pb.Width = screenW; pb.Height = 5; pb.Margin = new Thickness(0, 20, 0, 0); can.Children.Add(pb); PSB.progress = pb; SymbolIcon flag = new SymbolIcon(); flag.Symbol = Symbol.Flag; flag.Foreground = new SolidColorBrush(Colors.OrangeRed); can.Children.Add(flag); PSB.flag = flag; SymbolIcon si = new SymbolIcon(); si.Symbol = Symbol.Pause; si.PointerPressed += Pause; PSB.play = si; can.Children.Add(si); Thickness tk = new Thickness(); tk.Top = 30; tk.Left = 10; tk.Top = 40; si.Margin = tk; si = new SymbolIcon(); si.Symbol = Symbol.Volume; si.PointerReleased += volume_released; PSB.volume = si; can.Children.Add(si); tk.Left += 30; si.Margin = tk; Slider s = new Slider(); s.Visibility = Visibility.Collapsed; s.ValueChanged += slider_change; s.Width = 100; PSB.slider = s; can.Children.Add(s); s.Margin = tk; TextBlock tb = new TextBlock(); tb.Foreground = Component.title_brush; tk.Left += 80; tb.Margin = tk; can.Children.Add(tb); PSB.title = tb; can = new Canvas(); p.Children.Add(can); can.Background = Component.trans_brush; PSB.bor = can; can.Width = screenW; can.Height = screenH; can.PointerPressed += (o, e) => { time = DateTime.Now.Ticks; PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); sx = pp.Position; sst = PSB.flag.Margin.Left; }; can.PointerMoved += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); if (pp.IsInContact) { double ox = pp.Position.X - sx.X; Thickness t = PSB.flag.Margin; t.Left = sst + ox; if (t.Left < 0) { t.Left = 0; } if (t.Left > screenX) { t.Left = screenX; } PSB.flag.Margin = t; } }; can.PointerReleased += (o, e) => { if (DateTime.Now.Ticks - time < presstime) { if (PSB.canB.Visibility == Visibility.Visible) { PSB.canB.Visibility = Visibility.Collapsed; PSB.bor.Width = screenW; PSB.bor.Height = screenH; } else { PSB.canB.Visibility = Visibility.Visible; PSB.bor.Width = screenW; PSB.bor.Height = screenH - 70; } } else { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); double ox = pp.Position.X - sx.X; X = sst + ox; if (X < 0) { X = 0; } if (X > screenX) { X = screenX; } Jump(); } }; }
private void mitPrint_Click(object sender, RoutedEventArgs e) { //this will print the report int intCurrentRow = 0; int intCounter; int intColumns; int intNumberOfRecords; try { PrintDialog pdProblemReport = new PrintDialog(); if (pdProblemReport.ShowDialog().Value) { FlowDocument fdProjectReport = new FlowDocument(); Thickness thickness = new Thickness(50, 50, 50, 50); fdProjectReport.PagePadding = thickness; pdProblemReport.PrintTicket.PageOrientation = System.Printing.PageOrientation.Landscape; //Set Up Table Columns Table ProjectReportTable = new Table(); fdProjectReport.Blocks.Add(ProjectReportTable); ProjectReportTable.CellSpacing = 0; intColumns = TheCrewHoursDataSet.crewhours.Columns.Count; fdProjectReport.ColumnWidth = 10; fdProjectReport.IsColumnWidthFlexible = false; for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++) { ProjectReportTable.Columns.Add(new TableColumn()); } ProjectReportTable.RowGroups.Add(new TableRowGroup()); //Title row ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); TableRow newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Employee Labor Report for Crew ID " + gstrCrewID)))); newTableRow.Cells[0].FontSize = 25; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[0].ColumnSpan = intColumns; newTableRow.Cells[0].TextAlignment = TextAlignment.Center; newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Date Range " + Convert.ToString(gdatStartDate) + " Thru " + Convert.ToString(gdatEndDate))))); newTableRow.Cells[0].FontSize = 18; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[0].ColumnSpan = intColumns; newTableRow.Cells[0].TextAlignment = TextAlignment.Center; newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Total Hours Of " + Convert.ToString(gdecTotalHours))))); newTableRow.Cells[0].FontSize = 18; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[0].ColumnSpan = intColumns; newTableRow.Cells[0].TextAlignment = TextAlignment.Center; newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); //Header Row ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Transaction ID")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Project ID")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Project Name")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("First Name")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Last Name")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Home Office")))); newTableRow.Cells.Add(new TableCell(new Paragraph(new Run("Hours")))); newTableRow.Cells[0].Padding = new Thickness(0, 0, 0, 10); //newTableRow.Cells[0].ColumnSpan = 1; //newTableRow.Cells[1].ColumnSpan = 1; //newTableRow.Cells[2].ColumnSpan = 1; //newTableRow.Cells[3].ColumnSpan = 2; //newTableRow.Cells[4].ColumnSpan = 1; //Format Header Row for (intCounter = 0; intCounter < intColumns; intCounter++) { newTableRow.Cells[intCounter].FontSize = 16; newTableRow.Cells[intCounter].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[intCounter].BorderBrush = Brushes.Black; newTableRow.Cells[intCounter].TextAlignment = TextAlignment.Center; newTableRow.Cells[intCounter].BorderThickness = new Thickness(); } intNumberOfRecords = TheCrewHoursDataSet.crewhours.Rows.Count; //Data, Format Data for (int intReportRowCounter = 0; intReportRowCounter < intNumberOfRecords; intReportRowCounter++) { ProjectReportTable.RowGroups[0].Rows.Add(new TableRow()); intCurrentRow++; newTableRow = ProjectReportTable.RowGroups[0].Rows[intCurrentRow]; for (int intColumnCounter = 0; intColumnCounter < intColumns; intColumnCounter++) { newTableRow.Cells.Add(new TableCell(new Paragraph(new Run(TheCrewHoursDataSet.crewhours[intReportRowCounter][intColumnCounter].ToString())))); newTableRow.Cells[intColumnCounter].FontSize = 12; newTableRow.Cells[0].FontFamily = new FontFamily("Times New Roman"); newTableRow.Cells[intColumnCounter].BorderBrush = Brushes.LightSteelBlue; newTableRow.Cells[intColumnCounter].BorderThickness = new Thickness(0, 0, 0, 1); newTableRow.Cells[intColumnCounter].TextAlignment = TextAlignment.Center; //if (intColumnCounter == 3) //{ //newTableRow.Cells[intColumnCounter].ColumnSpan = 2; //} } } //Set up page and print fdProjectReport.ColumnWidth = pdProblemReport.PrintableAreaWidth; fdProjectReport.PageHeight = pdProblemReport.PrintableAreaHeight; fdProjectReport.PageWidth = pdProblemReport.PrintableAreaWidth; pdProblemReport.PrintDocument(((IDocumentPaginatorSource)fdProjectReport).DocumentPaginator, "Crew Labor Report"); intCurrentRow = 0; } } catch (Exception Ex) { TheMessagesClass.ErrorMessage(Ex.ToString()); TheEventLogClass.InsertEventLogEntry(DateTime.Now, "Blue Jay ERP // Find Employee Crew Assignment // Print Button " + Ex.Message); } }
//------------------------------------------------------------------- // // Private Methods // //------------------------------------------------------------------- #region Private Methods // Helper function to add up the left and right size as width, as well as the top and bottom size as height private static Size HelperCollapseThickness(Thickness th) { return(new Size(th.Left + th.Right, th.Top + th.Bottom)); }
/// <summary> /// In addition to the child, Border renders a background + border. The background is drawn inside the border. /// </summary> protected override void OnRender(DrawingContext dc) { bool useLayoutRounding = this.UseLayoutRounding; DpiScale dpi = GetDpi(); if (_useComplexRenderCodePath) { Brush brush; StreamGeometry borderGeometry = BorderGeometryCache; if (borderGeometry != null && (brush = BorderBrush) != null) { dc.DrawGeometry(brush, null, borderGeometry); } StreamGeometry backgroundGeometry = BackgroundGeometryCache; if (backgroundGeometry != null && (brush = Background) != null) { dc.DrawGeometry(brush, null, backgroundGeometry); } } else { Thickness border = BorderThickness; Brush borderBrush; CornerRadius cornerRadius = CornerRadius; double outerCornerRadius = cornerRadius.TopLeft; // Already validated that all corners have the same radius bool roundedCorners = !DoubleUtil.IsZero(outerCornerRadius); // If we have a brush with which to draw the border, do so. // NB: We double draw corners right now. Corner handling is tricky (bevelling, &c...) and // we need a firm spec before doing "the right thing." (greglett, ffortes) if (!border.IsZero && (borderBrush = BorderBrush) != null) { // Initialize the first pen. Note that each pen is created via new() // and frozen if possible. Doing this avoids the pen // being copied when used in the DrawLine methods. Pen pen = LeftPenCache; if (pen == null) { pen = new Pen(); pen.Brush = borderBrush; if (useLayoutRounding) { pen.Thickness = UIElement.RoundLayoutValue(border.Left, dpi.DpiScaleX); } else { pen.Thickness = border.Left; } if (borderBrush.IsFrozen) { pen.Freeze(); } LeftPenCache = pen; } double halfThickness; if (border.IsUniform) { halfThickness = pen.Thickness * 0.5; // Create rect w/ border thickness, and round if applying layout rounding. Rect rect = new Rect(new Point(halfThickness, halfThickness), new Point(RenderSize.Width - halfThickness, RenderSize.Height - halfThickness)); if (roundedCorners) { dc.DrawRoundedRectangle( null, pen, rect, outerCornerRadius, outerCornerRadius); } else { dc.DrawRectangle( null, pen, rect); } } else { // Nonuniform border; stroke each edge. if (DoubleUtil.GreaterThan(border.Left, 0)) { halfThickness = pen.Thickness * 0.5; dc.DrawLine( pen, new Point(halfThickness, 0), new Point(halfThickness, RenderSize.Height)); } if (DoubleUtil.GreaterThan(border.Right, 0)) { pen = RightPenCache; if (pen == null) { pen = new Pen(); pen.Brush = borderBrush; if (useLayoutRounding) { pen.Thickness = UIElement.RoundLayoutValue(border.Right, dpi.DpiScaleX); } else { pen.Thickness = border.Right; } if (borderBrush.IsFrozen) { pen.Freeze(); } RightPenCache = pen; } halfThickness = pen.Thickness * 0.5; dc.DrawLine( pen, new Point(RenderSize.Width - halfThickness, 0), new Point(RenderSize.Width - halfThickness, RenderSize.Height)); } if (DoubleUtil.GreaterThan(border.Top, 0)) { pen = TopPenCache; if (pen == null) { pen = new Pen(); pen.Brush = borderBrush; if (useLayoutRounding) { pen.Thickness = UIElement.RoundLayoutValue(border.Top, dpi.DpiScaleY); } else { pen.Thickness = border.Top; } if (borderBrush.IsFrozen) { pen.Freeze(); } TopPenCache = pen; } halfThickness = pen.Thickness * 0.5; dc.DrawLine( pen, new Point(0, halfThickness), new Point(RenderSize.Width, halfThickness)); } if (DoubleUtil.GreaterThan(border.Bottom, 0)) { pen = BottomPenCache; if (pen == null) { pen = new Pen(); pen.Brush = borderBrush; if (useLayoutRounding) { pen.Thickness = UIElement.RoundLayoutValue(border.Bottom, dpi.DpiScaleY); } else { pen.Thickness = border.Bottom; } if (borderBrush.IsFrozen) { pen.Freeze(); } BottomPenCache = pen; } halfThickness = pen.Thickness * 0.5; dc.DrawLine( pen, new Point(0, RenderSize.Height - halfThickness), new Point(RenderSize.Width, RenderSize.Height - halfThickness)); } } } // Draw background in rectangle inside border. Brush background = Background; if (background != null) { // Intialize background Point ptTL, ptBR; if (useLayoutRounding) { ptTL = new Point(UIElement.RoundLayoutValue(border.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(border.Top, dpi.DpiScaleY)); if (FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness) { ptBR = new Point(UIElement.RoundLayoutValue(RenderSize.Width - border.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(RenderSize.Height - border.Bottom, dpi.DpiScaleY)); } else { ptBR = new Point(RenderSize.Width - UIElement.RoundLayoutValue(border.Right, dpi.DpiScaleX), RenderSize.Height - UIElement.RoundLayoutValue(border.Bottom, dpi.DpiScaleY)); } } else { ptTL = new Point(border.Left, border.Top); ptBR = new Point(RenderSize.Width - border.Right, RenderSize.Height - border.Bottom); } // Do not draw background if the borders are so large that they overlap. if (ptBR.X > ptTL.X && ptBR.Y > ptTL.Y) { if (roundedCorners) { Radii innerRadii = new Radii(cornerRadius, border, false); // Determine the inner edge radius double innerCornerRadius = innerRadii.TopLeft; // Already validated that all corners have the same radius dc.DrawRoundedRectangle(background, null, new Rect(ptTL, ptBR), innerCornerRadius, innerCornerRadius); } else { dc.DrawRectangle(background, null, new Rect(ptTL, ptBR)); } } } } }
public bool PointInsideControl(Point pos, double actualWidth, double actualHeight, Thickness margin) => pos.X > 0 - margin.Left && pos.X < actualWidth + margin.Right && (pos.Y > 0 - margin.Top && pos.Y < actualHeight + margin.Bottom);
/// <summary> /// Constructor /// </summary> public PointingDeviceInputModeToMarginConverter() { MouseMargin = new Thickness(); TouchMargin = new Thickness(); }
public static T Margin <T>(this T view, Thickness thickness) where T : View { view.Margin = thickness; return(view); }
public MyMenu() { Padding = new Thickness(0, 20, 0, 20); InitializeComponent(); }
public void Init() { var groupLabel = new Label { Text = "Is group by color" }; var groupSwitch = new Switch(); var groupLayout = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { groupSwitch, groupLabel } }; var groupLabel1 = new Label { Text = "Is group by tags" }; var groupSwitch1 = new Switch(); var groupLayout1 = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { groupSwitch1, groupLabel1 } }; var findInput = new Entry { Text = "", Margin = new Thickness( 0, 10, 0, 0) }; var newNoteButton = new Button { Text = "New note" }; var findLayer = new StackLayout { Children = { findInput, newNoteButton } }; var header = new Label { Text = "Notes", FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), HorizontalOptions = LayoutOptions.Center, Padding = new Thickness(0, 10) }; var notes = _noteService.GetNotes(); var listNotesView = UpdateView(groupSwitch, groupSwitch1, header, notes); listNotesView.ItemTapped += OnItemTapped; newNoteButton.Clicked += NewNote; groupSwitch.Toggled += (sender, args) => { if ((sender as Switch).IsToggled) { groupSwitch1.IsToggled = false; } Find(sender, args); }; groupSwitch1.Toggled += (sender, args) => { if ((sender as Switch).IsToggled) { groupSwitch.IsToggled = false; } Find(sender, args); }; findInput.TextChanged += Find; void Find(object sender, EventArgs e) { var findItems = _noteService.Find(findInput.Text); var view = UpdateView(groupSwitch, groupSwitch1, header, findItems); listNotesView.IsGroupingEnabled = view.IsGroupingEnabled; listNotesView.ItemsSource = view.ItemsSource; listNotesView.GroupDisplayBinding = view.GroupDisplayBinding; } Padding = new Thickness(10, 0, 10, 0); Content = new StackLayout { Children = { findLayer, groupLayout, groupLayout1, listNotesView } }; }
private void SetEllipseOffset(double width) { EllipseOffset = new Thickness(0, width / 2, 0, 0); }
public FirstPage() { const string entryTextPaceHolder = "Enter text and click 'Go'"; var viewModel = new FirstPageViewModel(); BindingContext = viewModel; _goButton = new StyledButton(Borders.Thin, 1) { Text = "Go", AutomationId = AutomationIdConstants.GoButton, // This provides an ID that can be referenced in UITests }; _goButton.SetBinding <FirstPageViewModel>(Button.CommandProperty, vm => vm.GoButtonTapped); var textEntry = new StyledEntry(1) { Placeholder = entryTextPaceHolder, AutomationId = AutomationIdConstants.TextEntry, // This provides an ID that can be referenced in UITests PlaceholderColor = Color.FromHex("749FA8"), ReturnType = ReturnType.Go }; textEntry.Completed += (sender, e) => viewModel?.GoButtonTapped?.Execute(null); textEntry.SetBinding <FirstPageViewModel>(Entry.TextProperty, vm => vm.EntryText); var textLabel = new StyledLabel { AutomationId = AutomationIdConstants.TextLabel, // This provides an ID that can be referenced in UITests HorizontalOptions = LayoutOptions.Center }; textLabel.SetBinding <FirstPageViewModel>(Label.TextProperty, vm => vm.LabelText); _listPageButton = new StyledButton(Borders.Thin, 1) { Text = "Go to List Page", AutomationId = AutomationIdConstants.ListViewButton // This provides an ID that can be referenced in UITests }; var activityIndicator = new ActivityIndicator { AutomationId = AutomationIdConstants.BusyActivityIndicator, // This provides an ID that can be referenced in UITests Color = Color.White }; activityIndicator.SetBinding <FirstPageViewModel>(ActivityIndicator.IsVisibleProperty, vm => vm.IsActiityIndicatorRunning); activityIndicator.SetBinding <FirstPageViewModel>(ActivityIndicator.IsRunningProperty, vm => vm.IsActiityIndicatorRunning); var stackLayout = new StackLayout { Children = { textEntry, _goButton, activityIndicator, textLabel, }, VerticalOptions = LayoutOptions.StartAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand }; var relativeLayout = new RelativeLayout(); relativeLayout.Children.Add(stackLayout, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width - 20); }), Constraint.RelativeToParent((parent) => { return(parent.Height / 2); }) ); relativeLayout.Children.Add(_listPageButton, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.Constant(250), Constraint.RelativeToParent((parent) => { return(parent.Width - 20); }) ); Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); Title = "First Page"; Content = relativeLayout; }
// Verified public CarriagesVM() { // Инициализация контекста БД dbContext = AppDBContext.GetInstance(); dbContext.CarriagesMs.Load(); // Margin Thickness temp = new Thickness(5); // Назначение свойств пачке контролов // Лэйбл "Модель", назначение текста, строки и колонки в Grid Model = new TextBlock(); Model.SetResourceReference(TextBlock.TextProperty, "Text_Model"); Grid.SetRow(Model, 0); Grid.SetColumn(Model, 0); // Лэйбл "Тип", назначение текста, строки и колонки в Grid Type = new TextBlock(); Type.SetResourceReference(TextBlock.TextProperty, "Text_Type"); Grid.SetRow(Type, 1); Grid.SetColumn(Type, 0); // Лэйбл "Вес", назначение текста, строки и колонки в Grid Weight = new TextBlock(); Weight.SetResourceReference(TextBlock.TextProperty, "Text_Weight"); Grid.SetRow(Weight, 2); Grid.SetColumn(Weight, 0); // Лэйбл "Разрешённая ММ", назначение текста, строки и колонки в Grid MaxLoadWeight = new TextBlock(); MaxLoadWeight.SetResourceReference(TextBlock.TextProperty, "Text_MaxLoadWeight"); Grid.SetRow(MaxLoadWeight, 3); Grid.SetColumn(MaxLoadWeight, 0); // Лэйбл "Средняя скорость 100", назначение текста, строки и колонки в Grid MaxSeats = new TextBlock(); MaxSeats.SetResourceReference(TextBlock.TextProperty, "Text_MaxSeats"); MaxSeats.TextWrapping = 0; Grid.SetRow(MaxSeats, 4); Grid.SetColumn(MaxSeats, 0); // Лэйбл "Средняя скорость 0", назначение текста, строки и колонки в Grid CarriageClass = new TextBlock(); CarriageClass.SetResourceReference(TextBlock.TextProperty, "Text_Class"); Grid.SetRow(CarriageClass, 5); Grid.SetColumn(CarriageClass, 0); // Текстбокс "Модель", назначение отсутпа (Margin), строки и колонки в Grid model = new TextBox(); model.Margin = temp; Grid.SetRow(model, 0); Grid.SetColumn(model, 1); // Комбобокс "Тип", назначение отсутпа (Margin), строки и колонки в Grid type = new ComboBox(); type.Margin = temp; Grid.SetRow(type, 1); Grid.SetColumn(type, 1); int lastSelectedIndex = -1; type.SelectionChanged += new SelectionChangedEventHandler((sender, e) => { if (type.SelectedIndex == 0) { carriageClass.IsEnabled = true; maxSeats.IsEnabled = true; carriageClass.SelectedIndex = lastSelectedIndex; return; } // Сохранение выбранного состояния lastSelectedIndex = carriageClass.SelectedIndex; carriageClass.SelectedIndex = -1; carriageClass.IsEnabled = false; maxSeats.IsEnabled = false; }); // Текстбокс "Вес", назначение отсутпа (Margin), строки и колонки в Grid weight = new TextBox(); weight.Margin = temp; Grid.SetRow(weight, 2); Grid.SetColumn(weight, 1); // Текстбокс "Разрешённая ММ", назначение отсутпа (Margin), строки и колонки в Grid maxLoadWeight = new TextBox(); maxLoadWeight.Margin = temp; Grid.SetRow(maxLoadWeight, 3); Grid.SetColumn(maxLoadWeight, 1); // Текстбокс "Разрешённая ММ", назначение отсутпа (Margin), строки и колонки в Grid maxSeats = new TextBox(); maxSeats.Margin = temp; Grid.SetRow(maxSeats, 4); Grid.SetColumn(maxSeats, 1); // Комбобокс "Тип", назначение отсутпа (Margin), строки и колонки в Grid carriageClass = new ComboBox(); carriageClass.Margin = temp; Grid.SetRow(carriageClass, 5); Grid.SetColumn(carriageClass, 1); // Вытягивание полов из ресурсов string cargoCarriage = (string)App.Current.Resources["Text_CargoCarriage"]; string passCarriage = (string)App.Current.Resources["Text_PassengerCarriage"]; string restCarriage = (string)App.Current.Resources["Text_RestauranCarriage"]; // Назначение элементов комбобокс type.Items.Insert(0, passCarriage); type.Items.Insert(1, restCarriage); type.Items.Insert(2, cargoCarriage); type.SelectedIndex = 0; // Вытягивание полов из ресурсов string classCompartment = (string)App.Current.Resources["Text_ClassCompartment"]; string classEconom = (string)App.Current.Resources["Text_ClassEconom"]; string classSeated = (string)App.Current.Resources["Text_ClassSeated"]; // Назначение элементов комбобокс carriageClass.Items.Insert(0, classCompartment); carriageClass.Items.Insert(1, classEconom); carriageClass.Items.Insert(2, classSeated); carriageClass.SelectedIndex = 0; // Инициализация списка элементов БД SourceList = dbContext.CarriagesMs.Local.ToBindingList(); }
public void AddResults(List <Result> newRawResults, string resultId) { lock (_resultsUpdateLock) { var newResults = newRawResults.Select(r => new ResultViewModel(r)).ToList(); // todo use async to do new result calculation var resultsCopy = Results.ToList(); var oldResults = resultsCopy.Where(r => r.RawResult.PluginID == resultId).ToList(); // intersection of A (old results) and B (new newResults) var intersection = oldResults.Intersect(newResults).ToList(); // remove result of relative complement of B in A foreach (var result in oldResults.Except(intersection)) { resultsCopy.Remove(result); } // update scores foreach (var result in newResults) { if (IsTopMostResult(result.RawResult)) { result.RawResult.Score = int.MaxValue; } } // update index for result in intersection of A and B foreach (var commonResult in intersection) { int oldIndex = resultsCopy.IndexOf(commonResult); int oldScore = resultsCopy[oldIndex].RawResult.Score; int newScore = newResults[newResults.IndexOf(commonResult)].RawResult.Score; if (newScore != oldScore) { var oldResult = resultsCopy[oldIndex]; oldResult.RawResult.Score = newScore; resultsCopy.RemoveAt(oldIndex); int newIndex = InsertIndexOf(newScore, resultsCopy); resultsCopy.Insert(newIndex, oldResult); } } // insert result in relative complement of A in B foreach (var result in newResults.Except(intersection)) { int newIndex = InsertIndexOf(result.RawResult.Score, resultsCopy); resultsCopy.Insert(newIndex, result); } // update UI in one run, so it can avoid UI flickering Results.Update(resultsCopy); if (Results.Count > 0) { Margin = new Thickness { Top = 8 }; SelectedResult = Results[0]; } else { Margin = new Thickness { Top = 0 }; } } }
public AllClientBillingReportPrinter(DataGrid documentSource, string documentTitle, Size pageSize, Thickness pageMargin) { _tableColumnDefinitions = new Collection <ColumnDefinition>(); _documentSource = documentSource; _tableColumnDefinitions = new Collection <ColumnDefinition>(); _documentSource = documentSource; this.DocumentTitle = documentTitle; this.PageSize = pageSize; this.PageMargin = pageMargin; if (_documentSource != null) { MeasureElements(); } }
public Tip() { HorizontalOptions = LayoutOptions.Center; VerticalOptions = LayoutOptions.Center; #region members = new Dictionary <string, Variable> { { "Width", new FVariable { ongetvalue = () => new Gnumber(Width), onsetvalue = (value) => { WidthRequest = Convert.ToDouble(value); return(0); } } }, { "Height", new FVariable { ongetvalue = () => new Gnumber(Height), onsetvalue = (value) => { HeightRequest = Convert.ToDouble(value); return(0); } } }, { "Horizontal", new FVariable { ongetvalue = () => new Gstring(HorizontalOptions.ToString()), onsetvalue = (value) => { if (value.ToString() == "center") { HorizontalOptions = LayoutOptions.Center; } else if (value.ToString() == "left") { HorizontalOptions = LayoutOptions.Start; } else if (value.ToString() == "right") { HorizontalOptions = LayoutOptions.End; } else if (value.ToString() == "stretch") { HorizontalOptions = LayoutOptions.Fill; } return(0); } } }, { "Vertical", new FVariable { ongetvalue = () => new Gstring(VerticalOptions.ToString()), onsetvalue = (value) => { if (value.ToString() == "center") { VerticalOptions = LayoutOptions.Center; } else if (value.ToString() == "bottom") { VerticalOptions = LayoutOptions.End; } else if (value.ToString() == "stretch") { VerticalOptions = LayoutOptions.Fill; } else if (value.ToString() == "top") { VerticalOptions = LayoutOptions.Start; } return(0); } } }, { "Margin", new FVariable { ongetvalue = () => new Glist { new Variable(Margin.Left), new Variable(Margin.Top), new Variable(Margin.Right), new Variable(Margin.Bottom) }, onsetvalue = (value) => { var list = value.IGetCSValue() as Glist; Margin = new Thickness( Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value) ); return(0); } } }, { "Visibility", new FVariable { ongetvalue = () => { string s = "null"; switch (IsVisible) { case true: s = "visiable"; break; case false: s = "gone"; break; } return(new Gstring(s)); }, onsetvalue = (value) => { if (value.ToString() == "gone") { IsVisible = false; } else if (value.ToString() == "hidden") { IsVisible = false; } else if (value.ToString() == "visible") { IsVisible = true; } return(0); } } }, { "Text", new FVariable { ongetvalue = () => new Gstring(Text.ToString()), onsetvalue = (value) => { Text = value.ToString(); return(0); } } }, { "FontSize", new FVariable { ongetvalue = () => new Gnumber(FontSize), onsetvalue = (value) => { FontSize = Convert.ToDouble(value); return(0); } } }, { "Padding", new FVariable { ongetvalue = () => new Glist { new Variable(Padding.Left), new Variable(Padding.Top), new Variable(Padding.Right), new Variable(Padding.Bottom) }, onsetvalue = (value) => { var list = value.IGetCSValue() as Glist; Padding = new Thickness( Convert.ToDouble(list[0].value), Convert.ToDouble(list[1].value), Convert.ToDouble(list[2].value), Convert.ToDouble(list[3].value) ); return(0); } } }, { "Background", new FVariable { ongetvalue = () => new Gstring(BackgroundColor.ToString()), onsetvalue = (value) => { BackgroundColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(value.ToString()); return(0); } } }, { "Foreground", new FVariable { ongetvalue = () => new Gstring(TextColor.ToString()), onsetvalue = (value) => { TextColor = (Color) new ColorTypeConverter().ConvertFromInvariantString(value.ToString()); return(0); } } }, }; parent = new GTXAM.Control(this); #endregion }
void WriteParagraphProperties() { DependencyObject parent; TextPointer position; position = _textpointer; position = position.GetNextContextPosition(LogicalDirection.Forward); parent = position.Parent; _openxmlwriter.WriteStartElement("w:pPr"); //ver 1.2 Numbering if ((listLevel > 0) && (listContext != 0)) { //Case : This is the 1st paragraph in a list item WriteListProperty(); //Add vertical spacing before this paragraph if its listlevel different from the previous list if (lastListLevel != listLevel) { //Handle Vertical Spacing _openxmlwriter.WriteStartElement("w:spacing"); _openxmlwriter.WriteAttributeString("w:before", "180"); _openxmlwriter.WriteEndElement(); } //can WordProcessingML handle the case when justification is "center" with bullet/numbering present //and with the bullet not centered with the text ? TextAlignment ta = (TextAlignment)parent.GetValue(Block.TextAlignmentProperty); WriteTextAlignmentProperty(ta); listContext = 0; } else if ((listLevel > 0) && (listContext == 0)) { //Case : This is not the 1st paragraph in a list item //but will still be indented int xx = 720 * listLevel; _openxmlwriter.WriteStartElement("w:ind"); _openxmlwriter.WriteAttributeString("w:left", xx.ToString()); _openxmlwriter.WriteEndElement(); //Add vertical spacing before this paragraph if its listlevel different from the previous list if (lastListLevel != listLevel) { //Handle Vertical Spacing _openxmlwriter.WriteStartElement("w:spacing"); _openxmlwriter.WriteAttributeString("w:before", "180"); _openxmlwriter.WriteEndElement(); } TextAlignment ta = (TextAlignment)parent.GetValue(Block.TextAlignmentProperty); WriteTextAlignmentProperty(ta); } else { TextAlignment ta = (TextAlignment)parent.GetValue(Block.TextAlignmentProperty); WriteTextAlignmentProperty(ta); //Handle Vertical Spacing Thickness mx = (Thickness)parent.GetValue(Block.MarginProperty); WriteMarginProperty(mx); double indent = (double)parent.GetValue(Paragraph.TextIndentProperty); WriteTextIndentProperty(indent); } _openxmlwriter.WriteEndElement(); lastListLevel = listLevel; }
public void ReSize(Thickness m) { Resize(); }
internal void ForceUpdateGroupHeader(ListViewItem listViewItem, KeyValuePair <IGroupHeader, ExpressionAnimationItem> item) { GeneralTransform gt = listViewItem.TransformToVisual(this); var rect = gt.TransformBounds(new Rect(0, 0, listViewItem.ActualWidth, listViewItem.ActualHeight)); groupHeaderDelta = item.Key.Height; //add delta,so that it does not look like suddenly var itemMargin = new Thickness(0, rect.Top - groupHeaderDelta - defaultListViewItemMargin.Top, 0, 0); RectangleGeometry itemClip = null; Visibility itemVisibility = Visibility.Collapsed; if (itemMargin.Top < 0) { var clipHeight = groupHeaderDelta + itemMargin.Top; //moving header has part in viewport if (clipHeight > 0) { itemVisibility = Visibility.Visible; itemClip = new RectangleGeometry() { Rect = new Rect(0, -itemMargin.Top, this.ActualWidth, clipHeight) }; } //moving header not in viewport else { itemVisibility = Visibility.Collapsed; itemClip = null; } } else if (itemMargin.Top + groupHeaderDelta > this.ActualHeight) { var clipHeight = groupHeaderDelta - (groupHeaderDelta + itemMargin.Top - this.ActualHeight); //moving header has part in viewport if (clipHeight > 0) { itemVisibility = Visibility.Visible; itemClip = new RectangleGeometry() { Rect = new Rect(0, 0, this.ActualWidth, clipHeight) }; } //moving header not in viewport else { itemVisibility = Visibility.Collapsed; itemClip = null; } } //moving header all in viewport else { itemVisibility = Visibility.Visible; itemClip = null; } if (currentTopGroupHeader != null) { var delta = currentTopGroupHeader.ActualHeight - (itemMargin.Top); if (delta > 0) { currentTopGroupHeader.Margin = new Thickness(0, -delta, 0, 0); currentTopGroupHeader.Clip = new RectangleGeometry() { Rect = new Rect(0, delta, currentTopGroupHeader.ActualWidth, currentTopGroupHeader.ActualHeight) }; if (delta >= groupHeaderDelta) { currentTopGroupHeader.Visibility = Visibility.Visible; currentTopGroupHeader.Margin = new Thickness(0); currentTopGroupHeader.Clip = null; currentTopGroupHeader.DataContext = item.Key; } } } ExpressionAnimationItem expressionItem = item.Value; expressionItem.StopAnimation(); item.Value.VisualElement.Margin = itemMargin; expressionItem.VisualElement.Clip = itemClip; expressionItem.VisualElement.Visibility = itemVisibility; if (expressionItem.ScrollViewer == null) { expressionItem.ScrollViewer = scrollViewer; } expressionItem.StartAnimation(true); }
private void HandleItemsInItemsPanel(bool isIntermediate, KeyValuePair <IGroupHeader, ExpressionAnimationItem> item, ListViewItem listViewItem) { GeneralTransform gt = listViewItem.TransformToVisual(this); var rect = gt.TransformBounds(new Rect(0, 0, listViewItem.ActualWidth, listViewItem.ActualHeight)); groupHeaderDelta = item.Key.Height; //add delta,so that it does not look like suddenly var itemMargin = new Thickness(0, rect.Top - groupHeaderDelta - defaultListViewItemMargin.Top, 0, 0); RectangleGeometry itemClip = null; Visibility itemVisibility = Visibility.Collapsed; if (itemMargin.Top < 0) { var clipHeight = groupHeaderDelta + itemMargin.Top; //moving header has part in viewport if (clipHeight > 0) { itemVisibility = Visibility.Visible; itemClip = new RectangleGeometry() { Rect = new Rect(0, -itemMargin.Top, this.ActualWidth, clipHeight) }; } //moving header not in viewport else { itemVisibility = Visibility.Collapsed; itemClip = null; } } else if (itemMargin.Top + groupHeaderDelta > this.ActualHeight) { var clipHeight = groupHeaderDelta - (groupHeaderDelta + itemMargin.Top - this.ActualHeight); //moving header has part in viewport if (clipHeight > 0) { itemVisibility = Visibility.Visible; itemClip = new RectangleGeometry() { Rect = new Rect(0, 0, this.ActualWidth, clipHeight) }; } //moving header not in viewport else { itemVisibility = Visibility.Collapsed; itemClip = null; } } //moving header all in viewport else { itemVisibility = Visibility.Visible; itemClip = null; } if (currentTopGroupHeader != null) { var delta = currentTopGroupHeader.ActualHeight - (itemMargin.Top); if (delta > 0) { currentTopGroupHeader.Margin = new Thickness(0, -delta, 0, 0); currentTopGroupHeader.Clip = new RectangleGeometry() { Rect = new Rect(0, delta, currentTopGroupHeader.ActualWidth, currentTopGroupHeader.ActualHeight) }; if (delta >= groupHeaderDelta) { currentTopGroupHeader.Visibility = Visibility.Visible; currentTopGroupHeader.Margin = new Thickness(0); currentTopGroupHeader.Clip = null; currentTopGroupHeader.DataContext = item.Key; } } } bool isInViewport = false; if (itemMargin.Top > 0) { var groupheaderRect = new Rect(0, itemMargin.Top, this.ActualWidth, groupHeaderDelta); isInViewport = (groupheaderRect.Top < this.ActualHeight && groupheaderRect.Bottom > 0); } if (!isInViewport) { ClearTempElement(item); } if (!item.Value.IsActive) { // isIntermediate is false or groupheaderRect has into view port and view not changing if (!isIntermediate || (isInViewport && !isViewChanging)) { ExpressionAnimationItem expressionItem = item.Value; expressionItem.StopAnimation(); item.Value.TempElement.Margin = new Thickness(0); item.Value.TempElement.Clip = null; item.Value.TempElement.Visibility = Visibility.Collapsed; item.Value.VisualElement.Margin = itemMargin; item.Value.VisualElement.Clip = itemClip; item.Value.VisualElement.Visibility = itemVisibility; if (expressionItem.ScrollViewer == null) { expressionItem.ScrollViewer = scrollViewer; } expressionItem.StartAnimation(true); } //temp use else if (isInViewport) { item.Value.TempElement.Margin = itemMargin; item.Value.TempElement.Clip = itemClip; item.Value.TempElement.Visibility = itemVisibility; } } //use active animation else { if (item.Value.VisualElement.Clip != itemClip || item.Value.VisualElement.Visibility != itemVisibility) { ExpressionAnimationItem expressionItem = item.Value; expressionItem.StopAnimation(); if (!isIntermediate) { item.Value.VisualElement.Margin = itemMargin; } //item.Value.VisualElement.Margin = itemMargin; expressionItem.VisualElement.Clip = itemClip; expressionItem.VisualElement.Visibility = itemVisibility; if (expressionItem.ScrollViewer == null) { expressionItem.ScrollViewer = scrollViewer; } expressionItem.StartAnimation(!isIntermediate); } } }
protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); ListViewItem listViewItem = element as ListViewItem; listViewItem.SizeChanged -= ListViewItem_SizeChanged; if (listViewItem.Tag == null) { defaultListViewItemMargin = listViewItem.Margin; } if (groupCollection != null) { var index = IndexFromContainer(element); var group = groupCollection.GroupHeaders.FirstOrDefault(x => x.FirstIndex == index || x.LastIndex == index); if (group != null) { if (groupheaders.ContainsKey(group) && groupheaders[group] != listViewItem) { groupheaders[group].Margin = defaultListViewItemMargin; } groupheaders[group] = listViewItem; if (!groupDic.ContainsKey(group)) { ContentControl groupheader = CreateGroupHeader(group); ContentControl tempGroupheader = CreateGroupHeader(group); ExpressionAnimationItem expressionAnimationItem = new ExpressionAnimationItem(); expressionAnimationItem.VisualElement = groupheader; expressionAnimationItem.TempElement = tempGroupheader; groupDic[group] = expressionAnimationItem; var temp = new Dictionary <IGroupHeader, ExpressionAnimationItem>(); foreach (var keyValue in groupDic.OrderBy(x => x.Key.FirstIndex)) { temp[keyValue.Key] = keyValue.Value; } groupDic = temp; if (groupHeadersCanvas != null) { groupHeadersCanvas.Children.Add(groupheader); groupHeadersCanvas.Children.Add(tempGroupheader); groupheader.Measure(new Windows.Foundation.Size(this.ActualWidth, this.ActualHeight)); group.Height = groupheader.DesiredSize.Height; groupheader.Height = tempGroupheader.Height = group.Height; groupheader.Width = tempGroupheader.Width = this.ActualWidth; if (group.FirstIndex == index) { listViewItem.Tag = listViewItem.Margin; listViewItem.Margin = GetItemMarginBaseOnDeafult(groupheader.DesiredSize.Height); listViewItem.SizeChanged += ListViewItem_SizeChanged; } groupheader.Visibility = Visibility.Collapsed; tempGroupheader.Visibility = Visibility.Collapsed; UpdateGroupHeaders(); } } else { if (group.FirstIndex == index) { listViewItem.Tag = listViewItem.Margin; listViewItem.Margin = GetItemMarginBaseOnDeafult(group.Height); listViewItem.SizeChanged += ListViewItem_SizeChanged; } else { listViewItem.Margin = defaultListViewItemMargin; } } } else { listViewItem.Margin = defaultListViewItemMargin; } } else { listViewItem.Margin = defaultListViewItemMargin; } }
static void CreateBar(Canvas p) { if (PSB.canA != null) { return; } Canvas can = new Canvas(); PSB.canA = can; p.Children.Add(can); can = new Canvas(); p.Children.Add(can); PSB.canB = can; can.Background = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)); can.Width = screenW; can.Height = 70; can.Margin = new Thickness(0, screenH - 70, 0, 0); ProgressBar pb = new ProgressBar(); pb.PointerReleased += ProgressChange; pb.Background = new SolidColorBrush(Color.FromArgb(64, 255, 0, 0)); pb.Foreground = new SolidColorBrush(Color.FromArgb(128, 0, 250, 18)); pb.Width = screenW; pb.Height = 5; pb.Margin = new Thickness(0, 20, 0, 0); can.Children.Add(pb); PSB.progress = pb; SymbolIcon flag = new SymbolIcon(); flag.Symbol = Symbol.Flag; flag.Foreground = new SolidColorBrush(Colors.OrangeRed); can.Children.Add(flag); PSB.flag = flag; SymbolIcon si = new SymbolIcon(); si.Symbol = Symbol.Pause; si.PointerPressed += Pause; PSB.play = si; can.Children.Add(si); Thickness tk = new Thickness(); tk.Top = 30; tk.Left = 10; tk.Top = 40; si.Margin = tk; si = new SymbolIcon(); si.Symbol = Symbol.Volume; si.PointerReleased += volume_released; PSB.volume = si; can.Children.Add(si); tk.Left += 30; si.Margin = tk; Slider s = new Slider(); s.Visibility = Visibility.Collapsed; s.ValueChanged += slider_change; s.Width = 100; PSB.slider = s; can.Children.Add(s); s.Margin = tk; ComboBox cb = new ComboBox(); cb.SelectionChanged += (o, e) => { ChangeSharp((o as ComboBox).SelectedIndex); }; PSB.sharp = cb; can.Children.Add(cb); tk.Left += 140; cb.Margin = tk; cb = new ComboBox(); cb.SelectionChanged += (o, e) => { ChangSite((o as ComboBox).SelectedIndex); }; PSB.site = cb; can.Children.Add(cb); tk.Left += 80; cb.Margin = tk; TextBlock tb = new TextBlock(); tb.Foreground = title_brush; tk.Left += 80; tb.Margin = tk; can.Children.Add(tb); PSB.title = tb; can = new Canvas(); p.Children.Add(can); can.Background = trans_brush; PSB.bor = can; can.Width = screenW; can.Height = screenH; can.PointerPressed += (o, e) => { time = DateTime.Now.Ticks; PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); sx = pp.Position; ss = PSB.flag.Margin.Left; }; can.PointerMoved += (o, e) => { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); if (pp.IsInContact) { double ox = pp.Position.X - sx.X; Thickness t = PSB.flag.Margin; double x = ss + ox; if (x < 0) { x = 0; } if (x > screenX) { x = screenX; } t.Left = x; PSB.flag.Margin = t; x /= screenX; x *= vic.alltime; int h = (int)x / 3600; int se = (int)x % 3600; int min = se / 60; se %= 60; string st = h.ToString() + ":" + min.ToString() + ":" + se.ToString(); Main.Notify(st, font_brush, trans_brush, 1000); } }; can.PointerReleased += (o, e) => { if (DateTime.Now.Ticks - time < presstime) { if (PSB.canB.Visibility == Visibility.Visible) { PSB.canB.Visibility = Visibility.Collapsed; PSB.bor.Width = screenW; PSB.bor.Height = screenH; } else { PSB.canB.Visibility = Visibility.Visible; PSB.bor.Width = screenW; PSB.bor.Height = screenH - 70; } } else { PointerPoint pp = PointerPoint.GetCurrentPoint(e.Pointer.PointerId); double ox = pp.Position.X - sx.X; X = ss + ox; if (X < 0) { X = 0; } if (X > screenX) { X = screenX; } Jump(); } }; }
public Geometry GetLineMarkerGeometry(SnapshotSpan bufferSpan, bool clipToViewport, Thickness padding) => GetMarkerGeometry(bufferSpan, clipToViewport, padding, true);
public PersonDialog() { InitializeComponent(); Width = 400; SizeToContent = SizeToContent.Height; WindowStartupLocation = WindowStartupLocation.CenterOwner; var spacing = new Thickness(5); Padding = spacing; grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); var firstNameLabel = new Label { Content = "First Name:", Margin = spacing }; grid.Children.Add(firstNameLabel); Grid.SetColumn(firstNameLabel, 0); Grid.SetRow(firstNameLabel, 0); var firstNameTextBox = new TextBox { Margin = spacing, VerticalContentAlignment = VerticalAlignment.Center }; grid.Children.Add(firstNameTextBox); Grid.SetColumn(firstNameTextBox, 1); Grid.SetRow(firstNameTextBox, 0); var lastNameLabel = new Label { Content = "Last Name:", Margin = spacing }; grid.Children.Add(lastNameLabel); Grid.SetColumn(lastNameLabel, 0); Grid.SetRow(lastNameLabel, 1); var lastNameTextBox = new TextBox { Margin = spacing, VerticalContentAlignment = VerticalAlignment.Center }; grid.Children.Add(lastNameTextBox); Grid.SetColumn(lastNameTextBox, 1); Grid.SetRow(lastNameTextBox, 1); var countryLabel = new Label { Content = "Country:", Margin = spacing }; grid.Children.Add(countryLabel); Grid.SetColumn(countryLabel, 0); Grid.SetRow(countryLabel, 2); var countryTextBox = new TextBox { Margin = spacing, VerticalContentAlignment = VerticalAlignment.Center }; grid.Children.Add(countryTextBox); Grid.SetColumn(countryTextBox, 1); Grid.SetRow(countryTextBox, 2); var cityLabel = new Label { Content = "City:", Margin = spacing }; grid.Children.Add(cityLabel); Grid.SetColumn(cityLabel, 0); Grid.SetRow(cityLabel, 3); var cityTextBox = new TextBox { Margin = spacing, VerticalContentAlignment = VerticalAlignment.Center }; grid.Children.Add(cityTextBox); Grid.SetColumn(cityTextBox, 1); Grid.SetRow(cityTextBox, 3); var streetNameLabel = new Label { Content = "Street Name:", Margin = spacing }; grid.Children.Add(streetNameLabel); Grid.SetColumn(streetNameLabel, 0); Grid.SetRow(streetNameLabel, 4); var streetNameTextBox = new TextBox { Margin = spacing, VerticalContentAlignment = VerticalAlignment.Center }; grid.Children.Add(streetNameTextBox); Grid.SetColumn(streetNameTextBox, 1); Grid.SetRow(streetNameTextBox, 4); var streetNumberLabel = new Label { Content = "Street Number:", Margin = spacing }; grid.Children.Add(streetNumberLabel); Grid.SetColumn(streetNumberLabel, 0); Grid.SetRow(streetNumberLabel, 5); var streetNumberTextBox = new TextBox { Margin = spacing, VerticalContentAlignment = VerticalAlignment.Center }; grid.Children.Add(streetNumberTextBox); Grid.SetColumn(streetNumberTextBox, 1); Grid.SetRow(streetNumberTextBox, 5); var button = new Button { Content = "OK", IsDefault = true, Margin = spacing, Padding = spacing }; grid.Children.Add(button); Grid.SetColumnSpan(button, 2); Grid.SetRow(button, 6); button.Click += (sender, args) => { PersonFirstName = firstNameTextBox.Text; PersonLastName = lastNameTextBox.Text; AddressCountry = countryTextBox.Text; AddressCity = cityTextBox.Text; AddressStreetName = streetNameTextBox.Text; try { AddressStreetNumber = byte.Parse(streetNumberTextBox.Text); DialogResult = true; } catch { MessageBox.Show("Please enter a valid street number."); Keyboard.Focus(streetNumberTextBox); streetNumberTextBox.SelectAll(); } }; PreviewKeyDown += (sender, args) => { if (args.Key == Key.Escape) { Close(); } }; Loaded += (sender, args) => { // Restrict window to actual height, effectively preventing vertical resizing. MinHeight = MaxHeight = ActualHeight; Keyboard.Focus(firstNameTextBox); }; }
/// <summary> /// 设置标题栏边距 /// </summary> /// <param name="element"></param> /// <param name="value"></param> public static void SetTitlePadding(DependencyObject element, Thickness value) => element.SetValue(TitlePaddingProperty, value);
/// <summary> /// Border computes the position of its single child and applies its child's alignments to the child. /// /// </summary> /// <param name="finalSize">The size reserved for this element by the parent</param> /// <returns>The actual ink area of the element, typically the same as finalSize</returns> protected override Size ArrangeOverride(Size finalSize) { Thickness borders = BorderThickness; if (this.UseLayoutRounding && !FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness) { DpiScale dpi = GetDpi(); borders = new Thickness(UIElement.RoundLayoutValue(borders.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borders.Top, dpi.DpiScaleY), UIElement.RoundLayoutValue(borders.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(borders.Bottom, dpi.DpiScaleY)); } Rect boundRect = new Rect(finalSize); Rect innerRect = HelperDeflateRect(boundRect, borders); // arrange child UIElement child = Child; if (child != null) { Rect childRect = HelperDeflateRect(innerRect, Padding); child.Arrange(childRect); } CornerRadius radii = CornerRadius; Brush borderBrush = BorderBrush; bool uniformCorners = AreUniformCorners(radii); // decide which code path to execute. complex (geometry path based) rendering // is used if one of the following is true: // 1. there are non-uniform rounded corners _useComplexRenderCodePath = !uniformCorners; if (!_useComplexRenderCodePath && borderBrush != null) { SolidColorBrush originIndependentBrush = borderBrush as SolidColorBrush; bool uniformBorders = borders.IsUniform; _useComplexRenderCodePath = // 2. the border brush is origin dependent (the only origin independent brush is a solid color brush) (originIndependentBrush == null) // 3. the border brush is semi-transtarent solid color brush AND border thickness is not uniform // (for uniform semi-transparent border Border.OnRender draws rectangle outline - so it works fine) || ((originIndependentBrush.Color.A < 0xff) && !uniformBorders) // 4. there are rounded corners AND the border thickness is not uniform || (!DoubleUtil.IsZero(radii.TopLeft) && !uniformBorders); } if (_useComplexRenderCodePath) { Radii innerRadii = new Radii(radii, borders, false); StreamGeometry backgroundGeometry = null; // calculate border / background rendering geometry if (!DoubleUtil.IsZero(innerRect.Width) && !DoubleUtil.IsZero(innerRect.Height)) { backgroundGeometry = new StreamGeometry(); using (StreamGeometryContext ctx = backgroundGeometry.Open()) { GenerateGeometry(ctx, innerRect, innerRadii); } backgroundGeometry.Freeze(); BackgroundGeometryCache = backgroundGeometry; } else { BackgroundGeometryCache = null; } if (!DoubleUtil.IsZero(boundRect.Width) && !DoubleUtil.IsZero(boundRect.Height)) { Radii outerRadii = new Radii(radii, borders, true); StreamGeometry borderGeometry = new StreamGeometry(); using (StreamGeometryContext ctx = borderGeometry.Open()) { GenerateGeometry(ctx, boundRect, outerRadii); if (backgroundGeometry != null) { GenerateGeometry(ctx, innerRect, innerRadii); } } borderGeometry.Freeze(); BorderGeometryCache = borderGeometry; } else { BorderGeometryCache = null; } } else { BackgroundGeometryCache = null; BorderGeometryCache = null; } return(finalSize); }
public static T Padding <T>(this T layout, Thickness thickness) where T : Layout { layout.Padding = thickness; return(layout); }
public bool Equals([AllowNull] Step other) { if (other == null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return((Color == other.Color && Color != null && other.Color != null && Color.Equals(other.Color)) && (Line == other.Line && Line != null && other.Line != null && Line.Equals(other.Line)) && (Thickness == other.Thickness && Thickness != null && other.Thickness != null && Thickness.Equals(other.Thickness)) && (Equals(Range, other.Range) || Range != null && other.Range != null && Range.SequenceEqual(other.Range)) && (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) && (TemplateItemName == other.TemplateItemName && TemplateItemName != null && other.TemplateItemName != null && TemplateItemName.Equals(other.TemplateItemName))); }
private static bool IsThicknessValid(object value) { Thickness t = (Thickness)value; return(t.IsValid(false, false, false, false)); }