本文整理汇总了C#中Contact.GetOrientation方法的典型用法代码示例。如果您正苦于以下问题:C# Contact.GetOrientation方法的具体用法?C# Contact.GetOrientation怎么用?C# Contact.GetOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact.GetOrientation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateOrientationArrow
/// <summary>
/// Rotate the arrow to demonstrate orientation.
/// </summary>
/// <param name="contact">the contact to diagram</param>
private void UpdateOrientationArrow(Contact contact)
{
bool isTag = contact.IsTagRecognized;
UIElement relativeTo = this;
double? contactOrientation = contact.GetOrientation(relativeTo);
// Only show orientation arrow if this contact is recognized as a tag
// and there is orientation data available.
if (isTag && contactOrientation != null)
{
// Show the arrow.
OrientationArrow.Visibility = Visibility.Visible;
// Set the arrow orientation.
ArrowRotateTransform.Angle = (double)contactOrientation;
// Set the arrow position.
Point position = contact.GetPosition(relativeTo);
ArrowTranslateTransform.X = position.X;
ArrowTranslateTransform.Y = position.Y;
}
else
{
// Hide the arrow.
OrientationArrow.Visibility = Visibility.Hidden;
}
}
示例2: addContact
public void addContact(Contact c, Grid parentGrid)
{
if(c.Tag.Type == TagType.Byte)
{
Point p = c.GetPosition(parentGrid);
double orientation = c.GetOrientation(parentGrid);
ContactDescriptor desc = new ContactDescriptor(c.Tag.Byte.Value, (int)p.X, (int) p.Y,(int) (orientation*10.0));
contactDictionary.Add(c, desc);
try
{
deviceInfoDictionary.Add(c.Tag.Byte.Value, new DeviceInformation(c.Tag.Byte.Value, ""));
}catch (Exception e) {
Console.WriteLine("Device With Byte Value %d already in deviceInfoDictionary", c.Tag.Byte.Value);
Console.WriteLine(e.ToString());
}
}
}
示例3: UpdateDescription
/// <summary>
/// Update the text description with the most recent property values. Position
/// the textbox so that it does not go offscreen (outside parentGrid). Also
/// position the connecting line between the contact and the textbox.
/// </summary>
/// <param name="parentGrid">the container for this diagram-
/// description text will not go outside of this container's bounds</param>
/// <param name="contact">the contact to diagram</param>
/// <param name="showContactInfo">Whether or not the contact info will be visible</param>
private void UpdateDescription(Grid parentGrid, Contact contact, bool showContactInfo)
{
// Show or hide the contact info based on showContactInfo
Description.Visibility = showContactInfo ? Visibility.Visible : Visibility.Hidden;
ConnectingLine.Visibility = showContactInfo ? Visibility.Visible : Visibility.Hidden;
if(!showContactInfo)
{
// Don't need to do the calculations if info isn't going to be shown
return;
}
Point position = contact.GetPosition(parentGrid);
Rect bounds = new Rect(0, 0, parentGrid.ActualWidth, parentGrid.ActualHeight);
// Determine where around the contact the description should be displayed.
// The default position is above and to the left.
bool isAbove = true;
bool isLeft = true;
// Description text for tags is different than non-tags
double descriptionXDistance;
bool isTag = contact.IsTagRecognized;
if (isTag)
{
descriptionXDistance = tagDescriptionXDistance;
}
else
{
descriptionXDistance = nonTagDescriptionXDistance;
}
// Put description below contact if default location is out of bounds.
Rect upperLeftBounds = GetDescriptionBounds(position, isAbove, isLeft, descriptionXDistance, descriptionYDistance);
if (upperLeftBounds.Top < bounds.Top)
{
isAbove = false;
}
// Put description to the right of the contact if default location is out of bounds.
if (upperLeftBounds.Left < bounds.Left)
{
isLeft = false;
}
// Calculate the final bounds that will be used for the textbox position
// based on the updated isAbove and isLeft values.
Rect finalBounds = GetDescriptionBounds(position, isAbove, isLeft, descriptionXDistance, descriptionYDistance);
Canvas.SetLeft(Description, finalBounds.Left);
Canvas.SetTop(Description, finalBounds.Top);
// Set the justification of the type in the textbox based
// on which side of the contact the textbox is on.
if(isLeft)
{
Description.TextAlignment = TextAlignment.Right;
}
else
{
Description.TextAlignment = TextAlignment.Left;
}
// Create the description string.
StringBuilder descriptionText = new StringBuilder();
descriptionText.AppendLine(String.Format(CultureInfo.InvariantCulture, "RecognizedTypes: {0}", GetContactTypeString(contact)));
descriptionText.AppendLine(String.Format(CultureInfo.InvariantCulture, "Id: {0}", contact.Id));
// Use the "f1" format specifier to limit the amount of decimal positions shown.
descriptionText.AppendLine(String.Format(CultureInfo.InvariantCulture, "X: {0}", position.X.ToString("f1", CultureInfo.InvariantCulture)));
descriptionText.AppendLine(String.Format(CultureInfo.InvariantCulture, "Y: {0}", position.Y.ToString("f1", CultureInfo.InvariantCulture)));
// Display "null" for Orientation if the contact does not have an orientation value.
string orientationString;
double? contactOrientation = contact.GetOrientation(parentGrid);
if(contactOrientation == null)
{
orientationString = "null";
}
else
{
orientationString = ((double)contactOrientation).ToString("f1", CultureInfo.InvariantCulture);
}
descriptionText.AppendLine(String.Format(CultureInfo.InvariantCulture, "Orientation: {0}", orientationString));
if (contact.Tag.Type == TagType.Byte)
{
descriptionText.AppendLine("Value: " + contact.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
}
else if (contact.Tag.Type == TagType.Identity)
{
descriptionText.AppendLine("Series: " + contact.Tag.Identity.Series.ToString("x16", CultureInfo.InvariantCulture));
//.........这里部分代码省略.........
示例4: updateContact
public void updateContact(Contact c, Grid parentGrid)
{
if (c.Tag.Type == TagType.Byte)
{
ContactDescriptor desc;
if (contactDictionary.Remove(c))
{
Point p = c.GetPosition(parentGrid);
desc = new ContactDescriptor(c.Tag.Byte.Value, (int)p.X, (int)p.Y, (int)(c.GetOrientation(parentGrid)));
contactDictionary.Add(c, desc);
}
}
}