Esempio n. 1
1
        public void CheckMail()
        {
            try
            {
                string processLoc = dataActionsObject.getProcessingFolderLocation();
                StreamWriter st = new StreamWriter("C:\\Test\\_testings.txt");
                string emailId = "*****@*****.**";// ConfigurationManager.AppSettings["UserName"].ToString();
                if (emailId != string.Empty)
                {
                    st.WriteLine(DateTime.Now + " " + emailId);
                    st.Close();
                    ExchangeService service = new ExchangeService();
                    service.Credentials = new WebCredentials(emailId, "Sea2013");
                    service.UseDefaultCredentials = false;
                    service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
                    Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
                    SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
                    if (inbox.UnreadCount > 0)
                    {
                        ItemView view = new ItemView(inbox.UnreadCount);
                        FindItemsResults<Item> findResults = inbox.FindItems(sf, view);
                        PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.From, EmailMessageSchema.ToRecipients);
                        itempropertyset.RequestedBodyType = BodyType.Text;
                        //inbox.UnreadCount
                        ServiceResponseCollection<GetItemResponse> items = service.BindToItems(findResults.Select(item => item.Id), itempropertyset);
                        MailItem[] msit = getMailItem(items, service);

                        foreach (MailItem item in msit)
                        {
                            item.message.IsRead = true;
                            item.message.Update(ConflictResolutionMode.AlwaysOverwrite);
                            foreach (Attachment attachment in item.attachment)
                            {
                                if (attachment is FileAttachment)
                                {
                                    string extName = attachment.Name.Substring(attachment.Name.LastIndexOf('.'));
                                    FileAttachment fileAttachment = attachment as FileAttachment;
                                    FileStream theStream = new FileStream(processLoc + fileAttachment.Name, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                                    fileAttachment.Load(theStream);
                                    byte[] fileContents;
                                    MemoryStream memStream = new MemoryStream();
                                    theStream.CopyTo(memStream);
                                    fileContents = memStream.GetBuffer();
                                    theStream.Close();
                                    theStream.Dispose();
                                    Console.WriteLine("Attachment name: " + fileAttachment.Name + fileAttachment.Content + fileAttachment.ContentType + fileAttachment.Size);
                                }
                            }
                        }
                    }
                    DeleteMail(emailId);
                }
            }
            catch (Exception ex)
            {

            }
        }
 /// <summary>
 /// Binds to an existing calendar folder and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the calendar folder.</param>
 /// <param name="id">The Id of the calendar folder to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A CalendarFolder instance representing the calendar folder corresponding to the specified Id.</returns>
 public static new CalendarFolder Bind(
     ExchangeService service,
     FolderId id,
     PropertySet propertySet)
 {
     return service.BindToFolder<CalendarFolder>(id, propertySet);
 }
        /// <summary>
        /// Returns a list of events given the start and end time, inclusive.
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public IEnumerable<ICalendarEvent> GetCalendarEvents(DateTimeOffset startDate, DateTimeOffset endDate)
        {
            // Initialize the calendar folder object with only the folder ID.
            var propertiesToGet = new PropertySet(PropertySet.IdOnly);
            propertiesToGet.RequestedBodyType = BodyType.Text;

            var calendar = CalendarFolder.Bind(_exchangeService, WellKnownFolderName.Calendar, propertiesToGet);
            
            // Set the start and end time and number of appointments to retrieve.
            var calendarView = new CalendarView(
                startDate.ToOffset(_exchangeService.TimeZone.BaseUtcOffset).DateTime,
                endDate.ToOffset(_exchangeService.TimeZone.BaseUtcOffset).DateTime,
                MAX_EVENTS_TO_RETRIEVE);

            // Retrieve a collection of appointments by using the calendar view.
            var appointments = calendar.FindAppointments(calendarView);

            // Get specific properties.
            var appointmentSpecificPropertiesToGet = new PropertySet(PropertySet.FirstClassProperties);
            appointmentSpecificPropertiesToGet.AddRange(NonFirstClassAppointmentProperties);
            appointmentSpecificPropertiesToGet.RequestedBodyType = BodyType.Text;
            _exchangeService.LoadPropertiesForItems(appointments, appointmentSpecificPropertiesToGet);

            return TransformExchangeAppointmentsToGenericEvents(appointments);
        }
Esempio n. 4
0
 /// <summary>
 /// Binds to an existing task and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the task.</param>
 /// <param name="id">The Id of the task to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A Task instance representing the task corresponding to the specified Id.</returns>
 public static new Task Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<Task>(id, propertySet);
 }
 /// <summary>
 /// Binds to an existing meeting request and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the meeting request.</param>
 /// <param name="id">The Id of the meeting request to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A MeetingRequest instance representing the meeting request corresponding to the specified Id.</returns>
 public static new MeetingRequest Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<MeetingRequest>(id, propertySet);
 }
