Example #1
0
 public void DeleteObject(ProcessObject obj)
 {
     // TODO удалить обработчики
     //obj.ProcessCurve.Modified -= ProcessCurveModifiedEventHandler;
     //obj.ProcessCurve.Erased -= ProcessCurveErasedEventHandler;
     if (obj.ToolpathCurve != null || obj.ProcessActions != null)
     {
         using (DocumentLock doclock = Document.LockDocument())
         {
             using (AcDb.Transaction trans = TransactionManager.StartTransaction())
             {
                 if (obj.ToolpathCurve != null)
                 {
                     trans.GetObject(obj.ToolpathCurve.ObjectId, AcDb.OpenMode.ForWrite);
                     obj.ToolpathCurve.Erase();
                 }
                 else
                 {
                     obj.ProcessActions.ForEach(p =>
                     {
                         trans.GetObject(p.Toolpath.ObjectId, AcDb.OpenMode.ForWrite);
                         p.Toolpath.Erase();
                     });
                 }
                 trans.Commit();
                 Editor.UpdateScreen();
             }
         }
     }
     RemoveConnect(obj, VertexType.Start);
     RemoveConnect(obj, VertexType.End);
     ObjectList.Remove(obj);
     ObjectForm.RefreshList();
 }
        //public AcadProcessesView()
        //{
        //    PaletteSet = new PaletteSet("Технология");
        //}
        public void Initialize()
        {
            PaletteSet = new PaletteSet("Технология")
            {
                Style       = PaletteSetStyles.NameEditable | PaletteSetStyles.ShowPropertiesMenu | PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton,
                MinimumSize = new Size(300, 200),
                KeepFocus   = true,
                Visible     = true
            };
            //_paletteSet.Add(name, control);
            //PaletteSet = new PaletteSet("Технология", new Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"));
            //PaletteSet.Style = PaletteSetStyles.NameEditable | PaletteSetStyles.ShowPropertiesMenu |
            //    PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton;
            //PaletteSet.MinimumSize = new System.Drawing.Size(300, 200);

            ObjectForm = new ObjectForm(this, ObjectList);
            PaletteSet.Add("Объекты", ObjectForm);

            SettingForm = new SettingForm(ProcessOptions, this);  // TODO - загрузка ProcessOptions
            PaletteSet.Add("Настройка", SettingForm);

            ProgramForm = new ProgramForm(ProgramList, ProcessOptions);
            PaletteSet.Add("Программа", ProgramForm);

            PaletteSet.PaletteActivated += new PaletteActivatedEventHandler(PaletteSet_PaletteActivated);
            Application.DocumentManager.MdiActiveDocument.Editor.SelectionAdded += new SelectionAddedEventHandler(CallbackSelectionAdded);
        }
Example #3
0
        private ACADProcessObjectHandler()
        {
            ps       = new Autodesk.AutoCAD.Windows.PaletteSet("Технология", new Guid("63B8DB5B-10E4-4924-B8A2-A9CF9158E4F6"));
            ps.Style = Autodesk.AutoCAD.Windows.PaletteSetStyles.NameEditable |
                       Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowPropertiesMenu |
                       Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowAutoHideButton |
                       Autodesk.AutoCAD.Windows.PaletteSetStyles.ShowCloseButton;
            ps.MinimumSize = new System.Drawing.Size(300, 200);
            fmObject       = new ObjectForm(this);
            ps.Add("Объекты", fmObject);
            fmSetting = new SettingForm(this);
            ps.Add("Настройка", fmSetting);

            ObjectParams param = new ObjectParams();

            param.MaterialType       = 0;
            param.GreatSpeed         = 1500;
            param.SmallSpeed         = 250;
            param.Frequency          = 1800;
            param.DepthAll           = 32;
            param.Depth              = 32;
            param.ToolNo             = 1;
            param.Tools              = new ObjectParams.Tool[3];
            param.Tools[0].Diameter  = 100;
            param.Tools[0].Thickness = 1;
            param.Tools[1].Diameter  = 200;
            param.Tools[1].Thickness = 2;
            param.Tools[2].Diameter  = 300;
            param.Tools[2].Thickness = 3;
            fmSetting.Params         = param;

            ed.SelectionAdded        += new SelectionAddedEventHandler(callback_SelectionAdded);
            fmObject.SelectItemAction = delegate(int index) { return(m_processList[index].SetSelected()); };
        }
Example #4
0
        void CallbackSelectionAdded(object sender, SelectionAddedEventArgs e)
        {
            //string type = e.AddedObjects[0].ObjectId.Handle.ToString();
            //ACADProcessesView.getInstanse().m_SettingForm.textBox1.AppendText(String.Format("{0} cnt:{1} add:{2} sel:{3}\r\n", ++line, e.Selection.Count, e.AddedObjects.Count, type));

            if (e.AddedObjects.Count == 1)
            {
                if (e.AddedObjects.GetObjectIds()[0] != CurrentObjectID)
                {
                    CurrentObjectID = e.AddedObjects.GetObjectIds()[0];
                    ObjectForm.SelectObject(ObjectList.FindIndex(p => p.ProcessCurve.ObjectId == CurrentObjectID));
                }
            }
            else if (CurrentObjectID != ObjectId.Null)
            {
                ObjectForm.SelectObject(-1);
                CurrentObjectID = ObjectId.Null;
            }
        }
Example #5
0
        void ProcessCurveModifiedEventHandler(object senderObj, EventArgs evtArgs)  // TODO изменение для дуг
        {
            Curve         curve = senderObj as Curve;
            ProcessObject obj   = ObjectList.Find(p => p.ProcessCurve == curve);

            if (obj != null &&
                (
                    (float)curve.StartPoint.X != obj.StartPoint.X || (float)curve.StartPoint.Y != obj.StartPoint.Y ||
                    (float)curve.EndPoint.X != obj.EndPoint.X || (float)curve.EndPoint.Y != obj.EndPoint.Y))
            {
                if ((float)curve.StartPoint.X != obj.StartPoint.X || (float)curve.StartPoint.Y != obj.StartPoint.Y)
                {
                    SetConnect(obj, VertexType.Start);
                }
                if ((float)curve.EndPoint.X != obj.EndPoint.X || (float)curve.EndPoint.Y != obj.EndPoint.Y)
                {
                    SetConnect(obj, VertexType.End);
                }
                obj.RefreshProcessCurveData();
                StartCalcToolpath(obj);
                ObjectForm.RefreshProperty();
                //Application.ShowAlertDialog("Modified");
            }
        }