本文整理汇总了C#中DisplayOrientations类的典型用法代码示例。如果您正苦于以下问题:C# DisplayOrientations类的具体用法?C# DisplayOrientations怎么用?C# DisplayOrientations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DisplayOrientations类属于命名空间,在下文中一共展示了DisplayOrientations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnNavigatedTo
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
_dataTransferManager = DataTransferManager.GetForCurrentView();
_dataTransferManager.DataRequested += OnDataRequested;
_navigationHelper.OnNavigatedTo(e);
if (InstagramModel != null)
{
await InstagramModel.LoadItemsAsync();
InstagramModel.SelectItem(e.Parameter);
InstagramModel.ViewType = ViewTypes.Detail;
}
DataContext = this;
// Allow this page to rotate
_currentOrientations = DisplayInformation.AutoRotationPreferences;
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait
| DisplayOrientations.Landscape
| DisplayOrientations.LandscapeFlipped
| DisplayOrientations.PortraitFlipped;
// Handle orientation changes
DisplayInformation.GetForCurrentView().OrientationChanged += this.OnOrientationChanged;
this.TransitionStoryboardState();
}
示例2: CameraCaptureUIPage
public CameraCaptureUIPage()
{
previous = DisplayInformation.AutoRotationPreferences;
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
this.Loaded += CameraCaptureUIPage_Loaded;
this.Unloaded += CameraCaptureUIPage_Unloaded;
this.InitializeComponent();
}
示例3: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.currentDisplayOrientations = DisplayInformation.AutoRotationPreferences;
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;
string id = e.Parameter as string;
this.OpenScript(id);
base.OnNavigatedTo(e);
}
示例4: ConvertDisplayOrientationToDegrees
private static int ConvertDisplayOrientationToDegrees(DisplayOrientations orientation)
{
switch (orientation)
{
case DisplayOrientations.Portrait:
return 90;
case DisplayOrientations.LandscapeFlipped:
return 180;
case DisplayOrientations.PortraitFlipped:
return 270;
case DisplayOrientations.Landscape:
default:
return 0;
}
}
示例5: OnNavigatedTo
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached.
/// This parameter is typically used to configure the page.</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
_autoRotation = DisplayInformation.AutoRotationPreferences;
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape;
// TODO: Prepare page for display here.
await InitializeAsync();
// TODO: If your application contains multiple pages, ensure that you are
// handling the hardware Back button by registering for the
// Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
// If you are using the NavigationHelper provided by some templates,
// this event is handled for you.
}
示例6: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
LoadState(e.Parameter);
if (HasPortrait)
{
_currentOrientations = DisplayInformation.AutoRotationPreferences;
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait
| DisplayOrientations.Landscape
| DisplayOrientations.LandscapeFlipped
| DisplayOrientations.PortraitFlipped;
// Handle orientation changes
DisplayInformation.GetForCurrentView().OrientationChanged += this.OnOrientationChanged;
this.TransitionStoryboardState();
}
}
示例7: OnNavigatedTo
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
_dataTransferManager = DataTransferManager.GetForCurrentView();
_dataTransferManager.DataRequested += OnDataRequested;
_navigationHelper.OnNavigatedTo(e);
if (YouTubeChannelModel != null)
{
await YouTubeChannelModel.LoadItemsAsync();
YouTubeChannelModel.SelectItem(e.Parameter);
YouTubeChannelModel.ViewType = ViewTypes.Detail;
}
ytViewer.OnNavigatedTo();
// Allow this page to rotate
_currentOrientations = DisplayInformation.AutoRotationPreferences;
DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait
| DisplayOrientations.Landscape
| DisplayOrientations.LandscapeFlipped
| DisplayOrientations.PortraitFlipped;
}
示例8: IsAspectChanging
/// <summary>
/// Gets a value that indicates if the aspect ratio is changing as part of the orientation change.
/// </summary>
/// <param name="oldOrientation">
/// The old orientation.
/// </param>
/// <param name="newOrientation">
/// The new orientation.
/// </param>
/// <returns>
/// <c>true</c> if the aspect ratio is changing as part of the orientation change; otherwise <c>false</c>.
/// </returns>
public static bool IsAspectChanging(DisplayOrientations oldOrientation, DisplayOrientations newOrientation)
{
// Going from landscape to portrait?
if ((oldOrientation == DisplayOrientations.Landscape) ||
(oldOrientation == DisplayOrientations.LandscapeFlipped))
{
if ((newOrientation == DisplayOrientations.Portrait) ||
(newOrientation == DisplayOrientations.PortraitFlipped))
{
return true;
}
}
// Going from portrait to landscape?
if ((oldOrientation == DisplayOrientations.Portrait) ||
(oldOrientation == DisplayOrientations.PortraitFlipped))
{
if ((newOrientation == DisplayOrientations.Landscape) ||
(newOrientation == DisplayOrientations.LandscapeFlipped))
{
return true;
}
}
// Nope
return false;
}
示例9: ConvertDisplayOrientationToSimpleOrientation
private SimpleOrientation ConvertDisplayOrientationToSimpleOrientation(DisplayOrientations orientation)
{
SimpleOrientation result;
switch (orientation)
{
case DisplayOrientations.Landscape:
result = SimpleOrientation.NotRotated;
break;
case DisplayOrientations.PortraitFlipped:
result = SimpleOrientation.Rotated90DegreesCounterclockwise;
break;
case DisplayOrientations.LandscapeFlipped:
result = SimpleOrientation.Rotated180DegreesCounterclockwise;
break;
case DisplayOrientations.Portrait:
default:
result = SimpleOrientation.Rotated270DegreesCounterclockwise;
break;
}
// Above assumes landscape; offset is needed if native orientation is portrait
if (_displayInformation.NativeOrientation == DisplayOrientations.Portrait)
{
result = AddOrientations(result, SimpleOrientation.Rotated90DegreesCounterclockwise);
}
return result;
}
示例10: ToOrientation
private static DisplayOrientation ToOrientation(DisplayOrientations orientations)
{
var result = DisplayOrientation.Default;
if ((orientations & DisplayOrientations.Landscape) != 0)
result |= DisplayOrientation.LandscapeLeft;
if ((orientations & DisplayOrientations.LandscapeFlipped) != 0)
result |= DisplayOrientation.LandscapeRight;
if ((orientations & DisplayOrientations.Portrait) != 0)
result |= DisplayOrientation.Portrait;
if ((orientations & DisplayOrientations.PortraitFlipped) != 0)
result |= DisplayOrientation.PortraitDown;
return result;
}
示例11: UWPMediaSink
/// <summary>
/// Initializes a new DetectorVideoSink.
/// </summary>
/// <param name="detector">The CaptureSourceMarkerDetector to use.</param>
public UWPMediaSink(CaptureSourceMarkerDetector detector)
{
this.detector = detector;
listener.ConnectionReceived += Listener_ConnectionReceived;
displayOrientation = displayInformation.CurrentOrientation;
displayInformation.OrientationChanged += DisplayInformation_OrientationChanged;
}
示例12: DisplayInformation_OrientationChanged
private void DisplayInformation_OrientationChanged(DisplayInformation sender, Object args)
{
displayOrientation = sender.CurrentOrientation;
if (capturing)
{
setPreviewRotation();
}
}
示例13: PageLoaded
private async void PageLoaded(object sender, RoutedEventArgs e)
{
_displayOrientation = _displayInformation.CurrentOrientation;
await InitializeCameraAsync();
StorageFile sf = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///wordlist.txt", UriKind.Absolute));
var _words = await FileIO.ReadLinesAsync(sf);
propertySet["tolerance"] = 0.78;
propertySet["hue"] = 320;
propertySet["dictionary"] = _words;
await _mediaCapture.AddVideoEffectAsync(new VideoEffectDefinition(typeof(TresholdVideoEffect).FullName, propertySet), MediaStreamType.VideoPreview);
var timer = new DispatcherTimer() { Interval = TimeSpan.FromMilliseconds(400) };
var textblockes = new List<TextBlock>();
timer.Tick += (s, agrs) =>
{
List<Point> centers = new List<Point>();
if (propertySet.ContainsKey("result"))
Result.Text = propertySet["result"].ToString();
if (propertySet.ContainsKey("centers"))
centers = propertySet["centers"] as List<Point>;
centers = centers.ToList();
if (!centers.Any())
return;
if (textblockes.Count == centers.Count)
{
for (int i = 0; i < centers.Count; i++)
{
textblockes[i].Margin = new Thickness(0, centers[i].Y, centers[i].X, 0);
}
}
else
{
foreach(TextBlock text in textblockes)
{
canvas.Children.Remove(text);
}
textblockes.Clear();
for (int i = 0; i < centers.Count; i++)
{
var textblock = new TextBlock
{
Text = i.ToString(),
Foreground = new SolidColorBrush(Colors.White),
FontSize = 24,
Margin = new Thickness(0, centers[i].Y, centers[i].X, 0)
};
canvas.Children.Add(textblock);
textblockes.Add(textblock);
}
}
};
timer.Start();
}
示例14: DisplayInformation_OrientationChanged
private async void DisplayInformation_OrientationChanged(DisplayInformation sender, object args)
{
_displayOrientation = sender.CurrentOrientation;
if (_isPreviewing)
{
await SetPreviewRotationAsync();
}
}
示例15: StartPreviewAsync
private async Task StartPreviewAsync()
{
// Prevent the device from sleeping while the preview is running
_displayRequest.RequestActive();
// Set the preview source in the UI and mirror it if necessary
HoldCamera.Source = mc;
HoldCamera.FlowDirection = _mirroringPreview ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
// Start the preview
try
{
await mc.StartPreviewAsync();
_isPreviewing = true;
_previewProperties = mc.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview);
}
catch (Exception ex)
{
Debug.WriteLine("Exception when starting the preview: {0}", ex.ToString());
}
// Initialize the preview to the current orientation
if (_previewProperties != null)
{
_displayOrientation = _displayInformation.CurrentOrientation;
await SetPreviewRotationAsync();
}
}