Inheritance: BaseViewModel
Example #1
0
    public UserViewModel(User info, RoomViewModel roomViewModel)
      : base(false)
    {
      Info = info;
      RoomViewModel = roomViewModel;

      SetRoomAdminCommand = new Command(SetRoomAdmin, Obj => ClientModel.Client != null);
      UserClickCommand = new Command(UserClick);
    }
Example #2
0
        public MessageViewModel(DateTime messageTime, string senderNick, FileId fileId, RoomViewModel roomVm)
            : this(Room.SpecificMessageId, roomVm, true)
        {
            this.fileId = fileId;

              Sender = new UserViewModel(senderNick, parentRoom);
              Progress = 0;

              var localMessageTime = messageTime.ToLocalTime();
              Title = Localizer.Instance.Localize(FromKey, localMessageTime.ToString(TimeFormat));

              var sizeDim = string.Empty;
              var size = 0L;

              using (var client = ClientModel.Get())
              {
            var file = GetFile(client, fileId);

            if (file.Size < 1024)
            {
              sizeDim = Localizer.Instance.Localize(ByteStrKey);
              size = file.Size;
            }

            if (file.Size >= 1024 && file.Size < 1024 * 1024)
            {
              sizeDim = Localizer.Instance.Localize(KByteStrKey);
              size = file.Size / 1024;
            }

            if (file.Size >= 1024 * 1024)
            {
              sizeDim = Localizer.Instance.Localize(MByteStrKey);
              size = file.Size / (1024 * 1024);
            }

            Text = file.Name + string.Format(SizeFormat, size, sizeDim);
              }

              Type = MessageType.File;
              DownloadFileCommand = new Command(DownloadFile, _ => ClientModel.Api != null);

              NotifierContext.DownloadProgress += CreateSubscriber<FileDownloadEventArgs>(ClientDownloadProgress);
              NotifierContext.PostedFileDeleted += CreateSubscriber<FileDownloadEventArgs>(ClientPostedFileDeleted);
        }
Example #3
0
        public UserViewModel(string nickLKey, UserId userId, RoomViewModel parentViewModel)
            : base(parentViewModel, true)
        {
            _userId = userId;
            _parent = parentViewModel;

            using (var client = ClientModel.Get())
            {
                _checkStatus = GetCheckStatus(client);
                _isClient    = GetClientStatus(client);
                _nickColor   = GetColor(client);
            }

            UserClickCommand         = new Command(UserClick);
            SetRoomAdminCommand      = new Command(SetRoomAdmin, _ => ClientModel.Api != null);
            OpenCertificateCommand   = new Command(OpenCertificate, _ => ClientModel.Api != null);
            SaveCertificateCommand   = new Command(SaveCertificate, _ => ClientModel.Api != null);
            RemoveCertificateCommand = new Command(RemoveCertificate, _ => ClientModel.Api != null);

            Events.TrustedCertificatesChanged += CreateSubscriber <TrustedCertificatesEventArgs>(TrustedCertificatesChanged);

            Localizer.Instance.LocaleChanged += RefreshNick;
        }
Example #4
0
    public MessageViewModel(UserViewModel sender, string fileName, FileDescription fileDescription, RoomViewModel room)
      : this(Room.SpecificMessageId, room, true)
    {
      NotifierContext.DownloadProgress += ClientDownloadProgress;
      NotifierContext.PostedFileDeleted += ClientPostedFileDeleted;

      Sender = sender;
      File = fileDescription;
      Progress = 0;
      Title = string.Format(From, DateTime.Now.ToString(TimeFormat));

      string sizeDim = string.Empty;
      float size = 0;

      if (fileDescription.Size < 1024)
      {
        sizeDim = ByteStr;
        size = fileDescription.Size;
      }

      if (fileDescription.Size >= 1024 && fileDescription.Size < 1024 * 1024)
      {
        sizeDim = KByteStr;
        size = fileDescription.Size / 1024.0f;
      }

      if (fileDescription.Size >= 1024 * 1024)
      {
        sizeDim = MByteStr;
        size = fileDescription.Size / (1024.0f * 1024.0f);
      }
      
      Text = fileName + string.Format(SizeFormat, size, sizeDim);
      Type = MessageType.File;
      DownloadFileCommand = new Command(DownloadFile, Obj => ClientModel.Client != null);
    }
