Does a Silverlight <Line> need Width and Height defined?
Date : March 29 2020, 07:55 AM
I wish this help you No, you can use one of this templates to define coordinates: X1, X2, Y1, Y2 Canvas.Left, Canvas.Top, Width, Height.
|
Silverlight - how to draw a line with an arc?
Date : March 29 2020, 07:55 AM
it fixes the issue Take a look at drawing Bezier curves ( MSDN Link) and learn about the different geometry types ( MSDN Link) Below is a code sample to get you started that will produce the following image: <Canvas x:Name="LayoutRoot" Background="White">
<Path Stroke="Blue" StrokeThickness="2" >
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure StartPoint="50,50">
<PathFigure.Segments>
<PathSegmentCollection>
<BezierSegment
Point1="50,20"
Point2="120,170"
Point3="350,150"
/>
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
<Path Fill="Gold" Stroke="Black" StrokeThickness="1">
<Path.Data>
<EllipseGeometry Center="50,50" RadiusX="20" RadiusY="20" />
</Path.Data>
</Path>
<Path Fill="Gold" Stroke="Black" StrokeThickness="1">
<Path.Data>
<EllipseGeometry Center="350,150" RadiusX="20" RadiusY="20" />
</Path.Data>
</Path>
</Canvas>
|
Draw line in ComboBox in Silverlight
Date : March 29 2020, 07:55 AM
this will help I see from your code that you didn't set Line's Stroke color. Try setting it to black (and don't forget to add ComboBox to some container): var lineTypeComboBox = new ComboBox
{
Width = 40,
Background = Background,
Margin = new Thickness(0),
Padding = new Thickness(0)
};
lineTypeComboBox.Items.Add(new Line { X1 = 1, X2 = 20, Y1 = 1, Y2 = 20, Stroke = new SolidColorBrush(Colors.Black) });
//add ComboBox to StackPanel
spMain.Children.Add(lineTypeComboBox);
<ComboBox Width="40">
<ComboBox.Resources>
<Style TargetType="Line">
<Setter Property="X1" Value="1" />
<Setter Property="Y1" Value="1" />
<Setter Property="X2" Value="20" />
<Setter Property="Y2" Value="1" />
<Setter Property="Stroke" Value="Black" />
</Style>
</ComboBox.Resources>
<ComboBox.Items>
<ComboBoxItem>
<Line StrokeThickness="1" />
</ComboBoxItem>
<ComboBoxItem>
<Line StrokeThickness="3" />
</ComboBoxItem>
<ComboBoxItem>
<Line StrokeThickness="5" />
</ComboBoxItem>
</ComboBox.Items>
</ComboBox>
|
Draw line with high StrokeThickness in silverlight
Tag : chash , By : Stephen Dewar
Date : March 29 2020, 07:55 AM
this one helps. I have an application where you can draw on a Canvas (like Paint). The C# code looks basically like this: , I think you are going to be charmed with my answer: Point _drawingStart;
bool _isDrawing;
private void startDrawing(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
_drawingStart = e.GetPosition((UIElement)sender);
InitializePath();
_isDrawing = true;
}
private void stopDrawing(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
_isDrawing = false;
}
private void doDrawing(object sender, System.Windows.Input.MouseEventArgs e)
{
if (_isDrawing)
{
AddPoint(e.GetPosition((UIElement)sender));
}
}
private void AddPoint(Point newpoint)
{
LineSegment l = new LineSegment() { Point = newpoint };
pathFigure.Segments.Add(l);
pathFigure.StartPoint = (pathFigure.Segments.First() as LineSegment).Point;
}
PathFigure pathFigure;
Path path;
private void InitializePath()
{
path = new Path()
{
StrokeLineJoin = PenLineJoin.Bevel,
StrokeDashCap = PenLineCap.Round,
StrokeEndLineCap = PenLineCap.Round,
StrokeStartLineCap = PenLineCap.Round,
StrokeThickness = 100.0,
Stroke = new SolidColorBrush(Colors.Red)
};
pathFigure = new PathFigure();
PathGeometry pathGeometry = new PathGeometry();
pathGeometry.Figures = new PathFigureCollection();
pathGeometry.Figures.Add(pathFigure);
path.Data = pathGeometry;
DrawingCanvas.Children.Add(path);
}
|
How to draw dot on touch in the same line (width or height) with other dot?
Tag : android , By : Yolanda N. Ceron
Date : March 29 2020, 07:55 AM
Does that help I have some situation here, I have one screen and when I touch on it drawing a dot on this coordinates, problem is that I want to draw second dot on the same line x or y it depend if we touch under the dot or next to it? Have you got any ideas about that? , Calculate the maximum of the absolute difference of your positions. float deltaX = Math.abs(event.getX()-otherPoint.getX());
float deltaY = Math.abs(event.getY()-otherPoint.getY());
if(Math.max(deltaX , deltaY) == deltaX){
// touched rather to left or to right of the otherPoint
}else{
// touched rather below or above the otherPoint
}
|