Esempio n. 6
0
 /// <summary>
 /// Binds to an existing item, whatever its actual type is, and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the item.</param>
 /// <param name="id">The Id of the item to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>An Item instance representing the item corresponding to the specified Id.</returns>
 public static Item Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<Item>(id, propertySet);
 }
 /// <summary>
 /// Binds to an existing e-mail message and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the e-mail message.</param>
 /// <param name="id">The Id of the e-mail message to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>An EmailMessage instance representing the e-mail message corresponding to the specified Id.</returns>
 public static new EmailMessage Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<EmailMessage>(id, propertySet);
 }
Esempio n. 8
0
        internal void ExportItem()
        {
            if (this.ItemToExport.GetType().Name.ToString() != "EmailMessage")
                throw new InvalidOperationException("Please provide item typeof EmailMessage.");

            ExchangeService ewsSession = this.GetSessionVariable();
            PropertySet propertySet = new PropertySet(EmailMessageSchema.MimeContent);
            propertySet.Add(EmailMessageSchema.ConversationTopic);

            EmailMessage emailMessage = EmailMessage.Bind(ewsSession, this.ItemToExport.Id, propertySet);

            Random rNumber = new Random();
            string directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "EmailExport");

            if (!Directory.Exists(directory))
                Directory.CreateDirectory(directory);

            if (string.IsNullOrEmpty(this.fileName))
            {
                int subjectLenght = emailMessage.ConversationTopic.Length > 10 ? 10 : emailMessage.ConversationTopic.Length;
                fileName = String.Format( "Email-{0}-{1}" , emailMessage.ConversationTopic.Substring( 0 , subjectLenght ) , rNumber.Next( 1 , 10 ) );
            }

            fileName = Path.Combine(directory, string.Format("{0}.eml", fileName));

            using (FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write))
            {
                fileStream.Write(emailMessage.MimeContent.Content, 0, emailMessage.MimeContent.Content.Length);
            }
        }
Esempio n. 9
0
        private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
        {
            //IMapDocument mxd;
            string x;
            x = e.mapX.ToString("#########.########");
            string y;
            y = e.mapY.ToString("#########.########");

            string data;
            data = "";
            data += string.Format("The map has x coordinate {0} \n y coordinate {1}", x, y);

            Form1 msgForm = new Form1();
            msgForm.label1.Text = data;
            //msgForm.ShowDialog();
            IPropertySet location = new PropertySet();
            location.SetProperty("ps","C:\\Users\\AlexanderN\\Documents\\ArcGIS\\Points.gdb");
            string featureBuffer = "C:\\Users\\AlexanderN\\Documents\\ArcGIS\\Points.gdb\\Buffer";
            string featurePoint = "C:\\Users\\AlexanderN\\Documents\\ArcGIS\\Points.gdb\\AdditionalPoint";
            IFeatureWorkspace ws;
            IFeature newPoint = ws.OpenFeatureClass(featurePoint) as IFeature;
            IFeature newBuffer = ws.OpenFeatureClass(featureBuffer) as IFeature;

                Geom.IPoint point = new Geom.PointClass();
                point.PutCoords(e.mapX, e.mapY);
                newPoint.Shape = point;
                IFeatureClass pointFC = newPoint as IFeatureClass;
                newPoint.Store();
        }
Esempio n. 10
0
 /// <summary>
 /// Binds to an existing Persona and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the Persona.</param>
 /// <param name="id">The Id of the Persona to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A Persona instance representing the Persona corresponding to the specified Id.</returns>
 public static new Persona Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<Persona>(id, propertySet);
 }
Esempio n. 11
0
 /// <summary>
 /// Binds to an existing appointment and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the appointment.</param>
 /// <param name="id">The Id of the appointment to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>An Appointment instance representing the appointment corresponding to the specified Id.</returns>
 public static new Appointment Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<Appointment>(id, propertySet);
 }
        private void createTestVirtualDocument()
        {
                // create a new DataObject to use as the parent node
                ObjectIdentity emptyIdentity = new ObjectIdentity(DefaultRepository);
                DataObject parentDO = new DataObject(emptyIdentity);
                parentDO.Type = "dm_document";
                PropertySet parentProperties = new PropertySet();
                parentProperties.Set("object_name", SampleContentManager.testVdmObjectName);
                parentDO.Properties = parentProperties;

                // link into a folder
                ObjectPath objectPath = new ObjectPath(SampleContentManager.sourcePath);
                ObjectIdentity sampleFolderIdentity = new ObjectIdentity(objectPath, DefaultRepository);
                ReferenceRelationship sampleFolderRelationship = new ReferenceRelationship();
                sampleFolderRelationship.Name = Relationship.RELATIONSHIP_FOLDER;
                sampleFolderRelationship.Target = sampleFolderIdentity;
                sampleFolderRelationship.TargetRole = Relationship.ROLE_PARENT;
                parentDO.Relationships.Add(sampleFolderRelationship);

                // get id of document to use for first child node
                ObjectIdentity child0Id = new ObjectIdentity();
                child0Id.RepositoryName = DefaultRepository;
                child0Id.Value = new Qualification(SampleContentManager.gifImageQualString);

                // get id of document to use for second child node
                ObjectIdentity child1Id = new ObjectIdentity();
                child1Id.RepositoryName = DefaultRepository;
                child1Id.Value = new Qualification(SampleContentManager.gifImage1QualString);

                ObjectIdentitySet childNodes = new ObjectIdentitySet();
                childNodes.AddIdentity(child0Id);
                childNodes.AddIdentity(child1Id);

                virtualDocumentServiceDemo.AddChildNodes(parentDO, childNodes);
        }
