public Telegram(ButtonBase target) { Target = target; }
private void Grid_Click(object sender, RoutedEventArgs e) { ButtonBase btn = e.Source as ButtonBase; if (btn != null) { switch (btn.Uid) { case "Min": this.WindowState = WindowState.Minimized; break; case "Max": if (this.btnMax.IsChecked == true) { this.WindowState = WindowState.Maximized; this.BorderThickness = new Thickness(0); } else { this.WindowState = WindowState.Normal; this.BorderThickness = new Thickness(10); } break; case "Close": this.Close(); break; case "Expand": Scale *= 1.1; Scale = Scale > 20 ? 20 : Scale; this.scale.ScaleX = this.scale.ScaleY = Scale; translate.X = translate.Y = 0; break; case "Shrink": Scale *= 0.9; Scale = Scale < 0.1 ? 0.1 : Scale; this.scale.ScaleX = this.scale.ScaleY = Scale; translate.X = translate.Y = 0; break; case "Rotate": double angle = this.rotate.Angle + 90; this.rotate.Angle = angle % 360; translate.X = translate.Y = 0; SetScale(this); break; case "Save": Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog(); sfd.Filter = "图像文件(*.jpg)|*.jpg|图像文件(*.bmp)|*.bmp"; string gifFilter = "|图像文件(*.gif)|*.gif"; string extension = "jpg"; if (this.img.FilePath.ToUpper().EndsWith(".GIF")) { sfd.Filter = sfd.Filter + gifFilter; sfd.FilterIndex = 3; extension = "gif"; } sfd.FileName = string.Format("IM图片{0}.{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), extension); if (sfd.ShowDialog() == true) { if (File.Exists(this.img.FilePath)) { File.Copy(this.img.FilePath, sfd.FileName, true); } else { using (MemoryStream ms = new MemoryStream()) { JpegBitmapEncoder encoder = new JpegBitmapEncoder(); //BmpBitmapEncoder encoder = new BmpBitmapEncoder(); BitmapImage img = new BitmapImage(new Uri(this.img.FilePath, UriKind.RelativeOrAbsolute)); encoder.Frames.Add(BitmapFrame.Create(img as BitmapSource)); encoder.Save(ms); ms.Seek(0, SeekOrigin.Begin); var bmpArray = ms.ToArray(); File.WriteAllBytes(sfd.FileName, bmpArray); } } } break; } } }
internal CheckableControlBaseAdapter(ButtonBase control) : base(control) { }
private void SinglePlayer_OnClick(ButtonBase btn) { SceneController.Ins.InitMode1Scene(); NowScene.Ins.LoadScene(SceneController.Ins.mode1Scene); }
private void QuitBtn_OnClick(ButtonBase btn) { Environment.Exit(0); }
/// <summary> /// Sets the style of the Button /// </summary> /// <param name="Button">The Button that will change its style</param> /// <param name="style">The new style of the Button</param> /// <remarks> /// If style is 0 then sets a popup style to the Button, otherwise sets a standard style to the Button. /// </remarks> public static void setStyle(ButtonBase Button, int style) { if ( (style == 0 ) || (style == 67108864) || (style == 33554432) ) Button.FlatStyle = System.Windows.Forms.FlatStyle.Popup; else if ( (style == 2097152) || (style == 1048576) || (style == 16777216 ) ) Button.FlatStyle = System.Windows.Forms.FlatStyle.Standard; else throw new System.ArgumentException("illegal style: " + style); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { MenuHost = Template.FindName("PART_MenuHost", this) as FrameworkElement; if (MenuHost != null) { MenuHost.InputBindings.Add(new KeyBinding(mainModel.ToggleMainMenuCommand, new KeyGesture(Key.Back))); MenuHost.InputBindings.Add(new KeyBinding(mainModel.ToggleMainMenuCommand, new KeyGesture(Key.Escape))); MenuHost.InputBindings.Add(new XInputBinding(mainModel.ToggleMainMenuCommand, XInputButton.Back)); MenuHost.InputBindings.Add(new XInputBinding(mainModel.ToggleMainMenuCommand, XInputButton.B)); } ButtonSettings = Template.FindName("PART_ButtonSettings", this) as ButtonBase; if (ButtonSettings != null) { ButtonSettings.Command = mainModel.ToggleSettingsMenuCommand; BindingTools.SetBinding(ButtonSettings, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.MainMenuFocused)); } ButtonExitPlaynite = Template.FindName("PART_ButtonExitPlaynite", this) as ButtonBase; if (ButtonExitPlaynite != null) { ButtonExitPlaynite.Command = mainModel.ExitCommand; } ButtonSwitchToDesktop = Template.FindName("PART_ButtonSwitchToDesktop", this) as ButtonBase; if (ButtonSwitchToDesktop != null) { ButtonSwitchToDesktop.Command = mainModel.SwitchToDesktopCommand; } ButtonPatreon = Template.FindName("PART_ButtonPatreon", this) as ButtonBase; if (ButtonPatreon != null) { ButtonPatreon.Command = new NavigateUrlCommand(); ButtonPatreon.CommandParameter = UrlConstants.Patreon; } ButtoFeedback = Template.FindName("PART_ButtoFeedback", this) as ButtonBase; if (ButtoFeedback != null) { ButtoFeedback.Command = new NavigateUrlCommand(); if (PlayniteEnvironment.ReleaseChannel == ReleaseChannel.Beta) { ButtoFeedback.CommandParameter = UrlConstants.IssuesTesting; } else { ButtoFeedback.CommandParameter = UrlConstants.Issues; } } ButtonRestartSystem = Template.FindName("PART_ButtonRestartSystem", this) as ButtonBase; if (ButtonRestartSystem != null) { ButtonRestartSystem.Command = mainModel.RestartSystemCommand; } ButtonShutdownSystem = Template.FindName("PART_ButtonShutdownSystem", this) as ButtonBase; if (ButtonShutdownSystem != null) { ButtonShutdownSystem.Command = mainModel.ShutdownSystemCommand; } ButtonSleepSystem = Template.FindName("PART_ButtonSleepSystem", this) as ButtonBase; if (ButtonSleepSystem != null) { ButtonSleepSystem.Command = mainModel.SleepSystemCommand; } ButtonHibernateSystem = Template.FindName("PART_ButtonHibernateSystem", this) as ButtonBase; if (ButtonHibernateSystem != null) { ButtonHibernateSystem.Command = mainModel.HibernateSystemCommand; } } }
protected override void OnApplyTemplate() #endif { base.OnApplyTemplate(); //---------------------------- // Get a reference to the UI elements defined in the control template: //---------------------------- _horizontalRoot = this.GetTemplateChild("HorizontalRoot") as FrameworkElement; _horizontalThumb = this.GetTemplateChild("HorizontalThumb") as Thumb; _horizontalSmallDecrease = this.GetTemplateChild("HorizontalSmallDecrease") as ButtonBase; _horizontalSmallIncrease = this.GetTemplateChild("HorizontalSmallIncrease") as ButtonBase; _horizontalLargeDecrease = this.GetTemplateChild("HorizontalLargeDecrease") as ButtonBase; _horizontalLargeIncrease = this.GetTemplateChild("HorizontalLargeIncrease") as ButtonBase; _verticalRoot = this.GetTemplateChild("VerticalRoot") as FrameworkElement; _verticalThumb = this.GetTemplateChild("VerticalThumb") as Thumb; _verticalSmallDecrease = this.GetTemplateChild("VerticalSmallDecrease") as ButtonBase; _verticalSmallIncrease = this.GetTemplateChild("VerticalSmallIncrease") as ButtonBase; _verticalLargeDecrease = this.GetTemplateChild("VerticalLargeDecrease") as ButtonBase; _verticalLargeIncrease = this.GetTemplateChild("VerticalLargeIncrease") as ButtonBase; //---------------------------- // Register the events: //---------------------------- if (_horizontalThumb != null) { _horizontalThumb.DragStarted += HorizontalThumb_DragStarted; _horizontalThumb.DragDelta += HorizontalThumb_DragDelta; _horizontalThumb.DragCompleted += HorizontalThumb_DragCompleted; } if (_verticalThumb != null) { _verticalThumb.DragStarted += VerticalThumb_DragStarted; _verticalThumb.DragDelta += VerticalThumb_DragDelta; _verticalThumb.DragCompleted += VerticalThumb_DragCompleted; } if (_horizontalSmallDecrease != null) { _horizontalSmallDecrease.Click += SmallDecrease_Click; } if (_verticalSmallDecrease != null) { _verticalSmallDecrease.Click += SmallDecrease_Click; } if (_horizontalLargeDecrease != null) { _horizontalLargeDecrease.Click += LargeDecrease_Click; } if (_verticalLargeDecrease != null) { _verticalLargeDecrease.Click += LargeDecrease_Click; } if (_horizontalSmallIncrease != null) { _horizontalSmallIncrease.Click += SmallIncrease_Click; } if (_verticalSmallIncrease != null) { _verticalSmallIncrease.Click += SmallIncrease_Click; } if (_horizontalLargeIncrease != null) { _horizontalLargeIncrease.Click += LargeIncrease_Click; } if (_verticalLargeIncrease != null) { _verticalLargeIncrease.Click += LargeIncrease_Click; } //---------------------------- // Display the horizontal or vertical root depending on the orientation: //---------------------------- if (_verticalRoot != null) { _verticalRoot.Visibility = (this.Orientation == Orientation.Vertical ? Visibility.Visible : Visibility.Collapsed); } if (_horizontalRoot != null) { _horizontalRoot.Visibility = (this.Orientation == Orientation.Horizontal ? Visibility.Visible : Visibility.Collapsed); } if (TryUpdateSizeAndPositionOfUIElements()) { _controlWasProperlyDrawn = true; } }
public ApiResult SaveAndPublishMenu(string json, UserContext userContext, DomainContext domainContext) { MenuEntity menuEntity = new MenuEntity(); menuEntity.DomainId = userContext.User.Domain; menuEntity.Menu = json; _dataBase.Remove(menuEntity); _dataBase.Insert(menuEntity); ApiResult result = new ApiResult(); //未认证订阅号没有自定义菜单权限 if (domainContext.Authorizer == null || domainContext.Authorizer.AuthorizationType == EnumAuthorizationType.UnauthorizedSubscription) { result.Success = false; result.Message = "未认证订阅号没有自定义菜单权限。"; return(result); } List <ButtonBase> _buttonList = new List <ButtonBase>(); JObject jObject = JObject.Parse(json); #region 解析 JArray buttonArray = (JArray)jObject["button"]; foreach (var button in buttonArray) { if (button["sub_button"] == null || button["sub_button"].Count() == 0) { ButtonBase newButton = null; switch (button["type"].ToString()) { case "wxc_function": newButton = GetWxcFunctionButton(button, domainContext); break; case "click": newButton = GetClickButton(button, domainContext); break; case "view": newButton = JsonHelper.Deserialize <ButtonView>(button.ToString()); break; case "wxc_campaign": newButton = GetWxcCampaignButton(button, domainContext); break; case "wxc_information": newButton = GetWxcInformationButton(button, domainContext); break; case "wxc_customForm": newButton = GetWxcCustomFormButton(button, domainContext); break; case "mediaId": newButton = GetMediaIdButton(button); break; } _buttonList.Add(newButton); } else { ParentButton parentButton = JsonHelper.Deserialize <ParentButton>(button.ToString()); parentButton.SubButton = new List <ButtonBase>(); JArray subButtonArray = (JArray)button["sub_button"]; foreach (var subButton in subButtonArray) { ButtonBase newSubButton = null; switch (subButton["type"].ToString()) { case "wxc_function": newSubButton = GetWxcFunctionButton(subButton, domainContext); break; case "click": newSubButton = GetClickButton(subButton, domainContext); break; case "view": newSubButton = JsonHelper.Deserialize <ButtonView>(subButton.ToString()); break; case "wxc_campaign": newSubButton = GetWxcCampaignButton(subButton, domainContext); break; case "wxc_information": newSubButton = GetWxcInformationButton(subButton, domainContext); break; case "wxc_customForm": newSubButton = GetWxcCustomFormButton(subButton, domainContext); break; case "mediaId": newSubButton = GetMediaIdButton(subButton); break; } parentButton.SubButton.Add(newSubButton); } _buttonList.Add(parentButton); } } #endregion ButtonWrapper menu = new ButtonWrapper(); menu.Button = _buttonList; RequestApiResult apiResult = MenuApi.Create(menu, domainContext.AccessToken); result.Success = apiResult.Success; result.Message = apiResult.Message; return(result); }
/// protected ButtonBaseAutomationPeer(ButtonBase owner) : base(owner) { }
private void OnRelatedControlClick(object sender, RoutedEventArgs e) { ButtonBase b = (ButtonBase)sender; this.Frame.Navigate(typeof(ItemPage), b.DataContext.ToString()); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); if (Template != null) { MenuHost = Template.FindName("PART_MenuHost", this) as FrameworkElement; if (MenuHost != null) { MenuHost.InputBindings.Add(new KeyBinding(mainModel.CloseAdditionalFiltersCommand, new KeyGesture(Key.Back))); MenuHost.InputBindings.Add(new KeyBinding(mainModel.CloseAdditionalFiltersCommand, new KeyGesture(Key.Escape))); MenuHost.InputBindings.Add(new KeyBinding() { Command = mainModel.ToggleFiltersCommand, Key = Key.F }); MenuHost.InputBindings.Add(new XInputBinding(mainModel.CloseAdditionalFiltersCommand, XInputButton.B)); } ButtonBack = Template.FindName("PART_ButtonBack", this) as ButtonBase; if (ButtonBack != null) { ButtonBack.Command = mainModel.CloseAdditionalFiltersCommand; BindingTools.SetBinding(ButtonBack, FocusBahaviors.FocusBindingProperty, mainModel, nameof(mainModel.FilterAdditionalPanelVisible)); } ItemsHost = Template.FindName("PART_ItemsHost", this) as ItemsControl; if (ItemsHost != null) { XNamespace pns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"; ItemsHost.ItemsPanel = Xaml.FromString <ItemsPanelTemplate>(new XDocument( new XElement(pns + nameof(ItemsPanelTemplate), new XElement(pns + nameof(VirtualizingStackPanel))) ).ToString()); ItemsHost.Template = Xaml.FromString <ControlTemplate>(new XDocument( new XElement(pns + nameof(ControlTemplate), new XElement(pns + nameof(ScrollViewer), new XAttribute(nameof(ScrollViewer.Focusable), false), new XAttribute(nameof(ScrollViewer.HorizontalScrollBarVisibility), ScrollBarVisibility.Disabled), new XAttribute(nameof(ScrollViewer.VerticalScrollBarVisibility), ScrollBarVisibility.Auto), new XAttribute(nameof(ScrollViewer.CanContentScroll), true), new XElement(pns + nameof(ItemsPresenter)))) ).ToString()); AssignFilter("LOCGenreLabel", "PART_ButtonGenre", GameField.Genres, nameof(FilterSettings.Genre)); AssignFilter("LOCGameReleaseYearTitle", "PART_ButtonReleaseYear", GameField.ReleaseYear, nameof(FilterSettings.ReleaseYear)); AssignFilter("LOCDeveloperLabel", "PART_ButtonDeveloper", GameField.Developers, nameof(FilterSettings.Developer)); AssignFilter("LOCPublisherLabel", "PART_ButtonPublisher", GameField.Publishers, nameof(FilterSettings.Publisher)); AssignFilter("LOCFeatureLabel", "PART_ButtonFeature", GameField.Features, nameof(FilterSettings.Feature)); AssignFilter("LOCTagLabel", "PART_ButtonTag", GameField.Tags, nameof(FilterSettings.Tag)); AssignFilter("LOCTimePlayed", "PART_ButtonPlayTime", GameField.Playtime, nameof(FilterSettings.PlayTime)); AssignFilter("LOCCompletionStatus", "PART_ButtonCompletionStatus", GameField.CompletionStatus, nameof(FilterSettings.CompletionStatuses)); AssignFilter("LOCSeriesLabel", "PART_ButtonSeries", GameField.Series, nameof(FilterSettings.Series)); AssignFilter("LOCRegionLabel", "PART_ButtonRegion", GameField.Regions, nameof(FilterSettings.Region)); AssignFilter("LOCSourceLabel", "PART_ButtonSource", GameField.Source, nameof(FilterSettings.Source)); AssignFilter("LOCAgeRatingLabel", "PART_ButtonAgeRating", GameField.AgeRatings, nameof(FilterSettings.AgeRating)); AssignFilter("LOCUserScore", "PART_ButtonUserScore", GameField.UserScore, nameof(FilterSettings.UserScore)); AssignFilter("LOCCommunityScore", "PART_ButtonCommunityScore", GameField.CommunityScore, nameof(FilterSettings.CommunityScore)); AssignFilter("LOCCriticScore", "PART_ButtonCriticScore", GameField.CriticScore, nameof(FilterSettings.CriticScore)); AssignFilter("LOCGameLastActivityTitle", "PART_ButtonLastActivity", GameField.LastActivity, nameof(FilterSettings.LastActivity)); AssignFilter("LOCAddedLabel", "PART_ButtonAdded", GameField.Added, nameof(FilterSettings.Added)); AssignFilter("LOCModifiedLabel", "PART_ButtonModified", GameField.Modified, nameof(FilterSettings.Modified)); } } }
public void EnqueueClickButton(ButtonBase button) { EnqueueClickButton(() => button); }
private static void CastAndVerifyItem(object item, out IToolStripElement element, out ButtonBase button) { if (item == null) { throw new ArgumentNullException("element", "ToolStrip.Elements doesn't accept null elements."); } element = item as IToolStripElement; if (element == null) { throw new ArgumentException("ToolStrip.Elements only accepts ButtonBase, IToolStripElement elements.", "element"); } button = item as ButtonBase; if (button == null) { throw new ArgumentException("ToolStrip.Elements only accepts ButtonBase, IToolStripElement elements.", "element"); } }
/// <summary> /// Sets an specific text and/or image to the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="control">The control to be contained analized to get the text and/or image for the Button</param> public static void SetButton(ButtonBase Button,System.Windows.Forms.Control control) { if(control.GetType().FullName == "System.Windows.Forms.Label") { Button.Image = ((System.Windows.Forms.Label)control).Image; Button.Text = ((System.Windows.Forms.Label)control).Text; Button.ImageAlign = ((System.Windows.Forms.Label)control).ImageAlign; Button.TextAlign = ((System.Windows.Forms.Label)control).TextAlign; } else { if(control.GetType().FullName == "System.Windows.Forms.PictureBox")//Tentative to see maps of UIGraphic { Button.Image = ((System.Windows.Forms.PictureBox)control).Image; Button.ImageAlign = ((System.Windows.Forms.Label)control).ImageAlign; } else Button.Text = control.Text; } Button.FlatStyle = System.Windows.Forms.FlatStyle.Standard; }
protected override void OnAttached() { _associatedButton = AssociatedObject; _associatedButton.Click += AssociatedButtonClick; }
/// <summary> /// Sets or remove the focus of an specific button within a panel. /// </summary> /// <param name="theArrayList">A reference to the penel whitch contains the button.</param> /// <param name="theButton">The button we want to pass the focus to.</param> /// <param name="theValue">A boolean value indicating whether the button should get the focus or lose it.</param> public static void SetSelected(System.Collections.IList theArrayList, ButtonBase theButton, bool theValue) { if(theArrayList.Contains(theButton)) { // while(theArrayList.GetEnumerator().MoveNext()) foreach (object item in theArrayList) { Control ctrl = item as Control; if (ctrl != null) { if (ctrl.Equals(theButton)) { if (theValue == true) ctrl.Select(); else ctrl.FindForm().Select(); } } } } }
internal CheckBoxStandardAdapter(ButtonBase control) : base(control) { }
/// <summary> /// Receives a Button instance and sets the Text and Image properties. /// </summary> /// <param name="buttonInstance">Button instance to be set.</param> /// <param name="buttonText">Value to be set to Text.</param> /// <param name="icon">Value to be set to Image.</param> public static void SetStandardButton (ButtonBase buttonInstance, System.String buttonText , System.Drawing.Image icon ) { buttonInstance.Text = buttonText; buttonInstance.Image = icon; }
internal ButtonPopupAdapter(ButtonBase control) : base(control) { }
private void BackBtn_OnClick(ButtonBase btn) { SceneController.Ins.InitMainScene(); NowScene.Ins.LoadScene(SceneController.Ins.mainScene); }
private void PaintWorker(PaintEventArgs e, bool up, CheckState state) { ButtonBaseAdapter.LayoutData data2; up = up && (state == CheckState.Unchecked); ButtonBaseAdapter.ColorData colors = base.PaintRender(e.Graphics).Calculate(); if (Application.RenderWithVisualStyles) { data2 = this.PaintLayout(e, true).Layout(); } else { data2 = this.PaintLayout(e, up).Layout(); } Graphics g = e.Graphics; ButtonBase control = base.Control; if (Application.RenderWithVisualStyles) { this.PaintThemedButtonBackground(e, base.Control.ClientRectangle, up); } else { Brush background = null; if (state == CheckState.Indeterminate) { background = ButtonBaseAdapter.CreateDitherBrush(colors.highlight, colors.buttonFace); } try { Rectangle clientRectangle = base.Control.ClientRectangle; if (up) { clientRectangle.Inflate(-2, -2); } else { clientRectangle.Inflate(-1, -1); } base.PaintButtonBackground(e, clientRectangle, background); } finally { if (background != null) { background.Dispose(); background = null; } } } base.PaintImage(e, data2); if (Application.RenderWithVisualStyles) { data2.focus.Inflate(1, 1); } base.PaintField(e, data2, colors, colors.windowText, true); if (!Application.RenderWithVisualStyles) { Rectangle r = base.Control.ClientRectangle; if (base.Control.IsDefault) { r.Inflate(-1, -1); } ButtonBaseAdapter.DrawDefaultBorder(g, r, colors.windowFrame, base.Control.IsDefault); if (up) { base.Draw3DBorder(g, r, colors, up); } else { ControlPaint.DrawBorder(g, r, colors.buttonShadow, ButtonBorderStyle.Solid); } } }
private void StartBtn_OnClick(ButtonBase btn) { SceneController.Ins.InitModeChoiceScene(); NowScene.Ins.LoadScene(SceneController.Ins.modeChoiceScene); }
protected void RelatedControl_Click(object sender, RoutedEventArgs e) { ButtonBase b = (ButtonBase)sender; NavigationRootPage.RootFrame.Navigate(typeof(ItemPage), b.Content.ToString()); }
internal RadioButtonStandardAdapter(ButtonBase control) : base(control) { }
internal CheckBoxPopupAdapter(ButtonBase control) : base(control) { }
internal CheckBoxFlatAdapter(ButtonBase control) : base(control) { }
/// <summary> /// Invoked when the content of this control has been changed. This method will add the dynamic controls automatically. /// </summary> /// <param name="oldContent">Old content.</param> /// <param name="newContent">New content.</param> protected override void OnContentChanged(object oldContent, object newContent) { base.OnContentChanged(oldContent, newContent); if (CatelEnvironment.IsInDesignMode) { return; } var newContentAsFrameworkElement = newContent as FrameworkElement; if (_isWrapped || !_wrapControlService.CanBeWrapped(newContentAsFrameworkElement)) { return; } var languageService = ServiceLocator.Default.ResolveType <ILanguageService>(); if (IsOKButtonAvailable) { var button = DataWindowButton.FromAsync(languageService.GetString("OK"), OnOkExecuteAsync, OnOkCanExecute); button.IsDefault = (DefaultButton == DataWindowDefaultButton.OK); _buttons.Add(button); } if (IsCancelButtonAvailable) { var button = DataWindowButton.FromAsync(languageService.GetString("Cancel"), OnCancelExecuteAsync, OnCancelCanExecute); button.IsCancel = true; _buttons.Add(button); } if (IsApplyButtonAvailable) { var button = DataWindowButton.FromAsync(languageService.GetString("Apply"), OnApplyExcuteAsync, OnApplyCanExecute); button.IsDefault = (DefaultButton == DataWindowDefaultButton.Apply); _buttons.Add(button); } if (IsCloseButtonAvailable) { var button = DataWindowButton.FromSync(languageService.GetString("Close"), OnCloseExecute, OnCloseCanExecute); button.IsDefault = (DefaultButton == DataWindowDefaultButton.Close); _buttons.Add(button); } foreach (var button in _buttons) { _commands.Add(button.Command); } var wrapOptions = WrapControlServiceWrapOptions.GenerateWarningAndErrorValidatorForDataContext; switch (_infoBarMessageControlGenerationMode) { case InfoBarMessageControlGenerationMode.None: break; case InfoBarMessageControlGenerationMode.Inline: wrapOptions |= WrapControlServiceWrapOptions.GenerateInlineInfoBarMessageControl; break; case InfoBarMessageControlGenerationMode.Overlay: wrapOptions |= WrapControlServiceWrapOptions.GenerateOverlayInfoBarMessageControl; break; } _isWrapped = true; var contentGrid = _wrapControlService.Wrap(newContentAsFrameworkElement, wrapOptions, _buttons.ToArray(), this); var internalGrid = contentGrid.FindVisualDescendant(obj => (obj is FrameworkElement) && string.Equals(((FrameworkElement)obj).Name, WrapControlServiceControlNames.InternalGridName)) as Grid; if (internalGrid != null) { internalGrid.SetResourceReference(StyleProperty, "WindowGridStyle"); newContentAsFrameworkElement.FocusFirstControl(); _defaultOkCommand = (from button in _buttons where button.IsDefault select button.Command).FirstOrDefault(); _defaultOkElement = _wrapControlService.GetWrappedElement <ButtonBase>(contentGrid, WrapControlServiceControlNames.DefaultOkButtonName); _defaultCancelCommand = (from button in _buttons where button.IsCancel select button.Command).FirstOrDefault(); InternalGrid = internalGrid; OnInternalGridChanged(); } }
internal DropDownButtonAdapter(ButtonBase control) : base(control) { }
public static void AddKeyboardAccelerator(this ButtonBase button, Key key, ModifierKeys modifiers) { AddKeyboardAccelerator(button, new KeyGesture(key, modifiers)); }
/// <summary> /// Sets the specific Text and Style for the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="label">The text associated with the Button</param> /// <param name="style">The style of the Button</param> public static void SetButton(ButtonBase Button, System.String label, int style) { Button.Text = label; setStyle(Button,style); }
public static void AddKeyboardAccelerator(this ButtonBase button, Key key, ModifierKeys modifiers, string displayString) { AddKeyboardAccelerator(button, new KeyGesture(key, modifiers, displayString)); }
/// <summary> /// Indicates whether an specific button is selected or not within a panel /// </summary> /// <param name="theArrayList">A reference to the penel where we will look in.</param> /// <param name="theButton">The button we want to know if it is selected.</param> /// <returns>A boolean value indicating if the button is selected within the panel.</returns> public static bool IsSelected(System.Collections.IList theArrayList, ButtonBase theButton) { if(theArrayList.Contains(theButton)) { return (theButton.Focused)? true : false; } return false; }
public static void AddKeyboardAccelerator(this ButtonBase button, Key key) { AddKeyboardAccelerator(button, new KeyGesture(key)); }
/// <summary> /// Sets an specific text and/or image to the Button /// </summary> /// <param name="Button">The button to be set</param> /// <param name="control">The control to be contained by the button</param> /// <param name="style">The style of the button</param> public static void SetButton(ButtonBase Button,System.Windows.Forms.Control control,int style) { SetButton(Button,control); setStyle(Button,style); }
private void RankBtn_OnClick(ButtonBase btn) { SceneController.Ins.InitRankScene(); NowScene.Ins.LoadScene(SceneController.Ins.rankScene); }
/// <summary> /// Selects the Button /// </summary> /// <param name="Button">The Button that will change its style</param> /// <param name="select">It determines if the button woll be selected</param> /// <remarks> /// If select is true thebutton will be selected, otherwise not. /// </remarks> public static void setSelected(ButtonBase Button, bool select) { if (select) Button.Select(); }
private void SurvivalMode_OnClick(ButtonBase btn) { SceneController.Ins.InitMode3Scene(); NowScene.Ins.LoadScene(SceneController.Ins.mode3Scene); }
/// <inheritdoc /> protected virtual void GetTemplateChildren() { VolumeSliderContainerElement = GetTemplateChild(VolumeTemplateParts.VolumeSliderContainer) as FrameworkElement; VolumeSliderElement = GetTemplateChild(VolumeTemplateParts.VolumeSlider) as VolumeSlider; MuteButtonElement = GetTemplateChild(VolumeTemplateParts.MuteButton) as ButtonBase; }
private void CopyChildControls(Control cDest, Control cSource, Action <Control> fCustomizeCopy) { if ((cDest == null) || (cSource == null)) { return; } foreach (Control c in cSource.Controls) { if (c == null) { Debug.Assert(false); continue; } bool bSetText = true; Control cCopy; if (c is Button) { cCopy = new Button(); } else if (c is CheckBox) { cCopy = new CheckBox(); (cCopy as CheckBox).Appearance = (c as CheckBox).Appearance; } else if (c is ComboBox) { cCopy = new ComboBox(); (cCopy as ComboBox).DropDownStyle = (c as ComboBox).DropDownStyle; } else if (c is GroupBox) { cCopy = new GroupBox(); } else if (c is HotKeyControlEx) { cCopy = new TextBox(); bSetText = false; } else if (c is Label) { cCopy = new Label(); } else if (c is NumericUpDown) { cCopy = new TextBox(); // NumericUpDown leads to GDI objects leak bSetText = false; } else if (c is RadioButton) { cCopy = new RadioButton(); } else if (c is RichTextBox) { cCopy = new TextBox(); // RTB leads to GDI objects leak (cCopy as TextBox).Multiline = true; } else if (c is TabControl) { cCopy = new TabControl(); } else if (c is TabPage) { cCopy = new TabPage(); } // HotKeyControlEx is a TextBox, so HotKeyControlEx must be first else if (c is TextBox) { cCopy = new TextBox(); (cCopy as TextBox).Multiline = (c as TextBox).Multiline; } // TabPage is a Panel, so TabPage must be first else if (c is Panel) { cCopy = new Panel(); } else { cCopy = new Label(); } Color clr = Color.FromArgb(128 + g_rand.Next(0, 128), 128 + g_rand.Next(0, 128), 128 + g_rand.Next(0, 128)); cCopy.Name = c.Name; cCopy.Font = c.Font; cCopy.BackColor = clr; if (bSetText) { cCopy.Text = c.Text; } cCopy.Location = c.Location; cCopy.Size = c.Size; // Debug.Assert(cCopy.ClientSize == c.ClientSize); cCopy.Dock = c.Dock; cCopy.Padding = c.Padding; // Type tCopy = cCopy.GetType(); // PropertyInfo piAutoSizeSrc = t.GetProperty("AutoSize", typeof(bool)); // PropertyInfo piAutoSizeDst = tCopy.GetProperty("AutoSize", typeof(bool)); // if((piAutoSizeSrc != null) && (piAutoSizeDst != null)) // { // MethodInfo miSrc = piAutoSizeSrc.GetGetMethod(); // MethodInfo miDst = piAutoSizeDst.GetSetMethod(); // miDst.Invoke(cCopy, new object[] { miSrc.Invoke(c, null) }); // } cCopy.AutoSize = c.AutoSize; cCopy.TabIndex = c.TabIndex; cCopy.TabStop = c.TabStop; ButtonBase bbCopy = (cCopy as ButtonBase); if ((bbCopy != null) && (c is ButtonBase)) { bbCopy.TextAlign = (c as ButtonBase).TextAlign; } Label lCopy = (cCopy as Label); if ((lCopy != null) && (c is Label)) { lCopy.TextAlign = (c as Label).TextAlign; } try { if (fCustomizeCopy != null) { fCustomizeCopy(cCopy); } cDest.Controls.Add(cCopy); if ((c is GroupBox) || (c is Panel) || (c is SplitContainer) || (c is TabControl)) { CopyChildControls(cCopy, c, fCustomizeCopy); } } catch (Exception) { Debug.Assert(false); } } }