void Update() { // 矢印キーの左右が押されていなければ、中央にする // 両方押されていば場合は、前のバーの状態を維持する BarPosition barPos = BarPosition.Center; if (Input.GetKey(KeyCode.LeftArrow) && Input.GetKey(KeyCode.RightArrow)) { barPos = prevState.barPosition; } else if (Input.GetKey(KeyCode.LeftArrow)) { barPos = BarPosition.Left; } else if (Input.GetKey(KeyCode.RightArrow)) { barPos = BarPosition.Right; } var newInput = new InputState { pushedEnterButton = Input.GetKeyDown(KeyCode.Return), pushedEscapeButton = Input.GetKeyDown(KeyCode.Escape), barPosition = barPos }; bool isChanged = !prevState.Equals(newInput); prevState = newInput; if (isChanged) { dispatcher?.Dispatch(new ChangedInput { state = newInput }); } }
private static Point[] GetShape(BarPosition barPosition, DigitPosition digitPos) { //Points retrieved when the form was 1006, 560. switch (barPosition) { case BarPosition.Top: Point[] shape1 = { new Point(44 + (int)digitPos, 111), new Point(213 + (int)digitPos, 111), new Point(168 + (int)digitPos, 155), new Point(86 + (int)digitPos, 155) }; return(shape1); case BarPosition.TopLeft: Point[] shape2 = { new Point(36 + (int)digitPos, 233), new Point(36 + (int)digitPos, 120), new Point(79 + (int)digitPos, 164), new Point(79 + (int)digitPos, 223), new Point(52 + (int)digitPos, 249) }; return(shape2); case BarPosition.TopRight: Point[] shape3 = { new Point(221 + (int)digitPos, 119), new Point(178 + (int)digitPos, 163), new Point(178 + (int)digitPos, 220), new Point(205 + (int)digitPos, 248), new Point(221 + (int)digitPos, 232) }; return(shape3); case BarPosition.Middle: Point[] shape4 = { new Point(83 + (int)digitPos, 236), new Point(175 + (int)digitPos, 236), new Point(196 + (int)digitPos, 258), new Point(175 + (int)digitPos, 279), new Point(83 + (int)digitPos, 279), new Point(60 + (int)digitPos, 258) }; return(shape4); case BarPosition.BottomLeft: Point[] shape5 = { new Point(53 + (int)digitPos, 266), new Point(36 + (int)digitPos, 285), new Point(36 + (int)digitPos, 396), new Point(80 + (int)digitPos, 350), new Point(80 + (int)digitPos, 292) }; return(shape5); case BarPosition.BottomRight: Point[] shape6 = { new Point(205 + (int)digitPos, 266), new Point(221 + (int)digitPos, 281), new Point(221 + (int)digitPos, 396), new Point(177 + (int)digitPos, 350), new Point(177 + (int)digitPos, 294) }; return(shape6); case BarPosition.Bottom: Point[] shape7 = { new Point(88 + (int)digitPos, 359), new Point(169 + (int)digitPos, 359), new Point(212 + (int)digitPos, 404), new Point(45 + (int)digitPos, 404) }; return(shape7); default: return(null); } }
public Vector2 GetPos(BarPosition pos) { switch (pos) { case BarPosition.Left: return(leftPos); case BarPosition.Center: return(centerPos); case BarPosition.Right: return(rightPos); default: throw new PatternMatchNotFoundException(pos); } }
public FormAppBar(AppConfig appConfig, IPInvokeHandler pinvokeHandler, uint signalShowHide) { this.direction = appConfig.Bar.Position; this.pinvokeHandler = pinvokeHandler; this.signalShowHide = signalShowHide; this.backColor = ColorTranslator.FromHtml(appConfig.Bar.Colors?.Background); this.focusForeColor = ColorTranslator.FromHtml(appConfig.Bar.Colors?.FocusedWorkspace.Text); this.focusBackColor = ColorTranslator.FromHtml(appConfig.Bar.Colors?.FocusedWorkspace.Background); this.color = ColorTranslator.FromHtml(appConfig.Bar.Colors?.Statusline); this.wantedSize = 25; this.iconSize = 23; this.contentStart = 1; this.contentStartTop = direction == BarPosition.Top || direction == BarPosition.Bottom; this.BackColor = backColor; this.ForeColor = color; InitializeComponent(); this.Height = wantedSize; this.Width = wantedSize; this.Size = new Size(wantedSize, wantedSize); containerControl.Height = direction == BarPosition.Left || direction == BarPosition.Right ? 400 : wantedSize; containerControl.Width = containerControl.Height == wantedSize ? 400 : wantedSize; }
public MoveBar(BarPosition pos) { this.position = pos; }
public void DrawBar(Image image, BarPosition barPosition) { if (image is null || _config.Config?.Bars is null) { return; } var bar = _config.Config.Bars.SingleOrDefault(b => b.Position == barPosition && b.Enabled); if (bar is default(Bar)) { return; } var fonts = new FontCollection().Install(bar.TextFont.Path); var font = new Font(fonts, bar.TextFont.Size); var text = bar.PrintCurrentDateTime ? DateTime.Now.ToString(bar.DateTimeFormat) : bar.Text; SizeF size = TextMeasurer.Measure(text, new RendererOptions(font)); var txtImageWidth = barPosition == BarPosition.Top || barPosition == BarPosition.Bottom ? _config.Config.ImageWidth : _config.Config.ImageHeight; using var txtImage = new Image <Rgba32>(Configuration.Default, txtImageWidth, bar.Height, bar.BackgroundColor.ToColor()); var txtLocation = bar.TextHorizontalAlignment switch { TextHorizontalAlignment.Left => new Point(0 + bar.TextPaddingLeftRight, GetTextYLocation()), TextHorizontalAlignment.Right => new Point(txtImageWidth - (int)size.Width - bar.TextPaddingLeftRight, GetTextYLocation()), TextHorizontalAlignment.Center => new Point(txtImageWidth / 2 - (int)size.Width / 2, GetTextYLocation()), _ => throw new ArgumentException() }; int GetTextYLocation() => (int)((bar.Height - size.Height) / 2) + bar.TextFont.PositionCorrection; TextGraphicsOptions options = new TextGraphicsOptions { Antialias = bar.Antialias, VerticalAlignment = VerticalAlignment.Top }; txtImage.Mutate(x => x.DrawText ( options, text, font, bar.TextFont.Color.ToColor(), txtLocation ) ); switch (barPosition) { case BarPosition.Left: txtImage.Mutate(x => x.Rotate(90f)); break; case BarPosition.Right: txtImage.Mutate(x => x.Rotate(90f)); break; } var txtImageLocation = barPosition switch { BarPosition.Left => new Point(0, 0), BarPosition.Right => new Point(image.Width - txtImage.Width, 0), BarPosition.Top => new Point(0, 0), BarPosition.Bottom => new Point(0, image.Height - txtImage.Height), _ => throw new ArgumentException() }; image.Mutate(x => x.DrawImage(txtImage, txtImageLocation, opacity: 0.95f)); } } }