Exemple #1
0
        //TODO: CmdSet_Click
        private void CmdSet_Click(object sender, EventArgs e)
        {
            swSelMgr = swModel.SelectionManager;
            if (swSelMgr.GetSelectedObjectCount() == 1) // Проверка выделения
            {
                if (swSelMgr.GetSelectedObjectType(1) == 15)
                {
                    if (m2 == 1)
                    {
                        VBMath.Randomize();
                        oldNoteName = "NN" + Strings.LTrim(Convert.ToString(VBMath.Rnd() * 100));
                        //Debug.Print(oldNoteName);
                        ok = swNote.SetName(oldNoteName);
                    }

                    swNote = swSelMgr.GetSelectedObject2(1);
                    ok     = swNote.SetName(newNoteName);
                    Start();
                }
                else
                {
                    MessageBox.Show("Необходимо выделить заметку");
                }
            }
            else
            {
                MessageBox.Show("Выделите одну заметку...");
            }
        }
        public void Test() // Проверка открытого документа
        {
            try
            {
                swModel = swApp.ActiveDoc;
                m2      = 0;

                if (swModel == null)
                {
                    m2 = 1;
                    FrmRecord.LblFirst.Content  = "Откройте документ";
                    FrmRecord.LblSecond.Content = "";
                }
                else if (swModel.GetType() == (int)swDocumentTypes_e.swDocDRAWING)
                {
                    MyDrw = swApp.ActiveDoc;
                }
                else if (swModel.GetType() == (int)swDocumentTypes_e.swDocPART)
                {
                    MyPart = swApp.ActiveDoc;
                }
                else if (swModel.GetType() == (int)swDocumentTypes_e.swDocASSEMBLY)
                {
                    MyAssem = swApp.ActiveDoc;
                }
                else
                {
                    m2 = 1;
                    FrmRecord.LblFirst.Content  = "Откройте нормальный документ";
                    FrmRecord.LblSecond.Content = "";
                }

                if (m2 == 0)
                {
                    SelMgr = swModel.SelectionManager;


                    if (SelMgr.GetSelectedObjectCount() == 1)
                    {
                        if ((int)SelMgr.GetSelectedObjectType(1) != (int)swSelectType_e.swSelDIMENSIONS) // Выберите размер swSelDIMENSIONS
                        {
                            FrmRecord.LblFirst.Content  = "Выберите размер";
                            FrmRecord.LblSecond.Content = "";
                            m2 = 1;
                        }
                    }
                    else
                    {
                        FrmRecord.LblFirst.Content  = "Выберите один размер";
                        FrmRecord.LblSecond.Content = "";
                        m2 = 1;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Source - {0},\r\n" +
                                              "TargetSite - {1},\r\n" +
                                              "Message - {2},\r\n" +
                                              "StackTrace - {3}\r\n",
                                              ex.Source, ex.TargetSite, ex.Message, ex.StackTrace));
            }
        }