Ejemplo n.º 1
0
        static void OnPrepareStampForSerialization(SerializedItem stamp, IItemProperties properties)
        {
            SerializedStampEventArgs serializedStampEventArgs = new SerializedStampEventArgs();

            serializedStampEventArgs.Item       = stamp;
            serializedStampEventArgs.Properties = properties;
            PrepareItemForSerialization?.Invoke(null, serializedStampEventArgs);
        }
Ejemplo n.º 2
0
 public void InsertStamp(int startIndex, IItemProperties item)
 {
     if (item.HasNoZOrder())
     {
         item.ZOrder = startIndex;
     }
     Items.Insert(startIndex, item);
 }
Ejemplo n.º 3
0
 public void AddItem(IItemProperties item)
 {
     if (item.HasNoZOrder())
     {
         item.ZOrder = Items.Count;
     }
     Items.Add(item);
 }
Ejemplo n.º 4
0
        public static SerializedItem From(IItemProperties itemProperties)
        {
            SerializedItem serializedItem = new SerializedItem();

            serializedItem.GetValuesFrom(itemProperties);
            OnPrepareStampForSerialization(serializedItem, itemProperties);
            return(serializedItem);
        }
Ejemplo n.º 5
0
 public override void GetPropertiesFrom(IItemProperties itemProperties, bool transferGuid = true)
 {
     base.GetPropertiesFrom(itemProperties, transferGuid);
     if (itemProperties is MapCharacter mapCharacter)
     {
         this.GetPropertiesFrom <MapCharacter>(mapCharacter);
     }
 }
Ejemplo n.º 6
0
 public void InsertStamps(int startIndex, List <IItemProperties> items)
 {
     for (int i = 0; i < items.Count; i++)
     {
         IItemProperties item = items[i];
         item.ResetZOrder();
         InsertStamp(startIndex + i, item);
     }
 }
Ejemplo n.º 7
0
 public ItemProperties(IItemProperties other)
 {
     Path         = other.Path;
     Name         = other.Name;
     Type         = other.Type;
     Sha1         = other.Sha1;
     Size         = other.Size;
     LastModified = other.LastModified;
 }
        protected double GetSavedValue(IItemProperties itemProperties)
        {
            if (!undoValues.ContainsKey(itemProperties.Guid))
            {
                System.Diagnostics.Debugger.Break();
                return(0);
            }

            return(undoValues[itemProperties.Guid]);
        }
Ejemplo n.º 9
0
        protected override void ActivateUndo(Map map)
        {
            IItemProperties stampFromGuid = map.GetItemFromGuid(stampGuid);

            if (stampFromGuid != null)
            {
                map.RemoveItem(stampFromGuid);
                map.ClearStampSelection();
            }
        }
        protected int GetSavedInt(IItemProperties stampProperties)
        {
            if (!undoValues.ContainsKey(stampProperties.Guid))
            {
                System.Diagnostics.Debugger.Break();
                return(0);
            }

            return((int)Math.Round(undoValues[stampProperties.Guid]));
        }
 protected void SaveValue(IItemProperties itemProperties, double value)
 {
     if (undoValues.ContainsKey(itemProperties.Guid))
     {
         undoValues[itemProperties.Guid] = value;
     }
     else
     {
         undoValues.Add(itemProperties.Guid, value);
     }
 }
Ejemplo n.º 12
0
 public static IItemProperties Clone(this IItemProperties item, double x = 0, double y = 0)
 {
     if (item is IStampProperties stamp)
     {
         return(stamp.Copy(x, y));
     }
     else
     {
         return(item.Copy(x, y));
     }
 }
Ejemplo n.º 13
0
 protected void SaveValue(IItemProperties stampProperties, T value)
 {
     if (undoValues.ContainsKey(stampProperties.Guid))
     {
         undoValues[stampProperties.Guid] = value;
     }
     else
     {
         undoValues.Add(stampProperties.Guid, value);
     }
 }
Ejemplo n.º 14
0
 public IItemProperties GetItemAt(double x, double y)
 {
     for (int i = Items.Count - 1; i >= 0; i--)
     {
         IItemProperties item = Items[i];
         if (item.ContainsPoint(x, y))
         {
             return(item);
         }
     }
     return(null);
 }
Ejemplo n.º 15
0
        public List <IItemProperties> GetItems(List <Guid> itemGuids)
        {
            List <IItemProperties> result = new List <IItemProperties>();

            foreach (Guid guid in itemGuids)
            {
                IItemProperties foundItem = GetItemFromGuid(guid);
                if (foundItem != null)
                {
                    result.Add(foundItem);
                }
            }
            return(result);
        }