Esempio n. 13
0
 /// <summary>
 /// Binds to an existing contact and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the contact.</param>
 /// <param name="id">The Id of the contact to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A Contact instance representing the contact corresponding to the specified Id.</returns>
 public static new Contact Bind(
     ExchangeService service,
     ItemId id,
     PropertySet propertySet)
 {
     return service.BindToItem<Contact>(id, propertySet);
 }
        public void ShowNumberProperties()
        {
            PropertySet propertySet = new PropertySet();

            //Create instances of NumberProperty
            propertySet.Set("TestShortName", (short) 10);
            propertySet.Set("TestIntegerName", 10);
            propertySet.Set("TestLongName", 10L);
            propertySet.Set("TestDoubleName", 10.10);

            //Create instance of DateProperty
            propertySet.Set("TestDateName", new DateTime());

            //Create instance of BooleanProperty
            propertySet.Set("TestBooleanName", false);

            //Create instance of ObjectIdProperty
            propertySet.Set("TestObjectIdName", new ObjectId("10"));

            List<Property> properties = propertySet.Properties;
            foreach (Property p in properties)
            {
                Console.WriteLine(typeof(Property).ToString() +
                                  " = " +
                                  p.GetValueAsString());
            }
        }
 /// <summary>
 /// Binds to an existing meeting cancellation message and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the meeting cancellation message.</param>
 /// <param name="id">The Id of the meeting cancellation message to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A MeetingCancellation instance representing the meeting cancellation message corresponding to the specified Id.</returns>
 public static new MeetingCancellation Bind(
     ExchangeService service,
     ItemId id, 
     PropertySet propertySet)
 {
     return service.BindToItem<MeetingCancellation>(id, propertySet);
 }
Esempio n. 16
0
 /// <summary>
 /// Creates an empty test package.
 /// </summary>
 public TestPackage()
 {
     files = new List<FileInfo>();
     hintDirectories = new List<DirectoryInfo>();
     excludedTestFrameworkIds = new List<string>();
     properties = new PropertySet();
 }
        /// <inheritdoc />
        public IHandler CreateHandler(IObjectDependencyResolver dependencyResolver, Type contractType, Type objectType, PropertySet properties)
        {
            if (! contractType.IsInstanceOfType(instance))
                throw new RuntimeException(string.Format("Could not satisfy contract of type '{0}' using pre-manufactured instance of type '{1}'.",
                    contractType, instance.GetType()));

            return new Handler(instance);
        }
        /// <inheritdoc />
        public IHandler CreateHandler(IObjectDependencyResolver dependencyResolver, Type contractType, Type objectType, PropertySet properties)
        {
            if (! contractType.IsAssignableFrom(objectType))
                throw new RuntimeException(string.Format("Could not satisfy contract of type '{0}' by creating an instance of type '{1}'.",
                    contractType, objectType));

            var objectFactory = new ObjectFactory(dependencyResolver, objectType, properties);
            return new SingletonHandler(objectFactory);
        }
        public EWSIncomingItemAttachment(ItemAttachment attachment)
        {
            _attachment = attachment;
            Logger.DebugFormat("Loading attachment");
            var additionalProperties = new PropertySet { ItemSchema.MimeContent };
            _attachment.Load(additionalProperties);

            Logger.DebugFormat("Attachment name is {0}", _attachment.Name);
        }