Example #5
0
 private MessageViewModel(long messageId, RoomViewModel room, bool initializeNotifier)
     : base(room, initializeNotifier)
 {
     MessageId  = messageId;
     parentRoom = room;
 }
Example #6
0
        public MessageViewModel(long messageId, DateTime messageTime, string senderNick, string receiverNick, string message, bool isPrivate, RoomViewModel room)
            : this(messageId, room, false)
        {
            Text     = message;
            Sender   = new UserViewModel(senderNick, room);
            Receiver = new UserViewModel(receiverNick, room);
            Type     = isPrivate ? MessageType.Private : MessageType.Common;

            EditMessageCommand = new Command(EditMessage, _ => ClientModel.Client != null);

            var localMessageTime = messageTime.ToLocalTime();

            Title = Localizer.Instance.Localize(isPrivate ? PMFormKey : FromKey, localMessageTime.ToString(TimeFormat));
        }
Example #7
0
        public MessageViewModel(long messageId, DateTime messageTime, string senderNick, string receiverNick, string message, bool isPrivate, RoomViewModel room)
            : this(messageId, room, false)
        {
            Text = message;
              Sender = new UserViewModel(senderNick, room);
              Receiver = new UserViewModel(receiverNick, room);
              Type = isPrivate ? MessageType.Private : MessageType.Common;

              EditMessageCommand = new Command(EditMessage, _ => ClientModel.Client != null);

              var localMessageTime = messageTime.ToLocalTime();
              Title = Localizer.Instance.Localize(isPrivate ? PMFormKey : FromKey, localMessageTime.ToString(TimeFormat));
        }
Example #8
0
 public UserViewModel(UserId userId, RoomViewModel parentViewModel)
     : this(null, userId, parentViewModel)
 {
 }
Example #9
0
 public MessageViewModel(string systemMessage, RoomViewModel room)
   : this(Room.SpecificMessageId, room, false)
 {
   Text = systemMessage;
   Type = MessageType.System;
 }
Example #10
0
    public MessageViewModel(long messageId, UserViewModel sender, UserViewModel receiver, string message, bool isPrivate, RoomViewModel room)
      : this(messageId, room, false)
    {
      Text = message;
      Sender = sender;
      Receiver = receiver;
      Type = isPrivate ? MessageType.Private : MessageType.Common;

      EditMessageCommand = new Command(EditMessage, Obj => ClientModel.Client != null);

      Title = string.Format(isPrivate ? PMForm : From, DateTime.Now.ToString(TimeFormat));
    }
Example #11
0
    private void ClientRoomOpened(object sender, RoomEventArgs e)
    {
      Dispatcher.BeginInvoke(new Action<RoomEventArgs>(args =>
      {
        if (Rooms.FirstOrDefault(roomVM => roomVM.Name == args.Room.Name) != null)
          return;

        RoomViewModel roomViewModel = new RoomViewModel(this, args.Room, args.Users);
        roomViewModel.Updated = true;
        Rooms.Add(roomViewModel);

        window.Alert();
      }), e);
    }
Example #12
0
 public UserViewModel(User info, RoomViewModel parentViewModel)
     : this(null, info, parentViewModel)
 {
 }
Example #13
0
        public MessageViewModel(UserViewModel sender, string fileName, FileDescription fileDescription, RoomViewModel room)
            : this(Room.SpecificMessageId, room, true)
        {
            NotifierContext.DownloadProgress  += ClientDownloadProgress;
            NotifierContext.PostedFileDeleted += ClientPostedFileDeleted;

            Sender   = sender;
            File     = fileDescription;
            Progress = 0;
            Title    = string.Format(From, DateTime.Now.ToString(TimeFormat));

            string sizeDim = string.Empty;
            float  size    = 0;

            if (fileDescription.Size < 1024)
            {
                sizeDim = ByteStr;
                size    = fileDescription.Size;
            }

            if (fileDescription.Size >= 1024 && fileDescription.Size < 1024 * 1024)
            {
                sizeDim = KByteStr;
                size    = fileDescription.Size / 1024.0f;
            }

            if (fileDescription.Size >= 1024 * 1024)
            {
                sizeDim = MByteStr;
                size    = fileDescription.Size / (1024.0f * 1024.0f);
            }

            Text = fileName + string.Format(SizeFormat, size, sizeDim);
            Type = MessageType.File;
            DownloadFileCommand = new Command(DownloadFile, Obj => ClientModel.Client != null);
        }
