public RebuildListForm(WebSites webSites)
        {
            InitializeComponent();
            InitializeDgv();

            AcceptButton = backButton;
            DialogResult = DialogResult.None;
            FormClosed  += RebuildListForm_FormClosed;

            _progressIndicator       = new Progress <KeyValuePair <string, KeyValuePair <string, int> > >(ReportProgress);
            _cancellationTokenSource = new CancellationTokenSource();
            _webSites = webSites;

            _webSites.GetNamesList("toRebuild").ForEach(name =>
            {
                var allCount = _webSites.GetWebSiteByName(name).DomainLists.HtmlFilesList["available"].Count +
                               _webSites.GetWebSiteByName(name).DomainLists.ImgsList["available"].Count +
                               _webSites.GetWebSiteByName(name).DomainLists.JsFilesList["available"].Count +
                               _webSites.GetWebSiteByName(name).DomainLists.CssFilesList["available"].Count;
                dashboardDgv.Rows.Add(name,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.HtmlFilesList["available"].Count,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.ImgsList["available"].Count,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.JsFilesList["available"].Count,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.CssFilesList["available"].Count,
                                      0, allCount);
            });

            UpdateStatusCount(dashboardDgv.Rows.Count);

            previewButton.Enabled        = false;
            previewBrowserButton.Enabled = false;
            previewButton.Click         += previewButton_Click;
            previewBrowserButton.Click  += previewButton_Click;
        }
        /// <summary>
        /// The function opens the website in the preview box or in the browser.
        /// </summary>
        /// <param name="handler">Browser or preview box</param>
        private void ShowPreview(string handler)
        {
            try
            {
                if (!_webSites.IsServerStarted)
                {
                    statusLabel.Text = @"Server was not started! Can't open site preview.";
                    return;
                }

                var webSite = _webSites.GetWebSiteByName(dashboardDgv.CurrentRow.Cells[0].Value.ToString());
                _webSites.SetCurrentRootDirectory(webSite.DomainDirectory);

                if (handler.Contains("Browser"))
                {
                    Process.Start(webSite.DomainPreviewUrl);
                }
                else
                {
                    using (var form = new PreviewForm(webSite.DomainPreviewUrl))
                        form.ShowDialog();
                    Focus();
                }
            }
            catch (Exception) { statusLabel.Text = @"Something went wrong! Can't open site preview."; }
        }
        private void FillGrid()
        {
            var namesList  = _webSites.GetNamesList("rebuilt");
            var count      = namesList.Count;
            var filesCount = new List <int>();

            namesList.ForEach(name => filesCount.Add(_webSites.GetWebSiteByName(name).DomainFilesCount));

            var rebuilt = namesList.Zip(filesCount, (name, files) => new { Name = name, Files = files });

            statusLabel.Text = @"You have " + count + (count == 1 ? @" rebuilt website." : @" rebuilt websites.");

            if (count == 0)
            {
                return;
            }

            rebuiltDgv.Rows.Clear();
            foreach (var webSite in rebuilt)
            {
                rebuiltDgv.Rows.Add(webSite.Name, webSite.Files);
            }
        }