Пример #1
0
        private void AddNewCycle()
        {
            TreeNode pNode = treeDataConstructor.SelectedNode ?? treeDataConstructor.Nodes[0];

            // попытаемся получить вышестоящий узел в дереве

            if (pNode == null) // всетаки неудалось.......
            {
                MessageBox.Show(@"DANGER!!! Ошибка указания родителя?!?!");
                return;
            }

            // найдем вышестоящий узел в ListPrimitives
            PrimitivNode pnfind = FindNodeWithGuid(pNode.Name);

            if (pnfind == null)
            {
                MessageBox.Show(@"DANGER!!! Ошибка поиска родителя?!?!");
                return;
            }

            // Сразу проверим узел выше, т.к. Циклёр можно создавать в корне дерева, или внутри другого каталога, а создание Циклёра внутри других элементов нелогично
            if (!(pnfind.TypeNode == PrimitivType.Catalog || pnfind.TypeNode == PrimitivType.Cycler || pnfind.TypeNode == PrimitivType.Rotate))
            {
                MessageBox.Show(@"Создание циклёра в нутри данного примитива невозможно!");
                return;
            }

            // вызовем диалог добавления циклёра
            frmCycler fCycler = new frmCycler(_mf);

            DialogResult dlResult = fCycler.ShowDialog();

            if (dlResult == DialogResult.OK)
            {
                PrimitivNode pn = new PrimitivNode(new PrimitivCycle((double)fCycler.numStart.Value, (double)fCycler.numStop.Value, (double)fCycler.numStep.Value, fCycler.cbX.Checked, fCycler.cbY.Checked, fCycler.cbZ.Checked, fCycler.textBoxName.Text));
                pnfind.Nodes.Add(pn);
                RefreshTree();
            }
        }
