Example #1
0
 public EditorUpdateAction(EditorItem item, string property, object oldValue, object newValue)
 {
     this.item = item;
     this.property = property;
     this.oldValue = oldValue;
     this.newValue = newValue;
 }
Example #2
0
 public EditorUpdateAction(EditorItem item, string[] property, object[] oldValues, object[] newValues)
 {
     this.item = item;
     this.properties = property;
     this.oldValues = oldValues;
     this.newValues = newValues;
 }
Example #3
0
        public SizingCommandItem(CommandPosition position, EditorItem owner)
            : base(position, owner)
        {
            this.commandSize = 6;
            this.widthInPixels = 6;
            this.heightInPixels = 6;
            switch (this.CommandPosition)
            {
                case CommandPosition.TopLeft:
                case CommandPosition.BottomRight:
                    this.cursor = Cursors.SizeNWSE;

                    break;
                case CommandPosition.TopCenter:
                case CommandPosition.BottomCenter:
                    this.cursor = Cursors.SizeNS;
                    break;
                case CommandPosition.MiddleLeft:
                case CommandPosition.MiddleRight:
                    this.cursor = Cursors.SizeWE;
                    break;
                case CommandPosition.TopRight:
                case CommandPosition.BottomLeft:
                    this.cursor = Cursors.SizeNESW;
                    break;
            }
        }
Example #4
0
 public MovingCommandItem(EditorItem owner)
     : base(CommandPosition.TopLeft, owner)
 {
     this.commandSize = 10;
     this.widthInPixels = 10;
     this.heightInPixels = 10;
     this.cursor = Cursors.SizeAll;
 }
Example #5
0
        public CommandItem(CommandPosition position, EditorItem owner)
        {
            this.Owner = owner;
            this.commandPosition = position;

            this.widthInPixels = commandSize;
            this.heightInPixels = commandSize;
        }
Example #6
0
        public EditorItem CreateItem(EditorItem newItem)
        {
            // tell action manager that we created new item
            ActionManager.Instance.EditorItemCreated(newItem);
            if (EditorItemCreated != null && newItem.NotifyCreation)
            {
                EditorItemCreated(newItem);
            }

            return newItem;
        }
Example #7
0
 /// <summary>
 /// When some item is placed
 /// </summary>
 /// <param name="item"></param>
 void EditorItem_ItemPlaced(EditorItem item)
 {
     if(InPreviewMode)
     {
         return;
     }
     AddNewEditorItemToList(item);
 }
Example #8
0
        /// <summary>
        /// Find node that contains editor item. This is recursive one
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        private TreeNode FindNodeWithEditorItem(TreeNode parent, EditorItem item)
        {
            if(tvItems.Nodes.Count == 0)
            {
                return null;
            }

            if (parent == null)
            {
                foreach (TreeNode node in tvItems.Nodes)
                {
                    if ((EditorItem)node.Tag == item)
                    {
                        return node;
                    }
                    TreeNode res = FindNodeWithEditorItem(node, item);
                    if (res != null)
                    {
                        return res;
                    }
                }
            }
            else
            {
                foreach (TreeNode node in parent.Nodes)
                {
                    if ((EditorItem)node.Tag == item)
                    {
                        return node;
                    }
                    TreeNode res = FindNodeWithEditorItem(node, item);
                    if (res != null)
                    {
                        return res;
                    }
                }
            }
            return null;
        }
