public static void Edit(WorkTypeClass work, WorkTypeClass newwork)
        {
            RemovefromList(work, true);
            bool check = false;

            foreach (WorksTypeTree comp in treelist)
            {
                if (comp.WorksList.CheckBoxes)
                {
                    WorkTypeClass oldwork = comp.CheckedWorks.Find(w => w.FullEquals(work));
                    if (oldwork != null)
                    {
                        check = true;
                        comp.CheckedWorks.Remove(oldwork);
                        WorkTypeClass newwork1 = newwork.Clone() as WorkTypeClass;
                        if (oldwork.parametrs.Count == newwork.parametrs.Count)
                        {
                            oldwork.ParametersValue.CopyTo(newwork1.ParametersValue, 0);
                        }
                        comp.CheckedWorks.Add(newwork1 as WorkTypeClass);
                    }
                }
            }
            AddtoList(newwork, check);
        }
示例#2
0
        public void FullEquals()
        {
            //arrange
            WorkTypeClass work  = new WorkTypeClass();
            WorkTypeClass work1 = work.Clone() as WorkTypeClass;

            //act
            bool actual = work.FullEquals(work1);

            //assert

            Assert.AreEqual(true, actual);
        }
        private void WorksList_AfterCheck(object sender, TreeViewEventArgs e)
        {
            TreeNode      node  = e.Node;
            bool          check = node.Checked;
            WorkTypeClass work  = null;

            if (node.Tag is WorkTypeClass)
            {
                work = node.Tag as WorkTypeClass;
            }
            if (work != null)
            {
                if (check)
                {
                    if (!CheckedWorks.Exists(w => w.Equals(work)))
                    {
                        CheckedWorks.Add((WorkTypeClass)work.Clone());
                    }
                }
                else
                {
                    CheckedWorks.Remove(CheckedWorks.Find(x => x.FullEquals(work)));
                }
                if (check)
                {
                    if (!CheckedCats.Contains(work.category))
                    {
                        CheckedCats.Add(work.category);
                    }
                }
                else
                {
                    CheckedCats.Remove(work.category);
                }
                CheckedNodesChanged?.Invoke(node, new EventArgs());
            }
        }