private async void CreateFileClicked(object sender, Windows.UI.Xaml.RoutedEventArgs e) { StorageFolder storageFolder = ApplicationData.Current.LocalFolder; this.sampleFile = await storageFolder.CreateFileAsync( MainPage.fileName, CreationCollisionOption.ReplaceExisting); StatusTextBlock.Text = "The file '" + sampleFile.Name + "' was created."; }
protected virtual void uiElement_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { if (moveD3dCanvas) { var newPosition = e.GetCurrentPoint(null); double deltaX = newPosition.Position.X - lastPos.Position.X; double deltaY = newPosition.Position.Y - lastPos.Position.Y; // Only support CompositeTransform and TranslateTransform // Is there any better way to handle this? if (uiElement.RenderTransform is CompositeTransform) { var compositeTransform = (CompositeTransform)uiElement.RenderTransform; compositeTransform.TranslateX += deltaX; compositeTransform.TranslateY += deltaY; } else if (uiElement.RenderTransform is TranslateTransform) { var translateTransform = (TranslateTransform)uiElement.RenderTransform; translateTransform.X += deltaX; translateTransform.Y += deltaY; } lastPos = newPosition; } }
public async override void OnNavigatedTo(object navigationParameter, Windows.UI.Xaml.Navigation.NavigationMode navigationMode, Dictionary<string, object> viewModelState) { base.OnNavigatedTo(navigationParameter, navigationMode, viewModelState); ErrorMessageTitle = string.Empty; ErrorMessage = string.Empty; try { LoadingData = true; CrudResult crudResult = await _entityRepository.GetEntitiesAsync(); EntityList = JsonConvert.DeserializeObject<List<Entity>>(crudResult.Content.ToString()); } catch (HttpRequestException ex) { ErrorMessageTitle = ErrorMessagesHelper.GetEntitiesAsyncFailedError; ErrorMessage = string.Format("{0}{1}", Environment.NewLine, ex.Message); } catch (Exception ex) { ErrorMessageTitle = ErrorMessagesHelper.ExceptionError; ErrorMessage = string.Format("{0}{1}", Environment.NewLine, ex.Message); } finally { LoadingData = false; } if (ErrorMessage != null && ErrorMessage != string.Empty) { MessageDialog messageDialog = new MessageDialog(ErrorMessage, ErrorMessageTitle); await messageDialog.ShowAsync(); } }
/// <summary> /// Start of the Drag and Drop operation: we set some content and change the DragUI /// depending on the selected options /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private async void SourceGrid_DragStarting(Windows.UI.Xaml.UIElement sender, Windows.UI.Xaml.DragStartingEventArgs args) { args.Data.SetText(SourceTextBox.Text); if ((bool)DataPackageRB.IsChecked) { // Standard icon will be used as the DragUIContent args.DragUI.SetContentFromDataPackage(); } else if ((bool)CustomContentRB.IsChecked) { // Generate a bitmap with only the TextBox // We need to take the deferral as the rendering won't be completed synchronously var deferral = args.GetDeferral(); var rtb = new RenderTargetBitmap(); await rtb.RenderAsync(SourceTextBox); var buffer = await rtb.GetPixelsAsync(); var bitmap = SoftwareBitmap.CreateCopyFromBuffer(buffer, BitmapPixelFormat.Bgra8, rtb.PixelWidth, rtb.PixelHeight, BitmapAlphaMode.Premultiplied); args.DragUI.SetContentFromSoftwareBitmap(bitmap); deferral.Complete(); } // else just show the dragged UIElement }
void UrlTextBox_KeyUp(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter) { webView.Source = new Uri(UrlTextBox.Text); } }
private void AppBarButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { AppBarButton button = sender as AppBarButton; int newFontSize = Int32.Parse(button.Tag.ToString()); mainPanel.BodyFontSize = newFontSize; mainPanel.UpdateFontSize(); }
private void App_UnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e) { //var client = new Microsoft.ApplicationInsights.TelemetryClient(); //client.TrackException(e.Exception); _logger.Error(e.Exception); e.Handled = true; }
protected override void OnNavigatedTo(Windows.UI.Xaml.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); // ok... this.GetModel().Activated(e.Parameter); }
/// <summary> /// Initializes the camera and populates the UI /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void InitializeCameraButton_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { var button = sender as Button; // Clear any previous message. rootPage.NotifyUser("", NotifyType.StatusMessage); button.IsEnabled = false; await _previewer.InitializeCameraAsync(); button.IsEnabled = true; if (_previewer.IsPreviewing) { if (string.IsNullOrEmpty(_previewer.MediaCapture.MediaCaptureSettings.AudioDeviceId)) { rootPage.NotifyUser("No audio device available. Cannot capture.", NotifyType.ErrorMessage); } else { button.Visibility = Visibility.Collapsed; PreviewControl.Visibility = Visibility.Visible; CheckIfStreamsAreIdentical(); PopulateComboBoxes(); VideoButton.IsEnabled = true; } } }
// Handle the returned files from file picker public async void ContinueFileOpenPicker(Windows.ApplicationModel.Activation.FileOpenPickerContinuationEventArgs args) { if (args.Files.Count > 0) { mediaElement.Stop(); try { // Open StorageFile as IRandomAccessStream to be passed to FFmpegInteropMSS StorageFile file = args.Files.FirstOrDefault(); IRandomAccessStream readStream = await file.OpenAsync(FileAccessMode.Read); // Instantiate FFmpeg object and pass the stream from opened file FFmpegMSS = FFmpegInteropMSS.CreateFFmpegInteropMSSFromStream(readStream, forceDecodeAudio, forceDecodeVideo); MediaStreamSource mss = FFmpegMSS.GetMediaStreamSource(); if (mss != null) { // Pass MediaStreamSource to Media Element mediaElement.SetMediaStreamSource(mss); } else { DisplayErrorMessage("Cannot open media"); } } catch (Exception ex) { DisplayErrorMessage(ex.Message); } } }
private void CompleteAllCheckBox_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { App.Store.Dispatch(new CompleteAllTodosAction { IsCompleted = CompleteAllCheckBox.IsChecked.Value }); }
// Cancel current shape request when the symbol selection changes private async void symbolCombo_SelectionChanged(object sender, Windows.UI.Xaml.Controls.SelectionChangedEventArgs e) { if (MyMapView.Editor.IsActive) MyMapView.Editor.Cancel.Execute(null); await AcceptPointsAsync(); }
private void UpdateTrigger(Windows.Graphics.Display.DisplayOrientations orientation) { var qualifiers = Windows.ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView().QualifierValues; var isOnMobile = qualifiers.ContainsKey("DeviceFamily") && qualifiers["DeviceFamily"].ToLowerInvariant() == "Mobile".ToLowerInvariant(); if (orientation == Windows.Graphics.Display.DisplayOrientations.None) { SetActive(false); } else if (orientation == Windows.Graphics.Display.DisplayOrientations.Landscape || orientation == Windows.Graphics.Display.DisplayOrientations.LandscapeFlipped) { if (isOnMobile) { SetActive(Orientation == Orientations.LandscapeMobile); } else { SetActive(Orientation == Orientations.Landscape); } } else if (orientation == Windows.Graphics.Display.DisplayOrientations.Portrait || orientation == Windows.Graphics.Display.DisplayOrientations.PortraitFlipped) { if (isOnMobile) { SetActive(Orientation == Orientations.PortraitMobile); } else { SetActive(Orientation == Orientations.Portrait); } } }
private void TextBox_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e) { var textBox = sender as TextBox; NewToDoItemNameTextBox = textBox; if (!string.IsNullOrEmpty(textBox.Text) && textBox.Text.Length > 3) { if (AddNewItemConfirmButton != null) AddNewItemConfirmButton.IsEnabled = true; if (e.Key == Windows.System.VirtualKey.Enter) { // Handle 'Enter' key for keyboard users if (e.Key == Windows.System.VirtualKey.Enter) { e.Handled = true; CreateNewToDoItem(textBox); } } } else { if (AddNewItemConfirmButton != null) AddNewItemConfirmButton.IsEnabled = false; } }
private void AppBarBackButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e) { if (Frame.CanGoBack) { Frame.GoBack(); } }
private void WebView1_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e) { WebView1.LoadCompleted += WebView1_LoadCompleted; var loginUrl = GetFacebookLoginUrl(AppId, ExtendedPermissions); WebView1.Navigate(loginUrl); }
private void WebView1_LoadCompleted(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e) { FuntownOAuthResult oauthResult; if (!_ft.TryParseOAuthCallbackUrl(e.Uri, out oauthResult)) { return; } if (oauthResult.IsSuccess) { var error_code = oauthResult.ErrorCode; var code = oauthResult.Code; var accessToken = oauthResult.AccessToken; if (error_code == 100 && !string.IsNullOrEmpty(code)) { RequestToken(code); return; } if (error_code == 100 && !string.IsNullOrEmpty(accessToken)) { LoginSucceded(accessToken); return; } } else { // user cancelled } }
private void downloadList_Holding(object sender, Windows.UI.Xaml.Input.HoldingRoutedEventArgs e) { FrameworkElement senderelement = sender as FrameworkElement; FlyoutBase flyoutbase = FlyoutBase.GetAttachedFlyout(senderelement); flyoutbase.ShowAt(senderelement); }
protected override void PrepareContainerForItemOverride(Windows.UI.Xaml.DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); DataItem dataItem = item as DataItem; int index =-1; if (dataItem != null) { index = dataItem.Group.Items.IndexOf(dataItem); } if (index >=0 && index < _sequence.Count) { colVal = (int)_sequence[index].Width; rowVal = (int)_sequence[index].Height; } else { colVal = (int)LayoutSizes.OtherSmallItem.Width; rowVal = (int)LayoutSizes.OtherSmallItem.Height; } VariableSizedWrapGrid.SetRowSpan(element as UIElement, rowVal); VariableSizedWrapGrid.SetColumnSpan(element as UIElement, colVal); }
void ITmdbObject.ProcessJson(Windows.Data.Json.JsonObject jsonObject) { Id = (int)jsonObject.GetSafeNumber("id"); Name = jsonObject.GetSafeString("name"); PosterPath = jsonObject.GetSafeString("poster_path"); BackdropPath = jsonObject.GetSafeString("backdrop_path"); }
/// <summary> /// Close the popup when the app is deactivated /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnWindowActivated(object sender, Windows.UI.Core.WindowActivatedEventArgs e) { if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated) { _popup.IsOpen = false; } }
void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e) { if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated) { settingsPopup.IsOpen = false; } }
void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e) { if (Frame.CanGoBack) { e.Handled = true; Frame.GoBack(); } }
private void tlMainTabs_TabPointerEntered(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { TabViewModel tvm = null; if (sender is FrameworkElement) { var fe = (FrameworkElement)sender; if (fe.DataContext is TabViewModel) tvm = (TabViewModel)fe.DataContext; else return; var visual = fe.TransformToVisual(layoutRoot); var point1 = visual.TransformPoint(new Point(0, 40)); var point2 = new Point(point1.X + fe.ActualWidth + 180, point1.Y + fe.ActualHeight + 140); //hide all the current tabs in the canvas _spriteBatch.Elements.ToList().ForEach(delegate (IVisualTreeElement element) { element.IsVisible = false; }); //now delete all the relevant elements in the spritebatch _spriteBatch.DeleteAll(); //create the new thumbnail sprite for current button _spriteBatch.Add(new TabThumbnailSprite() { Layout = new Rect(point1, point2), ID = const_TabPreview, TextureBackgroundUri = tvm.ThumbUri, IsVisible = true }); _spriteBatch.IsVisible = true; } CanvasInvalidate(); }
private void CoreApplication_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e) { if (OnSuspending != null) { this.OnSuspending(this, null); } }
static void image_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { var image = sender as Image; image.Height += 10; image.Width += 10; }
/// <summary> /// If we've lost focus and returned to this app, reload the store, as the on-disk content might have /// been changed by the background task. /// </summary> /// <param name="sender">Ignored</param> /// <param name="args">Ignored</param> private async void CoreWindow_VisibilityChanged(Windows.UI.Core.CoreWindow sender, Windows.UI.Core.VisibilityChangedEventArgs args) { //if (args.Visible == true) //{ // await DefaultViewModel.LoadTrips(); //} }
private async void button_send_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) { JArray ja = new JArray(); foreach (var a in ((ListView)listView_friends).SelectedItems) { classes.Friend friendToSendSnapTo = (classes.Friend)(a); ja.Add(friendToSendSnapTo.username); } String JSON = await a.sendSnap(main.static_user, main.static_pass, pb, ja.ToString(), snap_file, int.Parse(slider_time.Value.ToString())); //Frame.Navigate(typeof(snap_screen)); JObject jo = JObject.Parse(JSON); if (jo["status"].ToString() == "True") { h.showSingleButtonDialog("Snap uploaded", "Snap uploaded successfully!", "Dismiss"); } else { h.showSingleButtonDialog("Server error [" + jo["code"] + "]", ((jo["message"] != null) ? jo["message"].ToString() : "No server message was provided"), "Dismiss"); } }
/// <summary> /// Entering the Target, we'll change its background and optionally change the DragUI as well /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TargetTextBox_DragEnter(object sender, Windows.UI.Xaml.DragEventArgs e) { /// Change the background of the target VisualStateManager.GoToState(this, "Inside", true); bool hasText = e.DataView.Contains(StandardDataFormats.Text); e.AcceptedOperation = hasText ? DataPackageOperation.Copy : DataPackageOperation.None; if (hasText) { e.DragUIOverride.Caption = "Drop here to insert text"; // Now customize the content if ((bool)HideRB.IsChecked) { e.DragUIOverride.IsGlyphVisible = false; e.DragUIOverride.IsContentVisible = false; } else if ((bool)CustomRB.IsChecked) { var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/dropcursor.png", UriKind.RelativeOrAbsolute)); // Anchor will define how to position the image relative to the pointer Point anchor = new Point(0,52); // lower left corner of the image e.DragUIOverride.SetContentFromBitmapImage(bitmap, anchor); e.DragUIOverride.IsGlyphVisible = false; e.DragUIOverride.IsCaptionVisible = false; } // else keep the DragUI Content set by the source } }
public void putCredentials(Windows.Data.Json.JsonObject jsonObject, string username, string password) { token = jsonObject.GetNamedString("token"); currentUser = jsonObject.GetNamedNumber("userId").ToString(); localSettings.Values["token"] = token; localSettings.Values["userId"] = currentUser; }
static void Main() { Windows.CreateMainWindowAndRun(new AltWind(), "Alternate and Winding Fill Modes"); }
private MainWindow GetMainWindow() { return(Windows.OfType <MainWindow>().FirstOrDefault()); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { ScrollInfo si; switch (message) { case MessageType.Size: int iMaxWidth = 40 * cxChar + 22 * cxCaps; cxClient = lParam.LowWord; cyClient = lParam.HighWord; // Set vertical scroll bar range and page size si = new ScrollInfo { Mask = ScrollInfoMask.Range | ScrollInfoMask.Page, Min = 0, Max = Metrics.SystemMetrics.Count - 1, Page = (uint)(cyClient / cyChar), }; window.SetScrollInfo(ScrollBar.Vertical, ref si, true); // Set horizontal scroll bar range and page size si.Max = 2 + iMaxWidth / cxChar; si.Page = (uint)(cxClient / cxChar); window.SetScrollInfo(ScrollBar.Horizontal, ref si, true); return(0); case MessageType.VerticalScroll: // Get all the vertical scroll bar information si = new ScrollInfo { Mask = ScrollInfoMask.All }; window.GetScrollInfo(ScrollBar.Vertical, ref si); // Save the position for comparison later on int iVertPos = si.Position; switch ((ScrollCommand)wParam.LowWord) { case ScrollCommand.Top: si.Position = si.Min; break; case ScrollCommand.Bottom: si.Position = si.Max; break; case ScrollCommand.LineUp: si.Position -= 1; break; case ScrollCommand.LineDown: si.Position += 1; break; case ScrollCommand.PageUp: si.Position -= (int)si.Page; break; case ScrollCommand.PageDown: si.Position += (int)si.Page; break; case ScrollCommand.ThumbTrack: si.Position = si.TrackPosition; break; } // Set the position and then retrieve it. Due to adjustments // by Windows it may not be the same as the value set. si.Mask = ScrollInfoMask.Position; window.SetScrollInfo(ScrollBar.Vertical, ref si, true); window.GetScrollInfo(ScrollBar.Vertical, ref si); // If the position has changed, scroll the window and update it if (si.Position != iVertPos) { window.ScrollWindow(new Point(0, cyChar * (iVertPos - si.Position))); window.UpdateWindow(); } return(0); case MessageType.HorizontalScroll: // Get all the horizontal scroll bar information si = new ScrollInfo { Mask = ScrollInfoMask.All }; window.GetScrollInfo(ScrollBar.Horizontal, ref si); // Save the position for comparison later on int iHorzPos = si.Position; switch ((ScrollCommand)wParam.LowWord) { case ScrollCommand.LineLeft: si.Position -= 1; break; case ScrollCommand.LineRight: si.Position += 1; break; case ScrollCommand.PageLeft: si.Position -= (int)si.Page; break; case ScrollCommand.PageRight: si.Position += (int)si.Page; break; case ScrollCommand.ThumbPosition: si.Position = si.TrackPosition; break; } // Set the position and then retrieve it. Due to adjustments // by Windows it may not be the same as the value set. si.Mask = ScrollInfoMask.Position; window.SetScrollInfo(ScrollBar.Horizontal, ref si, true); window.GetScrollInfo(ScrollBar.Horizontal, ref si); // If the position has changed, scroll the window if (si.Position != iHorzPos) { window.ScrollWindow(new Point(cxChar * (iHorzPos - si.Position), 0)); } return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint(out PaintStruct ps)) { // Get vertical scroll bar position si = new ScrollInfo { Mask = ScrollInfoMask.Position }; window.GetScrollInfo(ScrollBar.Vertical, ref si); iVertPos = si.Position; // Get horizontal scroll bar position window.GetScrollInfo(ScrollBar.Horizontal, ref si); iHorzPos = si.Position; // Find painting limits int iPaintBeg = Math.Max(0, iVertPos + ps.Paint.Top / cyChar); int iPaintEnd = Math.Min(Metrics.SystemMetrics.Count - 1, iVertPos + ps.Paint.Bottom / cyChar); var keys = Metrics.SystemMetrics.Keys.ToArray(); for (int i = iPaintBeg; i <= iPaintEnd; i++) { var metric = keys[i]; int x = cxChar * (1 - iHorzPos); int y = cyChar * (i - iVertPos); dc.TextOut(new Point(x, y), metric.ToString().AsSpan()); dc.TextOut(new Point(x + 22 * cxCaps, y), Metrics.SystemMetrics[metric].AsSpan()); dc.SetTextAlignment(new TextAlignment(TextAlignment.Horizontal.Right, TextAlignment.Vertical.Top)); dc.TextOut(new Point(x + 22 * cxCaps + 40 * cxChar, y), Windows.GetSystemMetrics(metric).ToString().AsSpan()); dc.SetTextAlignment(new TextAlignment(TextAlignment.Horizontal.Left, TextAlignment.Vertical.Top)); } } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
public static void CloseWindow(Windows windowType) { InstantiateWindow(windowType, false); }
public static void OpenWindow(Windows windowType) { InstantiateWindow(windowType, true); }
public async Task <int> Collect(IConsole console, int processId, string output, DumpTypeOption type) { if (processId == 0) { console.Error.WriteLine("ProcessId is required."); return(1); } try { if (output == null) { // Build timestamp based file path string timestamp = $"{DateTime.Now:yyyyMMdd_HHmmss}"; output = Path.Combine(Directory.GetCurrentDirectory(), RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? $"dump_{timestamp}.dmp" : $"core_{timestamp}"); } // Make sure the dump path is NOT relative. This path could be sent to the runtime // process on Linux which may have a different current directory. output = Path.GetFullPath(output); // Display the type of dump and dump path string dumpTypeMessage = type == DumpTypeOption.Mini ? "minidump" : "minidump with heap"; console.Out.WriteLine($"Writing {dumpTypeMessage} to {output}"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { // Get the process Process process = Process.GetProcessById(processId); await Windows.CollectDumpAsync(process, output, type); } else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { DiagnosticsHelpers.DumpType dumpType = type == DumpTypeOption.Heap ? DiagnosticsHelpers.DumpType.WithHeap : DiagnosticsHelpers.DumpType.Normal; // Send the command to the runtime to initiate the core dump var hr = DiagnosticsHelpers.GenerateCoreDump(processId, output, dumpType, diagnostics: false); if (hr != 0) { throw new InvalidOperationException($"Core dump generation FAILED 0x{hr:X8}"); } } else { throw new PlatformNotSupportedException($"Unsupported operating system: {RuntimeInformation.OSDescription}"); } } catch (Exception ex) when (ex is FileNotFoundException || ex is DirectoryNotFoundException || ex is UnauthorizedAccessException || ex is PlatformNotSupportedException || ex is InvalidDataException || ex is InvalidOperationException || ex is NotSupportedException) { console.Error.WriteLine($"{ex.Message}"); return(1); } console.Out.WriteLine($"Complete"); return(0); }
public void GetClassInfo_GlobalAtom() { var info = Windows.GetClassInfo(null, new Atom(32768)); }
private ServiceInfo ChangeStartTypeInWindows( string serviceName, StartType startType) { if (string.IsNullOrWhiteSpace(serviceName)) { return(new ServiceInfo { ServiceName = serviceName, ErrorCode = (int)Windows.Error.InvalidName, ErrorMessage = $"Service name \"{serviceName}\" is invalid" }); } var managerHandle = Windows.OpenSCManagerW( null, null, Windows.ServiceControlManagerAccessRight.Connect ); if (managerHandle == IntPtr.Zero) { var errorCode = Marshal.GetLastWin32Error(); return(new ServiceInfo { ServiceName = serviceName, ErrorCode = errorCode, ErrorMessage = $"Can not open Windows service controller manager, error code: {errorCode}" }); } var serviceInfo = new ServiceInfo { ServiceName = serviceName, StartType = startType }; var serviceHandle = Windows.OpenServiceW( managerHandle, serviceName, Windows.ServiceAccessRight.ChangeConfig | Windows.ServiceAccessRight.QueryConfig | Windows.ServiceAccessRight.QueryStatus ); if (serviceHandle == IntPtr.Zero) { var errorCode = Marshal.GetLastWin32Error(); serviceInfo.ErrorCode = errorCode; serviceInfo.ErrorMessage = $"Can not open Windows service \"{serviceName}\", error code: {errorCode}"; } else { var success = Windows.ChangeServiceConfigW( serviceHandle, Windows.ServiceType.NoChange, ConvertToWindows(startType), Windows.ErrorControlType.NoChange, null, null, IntPtr.Zero, null, null, null, null ); if (!success) { var errorCode = Marshal.GetLastWin32Error(); serviceInfo.ErrorCode = errorCode; serviceInfo.ErrorMessage = $"Can not change Windows service \"{serviceName}\" config, error code: {errorCode}"; } serviceInfo = UpdateCurrentStateInWindows(serviceHandle, serviceInfo); Windows.CloseServiceHandle(serviceHandle); } Windows.CloseServiceHandle(managerHandle); return(serviceInfo); }
protected virtual Task Refresh() { var fileName = default(string); var fileData = default(IFileData); var metaData = default(IDictionary <string, string>); var outputStream = this.PlaybackManager.CurrentStream; if (outputStream != null) { fileName = outputStream.FileName; if (outputStream.PlaylistItem.LibraryItem_Id.HasValue) { fileData = this.LibraryBrowser.Get(outputStream.PlaylistItem.LibraryItem_Id.Value); } else { fileData = outputStream.PlaylistItem; } lock (fileData.MetaDatas) { metaData = fileData.MetaDatas.ToDictionary( metaDataItem => metaDataItem.Name, metaDataItem => metaDataItem.Value, StringComparer.OrdinalIgnoreCase ); } } return(Windows.Invoke(() => { if (metaData != null) { this.FileName = fileName; this.FileData = fileData; this.Artist = metaData.GetValueOrDefault(CommonMetaData.Artist); this.Performer = metaData.GetValueOrDefault(CommonMetaData.Performer); this.Album = metaData.GetValueOrDefault(CommonMetaData.Album); this.Title = metaData.GetValueOrDefault(CommonMetaData.Title); this.Genre = metaData.GetValueOrDefault(CommonMetaData.Genre); this.Year = metaData.GetValueOrDefault(CommonMetaData.Year); this.Channels = metaData.GetValueOrDefault(CommonProperties.AudioChannels); this.SampleRate = metaData.GetValueOrDefault(CommonProperties.AudioSampleRate); this.BitsPerSample = metaData.GetValueOrDefault(CommonProperties.BitsPerSample); this.Bitrate = metaData.GetValueOrDefault(CommonProperties.AudioBitrate); this.HasData = true; } else { this.HasData = false; this.FileName = fileName; this.FileData = fileData; this.Artist = null; this.Performer = null; this.Album = null; this.Title = null; this.Genre = null; this.Year = null; this.Channels = null; this.SampleRate = null; this.BitsPerSample = null; this.Bitrate = null; } })); }
private void SetContextMenuEventHandlers() { _contextMenu.Opening += (sender, args) => _contextMenu.ShowHideTreeContextMenuItems(SelectedNode); _contextMenu.ConnectClicked += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo; if (selectedNodeAsContainer != null) { ConnectionInitiator.OpenConnection(selectedNodeAsContainer, ConnectionInfo.Force.DoNotJump); } else { ConnectionInitiator.OpenConnection(SelectedNode, ConnectionInfo.Force.DoNotJump); } }; _contextMenu.ConnectToConsoleSessionClicked += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo; if (selectedNodeAsContainer != null) { ConnectionInitiator.OpenConnection(selectedNodeAsContainer, ConnectionInfo.Force.UseConsoleSession | ConnectionInfo.Force.DoNotJump); } else { ConnectionInitiator.OpenConnection(SelectedNode, ConnectionInfo.Force.UseConsoleSession | ConnectionInfo.Force.DoNotJump); } }; _contextMenu.DontConnectToConsoleSessionClicked += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo; if (selectedNodeAsContainer != null) { ConnectionInitiator.OpenConnection(selectedNodeAsContainer, ConnectionInfo.Force.DontUseConsoleSession | ConnectionInfo.Force.DoNotJump); } else { ConnectionInitiator.OpenConnection(SelectedNode, ConnectionInfo.Force.DontUseConsoleSession | ConnectionInfo.Force.DoNotJump); } }; _contextMenu.ConnectInFullscreenClicked += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo; if (selectedNodeAsContainer != null) { ConnectionInitiator.OpenConnection(selectedNodeAsContainer, ConnectionInfo.Force.Fullscreen | ConnectionInfo.Force.DoNotJump); } else { ConnectionInitiator.OpenConnection(SelectedNode, ConnectionInfo.Force.Fullscreen | ConnectionInfo.Force.DoNotJump); } }; _contextMenu.ConnectWithNoCredentialsClick += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo; if (selectedNodeAsContainer != null) { ConnectionInitiator.OpenConnection(selectedNodeAsContainer, ConnectionInfo.Force.NoCredentials); } else { ConnectionInitiator.OpenConnection(SelectedNode, ConnectionInfo.Force.NoCredentials); } }; _contextMenu.ChoosePanelBeforeConnectingClicked += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo; if (selectedNodeAsContainer != null) { ConnectionInitiator.OpenConnection(selectedNodeAsContainer, ConnectionInfo.Force.OverridePanel | ConnectionInfo.Force.DoNotJump); } else { ConnectionInitiator.OpenConnection(SelectedNode, ConnectionInfo.Force.OverridePanel | ConnectionInfo.Force.DoNotJump); } }; _contextMenu.DisconnectClicked += (sender, args) => DisconnectConnection(SelectedNode); _contextMenu.TransferFileClicked += (sender, args) => SshTransferFile(); _contextMenu.DuplicateClicked += (sender, args) => DuplicateSelectedNode(); _contextMenu.RenameClicked += (sender, args) => RenameSelectedNode(); _contextMenu.DeleteClicked += (sender, args) => DeleteSelectedNode(); _contextMenu.ImportFileClicked += (sender, args) => { var selectedNodeAsContainer = SelectedNode as ContainerInfo ?? SelectedNode.Parent; Import.ImportFromFile(selectedNodeAsContainer, true); }; _contextMenu.ImportActiveDirectoryClicked += (sender, args) => Windows.Show(WindowType.ActiveDirectoryImport); _contextMenu.ImportPortScanClicked += (sender, args) => Windows.Show(WindowType.PortScan); _contextMenu.ExportFileClicked += (sender, args) => Export.ExportToFile(SelectedNode, Runtime.ConnectionTreeModel); _contextMenu.AddConnectionClicked += cMenTreeAddConnection_Click; _contextMenu.AddFolderClicked += cMenTreeAddFolder_Click; _contextMenu.SortAscendingClicked += (sender, args) => SortNodesRecursive(SelectedNode, ListSortDirection.Ascending); _contextMenu.SortDescendingClicked += (sender, args) => SortNodesRecursive(SelectedNode, ListSortDirection.Descending); _contextMenu.MoveUpClicked += cMenTreeMoveUp_Click; _contextMenu.MoveDownClicked += cMenTreeMoveDown_Click; _contextMenu.ExternalToolClicked += (sender, args) => StartExternalApp((ExternalTool)((ToolStripMenuItem)sender).Tag); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: _chunk = _sb.GetChunk(); goto case MessageType.DisplayChange; case MessageType.DisplayChange: // Get maximum size of client area cyClientMax = Windows.GetSystemMetrics(SystemMetric.MaximizedHeight); // Get character size for fixed-pitch font using (DeviceContext dc = window.GetDeviceContext()) { dc.SelectObject(StockFont.SystemFixed); dc.GetTextMetrics(out TextMetrics tm); cyChar = tm.Height; } cLinesMax = cyClientMax / cyChar; pmsg = new WindowMessage[cLinesMax]; cLines = 0; goto CalculateScroll; case MessageType.Size: cxClient = lParam.LowWord; cyClient = lParam.HighWord; CalculateScroll: rectScroll = Rectangle.FromLTRB(0, cyChar, cxClient, cyChar * (cyClient / cyChar)); window.Invalidate(true); return(0); case MessageType.KeyDown: case MessageType.KeyUp: case MessageType.Char: case MessageType.DeadChar: case MessageType.SystemKeyDown: case MessageType.SystemKeyUp: case MessageType.SystemChar: case MessageType.SystemDeadChar: // Rearrange storage array for (int i = cLinesMax - 1; i > 0; i--) { pmsg[i] = pmsg[i - 1]; } // Store new message pmsg[0] = new WindowMessage(window, message, wParam, lParam); cLines = Math.Min(cLines + 1, cLinesMax); // Scroll up the display window.ScrollWindow(new Point(0, -cyChar), rectScroll, rectScroll); break; // i.e., call DefWindowProc so Sys messages work case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SelectObject(StockFont.SystemFixed); dc.SetBackgroundMode(BackgroundMode.Transparent); dc.TextOut(default, "Message Key Char Repeat Scan Ext ALT Prev Tran".AsSpan()); dc.TextOut(default, "_______ ___ ____ ______ ____ ___ ___ ____ ____".AsSpan()); for (int i = 0; i < Math.Min(cLines, cyClient / cyChar - 1); i++) { bool iType; switch (pmsg[i].Type) { case MessageType.Char: case MessageType.SystemChar: case MessageType.DeadChar: case MessageType.SystemDeadChar: iType = true; break; default: iType = false; break; } _sb.Clear(); _sb.AppendFormat(iType ? "{0,-13} {1,3} {2,15} {3,6} {4,4} {5,3} {6,3} {7,4} {8,4}" : "{0,-13} {1,3} {2,-15} {3,6} {4,4} {5,3} {6,3} {7,4} {8,4} VirtualKey: {9}", pmsg[i].Type, pmsg[i].wParam.ToString(), iType ? $"0x{((uint)pmsg[i].wParam):X4} {(char)(uint)pmsg[i].wParam}" : Windows.GetKeyNameText(pmsg[i].lParam), pmsg[i].lParam.LowWord, pmsg[i].lParam.HighWord & 0xFF, (0x01000000 & pmsg[i].lParam) != 0 ? "Yes" : "No", (0x20000000 & pmsg[i].lParam) != 0 ? "Yes" : "No", (0x40000000 & pmsg[i].lParam) != 0 ? "Down" : "Up", (0x80000000 & pmsg[i].lParam) != 0 ? "Up" : "Down", (VirtualKey)pmsg[i].wParam); dc.TextOut(new Point(0, (cyClient / cyChar - 1 - i) * cyChar), _chunk.Span.Slice(0, _sb.Length)); } } return(0); }
private ServiceInfo QueryStartTypeInWindows(string serviceName) { if (string.IsNullOrWhiteSpace(serviceName)) { return(new ServiceInfo { ServiceName = serviceName, ErrorCode = (int)Windows.Error.InvalidName, ErrorMessage = $"Service name \"{serviceName}\" is invalid" }); } var managerHandle = Windows.OpenSCManagerW( null, null, Windows.ServiceControlManagerAccessRight.Connect ); if (managerHandle == IntPtr.Zero) { var errorCode = Marshal.GetLastWin32Error(); return(new ServiceInfo { ServiceName = serviceName, ErrorCode = errorCode, ErrorMessage = $"Can not open Windows service controller manager, error code: {errorCode}" }); } var serviceInfo = new ServiceInfo { ServiceName = serviceName }; var serviceHandle = Windows.OpenServiceW( managerHandle, serviceName, Windows.ServiceAccessRight.QueryConfig | Windows.ServiceAccessRight.QueryStatus ); if (serviceHandle == IntPtr.Zero) { var errorCode = Marshal.GetLastWin32Error(); serviceInfo.ErrorCode = errorCode; serviceInfo.ErrorMessage = $"Can not open Windows service \"{serviceName}\", error code: {errorCode}"; } else { const uint bytesAllocated = 8192; var serviceConfigPtr = Marshal.AllocHGlobal((int)bytesAllocated); try { uint bytes = 0; var success = Windows.QueryServiceConfigW( serviceHandle, serviceConfigPtr, bytesAllocated, ref bytes ); if (success) { var serviceConfig = (Windows.QueryServiceConfig)Marshal.PtrToStructure( serviceConfigPtr, typeof(Windows.QueryServiceConfig) ); serviceInfo.StartType = ConvertFromWindows(serviceConfig.dwStartType); } else { var errorCode = Marshal.GetLastWin32Error(); serviceInfo.ErrorCode = errorCode; serviceInfo.ErrorMessage = $"Can not query Windows service \"{serviceName}\" config, error code: {errorCode}"; } } catch (Exception e) { Log($"Can not query Windows service \"{serviceName}\" start type: {e.Message}"); } finally { Marshal.FreeHGlobal(serviceConfigPtr); } serviceInfo = UpdateCurrentStateInWindows(serviceHandle, serviceInfo); Windows.CloseServiceHandle(serviceHandle); } Windows.CloseServiceHandle(managerHandle); return(serviceInfo); }
/// <summary> /// Sets the toggle state to on or off. Sets the /// text in the control accordingly /// </summary> /// <param name="isOn">true if on</param> public void SetToggleState(Boolean isOn) { _toggleState = isOn; Windows.SetText(UIControl, _toggleState ? _onStateText : _offStateText); }
protected virtual async void OnActiveChanged(object sender, EventArgs e) { await Windows.Invoke(() => this.OnIsSavingChanged()).ConfigureAwait(false); }
/// <summary> /// Executes the specified command /// </summary> /// <param name="command">The command to execute</param> /// <param name="commandArg">Optional arguments for the command</param> /// <param name="handled">set this to true if handled</param> public override void OnRunCommand(String command, object commandArg, ref bool handled) { handled = true; switch (command) { case "CmdParitalMaximizeWindow": Windows.SetForegroundWindowSizePercent(Context.AppWindowPosition, Common.AppPreferences.WindowMaximizeSizePercent); break; case "SwitchAppWindow": DialogUtils.ShowTaskSwitcher(IEProcessName); break; case "CmdZoomIn": appTextInterface.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Add); appTextInterface.Resume(); break; case "CmdZoomOut": appTextInterface.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.Subtract); appTextInterface.Resume(); break; case "CmdZoomFit": appTextInterface.Pause(); AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D0); appTextInterface.Resume(); break; case "CmdFind": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F); break; case "IEGoBackward": AgentManager.Instance.Keyboard.Send(Keys.BrowserBack); break; case "IEGoForward": AgentManager.Instance.Keyboard.Send(Keys.LMenu, Keys.Right); break; case "IEHomePage": AgentManager.Instance.Keyboard.Send(Keys.BrowserHome); break; case "IEWebSearch": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.E); break; case "IEFavorites": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.I); //AgentController.Instance.Send(Keys.BrowserFavorites); break; case "IEHistory": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.H); break; case "IEAddFavorites": AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.D); break; case "IERefreshPage": AgentManager.Instance.Keyboard.Send(Keys.BrowserRefresh); break; case "IEAddressBar": AgentManager.Instance.Keyboard.Send(Keys.F4); break; case "IEBrowserMenu": showPanel(this, new PanelRequestEventArgs("InternetExplorerBrowserMenu", "IExplorer", WindowActivityMonitor.GetForegroundWindowInfo(), true)); break; case "IEZoomMenu": showPanel(this, new PanelRequestEventArgs("InternetExplorerZoomMenu", "IExplorer", WindowActivityMonitor.GetForegroundWindowInfo(), true)); break; case "IEEmailLink": _explorerElements.EmailPageAsLink(); break; default: base.OnRunCommand(command, commandArg, ref handled); break; } }
static void Main() { Windows.CreateMainWindowAndRun(new KeyView1(), "Keyboard Message Viewer #1"); }
/// <summary> /// Adds a window to this manager. /// </summary> /// <param name="window">The window to add.</param> public void AddWindow(IWindow window) { lock (_syncRoot) { Windows.Add(window); } }
static void Main() { Windows.CreateMainWindowAndRun(new DigClock(), "Digital Clock"); }
private void OnImportPortScanClicked(object sender, EventArgs e) { Windows.Show(WindowType.PortScan); }
/// <summary> /// Removes the given window from this manager. /// </summary> /// <param name="window">The window to remove.</param> /// <returns> /// Whether the removal was successful or not. One reason why this might return false is that the given window /// isn't being managed by this manager. /// </returns> public bool RemoveWindow(IWindow window) { lock (_syncRoot) { return(Windows.Remove(window)); } }
private void UpdateOnce() { var threads = Windows.GetProcessThreads(_pid); Dictionary <int, ThreadItem> newdictionary = new Dictionary <int, ThreadItem>(this.Dictionary); if (threads == null) { threads = new Dictionary <int, SystemThreadInformation>(); } // look for dead threads foreach (int tid in Dictionary.Keys) { if (!threads.ContainsKey(tid)) { ThreadItem item = this.Dictionary[tid]; if (item.ThreadQueryLimitedHandle != null) { item.ThreadQueryLimitedHandle.Dispose(); } this.OnDictionaryRemoved(item); newdictionary.Remove(tid); } } // Get resolve results. _messageQueue.Listen(); // look for new threads foreach (int tid in threads.Keys) { var t = threads[tid]; if (!Dictionary.ContainsKey(tid)) { ThreadItem item = new ThreadItem(); item.RunId = this.RunCount; item.Tid = tid; item.ContextSwitches = t.ContextSwitchCount; item.WaitReason = t.WaitReason; try { item.ThreadQueryLimitedHandle = new ThreadHandle(tid, Program.MinThreadQueryRights); try { item.PriorityI = (int)item.ThreadQueryLimitedHandle.GetBasePriorityWin32(); item.Priority = item.ThreadQueryLimitedHandle.GetBasePriorityWin32().ToString(); } catch { } if (KProcessHacker.Instance != null) { try { item.IsGuiThread = KProcessHacker.Instance.KphGetThreadWin32Thread(item.ThreadQueryLimitedHandle) != 0; } catch { } } if (OSVersion.HasCycleTime) { try { item.Cycles = item.ThreadQueryLimitedHandle.GetCycleTime(); } catch { } } } catch { } if (KProcessHacker.Instance != null && item.ThreadQueryLimitedHandle != null) { try { item.StartAddressI = KProcessHacker.Instance.GetThreadStartAddress(item.ThreadQueryLimitedHandle).ToIntPtr(); } catch { } } else { try { using (ThreadHandle thandle = new ThreadHandle(tid, ThreadAccess.QueryInformation)) { item.StartAddressI = thandle.GetWin32StartAddress(); } } catch { item.StartAddressI = t.StartAddress; } } if (!_waitedForLoad) { _waitedForLoad = true; try { if (_moduleLoadCompletedEvent.WaitOne(0, false)) { item.StartAddress = this.GetThreadBasicStartAddress( item.StartAddressI.ToUInt64(), out item.StartAddressLevel); } } catch { } } if (string.IsNullOrEmpty(item.StartAddress)) { item.StartAddress = Utils.FormatAddress(item.StartAddressI); item.StartAddressLevel = SymbolResolveLevel.Address; } this.QueueThreadResolveStartAddress(tid, item.StartAddressI.ToUInt64()); newdictionary.Add(tid, item); this.OnDictionaryAdded(item); } // look for modified threads else { ThreadItem item = Dictionary[tid]; ThreadItem newitem = item.Clone() as ThreadItem; newitem.JustResolved = false; newitem.ContextSwitchesDelta = t.ContextSwitchCount - newitem.ContextSwitches; newitem.ContextSwitches = t.ContextSwitchCount; newitem.WaitReason = t.WaitReason; try { newitem.PriorityI = (int)newitem.ThreadQueryLimitedHandle.GetBasePriorityWin32(); newitem.Priority = newitem.ThreadQueryLimitedHandle.GetBasePriorityWin32().ToString(); } catch { } if (KProcessHacker.Instance != null) { try { newitem.IsGuiThread = KProcessHacker.Instance.KphGetThreadWin32Thread(newitem.ThreadQueryLimitedHandle) != 0; } catch { } } if (OSVersion.HasCycleTime) { try { ulong thisCycles = newitem.ThreadQueryLimitedHandle.GetCycleTime(); newitem.CyclesDelta = thisCycles - newitem.Cycles; newitem.Cycles = thisCycles; } catch { } } if (newitem.StartAddressLevel == SymbolResolveLevel.Address) { if (_moduleLoadCompletedEvent.WaitOne(0, false)) { newitem.StartAddress = this.GetThreadBasicStartAddress( newitem.StartAddressI.ToUInt64(), out newitem.StartAddressLevel); } // If we couldn't resolve it to a module+offset, // use the StartAddress (instead of the Win32StartAddress) // and queue the resolve again. if ( item.StartAddressLevel == SymbolResolveLevel.Address && item.JustResolved) { if (item.StartAddressI != t.StartAddress) { item.StartAddressI = t.StartAddress; this.QueueThreadResolveStartAddress(tid, item.StartAddressI.ToUInt64()); } } } if ( newitem.ContextSwitches != item.ContextSwitches || newitem.ContextSwitchesDelta != item.ContextSwitchesDelta || newitem.Cycles != item.Cycles || newitem.CyclesDelta != item.CyclesDelta || newitem.IsGuiThread != item.IsGuiThread || newitem.Priority != item.Priority || newitem.StartAddress != item.StartAddress || newitem.WaitReason != item.WaitReason || item.JustResolved ) { newdictionary[tid] = newitem; this.OnDictionaryModified(item, newitem); } } } Dictionary = newdictionary; }
/// <summary> /// Gets the window with a context current on this thread. /// </summary> /// <returns>The window with a context current on this thread.</returns> public IWindow GetCurrent() => Windows.FirstOrDefault(x => x.IsCurrentContext);
protected virtual void OnCanGetDataChanged(object sender, EventArgs e) { var task = Windows.Invoke(this.Update); }
private void OnImportActiveDirectoryClicked(object sender, EventArgs e) { Windows.Show(WindowType.ActiveDirectoryImport); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: window.SetWindowLong(0, IntPtr.Zero); // on/off flag return(0); case MessageType.KeyDown: // Send most key presses to the parent window if ((VirtualKey)wParam != VirtualKey.Return && (VirtualKey)wParam != VirtualKey.Space) { window.GetParent().SendMessage(message, wParam, lParam); return(0); } // For Return and Space, fall through to toggle the square goto case MessageType.LeftButtonDown; case MessageType.LeftButtonDown: window.SetWindowLong(0, (IntPtr)(1 ^ (int)window.GetWindowLong(0))); window.SetFocus(); window.Invalidate(false); return(0); // For focus messages, invalidate the window for repaint case MessageType.SetFocus: Checker4.idFocus = (int)window.GetWindowLong(WindowLong.Id); // Fall through goto case MessageType.KillFocus; case MessageType.KillFocus: window.Invalidate(); return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { Rectangle rect = window.GetClientRectangle(); dc.Rectangle(rect); if (window.GetWindowLong(0) != IntPtr.Zero) { dc.MoveTo(new Point(0, 0)); dc.LineTo(new Point(rect.Right, rect.Bottom)); dc.MoveTo(new Point(0, rect.Bottom)); dc.LineTo(new Point(rect.Right, 0)); } // Draw the "focus" rectangle if (window == Windows.GetFocus()) { rect.Inflate(rect.Width / -10, rect.Height / -10); dc.SelectObject(StockBrush.Null); using PenHandle pen = Gdi.CreatePen(PenStyle.Dash, 0, default); dc.SelectObject(pen); dc.Rectangle(rect); dc.SelectObject(StockPen.Black); } } return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }
private static void VerifyCom(void *p, Guid iid) { void *_; Debug.Assert(Windows.SUCCEEDED(((IUnknown *)p)->QueryInterface(&iid, &_))); }
private void mMenToolsOptions_Click(object sender, EventArgs e) { Windows.Show(WindowType.Options); }
/// <summary> /// Handler for highlight off. Update the tooltip /// </summary> /// <param name="widget">Widget</param> /// <param name="handled">was it handled</param> private void widget_EvtHighlightOff(Widget widget, out bool handled) { handled = false; Windows.SetText(labelToolTip, String.Empty); }
private void mMenToolsComponentsCheck_Click(object sender, EventArgs e) { Windows.Show(WindowType.ComponentsCheck); }
protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { int x, y; switch (message) { case MessageType.Create: for (x = 0; x < DIVISIONS; x++) { for (y = 0; y < DIVISIONS; y++) { _hwndChild[x, y] = _childClass.CreateWindow( style: WindowStyles.ChildWindow | WindowStyles.Visible, parentWindow: window, menuHandle: (MenuHandle)(y << 8 | x)); } } return(0); case MessageType.Size: _cxBlock = lParam.LowWord / DIVISIONS; _cyBlock = lParam.HighWord / DIVISIONS; for (x = 0; x < DIVISIONS; x++) { for (y = 0; y < DIVISIONS; y++) { _hwndChild[x, y].MoveWindow( new Rectangle(x * _cxBlock, y * _cyBlock, _cxBlock, _cyBlock), repaint: true); } } return(0); case MessageType.LeftButtonDown: Windows.MessageBeep(BeepType.Ok); return(0); // On set-focus message, set focus to child window case MessageType.SetFocus: window.GetDialogItem(idFocus).SetFocus(); return(0); // On key-down message, possibly change the focus window case MessageType.KeyDown: x = idFocus & 0xFF; y = idFocus >> 8; switch ((VirtualKey)wParam) { case VirtualKey.Up: y--; break; case VirtualKey.Down: y++; break; case VirtualKey.Left: x--; break; case VirtualKey.Right: x++; break; case VirtualKey.Home: x = y = 0; break; case VirtualKey.End: x = y = DIVISIONS - 1; break; default: return(0); } x = (x + DIVISIONS) % DIVISIONS; y = (y + DIVISIONS) % DIVISIONS; idFocus = y << 8 | x; window.GetDialogItem(idFocus).SetFocus(); return(0); } return(base.WindowProcedure(window, message, wParam, lParam)); }