protected override void OnPaint(PaintEventArgs e) { foreach (ButtonDirection b in buttons.Keys) { ButtonLocation loc = buttons[b]; RenderContext renderContext = new RenderContext(this, e.Graphics, e.ClipRectangle, renderer); renderContext.Graphics.CompositingQuality = CompositingQuality.HighQuality; renderContext.Graphics.SmoothingMode = SmoothingMode.HighQuality; VisualOrientation visualOrientation = VisualOrientation.Top; PaletteState state; if (loc.Enabled) { if (pressedButton == ButtonDirection.None) { state = trackingButton == b ? PaletteState.Tracking : PaletteState.Normal; } else { if (pressedButton == b) { state = pressedButton == trackingButton ? PaletteState.Pressed : PaletteState.Tracking; } else { state = PaletteState.Normal; } } } else { state = PaletteState.Disabled; } GraphicsPath backPath = renderer.RenderStandardBorder.GetBackPath(renderContext, loc.Rect, paletteBorderButton, visualOrientation, state); mementoBackground = renderer.RenderStandardBack.DrawBack(renderContext, loc.Rect, backPath, paletteBackButton, visualOrientation, state, mementoBackground); renderer.RenderStandardBorder.DrawBorder(renderContext, loc.Rect, paletteBorderButton, visualOrientation, state); if (images[b] != null) { int x = (loc.Rect.Width - images[b].Width) / 2; int y = (loc.Rect.Height - images[b].Height) / 2; if (x < 0) { x = 0; } if (y < 0) { y = 0; } renderContext.Graphics.DrawImage(images[b], loc.Rect.X + x, loc.Rect.Y + y); } } }
private void UpdateSaveLocations() { ButtonLocation.RemoveAllItems(); foreach (String location in iSaveSupport.SaveLocations) { ButtonLocation.AddItemWithTitle(location); } }
ButtonDirection GetButton(Point location) { foreach (ButtonDirection b in buttons.Keys) { ButtonLocation loc = buttons[b]; if (loc.Contains(location)) { return(b); } } return(ButtonDirection.None); }
public void SetEnabledButton(ButtonDirection direction, bool value) { if (direction != ButtonDirection.None) { ButtonLocation loc = buttons[direction]; loc.Enabled = value; Invalidate(); } else { throw new InvalidEnumArgumentException("Invalid button direction argument"); } }
private void UpdateSaveLocation() { string selected = ButtonLocation.TitleOfSelectedItem; if (selected != iSaveSupport.SaveLocation) { ButtonLocation.SelectItemWithTitle(iSaveSupport.SaveLocation); } if (ButtonLocation.SelectedItem == null && ButtonLocation.NumberOfItems > 0) { ButtonLocation.SelectItemAtIndex(0); } }
public Task <TView> AddButton <TView>(ButtonLocation location, TView button) where TView : View { if (location == ButtonLocation.Left) { return(Left.Add(button)); } if (location == ButtonLocation.Right) { return(Right.Add(button)); } else { throw new NotSupportedException(location + " is not supported?!"); } }
public void SetButtonIcon(ButtonLocation loc, ButtonIcon ico) { string path = ""; switch (ico) { case ButtonIcon.Back: path = "icon_back.png"; break; case ButtonIcon.Add: path = "icon_add.png"; break; case ButtonIcon.Delete: path = "icon_bin.png"; break; case ButtonIcon.Done: path = "icon_check.png"; break; } if (loc == ButtonLocation.Left) { imageLeft.Source = path; } else { imageRight.Source = path; } }
private void ButtonClick(ButtonLocation buttonLocation) { var tabControl = (TabControl)FindName($"TabControl{buttonLocation.ToString()}"); if (tabControl == null) { return; } var textBlock = (TextBlock)FindName($"TextBlock{buttonLocation.ToString()}"); if (textBlock == null) { return; } if (tabControl.SelectedIndex == 0 && !string.IsNullOrEmpty(textBlock.Text) && allowSound) { synthesizer.SpeakAsyncCancelAll(); synthesizer.SpeakAsync(textBlock.Text); } if (MenuItemGuessPlayMode.IsChecked) { if (textBlock.Text == LabelGuess.Content.ToString()) { //Correct if (SoundMenuItem.IsChecked) { SystemSounds.Hand.Play(); } guessCorrectFlashCount = 0; timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) }; timer.Tick += timer_Tick; timer.Start(); guessCorrectTabControl = tabControl; return; } if (SoundMenuItem.IsChecked) { SystemSounds.Beep.Play(); } } //Randomize after all tiles turned var doRandomize = true; var locationEnumList = Enum.GetValues(typeof(ButtonLocation)).Cast <ButtonLocation>().ToList(); foreach (var checkButtonLocation in locationEnumList) { var checkTabControl = (TabControl)FindName($"TabControl{checkButtonLocation.ToString()}"); if (checkTabControl == null) { continue; } if (checkTabControl.SelectedIndex == 0) { doRandomize = false; } } if (doRandomize) { RandomizeTiles(); return; } tabControl.SelectedIndex = Math.Abs(tabControl.SelectedIndex - 1); }
public CustomButton(Action listenEvent, string buttonTxt = "", ButtonLocation buttonLocation = ButtonLocation.Default) { buttonAction = listenEvent; buttonText = buttonTxt; location = buttonLocation; }