예제 #1
0
        internal void SaveGroup(GroupView group)
        {
            foreach (var permission in group.AssignedPermissions)
            {
                foreach (var permissionType in permission.Value)
                {
                    permissionType.PermissionType = string.Format("menu:{0}", permissionType.PermissionType);
                }
            }
            HttpWebResponse response;
            HttpWebRequest  request;

            if (group.IsNew)
            {
                request = GetServiceRequest("groups", "POST");
            }
            else
            {
                request = GetServiceRequest(string.Format("users/{0}", group.ID), "PUT");
            }
            string body = Serialize(group.GetGroup());

            request.ContentLength = body.Length;
            SetBody(ref request, body);
            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException ex)
            {
                throw ex;
            }
        }
        //end Edit
        public override void UpdateView(Webb.Reports.ExControls.Views.ExControlView i_View)
        {
            if (this.C_GroupInfoTree.Nodes.Count <= 0)
            {
                return;
            }

            GroupInfo m_GroupInfo = this.C_GroupInfoTree.Nodes[0].Tag as GroupInfo;

            this.UpdateView(m_GroupInfo, this.C_GroupInfoTree.Nodes[0]);

            GroupView m_GroupView = i_View as GroupView;

            //begin Edit @simon
            this.UpdateColumnsWidth(m_GroupView);
            //end Edit

            m_GroupView.HaveHeader = this.C_CheckHeader.Checked;

            GroupInfo m_RootGroupInfo = this.C_GroupInfoTree.Nodes[0].Tag as GroupInfo;

            if (m_GroupView.RootGroupInfo is SectionGroupInfo)
            {
                m_GroupView.RootGroupInfo.SubGroupInfos.Clear();

                m_GroupView.RootGroupInfo.SubGroupInfos.Add(m_RootGroupInfo);
            }
            else
            {
                m_GroupView.RootGroupInfo = m_RootGroupInfo;
            }
        }
        public Control view()
        {
            Control v = new GroupView();

            v.DataContext = this;
            return(v);
        }
        public IActionResult Edit(int id, GroupView updatedGroup)
        {
            if (id != updatedGroup.group.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var rmp = _context.PeopleGroups.Where(eo => eo.GroupId == id);
                _context.RemoveRange(rmp);
                _context.SaveChanges();

                // Add locations, attendees and owners
                if (updatedGroup.SelectedPeople != null)
                {
                    foreach (var peopleId in updatedGroup.SelectedPeople)
                    {
                        _context.PeopleGroups.Add(new PeopleGroup
                        {
                            GroupId  = updatedGroup.group.Id,
                            PeopleId = peopleId
                        });
                    }
                }

                _context.Groups.Update(updatedGroup.group);
                _context.SaveChanges();

                return(RedirectToAction("Index", nameof(People)));
            }

            return(View(updatedGroup));
        }
