Inheritance: Caliburn.Micro.PropertyChangedBase
Exemplo n.º 1
0
 public void CreateGroup()
 {
     if (!CanCreateGroup) return;
     var ng = new csGroup {Name = NewGroupName.Trim()};
     AppState.Imb.CreateGroupAndJoin(ng);
     //AppState.Imb.JoinGroup(ng);
     NewGroupName = string.Empty;
     SelectedTab = 0;
 }
Exemplo n.º 2
0
        private void ProcessImbVariableGroup(string aVarName, string value) {
            var groupName = aVarName.Split('.')[0];

            var group = groups.FirstOrDefault(k => Equals(k.Name, groupName)); // Equals made static.

            if (string.IsNullOrEmpty(value)) {
                if (CanDeleteGroup(group)) {
                    Groups.Remove(group);
                    Execute.OnUIThread(() => {
                        
                        AppState.TriggerNotification(group.Name + " has been deleted", pathData: MenuHelpers.GroupIcon);
                    });
                    // First call OnClientRemoved before you remove the client. Otherwise you will generate an exception.
                }
            }
            else {
                if (group != null) {
                    group.FromString(value); // Update group info
                }
                else {
                    // Create group
                    var st = new csGroup {Name = groupName};
                    st.FromString(value);
                    Groups.Add(st);
                    var s = string.Format("Created group '{0}'{1}",
                        groupName, (st.OwnerClient != null ? 
                        string.Format(" owned by client '{0}'", (st.OwnerClient.Name ?? "-")) : string.Empty));
                    Execute.OnUIThread(() => AppState.TriggerNotification(s, pathData: MenuHelpers.GroupIcon));
                }
            }
        }
Exemplo n.º 3
0
 internal void DeleteGroup(csGroup group) {
     if (!CanDeleteGroup(group)) return;
     Execute.OnUIThread(() =>
     {
         Groups.Remove(@group);
         Imb.SetVariableValue(@group.Name + ".group", "");
         AppState.TriggerNotification(@group.Name + " has been deleted", pathData: MenuHelpers.GroupIcon);
     });            
 }
Exemplo n.º 4
0
 /// <summary>
 /// Only the owner can delete a group.
 /// </summary>
 /// <param name="group"></param>
 /// <returns></returns>
 public bool CanDeleteGroup(csGroup group) {
     return group != null
            && Groups.Contains(@group)
            && AppState.Imb != null
            && AppState.Imb.Imb != null
            && AppState.Imb.Imb.ClientHandle == group.Owner;
 }
Exemplo n.º 5
0
 public void LeaveGroup(csGroup g, bool pRemoveActiveGroup = true)
 {
     if (g == null) return;
     if (g.IsMemberOfGroup)
     {
         g.StopImb();
         if (pRemoveActiveGroup) ActiveGroup = null;
         LogCs.LogMessage(String.Format("Left IMB group '{0}'", g.Name));
         AppState.TriggerNotification("You left " + g.Name, pathData: MenuHelpers.GroupIcon);
     };      
 }
Exemplo n.º 6
0
 public void JoinGroup(csGroup ng) {
     if (ng == null) return;
     if ((ActiveGroup != null) && (ActiveGroup.Name == ng.Name)) return; // Already member of group
     foreach (var g in Groups.Where(k => k.IsMemberOfGroup && k.Name != ng.Name)) 
     {
         LeaveGroup(g, false);
     }
     ActiveGroup = ng;
     if (!ng.IsMemberOfGroup)
     {
         ng.InitImb();
         LogCs.LogMessage("Joined IMB group '{0}'", ng.Name);
         AppState.TriggerNotification("You joined " + ng.Name, pathData: MenuHelpers.GroupIcon);
     }
 }
Exemplo n.º 7
0
 public void CreateGroupAndJoin(csGroup group)
 {
     if (Imb == null) return;
     Status.Id = Imb.ClientHandle;
     if (group.Owner == 0) {
         group.Owner = AppState.Imb.Imb.ClientHandle;
         group.OwnerClient = AppState.Imb.Status;
     }
     Groups.Add(group);
     group.UpdateGroup();
     JoinGroup(group);
 }