本文整理汇总了C#中System.Windows.Controls.Control类的典型用法代码示例。如果您正苦于以下问题:C# Control类的具体用法?C# Control怎么用?C# Control使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Control类属于System.Windows.Controls命名空间,在下文中一共展示了Control类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIsSendingMouseWheelEventToParent
/// <summary>
/// Gets the IsSendingMouseWheelEventToParent for a given <see cref="TextBox"/>.
/// </summary>
/// <param name="control">
/// The <see cref="TextBox"/> whose IsSendingMouseWheelEventToParent is to be retrieved.
/// </param>
/// <returns>
/// The IsSendingMouseWheelEventToParent, or <see langword="null"/>
/// if no IsSendingMouseWheelEventToParent has been set.
/// </returns>
public static bool? GetIsSendingMouseWheelEventToParent(Control control)
{
if (control == null)
throw new ArgumentNullException("");
return control.GetValue(ScrollProperty) as bool?;
}
示例2: TemplatedAdorner
/// <summary>
/// Initializes a new instance of the <see cref="TemplatedAdorner"/> class.
/// </summary>
/// <param name="adornedElement">The adorned element.</param>
/// <param name="dataContext">The data context.</param>
/// <param name="adornerTemplate">The adorner template.</param>
public TemplatedAdorner(UIElement adornedElement, object dataContext, ControlTemplate adornerTemplate)
: base(adornedElement)
{
_child = new Control {Template = adornerTemplate};
DataContext = dataContext;
AddVisualChild(_child);
}
示例3: Activate
public void Activate(Control Container) {
Container.ContextMenu = this;
Container.ContextMenu.IsEnabled = true;
Container.ContextMenu.PlacementTarget = Container;
Container.ContextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
Container.ContextMenu.IsOpen = true;
}
示例4: GetCulture
/// <summary>
/// Gets spell checking culture of the specified control.
/// </summary>
/// <param name="control">
/// The control.
/// </param>
/// <returns>
/// The spell checking culture.
/// </returns>
/// <exception cref="ArgumentNullException">
/// The <paramref name="control"/> parameter is null.
/// </exception>
public static CultureInfo GetCulture(Control control)
{
if (control == null)
throw new ArgumentNullException("control");
return (CultureInfo)control.GetValue(CultureProperty);
}
示例5: Verify
public static void Verify(Control control)
{
using (addAdditionalInfo())
{
Approvals.Verify(new ImageWriter(f => WpfUtils.ScreenCapture(control, f)));
}
}
示例6: CreateViewModel
/// <summary>
/// Create viewmodel objects for each view.
/// </summary>
public object CreateViewModel(Control control, string queryString)
{
object result = null;
if (control is WpUI.MainPage)
result = App.ViewModel.MainPageViewModel;
else if (control is Views.Login)
result = new ViewModels.Login();
else if (control is Views.ProjectDetails)
result = new ViewModels.ProjectDetail(queryString);
else if (control is Views.ProjectEdit)
result = new ViewModels.ProjectEdit(queryString);
else if (control is Views.ResourceDetails)
result = new ViewModels.ResourceDetail(queryString);
else if (control is Views.ResourceEdit)
result = new ViewModels.ResourceEdit(queryString);
else if (control is Views.RoleListEdit)
result = new ViewModels.RoleListEdit();
else
result = ((NavigationShell)Bxf.Shell.Instance).PendingView.Model;
((NavigationShell)Bxf.Shell.Instance).PendingView = null;
return result;
}
示例7: Run
public override void Run(
IAnimationContext context,
Control control,
TimeSpan duration,
Action<Control> endMethod)
{
var storyboard = new Storyboard();
DoubleAnimation fadeAnimation;
if ( rounds > 1 )
{
fadeAnimation = new DoubleAnimation( startOpacity, endOpacity, new Duration( duration ) );
fadeAnimation.AutoReverse = true;
fadeAnimation.RepeatBehavior = new RepeatBehavior( rounds - 1 );
storyboard.Children.Add( fadeAnimation );
Storyboard.SetTarget( fadeAnimation, control );
Storyboard.SetTargetProperty( fadeAnimation, new PropertyPath( UIElement.OpacityProperty ) );
}
fadeAnimation = new DoubleAnimation( startOpacity, endOpacity, new Duration( duration ) );
fadeAnimation.BeginTime = TimeSpan.FromMilliseconds( duration.TotalMilliseconds * ( rounds - 1 ) * 2 );
storyboard.Children.Add( fadeAnimation );
Storyboard.SetTarget( fadeAnimation, control );
Storyboard.SetTargetProperty( fadeAnimation, new PropertyPath( UIElement.OpacityProperty ) );
if ( endMethod != null )
storyboard.Completed += ( s, a ) => endMethod( control );
storyboard.Begin( control );
}
示例8: TrySetText
private static void TrySetText(Control element, string text)
{
var peer = FrameworkElementAutomationPeer.FromElement(element);
var provider = peer == null ? null : peer.GetPattern(PatternInterface.Value) as IValueProvider;
if (provider != null)
{
provider.SetValue(text);
}
else if (element is TextBox)
{
var textBox = element as TextBox;
textBox.Text = text;
textBox.SelectionStart = text.Length;
}
else if (element is PasswordBox)
{
var passwordBox = element as PasswordBox;
passwordBox.Password = text;
}
else
{
throw new AutomationException("Element does not support SendKeys.", ResponseStatus.UnknownError);
}
// TODO: new parameter - FocusState
element.Focus();
}
示例9: ControlContainer
/// <summary>
/// Initializes a new instance of <see cref="ControlContainer"/> for specified <see cref="Control"/>.
/// </summary>
/// <param name="Control">Control</param>
public ControlContainer(Control Control)
{
if (Control == null) {
throw new ArgumentException("Control cannot be null");
}
this.Control = Control;
}
示例10: InitializeDialogPanel
internal void InitializeDialogPanel(bool modal, Control focusControl)
{
lock (m_Lock)
{
InitializeDialogPanel(modal, focusControl, ApplicationEx.LayoutRoot/*parent*/);
}
}
示例11: ResetStatus
public void ResetStatus(Control[] textBoxes = null, Label[] labels = null)
{
if (_dispatcher.CheckAccess())
{
if (textBoxes != null)
{
foreach (Control t in textBoxes)
{
if (t != null)
t.Background = new SolidColorBrush(Colors.White);
}
}
if (textBoxes != null && labels != null)
{
foreach (Label t in labels)
{
if (t != null)
t.Foreground = new SolidColorBrush(Colors.Black);
}
}
if (_errorText != null)
_errorText.Visibility = Visibility.Hidden;
if (_statusText != null)
_statusText.Visibility = Visibility.Hidden;
}
else
{
_dispatcher.Invoke(new Action(() => ResetStatus(textBoxes, labels)));
}
}
示例12: ScreeenCaptureInStaThread
public static string ScreeenCaptureInStaThread(string received, Control control)
{
Exception caught = null;
var t = new Thread(() =>
{
try
{
ScreenCapture(control, received);
}
catch (Exception e)
{
caught = e;
}
});
t.SetApartmentState(ApartmentState.STA); //Many WPF UI elements need to be created inside STA
t.Start();
t.Join();
if (caught != null)
{
throw new Exception("Creating window failed.", caught);
}
return received;
}
示例13: SetIsSendingMouseWheelEventToParent
/// <summary>
/// Sets the IsSendingMouseWheelEventToParent for a given <see cref="TextBox"/>.
/// </summary>
/// <param name="control">
/// The <see cref="TextBox"/> whose IsSendingMouseWheelEventToParent is to be set.
/// </param>
/// <param name="IsSendingMouseWheelEventToParent">
/// The IsSendingMouseWheelEventToParent to set, or <see langword="null"/>
/// to remove any existing IsSendingMouseWheelEventToParent from <paramref name="control"/>.
/// </param>
public static void SetIsSendingMouseWheelEventToParent(Control control, bool? sendToParent)
{
if (control == null)
throw new ArgumentNullException("");
control.SetValue(ScrollProperty, sendToParent);
}
示例14: SetDefaultPageAttributes
/// <summary>
/// Ustawia domyślne właściwości kontrolek.
/// </summary>
/// <param name="page">Kontrolka.</param>
/// <returns>Kontrolka wzbogacona o domyślne właściwości związane z wyświetlaniem na ekranie.</returns>
protected Control SetDefaultPageAttributes(Control page)
{
page.Margin = new Thickness(0);
page.Height = page.Width = double.NaN;
return page;
}
示例15: getImageFromControl
/// <summary>
/// Convert any control to a PngBitmapEncoder
/// </summary>
/// <param name="controlToConvert">The control to convert to an ImageSource</param>
/// <returns>The returned ImageSource of the controlToConvert</returns>
private static PngBitmapEncoder getImageFromControl(Control controlToConvert)
{
// save current canvas transform
Transform transform = controlToConvert.LayoutTransform;
// get size of control
Size sizeOfControl = new Size(controlToConvert.ActualWidth, controlToConvert.ActualHeight);
// measure and arrange the control
controlToConvert.Measure(sizeOfControl);
// arrange the surface
controlToConvert.Arrange(new Rect(sizeOfControl));
// craete and render surface and push bitmap to it
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((Int32)sizeOfControl.Width, (Int32)sizeOfControl.Height, 96d, 96d, PixelFormats.Pbgra32);
// now render surface to bitmap
renderBitmap.Render(controlToConvert);
// encode png data
PngBitmapEncoder pngEncoder = new PngBitmapEncoder();
// puch rendered bitmap into it
pngEncoder.Frames.Add(BitmapFrame.Create(renderBitmap));
// return encoder
return pngEncoder;
}