예제 #5
0
        public GetPermissionsResponse GetPermissions(Guid GroupID)
        {
            GetPermissionsResponse response = new GetPermissionsResponse();

            GroupView groupView = new GroupView();

            groupView = _groupRepository.FindBy(GroupID).ConvertToGroupView();

            try
            {
                IEnumerable <PermissionView> permissions = _permissionRepository.FindAll()
                                                           .ConvertToPermissionViews();

                response.PermissionViews = permissions;
                foreach (PermissionView permissionView in response.PermissionViews)
                {
                    bool guaranteed = (from p in groupView.Permissions
                                       where p.PermitKey == permissionView.Key
                                       select p.Guaranteed).FirstOrDefault();
                    // بخاطر اینکه بصورت آجاکسی بتوان ویرایش کرد ناچاریم آیدی گروه را به جای آیدی پرمیشن جا بزنیم
                    permissionView.ID         = groupView.ID;
                    permissionView.Guaranteed = guaranteed;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }
예제 #6
0
        public ActionResult Attend(int id = 0)
        {
            if (id == 0 || !Permission.LoginedNeed(Request, Response, Session))
            {
                return(null);
            }

            Exam exam = ExamView.GetExamById(id);

            if (exam == null || DateTime.Now < exam.start_date || DateTime.Now > exam.end_date)
            {
                Permission.BackToPrevPageOrIndex(Request, Response);
                return(null);
            }

            User             user       = (User)Session["user"];
            List <int>       userGroups = GroupView.GetGroupMemberByUID(user.uid).Select(gm => (int)gm.gid).ToList();
            IQueryable <int> examGroups = ExamView.GetAllGroupsByExam(exam.eid).Select(e => e.gid);
            List <int>       gids       = userGroups.Intersect(examGroups).ToList();

            if ((exam._public == false && gids.Count() == 0) || ResultView.GetResult(id, user.uid) != null)
            {
                Permission.BackToPrevPageOrIndex(Request, Response);
                return(null);
            }

            ViewBag.exam      = exam;
            ViewBag.questions = FileOperation.ReadFile(exam.exam_path);

            return(View());
        }
예제 #7
0
        public static ExControlStyles GetStyle(WebbReport webbReport)
        {
            ExControlStyles excontrolStyle = new ExControlStyles();

            Band band = webbReport.Bands[BandKind.Detail];

            foreach (XRControl xrControl in band.Controls)
            {
                if (!(xrControl is WinControlContainer))
                {
                    continue;
                }

                Control c = (xrControl as WinControlContainer).WinControl;

                if (c is GridControl)
                {
                    GridView gridView = (c as GridControl).GridView;

                    excontrolStyle.ApplyStyle(gridView.Styles);

                    return(excontrolStyle);
                }
                else if (c is GroupingControl)
                {
                    GroupView groupView = (c as GroupingControl)._GroupView;

                    excontrolStyle.ApplyStyle(groupView.Styles);

                    return(excontrolStyle);
                }
            }
            return(excontrolStyle);
        }
예제 #8
0
        public ActionResult Groups()
        {
            var groups             = Kcsar.Membership.RoleProvider.GetRoles().OrderBy(x => x.Name);
            List <GroupView> model = new List <GroupView>();

            Guid[] owners       = groups.SelectMany(f => f.Owners).Distinct().ToArray();
            var    ownerDetails = (owners.Length > 0) ? this.db.Members.Where(GetSelectorPredicate <Member>(owners)).ToDictionary(f => f.Id, f => f) : new Dictionary <Guid, Member>();

            foreach (var group in groups)
            {
                GroupView view = new GroupView {
                    Name = group.Name, EmailAddress = group.EmailAddress, Destinations = group.Destinations.ToArray()
                };
                List <MemberSummaryRow> ownersView = new List <MemberSummaryRow>();
                foreach (Guid owner in group.Owners)
                {
                    Member m = ownerDetails[owner];
                    ownersView.Add(new MemberSummaryRow
                    {
                        Name = m.FullName,
                        Id   = owner
                    });
                }
                view.Owners = ownersView.ToArray();
                model.Add(view);
            }
            ViewData["IsAdmin"] = User.IsInRole("site.accounts");
            ViewData["UserId"]  = Permissions.UserId;


            return(View(model));
        }
 private void grvDeviceTypes_GroupViewItemDoubleClick(GroupView sender, GroupViewItemDoubleClickEventArgs e)
 {
     btnApply.Enabled   = true;
     SelectedDeviceType = grvDeviceTypes.GroupViewItems[grvDeviceTypes.SelectedItem].Text;
     this.DialogResult  = DialogResult.OK;
     this.Close();
 }
예제 #10
0
        public ActionResult Remove(GroupView model)
        {
            var memberToDelete = model.Members.Where(x => x.IsDeleted).FirstOrDefault();

            var group  = db.Groups.Find(model.Id);
            var person = db.People.Find(memberToDelete.Id);

            ModelState.Remove("SectedPersonIdToAdd");
            if (ModelState.IsValid)
            {
                group.Persons.Remove(person);
                db.SaveChanges();
            }

            var members = group.Persons.Select(x =>
                                               new GroupMemberRow()
            {
                Id        = x.Id,
                FirstName = x.FirstName,
                LastName  = x.LastName
            }).ToList();

            model.Members = members;
            ModelState.Clear();
            return(PartialView("_GroupMember", model));
        }
예제 #11
0
        public GetGeneralResponse <IEnumerable <PermissionView> > GetPermissions(Guid GroupID, int pageSize, int pageNumber)
        {
            //GetPermissionsResponse response = new GetPermissionsResponse();
            GetGeneralResponse <IEnumerable <PermissionView> > response = new GetGeneralResponse <IEnumerable <PermissionView> >();
            GroupView groupView = new GroupView();

            groupView = _groupRepository.FindBy(GroupID).ConvertToGroupView();

            try
            {
                int index = (pageNumber - 1) * pageSize;
                int count = pageSize;

                Response <Permission> permissions = _permissionRepository.FindAll(index, count);
                response.data = permissions.data.ConvertToPermissionViews();


                foreach (PermissionView permissionView in response.data)
                {
                    bool guaranteed = (from p in groupView.Permissions
                                       where p.PermitKey == permissionView.Key
                                       select p.Guaranteed).FirstOrDefault();
                    // بخاطر اینکه بصورت آجاکسی بتوان ویرایش کرد ناچاریم آیدی گروه را به جای آیدی پرمیشن جا بزنیم
                    permissionView.ID         = groupView.ID;
                    permissionView.Guaranteed = guaranteed;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(response);
        }
예제 #12
0
        public void TestCellSelectorOnStudentsList()
        {
            //Navigating to Students Page

            TopMenu topMenuInstance = new TopMenu(driver);
            Actions builder         = new Actions(driver);

            builder.MoveToElement(topMenuInstance.TopMenuSection).Build().Perform();
            Acts.Click(topMenuInstance.StudentsItem);


            //Select group from LeftContainer

            mainPageClassInstance = new MainPageClass(driver);

            Acts.Click(mainPageClassInstance.LeftContainer.GroupsInLocation.GetGroupByName("DP-094-MQC"));

            //Go to table

            GroupView groupViewInstance = new GroupView(driver);

            groupViewInstance.EditButton.Click();

            //Select some cell using method CellSelector

            EditStudentList editStudentListInstance = new EditStudentList(driver);
            string          text = editStudentListInstance
                                   .StudentTable
                                   .GetCellBy2Keys("English level", "Reaper Carolina")
                                   .Text;

            Console.WriteLine(text);
        }
예제 #13
0
        public override void SetView(Webb.Reports.ExControls.Views.ExControlView i_View)
        {
            this.C_GroupInfoTree.Nodes.Clear();

            GroupView m_GroupView = i_View as GroupView;

            SetColumnsWidth(m_GroupView);

            this.C_CheckHeader.Checked = m_GroupView.HaveHeader;

            GroupInfo m_GroupInfo = null;

            if (m_GroupView.RootGroupInfo is SectionGroupInfo)
            {
                if (m_GroupView.RootGroupInfo.SubGroupInfos.Count > 0)
                {
                    m_GroupInfo = m_GroupView.RootGroupInfo.SubGroupInfos[0];
                }
            }
            else
            {
                m_GroupInfo = m_GroupView.RootGroupInfo;
            }

            this.SetView(m_GroupInfo, null);
        }
예제 #14
0
        public static R GetView <T, R>(this T entity)
            where T : class, IEntity
            where R : class, IEntity
        {
            switch (entity)
            {
            case Student student:
            {
                var result = new StudentView
                {
                    Id         = student.Id,
                    FirstName  = student.FirstName,
                    LastName   = student.LastName,
                    MiddleName = student.MiddleName
                };
                return((R)(object)result);
            }

            case Group group:
            {
                var result = new GroupView
                {
                    Id       = group.Id,
                    Photo    = group.Photo,
                    Name     = group.Name,
                    Students = group.Students.Count()
                };
                return((R)(object)result);
            }
            }

            return(null);
        }
예제 #15
0
        //Added By Zafari
        // برگرداند دسترسی های یک گروه
        public JsonResult Permissions_Test(Guid GroupID, int?pageSize, int?pageNumber)
        {
            GetGeneralResponse <IEnumerable <Permit> > response = new GetGeneralResponse <IEnumerable <Permit> >();

            #region Check Access
            bool hasPermission = GetEmployee().IsGuaranteed("GroupPermission_Read");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(Json(response, JsonRequestBehavior.AllowGet));
            }
            #endregion

            int PageSize   = pageSize == null ? -1 : (int)pageSize;
            int PageNumber = pageNumber == null ? -1 : (int)pageNumber;

            int index = (PageNumber - 1) * PageSize;
            int count = PageSize;

            GroupView groupView = _groupService.GetGroup(new GetRequest()
            {
                ID = GroupID
            }).GroupView;

            response.data       = count != -1 ? groupView.Permissions.Skip(index).Take(count) : groupView.Permissions;
            response.totalCount = groupView.Permissions.Count();

            //.GroupBy(g => g.Permission.Group)
            return(Json(response.data, JsonRequestBehavior.AllowGet));
        }
예제 #16
0
        internal void SaveGroup(GroupView group)
        {
            HttpWebResponse response;
            HttpWebRequest  request;

            if (group.IsNew)
            {
                request = GetServiceRequest("groups", "POST");
            }
            else
            {
                request = GetServiceRequest(string.Format("users/{0}", group.ID), "PUT");
            }


            string body = Serialize(group.GetGroup());

            request.ContentLength = body.Length;
            SetBody(ref request, body);


            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException ex)
            {
                throw ex;
            }
        }
예제 #17
0
        public async Task <ActionResult> EditGroup(GroupView view)
        {
            if (ModelState.IsValid)
            {
                var pic    = view.Logo;
                var folder = "~/Content/Groups";

                if (view.LogoFile != null)
                {
                    pic = FilesHelper.UploadPhoto(view.LogoFile, folder);
                    pic = string.Format("{0}/{1}", folder, pic);
                }

                var group = ToGroup(view);
                group.Logo            = pic;
                db.Entry(group).State = EntityState.Modified;
                var response = await DBHelper.SaveChangesAsync(db);

                if (response.Succeeded)
                {
                    return(RedirectToAction(string.Format("Details/{0}", view.OwnerId)));
                }

                ModelState.AddModelError(string.Empty, response.Message);
            }

            return(View(view));
        }
        // Retrieves the number of highlights given the group ID and filtering params
        public static void GetNumberOfHighlights(GroupView groupView, GetNumberOfHighlightsCallbackDelegate callback)
        {
            if (!instanceCreated)
            {
                Debug.LogError("ERROR: Cannot get number of highlights. The SDK has not been initialized.");
                return;
            }

            GroupViewInternal spi = new GroupViewInternal();

            spi.groupId            = groupView.GroupId;
            spi.significanceFilter = (int)groupView.SignificanceFilter;
            spi.tagFilter          = (int)groupView.TagFilter;

            IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(spi));

            GetNumberOfHighlightsCallbackId cid = new GetNumberOfHighlightsCallbackId();

            cid.id       = GetCallbackId();
            cid.callback = callback;

            IntPtr pntid = Marshal.AllocHGlobal(Marshal.SizeOf(cid));

            try
            {
                Marshal.StructureToPtr(spi, pnt, false);
                Marshal.StructureToPtr(cid, pntid, false);
                Highlights_GetNumberOfHighlightsAsync(pnt, pntid);
            }
            finally
            {
                Marshal.FreeHGlobal(pnt);
                Marshal.FreeHGlobal(pntid);
            }
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var @group = await _context.Groups.SingleOrDefaultAsync(m => m.Id == id);

            if (@group == null)
            {
                return(NotFound());
            }

            var gv = new GroupView();

            gv.group          = @group;
            gv.SelectedPeople = _context.PeopleGroups
                                .Where(g => g.GroupId == id)
                                .Select(g => g.PeopleId)
                                .ToList();
            gv.People     = _context.People.ToList();
            gv.PeopleList = new SelectList(_context.People.Where(g => g.Id != id), "Id", "TypedDisplayName");

            return(View(gv));
        }
예제 #20
0
        public JsonResult Add()
        {
            if (!Permission.LoginedNeed(Request, Response, Session))
            {
                return(Json(false));
            }

            User   user     = (User)Session["user"];
            int    gid      = Convert.ToInt32(Request["gid"]);
            string username = Request["username"];

            GroupMember memberInfo = GroupView.GetGroupMember(user.uid, gid);

            if (memberInfo == null || memberInfo.rank < (int)MemberRank.ADMINISTRATOR)
            {
                return(Json(false));
            }

            User newMember = UserView.GetUserByUsername(username);

            if (newMember == null)
            {
                return(Json(false));
            }

            GroupMember newMemberInfo = new GroupMember
            {
                uid  = newMember.uid,
                gid  = gid,
                rank = 0
            };

            return(Json(GroupView.AddMember(gid, newMemberInfo)));
        }
예제 #21
0
        public JsonResult Join()
        {
            if (!Permission.LoginedNeed(Request, Response, Session))
            {
                return(Json(false));
            }

            User  user  = (User)Session["user"];
            int   gid   = Convert.ToInt32(Request["gid"]);
            Group group = GroupView.GetGroupById(gid);

            if (group == null || group.allow_join == false)
            {
                Json(false);
            }
            if (GroupView.GetGroupMember(user.uid, gid) != null)
            {
                return(Json(false));
            }
            GroupMember member = new GroupMember
            {
                uid  = user.uid,
                gid  = gid,
                rank = (int)MemberRank.MEMBER
            };

            return(Json(GroupView.AddMember(gid, member)));
        }
예제 #22
0
        // GET: Group
        public ActionResult Index(int id = 1)
        {
            if (!Permission.LoginedNeed(Request, Response, Session))
            {
                return(null);
            }

            IOrderedQueryable <Group> groups = null;

            if (groupsCache != null)
            {
                groups = groupsCache;
            }
            else
            {
                groups      = GroupView.GetAllGroups();
                groupsCache = groups;
            }

            int totalPageNumber = pager.GetPageNumber(groups);

            if (id > totalPageNumber || id < 1)
            {
                id = 1;
            }
            ViewBag.totalPageNumber = totalPageNumber;
            ViewBag.groups          = pager.GetPage(groups, id);
            ViewBag.page            = id;
            ViewBag.user            = (User)Session["user"];

            return(View());
        }
예제 #23
0
        public ActionResult Add(GroupView model)
        {
            var ownerId = Operator().OwnerGroupId;

            var group  = db.Groups.Find(model.Id);
            var person = db.People.Find(new Guid(model.SectedPersonIdToAdd));

            if (ModelState.IsValid)
            {
                group.Persons.Add(person);
                db.SaveChanges();
            }

            var members = group.Persons.Select(x =>
                                               new GroupMemberRow()
            {
                Id        = x.Id,
                FirstName = x.FirstName,
                LastName  = x.LastName
            }
                                               ).ToList();



            model.Members = members;


            ModelState.Clear();
            return(PartialView("_GroupMember", model));
        }
예제 #24
0
        private void RefreshVisibleRails(int gid)
        {
            GroupView gv = m_groupViews[gid];
            RailGroup rg;

            lock (m_tree)
            {
                rg = m_tree.Groups[gv.GroupId];
            }

            Dictionary <int, bool> railVis = new Dictionary <int, bool>();

            foreach (int railId in gv.VisibleRailIds)
            {
                railVis[railId] = true;
            }

            gv.VisibleRailIds.Clear();
            foreach (int railId in gv.RailIds)
            {
                if (railVis.ContainsKey(railId))
                {
                    gv.VisibleRailIds.Add(railId);
                }
            }
        }
예제 #25
0
        public void TestNewCellSelectorOnStudentsList()
        {
            //Navigating to Students Page

            TopMenu topMenuInstance = new TopMenu(driver);
            Actions builder         = new Actions(driver);

            builder.MoveToElement(topMenuInstance.TopMenuSection).Build().Perform();
            Acts.Click(topMenuInstance.StudentsItem);


            //Select group from LeftContainer

            mainPageClassInstance = new MainPageClass(driver);

            Acts.Click(mainPageClassInstance.LeftContainer.GroupsInLocation.GetGroupByName("DP-094-MQC"));

            //Go to table

            GroupView groupViewInstance = new GroupView(driver);

            groupViewInstance.EditButton.Click();

            //Select some cell using method CellSelector
            EditStudentList editStudentListInstance = new EditStudentList(driver);
            IWebElement     tableElement            = editStudentListInstance.StudentTable;
            Table           table = new Table(tableElement, driver);
            String          text1 = table.getValueFromCell(2, 2);
            String          text2 = table.getValueFromCell(2, "Name");

            Console.WriteLine(text1);
            Console.WriteLine(text2);
        }
예제 #26
0
        //begin Edit @simon 08/19/2008
        #region Edit Set  and Update ColumnsWidth
        private void SetColumnsWidth(GroupView i_View)
        {
            if (i_View == null)
            {
                return;
            }
            if (i_View.ColumnsWidth == null || i_View.ColumnsWidth.Count <= 0)
            {
                return;
            }
            if (i_View.PrintingTable != null)
            {
                int ColumnsCount = i_View.PrintingTable.GetColumns();
                i_View.ColumnsWidth.Clear();
                Int32Collection ColumnsWidthCopy = new Int32Collection();
                for (int i = 0; i < ColumnsCount; i++)
                {
                    i_View.ColumnsWidth.Add(i_View.PrintingTable.GetColumnWidth(i));
                }
            }
            int nCol = 0;

            if (i_View.ShowRowIndicators)
            {
                nCol++;
            }
            GroupInfo m_GroupInfo = i_View.RootGroupInfo;

            this.SetColumnsWidth(m_GroupInfo, ref nCol, i_View.ColumnsWidth);
        }
        public AddGroupViewModel(GroupView groupView)
        {
            using (var repo = new Repository())
            {
                Corpuses        = new List <Corpus>(repo.GetAll <Corpus>());
                Spezialisations = new List <Spezialisation>(repo.GetAll <Spezialisation>());

                Budgets = new List <string>()
                {
                    "Бюджет", "Вне бюджет"
                };

                Budget = Budgets[0];

                if (groupView == null)
                {
                    Group = new Group();
                    Group.DateEntrance = DateTime.Now;
                    Spezialisation     = Spezialisations[0];
                    Corpus             = Corpuses[0];
                }
                else
                {
                    _isToUpdate    = true;
                    Group          = repo.Get <Group>(groupView.Id);
                    Spezialisation = Group.Spezialisation;
                    Corpus         = Group.Corpus;
                }
            }


            AcceptCommand = new RelayCommand(Accept);
        }
예제 #28
0
        public static R GetViewById <T, R>(this IEnumerable <T> sequence, int id)
            where T : class, IEntity
            where R : class, IEntity
        {
            switch (sequence)
            {
            case IEnumerable <Student> students:
            {
                var student = students.FirstOrDefault(s => s.Id == id);
                var result  = new StudentView
                {
                    Id         = student.Id,
                    FirstName  = student.FirstName,
                    LastName   = student.LastName,
                    MiddleName = student.MiddleName
                };
                return((R)(object)result);
            }

            case IEnumerable <Group> groups:
            {
                var group  = groups.FirstOrDefault(s => s.Id == id);
                var result = new GroupView
                {
                    Id       = group.Id,
                    Photo    = group.Photo,
                    Name     = group.Name,
                    Students = group.Students.Count()
                };
                return((R)(object)result);
            }
            }

            return(null);
        }
예제 #29
0
        public JsonResult SubmitChange()
        {
            if (!Permission.LoginedNeed(Request, Response, Session))
            {
                return(Json(false));
            }
            User user = (User)Session["user"];
            int  gid  = Convert.ToInt32(Request["gid"]);
            int  uid  = Convert.ToInt32(Request["uid"]);
            int  rank = Convert.ToInt32(Request["rank"]);

            GroupMember opInfo     = GroupView.GetGroupMember(user.uid, gid);
            GroupMember memberInfo = GroupView.GetGroupMember(uid, gid);

            if (opInfo == null || memberInfo == null ||
                rank >= 3 || rank < 0 ||
                opInfo.rank < (int)MemberRank.ADMINISTRATOR ||
                memberInfo.rank == (int)MemberRank.CREATOR)
            {
                return(Json(false));
            }

            memberInfo.rank = rank;

            return(Json(GroupView.SaveGroupMember(memberInfo)));
        }
예제 #30
0
 public void UpdateUI()
 {
     _ = Dispatcher.RunAsync
             (Windows.UI.Core.CoreDispatcherPriority.Normal,
             new Windows.UI.Core.DispatchedHandler(() =>
     {
         FriendView.UpdateList();
         GroupView.UpdateList();
     }));
 }
예제 #31
0
        protected override void DrawText(Graphics gph, int nindex, Rectangle rc, GroupView.ItemState state)
        {
            if (((rc.Width > 0) && (rc.Height > 0)) && ((nindex >= 0) && (nindex < this.VisibleItems.Count)))
            {
                GroupViewItem item = (GroupViewItem)this.VisibleItems[nindex];
                if (nindex != this.nRenameItem)
                {
                    if (this.bTextWrap && this.bSmallImageView)
                    {
                        rc.Y += this.nImageSpacing;
                        rc.Height -= this.nImageSpacing;
                    }
                    Matrix transform = gph.Transform;
                    if (item.Enabled && base.Enabled)
                    {
                        Brush brush;
                        FontStyle style = this._markedBoldItems.Contains(item)
                            ? FontStyle.Bold
                            : ((nindex == this.nHighlightedItem) && this.bTextUnderline) 
                                    ? FontStyle.Underline 
                                    : this.Font.Style;
                        Font font = FontUtil.CreateFont(this.Font, style);
                        if ((nindex == this.nHighlightedItem) && (nindex == this.nSelectedItem))
                        {
                            if (state == ItemState.Selecting)
                            {
                                brush = new SolidBrush(this.clrSelectingText);
                            }
                            else
                            {
                                brush = new SolidBrush(this.clrSelectedHighlightText);
                            }
                        }
                        else if (nindex == this.nSelectedItem)
                        {
                            brush = new SolidBrush(this.clrSelectedText);
                        }
                        else if (nindex == this.nHighlightedItem)
                        {
                            brush = new SolidBrush(this.clrHighlightText);
                        }
                        else
                        {
                            brush = new SolidBrush(this.ForeColor);
                        }
                        bool? isOnline;
                        if (_markedItems.TryGetValue(item, out isOnline))
                        {
                            brush = isOnline.HasValue ? (isOnline.Value ? new SolidBrush(Color.Green) : new SolidBrush(Color.Red)) : brush;
                        }
                        //if (this._markedItems.Contains(item))
                        //{
                        //    brush = new SolidBrush(Color.Red);
                        //}
                        StringFormat format = new StringFormat(StringFormatFlags.LineLimit);
                        if (this.ctrlToolTip.Visible && (nindex == this.nHighlightedItem))
                        {
                            format.Alignment = StringAlignment.Near;
                            format.FormatFlags |= StringFormatFlags.NoWrap;
                            format.Trimming = StringTrimming.None;
                            format.LineAlignment = StringAlignment.Center;
                        }
                        else
                        {
                            if (this.bSmallImageView)
                            {
                                format.Alignment = StringAlignment.Near;
                                gph.MeasureString(item.Text, font);
                            }
                            else
                            {
                                format.Alignment = StringAlignment.Center;
                            }
                            if (!this.bTextWrap)
                            {
                                format.Trimming = StringTrimming.EllipsisCharacter;
                                format.FormatFlags |= StringFormatFlags.NoWrap;
                                format.LineAlignment = StringAlignment.Center;
                            }
                            else
                            {
                                format.Trimming = StringTrimming.EllipsisWord;
                            }
                        }
                        if (this.GetIsMirrored())
                        {
                            format.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                        }
                        gph.TextRenderingHint = TextRenderingHint.SystemDefault;
                        gph.DrawString(item.Text, font, brush, rc, format);
                        font.Dispose();
                        format.Dispose();
                    }
                    else
                    {
                        StringFormat format2 = new StringFormat(StringFormatFlags.LineLimit);
                        format2.Trimming = StringTrimming.EllipsisWord;
                        if (this.bSmallImageView)
                        {
                            format2.Alignment = StringAlignment.Near;
                        }
                        else
                        {
                            format2.Alignment = StringAlignment.Center;
                        }
                        if (!this.bTextWrap)
                        {
                            format2.FormatFlags |= StringFormatFlags.NoWrap;
                            format2.LineAlignment = StringAlignment.Center;
                        }
                        if (this.GetIsMirrored())
                        {
                            format2.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
                        }
                        ControlPaint.DrawStringDisabled(gph, item.Text, this.Font, SystemColors.Control, rc, format2);
                        format2.Dispose();
                    }
                    gph.Transform = transform;
                }
            }

        }
 public  Control view()
 {
     Control v = new GroupView();
     v.DataContext = this;
     return v;
 }