Esempio n. 20
0
        public void ProcessMails()
        {
            // Get the inbox folder and load all properties. This results in a GetFolder call to EWS. 
            Folder folder = Folder.Bind(service, WellKnownFolderName.Inbox);
            PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.Body, ItemSchema.TextBody, ItemSchema.NormalizedBody);
            //propSet.RequestedBodyType = BodyType.Text;
            //propSet.BasePropertySet = BasePropertySet.FirstClassProperties;
            ItemView view = new ItemView(1);
            SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
            var items = folder.FindItems(sf, view);

            foreach (var item in items)
            {
                Item mailItem = Item.Bind(service, item.Id, propSet);
                Console.WriteLine(mailItem.Subject);
                Console.WriteLine("*********************************************************");
                Console.WriteLine(mailItem.Body);
                Console.WriteLine("*********************************************************");
                Console.WriteLine(mailItem.TextBody ?? "");
                Console.WriteLine("*********************************************************");
                Console.WriteLine(mailItem.NormalizedBody ?? "");
                Console.WriteLine("*********************************************************");
                Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n");

                HtmlDocument htmlDoc = new HtmlDocument();
                htmlDoc.LoadHtml(mailItem.NormalizedBody);

                if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
                {
                    // TODO: Handle any parse errors as required
                }
                else
                {

                    if (htmlDoc.DocumentNode != null)
                    {
                        var nodes = htmlDoc.DocumentNode.SelectNodes("//table");
                        for (int i = 0; i < nodes.Count; i++)
                        {
                            var node = nodes[i];
                            if (i == 0)
                            {

                            }
                            else if (i == 1)
                            {
                                var table = Utilities.GetDataTable(node);
                            }
                            else
                            {
                                break; //TODO: raise error? continue silently?
                            }
                        }
                    }
                }
            }
        }
        public void AgsConnect_Works()
        {
            var connectionFactory = (IAGSServerConnectionFactory2) new AGSServerConnectionFactory();
            IPropertySet connectionProps = new PropertySet();
            connectionProps.SetProperty("URL", address);

            IAGSServerConnection gisServer = connectionFactory.Open(connectionProps, 0);
            Assert.That(gisServer, Is.Not.Null);
        }
 private object GetProperty(PropertySet props, string key)
 {
     foreach (PropertySetProperty prop in props.PropertyArray)
     {
         if (string.Compare(prop.Key, key, true) == 0)
             return prop.Value;
     }
     return null;
 }
Esempio n. 23
0
        public void GetMappingView_InterfaceWithIndexer_ShouldThrowNotSupportedException()
        {
            var Mapping = new PropertySet();
            Mapping["Value"] = "value";

            Assert.Throws<NotSupportedException>(() =>
            {
                MetadataMapper.Map<IMappingViewWithIndexer>(Mapping);
            });
        }
 /// <summary>
 /// Binds to an existing calendar folder and loads the specified set of properties.
 /// Calling this method results in a call to EWS.
 /// </summary>
 /// <param name="service">The service to use to bind to the calendar folder.</param>
 /// <param name="name">The name of the calendar folder to bind to.</param>
 /// <param name="propertySet">The set of properties to load.</param>
 /// <returns>A CalendarFolder instance representing the calendar folder with the specified name.</returns>
 public static new CalendarFolder Bind(
     ExchangeService service,
     WellKnownFolderName name,
     PropertySet propertySet)
 {
     return CalendarFolder.Bind(
         service,
         new FolderId(name),
         propertySet);
 }
Esempio n. 25
0
        public void GetMappingView_AbstractClass_ShouldThrowMissingMethodException()
        {
            var Mapping = new PropertySet();
            Mapping["Value"] = "value";

            Assert.Throws<NotSupportedException>(() =>
            {
                MetadataMapper.Map<AbstractClassMappingView>(Mapping);
            });
        }
Esempio n. 26
0
        public void GetMappingView_AbstractClassWithConstructor_ShouldThrowMemberAccessException()
        {
            var Mapping = new PropertySet();
            Mapping["Value"] = "value";

            Assert.Throws<MemberAccessException>(() =>
            {
                MetadataMapper.Map<AbstractClassWithConstructorMappingView>(Mapping);
            });
        }
 public ComponentDescriptor(Registry registry, ComponentRegistration componentRegistration)
 {
     this.registry = registry;
     pluginDescriptor = (PluginDescriptor) componentRegistration.Plugin;
     serviceDescriptor = (ServiceDescriptor) componentRegistration.Service;
     componentId = componentRegistration.ComponentId;
     componentTypeName = componentRegistration.ComponentTypeName ?? serviceDescriptor.DefaultComponentTypeName;
     componentProperties = componentRegistration.ComponentProperties.Copy().AsReadOnly();
     traitsProperties = componentRegistration.TraitsProperties.Copy().AsReadOnly();
     componentHandlerFactory = componentRegistration.ComponentHandlerFactory;
 }
Esempio n. 28
0
        public void Copy()
        {
            PropertySet original = new PropertySet();
            original.Add("abc", "123");
            original.Add("def", "");

            PropertySet copy = original.Copy();

            Assert.AreNotSame(original, copy);
            AssertAreEqual(original, copy);
        }
