private void frmPrincipal_Load(object sender, EventArgs e)
        {
            Icon          = Properties.Resources.Icon;
            taskIcon.Icon = Properties.Resources.Icon;
            foreach (string file in Directory.GetFiles(PastaChecklists))
            {
                lbItems.Items.Add(lbDisplay.Create(file));
            }
            var regexItem = new Regex("^[a-zA-Z]*$");

            if (!System.Diagnostics.Debugger.IsAttached)
            {
                if (Properties.Settings.Default.Nome == "")
                {
                    string nome = "";
                    while (nome == "")
                    {
                        nome = InputBox.Show("", "Digite seu nome:");
                        if (!regexItem.IsMatch(nome))
                        {
                            nome = "";
                        }
                    }
                    Properties.Settings.Default.Nome = nome;
                    Properties.Settings.Default.Save();
                    ChecklistExtensions.GenerateCheckList(nome, false);
                }
            }
            MessageBox.Show("Bem vindo " + Properties.Settings.Default.Nome + "!");
            ActionsWatcher.Path = PastaChecklists;
        }
 private void ActionsWatcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (CheckAtiva?.Path == e.FullPath)
     {
         CheckAtiva         = ChecklistExtensions.ReadChecklist(e.FullPath);
         lbCheck.DataSource = CheckAtiva.GetList();
     }
 }
        private void MoveStrip_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem _sender = sender as ToolStripMenuItem;

            Classes.Checklist clTarget = ChecklistExtensions.FindCheckList(_sender.Text);
            object            item     = lbCheck.SelectedItem;

            CheckAtiva.MoverItem(item, clTarget);
        }
        private void lbItems_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox lb = sender as ListBox;

            if (lb.SelectedIndex != -1)
            {
                string path = lbDisplay.GetPath(lb.SelectedItem);
                CheckAtiva = ChecklistExtensions.ReadChecklist(path);
                if (CheckAtiva.Accessible)
                {
                    lbCheck.ContextMenuStrip = stripChecklist;
                }
                else
                {
                    lbCheck.ContextMenuStrip = null;
                }
                lbCheck.DataSource = CheckAtiva.GetList();
            }
            lbCheck.Focus();
        }
        private void lbCheck_DrawItem(object sender, DrawItemEventArgs e)
        {
            ListBox lb = sender as ListBox;

            if (e.Index < 0)
            {
                return;
            }
            object addedItem = lb.Items[e.Index];
            Color  c         = ChecklistExtensions.GetColor(addedItem);
            Brush  b         = Brushes.Black;

            //if the item state is selected them change the back color
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e = new DrawItemEventArgs(e.Graphics,
                                          e.Font,
                                          e.Bounds,
                                          e.Index,
                                          e.State ^ DrawItemState.Selected,
                                          e.ForeColor,
                                          Color.Black);//Choose the color
                b = new SolidBrush(c);
            }
            else if ((e.State & DrawItemState.NoFocusRect) == DrawItemState.NoFocusRect)
            {
                e = new DrawItemEventArgs(e.Graphics,
                                          e.Font,
                                          e.Bounds,
                                          e.Index,
                                          e.State ^ DrawItemState.NoFocusRect,
                                          e.ForeColor,
                                          c);//Choose the color
            }
            // Draw the background of the ListBox control for each item.
            e.DrawBackground();
            // Draw the current item text
            e.Graphics.DrawString(addedItem.ToString(), e.Font, b, e.Bounds, StringFormat.GenericDefault);
            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }
        private void stripAdicionarRemover_Opening(object sender, CancelEventArgs e)
        {
            ToolStripMenuItem moverParaStrip = (sender as ContextMenuStrip).Items.Find("moverParaToolStripMenuItem", false)[0] as ToolStripMenuItem;

            moverParaStrip.DropDownItems.Clear();
            List <ToolStripMenuItem> Acessibles = new List <ToolStripMenuItem>();

            foreach (object clRef in lbItems.Items)
            {
                Classes.Checklist cl = ChecklistExtensions.ReadChecklist(lbDisplay.GetPath(clRef));
                if (cl.Path != CheckAtiva.Path)
                {
                    ToolStripMenuItem moveStrip = new ToolStripMenuItem()
                    {
                        Name = "MoverPara" + cl.Name + "ToolStripMenu", Text = cl.Name
                    };
                    moveStrip.Click += MoveStrip_Click;
                    moverParaStrip.DropDownItems.Add(moveStrip);
                }
            }
        }
 private void helpToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ChecklistExtensions.RunHelper(lbCheck.SelectedItem);
 }