Пример #1
0
 /// <summary>
 /// METHOD: AddImage, the method which adds new images to the collection
 /// </summary>
 public void AddImage()
 {
     // IF the returned value of the fileDialog is cancel
     if (_fileDialog.ShowDialog() == DialogResult.Cancel)
     {
         // THEN
         // PRINT to console "Cancelled out"
         Console.WriteLine("Cancelled out");
     }
     // ELSE
     else
     {
         // DECLARE a new List of strings set as a new List of strings
         IList <String> fileNamePaths = new List <String>();
         // SET the value of the _fileNamePaths list to the strings selected
         // by the user in the dialog window
         fileNamePaths = _fileDialog.FileNames;
         // FOREACH through the list of strings generated
         foreach (String s in fileNamePaths)
         {
             // INSTANTIATE instance variable, type String
             // SET to a new guid as a string
             String uid = Guid.NewGuid().ToString();
             // INSTANTIATE instance variable, type IImage data
             // SET to a new ImageData, passing in OpenDisplayView to constructor
             IImageData i = new ImageData();
             // CAST IImageData as a IImageManipulatorInject
             (i as IImageManipulatorInject).Inject(_imgManipulator);
             // INSTANTIATE and INITIALISE a new PictureBox, passing in the UID as a
             PictureBox pb = new CustomPictureBox(uid);
             // SUBSCRIBE the OnImageEvent method in DisplayImage to the picture box
             pb.DoubleClick += _imgCollection.DoubleClick;
             // CAST image data as an IPublisher and call Subscribe _collectionView as ISubscriber
             (i as IPublisher).Subscribe((_collectionView as ISubscriber).OnImageEvent);
             // CALL to AddImage method on IImageData variable
             // passing in picture box and image returned from LoadImage method of
             // the image manipulator
             i.AddImage(pb, _imgManipulator.LoadImage(s));
             // ADD IImageData to _imageCollection and passing in uid aswell
             // ***** Created IImageData in this class as the image collection is
             // for storage purposes only *****
             _imgCollection.AddImage(i, uid);
         }
     }
 }
Пример #2
0
        private void SetValueData(ObjectData obj, XmlNode node)
        {
            XmlAttribute attr = node.Attributes["name"];

            if (attr != null && !string.IsNullOrEmpty(attr.Value))
            {
                Field field = obj.ObjectClass.FindField(attr.Value, true);
                attr = node.Attributes["value"];
                if (field != null && (attr != null || field.FieldType == FieldType.Image || field.FieldType == FieldType.Table))
                {
                    string valueData = attr != null ? attr.Value : string.Empty;
                    switch (field.FieldType)
                    {
                    case FieldType.Boolean:
                        obj[field] = bool.Parse(valueData);
                        break;

                    case FieldType.Date:
                        obj[field] = DateTime.Parse(valueData);
                        break;

                    case FieldType.Image:
                        attr = node.Attributes["ref_path"];
                        string refPath = attr == null ? string.Empty : attr.Value;
                        //attr = node.Attributes["ref_data"];
                        //bool refData = attr == null ? true : bool.Parse(attr.Value);
                        ImageData id = new ImageData(refPath);
                        //id.ReferenceData = refData;
                        foreach (XmlNode item in node.ChildNodes)
                        {
                            attr = item.Attributes["path"];
                            if (attr != null)
                            {
                                id.AddImage(attr.Value);
                            }
                        }
                        obj[field] = id;

                        break;

                    case FieldType.List:
                        this.updatedData.Add(new UpdatedReferenceData(node, obj, field, valueData));
                        break;

                    case FieldType.Number:
                        obj[field] = decimal.Parse(valueData);
                        break;

                    case FieldType.Rating:
                        obj[field] = decimal.Parse(valueData);
                        break;

                    case FieldType.Reference:
                        this.updatedData.Add(new UpdatedReferenceData(node, obj, field, valueData));
                        break;

                    case FieldType.Select:
                        obj[field] = int.Parse(valueData);
                        break;

                    case FieldType.Table:
                        this.updatedData.Add(new UpdatedReferenceData(node, obj, field, valueData));
                        break;

                    default:
                        obj[field] = valueData;
                        break;
                    }
                }
            }
        }