Esempio n. 29
0
        public void SerializeToXml(string expectedXml, string[] keyValuePairs)
        {
            PropertySet map = new PropertySet();
            for (int i = 0; i < keyValuePairs.Length; i += 2)
                map.Add(keyValuePairs[i], keyValuePairs[i + 1]);

            StringWriter writer = new StringWriter();
            serializer.Serialize(writer, map);

            Assert.AreEqual(expectedXml, writer.ToString());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetFolderResponse"/> class.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="propertySet">The property set from the request.</param>
        internal GetFolderResponse(Folder folder, PropertySet propertySet)
            : base()
        {
            this.folder = folder;
            this.propertySet = propertySet;

            EwsUtilities.Assert(
                this.propertySet != null,
                "GetFolderResponse.ctor",
                "PropertySet should not be null");
        }
Esempio n. 31
0
        public MainForm()
        {
            InitializeComponent();

            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);
            this.axRenderControl1.Camera.FlyTime = 1;
            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;

            // 设置天空盒
            flag = Application.StartupPath.LastIndexOf("Samples");
            if (flag > -1)
            {
                string  tmpSkyboxPath = Path.Combine(Application.StartupPath.Substring(0, flag), @"Samples\Media\skybox");
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = Path.Combine(Application.StartupPath.Substring(0, flag), @"Samples\Media\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                string[]        fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // 设置时间轴
            this.trackBarTime.Minimum = 0;
            this.trackBarTime.Maximum = 4;

            // CreateFeautureLayer
            bool hasfly = false;

            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);
                    if (featureLayer == null)
                    {
                        continue;
                    }

                    if (fc.Name.Equals("Building") && geoName.Equals("Geometry"))
                    {
                        pset = new PropertySet();
                        pset.SetProperty("type", this.trackBarTime.Minimum);
                        featureLayer.CompareRenderRuleVariants = pset;

                        IValueMapGeometryRender render = new ValueMapGeometryRender();
                        {
                            IGeometryRenderScheme scheme = new GeometryRenderScheme();
                            IComparedRenderRule   rule   = new ComparedRenderRule();
                            rule.LookUpField     = "BuildType";
                            rule.CompareVariant  = "type";
                            rule.CompareOperator = gviCompareType.gviCompareEqual;
                            scheme.AddRule(rule);
                            IModelPointSymbol symbol = new ModelPointSymbol();
                            symbol.EnableColor = true;
                            symbol.Color       = System.Drawing.Color.Green;
                            scheme.Symbol      = symbol;
                            render.AddScheme(scheme);
                        }
                        {
                            IGeometryRenderScheme scheme = new GeometryRenderScheme();
                            IComparedRenderRule   rule   = new ComparedRenderRule();
                            rule.LookUpField     = "BuildType";
                            rule.CompareVariant  = "type";
                            rule.CompareOperator = gviCompareType.gviCompareLessOrEqual;
                            scheme.AddRule(rule);
                            render.AddScheme(scheme);
                        }
                        featureLayer.SetGeometryRender(render);
                        buildlayer = featureLayer;
                    }

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        angle.Set(0, -30, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 300, angle);
                        hasfly = true;
                    }
                }
            }

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "ComparedRenderRule.html";
            }
        }
Esempio n. 32
0
        /// <summary>
        /// 初始化
        /// </summary>
        private void init()
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(false, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;
            this.axRenderControl1.Camera.FlyTime = 1;


            #region 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;

                string tmpFDBPath = (strMediaPath + @"\SDKDEMO.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                datasetCRS = dataset.SpatialReference;
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string>        geoNames   = new List <string>();
                    IFieldInfoCollection fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }
                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);
                }
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            bool hasfly = false;
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    if (!geoName.Equals("Geometry"))
                    {
                        continue;
                    }

                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(
                        fc, geoName, null, null, rootId);
                    featureLayer.MouseSelectMask = gviViewportMask.gviViewNone;

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        IEulerAngle angle = new EulerAngle();
                        angle.Set(0, -20, 0);
                        if (geoFactory == null)
                        {
                            geoFactory = new GeometryFactory();
                        }
                        IPoint pos = geoFactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        pos.SpatialCRS = datasetCRS;
                        pos.Position   = env.Center;
                        this.axRenderControl1.Camera.LookAt2(pos, 1000, angle);
                    }
                    hasfly = true;
                }
            }
            #endregion 加载FDB场景

            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionShapeFile;
                string tmpShpPath = (strMediaPath + @"\shp\Singapore\BCA_EXISTING_BUILDING.shp");
                ci.Database = tmpShpPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                IDataSource        ds        = dsFactory.OpenDataSource(ci);
                string[]           setnames  = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                IFeatureDataSet dataset = ds.OpenFeatureDataset(setnames[0]);
                shpCRS = dataset.SpatialReference;
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                IFeatureClass fc = dataset.OpenFeatureClass(fcnames[0]);
                this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, "Geometry", null, null, rootId);
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            this.axRenderControl1.InteractMode          = gviInteractMode.gviInteractSelect;
            this.axRenderControl1.MouseSelectObjectMask = gviMouseSelectObjectMask.gviSelectFeatureLayer;
            this.axRenderControl1.MouseSelectMode       = gviMouseSelectMode.gviMouseSelectClick;
            this.axRenderControl1.RcMouseClickSelect   += new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);


            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "SpatialQuery.html";
            }
        }
