public void SwitchBuffer() { var buffers = bufferManager.EnumerateBuffers().ToList(); if (buffers.Count < 2) { return; } var cur = ViewManager.ActiveView?.Buffer; var idx = cur != null?buffers.IndexOf(cur) : 0; if (switchBufferControl == null) { switchBufferControl = new SwitchBufferControl(); switchBufferControl.CloseRequested += (o, ev) => { switchBufferControl.FindForm().Controls.Remove(switchBufferControl); var newBuf = switchBufferControl.Buffers[switchBufferControl.SelectedIndex]; var view = ViewManager.EnumerateViews() .FirstOrDefault(v => v.Buffer == newBuf); if (view != null) { ViewManager.ActivateView(view); } else { OpenBuffer(newBuf); } }; } var oldFrm = switchBufferControl.FindForm(); if (oldFrm != null) { oldFrm.Controls.Remove(switchBufferControl); } var frm = Form.ActiveForm; switchBufferControl.Buffers = buffers; switchBufferControl.Width = frm.Width / 3; switchBufferControl.Height = switchBufferControl.CalculateHeight(); switchBufferControl.Left = (frm.Width - switchBufferControl.Width) / 2; switchBufferControl.Top = (frm.Height - switchBufferControl.Height) / 2; switchBufferControl.SelectedIndex = idx + 1 >= buffers.Count ? 0 : idx + 1; frm.Controls.Add(switchBufferControl); switchBufferControl.BringToFront(); switchBufferControl.Focus(); }
public IEnumerable <ValueItem> EnumerateArgumentValues() { return(bufferManager.EnumerateBuffers() .Where(b => b.IsDirty) .Select(b => new ValueItem(b.File.Name, b.File.DirectoryName))); }