public void DeleteSelected()
        {
            if (SelectedFolderViewModel == null)
            {
                return;
            }

            // TODO: DI directory, remove strong coupling
            var directory = new Directory();

            if (SelectedFolderViewModel.NodeType == NodeType.Folder)
            {
                directory.DeleteFolder(SelectedFolderViewModel.Folder);
                ViewList.Remove(SelectedFolderViewModel);
                MessengerInstance.Send(new DeleteFiles(), MessageToken.RefreshTree);
            }
            else
            {
                MessageBox.Show("File Delete Not Implemented Yet");
            }
        }
Esempio n. 2
0
        private void ProcessPacket()
        {
            var header = (PACKET_HEADER)PACKET_HEADER.Deserialize(data, typeof(PACKET_HEADER));

            this.RecvMessage = header.command.ToString();
            switch (header.command)
            {
            case PACKET_COMMAND.PACKET_SC_LOGIN_ACK:
            {
                var packet = (PKS_SC_LOGIN_ACK)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_LOGIN_ACK));
            }
            break;

            case PACKET_COMMAND.PACKET_SC_CHAT:
            {
                var packet = (PKS_SC_CHAT)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_CHAT));
                this.Chat = new string(packet.chat).Split('\0')[0];
                this.ChatCount++;
            }
            break;

            case PACKET_COMMAND.PACKET_SC_MOVE:
            {
                var packet = (PKS_SC_MOVE)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_MOVE));
                this.Position = packet.dest;
            }
            break;

            case PACKET_COMMAND.PACKET_SC_VIEW:
            {
                var packet = (PKS_SC_VIEW)PACKET_HEADER.Deserialize(data, typeof(PKS_SC_VIEW));
                lock (lockObject)
                {
                    if (ViewList == null)
                    {
                        break;
                    }
                    foreach (var view in ViewList)
                    {
                        view.IsUpdate = false;
                    }
                    var name = new string(packet.commanderID1).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest1.X;
                                view.PositionY = packet.dest1.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            var view = new ClientView(packet.dest1.X, packet.dest1.Y, name);
                            ViewList.Add(view);
                        }
                    }


                    name = new string(packet.commanderID2).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest2.X;
                                view.PositionY = packet.dest2.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest2.X, packet.dest2.Y, name));
                        }
                    }
                    name = new string(packet.commanderID3).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest3.X;
                                view.PositionY = packet.dest3.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest3.X, packet.dest3.Y, name));
                        }
                    }

                    name = new string(packet.commanderID4).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest4.X;
                                view.PositionY = packet.dest4.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest4.X, packet.dest4.Y, name));
                        }
                    }

                    name = new string(packet.commanderID5).Split('\0')[0];
                    if (name != "None")
                    {
                        bool isFind = false;
                        foreach (var view in ViewList)
                        {
                            if (view.Name == name)
                            {
                                view.PositionX = packet.dest5.X;
                                view.PositionY = packet.dest5.Y;
                                view.IsUpdate  = true;
                                isFind         = true;
                                break;
                            }
                        }
                        if (!isFind)
                        {
                            ViewList.Add(new ClientView(packet.dest5.X, packet.dest5.Y, name));
                        }
                    }
                    foreach (var view in ViewList.ToList())
                    {
                        if (!view.IsUpdate)
                        {
                            ViewList.Remove(view);
                        }
                    }
                }

                /*
                 *
                 * if (new string(packet.commanderID2).Split('\0')[0] == "")
                 * {
                 *  break;
                 * }
                 * clientViewList.Add(new ClientView(packet.dest2.X, packet.dest2.Y, new string(packet.commanderID2).Split('\0')[0]));
                 *
                 *
                 * if (new string(packet.commanderID3).Split('\0')[0] == "")
                 * {
                 *  break;
                 * }
                 * clientViewList.Add(new ClientView(packet.dest3.X, packet.dest3.Y, new string(packet.commanderID3).Split('\0')[0]));
                 */
            }
            break;

            default:
                this.Error = "wrong packet command";
                break;
            }
        }