/// <summary> /// Creates a new ConsolePanel /// </summary> public ProtectedConsolePanel() { this.CanFocus = false; ProtectedPanel = new ConsolePanel(); ProtectedPanel.Parent = this; ProtectedPanel.Fill(); }
/// <summary> /// Creates a new ConsolePanel /// </summary> public ProtectedConsolePanel() { this.CanFocus = false; ProtectedPanel = new ConsolePanel(); ProtectedPanel.Parent = this; ProtectedPanel.Fill(); this.SubscribeForLifetime(nameof(Background), () => ProtectedPanel.Background = Background, this); this.SubscribeForLifetime(nameof(Foreground), () => ProtectedPanel.Foreground = Foreground, this); }
private void InitFramePanel() { // vertical divider framePanel.Add(new ConsolePanel() { Width = 1, Background = RGB.White }).DockToRight().FillVertically(); var options = new ListGridOptions <InMemoryConsoleBitmapFrame>() { DataSource = new SyncList <InMemoryConsoleBitmapFrame>(animation.Frames), Columns = new List <ListGridColumnDefinition <InMemoryConsoleBitmapFrame> >() { new ListGridColumnDefinition <InMemoryConsoleBitmapFrame>() { Width = framePanel.Width - 2, Type = GridValueType.Pixels, Formatter = f => new Label() { Text = $"Frame {animation.Frames.IndexOf(f)+1}".ToWhite() }, Header = "Frame".ToYellow(), } }, ShowColumnHeaders = false, ShowPager = false, EnablePagerKeyboardShortcuts = false, }; frameList = framePanel.Add(new ListGrid <InMemoryConsoleBitmapFrame>(options)).Fill(padding: new Thickness(1, 1, 0, 0)); refreshed.SubscribeForLifetime(() => { frameList.Refresh(); }, frameList); BorderPanel fakeDialog = null; Label fakeDialogLabel = null; frameList.SelectionChanged.SubscribeForLifetime(() => { CurrentFrameIndex = frameList.SelectedRowIndex; Refresh(); if (fakeDialog != null) { fakeDialog.X = frameList.AbsoluteX + frameList.Width - 2; fakeDialog.Y = frameList.Y + 1 + frameList.SelectedRowIndex; fakeDialogLabel.Text = FormatTimespanForFramePopup(CurrentFrame.FrameTime); } }, frameList); frameList.Focused.SubscribeForLifetime(() => { var fakeDialogContent = new ConsolePanel() { Background = TimespanPopupBGColor }; fakeDialog = ConsoleApp.Current.LayoutRoot.Add(new BorderPanel(fakeDialogContent)); fakeDialog.BorderColor = RGB.Blue; fakeDialog.Width = 30; fakeDialog.Height = 5; fakeDialog.X = frameList.AbsoluteX + frameList.Width - 2; fakeDialog.Y = frameList.Y + 1 + frameList.SelectedRowIndex; fakeDialogContent.Fill(); fakeDialogLabel = fakeDialogContent.Add(new Label() { Text = FormatTimespanForFramePopup(CurrentFrame.FrameTime) }).CenterBoth(); refreshed.SubscribeForLifetime(() => { fakeDialogLabel.Text = FormatTimespanForFramePopup(CurrentFrame.FrameTime); }, fakeDialogLabel); ConsoleApp.Current.FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.OemPlus, null, () => { undoRedo.Do(new ShiftTimeStampForwardAction(this, CurrentFrameIndex, 50)); }, fakeDialog); ConsoleApp.Current.FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.OemMinus, null, () => { undoRedo.Do(new ShiftTimeStampBackwardAction(this, CurrentFrameIndex, 50)); }, fakeDialog); ConsoleApp.Current.FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.OemPlus, ConsoleModifiers.Shift, () => { undoRedo.Do(new ShiftTimeStampForwardAction(this, CurrentFrameIndex, 10)); }, fakeDialog); ConsoleApp.Current.FocusManager.GlobalKeyHandlers.PushForLifetime(ConsoleKey.OemMinus, ConsoleModifiers.Shift, () => { undoRedo.Do(new ShiftTimeStampBackwardAction(this, CurrentFrameIndex, 10)); }, fakeDialog); }, frameList); frameList.Unfocused.SubscribeForLifetime(() => { fakeDialog?.Dispose(); fakeDialogLabel = null; fakeDialog = null; }, frameList); }