<commit_before>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Resources;
using System.Globalization;
using TestPlatform.Models;

namespace TestPlatform.Views.MainForms
{
    public partial class FileManagment : UserControl
    {
        private ResourceManager LocRM = new ResourceManager("TestPlatform.Resources.Localizations.LocalizedResources", typeof(FormMain).Assembly);
        private CultureInfo currentCulture = CultureInfo.CurrentUICulture;
        private char mode;
        private bool hasConflict = false;

        private string originPath, destinationPath, type;

        public FileManagment(string originPath, string destinationPath, char mode, string type)
        {
            InitializeComponent();
            this.mode = mode;
            this.originPath = originPath;
            this.destinationPath = destinationPath;
            this.type = type;
            if (mode == 'r') //recover mode
            {
                sendButton.Text = LocRM.GetString("recover", currentCulture);
                originListLabel.Text = LocRM.GetString("deletedPrograms", currentCulture);
                destinationListLabel.Text = LocRM.GetString("toRecoverPrograms", currentCulture);
                errorMessage.Text = LocRM.GetString("warningRecover", currentCulture);
            }
            else if (mode == 'd') //delete mode
            {
                sendButton.Text = LocRM.GetString("delete", currentCulture);
                originListLabel.Text = LocRM.GetString("existingPrograms", currentCulture);
                destinationListLabel.Text = LocRM.GetString("toDeletePrograms", currentCulture);
                errorMessage.Text = LocRM.GetString("warningDelete", currentCulture);
            }
            else
            {
                throw new ArgumentException();
            }
            loadOriginList();
        }

        private void originFilesList_DrawItem(object sender, DrawItemEventArgs e)
        {
            SolidBrush whiteSolidBrush = new SolidBrush(Color.White);
            SolidBrush blackSolidBrush = new SolidBrush(Color.Black);
            SolidBrush blueSolidBrush = new SolidBrush(Color.FromKnownColor(KnownColor.Highlight));
            SolidBrush redSolidBrush = new SolidBrush(Color.Red);
            SolidBrush orangeSolidBush = new SolidBrush(Color.Orange);

            e.DrawBackground();
            bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected);

            int index = e.Index;
            if (index >= 0 && index < originFilesList.Items.Count)
            {
                string text = originFilesList.Items[index].ToString();
                Graphics g = e.Graphics;

                //background:
                SolidBrush backgroundBrush;
                if (selected)
                {
                    backgroundBrush = blueSolidBrush;
                }
                else if (File.Exists(destinationPath + text + ".prg") == true)
                {
                    backgroundBrush = redSolidBrush;
                }
                else
                {
                    if (type == "program" && mode == 'd' && isProgramUsed(text))
                    {
                        backgroundBrush = orangeSolidBush;
                        warningLabel.Visible = true;
                    }
                    else
                    {
                        backgroundBrush = whiteSolidBrush;
                    }
                }
                g.FillRectangle(backgroundBrush, e.Bounds);

                //text:
                SolidBrush foregroundBrush = (selected) ? whiteSolidBrush : blackSolidBrush;
                g.DrawString(text, e.Font, foregroundBrush, originFilesList.GetItemRectangle(index).Location);
            }
            e.DrawFocusRectangle();<commit_msg>Now if program exists in backup folder and it is used by an experiment, then it is painted orange instead red, because orange items has more restrictions than red ones<commit_after>﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Resources;
using System.Globalization;
using TestPlatform.Models;

namespace TestPlatform.Views.MainForms
{
    public partial class FileManagment : UserControl
    {
        private ResourceManager LocRM = new ResourceManager("TestPlatform.Resources.Localizations.LocalizedResources", typeof(FormMain).Assembly);
        private CultureInfo currentCulture = CultureInfo.CurrentUICulture;
        private char mode;
        private bool hasConflict = false;

        private string originPath, destinationPath, type;

        public FileManagment(string originPath, string destinationPath, char mode, string type)
        {
            InitializeComponent();
            this.mode = mode;
            this.originPath = originPath;
            this.destinationPath = destinationPath;
            this.type = type;
            if (mode == 'r') //recover mode
            {
                sendButton.Text = LocRM.GetString("recover", currentCulture);
                originListLabel.Text = LocRM.GetString("deletedPrograms", currentCulture);
                destinationListLabel.Text = LocRM.GetString("toRecoverPrograms", currentCulture);
                errorMessage.Text = LocRM.GetString("warningRecover", currentCulture);
            }
            else if (mode == 'd') //delete mode
            {
                sendButton.Text = LocRM.GetString("delete", currentCulture);
                originListLabel.Text = LocRM.GetString("existingPrograms", currentCulture);
                destinationListLabel.Text = LocRM.GetString("toDeletePrograms", currentCulture);
                errorMessage.Text = LocRM.GetString("warningDelete", currentCulture);
            }
            else
            {
                throw new ArgumentException();
            }
            loadOriginList();
        }

        private void originFilesList_DrawItem(object sender, DrawItemEventArgs e)
        {
            SolidBrush whiteSolidBrush = new SolidBrush(Color.White);
            SolidBrush blackSolidBrush = new SolidBrush(Color.Black);
            SolidBrush blueSolidBrush = new SolidBrush(Color.FromKnownColor(KnownColor.Highlight));
            SolidBrush redSolidBrush = new SolidBrush(Color.Red);
            SolidBrush orangeSolidBush = new SolidBrush(Color.Orange);

            e.DrawBackground();
            bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected);

            int index = e.Index;
            if (index >= 0 && index < originFilesList.Items.Count)
            {
                string text = originFilesList.Items[index].ToString();
                Graphics g = e.Graphics;

                //background:
                SolidBrush backgroundBrush;
                if (selected)
                {
                    backgroundBrush = blueSolidBrush;
                }
                else if (type == "program" && mode == 'd' && isProgramUsed(text))
                {
                    backgroundBrush = orangeSolidBush;
                    warningLabel.Visible = true;
                }
                else if (File.Exists(destinationPath + text + ".prg") == true)
                {
                    backgroundBrush = redSolidBrush;
                }
                else
                {
                    backgroundBrush = whiteSolidBrush;
                }

                g.FillRectangle(backgroundBrush, e.Bounds);

                //text:
                SolidBrush foregroundBrush = (selected) ? whiteSolidBrush : blackSolidBrush;
                g.DrawString(text, e.Font, foregroundBrush, originFilesList.GetItemRectangle(index).Location);
            }
            e.DrawFocusRectangle();
{'fraction_non_alphanumeric': 0.08396098283738733, 'fraction_numerical': 0.0002469440671687863, 'mean_word_length': 1.9210241615578796, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2000753', 'n_tokens_mistral': 2016, 'n_tokens_neox': 1833, 'n_words': 430}