本文整理汇总了C#中Windows.UI.Core.CoreDispatcher类的典型用法代码示例。如果您正苦于以下问题:C# CoreDispatcher类的具体用法?C# CoreDispatcher怎么用?C# CoreDispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoreDispatcher类属于Windows.UI.Core命名空间,在下文中一共展示了CoreDispatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: StartStreaming
/// <summary>
/// When the user presses "Start Streaming Steam", first check that they are paired
/// </summary>
public static async Task<StreamContext> StartStreaming(CoreDispatcher uiDispatcher, Computer computer, MoonlightStreamConfiguration streamConfig)
{
PairingManager p = new PairingManager(computer);
// If we can't get the pair state, return
bool? pairState = await p.QueryPairState();
if (!pairState.HasValue)
{
DialogUtils.DisplayDialog(uiDispatcher, "Pair state query failed", "Failed to start streaming");
return null;
}
// If we're not paired, return
if (pairState == false)
{
DialogUtils.DisplayDialog(uiDispatcher, "Device not paired", "Failed to start streaming");
return null;
}
// Lookup the desired app in the app list
// NOTE: This will go away when we have a proper app list
int appId = await LookupAppIdForApp(uiDispatcher, new NvHttp(computer.IpAddress), "Steam");
if (appId == 0)
{
// LookupAppIdForApp() handles displaying a failure dialog
return null;
}
return new StreamContext(computer, appId, streamConfig);
}
开发者ID:cmathser,项目名称:moonlight-windows,代码行数:33,代码来源:ConnectionManager.cs
示例2: MapsViewModel
public MapsViewModel(MapControl mapControl)
{
_mapControl = mapControl;
StopStreetViewCommand = new DelegateCommand(StopStreetView, () => IsStreetView);
StartStreetViewCommand = new DelegateCommand(StartStreetViewAsync, () => !IsStreetView);
if (!DesignMode.DesignModeEnabled)
{
_dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
}
_locator.StatusChanged += async (s, e) =>
{
await _dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
PositionStatus = e.Status
);
};
// intialize defaults at startup
CurrentPosition = new Geopoint(new BasicGeoposition { Latitude = 48.2, Longitude = 16.3 });
// { Latitude = 47.604, Longitude = -122.329 });
CurrentMapStyle = MapStyle.Road;
DesiredPitch = 0;
ZoomLevel = 12;
}
开发者ID:ProfessionalCSharp,项目名称:ProfessionalCSharp6,代码行数:25,代码来源:MapsViewModel.cs
示例3: Pair
/// <summary>
/// Pair with the hostname in the textbox
/// </summary>
public async Task Pair(CoreDispatcher uiDispatcher, Computer c)
{
Debug.WriteLine("Pairing...");
// Get the pair state.
bool? pairState = await QueryPairState();
if (pairState == true)
{
DialogUtils.DisplayDialog(uiDispatcher, "This device is already paired to the host PC", "Already Paired");
return;
}
// pairstate = null. We've encountered an error
else if (!pairState.HasValue)
{
DialogUtils.DisplayDialog(uiDispatcher, "Failed to query pair state", "Pairing failed");
return;
}
bool challenge = await PairingCryptoHelpers.PerformPairingHandshake(uiDispatcher, new WindowsCryptoProvider(), nv, nv.GetUniqueId());
if (!challenge)
{
Debug.WriteLine("Challenges failed");
return;
}
// Otherwise, everything was successful
MainPage.SaveComputer(c);
// FIXME: We can't have two dialogs open at once.
// DialogUtils.DisplayDialog(uiDispatcher, "Pairing successful", "Success");
}
开发者ID:cmathser,项目名称:moonlight-windows,代码行数:34,代码来源:PairingManager.cs
示例4: CoreDispatcher_AcceleratorKeyActivated
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
{
if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
e.EventType == CoreAcceleratorKeyEventType.KeyDown))
{
var coreWindow = Windows.UI.Xaml.Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
var virtualKey = e.VirtualKey;
bool winKey = ((coreWindow.GetKeyState(VirtualKey.LeftWindows) & downState) == downState || (coreWindow.GetKeyState(VirtualKey.RightWindows) & downState) == downState);
bool altKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
// raise keydown actions
var keyDown = new KeyboardEventArgs
{
AltKey = altKey,
Character = ToChar(virtualKey, shiftKey),
ControlKey = controlKey,
EventArgs = e,
ShiftKey = shiftKey,
VirtualKey = virtualKey
};
try { _KeyDown?.Raise(this, keyDown); }
catch { }
// Handle F5 to refresh content
if (virtualKey == VirtualKey.F5)
{
bool noModifiers = !altKey && !controlKey && !shiftKey;
_RefreshRequest?.Raise(this, keyDown);
}
}
}
开发者ID:ZedTheYeti,项目名称:Hangups-UWP,代码行数:35,代码来源:KeyboardService.cs
示例5: WindowsPhoneRunner
public WindowsPhoneRunner(Windows.UI.Core.CoreDispatcher dispatcher, Windows.UI.Xaml.Controls.TextBlock textBlock)
{
_dispatcher = dispatcher;
_output = textBlock;
}
开发者ID:lawandeneel,项目名称:Fashion,代码行数:7,代码来源:WindowsPhoneRunner.cs
示例6: AudioPlayerControl
internal AudioPlayerControl(CoreDispatcher dispatcher)
{
this.dispatcher = dispatcher;
BackgroundMediaPlayer.MessageReceivedFromBackground += BackgroundMediaPlayer_MessageReceivedFromBackground;
SendToBackground(CommunicationConstants.GetInfo);
BackgroundMediaPlayer.Current.CurrentStateChanged += BackgroundMediaPlayer_CurrentStateChanged;
}
开发者ID:JulianMH,项目名称:music-3,代码行数:7,代码来源:AudioPlayerControl.cs
示例7: WindowsBasePlatformServices
public WindowsBasePlatformServices(CoreDispatcher dispatcher)
{
if (dispatcher == null)
throw new ArgumentNullException("dispatcher");
_dispatcher = dispatcher;
}
开发者ID:Costo,项目名称:Xamarin.Forms,代码行数:7,代码来源:WindowsBasePlatformServices.cs
示例8: DashboardViewModel
public DashboardViewModel(CoreDispatcher dispatcher)
{
_dispatcher = dispatcher;
PageTitle = "Learning to use Gyrometer";
SetupSensor();
}
开发者ID:derikwhittaker,项目名称:LiveLessons.WinRT,代码行数:7,代码来源:DashboardViewModel.cs
示例9: CoreDispatcher_AcceleratorKeyActivated
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
if (args.EventType.ToString().Contains("Down") && !args.Handled)
{
var alt = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var shift = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var control = (Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
var windows = ((Window.Current.CoreWindow.GetKeyState(VirtualKey.LeftWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down) || ((Window.Current.CoreWindow.GetKeyState(VirtualKey.RightWindows) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down);
var character = ToChar(args.VirtualKey, shift);
var keyDown = new KeyboardEventArgs
{
AltKey = alt,
Character = character,
ControlKey = control,
EventArgs = args,
ShiftKey = shift,
VirtualKey = args.VirtualKey
};
try { KeyDown?.Invoke(keyDown); }
finally
{
args.Handled = keyDown.Handled;
}
}
}
开发者ID:haroldma,项目名称:Audiotica,代码行数:27,代码来源:KeyboardHelper.cs
示例10: CoreDispatcher_AcceleratorKeyActivated
/// <summary>
/// Invoked on every keystroke, including system keys such as Alt key combinations, when
/// this page is active and occupies the entire window. Used to detect keyboard navigation
/// between pages even when the page itself doesn't have focus.
/// </summary>
/// <param name="sender">Instance that triggered the event.</param>
/// <param name="args">Event data describing the conditions that led to the event.</param>
private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs args)
{
var virtualKey = args.VirtualKey;
// Only investigate further when Left, Right, or the dedicated Previous or Next keys are pressed
if ((args.EventType == CoreAcceleratorKeyEventType.SystemKeyDown || args.EventType == CoreAcceleratorKeyEventType.KeyDown) &&
(virtualKey == VirtualKey.Left || virtualKey == VirtualKey.Right || (int)virtualKey == 166 || (int)virtualKey == 167))
{
var coreWindow = Window.Current.CoreWindow;
var downState = CoreVirtualKeyStates.Down;
var menuKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
var controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
var shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;
var noModifiers = !menuKey && !controlKey && !shiftKey;
var onlyAlt = menuKey && !controlKey && !shiftKey;
if (((int)virtualKey == 166 && noModifiers) || (virtualKey == VirtualKey.Left && onlyAlt))
{
// When the previous key or Alt+Left are pressed navigate back
args.Handled = true;
GoBack(this, new RoutedEventArgs());
}
else if (((int)virtualKey == 167 && noModifiers) || (virtualKey == VirtualKey.Right && onlyAlt))
{
// When the next key or Alt+Right are pressed navigate forward
args.Handled = true;
GoForward(this, new RoutedEventArgs());
}
}
}
开发者ID:stevehansen,项目名称:vidyano_v1,代码行数:37,代码来源:LayoutAwarePage.cs
示例11: InitializeAsync
public async Task<ImageSource> InitializeAsync(CoreDispatcher dispatcher, IRandomAccessStream streamSource, CancellationTokenSource cancellationTokenSource)
{
byte[] bytes = new byte[streamSource.Size];
await streamSource.ReadAsync(bytes.AsBuffer(), (uint)streamSource.Size, InputStreamOptions.None).AsTask(cancellationTokenSource.Token);
var imageSource = WebpCodec.Decode(bytes);
return imageSource;
}
开发者ID:yyx290799684,项目名称:ImageLib.UWP,代码行数:7,代码来源:WebpDecoder.cs
示例12: LookupAppIdForApp
/// <summary>
/// Query the app list on the server to get the Steam App ID
/// </summary>
/// <returns>True if the operation succeeded, false otherwise</returns>
private static async Task<int> LookupAppIdForApp(CoreDispatcher dispatcher, NvHttp nv, String app)
{
XmlQuery appList;
string appIdStr;
appList = new XmlQuery(nv.BaseUrl + "/applist?uniqueid=" + nv.GetUniqueId());
// App list query went well - try to get the app ID
try
{
appIdStr = await appList.SearchElement("App", "AppTitle", app, "ID");
Debug.WriteLine(appIdStr);
if (appIdStr == null)
{
// Not found
DialogUtils.DisplayDialog(dispatcher, "App Not Found", "App ID Lookup Failed");
return 0;
}
}
// Exception connecting to the resource
catch (Exception e)
{
// Steam ID lookup failed
DialogUtils.DisplayDialog(dispatcher, "Failed to get app ID: " + e.Message, "App ID Lookup Failed");
return 0;
}
// We're in the clear - save the app ID
return Convert.ToInt32(appIdStr);
}
开发者ID:cmathser,项目名称:moonlight-windows,代码行数:34,代码来源:ConnectionManager.cs
示例13: SongDownloadService
public SongDownloadService(ICollectionService service, ISqlService sqlService, CoreDispatcher dispatcher)
{
this.service = service;
this.sqlService = sqlService;
this.dispatcher = dispatcher;
ActiveDownloads = new ObservableCollection<Song>();
}
开发者ID:jayharry28,项目名称:Audiotica,代码行数:7,代码来源:SongDownloadService.cs
示例14: BlankPage8
public BlankPage8()
{
this.InitializeComponent();
MainDispatcher = this.Dispatcher;
_mainController = new MainController();
Loaded += BlankPage8_Loaded;
}
开发者ID:HppZ,项目名称:UniversalTest,代码行数:7,代码来源:BlankPage8.xaml.cs
示例15: InitializeRecognizer
/// <summary>
/// When activating the scenario, ensure we have permission from the user to access their microphone, and
/// provide an appropriate path for the user to enable access to the microphone if they haven't
/// given explicit permission for it.
/// </summary>
/// <param name="e">The navigation event details</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
// Save the UI thread dispatcher to allow speech status messages to be shown on the UI.
dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
if (permissionGained)
{
// Enable the recognition buttons.
btnRecognizeWithUI.IsEnabled = true;
btnRecognizeWithoutUI.IsEnabled = true;
Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
string langTag = speechLanguage.LanguageTag;
speechContext = ResourceContext.GetForCurrentView();
speechContext.Languages = new string[] { langTag };
speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");
PopulateLanguageDropdown();
await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
}
else
{
resultTextBlock.Visibility = Visibility.Visible;
resultTextBlock.Text = "Permission to access capture resources was not given by the user; please set the application setting in Settings->Privacy->Microphone.";
btnRecognizeWithUI.IsEnabled = false;
btnRecognizeWithoutUI.IsEnabled = false;
cbLanguageSelection.IsEnabled = false;
}
}
开发者ID:n3d0r,项目名称:hackuci,代码行数:37,代码来源:ListConstraintScenario.xaml.cs
示例16: Init
/// <summary>
/// Initialization method that must be called from the UI thread
/// </summary>
public static void Init()
{
if (m_refDispatcher == null)
{
Dispatcher = Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher;
}
}
开发者ID:Strimy,项目名称:WinRTCore,代码行数:10,代码来源:DispatcherService.cs
示例17: InitializeRecognizer
/// <summary>
/// Upon entering the scenario, ensure that we have permissions to use the Microphone. This may entail popping up
/// a dialog to the user on Desktop systems. Only enable functionality once we've gained that permission in order to
/// prevent errors from occurring when using the SpeechRecognizer. If speech is not a primary input mechanism, developers
/// should consider disabling appropriate parts of the UI if the user does not have a recording device, or does not allow
/// audio input.
/// </summary>
/// <param name="e">Unused navigation parameters</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
rootPage = MainPage.Current;
// Keep track of the UI thread dispatcher, as speech events will come in on a separate thread.
dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
// Prompt the user for permission to access the microphone. This request will only happen
// once, it will not re-prompt if the user rejects the permission.
bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
if (permissionGained)
{
btnContinuousRecognize.IsEnabled = true;
}
else
{
resultTextBlock.Text = "Permission to access capture resources was not given by the user, reset the application setting in Settings->Privacy->Microphone.";
}
Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
string langTag = speechLanguage.LanguageTag;
speechContext = ResourceContext.GetForCurrentView();
speechContext.Languages = new string[] { langTag };
speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");
PopulateLanguageDropdown();
// Initialize the recognizer. Since the recognizer is disposed on scenario exit, we need to make sure we re-initialize it on scenario
// entrance, as the xaml page may not get destroyed between openings of the scenario.
await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
}
开发者ID:mhdubose,项目名称:Windows-universal-samples,代码行数:41,代码来源:ContinuousRecognitionSRGSConstraintScenario.xaml.cs
示例18: MainPage
public MainPage()
{
InitializeComponent();
DataContext = this;
_dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
// Create the Bluetooth LE watcher from the Windows 10 UWP
_watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
// Construct the Universal Bluetooth Beacon manager
_beaconManager = new BeaconManager();
BeaconListView.ItemsSource = _beaconManager.BluetoothBeacons;
// Simulate beacon info
//#if DEBUG
// var eddystoneBeacon = new Beacon(Beacon.BeaconTypeEnum.Eddystone);
// eddystoneBeacon.BeaconFrames.Add(new TlmEddystoneFrame(0, 3100, (float)25.5, 2000, 1000));
// // Ranging Data 0xEE = -18dbM: needs unchecked syntax to cast constants, works without unchecked for runtime variables
// // (sbyte)0x12 = +18dbM
// // Sample values from: https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.tx_power_level.xml
// eddystoneBeacon.BeaconFrames.Add(new UidEddystoneFrame(unchecked((sbyte)0xEE),
// new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A },
// new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }));
// eddystoneBeacon.BeaconFrames.Add(new UrlEddystoneFrame(220, "http://www.tieto.at"));
// eddystoneBeacon.Rssi = -49;
// eddystoneBeacon.BluetoothAddress = 0x0000e27ef189f6c4; // 3
// eddystoneBeacon.Timestamp = DateTimeOffset.Now;
// _beaconManager.BluetoothBeacons.Add(eddystoneBeacon);
//#endif
}
开发者ID:repositorymanagemen,项目名称:universal-beacon,代码行数:30,代码来源:MainPage.xaml.cs
示例19: MainPage_Loaded
private async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
SetupPersonGroup();
dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
bool permissionGained = await RequestMicrophonePermission();
if (!permissionGained)
return; // No permission granted
Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
string langTag = speechLanguage.LanguageTag;
speechContext = ResourceContext.GetForCurrentView();
speechContext.Languages = new string[] { langTag };
speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");
await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
try
{
await speechRecognizer.ContinuousRecognitionSession.StartAsync();
}
catch (Exception ex)
{
var messageDialog = new Windows.UI.Popups.MessageDialog(ex.Message, "Exception");
await messageDialog.ShowAsync();
}
}
开发者ID:liliankasem,项目名称:ProjectSpike,代码行数:30,代码来源:MainPage.xaml.cs
示例20: InitializeRecognizer
/// <summary>
/// Upon entering the scenario, ensure that we have permissions to use the Microphone. This may entail popping up
/// a dialog to the user on Desktop systems. Only enable functionality once we've gained that permission in order to
/// prevent errors from occurring when using the SpeechRecognizer. If speech is not a primary input mechanism, developers
/// should consider disabling appropriate parts of the UI if the user does not have a recording device, or does not allow
/// audio input.
/// </summary>
/// <param name="e">Unused navigation parameters</param>
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
rootPage = MainPage.Current;
// Keep track of the UI thread dispatcher, as speech events will come in on a separate thread.
dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
// Prompt the user for permission to access the microphone. This request will only happen
// once, it will not re-prompt if the user rejects the permission.
bool permissionGained = await AudioCapturePermissions.RequestMicrophonePermission();
if (permissionGained)
{
btnContinuousRecognize.IsEnabled = true;
// Initialize resource map to retrieve localized speech strings.
Language speechLanguage = SpeechRecognizer.SystemSpeechLanguage;
string langTag = speechLanguage.LanguageTag;
speechContext = ResourceContext.GetForCurrentView();
speechContext.Languages = new string[] { langTag };
speechResourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("LocalizationSpeechResources");
PopulateLanguageDropdown();
await InitializeRecognizer(SpeechRecognizer.SystemSpeechLanguage);
}
else
{
this.resultTextBlock.Visibility = Visibility.Visible;
this.resultTextBlock.Text = "Permission to access capture resources was not given by the user, reset the application setting in Settings->Privacy->Microphone.";
btnContinuousRecognize.IsEnabled = false;
cbLanguageSelection.IsEnabled = false;
}
}
开发者ID:C-C-D-I,项目名称:Windows-universal-samples,代码行数:41,代码来源:ContinuousRecognitionListGrammarScenario.xaml.cs
注:本文中的Windows.UI.Core.CoreDispatcher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论