Esempio n. 33
0
        /// <summary>
        /// Adds WMS document to map
        /// </summary>
        /// <param name="ipMxDoc"></param>
        /// <param name="strServer"></param>
        /// <param name="strLayerName"></param>
        /// <param name="strSecretName"></param>
        /// <returns></returns>
        private bool addLayerWMS(IMxDocument ipMxDoc, string strServer, string strLayerName, string strSecretName)
        {
            IPropertySet ipPropSet = new PropertySet();
            string       strFinalChar;

            // check the final char
            strFinalChar = strServer.Substring(strServer.Length - 1);
            if (strFinalChar == "?" && strFinalChar != "&")
            {
                if (strServer.Contains("?"))
                {
                    ipPropSet.SetProperty("URL", (strServer + '&'));
                }
                else
                {
                    ipPropSet.SetProperty("URL", (strServer + '?'));
                }
            }
            else
            {
                ipPropSet.SetProperty("URL", strServer + '?');
            }

            IMap               map               = (IMap)ipMxDoc.FocusMap;
            IActiveView        activeView        = (IActiveView)map;
            IWMSGroupLayer     wmsGroupLayer     = (IWMSGroupLayer) new WMSMapLayerClass();
            IWMSConnectionName wmsConnectionName = new WMSConnectionName();

            wmsConnectionName.ConnectionProperties = ipPropSet;

            IDataLayer dataLayer;
            bool       connected = false;

            try
            {
                dataLayer = (IDataLayer)wmsGroupLayer;
                IName connName = (IName)wmsConnectionName;
                connected = dataLayer.Connect(connName);
            }
            catch (Exception ex)
            {
                connected = false;
            }
            if (!connected)
            {
                return(false);
            }

            // get service description out of the layer. the service description contains
            // information about the wms categories and layers supported by the service
            IWMSServiceDescription wmsServiceDesc = wmsGroupLayer.WMSServiceDescription;
            IWMSLayerDescription   wmsLayerDesc   = null;
            ILayer         newLayer;
            ILayer         layer;
            IWMSLayer      newWmsLayer;
            IWMSGroupLayer newWmsGroupLayer;

            for (int i = 0; i < wmsServiceDesc.LayerDescriptionCount; i++)
            {
                newLayer = null;

                wmsLayerDesc = wmsServiceDesc.get_LayerDescription(i);
                if (wmsLayerDesc.LayerDescriptionCount == 0)
                {
                    // wms layer
                    newWmsLayer = wmsGroupLayer.CreateWMSLayer(wmsLayerDesc);
                    newLayer    = (ILayer)newWmsLayer;
                    if (newLayer == null)
                    {
                    }
                }
                else
                {
                    // wms group layer
                    newWmsGroupLayer = wmsGroupLayer.CreateWMSGroupLayers(wmsLayerDesc);
                    newLayer         = (ILayer)newWmsGroupLayer;
                    if (newLayer == null)
                    {
                    }
                }

                // add newly created layer
                // wmsGroupLayer.InsertLayer(newLayer, 0);
            }

            // configure the layer before adding it to the map
            layer      = (ILayer)wmsGroupLayer;
            layer.Name = wmsServiceDesc.WMSTitle;

            // add to focus map
            map.AddLayer(layer);

            // add to the service list
            string strItem = EncodeServiceList(strServer, wmsServiceDesc.WMSTitle, strSecretName);

            //  m_pLogger.Msg "adding to service list : " & strItem
            colServiceList.Add(strItem);

            // set flag
            return(true);
        }