Ejemplo n.º 16
0
        public static void Ungroup(IGroup group, List <IItemProperties> ungroupedStamps)
        {
            if (group.Locked)
            {
                return;
            }

            for (int i = 0; i < group.Children.Count; i++)
            {
                IItemProperties stamp = group.Children[i];
                stamp.Move(group.X, group.Y);
                stamp.ZOrder = group.ZOrder + i;
                ungroupedStamps.Add(stamp);
            }
        }
Ejemplo n.º 17
0
 public virtual void GetPropertiesFrom(IItemProperties itemProperties, bool transferGuid = true)
 {
     if (transferGuid)
     {
         Guid = itemProperties.Guid;
     }
     X        = itemProperties.X;
     Y        = itemProperties.Y;
     Locked   = itemProperties.Locked;
     ZOrder   = itemProperties.ZOrder;
     Visible  = itemProperties.Visible;
     FileName = itemProperties.FileName;
     Height   = itemProperties.Height;
     Width    = itemProperties.Width;
     TypeName = itemProperties.TypeName;
 }
Ejemplo n.º 18
0
        void Copy(Map map, double deltaX, double deltaY)
        {
            List <IItemProperties> copiedStamps = new List <IItemProperties>();

            List <IItemProperties> zOrderedSelection = map.SelectedItems.OrderBy(x => x.ZOrder).ToList();

            foreach (IItemProperties item in zOrderedSelection)
            {
                IItemProperties newStamp = item.Clone(deltaX, deltaY);

                if (newStamp != null)
                {
                    map.AddItem(newStamp);
                    copiedStamps.Add(newStamp);
                }
            }

            originalStampSelection.AddRange(map.SelectedItems.Select(stampProperties => stampProperties.Guid));
            SetSelectedItems(map, copiedStamps);
        }
