コード例 #1
0
 private void Purge(DirectoryInfo di)
 {
     try
     {
         Directory.Delete(di.FullName, true);
         //foreach (FileInfo file in di.EnumerateFiles())
         //{
         //    //if (WaitForFile(file.FullName))
         //        file.Delete();
         //}
         //foreach (DirectoryInfo dir in di.EnumerateDirectories())
         //{
         //    dir.Delete(true);
         //}
         ResultsTextBox.AppendText("Папка \"" + di.Name + "\" из каталога " + di.Parent.FullName + " успешно удалена!\n");
         PurgeButton.Visibility = Visibility.Hidden;
     }
     catch (Exception ex)
     {
         if (di.Exists)
         {
             ResultsTextBox.AppendText("Папка \"" + di.Name + "\" используется. Пожалуйста подождите ещё.\n");
         }
         else
         {
             ResultsTextBox.AppendText("Папка \"" + di.Name + "\" не найдена в каталоге " + di.Parent.FullName + "\n");
         }
     }
     finally
     {
     }
 }
コード例 #2
0
 /// <summary>
 /// Event invoked for each process in <see cref="PowerShellOperations.Example1"/> and
 /// <see cref="PowerShellOperations.Example2Task"/>
 ///
 /// The method <see cref="PowerShellOperations.Example2Task"/> requires <see cref="ControlExtensions.InvokeIfRequired"/>
 /// to prevent cross threading violation while <see cref="PowerShellOperations.Example1"/> does not cause a violation
 ///
 /// </summary>
 /// <param name="sender"></param>
 private void PowerShellOperationsOnProcessItemHandler(ProcessItem sender)
 {
     ResultsTextBox.InvokeIfRequired(tb =>
     {
         tb.AppendTextWithNewLines($"{sender}".RemoveExtraSpaces().Beautify());
     });
 }
コード例 #3
0
        /// <summary>
        /// Загрузка
        /// </summary>
        ///
        private async void Start_Click(object sender, RoutedEventArgs e)
        {
            StartButton.IsEnabled = false;
            try
            {
                cts = new CancellationTokenSource();
                //ResultsTextBox.Clear();
                StopButton.Visibility = Visibility.Visible;
                await AccessTheWebAsync(UrlTextBox.Text.ToString(), cts.Token);

                ResultsTextBox.AppendText("Загрузка завершена.\n");
                if (new DirectoryInfo(BadDirectory).Exists)
                {
                    PurgeButton.Visibility = Visibility.Visible;
                }
            }
            catch (OperationCanceledException)
            {
                ResultsTextBox.AppendText("Загрузка отменена.\n");
            }
            catch (Exception)
            {
                ResultsTextBox.AppendText("Загрузка не удалась.\n");
            }
            finally
            {
                StartButton.IsEnabled = true;
                StopButton.Visibility = Visibility.Hidden;
            }
        }
コード例 #4
0
 private void RefreshResultsForm()
 {
     //MaintextBox.AppendText(grade.ToString());
     // MaintextBox.AppendText("\r\n");
     ResultsTextBox.Clear();
     ResultsTextBox.AppendText($"TotalScore: {quiz.CorrectAnswers} / {quiz.NumberOfQuestions}");
 }
コード例 #5
0
 private void EncryptFileButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(KeyBoxFile.Text) || string.IsNullOrWhiteSpace(FilePathBox.Text))
     {
         MessageBox.Show("You must enter a key!");
     }
     else
     {
         ResultsTextBox.AppendText("Encrypting...\n");
         var    crypto = new Crypto(KeyBoxFile.Text);
         string fileContents;
         using (StreamReader sr = new StreamReader(FilePathBox.Text))
         {
             fileContents = sr.ReadToEnd();
         }
         using (
             StreamWriter sw =
                 new StreamWriter(Path.Combine(Path.GetDirectoryName(FilePathBox.Text),
                                               Path.GetFileNameWithoutExtension(FilePathBox.Text) + "Encrypted" + ".txt")))
         {
             sw.Write(crypto.Encrypt(fileContents));
             sw.Write(Hasher.GenerateBase64Hash(MD5.Create(), fileContents));
         }
         ResultsTextBox.AppendText("Encryption complete.\n");
     }
 }