Пример #2
0
        // ReSharper disable once FunctionComplexityOverflow
        private void OpenFormDialog()
        {
            if (treeDataConstructor.SelectedNode == null)
            {
                return;
            }

            // Необходимость перезаполнения дерева обновленными данными
            bool needRefreshTree = false;

            //получим примитив по гуиду
            // ReSharper disable once SuggestVarOrType_SimpleTypes
            PrimitivNode pfind = FindNodeWithGuid(treeDataConstructor.SelectedNode.Name);

            //определим его тип, и откроем необходимый диалог

            if (pfind.TypeNode == PrimitivType.Catalog)
            {
                // вызовем диалог добавления группы
                // ReSharper disable once SuggestVarOrType_SimpleTypes
                frmCatalog fCatalog = new frmCatalog(_mf)
                {
                    deltaX      = { Value = (decimal)pfind.Catalog.DeltaX },
                    deltaY      = { Value = (decimal)pfind.Catalog.DeltaY },
                    deltaZ      = { Value = (decimal)pfind.Catalog.DeltaZ },
                    textBoxName = { Text = pfind.Catalog.Name },
                    deltaRotate = { Value = (decimal)pfind.Catalog.DeltaRotate }
                };

                // ReSharper disable once SuggestVarOrType_SimpleTypes
                DialogResult dlResult = fCatalog.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Catalog.DeltaX      = (double)fCatalog.deltaX.Value;
                    pfind.Catalog.DeltaY      = (double)fCatalog.deltaY.Value;
                    pfind.Catalog.DeltaZ      = (double)fCatalog.deltaZ.Value;
                    pfind.Catalog.Name        = fCatalog.textBoxName.Text;
                    pfind.Catalog.DeltaRotate = (double)fCatalog.deltaRotate.Value;

                    needRefreshTree = true;
                }
            }

            if (pfind.TypeNode == PrimitivType.Cycler)
            {
                // вызовем диалог добавления группы
                // ReSharper disable once SuggestVarOrType_SimpleTypes
                frmCycler fCycler = new frmCycler(_mf)
                {
                    numStart    = { Value = (decimal)pfind.Cycler.CStart },
                    numStop     = { Value = (decimal)pfind.Cycler.CStop },
                    numStep     = { Value = (decimal)pfind.Cycler.CStep },
                    textBoxName = { Text = pfind.Cycler.Name },
                    cbX         = { Checked = pfind.Cycler.AllowDeltaX },
                    cbY         = { Checked = pfind.Cycler.AllowDeltaY },
                    cbZ         = { Checked = pfind.Cycler.AllowDeltaZ }
                };


                // ReSharper disable once SuggestVarOrType_SimpleTypes
                DialogResult dlResult = fCycler.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Cycler.CStart = (double)fCycler.numStart.Value;
                    pfind.Cycler.CStop  = (double)fCycler.numStop.Value;
                    pfind.Cycler.CStep  = (double)fCycler.numStep.Value;

                    pfind.Cycler.Name        = fCycler.textBoxName.Text;
                    pfind.Cycler.AllowDeltaX = fCycler.cbX.Checked;
                    pfind.Cycler.AllowDeltaY = fCycler.cbY.Checked;
                    pfind.Cycler.AllowDeltaZ = fCycler.cbZ.Checked;

                    needRefreshTree = true;
                }
            }


            if (pfind.TypeNode == PrimitivType.Rotate)
            {
                // вызовем диалог добавления группы
                // ReSharper disable once SuggestVarOrType_SimpleTypes
                frmRotate frotate = new frmRotate(_mf)
                {
                    centerX          = { Value = (decimal)pfind.Rotate.X },
                    centerY          = { Value = (decimal)pfind.Rotate.Y },
                    centerZ          = { Value = (decimal)pfind.Rotate.Z },
                    rotateRadius     = { Value = (decimal)pfind.Rotate.Radius },
                    rotateStartAngle = { Value = (decimal)pfind.Rotate.AngleStart },
                    rotateStopAngle  = { Value = (decimal)pfind.Rotate.AngleStop },
                    rotateStepAngle  = { Value = (decimal)pfind.Rotate.AngleStep },
                    deltaStepRadius  = { Value = (decimal)pfind.Rotate.DeltaStepRadius },
                    RotateRotates    = { Value = (decimal)pfind.Rotate.RotateRotates },
                    textBoxName      = { Text = pfind.Rotate.Name }
                };



                DialogResult dlResult = frotate.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Rotate.Name = frotate.textBoxName.Text;

                    pfind.Rotate.X = (double)frotate.centerX.Value;
                    pfind.Rotate.Y = (double)frotate.centerY.Value;
                    pfind.Rotate.Z = (double)frotate.centerZ.Value;

                    pfind.Rotate.Radius     = (double)frotate.rotateRadius.Value;
                    pfind.Rotate.AngleStart = (double)frotate.rotateStartAngle.Value;
                    pfind.Rotate.AngleStop  = (double)frotate.rotateStopAngle.Value;
                    pfind.Rotate.AngleStep  = (double)frotate.rotateStepAngle.Value;

                    pfind.Rotate.DeltaStepRadius = (double)frotate.deltaStepRadius.Value;
                    pfind.Rotate.RotateRotates   = (double)frotate.RotateRotates.Value;

                    needRefreshTree = true;
                }
            }



            if (pfind.TypeNode == PrimitivType.Point)
            {
                // вызовем диалог добавления группы
                frmPoint fPoint = new frmPoint
                {
                    numPosX = { Value = (decimal)pfind.Point.X },
                    numPosY = { Value = (decimal)pfind.Point.Y },
                    numPosZ = { Value = (decimal)pfind.Point.Z }
                };

                DialogResult dlResult = fPoint.ShowDialog();

                if (dlResult == DialogResult.OK)
                {
                    pfind.Point.X   = (double)fPoint.numPosX.Value;
                    pfind.Point.Y   = (double)fPoint.numPosY.Value;
                    pfind.Point.Z   = (double)fPoint.numPosZ.Value;
                    needRefreshTree = true;
                }
            }

            if (needRefreshTree)
            {
                RefreshTree();
            }
        }