예제 #1
0
파일: Form1.cs 프로젝트: Slawisch/SP_Lab2
        private void RandomAddClicked(object sender, EventArgs e)
        {
            var factory = FactoryExtension.RandomFactory();

            if (factory != null)
            {
                Factories.AddFactory(factory);
            }
            UpdateListBox();
        }
예제 #2
0
파일: Form1.cs 프로젝트: Slawisch/SP_Lab2
        private void MergeClicked(object sender, EventArgs e)
        {
            var mergeIndex = listBox1.SelectedIndices[0];

            if (mergeIndex >= 0 && mergeIndex < Factories.Length)
            {
                List <int> indices = listBox1.SelectedIndices.Cast <int>().ToList();
                Factories.MergeFactories(indices);
                UpdateListBox();
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: Slawisch/SP_Lab2
        private void ManualAddCLicked(object sender, EventArgs e)
        {
            var factoryForm = new NewFactoryForm();

            factoryForm.ShowDialog();
            if (factoryForm.DialogResult == DialogResult.Yes)
            {
                if (factoryForm.NewFactory != null)
                {
                    Factories.AddFactory(factoryForm.NewFactory);
                }
                UpdateListBox();
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: Slawisch/SP_Lab2
        private void UpdateListBox()
        {
            var selectedIndices = listBox1.SelectedIndices.Cast <int>().ToList();

            listBox1.Items.Clear();
            for (int i = 0; i < Factories.Length; i++)
            {
                listBox1.Items.Add(Factories.GetFactoryByIndex(i));
            }
            listBox1.Update();
            foreach (var item in selectedIndices)
            {
                listBox1.SetSelected(item, true);
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: Slawisch/SP_Lab2
 private void DeleteClicked(object sender, EventArgs e)
 {
     ActionByIndex(listBox1.SelectedIndex, factory => Factories.DeleteFactory(listBox1.SelectedIndex));
 }
예제 #6
0
파일: Form1.cs 프로젝트: Slawisch/SP_Lab2
 private void SortClicked(object sender, EventArgs e)
 {
     Factories.Sort();
     UpdateListBox();
 }