Esempio n. 34
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // 初始化RenderControl控件
            IPropertySet ps = new PropertySet();

            ps.SetProperty("RenderSystem", gviRenderSystem.gviRenderOpenGL);
            this.axRenderControl1.Initialize(true, ps);

            rootId = this.axRenderControl1.ObjectManager.GetProjectTree().RootID;
            this.axRenderControl1.Camera.FlyTime = 1;

            // 设置天空盒

            if (System.IO.Directory.Exists(strMediaPath))
            {
                string  tmpSkyboxPath = strMediaPath + @"\skybox";
                ISkyBox skybox        = this.axRenderControl1.ObjectManager.GetSkyBox(0);
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBack, tmpSkyboxPath + "\\1_BK.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageBottom, tmpSkyboxPath + "\\1_DN.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageFront, tmpSkyboxPath + "\\1_FR.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageLeft, tmpSkyboxPath + "\\1_LF.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageRight, tmpSkyboxPath + "\\1_RT.jpg");
                skybox.SetImagePath(gviSkyboxImageIndex.gviSkyboxImageTop, tmpSkyboxPath + "\\1_UP.jpg");
            }
            else
            {
                MessageBox.Show("请不要随意更改SDK目录名");
                return;
            }

            // 加载FDB场景
            try
            {
                IConnectionInfo ci = new ConnectionInfo();
                ci.ConnectionType = gviConnectionType.gviConnectionFireBird2x;
                string tmpFDBPath = (strMediaPath + @"\BIM.FDB");
                ci.Database = tmpFDBPath;
                IDataSourceFactory dsFactory = new DataSourceFactory();
                ds = dsFactory.OpenDataSource(ci);
                string[] setnames = (string[])ds.GetFeatureDatasetNames();
                if (setnames.Length == 0)
                {
                    return;
                }
                dataset = ds.OpenFeatureDataset(setnames[0]);   //此处把dataset作为全局对象,以便后面调用
                string[] fcnames = (string[])dataset.GetNamesByType(gviDataSetType.gviDataSetFeatureClassTable);
                if (fcnames.Length == 0)
                {
                    return;
                }
                fcMap = new Hashtable(fcnames.Length);
                foreach (string name in fcnames)
                {
                    IFeatureClass fc = dataset.OpenFeatureClass(name);
                    // 找到空间列字段
                    List <string> geoNames = new List <string>();
                    fieldinfos = fc.GetFields();
                    for (int i = 0; i < fieldinfos.Count; i++)
                    {
                        IFieldInfo fieldinfo = fieldinfos.Get(i);
                        if (null == fieldinfo)
                        {
                            continue;
                        }

                        //找出设置了域的字段
                        IDomain domain = fieldinfo.Domain;
                        if (domain != null)
                        {
                            if (!fieldNamesHasDomain.Contains(fieldinfo.Name))
                            {
                                fieldNamesHasDomain.Add(fieldinfo.Name);
                            }
                        }

                        IGeometryDef geometryDef = fieldinfo.GeometryDef;
                        if (null == geometryDef)
                        {
                            continue;
                        }
                        geoNames.Add(fieldinfo.Name);
                    }
                    fcMap.Add(fc, geoNames);
                }

                //设置可供选择的字段
                comboBoxDomains.DataSource = fieldNamesHasDomain.ToArray();
                if (fieldNamesHasDomain.Count > 0)
                {
                    comboBoxDomains.SelectedIndex = 0;
                }
                SetDomainTree();
            }
            catch (COMException ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
                return;
            }

            // CreateFeautureLayer
            bool hasfly = false;

            layerList = new List <IFeatureLayer>();
            foreach (IFeatureClass fc in fcMap.Keys)
            {
                List <string> geoNames = (List <string>)fcMap[fc];
                foreach (string geoName in geoNames)
                {
                    ISimpleGeometryRender georender = null;
                    if (comboBoxDomains.SelectedIndex >= 0 && fieldNamesHasDomain.Count > 0)
                    {
                        georender = new SimpleGeometryRender();
                        georender.RenderGroupField = fieldNamesHasDomain[comboBoxDomains.SelectedIndex];
                    }
                    IFeatureLayer featureLayer = this.axRenderControl1.ObjectManager.CreateFeatureLayer(fc, geoName, null, georender, rootId);
                    layerList.Add(featureLayer);

                    if (!hasfly)
                    {
                        IFieldInfoCollection fieldinfos  = fc.GetFields();
                        IFieldInfo           fieldinfo   = fieldinfos.Get(fieldinfos.IndexOf(geoName));
                        IGeometryDef         geometryDef = fieldinfo.GeometryDef;
                        IEnvelope            env         = geometryDef.Envelope;
                        if (env == null || (env.MaxX == 0.0 && env.MaxY == 0.0 && env.MaxZ == 0.0 &&
                                            env.MinX == 0.0 && env.MinY == 0.0 && env.MinZ == 0.0))
                        {
                            continue;
                        }
                        IEulerAngle angle = new EulerAngle();
                        angle.Set(0, -20, 0);
                        this.axRenderControl1.Camera.LookAt(env.Center, 1000, angle);
                    }
                    hasfly = true;
                }
            }

            //绑定事件
            this.comboBoxDomains.SelectedIndexChanged += new System.EventHandler(this.comboBoxDomains_SelectedIndexChanged);

            {
                this.helpProvider1.SetShowHelp(this.axRenderControl1, true);
                this.helpProvider1.SetHelpString(this.axRenderControl1, "");
                this.helpProvider1.HelpNamespace = "DomainTree.html";
            }
        }
Esempio n. 35
0
 internal void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
 {
     PropertySet?.Invoke(this, new PropertyChangedEventArgs(propertyName));
 }
Esempio n. 36
0
 public FakeApplicationDataContainer()
 {
     Values = new PropertySet();
 }
