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(); } } }
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(); } } }
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(); } } }
public void Restart(Entity entity) { MachineComponent machine = entity.Get <MachineComponent>(); machine.Restart(); }