예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contactservice"></param>
        public mainviewmodel(icontactservice contactservice,
                             defaultviewmodel defaultviewmodel,
                             contactviewmodel contactviewmodel,
                             contactscollectionviewmodel contactcollectionviewmodel)
        {
            icon            = "/artifacts/images/logo.jpg";
            iconheight      = 100;
            iconwidth       = 100;
            _contactservice = contactservice;
            // a bit ugly way of hooking event handlers
            contactviewmodel.saved += (s, e) => { content = pages.Where(x => x.displayname.Equals("allcontacts")).First().refresh(); };
            contactcollectionviewmodel.editting += (s, e) =>
            {
                var contacollection = s as contactscollectionviewmodel;
                var contact         = pages.Single(x => x.displayname.Equals("new contact")) as contactviewmodel;

                if (contact != null && contacollection != null)
                {
                    contact.model = contacollection.current.model;
                    content       = contact;
                }
            };
            contactviewmodel.close           += close;
            contactcollectionviewmodel.close += close;
            content = defaultviewmodel;

            pages = new List <pageviewmodel>
            {
                defaultviewmodel,
                contactviewmodel,
                contactcollectionviewmodel
            };
        }
예제 #2
0
파일: main.cs 프로젝트: kulubaev/demo
        /// <summary>
        /// 
        /// </summary>
        /// <param name="contactservice"></param>
        public mainviewmodel(icontactservice contactservice,
            defaultviewmodel defaultviewmodel,
            contactviewmodel contactviewmodel,
            contactscollectionviewmodel contactcollectionviewmodel)
        {
            icon = "/artifacts/images/logo.jpg";
            iconheight = 100;
            iconwidth = 100;
            _contactservice = contactservice;
            // a bit ugly way of hooking event handlers
            contactviewmodel.saved += (s, e) => { content = pages.Where(x => x.displayname.Equals("allcontacts")).First().refresh(); };
            contactcollectionviewmodel.editting += (s, e) =>
                                                       {
                                                          var contacollection = s as contactscollectionviewmodel;
                                                          var contact = pages.Single(x => x.displayname.Equals("new contact")) as contactviewmodel;

                                                          if(contact != null && contacollection != null)
                                                          {
                                                              contact.model = contacollection.current.model;
                                                              content = contact;
                                                          }

                                                       };
            contactviewmodel.close +=close;
            contactcollectionviewmodel.close += close;
            content = defaultviewmodel;

            pages = new List<pageviewmodel>
                        {

                            defaultviewmodel,
                            contactviewmodel,
                            contactcollectionviewmodel

                        };
        }