示例#1
0
        public MainWindow()
        {
            InitializeComponent();
            #region Initialize Popup-Windows
            tempConnect = new Connect(this);
            tempNewDirectory = new NewDirectory(this);
            tempRenameDirectory = new RenameDirectory(this);
            tempMoveDirectory = new MoveDirectory(this);
            tempAddUser = new Client.AddUser(this);
            tempEditUser = new Client.EditUser(this);
            tempViewUser = new Client.ViewUser(this);
            tempAddGroup = new Client.AddGroup(this);
            tempViewGroup = new Client.ViewGroup(this);
            tempViewPermissions = new Client.ViewPermissions(this);
            #endregion
            #region Initialize Lists of ribbonButtons

            filesItems = new Microsoft.Windows.Controls.Ribbon.RibbonMenuItem[17]
            {NewDirectory,Rename, Move,Delete,
            Upload, Download, _Rename,Copy,Paste,Details,_Delete,
            _AddUser,_EditUser,_ViewUser,
            _AddGroup,_EditGroup,_ViewGroup};

            accessItems = new Microsoft.Windows.Controls.Ribbon.RibbonMenuItem[6]
            {AddUser,EditUser,ViewUser,
            AddGroup,EditGroup,ViewGroup};

            helpItems = new Microsoft.Windows.Controls.Ribbon.RibbonMenuItem[0];

            aboutItems = new Microsoft.Windows.Controls.Ribbon.RibbonMenuItem[0];

            #endregion

            dockPanel.DataContext = directory;


        }
        static void Main(string[] args)
        {
            string server = "127.0.0.1";
            int port;
            Connect connect;
            Console.WriteLine("Hi! Choose server with \"1\" or \"2\":\n\t1. SMTP-server\n\t2. POP3-server");
            int choose = 0;
            try
            {
                choose = Convert.ToInt32(Console.ReadLine());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in: \n\n{0}", ex);
            }
            switch (choose)
            {
                case 2:
                    port = 110;//POP3
                    break;
                case 1:
                    port = 25;//SMTP
                    break;
                default:
                    Console.WriteLine("Incorrect value.\n\nExiting...");
                    return;
            }

            connect = new Connect(server, port);
            connect.HandShake();
            string s = "";
            while(true)
            {
                Console.Write("\\> ");
                s = Console.ReadLine();
                connect.sendToServer(s);
                if (s == "QUIT")
                {
                    Console.WriteLine("Press enter to exit . . .");
                    Console.ReadKey();
                    Environment.Exit(0);
                }
                if (s == "DATA")
                {
                    string text = "";
                    while (true)
                    {
                        Console.Write("\\> ");
                        s = Console.ReadLine();
                        if (s == ".")
                        {
                            break;
                        }
                        text += s + "\n";
                    }
                    connect.sendToServer(text);
                }
            }
        }