예제 #1
0
        private void ServerEditCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = Server.SelectedItem;

            ServerComponent    server = entity.Get <ServerComponent>();
            ServerOptionWindow wnd    = new ServerOptionWindow()
            {
                Title = server.Name, Owner = this
            };

            ServerOptionsComponent options = entity.Get <ServerOptionsComponent>();

            wnd.MaxTransfers.Text = options.MaxTransfers.ToString();
            wnd.MaxChunks.Text    = options.MaxChunks.ToString();
            wnd.ChunkSize.Text    = (options.ChunkSize >> 10).ToString();

            //wnd.Ping.IsChecked = options.Ping;
            //wnd.Info.IsChecked = options.Info;

            bool result = (bool)wnd.ShowDialog();

            if (result)
            {
                options.MaxTransfers = int.Parse(wnd.MaxTransfers.Text);
                options.MaxChunks    = int.Parse(wnd.MaxChunks.Text);
                options.ChunkSize    = int.Parse(wnd.ChunkSize.Text) << 10;

                //options.Ping = (bool) wnd.Ping.IsChecked;
                //options.Info = (bool) wnd.Info.IsChecked;
            }
        }
예제 #2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     DemonSaw.Entity.Entity entity = ClientController.Get();
     ClientListView.SelectedItem = entity;
     ClientController.Select(entity);
     MenuController.Select(entity);
 }
예제 #3
0
 private void DataGrid_Select(DataGridRow row)
 {
     // TODO: Add more tabs
     //
     if (ShareTab != null && ShareTab.IsSelected)
     {
         DemonSaw.Entity.Entity entity = (DemonSaw.Entity.Entity)row.Item;
         ClientController.Select(entity);
     }
 }
예제 #4
0
 private void DataGrid_Select(DataGridRow row)
 {
     // TODO: Add more tabs
     //
     if (ServerTab != null && ServerTab.IsSelected)
     {
         DemonSaw.Entity.Entity entity = (DemonSaw.Entity.Entity)row.Item;
         Server.Select(entity);
     }
 }
예제 #5
0
        private void ClientRemoveCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;

            if (entity != null)
            {
                GroupImage.Source = null;
                ClientController.Remove(entity);
                FileController.Clear();
            }
        }
예제 #6
0
        private void DownloadListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DemonSaw.Entity.Entity entity = DownloadController.SelectedItem;
            if (entity == null)
            {
                return;
            }

            FileComponent file = entity.Get <FileComponent>();

            FileUtil.Execute(file.Path);
        }
예제 #7
0
        private void RouterListView_Address_DropDownClosed(object sender, EventArgs e)
        {
            DemonSaw.Entity.Entity entity = RouterController.SelectedItem;
            if (entity == null)
            {
                return;
            }

            ComboBox        control = (ComboBox)sender;
            ServerComponent server  = entity.Get <ServerComponent>();

            if (!server.Address.Equals(control.SelectedItem))
            {
                server.Address = (string)control.SelectedItem;
                RouterController.Restart(entity);
            }
        }
예제 #8
0
        private void ClientEditCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;
            ClientEditWindow       wnd    = new ClientEditWindow(entity)
            {
                Owner = this
            };

            bool result = (bool)wnd.ShowDialog();

            if (result)
            {
                // Client
                ClientComponent client = entity.Get <ClientComponent>();
                client.Name     = wnd.ClientName.Text;
                client.Download = wnd.DownloadPath.Text;

                // Group
                GroupComponent group        = entity.Get <GroupComponent>();
                bool           groupChanged = (entity == MenuController.Entity) && !group.Path.Equals(wnd.GroupPath.Text);
                group.Path        = wnd.GroupPath.Text;
                GroupImage.Source = group.Image;

                // Options
                ClientOptionsComponent options = entity.Get <ClientOptionsComponent>();
                options.MaxDownloads = int.Parse(wnd.MaxDownloads.Text);
                options.MaxUploads   = int.Parse(wnd.MaxUploads.Text);

                // Machine
                MachineComponent machine = entity.Get <MachineComponent>();
                machine.Restart();

                // Controller
                MenuController.Update();

                if (groupChanged)
                {
                    SearchController.Clear();
                    BrowseController.Clear();
                }
            }
        }