Example #14
0
        public MessageViewModel(long messageId, UserViewModel sender, UserViewModel receiver, string message, bool isPrivate, RoomViewModel room)
            : this(messageId, room, false)
        {
            Text     = message;
            Sender   = sender;
            Receiver = receiver;
            Type     = isPrivate ? MessageType.Private : MessageType.Common;

            EditMessageCommand = new Command(EditMessage, Obj => ClientModel.Client != null);

            Title = string.Format(isPrivate ? PMForm : From, DateTime.Now.ToString(TimeFormat));
        }
Example #15
0
 public MessageViewModel(string systemMessage, RoomViewModel room)
     : this(Room.SpecificMessageId, room, false)
 {
     Text = systemMessage;
     Type = MessageType.System;
 }
Example #16
0
        public MessageViewModel(DateTime messageTime, string senderNick, FileId fileId, RoomViewModel roomVm)
            : this(Room.SpecificMessageId, roomVm, true)
        {
            this.fileId = fileId;

            Sender   = new UserViewModel(senderNick, parentRoom);
            Progress = 0;

            var localMessageTime = messageTime.ToLocalTime();

            Title = Localizer.Instance.Localize(FromKey, localMessageTime.ToString(TimeFormat));

            var sizeDim = string.Empty;
            var size    = 0L;

            using (var client = ClientModel.Get())
            {
                var file = GetFile(client, fileId);

                if (file.Size < 1024)
                {
                    sizeDim = Localizer.Instance.Localize(ByteStrKey);
                    size    = file.Size;
                }

                if (file.Size >= 1024 && file.Size < 1024 * 1024)
                {
                    sizeDim = Localizer.Instance.Localize(KByteStrKey);
                    size    = file.Size / 1024;
                }

                if (file.Size >= 1024 * 1024)
                {
                    sizeDim = Localizer.Instance.Localize(MByteStrKey);
                    size    = file.Size / (1024 * 1024);
                }

                Text = file.Name + string.Format(SizeFormat, size, sizeDim);
            }

            Type = MessageType.File;
            DownloadFileCommand = new Command(DownloadFile, _ => ClientModel.Api != null);

            Events.DownloadProgress  += CreateSubscriber <FileDownloadEventArgs>(ClientDownloadProgress);
            Events.PostedFileDeleted += CreateSubscriber <FileDownloadEventArgs>(ClientPostedFileDeleted);
        }
        public MessageViewModel(long messageId, DateTime messageTime, UserId senderId, UserId receiverId, string message, bool isPrivate, RoomViewModel room)
            : this(messageId, room, false)
        {
            Text     = message;
            Title    = Localizer.Instance.Localize(isPrivate ? PMFormKey : FromKey, GetTimeStr(messageTime));
            Sender   = new LightUserViewModel(senderId, room);
            Receiver = new LightUserViewModel(receiverId, room);
            Type     = isPrivate ? MessageType.Private : MessageType.Common;

            EditMessageCommand = new Command(EditMessage, _ => ClientModel.Client != null);
        }
Example #18
0
 private MessageViewModel(long messageId, RoomViewModel room, bool initializeNotifier)
   : base(initializeNotifier)
 {
   MessageId = messageId;
   roomViewModel = room;
   time = DateTime.Now;
 }
Example #19
0
        private void ClientRoomOpened(RoomEventArgs e)
        {
            // If room view model already exist then event will be processed by it self
              if (Rooms.Any(vm => vm.Name == e.RoomName))
            return;

              // Else create new view model
              var roomViewModel = new RoomViewModel(this, e.RoomName, e.Users);
              roomViewModel.Updated = true;
              Rooms.Add(roomViewModel);

              window.Alert();
        }
Example #20
0
 private MessageViewModel(long messageId, RoomViewModel room, bool initializeNotifier)
     : base(room, initializeNotifier)
 {
     MessageId = messageId;
       parentRoom = room;
 }
Example #21
0
 public UserViewModel(string userNick, RoomViewModel parentViewModel)
     : this(null, userNick, parentViewModel)
 {
 }