コード例 #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            ResultsTextBox.Clear();
            //ResultsTextBox.Text = CommandOne(procedureString, connectOne);

            using (SqlConnection connection = new SqlConnection(connectOne))
            {
                try
                {
                    SqlCommand command = new SqlCommand(queryString, connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "[Ten Most Expensive Products]";
                    command.Connection.Open();
                    SqlDataReader reader  = command.ExecuteReader();
                    StringBuilder results = new StringBuilder();
                    while (reader.Read())
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            results.Append(reader[i].ToString() + "\t");
                        }
                        results.Append(Environment.NewLine);
                    }
                    ResultsTextBox.Text = results.ToString();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #7
0
        /*
         *  Celem ćwiczenia jest uzupełnienie poniższych metod.
         *  Każda metoda powinna zawierać kod C#, który z pomocą LINQ'a będzie realizować
         *  zapytania opisane za pomocą SQL'a.
         *  Rezultat zapytania powinien zostać wyświetlony za pomocą kontrolki DataGrid.
         *  W tym celu końcowy wynik należy rzutować do Listy (metoda ToList()).
         *  Jeśli dane zapytanie zwraca pojedynczy wynik możemy je wyświetlić w kontrolce
         *  TextBox WynikTextBox.
         */

        /// <summary>
        /// SELECT * FROM Emps WHERE Job = "Backend programmer";
        /// </summary>
        public void Example1Button_Click(object sender, EventArgs e)
        {
            //var res = new List<Emp>();
            //foreach(var emp in Emps)
            //{
            //    if (emp.Job == "Backend programmer") res.Add(emp);
            //}

            //1. Query syntax (SQL)
            // var res = from emp in Emps
            // where emp.Job == "Backend programmer"
            // select new
            // {
            // Nazwisko = emp.Ename,
            // Zawod = emp.Job
            // };


            //2. Lambda and Extension methods
            var res = Emps.Where(emp =>
                                 emp.Job.Equals("Backend programmer")).Select(emp =>
                                                                              new
            {
                emp.Ename,
                emp.Salary
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #8
0
        private void button5_Click(object sender, EventArgs e)
        {
            ResultsTextBox.Clear();
            thisCity = CityTextBox.Text;
            string paramRequest = "SELECT CustomerID, CompanyName, City FROM Customers WHERE City = @City";

            ResultsTextBox.Text = CommandTwo(paramRequest, connectOne, thisCity);
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: NateVolt/ComPortTesting
        private void SendAllButton_Click(object sender, EventArgs e)
        {
            ResultsTextBox.Clear();
            var    responses = ComObject.GetResponsesAtBaudRate(PortsComboBox.SelectedItem.ToString(), GetAllSelectedBauds());
            string result    = string.Join("\r\n", responses.Select(x => $"Baud {x.Key},{x.Value ?? "No response"}"));

            ResultsTextBox.Text = result;
        }
コード例 #10
0
        /// <summary>
        /// SELECT MAX(Salary) FROM Emps;
        /// </summary>
        public void Example3Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Max(emp => emp.Salary);

            ResultsTextBox.Clear();
            ResultsTextBox.AppendText(res.ToString());
            ResultsList.DataSource = null;
        }
コード例 #11
0
        //Znajdź pracownika z najwyższą pensją wykorzystując metodę Aggregate()
        public void Example11Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Aggregate((empA, empB) => empA.Salary > empB.Salary ? empA : empB);

            ResultsTextBox.Clear();
            ResultsTextBox.AppendText(res.ToString());
            ResultsList.DataSource = null;
        }
コード例 #12
0
        /// <summary>
        /// Zwróć wartość "true" jeśli choć jeden
        /// z elementów kolekcji pracuje jako "Backend programmer".
        /// </summary>
        public void Example8Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Any(emp => "Backend programmer".Equals(emp.Job));

            ResultsTextBox.Clear();
            ResultsTextBox.AppendText(res.ToString());
            ResultsList.DataSource = null;
        }
コード例 #13
0
        /// <summary>
        /// SELECT TOP 1 * FROM Emp WHERE Job="Frontend programmer"
        /// ORDER BY HireDate DESC;
        /// </summary>
        public void Example9Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Where(emp => "Frontend programmer".Equals(emp.Job))
                      .Take(1)
                      .ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #14
0
        //Z pomocą języka LINQ i metody SelectMany wykonaj złączenie
        //typu CROSS JOIN
        public void Example12Button_Click(object sender, EventArgs e)
        {
            var res = Emps.SelectMany(emp => Depts.Select(dept => new
            {
                emp.Ename,
                dept.Dname
            })).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #15
0
        /// <summary>
        /// SELECT ename AS Nazwisko, job AS Praca FROM Emps;
        /// </summary>
        public void Example5Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Select(emp => new
            {
                Nazwisko = emp.Ename,
                Praca    = emp.Job
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #16
0
        /// <summary>
        /// SELECT Job AS Praca, COUNT(1) LiczbaPracownikow FROM Emps GROUP BY Job;
        /// </summary>
        public void Example7Button_Click(object sender, EventArgs e)
        {
            var res = Emps.GroupBy(emp => emp.Job)
                      .Select(emps => new
            {
                Praca = emps.Key,
                Count = emps.Count()
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #17
0
        /// <summary>
        /// SELECT * FROM Emps WHERE Salary=(SELECT MAX(Salary) FROM Emps);
        /// </summary>
        public void Example4Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Where(emp =>
                                 emp.Salary == Emps.Max(empSal => empSal.Salary))
                      .Select(emp => new
            {
                emp.Ename,
                emp.Salary
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #18
0
        /// <summary>
        /// SELECT Emps.Ename, Emps.Job, Depts.Dname FROM Emps
        /// INNER JOIN Depts ON Emps.Deptno=Depts.Deptno
        /// Rezultat: Złączenie kolekcji Emps i Depts.
        /// </summary>
        public void Example6Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Join(Depts, emp => emp.Deptno,
                                dept => dept.Deptno,
                                (emp, dept) => new
            {
                emp.Ename,
                emp.Job,
                dept.Dname
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #19
0
        /// <summary>
        /// SELECT * FROM Emps Job = "Frontend programmer" AND Salary>1000 ORDER BY Ename DESC;
        /// </summary>
        public void Example2Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Where(emp =>
                                 emp.Job.Equals("Frontend programmer") &&
                                 emp.Salary >= 1000)
                      .Select(emp =>
                              new
            {
                emp.Ename,
                emp.Salary
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #20
0
        private void FeaturesSelectionComputeButton_Click(object sender, RoutedEventArgs e)
        {
            if (FeatureClasses == null || !FeatureClasses.Any())
            {
                ResultsTextBox.AppendText($"{Environment.NewLine}There is no class loaded, use Open file button to load some data.");
                return;
            }

            var validFeatureCountInputted = int.TryParse(FeaturesSelectionFeaturesCountTextBox.Text, out int featureCount);

            if (validFeatureCountInputted)
            {
                var computationResultBuilder = new StringBuilder($"{Environment.NewLine}Best {featureCount} features: ");
                try
                {
                    var watch = Stopwatch.StartNew();
                    IEnumerable <int> discriminationResults;
                    switch (SelectedAlgorithm)
                    {
                    case FeatureSelectionAlgorithm.SFS:
                        discriminationResults = new FisherLinearDiscriminator().DiscriminateWithSequentialForwardSelection(FeatureClasses, int.Parse(FeaturesSelectionFeaturesCountTextBox.Text));
                        break;

                    case FeatureSelectionAlgorithm.Default:
                    default:
                        discriminationResults = new FisherLinearDiscriminator().Discriminate(FeatureClasses, int.Parse(FeaturesSelectionFeaturesCountTextBox.Text));
                        break;
                    }
                    watch.Stop();

                    foreach (var featurePosition in discriminationResults)
                    {
                        computationResultBuilder.Append($"{featurePosition}, ");
                    }
                    computationResultBuilder.Remove(computationResultBuilder.Length - 2, 2);
                    computationResultBuilder.AppendLine($"\t{SelectedAlgorithm.ToString()}\tElapsed time: {watch.Elapsed.Minutes} min {watch.Elapsed.Seconds} s");
                    ResultsTextBox.AppendText(computationResultBuilder.ToString());
                }
                catch (Exception ex)
                {
                    ResultsTextBox.AppendText($"{Environment.NewLine}Error occured while computing: {ex.Message}.");
                }
            }
            else
            {
                ResultsTextBox.AppendText($"{Environment.NewLine}Invalid feature count \"{FeaturesSelectionFeaturesCountTextBox.Text}\" inputted.");
            }
        }
コード例 #21
0
        private void FindButton_Click(object sender, EventArgs e)
        {
            ResultsTextBox.Clear();
            string input = AddressTextBox.Text;

            if (LookupRadioButton.Checked)
            {
                var result = AddressFinder.Find(input);
                ResultsTextBox.Text = result.ToString();
            }
            else
            {
                var result = AddressFinder.Parse(input);
                ResultsTextBox.Text = result.ToString();
            }
        }
コード例 #22
0
        /// <summary>
        /// SELECT Ename, Job, Hiredate FROM Emps
        /// UNION
        /// SELECT "Brak wartości", null, null;
        /// </summary>
        public void Example10Button_Click(object sender, EventArgs e)
        {
            var res = Emps.Union(
                new List <Emp> {
                new Emp {
                    Ename = "Brak wartości", Job = null, HireDate = null
                }
            })
                      .Select(emp => new {
                emp.Ename,
                emp.Job,
                emp.HireDate
            }).ToList();

            ResultsTextBox.Clear();
            ResultsList.DataSource = res;
        }
コード例 #23
0
 private void DecryptFileButton_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(KeyBoxFile.Text) || string.IsNullOrWhiteSpace(FilePathBox.Text))
     {
         MessageBox.Show("You must enter a key!");
     }
     else
     {
         ResultsTextBox.AppendText("Decrypting...\n");
         var    crypto = new Crypto(KeyBoxFile.Text);
         string fileContents;
         string extractedHash;
         string decryptedHash;
         using (StreamReader sr = new StreamReader(FilePathBox.Text))
         {
             fileContents = sr.ReadToEnd();
         }
         extractedHash         = Hasher.ExtractHash(fileContents);
         ExtractedHashBox.Text = extractedHash;
         fileContents          = fileContents.Substring(0, fileContents.Length - 24);
         var utf8WithBom = new UTF8Encoding(true);
         using (
             StreamWriter sw =
                 new StreamWriter(Path.Combine(Path.GetDirectoryName(FilePathBox.Text),
                                               Path.GetFileNameWithoutExtension(FilePathBox.Text) + "Decrypted" + ".txt"), false, utf8WithBom))
         {
             sw.Write(crypto.Decrypt(fileContents));
         }
         using (StreamReader sr = new StreamReader(Path.Combine(Path.GetDirectoryName(FilePathBox.Text), Path.GetFileNameWithoutExtension(FilePathBox.Text) + "Decrypted" + ".txt")))
         {
             fileContents = sr.ReadToEnd();
         }
         decryptedHash = Hasher.GenerateBase64Hash(MD5.Create(), fileContents);
         ResultsTextBox.AppendText("Decryption complete.\n");
         ResultsTextBox.AppendText(string.Format("Decrypted Hash: {0}\n", decryptedHash));
         ResultsTextBox.AppendText(string.Format("Extracted Hash: {0}\n", extractedHash));
         if (Hasher.VerifyHash(decryptedHash, extractedHash))
         {
             ResultsTextBox.AppendText("Hashes match!  Successful decryption.\n");
         }
         else
         {
             ResultsTextBox.AppendText("Hashes do not match!  Unsuccessful decryption.\n");
         }
     }
 }
コード例 #24
0
        private void LoadData(WorkUnitHistoryModel model)
        {
            DataViewComboBox.DataSource = model.QueryBindingSource;
            DataViewEditButton.BindEnabled(model, nameof(WorkUnitHistoryModel.EditAndDeleteButtonsEnabled));
            DataViewDeleteButton.BindEnabled(model, nameof(WorkUnitHistoryModel.EditAndDeleteButtonsEnabled));

            rdoPanelProduction.DataSource  = model;
            rdoPanelProduction.ValueMember = "BonusCalculation";
            ResultsTextBox.BindText(model, nameof(WorkUnitHistoryModel.TotalEntries));
            PageNumberTextBox.BindText(model, nameof(WorkUnitHistoryModel.CurrentPage));
            ResultNumberUpDownControl.DataBindings.Add("Value", model, nameof(WorkUnitHistoryModel.ShowEntriesValue), false, DataSourceUpdateMode.OnPropertyChanged);

            dataGridView1.DataSource = model.HistoryBindingSource;

            Location         = model.FormLocation;
            LocationChanged += (s, e) => model.FormLocation = WindowState == FormWindowState.Normal ? Location : RestoreBounds.Location;
            Size             = model.FormSize;
            SizeChanged     += (s, e) => model.FormSize = WindowState == FormWindowState.Normal ? Size : RestoreBounds.Size;
            RestoreColumnSettings(model.FormColumns);
        }
コード例 #25
0
ファイル: RegexTesterForm.cs プロジェクト: Siyy/RegexTester
 private void TestRegexButton_Click(object sender, EventArgs e)
 {
     ResultsTextBox.Clear();
     try
     {
         RegexOptions selectedRegexOptions = this.GetSelectedRegexOptions();
         Regex        regex = new Regex(this.RegexTextBox.Text, selectedRegexOptions);
         var          mch   = regex.Match(this.InputTextBox.Text);
         if (mch.Success)
         {
             //this.ResultsTextBox.Text = "MATCH FOUND";
             //this.ResultsTextBox.ForeColor = Color.Black;
             ShowMatch(true);
             var sb = new StringBuilder();
             if (mch.Groups.Count > 0)
             {
                 sb.AppendLine($"Groups[{mch.Groups.Count}]:");
                 sb.AppendLine("-------------------------------");
             }
             foreach (var mgo in mch.Groups)
             {
                 Group mg     = mgo as Group;
                 var   idx    = (mg.Success, mg.Index, End : (mg.Index + mg.Length));
                 var   idxTxt = idx.Success ? $"{idx.Index:0000} - {idx.End:0000}" : "   fail!   ";
                 sb.AppendLine($"[{idxTxt}]<{mg.Name}>:{mg.Value}");
             }
             ResultsTextBox.Text = sb.ToString();
         }
         else
         {
             //this.ResultsTextBox.Text = "NO MATCH FOUND";
             //this.ResultsTextBox.ForeColor = Color.Red;
             ShowMatch(false);
         }
     }
     catch (ArgumentException exception)
     {
         this.ResultsTextBox.ForeColor = Color.Red;
         this.ResultsTextBox.Text      = "There was an error in your regular expression:" + Environment.NewLine + exception.Message;
     }
 }
コード例 #26
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ResultsTextBox.AppendText(
                "\"URL\" - страница манги на comic-gardo. \n" +
                "\"Bad\" - папка для перепутанных изображений с сайта. \n" +
                "\"Good\" - папка для обработаных изображений. \n" +
                "\"Загрузить\" - загрузить изображения с сайта в папку Bad. \n" +
                "\"Обработать\" - восстановить порядок в изображениях и положить в папку Good.\n" +
                "\"Purge\" - удалить папку \"Bad\". Может потребовать подождать некоторое время.\n" +
                "===============================================================\n"

                );
            SrcTextBox.Text = System.AppDomain.CurrentDomain.BaseDirectory + "Bad\\";
            BadDirectory    = SrcTextBox.Text;

            OutTextBox.Text = System.AppDomain.CurrentDomain.BaseDirectory + "Good\\";
            //GoodDirectory = OutTextBox.Text;

            if (new DirectoryInfo(BadDirectory).Exists)
            {
                PurgeButton.Visibility = Visibility.Visible;
            }
        }
コード例 #27
0
        private void OpenFileButton_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog
            {
                Filter      = "txt files (*.txt)|*.txt|All files (*.*)|*.*",
                FilterIndex = 0
            };

            if (openFileDialog.ShowDialog() == true)
            {
                string[] fileContent = null;
                try
                {
                    fileContent = File.ReadAllLines(openFileDialog.FileName);
                    if (fileContent != null && fileContent.Any())
                    {
                        FeatureClasses = GetFeatureClasses(fileContent);
                        foreach (var featureClass in FeatureClasses)
                        {
                            if (featureClass.Features.Count < 10 && featureClass.Samples.Count < 10)
                            {
                                ResultsTextBox.AppendText($"{Environment.NewLine}{featureClass.ToString()}");
                            }
                            else
                            {
                                ResultsTextBox.AppendText($"{Environment.NewLine}{featureClass.Name} class loaded");
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    ResultsTextBox.AppendText($"{Environment.NewLine} File {openFileDialog.FileName} is broken or of not supported format.");
                }
            }
        }
コード例 #28
0
        private void button6_Click(object sender, EventArgs e)
        {
            ResultsTextBox.Clear();
            using (SqlConnection connection = new SqlConnection(connectOne))
            {
                try
                {
                    SqlCommand command = new SqlCommand(queryString, connection);
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "SalesByCategory";
                    command.Parameters.Add("@CategoryName", SqlDbType.VarChar, 80).Value = CategoryNameTextBox.Text;
                    command.Parameters.Add("@OrdYear", SqlDbType.Int).Value = OrdYearTextBox.Text;
                    command.Connection.Open();
                    SqlDataReader reader  = command.ExecuteReader();
                    StringBuilder results = new StringBuilder();
                    while (reader.Read())
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            results.Append(reader[i].ToString() + "\t");
                        }
                        results.Append(Environment.NewLine);
                    }
                    ResultsTextBox.Text = results.ToString();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                finally
                {
                    connection.Close();
                }
            }
        }
コード例 #29
0
 public void WriteLine(string str)
 {
     ResultsTextBox.AppendLine(str);
 }
コード例 #30
0
        private async void solveBtn_Click(object sender, EventArgs e)
        {
            solveBtn.Enabled = false;
            solveBtn.Text    = "Solving...";
            TOTAL_SOLUTIONS  = 0;
            ResultsTextBox.Clear();

            #region TEST COLLECTION:
            //short[,] A = new short[,]
            //{
            //    { 1, 1, 1 },
            //    { 1, 0, 1 }
            //};//4 Distinct
            //short[,] B = new short[,]
            //{
            //    { 0, 1 },
            //    { 0, 1 },
            //    { 1, 1 },
            //    { 0, 1 }
            //};//8 Distinct
            //short[,] C = new short[,]
            //{
            //    { 1 },
            //    { 1 },
            //};//2 Distinct
            //short[,] D = new short[,]
            //{
            //    { 1, 0 },
            //    { 1, 0 },
            //    { 1, 1 }
            //};//8 Distinct

            //var sm = new ShapeMan(new List<Shape> { new Shape(A), new Shape(B), new Shape(C), new Shape(D) });

            //foreach (var item in sm.ReadyShapesLists)
            //    await new Solver(item, this).TrySolve();

            //if(TOTAL_SOLUTIONS == 0)
            //    WriteLine("No Possible Solution!");
            #endregion

            if (await ReadShapes())
            {
                ShapeMan    sm    = new ShapeMan(shapes);
                List <Task> tasks = new List <Task>(sm.ReadyShapesLists.Count);
                foreach (var item in sm.ReadyShapesLists)
                {
                    tasks.Add(new Solver(item, this).TrySolve()); //auto writes
                }
                var sw = new Stopwatch();

                #region Solving Parallel
                sw.Start();
                Thread.BeginThreadAffinity();
                Parallel.ForEach(tasks, task => task.Start());
                Thread.EndThreadAffinity();
                await Task.WhenAll(tasks);

                sw.Stop();
                #endregion

                if (TOTAL_SOLUTIONS == 0)
                {
                    WriteLine(string.Format("No Possible Solution!, Time Elapsed: {0}s.",
                                            (sw.ElapsedMilliseconds / 1000.0).ToString()));
                }
                else
                {
                    WriteLine(string.Format("Total Possible Solutions : {0}, Time Elapsed: {1}s.",
                                            TOTAL_SOLUTIONS.ToString(), (sw.ElapsedMilliseconds / 1000.0).ToString()));
                }
            }
            else
            {
                WriteLine("Cannot Read Shapes!,");
                WriteLine("Please Check & Format Input Correctly.");
            }

            solveBtn.Text    = "Solve";
            solveBtn.Enabled = true;
        }