本文整理汇总了C#中System.Windows.Controls.Border类的典型用法代码示例。如果您正苦于以下问题:C# Border类的具体用法?C# Border怎么用?C# Border使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Border类属于System.Windows.Controls命名空间,在下文中一共展示了Border类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PageHeader
public PageHeader()
{
Brush brush = new SolidColorBrush(Colors.DarkGray);
brush.Opacity = 0.60;
this.Background = brush;
Border frameBorder = new Border();
frameBorder.BorderBrush = Brushes.Gray;
frameBorder.BorderThickness = new Thickness(2);
DockPanel panelMain = new DockPanel();
panelMain.Margin = new Thickness(5, 5, 5, 5);
panelMain.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
txtText = new TextBlock();
txtText.FontSize = 32;
txtText.Margin = new Thickness(5, 0, 0, 0);
txtText.SetResourceReference(TextBlock.ForegroundProperty, "HeaderTextColor");
txtText.VerticalAlignment = System.Windows.VerticalAlignment.Bottom;
panelMain.Children.Add(txtText);
frameBorder.Child = panelMain;
this.Content = frameBorder;
}
示例2: ModifyNewContent
protected override FrameworkElement ModifyNewContent(ITransitionControl container, FrameworkElement newContent)
{
if (newContent == null)
{
HideBackground(container);
container.Remove(_border);
return null;
}
ShowBackground(container);
_border = WrapInBorder(newContent);
_border.Opacity = 0;
SetPosition(_border);
newContent.SizeChanged += (sender, e) => SetPosition(_border);
var ctrl = container.AsControl();
ctrl.SizeChanged += (sender, e) => SetPosition(_border);
return _border;
}
示例3: BorderHitTestTest
public void BorderHitTestTest()
{
Border border = new Border
{
Width = 200,
Height = 100,
BorderThickness = new Thickness(10, 20, 30, 40),
IsRootElement = true,
};
border.Measure(Size.Infinity);
border.Arrange(new Rect(border.DesiredSize));
BackgroundHitTestTest(border, null);
BorderHitTestTest(border, null);
border.Background = Brushes.Transparent;
border.BorderBrush = null;
BackgroundHitTestTest(border, border);
BorderHitTestTest(border, border);
border.Background = null;
border.BorderBrush = Brushes.Transparent;
BackgroundHitTestTest(border, null);
BorderHitTestTest(border, border);
border.Background = Brushes.Transparent;
border.BorderBrush = Brushes.Transparent;
BackgroundHitTestTest(border, border);
BorderHitTestTest(border, border);
}
示例4: CreateWidgetControl
public FrameworkElement CreateWidgetControl(IDiagram widgetViewModel, ContextMenu contextMenu)
{
var buttonHolder = widgetViewModel as DefaultWidgetViewModel;
var brd = new Border
{
DataContext = buttonHolder,
ContextMenu = contextMenu,
BorderBrush = System.Windows.Media.Brushes.Gray,
Background = System.Windows.Media.Brushes.White
};
var ret = new Button { DataContext = buttonHolder, ContextMenu = contextMenu, Content = "New Widget" };
brd.Child = ret;
var heightBinding = new Binding("Height") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var widthBinding = new Binding("Width") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var xBinding = new Binding("X") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var yBinding = new Binding("Y") { Source = buttonHolder, Mode = BindingMode.TwoWay };
var transformBinding = new Binding("RenderTransform") { Source = buttonHolder, Mode = BindingMode.OneWay };
brd.SetBinding(InkCanvas.LeftProperty, xBinding);
brd.SetBinding(InkCanvas.TopProperty, yBinding);
brd.SetBinding(FrameworkElement.HeightProperty, heightBinding);
brd.SetBinding(FrameworkElement.WidthProperty, widthBinding);
brd.SetBinding(UIElement.RenderTransformProperty, transformBinding);
return brd;
}
示例5: KinectDance
public KinectDance(double layoutHeight, double layoutWidth, List<TextBlock> menus, Style mouseOverStyle, Border menuBorder,TextBox debugBox = null)
{
_layoutHeight = layoutHeight;
_layoutWidth = layoutWidth;
_debugBox = debugBox;
_menus = menus;
_menuBorder = menuBorder;
_mouseOverStyle = mouseOverStyle;
_kinect = KinectSensor.KinectSensors.FirstOrDefault();
if (_kinect == null) return;
//_kinect.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
_kinect.Start();
_kinect.ColorStream.Enable();
_kinect.SkeletonStream.Enable(new TransformSmoothParameters
{
Smoothing = 0.7f,
Correction = 0.3f,
Prediction = 0.4f,
JitterRadius = 0.5f,
MaxDeviationRadius = 0.5f
});
_kinect.SkeletonFrameReady += kinect_SkeletonFrameReady;
}
示例6: InitGrid
private void InitGrid()
{
var first = true;
_gridPlace.ColumnDefinitions.Clear();
_gridPlace.RowDefinitions.Clear();
_gridPlace.Width = _place.GetLength(0)*10;
_gridPlace.Height = _place.GetLength(1)*10;
for (var i = 0; i < _place.GetLength(0); i++)
{
_gridPlace.ColumnDefinitions.Add(new ColumnDefinition());
for (var j = 0; j < _place.GetLength(1); j++)
{
if (first) _gridPlace.RowDefinitions.Add(new RowDefinition());
var border = new Border();
border.SetValue(Grid.RowProperty, i);
border.SetValue(Grid.ColumnProperty, j);
border.MouseLeftButtonUp += ChangeToSeat;
border.MouseRightButtonUp += ChangeToTable;
border.Style = _gridPlace.FindResource("Empty") as Style;
_gridPlace.Children.Add(border);
}
first = false;
}
}
示例7: AddDrop
public static FlowDocument AddDrop(this StackPanel sp, Drop drop)
{
FlowDocumentParser fdp = new FlowDocumentParser() { TextAlignment = TextAlignment.Right };
fdp.AddBold(drop.Author.Name + " at " +
String.Format("{0:dd/MM/yyyy HH:mm}", drop.UpdatedAt));
fdp = new FlowDocumentParser(fdp.Doc);
fdp.AddMarkUp(drop.Content);
FlowDocumentScrollViewer fdsv = new FlowDocumentScrollViewer()
{
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
Document = fdp.Doc,
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
Foreground = new SolidColorBrush(Colors.White)
};
Border border = new Border()
{
BorderThickness = new Thickness(0, 5, 0, 5),
CornerRadius = new CornerRadius(10),
Padding = new Thickness(3),
Background = new SolidColorBrush(Colors.Black),
Cursor = Cursors.Hand,
Child = fdsv
};
fdp.Doc.PreviewMouseWheel += Bubbler;
fdsv.PreviewMouseWheel += Bubbler;
fdsv.SizeChanged += Resizer;
sp.Children.Add(border);
return fdp.Doc;
}
示例8: showPopup2_Click
private void showPopup2_Click(object sender, RoutedEventArgs e)
{
if (p.IsOpen == true)
return;
Border border = new Border();
border.BorderBrush = new SolidColorBrush(Colors.White);
border.BorderThickness = new Thickness(2.0);
StackPanel panel1 = new StackPanel();
Button button1 = new Button();
button1.Content = "Close";
button1.Margin = new Thickness(5.0);
button1.Click += new RoutedEventHandler(button1_Click);
TextBlock textblock1 = new TextBlock();
textblock1.Text = "Premi il pulsante Close";
textblock1.Margin = new Thickness(5.0);
panel1.Children.Add(textblock1);
panel1.Children.Add(button1);
border.Child = panel1;
p = new Popup();
// Imposta la proprietà Child con il border che è il contenitore principale che contiene a sua volta uno stackpanel, un textblock ed un button.
p.Child = border;
//imposta la posizione del popup
p.VerticalOffset = 100;
p.HorizontalOffset = 50;
// apre il popup
p.IsOpen = true;
}
示例9: ChangeObjVisibilityWindow
public ChangeObjVisibilityWindow()
{
InitializeComponent();
var mainWin = DesignerMainWindow.GetInstance();
for (int i = 0; i < mainWin.canMainCanvas.Children.Count; i++)
{
UIElement elem = mainWin.canMainCanvas.Children[i];
var obj = elem as IObject;
if (obj == null) continue;
if (obj.Type == ObjectType.Area || obj.Type == ObjectType.DropContainer
|| obj.Type == ObjectType.FlashAnimation || obj.Type == ObjectType.Sound) continue;
var brdr = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(0),
Margin = new Thickness(1, 3, 2, 3),
Width = 110,
Height = 110/1.66667
};
var element = elem as IObject;
IObject copy = element.DeepCopyWithObjectId();
copy.HorizontalAlignment = HorizontalAlignment.Center;
copy.VerticalAlignment = VerticalAlignment.Center;
if (copy.Height > copy.Width)
copy.Height = brdr.Height - 10;
else
copy.Width = brdr.Width - 15;
brdr.Child = copy as UIElement;
lbObjects.Items.Add(brdr);
}
}
示例10: CreateCellContent
// bind cell to ticker
public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range)
{
// create binding for this cell
var r = grid.Rows[range.Row];
var c = grid.Columns[range.Column];
var pi = c.PropertyInfo;
if (r.DataItem is FinancialData &&
(pi.Name == "LastSale" || pi.Name == "Bid" || pi.Name == "Ask"))
{
// create stock ticker cell
StockTicker ticker = new StockTicker();
bdr.Child = ticker;
bdr.Padding = _thicknessEmpty;
// to show sparklines
ticker.Tag = r.DataItem;
ticker.BindingSource = pi.Name;
// traditional binding
var binding = new Binding(pi.Name);
binding.Source = r.DataItem;
binding.Mode = BindingMode.OneWay;
ticker.SetBinding(StockTicker.ValueProperty, binding);
}
else
{
// use default implementation
base.CreateCellContent(grid, bdr, range);
}
}
示例11: WaveGraph
public WaveGraph(Canvas waveGraph, Border waveBorder, float[] soundData, int sampleRate)
{
float max;
int i;
this.waveGraph = waveGraph;
this.waveBorder = waveBorder;
this.soundData = soundData;
this.sampleRate = sampleRate;
max = soundData.Max(element => Math.Abs(element));
createAmplitudeLabels(max);
numberOfSeconds = (soundData.Length / sampleRate);
heightRatio = GRAPH_HEIGHT / (max * 2);
//DrawSecond(PIXEL_SECOND * 0, sampleRate * 0);
for (i = 0; i < numberOfSeconds; i++)
{
createSecondLabel(i);
DrawSecond(PIXEL_SECOND*i, sampleRate*i);
}
//create final second label
createSecondLabel(i);
//adjusts the canvas width based on number of seconds and space between end points
int newCanvasWidth = (numberOfSeconds * PIXEL_SECOND) + (XSTART * 2);
if (newCanvasWidth > canvasWidth)
{
waveBorder.Height += HSCROLLSIZE;
Console.WriteLine(canvasHeight);
waveGraph.Height = canvasHeight;
extendCanvas(newCanvasWidth);
}
//DrawGraph();
}
示例12: AddActor
public void AddActor(string name)
{
var header = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = new Thickness(1),
Margin = new Thickness(5),
CornerRadius = new CornerRadius(3),
Padding = new Thickness(15, 2, 15, 2),
Child = new TextBlock { Text = name },
SnapsToDevicePixels = true,
};
SeqDiagPanel.SetPosition(header,
Position.OneColumn(_column, 0));
LayoutRoot.Children.Add(header);
var line = new Line
{
StrokeThickness = 1,
Y1 = 0,
Y2 = 75,
X1 = 0,
X2 = 0,
MinHeight = 75,
Stroke = Brushes.Black,
Stretch = Stretch.Fill,
SnapsToDevicePixels = true,
};
SeqDiagPanel.SetPosition(line, Position.Body(_column));
LayoutRoot.Children.Add(line);
_column++;
}
示例13: RemovedItemAdorner
public RemovedItemAdorner(UIElement adornedPanel, FrameworkElement adornedElement)
: base(adornedPanel)
{
this.IsHitTestVisible = false;
Width = Math.Ceiling(adornedElement.ActualWidth);
Height = Math.Ceiling(adornedElement.ActualHeight);
var offset = VisualTreeHelper.GetOffset(adornedElement);
_border = new Border
{
Background = new VisualBrush(adornedElement),
Width = adornedElement.ActualWidth,
Height = adornedElement.ActualHeight,
RenderTransform = new TranslateTransform
{
X = offset.X,
Y = offset.Y,
}
};
// HACK: Need to figure out why this doesn't work
_border.Width = 50;
_border.Height = 40;
AddVisualChild(_border);
Loaded += RemovedItemAdorner_Loaded;
}
示例14: PageContent
public PageContent()
{
Brush brush = new SolidColorBrush(Colors.DarkGray);
brush.Opacity = 0.80;
this.Background = brush;
Border frameBorder = new Border();
frameBorder.BorderBrush = Brushes.Gray;
frameBorder.BorderThickness = new Thickness(2);
Grid panelMain = new Grid();
RowDefinition rowDefTop = new RowDefinition();
rowDefTop.Height = new GridLength(90, GridUnitType.Star);
panelMain.RowDefinitions.Add(rowDefTop);
RowDefinition rowDefBottom = new RowDefinition();
rowDefBottom.Height = new GridLength(10, GridUnitType.Star);
panelMain.RowDefinitions.Add(rowDefBottom);
panelContent = new StackPanel();
panelContent.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
panelContent.Margin = new Thickness(10, 10, 10, 10);
Grid.SetRow(panelContent, 0);
panelMain.Children.Add(panelContent);
frameBorder.Child = panelMain;
this.Content = frameBorder;
}
示例15: ShowTutorialHint
public static void ShowTutorialHint()
{
if (Properties.Settings.Default.showtutorial)
{
Properties.Settings.Default.showtutorial = false;
Properties.Settings.Default.Save();
MiscTools.FlashControl(Main.btnTutorial, Colors.Yellow, Main);
var tutHint = new Popup
{
VerticalOffset = -3,
PlacementTarget = Main.btnTutorial,
Placement = PlacementMode.Top,
IsOpen = true
};
var brd = new Border
{
BorderBrush =
new LinearGradientBrush(Colors.LightSlateGray, Colors.Black, .45),
BorderThickness = new Thickness(1),
Background =
new LinearGradientBrush(Colors.LightYellow, Colors.PaleGoldenrod, .25),
Child = new TextBlock
{
Margin = new Thickness(4),
FontSize = 12,
Text = "Click to start a short tutorial on how to use Elinor"
}
};
tutHint.Child = brd;
tutHint.MouseDown += delegate { tutHint.IsOpen = false; };
}
}