本文整理汇总了C#中Line.SetBinding方法的典型用法代码示例。如果您正苦于以下问题:C# Line.SetBinding方法的具体用法?C# Line.SetBinding怎么用?C# Line.SetBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Line
的用法示例。
在下文中一共展示了Line.SetBinding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefaultLegendItemsBuilder
private static IEnumerable<FrameworkElement> DefaultLegendItemsBuilder(IPlotterElement plotterElement)
{
LineGraph lineGraph = (LineGraph)plotterElement;
Line line = new Line { X1 = 0, Y1 = 10, X2 = 20, Y2 = 0, Stretch = Stretch.Fill, DataContext = lineGraph };
line.SetBinding(Line.StrokeProperty, "Stroke");
line.SetBinding(Line.StrokeThicknessProperty, "StrokeThickness");
Legend.SetVisualContent(lineGraph, line);
var legendItem = LegendItemsHelper.BuildDefaultLegendItem(lineGraph);
yield return legendItem;
}
示例2: CreateDifferentlyLookingLegendItem
private IEnumerable<FrameworkElement> CreateDifferentlyLookingLegendItem(IPlotterElement plotterElement)
{
StackPanel host = new StackPanel { Orientation = Orientation.Horizontal };
TextBlock textBlock = new TextBlock();
textBlock.SetBinding(TextBlock.TextProperty, BindingHelper.CreateAttachedPropertyBinding(NewLegend.DescriptionProperty));
host.Children.Add(textBlock);
Line line = new Line { X1 = 0, Y1 = 0, X2 = 20, Y2 = 10, Stretch = Stretch.Fill };
line.SetBinding(Line.StrokeProperty, new Binding("Stroke"));
line.SetBinding(Line.StrokeThicknessProperty, new Binding("StrokeThickness"));
host.Children.Add(line);
host.DataContext = plotterElement;
yield return host;
}
示例3: ChartLabelBase
/// <summary>
/// Creates an instance of ChartLabelBase.
/// </summary>
public ChartLabelBase()
{
DefaultStyleKey = typeof(ChartLabelBase);
IsMovable = true;
SetBinding(ChartLabelBase.ConnectionStrokeProperty, new Binding("Foreground") { Source = this });
_line = new Line();
_line.SetBinding(Line.StrokeProperty, new Binding("ConnectionStroke") { Source = this });
_line.SetBinding(Line.StrokeDashArrayProperty, new Binding("ConnectionStrokeDashArray") { Source = this });
_line.SetBinding(Line.StrokeThicknessProperty, new Binding("ConnectionStrokeThickness") { Source = this });
_line.SetBinding(Line.VisibilityProperty, new Binding("Visibility") { Source = this });
Offset = EmptyPoint;
}
示例4: Create
/// <summary>
/// Creates a vertical dotted line to separate the line numbers from the text view.
/// </summary>
public static UIElement Create(TextEditor editor)
{
Line line = new Line {
X1 = 0, Y1 = 0, X2 = 0, Y2 = 1,
StrokeDashArray = { 0, 2 },
Stretch = Stretch.Fill,
StrokeThickness = 1,
StrokeDashCap = PenLineCap.Round,
Margin = new Thickness(2, 0, 2, 0),
Tag = tag
};
line.SetBinding(
Line.StrokeProperty,
new Binding("LineNumbersForeground") { Source = editor }
);
return line;
}
示例5: BindALine
internal Line BindALine()
{
var l = new Line();
var s = Separator as Separator;
if (s == null) return l;
l.SetBinding(Shape.StrokeProperty,
new Binding {Path = new PropertyPath("Stroke"), Source = s});
try
{
l.SetBinding(Shape.StrokeDashArrayProperty,
new Binding { Path = new PropertyPath("StrokeDashArray"), Source = s });
}
catch (Exception)
{
// temporarily ignore it
}
l.SetBinding(Shape.StrokeThicknessProperty,
new Binding {Path = new PropertyPath("StrokeThickness"), Source = s});
l.SetBinding(VisibilityProperty,
new Binding {Path = new PropertyPath("Visibility"), Source = s});
return l;
}
示例6: DrawWall
private Line DrawWall(int i)
{
Binding bDataContext = new Binding("CurrentLevel.Lvl.Walls[" + i + "]");
Binding bX1 = new Binding("Start.X");
Binding bY1 = new Binding("Start.Y");
Binding bX2 = new Binding("End.X");
Binding bY2 = new Binding("End.Y");
bX1.Converter = scaleConv;
bY1.Converter = scaleConv;
bX2.Converter = scaleConv;
bY2.Converter = scaleConv;
Line l = new Line();
l.SetBinding(Line.DataContextProperty, bDataContext);
l.SetBinding(Line.X1Property, bX1);
l.SetBinding(Line.Y1Property, bY1);
l.SetBinding(Line.X2Property, bX2);
l.SetBinding(Line.Y2Property, bY2);
l.Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 255));
l.StrokeThickness = 5;
rootCanvas.Children.Add(l);
return l;
}
示例7: Initialize
/// <summary>
/// Initializes this instance.
/// </summary>
internal void Initialize()
{
double desiredHeight = 0;
double labelSize = 0;
//if (m_MinValue == m_startValue + m_Interval)
CalculateAutoInterval();
GenerateLabels();
if (this.ActualHeight > 0 && this.ActualWidth > 0)
{
this.Children.Clear();
double xAxisWidthStep = this.ActualWidth / ((MIntervalCount > 0) ? MIntervalCount : 1);
double xAxisWidthPosition = this.DataToPoint(MStartValue);
double minorstep = 0;
//m_offset = this.DataToPoint(m_MinValue + m_Interval);
Rect oldRect = new Rect(0, 0, 0, 0);
AxisLine = new Line();
AxisLine.X1 = 0;
AxisLine.X2 = this.ActualWidth;
AxisLine.Y1 = 0;
AxisLine.Y2 = 0;
Binding binding = new Binding();
binding.Path = new PropertyPath("AxisLineStyle");
binding.Source = this;
AxisLine.SetBinding(Line.StyleProperty, binding);
Labels = new List<ContentControl>();
MajorTickLines = new List<Line>();
MinorTickLines = new List<Line>();
for (int i = 0; i < this.MLabels.Count; i++)
{
ContentControl label = new ContentControl();
label.Content = MLabels[i];
Binding labelTemplateBinding = new Binding();
labelTemplateBinding.Path = new PropertyPath("LabelTemplate");
labelTemplateBinding.Source = this;
label.SetBinding(ContentControl.ContentTemplateProperty, labelTemplateBinding);
label.Measure(new Size(this.ActualHeight, this.ActualWidth));
RotateTransform labelRotation = new RotateTransform();
labelRotation.Angle = LabelAngle;
Rect rotatedRect = GetRotatedRect(new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height), labelRotation);
//label.RenderTransformOrigin = new Point(0.5, 0.5);
label.RenderTransform = labelRotation;
Labels.Add(label);
Line tickLine = new Line();
double labelPadding = 0;
Binding styleBinding = new Binding();
styleBinding.Path = new PropertyPath("MajorLineStyle");
styleBinding.Source = this;
tickLine.SetBinding(Line.StyleProperty, styleBinding);
tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
tickLine.X1 = xAxisWidthPosition - (tickLine.DesiredSize.Width / 2);
tickLine.X2 = xAxisWidthPosition - (tickLine.DesiredSize.Width / 2);
switch (this.MajorTicksPosition)
{
case TickPosition.Inside:
tickLine.Y1 = 0;
Binding tickSizeInsideBinding = new Binding();
tickSizeInsideBinding.Path = new PropertyPath("MajorLineSize");
tickSizeInsideBinding.Source = this;
tickSizeInsideBinding.Converter = new NegativeConverter();
tickLine.SetBinding(Line.Y2Property, tickSizeInsideBinding);
if (this.ShowMajorTicks)
{
labelPadding = 0;
desiredHeight = 0;
}
break;
case TickPosition.Cross:
Binding tickSizeNegativeCrossBinding = new Binding();
tickSizeNegativeCrossBinding.Path = new PropertyPath("MajorLineSize");
tickSizeNegativeCrossBinding.Source = this;
tickSizeNegativeCrossBinding.Converter = new NegativeHalfConverter();
tickLine.SetBinding(Line.Y1Property, tickSizeNegativeCrossBinding);
Binding tickSizeCrossBinding = new Binding();
tickSizeCrossBinding.Path = new PropertyPath("MajorLineSize");
tickSizeCrossBinding.Source = this;
tickSizeCrossBinding.Converter = new HalfValueConverter();
tickLine.SetBinding(Line.Y2Property, tickSizeCrossBinding);
if (this.ShowMajorTicks)
{
labelPadding = tickLine.Y2;
desiredHeight = MajorLineSize / 2;
}
break;
case TickPosition.Outside:
tickLine.Y1 = 0;
Binding tickSizeBinding = new Binding();
tickSizeBinding.Path = new PropertyPath("MajorLineSize");
tickSizeBinding.Source = this;
tickLine.SetBinding(Line.Y2Property, tickSizeBinding);
if (this.ShowMajorTicks)
{
labelPadding = tickLine.Y2;
desiredHeight = MajorLineSize;
//.........这里部分代码省略.........
示例8: BindALine
internal Line BindALine()
{
var l = new Line();
var s = Separator as Separator;
if (s == null) return l;
l.SetBinding(Shape.StrokeProperty,
new Binding {Path = new PropertyPath(Wpf.Separator.StrokeProperty), Source = s});
l.SetBinding(Shape.StrokeDashArrayProperty,
new Binding {Path = new PropertyPath(Wpf.Separator.StrokeDashArrayProperty), Source = s});
l.SetBinding(Shape.StrokeThicknessProperty,
new Binding {Path = new PropertyPath(Wpf.Separator.StrokeThicknessProperty), Source = s});
l.SetBinding(VisibilityProperty,
new Binding {Path = new PropertyPath(VisibilityProperty), Source = s});
return l;
}
示例9: GetTickLine
internal Line GetTickLine()
{
TickElement = new Line();
Binding styleBinding = new Binding();
styleBinding.Source = this;
styleBinding.Path = new PropertyPath("LineStyle");
TickElement.SetBinding(Line.StyleProperty, styleBinding);
return TickElement;
}
示例10: CreateTick
FrameworkElement CreateTick(Point start, Point end)
{
if (TickTemplate == null) {
Line ln = new Line();
ln.SetBinding(Line.StrokeProperty, new System.Windows.Data.Binding("Foreground"));
ln.StrokeThickness = 1.0;
ln.X1 = start.X;
ln.Y1 = start.Y;
ln.X2 = end.X;
ln.Y2 = end.Y;
return ln;
} else {
ContentPresenter cp = new ContentPresenter();
cp.Content = "a";
cp.ContentTemplate = TickTemplate;
cp.SetValue(Canvas.TopProperty, (IsHorizontal ? start.Y : start.Y - cp.ActualHeight / 2 ));
cp.SetValue(Canvas.LeftProperty, (IsHorizontal ? start.X - cp.ActualWidth / 2 : start.X));
return cp;
}
//return null;
}
示例11: DrawGrid
private void DrawGrid()
{
//clear the canvas's children
//WorkBench.Children.Clear();
double gridSpacing = 100.0;
selectionCanvas.UseLayoutRounding = true;
// draw vertical lines on grid
for (double i = 0.0; i < selectionCanvas.ActualWidth; i += gridSpacing)
{
var xLine = new Line();
xLine.Stroke = new SolidColorBrush(Color.FromArgb(255, 180, 180, 180));
xLine.X1 = i;
xLine.Y1 = 0;
xLine.X2 = i;
xLine.Y2 = selectionCanvas.ActualHeight;
xLine.HorizontalAlignment = HorizontalAlignment.Left;
xLine.VerticalAlignment = VerticalAlignment.Center;
xLine.StrokeThickness = 1;
selectionCanvas.Children.Add(xLine);
Line xLine2 = null;
if (i == 0.0)
{
xLine.Stroke = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
xLine2 = new Line();
xLine2.Stroke = new SolidColorBrush(Color.FromArgb(70, 180, 180, 180));
xLine2.HorizontalAlignment = HorizontalAlignment.Left;
xLine2.VerticalAlignment = VerticalAlignment.Center;
xLine2.StrokeThickness = 6;
xLine2.Y1 = xLine.Y1 + 6.5;
xLine2.X1 = xLine.X1 + 3.5;
xLine2.X2 = xLine.X2 + 3.5;
xLine2.Y2 = selectionCanvas.ActualHeight;
xLine2.IsHitTestVisible = false;
selectionCanvas.Children.Add(xLine2);
}
//Dynamo.Controls.DragCanvas.SetCanBeDragged(xLine, false);
xLine.IsHitTestVisible = false;
Binding binding = new Binding()
{
Path = new PropertyPath("FullscreenWatchVisible"),
Converter = new InverseBoolToVisibilityConverter(),
Mode = BindingMode.OneWay,
};
xLine.SetBinding(UIElement.VisibilityProperty, binding);
if (xLine2 != null)
{
xLine2.SetBinding(UIElement.VisibilityProperty, binding);
}
}
// draw horizontal lines on grid
for (double i = 0.0; i < selectionCanvas.ActualHeight; i += gridSpacing)
{
var yLine = new Line();
yLine.Stroke = new SolidColorBrush(Color.FromArgb(255, 180, 180, 180));
yLine.X1 = -0.5;
yLine.Y1 = i;
yLine.X2 = selectionCanvas.ActualWidth;
yLine.Y2 = i;
yLine.HorizontalAlignment = HorizontalAlignment.Left;
yLine.VerticalAlignment = VerticalAlignment.Center;
yLine.StrokeThickness = 1;
selectionCanvas.Children.Add(yLine);
Line yLine2 = null;
if (i == 0.0)
{
yLine.Stroke = new SolidColorBrush(Color.FromArgb(255, 140, 140, 140));
yLine2 = new Line();
yLine2.Stroke = new SolidColorBrush(Color.FromArgb(70, 180, 180, 180));
yLine2.StrokeThickness = 6;
yLine2.X1 = 0;
yLine2.X2 = selectionCanvas.ActualWidth;
yLine2.Y1 = yLine.Y1 + 3.5;
yLine2.Y2 = yLine.Y2 + 3.5;
yLine2.HorizontalAlignment = HorizontalAlignment.Left;
yLine2.VerticalAlignment = VerticalAlignment.Center;
yLine2.IsHitTestVisible = false;
selectionCanvas.Children.Add(yLine2);
}
//Dynamo.Controls.DragCanvas.SetCanBeDragged(yLine, false);
yLine.IsHitTestVisible = false;
Binding binding = new Binding()
{
Path = new PropertyPath("FullscreenWatchVisible"),
Converter = new InverseBoolToVisibilityConverter(),
Mode = BindingMode.OneWay,
};
yLine.SetBinding(UIElement.VisibilityProperty, binding);
//.........这里部分代码省略.........
示例12: UpdateStackPanel
private void UpdateStackPanel()
{
mainStackPanel.Children.Clear();
int longestDescr = 0;
bool empty = true;
foreach (ILegendable l in graphsInLegend) {
if (!l.ShowInLegend) continue;
empty = false;
StackPanel legendItem = new StackPanel();
ToolTip tooltip = new ToolTip() { Content = l.Description};
legendItem.Orientation = Orientation.Horizontal;
Line line = new Line();
line.SetBinding(Line.StrokeProperty, new Binding(){Source =l, Path = new PropertyPath("LineColor")});
line.StrokeThickness = l.LineThickness;
line.X2 = 0; line.Y2 = 0;
line.X1 = 15; line.Y1 = 15;
ToolTipService.SetToolTip(legendItem, tooltip);
legendItem.Children.Add(line);
TextBlock textBlock = new TextBlock();
textBlock.Margin = new Thickness(5.0);
if (l.Description.Length > longestDescr)
longestDescr = l.Description.Length;
if (l.Description.Length > AllowedDescriptionLength+1)
textBlock.Text = String.Format("{0}...", l.Description.Remove(AllowedDescriptionLength));
else
textBlock.Text = l.Description;
Binding bd2 = new Binding();
bd2.Source = l;
bd2.Path = new PropertyPath("Description");
bd2.Mode = BindingMode.OneWay;
textBlock.SetBinding(TextBlock.TextProperty, bd2);
legendItem.Children.Add(textBlock);
//If possible include a checkbox to switch the graph on and off
legendItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
CheckBox c = new CheckBox();
c.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
c.VerticalAlignment = System.Windows.VerticalAlignment.Center;
Binding bd = new Binding();
bd.Source = l;
bd.Path = new PropertyPath("ShowInPlotter");
bd.Mode = BindingMode.TwoWay;
c.SetBinding(CheckBox.IsCheckedProperty, bd);
legendItem.Children.Add(c);
mainStackPanel.Children.Add(legendItem);
}
if (empty)
{
if (Height != 0 && Width != 0)
{
previousSize = new Size(Width, Height);
Width = 0; Height = 0;
}
}
else
{
Width = previousSize.Width;
Height = previousSize.Height;
}
//if(EnableAutomaticDescriptionLength)
//{
// bool changed = false;
// double centralGridWidth = Plotter.CentralGrid.ActualWidth;
// if (centralGridWidth / 3 < ActualWidth)
// {
// changed = true;
// if (AllowedDescriptionLength > longestDescr)
// AllowedDescriptionLength = longestDescr - 3;
// else AllowedDescriptionLength--;
// }
// else if((longestDescr>AllowedDescriptionLength+3)
// && (AllowedDescriptionLength<int.MaxValue-3)
// && centralGridWidth / 2.8 > ActualWidth)
// {
// AllowedDescriptionLength++;
// changed = true;
// }
// if (changed)
// legendable_VisualizationChanged(this, EventArgs.Empty);
//}
}
示例13: OnConnectionCollectionChanged
public static void OnConnectionCollectionChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
IEnumerable<IConnectionViewModel> connectionViewModels = e.NewValue as IEnumerable<IConnectionViewModel>;
Canvas canvas = o as Canvas;
if (connectionViewModels != null && canvas != null)
{
foreach (IConnectionViewModel cvm in connectionViewModels)
{
Line connection = new Line();
connection.DataContext = cvm;
connection.SetBinding(Line.X1Property, new Binding("X1"));
connection.SetBinding(Line.X2Property, new Binding("X2"));
connection.SetBinding(Line.Y1Property, new Binding("Y1"));
connection.SetBinding(Line.Y2Property, new Binding("Y2"));
connection.SetBinding(Line.StrokeProperty, new Binding("Stroke"));
connection.SetBinding(Line.StrokeThicknessProperty, new Binding("Thickness"));
connection.SetBinding(Line.OpacityProperty, new Binding("Opacity"));
connection.SetBinding(Canvas.LeftProperty, new Binding("Left"));
connection.SetBinding(Canvas.TopProperty, new Binding("Top"));
canvas.Children.Add(connection);
}
}
}
示例14: CreateGridLine
private Line CreateGridLine(bool major)
{
Line line = new Line();
line.UseLayoutRounding = true;
line.SetBinding(FrameworkElement.StyleProperty, (BindingBase)new Binding(major ? "MajorGridlineStyle" : "MinorGridlineStyle")
{
Source = (object)this.Axis
});
return line;
}
示例15: CreateLine
/// <summary>
/// Creates a line.
/// </summary>
/// <param name="tangibleObject">The tangible object.</param>
/// <returns>the line.</returns>
static Line CreateLine(TangibleObject tangibleObject)
{
Check.NotNull(tangibleObject, "tangibleObject");
Line topLine = new Line();
topLine.Stroke = new SolidColorBrush(Colors.DarkBlue);
topLine.StrokeThickness = 5;
// Bind properties
Binding x1Binding = new Binding()
{
Source = tangibleObject.TopLine.Point1,
Path = new Windows.UI.Xaml.PropertyPath("X"),
Mode = BindingMode.OneWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
};
topLine.SetBinding(Line.X1Property, x1Binding);
Binding y1Binding = new Binding()
{
Source = tangibleObject.TopLine.Point1,
Path = new Windows.UI.Xaml.PropertyPath("Y"),
Mode = BindingMode.OneWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
};
topLine.SetBinding(Line.Y1Property, y1Binding);
Binding x2Binding = new Binding()
{
Source = tangibleObject.TopLine.Point2,
Path = new Windows.UI.Xaml.PropertyPath("X"),
Mode = BindingMode.OneWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
};
topLine.SetBinding(Line.X2Property, x2Binding);
Binding y2Binding = new Binding()
{
Source = tangibleObject.TopLine.Point2,
Path = new Windows.UI.Xaml.PropertyPath("Y"),
Mode = BindingMode.OneWay,
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
};
topLine.SetBinding(Line.Y2Property, y2Binding);
return topLine;
}