Example #9
0
        /// <summary>
        /// Find all horizontal items needed for adjusting spacing
        /// </summary>
        private void FindHItems()
        {
            FirstItem = null;
            LastLeft = null;
            LastRight = null;

            // Find objects that are far left and far right...
            foreach(EditorItem tmpItem in EditorController.Instance.SelectedItems)
            {
                if(FirstItem == null)
                {
                    FirstItem = tmpItem;
                }

                if(LastLeft == null)
                {
                    LastLeft = tmpItem;
                }
                else
                {
                    if(tmpItem.LocationInPixelsX < LastLeft.LocationInPixelsX)
                    {
                        LastLeft = tmpItem;
                    }
                }

                if(LastRight == null)
                {
                    LastRight = tmpItem;
                }
                else
                {
                    if(tmpItem.LocationInPixelsX > LastRight.LocationInPixelsX)
                    {
                        LastRight = tmpItem;
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// This will delete selected items
        /// </summary>
        public void DeleteSelected()
        {
            EditorItem[] itemList = new EditorItem[SelectedItems.Count];
            itemList = SelectedItems.ToArray();

            for(int i = 0; i < SelectedItems.Count; i++)
            {
                EditorItemFactory.Instance.DeleteItem(itemList[i]);
            }
            SelectedItems.Clear();
            OnEditorItemHierarchyChanged();
        }
Example #11
0
        /// <summary>
        /// This will select one item
        /// </summary>
        /// <param name="item"></param>
        public void SelectItem(EditorItem item)
        {
            DeselectAll();
            if (item != null)
            {
                item.IsSelected = true;
                SelectedItems.Add(item);
                ShowObjectProperties(this.SelectedItems[0]);
                if (SelectionChanged != null)
                {
                    SelectionChanged(SelectedItems);
                }

                //if (EditorViewer != null)
                {
                    EditorProject.FrmReport.RefreshPanels();
                }
            }
        }
Example #12
0
        void Instance_EditorItemDeleted(EditorItem item)
        {
            // add to combo box
            cmbObjects.SelectedValueChanged -= cmbObjects_SelectedValueChanged;
            EditorItemComboItem foundCbxItem = null;
            foreach (EditorItemComboItem cbxItem in itemsCreated)
            {
                if (cbxItem.Item == item)
                {
                    foundCbxItem = cbxItem;
                    break;
                }
            }

            itemsCreated.Remove(foundCbxItem);
            cmbObjects.DataSource = null;
            cmbObjects.DataSource = itemsCreated;
            cmbObjects.DisplayMember = "Text";
            cmbObjects.ValueMember = "Item";
            cmbObjects.Refresh();
            cmbObjects.SelectedValueChanged += cmbObjects_SelectedValueChanged;
        }
Example #13
0
 public void DeleteItem(EditorItem item)
 {
     if (this.SelectedItems.Contains(item))
     {
         this.SelectedItems.Remove(item);
     }
     EditorItemFactory.Instance.DeleteItem(item);
     OnEditorItemHierarchyChanged();
 }
Example #14
0
 /// <summary>
 /// This will check if possibleParent is somewhere in parent list
 /// </summary>
 /// <param name="possibleParent"></param>
 /// <param name="fullCheck"></param>
 public bool CheckIfParent(EditorItem possibleParent)
 {
     if (this.Parent == possibleParent)
     {
         return true;
     }
     else
     {
         if (this.Parent != null)
         {
             return this.Parent.CheckIfParent(possibleParent);
         }
     }
     return false;
 }
Example #15
0
 public EditorDeleteAction(EditorItem itemDeleted, int parentIndex)
 {
     this.itemDeleted = itemDeleted;
     this.parentIndex = parentIndex;
 }
Example #16
0
        /// <summary>
        /// this will delete item 
        /// </summary>
        /// <param name="item"></param>
        public void DeleteItem(EditorItem item)
        {
            // mark item as deleted
            //item.IsDeleted = true;
            // detach it from parent
            if (item.Parent == null)
            {
                throw new Exception("Item for removal has no parent");
            }
            else
            {
                // find exact child and remember index of it
                int parentIndex = 0;
                foreach(EditorItem child in item.Parent.Children)
                {
                    if (child == item)
                    {
                        break;
                    }
                    parentIndex++;
                }
                item.Parent.Children.Remove(item);
                item.StopMoving(true);
                item.IsSelected = false;
                if (EditorItemDeleted != null && item.NotifyDeletion)
                {
                    EditorItemDeleted(item);
                }

                ActionManager.Instance.EditorItemDeleted(item, parentIndex);

                // perform docking on parent to rearrange items
                item.Parent.DockAll();
            }
        }
Example #17
0
        /// <summary>
        /// Little different clone where parent is set to new one
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        protected object Clone(EditorItem newParent)
        {
            EditorItem newItem = (EditorItem)this.MemberwiseClone();

            // make new name
            newItem.Name = MakeName();

            // make new matrices
            newItem.drawMatrix = new System.Drawing.Drawing2D.Matrix();
            newItem.LastDrawMatrix = new System.Drawing.Drawing2D.Matrix();
            newItem.viewMatrix = new System.Drawing.Drawing2D.Matrix();

            newItem.Parent = newParent;
            // attach to parent
            //if (newItem.Parent != null)
            //{
            //    newItem.Parent.Children.Add(newItem);
            //}

            // copy children
            newItem.children = new List<EditorItem>();
            foreach (EditorItem child in this.Children)
            {
                // clone child giving them new parent as parameter
                child.Clone(newItem);
            }

            // tell factory that we created some new item
            EditorItemFactory.Instance.CreateItem(newItem);
            return newItem;
        }
Example #18
0
        /// <summary>
        /// group of properties is changed. This is used for example when locationx,y are changed
        /// </summary>
        /// <param name="item"></param>
        /// <param name="properties"></param>
        /// <param name="newValues"></param>
        /// <param name="oldValues"></param>
        public void EditorItemUpdate(EditorItem item, string[] properties, object[] oldValues, object[] newValues)
        {
            if (!Disabled)
            {
                EditorUpdateAction action = new EditorUpdateAction(item, properties, oldValues, newValues);
                actions.Insert(currentActionIndex, action);
                currentActionIndex++;

                RemoveNotValidItems();
                EditorController.Instance.ProjectSaved = false;
            }
        }
Example #19
0
        /// <summary>
        /// Call this when editor item is deleted
        /// </summary>
        /// <param name="item"></param>
        public void EditorItemDeleted(EditorItem item, int parentIndex)
        {
            if (!Disabled)
            {
                EditorDeleteAction action = new EditorDeleteAction(item, parentIndex);
                actions.Insert(currentActionIndex, action);
                currentActionIndex++;

                RemoveNotValidItems();
                EditorController.Instance.ProjectSaved = false;
            }
        }
Example #20
0
        /// <summary>
        /// Add new item to tvItems list
        /// </summary>
        /// <param name="itemsCreated"></param>
        public void AddNewEditorItemToList(EditorItem itemsCreated)
        {
            // if node exists then remove it first and later add again
            TreeNode fNode = FindNodeWithEditorItem(null, itemsCreated);
            if (fNode != null)
            {
                // turn off notifications for this removal
                tvItems.AfterSelect -= tvItems_AfterSelect;
                if (fNode.Parent != null)
                {
                    fNode.Parent.Nodes.Remove(fNode);
                }
                else
                {
                    tvItems.Nodes.Remove(fNode);
                }
                tvItems.AfterSelect += tvItems_AfterSelect;
            }

            // Now add new item
            TreeNode foundNode = FindNodeWithEditorItem(null, itemsCreated.Parent);
            if (foundNode != null)
            {
                if (fNode != null)
                {
                    foundNode.Nodes.Add(fNode);
                }
                else
                {
                    TreeNode newNode = foundNode.Nodes.Add(itemsCreated.Name);
                    newNode.Tag = itemsCreated;
                }
            }
            else
            {
                if (fNode != null)
                {
                    tvItems.Nodes.Add(fNode);
                }
                else
                {
                    TreeNode newNode = tvItems.Nodes.Add(itemsCreated.Name);
                    newNode.Tag = itemsCreated;
                }
            }
        }
Example #21
0
 void EditorItem_EditorItemCreated(EditorItem itemCreated)
 {
     if(InPreviewMode)
     {
         return;
     }
     // add to combo box
     cmbObjects.SelectedValueChanged -= cmbObjects_SelectedValueChanged;
     itemsCreated.Add(new EditorItemComboItem(itemCreated));
     cmbObjects.DataSource = null;
     cmbObjects.DataSource = itemsCreated;
     cmbObjects.DisplayMember = "Text";
     cmbObjects.ValueMember = "Item";
     cmbObjects.Refresh();
     cmbObjects.SelectedValueChanged += cmbObjects_SelectedValueChanged;
 }
Example #22
0
 public EditorItemComboItem(EditorItem item)
 {
     this.Text = string.Format("{0} : {1}", item.Name, item.GetType().Name);
     this.item = item;
 }
Example #23
0
 public void StartMoving()
 {
     if (this.dockPosition == DockingPosition.DOCK_NONE)
     {
         this.IsMoved = true;
         startMovingX = this.LocationInUnitsX;
         startMovingY = this.LocationInUnitsY;
         startParent = this.Parent;
     }
 }
Example #24
0
        /// <summary>
        /// Find all vertical items needed for adjusting spacing
        /// </summary>
        private void FindVItems()
        {
            FirstItem = null;
            LastTop = null;
            LastBottom = null;

            // Find objects that are far left and far right...
            foreach(EditorItem tmpItem in EditorController.Instance.SelectedItems)
            {
                if(FirstItem == null)
                {
                    FirstItem = tmpItem;
                }

                if(LastTop == null)
                {
                    LastTop = tmpItem;
                }
                else
                {
                    if(tmpItem.LocationInPixelsY < LastTop.LocationInPixelsY)
                    {
                        LastTop = tmpItem;
                    }
                }

                if(LastBottom == null)
                {
                    LastBottom = tmpItem;
                }
                else
                {
                    if (tmpItem.LocationInPixelsY > LastBottom.LocationInPixelsY)
                    {
                        LastBottom = tmpItem;
                    }
                }
            }
        }
Example #25
0
        /// <summary>
        /// This should place new editor item correctly in project hierarchy on location x, y in pixels - later these coordinates will become transformed to appropriate values
        /// </summary>
        /// <param name="newItem"></param>
        public virtual bool AddNewItem(EditorItem newItem, float x, float y, float width, float height, bool transformSize)
        {
            // if this item is not container return false
            if (!isContainer)
            {
                return false;
            }
            if (newItem == this)
            {
                return false;
            }

            // check if any of children items would return true on this method
            foreach(EditorItem child in Children)
            {
                if (child.AddNewItem(newItem, x, y, width, height, transformSize))
                {
                    return true;
                }
            }

            // invert coordinates by view matrix and width and height vectors
            PointF point = new PointF(x, y);
            PointF[] points = new PointF[1];
            points[0] = point;

            Matrix tmpMatrix = LastDrawMatrix.Clone();

            tmpMatrix.Invert();
            tmpMatrix.TransformPoints(points);
            point = points[0];
            x = point.X;
            y = point.Y;

            point.X = width;
            point.Y = height;

            if (transformSize)
            {
                points[0] = point;
                tmpMatrix.TransformVectors(points);
                point = points[0];
            }

            width = point.X;
            height = point.Y;

            // does this new item falls inside this component
            float sx = 0; // *zoomLevel;
            float sy = 0; // *zoomLevel;
            float w = WidthInPixels; //  *zoomLevel;
            float h = HeightInPixels; // *zoomLevel;

            // if starting coordinate fall inside this component rect
            if (x >= sx && x <= sx + w && y >= sy && y <= sy + h)
            {
                if (newItem.Parent != this)
                {
                    if (newItem.Parent != null)
                    {
                        //remove it from previous parent
                        newItem.Parent.Children.Remove(newItem);
                    }

                    newItem.Parent = this;
                    //this.Children.Add(newItem);

                    // update and set location and size properties of newItem
                    newItem.MeasureUnit = this.MeasureUnit;

                    newItem.LocationInUnitsX = UnitsManager.Instance.ConvertUnit(x, MeasureUnits.pixel, MeasureUnit);
                    newItem.LocationInUnitsY = UnitsManager.Instance.ConvertUnit(y, MeasureUnits.pixel, MeasureUnit);
                    newItem.LocationInUnitsX = (float)Math.Round((double)newItem.LocationInUnitsX, 3);
                    newItem.LocationInUnitsY = (float)Math.Round((double)newItem.LocationInUnitsY, 3);

                    if (width == 0 && height == 0)
                    {

                    }
                    else
                    {
                        newItem.WidthInUnits = UnitsManager.Instance.ConvertUnit(width, MeasureUnits.pixel, MeasureUnit);
                        newItem.HeightInUnits = UnitsManager.Instance.ConvertUnit(height, MeasureUnits.pixel, MeasureUnit);
                    }

                    // notify that we have placed item
                    if (EditorItem.ItemPlaced != null)
                    {
                        EditorItem.ItemPlaced(newItem);
                    }
                }

                return true;
            }
            else
            {
                return false;
            }
        }
Example #26
0
        private void RenameDataAndColumn(EditorItem newItem, renamedItems renItem)
        {
            string tmpColumnString;

            foreach(EditorItem item in newItem.Children)
            {
                RenameDataAndColumn(item, renItem);
                if(item is DynamicEditorItemInterface)
                {
                    DynamicEditorItemInterface tmp = (DynamicEditorItemInterface)item;
                    if(renItem.type == 0)
                    {
                        if(tmp.SourceDataStream == renItem.befoure)
                        {
                            tmpColumnString = tmp.SourceColumn;
                            tmp.SourceDataStream = renItem.after;
                            tmp.SourceColumn = tmpColumnString;
                        }
                    }else if(renItem.type == 1)
                    {
                        if(tmp.SourceColumn == renItem.befoure)
                        {
                            tmp.SourceColumn = renItem.after;
                        }
                    }
                }
            }
        }
Example #27
0
        /// <summary>
        /// Create <fonts> node and put all fonts here by analyzing BaseTextItems in parentItem
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="element"></param>
        public void Save(EditorItem parentItem, System.Xml.XmlDocument doc, System.Xml.XmlElement element)
        {
            XmlElement el = doc.CreateElement("Fonts");

            List<BaseTextItems> baseTextItems = new List<BaseTextItems>();
            EditorFont editorFont;
            GetBaseTextItems(parentItem, baseTextItems);

            this.fonts.Clear();
            foreach (BaseTextItems textItem in baseTextItems)
            {
                // create and save each font still not created. We first check if it exists so not to save duplicates
                // currently font is unique if has same name and style
                editorFont = FindFont(textItem.Font.Name, textItem.Font.Style);
                if (editorFont == null)
                {
                    editorFont = CreateFont(textItem.Font);
                    editorFont.Save(doc, el);
                }
                // so we later know how to load it
                textItem.FontSaveId = editorFont.SaveID;
            }
            element.AppendChild(el);
        }
Example #28
0
        /// <summary>
        /// Get all base test items recursively
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="outBaseTextItems"></param>
        private void GetBaseTextItems(EditorItem parent, List<BaseTextItems> outBaseTextItems)
        {
            if (parent is BaseTextItems)
            {
                outBaseTextItems.Add((BaseTextItems)parent);
            }

            foreach (EditorItem item in parent.Children)
            {
                GetBaseTextItems(item, outBaseTextItems);
            }
        }
Example #29
0
 public Anchor(EditorItem ownerItem)
 {
     owner = ownerItem;
 }
Example #30
0
 private bool ValidateSelectionForMoving(EditorItem firstItem, EditorItem item)
 {
     bool result = true;
     EditorItem checkItem = item;
     while(true)
     {
         if(checkItem.Parent == null)
         {
             result = false;
             break;
         }else if(checkItem.Parent != firstItem.Parent)
         {
             if(checkItem.Parent.IsSelected)
             {
                 if(checkItem.Parent != firstItem)
                 {
                     checkItem = checkItem.Parent;
                 }else{
                     result = true;
                     break;
                 }
             }
             else
             {
                 result = false;
                 break;
             }
         }else{
             result = true;
             break;
         }
     }
     return result;
 }