Exemple #1
0
        private void UpdateFiles(DirBlock block, string[] filesInFolder)
        {
            if (block.FileList == null || !block.FileList.Any())
            {
                block.FileList = new List <string>(filesInFolder);
                return;
            }

            //remove deleted file
            block.FileList = block.FileList.Where(filesInFolder.Contains).ToList();

            var newFile = filesInFolder.Where(x => !block.FileList.Contains(x));

            if (rdBtnDirectBot.Checked)
            {
                block.FileList.AddRange(newFile);
            }
            else
            {
                var oldFileList = block.FileList;
                block.FileList = new List <string>(newFile);
                block.FileList.AddRange(oldFileList);
            }
        }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();

            var directoriesPath = Settings.Default.FilesPath;

            this.Text = Settings.Default.FormName;

            this.Width  = Settings.Default.WidthOneBlock * directoriesPath.Count + 10 * (directoriesPath.Count + 3); // + 3 нужно для отступов до первого и после последнего блока
            this.Height = Settings.Default.HeightOneBlock + _allBlockTop + 50;

            _blockList = new List <DirBlock>();

            var i = 0;

            foreach (var dirPath in directoriesPath)
            {
                var txtBoxDir = CreateTxtBoxDir(i);
                var lblDir    = CreateLabelDir(dirPath, i++);

                var pair = new DirBlock(lblDir, txtBoxDir, dirPath, new List <string>());
                _blockList.Add(pair);

                this.Controls.Add(txtBoxDir);
                this.Controls.Add(lblDir);
            }

            lblLastUpdate.Text = string.Format(Settings.Default.LastUpdateMessange, _lastUpdateWas);

            switch (Settings.Default.SortType)
            {
            case 1:
            {
                rdBtnSort1.Checked = true;
                break;
            }

            case 2:
            {
                rdBtnSort2.Checked = true;
                break;
            }

            case 3:
            {
                rdBtnSort3.Checked = true;
                break;
            }
            }

            switch (Settings.Default.SortDirect)
            {
            case 1:
            {
                rdBtnDirectTop.Checked = true;
                break;
            }

            case 2:
            {
                rdBtnDirectBot.Checked = true;
                break;
            }
            }

            UpdateFolders();
            timer1.Start();
        }