本文整理汇总了C#中System.Windows.Thickness类的典型用法代码示例。如果您正苦于以下问题:C# Thickness类的具体用法?C# Thickness怎么用?C# Thickness使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Thickness类属于System.Windows命名空间,在下文中一共展示了Thickness类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
String Param = parameter as String;
Double Value = (Double)value;
Thickness Margin = new Thickness(0);
if (Param != null)
{
if (Param.Equals(String.Empty))
{
Margin = new Thickness(Value);
}
else
{
String[] sSides = Param.Replace("x", Value.ToString()).Split(',');
Double[] dSides= new Double[sSides.Length];
for (int i = 0; i < sSides.Length; ++i)
dSides[i] = Parse.TryParse<Double>(sSides[i], 0);
switch (sSides.Length)
{
default: break;
case 2:
Margin = new Thickness(dSides[0], dSides[1], dSides[0], dSides[1]);
break;
case 4:
Margin = new Thickness(dSides[0], dSides[1], dSides[2], dSides[3]);
break;
}
}
}
return Margin;
}
示例2: Convert
/// <summary>
/// Convert from A to B.
/// </summary>
/// <param name="pValue">The value to convert.</param>
/// <param name="pTargetType">The target type.</param>
/// <param name="pExtraParameter">The extra parameter to use (not used by the converter).</param>
/// <param name="pCulture">The culture to use (not used by the converter).</param>
/// <returns>The value converted.</returns>
public object Convert(object[] pValue, Type pTargetType, object pExtraParameter, CultureInfo pCulture)
{
if (pValue.Any(lValue => lValue == DependencyProperty.UnsetValue))
{
return Binding.DoNothing;
}
// First value is the port list count, second is the list.
int lPortsCount = System.Convert.ToInt32(pValue[0]);
PortViewModelCollection lPorts = pValue[1] as PortViewModelCollection;
// Evaluating the padding using the ports.
Thickness lPadding = new Thickness();
if (lPorts != null)
{
if (lPorts.Any(lPort => lPort.Direction == PortDirection.Input))
{
lPadding.Left = PORT_WIDTH;
}
if (lPorts.Any(lPort => lPort.Direction == PortDirection.Output))
{
lPadding.Right = PORT_WIDTH;
}
}
return lPadding;
}
示例3: AddGeometries
public static void AddGeometries(WpfHexView hexView, Collection<VSTF.TextBounds> textBounds, bool isLineGeometry, bool clipToViewport, Thickness padding, double minWidth, ref PathGeometry geo, ref bool createOutlinedPath) {
foreach (var bounds in textBounds) {
double left = bounds.Left - padding.Left;
double right = bounds.Right + padding.Right;
double top, bottom;
if (isLineGeometry) {
top = bounds.Top - padding.Top;
bottom = bounds.Bottom + padding.Bottom;
}
else {
top = bounds.TextTop - padding.Top;
bottom = bounds.TextBottom + padding.Bottom;
}
if (right - left < minWidth)
right = left + minWidth;
if (clipToViewport) {
left = Math.Max(left, hexView.ViewportLeft);
right = Math.Min(right, hexView.ViewportRight);
}
if (right <= left || bottom <= top)
continue;
const double MAX_HEIGHT = 1000000;
const double MAX_WIDTH = 1000000;
double width = Math.Min(right - left, MAX_WIDTH);
double height = Math.Min(bottom - top, MAX_HEIGHT);
if (geo == null)
geo = new PathGeometry { FillRule = FillRule.Nonzero };
else
createOutlinedPath = true;
geo.AddGeometry(new RectangleGeometry(new Rect(left, top, width, height)));
}
}
示例4: PrintDocument
public PrintDocument(Thickness margin)
{
PageLayout = new PrintLayout
{
Margin = margin,
};
}
示例5: FileListItem
public FileListItem(string captionText, string imagePath)
: base()
{
Margin = new Thickness(13);
var panel = new StackPanel();
var imageSource = new BitmapImage();
var image = new Image();
var caption = new TextBlock();
imageSource.BeginInit();
imageSource.UriSource = new Uri(imagePath, UriKind.Relative);
imageSource.EndInit();
image.VerticalAlignment = System.Windows.VerticalAlignment.Center;
image.Source = imageSource;
image.Height = 64;
image.Width = 64;
image.ToolTip = "Select & click on 'Table' for data view.";
caption.TextAlignment = TextAlignment.Center;
caption.TextWrapping = TextWrapping.Wrap;
caption.Text = captionText;
Caption = captionText;
if (caption.Text.Length <= 18)
caption.Text += "\n ";
panel.Children.Add(image);
panel.Children.Add(caption);
Child = panel;
}
示例6: UpdateUpBorder
protected virtual void UpdateUpBorder()
{
if (ShowUpBorder)
BorderThickness = new Thickness(BorderThickness.Left, 1, BorderThickness.Right, BorderThickness.Bottom);
else
BorderThickness = new Thickness(BorderThickness.Left, 0, BorderThickness.Right, BorderThickness.Bottom);
}
示例7: ExtendGlassFrame
public static bool ExtendGlassFrame(Window window, Thickness margin)
{
if (!Native.DwmIsCompositionEnabled())
return false;
try
{
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (hwnd == IntPtr.Zero)
throw new InvalidOperationException("The Window must be shown before extending glass.");
// Set the background to transparent from both the WPF and Win32 perspectives
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
Native.MARGINS margins = new Native.MARGINS(margin);
Native.DwmExtendFrameIntoClientArea(hwnd, ref margins);
return true;
}
catch (Exception ex)
{
LogWriter.Log(ex, "Error • Glass");
}
return false;
}
示例8: MARGINS
public MARGINS(Thickness thickness)
{
Left = (int)thickness.Left;
Right = (int)thickness.Right;
Top = (int)thickness.Top;
Bottom = (int)thickness.Bottom;
}
示例9: ExtendGlassFrame
/// <summary>
/// Extends the Aero Glass area on a given window.
/// </summary>
/// <param name="window">The window to extend glass onto.</param>
/// <param name="margin">The distances from the border to extend the glass by.</param>
/// <returns>True if glass was extended successfully, otherwise false.</returns>
public static bool ExtendGlassFrame(Window window, Thickness margin)
{
if (window == null) {
throw new ArgumentNullException("window");
}
bool result = false;
try {
if (DwmIsCompositionEnabled()) {
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if (hwnd == IntPtr.Zero)
throw new InvalidOperationException("The Window must be shown before extending glass.");
// Set the background to transparent from both the WPF and Win32 perspectives
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
result = true;
}
} catch { }
return result;
}
示例10: Dock
public Dock(Canvas parent_canvas)
{
parentCanvas = parent_canvas;
emptyDockContents = new StackPanel();
emptyDockContents.Orientation = Orientation.Horizontal;
emptyDockContents.Margin = new Thickness(5, 5, 5, 5);
TextBox dropToAdd = new TextBox();
dropToAdd.Background = new SolidColorBrush(Colors.Transparent);
dropToAdd.BorderBrush = new SolidColorBrush(Colors.Transparent);
dropToAdd.Text = "Drop Here To Add";
dropToAdd.Foreground = new SolidColorBrush(Colors.White);
dropToAdd.FontSize = 18;
dropToAdd.VerticalAlignment = VerticalAlignment.Center;
emptyDockContents.Children.Add(dropToAdd);
Image iconImage = new Image();
//iconImage.Source = "";// guiConfig.getAddToDockImage();
iconImage.Width = 40;
iconImage.Height = 40;
iconImage.Margin = new Thickness(5,0,5,0);
//emptyDockContents.Children.Add(iconImage);
MinHeight = 80;
MaxHeight = 80;
Background = new SolidColorBrush(Color.FromArgb(200, 0, 0, 0));
BorderBrush = new SolidColorBrush(Colors.White);
BorderThickness = new Thickness(2, 2, 2, 0);
Child = emptyDockContents;
SizeChanged += Dock_SizeChanged;
}
示例11: AppearanceManager
public AppearanceManager(ISettingsManager manager)
{
_manager = manager;
DefaultMargin = new Thickness(0, 0, 0, 2);
DefaultPadding = new Thickness(0, 4, 0, 4);
}
示例12: ExtendGlassFrame
/// <summary>
/// Extends the glass frame.
/// </summary>
/// <param name="window">The window.</param>
/// <param name="margin">The margin.</param>
/// <returns></returns>
public static bool ExtendGlassFrame(Window window, Thickness margin)
{
if(!DwmIsCompositionEnabled()) {
return false;
}
IntPtr hwnd = new WindowInteropHelper(window).Handle;
if(hwnd == IntPtr.Zero) {
throw new InvalidOperationException("The Window must be shown before extending glass.");
}
// Set the background to transparent from both the WPF and Win32 perspectives
SolidColorBrush background = new SolidColorBrush(Colors.Red);
background.Opacity = 0.5;
window.Background = Brushes.Transparent;
HwndSource.FromHwnd(hwnd).CompositionTarget.BackgroundColor = Colors.Transparent;
MARGINS margins = new MARGINS(margin);
DwmExtendFrameIntoClientArea(hwnd, ref margins);
return true;
}
示例13: ThicknessInterpolation
/// <summary>Creates a new <see cref="ThicknessInterpolation"/> instance with the specified parameters.</summary>
/// <param name="interpolator">The interpolation function.</param>
/// <param name="fromValue">The starting value of the animation, or <c>null</c>.</param>
/// <param name="toValue">The ending value of the animation, or <c>null</c>.</param>
/// <param name="isAdditive">Indicates whether the interpolation is additive.</param>
/// <param name="isCumulative">Indicates whether the interpolation is cumulative.</param>
public ThicknessInterpolation(Interpolator interpolator, Thickness? fromValue, Thickness? toValue, bool isAdditive, bool isCumulative) : this() {
Interpolator = interpolator;
if (fromValue.HasValue) base.From = fromValue.Value; else if (isAdditive) base.From = new Thickness();
if (toValue.HasValue) base.To = toValue.Value; else if (isAdditive) base.To = new Thickness();
base.IsAdditive = isAdditive;
base.IsCumulative = isCumulative;
}
示例14: IsNonNegative
internal static bool IsNonNegative(Thickness value)
{
return DoubleUtil.IsNonNegative(value.Left) &&
DoubleUtil.IsNonNegative(value.Top) &&
DoubleUtil.IsNonNegative(value.Right) &&
DoubleUtil.IsNonNegative(value.Bottom);
}
示例15: Margins
public Margins(Thickness t)
{
Left = (int)t.Left;
Right = (int)t.Right;
Top = (int)t.Top;
Bottom = (int)t.Bottom;
}