Example #1
0
 public void PostCreateCADObject(CADObject obj)
 {
     if (obj.LockOperation != null)
     {
         if (obj.LockOperation.TemporaryObjectsDictionary.ContainsKey(obj.UID))
         {
             while (obj != null && !obj.LockOperation.TemporaryObjectsDictionary.TryRemove(obj.UID, out obj))
             {
                 ;
             }
         }
     }
     //else
     //{
     //    if (TemporaryObjectsDictionary.ContainsKey(obj.UID))
     //    {
     //        while (!TemporaryObjectsDictionary.TryRemove(obj.UID, out obj)) ;
     //    }
     //}
     if (!ObjectsDictionary.ContainsKey(obj.UID))
     {
         obj.PostCreated = true;
         ParentControl.DocumentTree.Nodes.Find("2D", true)[0].Nodes.Add(new TreeNode(obj.ToString())
         {
             Tag  = obj,
             Name = obj.ToString()
         });
     }
     ObjectsDictionary[obj.UID] = obj;
 }
Example #2
0
        public TextBlock SaveDocument()
        {
            TextBlock file = new TextBlock();

            CADObject.SaveField(CADObject.FindField("allVertices", GetType()), this, file);
            foreach (CADObject o in ObjectsDictionary.Values)
            {
                o.Save(file.AddChild(o.GetType().Name));
            }
            return(file);
        }
Example #3
0
        /// <summary>
        /// Функция создания нового объекта в документе
        /// </summary>
        /// <param name="elemType">Тип элемента из перечисления <see cref="ElementTypes"/></param>
        /// <param name="id">ИД объекта, если загружается ранее созданный объект. Для выделения нового ИД надо ставить значение -1.</param>
        /// <returns>Возвращает созданный объект или null в случае неудачи</returns>
        internal CADObject CreateCADObject(ElementTypes elemType, int id, UserOperation operation)
        {
            CADObject o = null;

            switch (elemType)
            {
            case ElementTypes.Line:
                o = new Line();
                break;

            case ElementTypes.Arc:
                o = new Arc();
                break;

            case ElementTypes.Circle:
                o = new Circle();
                break;

            //case ElementTypes.Point:
            //    o = new Point();
            //    break;
            default:
                Log.Error("No objects!");
                break;
            }
            if (o != null)
            {
                o.LockOperation = operation;
                o.ElementType   = elemType;
                if (id == -1)
                {
                    o.UID = ++_elemIdCounter;
                }
                else
                {
                    o.UID = id;
                }
                //else
                //    TemporaryObjectsDictionary[o.UID] = o;
                o.Parent = this;
                if (operation != null)
                {
                    operation.TemporaryObjectsDictionary[o.UID] = o;
                }
                else
                {
                    PostCreateCADObject(o);
                }
            }
            return(o);
        }