예제 #9
0
        private void ClientListView_Enabled_CheckedChanged(object sender, RoutedEventArgs e)
        {
            DataGridRow row = WpfUtil.GetGridRow(e.OriginalSource);

            if (row != null)
            {
                DemonSaw.Entity.Entity entity = (DemonSaw.Entity.Entity)row.Item;

                if (entity != null)
                {
                    CheckBox        control = (CheckBox)sender;
                    bool            enabled = (bool)control.IsChecked;
                    ClientComponent client  = entity.Get <ClientComponent>();

                    if (client.Enabled != enabled)
                    {
                        ClientController.Toggle(entity);
                    }
                }
            }
        }
예제 #10
0
        private void FileAddCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;

            System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description = "Select the directory that you want to share.",
            };

            System.Windows.Forms.DialogResult result = dlg.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FileComponent file = new FileComponent(dlg.SelectedPath)
                {
                    Owner = entity
                };
                FileController.Add(file);
            }

            FileTreeView.UnselectAll();
        }
예제 #11
0
        private void ClientListView_GroupImageButton_Click(object sender, RoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;
            if (entity == null)
            {
                return;
            }

            // Group
            GroupComponent group = entity.Get <GroupComponent>();

            OpenFileDialog dlg = new OpenFileDialog()
            {
                Title       = "Browse For Group Image",
                FileName    = group.Path,
                Filter      = "BMP Files (*.bmp)|*.bmp|JPEG Files (*.jpeg)|*.jpeg|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|ICO Files (*.ico)|*.ico|PNG Files (*.png)|*.png|All files (*.*)|*.*",
                FilterIndex = 7
            };

            if (dlg.ShowDialog() == true)
            {
                // Group
                bool groupChanged = (entity == MenuController.Entity) && !group.Path.Equals(dlg.FileName);
                group.Path        = dlg.FileName;
                GroupImage.Source = group.Image;

                // Machine
                MachineComponent machine = entity.Get <MachineComponent>();
                machine.Restart();

                // Controllers
                if (groupChanged)
                {
                    SearchController.Clear();
                    BrowseController.Clear();
                }
            }
        }
예제 #12
0
        private void RouterEditCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;
            RouterEditWindow       wnd    = new RouterEditWindow(entity)
            {
                Owner = this
            };

            bool result = (bool)wnd.ShowDialog();

            if (result)
            {
                if (!NetworkUtil.IsPortValid(wnd.Port.Text))
                {
                    return;
                }

                // Router
                ServerComponent server      = entity.Get <ServerComponent>();
                bool            nameChanged = !server.Name.Equals(wnd.RouterName.Text);
                server.Name       = wnd.RouterName.Text;
                server.Address    = wnd.Address.Text;
                server.Port       = int.Parse(wnd.Port.Text);
                server.Passphrase = wnd.Passphrase.Text;

                // Machine
                MachineComponent machine = entity.Get <MachineComponent>();
                machine.Restart();

                // Controller
                MenuController.Update();

                if (nameChanged)
                {
                    BrowseController.Select();
                }
            }
        }
예제 #13
0
        private void ClientListView_DownloadPathButton_Click(object sender, RoutedEventArgs e)
        {
            DemonSaw.Entity.Entity entity = ClientController.SelectedItem;
            if (entity == null)
            {
                return;
            }

            // Client
            ClientComponent client = entity.Get <ClientComponent>();

            System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog()
            {
                Description  = "Select the directory that you want to use as the download location.",
                SelectedPath = client.Download
            };

            System.Windows.Forms.DialogResult result = dlg.ShowDialog();
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                client.Download = dlg.SelectedPath;
            }
        }
예제 #14
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     DemonSaw.Entity.Entity entity = Server.Get();
     ServerListView.SelectedItem = entity;
     Server.Select(entity);
 }
예제 #15
0
        public ClientEditWindow(DemonSaw.Entity.Entity entity)
        {
            _entity = entity;

            InitializeComponent();
        }