Esempio n. 37
0
        /// <summary>
        /// Updates the file with the user-edited properties. The m_imageProperties object
        /// is still usable after the method completes.
        /// </summary>
        private async void Apply_Click(object sender, RoutedEventArgs e)
        {
            rootPage.NotifyUser("Saving file...", NotifyType.StatusMessage);

            m_imageProperties.Title = TitleTextbox.Text;

            // Keywords are stored as an IList of strings.
            if (KeywordsTextbox.Text.Length > 0)
            {
                string[] keywordsArray = KeywordsTextbox.Text.Split('\n');
                m_imageProperties.Keywords.Clear();

                for (uint i = 0; i < keywordsArray.Length; i++)
                {
                    m_imageProperties.Keywords.Add(keywordsArray[i]);
                }
            }

            PropertySet propertiesToSave = new PropertySet();

            // Perform some simple validation of the GPS data and package it in a format
            // better suited for writing to the file.
            bool gpsWriteFailed = false;

            double[] latitude     = new double[3];
            double[] longitude    = new double[3];
            string   latitudeRef  = String.Empty;
            string   longitudeRef = String.Empty;

            try
            {
                latitude[0] = Math.Floor(Double.Parse(LatDegTextbox.Text));
                latitude[1] = Math.Floor(Double.Parse(LatMinTextbox.Text));
                latitude[2] = Double.Parse(LatSecTextbox.Text);

                longitude[0] = Math.Floor(Double.Parse(LongDegTextbox.Text));
                longitude[1] = Math.Floor(Double.Parse(LongMinTextbox.Text));
                longitude[2] = Double.Parse(LongSecTextbox.Text);

                latitudeRef  = LatRefTextbox.Text.ToUpper();
                longitudeRef = LongRefTextbox.Text.ToUpper();
            }
            catch (Exception) // Treat any exception as invalid GPS data.
            {
                gpsWriteFailed = true;
            }

            if ((latitude[0] >= 0 && latitude[0] <= 90) &&
                (latitude[1] >= 0 && latitude[1] <= 60) &&
                (latitude[2] >= 0 && latitude[2] <= 60) &&
                (latitudeRef == "N" || latitudeRef == "S") &&
                (longitude[0] >= 0 && longitude[0] <= 180) &&
                (latitude[1] >= 0 && longitude[1] <= 60) &&
                (longitude[2] >= 0 && longitude[2] <= 60) &&
                (longitudeRef == "E" || longitudeRef == "W"))
            {
                propertiesToSave.Add("System.GPS.LatitudeRef", latitudeRef);
                propertiesToSave.Add("System.GPS.LongitudeRef", longitudeRef);

                // The Latitude and Longitude properties are read-only. Instead,
                // write to System.GPS.LatitudeNumerator, LatitudeDenominator, etc.
                // These are length 3 arrays of integers. For simplicity, the
                // seconds data is rounded to the nearest 10000th.
                uint[] latitudeNumerator =
                {
                    (uint)latitude[0],
                    (uint)latitude[1],
                    (uint)(latitude[2] * 10000)
                };

                uint[] longitudeNumerator =
                {
                    (uint)longitude[0],
                    (uint)longitude[1],
                    (uint)(longitude[2] * 10000)
                };

                // LatitudeDenominator and LongitudeDenominator share the same values.
                uint[] denominator =
                {
                    1,
                    1,
                    10000
                };

                propertiesToSave.Add("System.GPS.LatitudeNumerator", latitudeNumerator);
                propertiesToSave.Add("System.GPS.LatitudeDenominator", denominator);
                propertiesToSave.Add("System.GPS.LongitudeNumerator", longitudeNumerator);
                propertiesToSave.Add("System.GPS.LongitudeDenominator", denominator);
            }
            else
            {
                gpsWriteFailed = true;
            }

            try
            {
                // SavePropertiesAsync commits edits to the top level properties (e.g. Title) as
                // well as any Windows properties contained within the propertiesToSave parameter.
                await m_imageProperties.SavePropertiesAsync(propertiesToSave);

                rootPage.NotifyUser(gpsWriteFailed ? "GPS data invalid; other properties successfully updated" :
                                    "All properties successfully updated", NotifyType.StatusMessage);
            }
            catch (Exception err)
            {
                switch (err.HResult)
                {
                case E_INVALIDARG:
                    // Some imaging formats, such as PNG and BMP, do not support Windows properties.
                    // Other formats do not support all Windows properties.
                    // For example, JPEG does not support System.FlagStatus.
                    rootPage.NotifyUser("Error: A property value is invalid, or the file format does " +
                                        "not support one or more requested properties.", NotifyType.ErrorMessage);

                    break;

                default:
                    rootPage.NotifyUser("Error: " + err.Message, NotifyType.ErrorMessage);
                    break;
                }

                ResetSessionState();
                ResetPersistedState();
            }
        }