Ejemplo n.º 19
0
 public UngroupedStamps(IItemProperties stampGroup)
 {
     StampGroup = stampGroup;
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionItem"/> class.
 /// </summary>
 /// <param name="path">The item path.</param>
 /// <param name="parent">The item parent.</param>
 /// <param name="properties">The item properties.</param>
 public SolutionItem(IItemPath path, ISolutionFolder parent, IItemProperties properties)
     : base(parent, path, properties)
 {
 }
Ejemplo n.º 21
0
        public virtual void NotifyCompletedAsync(Dispatcher dispatcher, IItemPath newItemPath, IItemProperties newItemProperties)
        {
            IDocumentCreatedCompletionArgs CompletionArgs = new DocumentCreatedCompletionArgs(newItemPath, newItemProperties);

            NotifyEventCompletedAsync(dispatcher, CompletionArgs);
        }
Ejemplo n.º 22
0
 protected T GetSavedValue(IItemProperties stampProperties)
 {
     if (!undoValues.ContainsKey(stampProperties.Guid))
     {
         System.Diagnostics.Debugger.Break();
         return(default);
Ejemplo n.º 23
0
 protected void AddSelectedItem(Map map, IItemProperties item)
 {
     map.SelectedItems.Add(item);
     SelectedItems.Add(item);
     UpdateSelectedStampGuids();
 }
Ejemplo n.º 24
0
 public AddItemOperation(ISolutionRoot root, IFolderPath destinationFolderPath, IItemPath newPath, IItemProperties newProperties)
     : base(root, destinationFolderPath, newPath, newProperties)
 {
 }
Ejemplo n.º 25
0
        protected virtual void Add(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable)
        {
            Assert.ValidateReference(pathTable);

            ClearExpandedFolders();

            List <ISolutionTreeNodeCollection> ModifiedCollectionList = new List <ISolutionTreeNodeCollection>();

            List <ITreeNodePath> PathList = new List <ITreeNodePath>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                PathList.Add(Entry.Key);
            }

            while (PathList.Count > 0)
            {
                IReadOnlyDictionary <IFolderPath, ISolutionFolder> FlatFolderTable = Root.FlatFolderChildren;

                int i = 0;
                while (i < PathList.Count)
                {
                    ITreeNodePath   Path       = PathList[i];
                    IPathConnection Connection = pathTable[Path];
                    IFolderPath     ParentPath = Connection.ParentPath;

                    if (FlatFolderTable.ContainsKey(ParentPath))
                    {
                        PathList.RemoveAt(i);

                        ISolutionFolder             ParentFolder       = FlatFolderTable[ParentPath];
                        ISolutionTreeNodeCollection ChildrenCollection = (ISolutionTreeNodeCollection)ParentFolder.Children;

                        IFolderPath AsFolderPath;
                        IItemPath   AsItemPath;

                        if ((AsFolderPath = Path as IFolderPath) != null)
                        {
                            IFolderProperties Properties = (IFolderProperties)Connection.Properties;

                            ISolutionFolder NewFolder = CreateSolutionFolder(ParentFolder, AsFolderPath, Properties);
                            ChildrenCollection.Add(NewFolder);

                            if (Connection.IsExpanded)
                            {
                                AddExpandedFolder(NewFolder);
                            }
                        }

                        else if ((AsItemPath = Path as IItemPath) != null)
                        {
                            IItemProperties Properties = (IItemProperties)Connection.Properties;

                            ISolutionItem NewItem = CreateSolutionItem(ParentFolder, AsItemPath, Properties);
                            ChildrenCollection.Add(NewItem);
                        }

                        else
                        {
                            Assert.InvalidExecutionPath();
                        }

                        if (!ModifiedCollectionList.Contains(ChildrenCollection))
                        {
                            ModifiedCollectionList.Add(ChildrenCollection);
                        }
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            foreach (ISolutionTreeNodeCollection ChildrenCollection in ModifiedCollectionList)
            {
                ChildrenCollection.Sort();
            }
        }
Ejemplo n.º 26
0
        protected virtual ISolutionItem CreateSolutionItem(ISolutionFolder parentFolder, IItemPath path, IItemProperties properties)
        {
            Assert.ValidateReference(parentFolder);
            Assert.ValidateReference(path);
            Assert.ValidateReference(properties);

            return(new SolutionItem(path, parentFolder, properties));
        }
Ejemplo n.º 27
0
 protected void RemoveSelectedItem(Map map, IItemProperties item)
 {
     map.SelectedItems.Remove(item);
     SelectedItems.Remove(item);
     UpdateSelectedStampGuids();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentCreatedCompletionArgs"/> class.
 /// </summary>
 /// <param name="newItemPath">The path to the created document item.</param>
 /// <param name="newItemProperties">The path to the created document properties.</param>
 public DocumentCreatedCompletionArgs(IItemPath newItemPath, IItemProperties newItemProperties)
 {
     NewItemPath       = newItemPath;
     NewItemProperties = newItemProperties;
 }
Ejemplo n.º 29
0
 public DocumentCreatedCompletionArgs(IItemPath NewItemPath, IItemProperties NewItemProperties)
 {
     this.NewItemPath       = NewItemPath;
     this.NewItemProperties = NewItemProperties;
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Helper method which generates columns for a given IItemProperties and adds
        /// them either to a datagrid or to a collection of columns as specified by the flag.
        /// </summary>
        /// <param name="dataGrid"></param>
        /// <param name="iItemProperties"></param>
        /// <param name="columnCollection"></param>
        private static void GenerateColumns(
            IItemProperties iItemProperties,
            DataGrid dataGrid,
            Collection<DataGridColumn> columnCollection)
        {
            Debug.Assert(iItemProperties != null, "iItemProperties should not be null");
            Debug.Assert(dataGrid != null || columnCollection != null, "Both dataGrid and columnCollection cannot not be null at the same time");
            
            ReadOnlyCollection<ItemPropertyInfo> itemProperties = iItemProperties.ItemProperties;

            if (itemProperties != null &&
                itemProperties.Count > 0)
            {
                foreach (ItemPropertyInfo itemProperty in itemProperties)
                {
                    DataGridColumn dataGridColumn = DataGridColumn.CreateDefaultColumn(itemProperty);

                    if (dataGrid != null)
                    {
                        // AutoGeneratingColumn event is raised before generating and adding column to datagrid
                        // and the column returned by the event handler is used instead of the original column.
                        DataGridAutoGeneratingColumnEventArgs eventArgs = new DataGridAutoGeneratingColumnEventArgs(dataGridColumn, itemProperty);
                        dataGrid.OnAutoGeneratingColumn(eventArgs);

                        if (!eventArgs.Cancel && eventArgs.Column != null)
                        {
                            eventArgs.Column.IsAutoGenerated = true;
                            dataGrid.Columns.Add(eventArgs.Column);
                        }
                    }
                    else
                    {
                        columnCollection.Add(dataGridColumn);
                    }
                }
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Helper method which generates columns for a given IItemProperties
        /// </summary>
        /// <param name="iItemProperties"></param>
        /// <returns></returns>
        public static Collection<DataGridColumn> GenerateColumns(IItemProperties itemProperties)
        {
            if (itemProperties == null)
            {
                throw new ArgumentNullException("itemProperties");
            }

            Collection<DataGridColumn> columnCollection = new Collection<DataGridColumn>();
            DataGrid.GenerateColumns(
                itemProperties.ItemProperties,
                null,
                columnCollection);
            return columnCollection;
        }
Ejemplo n.º 32
0
 public ResizeTracker(IItemProperties item)
 {
     Item = item;
 }