In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to parse the Shapes namespace in. Net Micro Framework, I believe many inexperienced people are helpless about this, for this reason this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.
In the Microsoft.SPOT.Presentation.Shapes namespace, there are several shape objects, mainly Ellipse, Line, Polygon, Rectangle, and also only the Rectangle implementation of ***, other shapes do not support fill color, although each object has a Fill attribute.
Strangely enough, each shape object can't set left and top coordinates, only width and height, which is very uncomfortable to use.
The StackPanel class is a derivative of Panel, literally a stackable panel. As its name suggests, it can contain multiple sub-objects, but each object cannot overlap and is stacked in a unique way.
There are several attribute methods to control stacking:
Orientation attribute, there are two ways: Orientation.Horizontal, Orientation.Vertical. When this property is set, the coordinate system of the children of StackPanel changes (unfortunately the font orientation does not change fundamentally).
2. HorizontalAlignment and VerticalAlignment attributes set the stacking method of sub-objects. Enumeration is defined as follows.
public enum HorizontalAlignment { Left = 0, Center = 1, Right = 2, Stretch = 3, } public enum VerticalAlignment { Top = 0, Center = 1, Bottom = 2, Stretch = 3, }
3. SetMargin method, which sets the size of the boundary blank.
The complete code is as follows,
using System; using Microsoft.SPOT; using Microsoft.SPOT.Input; using Microsoft.SPOT.Presentation; using Microsoft.SPOT.Presentation.Controls; using Microsoft.SPOT.Presentation.Media; using Microsoft.SPOT.Presentation.Shapes; namespace MFWindow { public class Program : Microsoft.SPOT.Application { public static void Main() { //Create a form WindowsDrawing win = new WindowsDrawing(); //Program running new Program().Run(win); } internal sealed class WindowsDrawing : Window { public WindowsDrawing() { this.Width = SystemMetrics.ScreenWidth; this.Height = SystemMetrics.ScreenHeight; //Display direction can be set (horizontal, vertical) //StackPanel panel = new StackPanel(Orientation.Vertical); StackPanel panel = new StackPanel(Orientation.Horizontal); //set boundary blank panel.SetMargin(10); //Set how objects stack panel.HorizontalAlignment = HorizontalAlignment.Center; panel.VerticalAlignment = VerticalAlignment.Center; this.Child = panel; //add text Text txt = new Text(Resources.GetFont(Resources.FontResources.small), "yefan"); //cannot set left,top coordinates txt.Width = 100; txt.Height = 30; panel.Children.Add(txt); //add different shape objects Shape[] shapes = new Shape[] { new Ellipse(), new Line(), new Polygon(new Int32[] { 0, 0, 10, 0, 10, 10, 0, 10 }), new Rectangle() }; //Set the necessary parameters of the shape object (objects cannot overlap, only stack together) foreach (Shape s in shapes) { s.Fill = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 0)); s.Stroke = new Pen(Color.Black, 2); //cannot set left,top coordinates s.Height = 40; s.Width = 40; panel.Children.Add(s); } } } } }
Just modifying the parameters in StackPanel panel = new StackPanel(Orientation.Horizontal); can achieve two different effects, as shown in the following two figures:
In general, I think the image objects provided by MF are not perfect, not only some basic functions are not completed (such as fill, line width), and the absolute coordinates of shape objects cannot be set (left,top), but also the total class is very few. I hope that there will be great improvements in future versions.
After reading the above, do you know how to parse the Shape namespace in. Net Micro Framework? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.