SCCManager/Remontor/BarSessionControl.cs

117 lines
3.0 KiB
C#

using Remontor.Connector;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Remontor
{
enum BarShow
{
HideBar,
ShowHistory,
ShowWords
}
internal partial class BarSessionControl : UserControl
{
public delegate bool HideBars(BarShow state);
public HideBars hideWors;
public HideBars hideHistory;
private BarShow barShow = BarShow.HideBar;
public List<BarButtonControl> buttons;
public BarSessionControl()
{
InitializeComponent();
SConnector.Update += UpdateBar;
buttons = new List<BarButtonControl>();
}
public void UpdateBar(List<Connect> connects)
{
bool GreyBackground = false;
buttons.Clear();
FlowButton.Controls.Clear();
foreach (var item in connects)
{
BarButtonControl button = new BarButtonControl(item, GreyBackground);
buttons.Add(button);
GreyBackground = !GreyBackground;
FlowButton.Controls.Add(button);
}
FlowButton.Controls.Add(NewBtn);
}
private void ShowBar_Click(object sender, EventArgs e)
{
if (barShow == BarShow.ShowHistory)
{
barShow = BarShow.HideBar;
}
else
{
barShow = BarShow.ShowHistory;
}
if (hideHistory(barShow))
{
ShowBar.BackColor = SystemColors.ActiveCaption;
ShowWords.BackColor = SystemColors.Control;
}
else
{
ShowBar.BackColor = SystemColors.Control;
}
hideWors(barShow);
}
private void NewBtn_Click(object sender, EventArgs e)
{
Finder.Finder finder = new Finder.Finder();
finder.ShowDialog();
}
private void FlowButton_ControlRemoved(object sender, ControlEventArgs e)
{
if(e.Control is BarButtonControl) e.Control.Dispose();
}
private void BarSessionControl_Load(object sender, EventArgs e)
{
}
private void ShowWords_Click(object sender, EventArgs e)
{
if (barShow == BarShow.ShowWords)
{
barShow = BarShow.HideBar;
}
else
{
barShow = BarShow.ShowWords;
}
if (hideWors(barShow))
{
ShowWords.BackColor = SystemColors.ActiveCaption;
ShowBar.BackColor = SystemColors.Control;
}
else
{
ShowWords.BackColor = SystemColors.Control;
}
hideHistory(barShow);
}
}
}