Beispiel #1
0
        public static void Show(Station.Neighbor withNeighbor, ChatClient chatClient, bool active = false)
        {
            ThreadUtils.RunOnUiAndWait(() =>
            {
                var chatWindow = GetShowingWindow(withNeighbor);
                if (chatWindow == null)
                {
                    chatWindow = new ChatWindow {
                        Owner = Application.Current.MainWindow
                    };
                    var vm = chatClient != null
                        ? new ChatViewModel(chatClient, withNeighbor)
                        : new ChatViewModel(withNeighbor);
                    chatWindow.DataContext = vm;
                    chatWindow.Closed     += ChatWindow_Closed;
                    chatWindow.Show();
                    _showingWindows.Add(vm, chatWindow);
                }
                else if (chatClient != null && chatWindow.DataContext is ChatViewModel vm)
                {
                    vm.SetChatClient(chatClient);
                }

                if (active)
                {
                    chatWindow.Activate();
                }
            });
        }
Beispiel #2
0
 public SendingViewModel(Station.Neighbor neighbor, IEnumerable <SendFileModel> sendingFiles)
 {
     _neighbor     = neighbor;
     _sendingFiles = sendingFiles.ToList();
     _thread       = new ThreadWrapper
     {
         DoWork  = SendFiles,
         OnError = OnErrorWhileSendingFiles,
         OnExit  = OnFinishSendingFiles
     };
 }
Beispiel #3
0
        private static ChatWindow GetShowingWindow(Station.Neighbor withNeighbor)
        {
            foreach (var pair in _showingWindows)
            {
                if (pair.Key.Neighbor.Address == withNeighbor.Address)
                {
                    return(pair.Value);
                }
            }

            return(null);
        }
Beispiel #4
0
        public NeighborMenuItemViewModel(MainViewModel mainViewModel, Station.Neighbor neighbor)
        {
            _mainViewModel = mainViewModel;
            _neighbor      = neighbor;

            MenuItems = new List <SubMenuItem> {
                new SubMenuItem
                {
                    Header  = "Send Files",
                    Command = new RelayCommand(HandleSendFiles),
                    Icon    = ImageUtils.ImageSourceFromBitmap(Resources.send_file)
                }, new SubMenuItem
                {
                    Header  = "Chat",
                    Command = new RelayCommand(HandleSendMessage),
                    Icon    = ImageUtils.ImageSourceFromBitmap(Resources.chat)
                }, new SubMenuItem
                {
                    Header  = "Terminal",
                    Command = new RelayCommand(HandleTerminal),
                    Icon    = ImageUtils.ImageSourceFromBitmap(Resources.terminal)
                }
            };
        }
Beispiel #5
0
 public SendAttachmentMessage(string[] files, Station.Neighbor to)
 {
     To    = to;
     Files = files;
 }
Beispiel #6
0
 public ChatViewModel(ChatClient chatClient, Station.Neighbor neighbor)
 {
     SetChatClient(chatClient ?? new ChatClient(neighbor.Address, Constants.ChatPort));
     Neighbor = neighbor;
     Title    = Neighbor.Name;
 }
Beispiel #7
0
 public ChatViewModel(Station.Neighbor neighbor)
     : this(null, neighbor)
 {
 }