예제 #1
0
        public void Rename(string newShortName)
        {
            //Trim AML extension
            if (newShortName.ToUpper().EndsWith(".AML"))
            {
                newShortName = newShortName.Substring(0, newShortName.Length - 4);
            }

            //Construct new name
            int    pos     = m_names[0].LastIndexOf("\\");
            String newName = m_names[0].Substring(0, pos) + newShortName + ".aml";

            //Rename
            File.Move(m_names[0], newName);

            //Tell parent that name is changed
            m_gxParent.Refresh();
        }
예제 #2
0
 public override void OnClick()
 {
     if (
         System.Windows.Forms.MessageBox.Show("是否删除选中对象!", "删除", System.Windows.Forms.MessageBoxButtons.YesNo,
                                              System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
     {
         IEnumGxObject enumGxObject = ((IGxSelection)_context.GxSelection).SelectedObjects;
         enumGxObject.Reset();
         IGxObject      gxObject      = enumGxObject.Next();
         IGxObjectArray gxObjectArray = new GxObjectArray();
         while (gxObject != null)
         {
             gxObjectArray.Insert(-1, gxObject);
             gxObject = enumGxObject.Next();
         }
         (enumGxObject as IGxObjectArray).Empty();
         enumGxObject = (gxObjectArray as IEnumGxObject);
         enumGxObject.Reset();
         gxObject = enumGxObject.Next();
         bool      flag      = false;
         IGxObject gxObject2 = null;
         while (gxObject != null)
         {
             if (gxObject2 == null)
             {
                 gxObject2 = gxObject.Parent;
             }
             IGxObjectEdit gxObjectEdit = gxObject as IGxObjectEdit;
             try
             {
                 if (gxObjectEdit.CanDelete())
                 {
                     gxObjectEdit.Delete();
                 }
                 else
                 {
                     flag = true;
                 }
             }
             catch (Exception ex)
             {
                 flag = true;
             }
             gxObject = enumGxObject.Next();
         }
         if (gxObject2 != null)
         {
             try
             {
                 gxObject2.Refresh();
             }
             catch (Exception ex)
             {
             }
         }
         if (flag)
         {
             System.Windows.Forms.MessageBox.Show("一个或多个对象不能删除!", "删除");
         }
     }
 }