Exemplo n.º 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;
            }
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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();
                }
            }
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 14
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     DemonSaw.Entity.Entity entity = Server.Get();
     ServerListView.SelectedItem = entity;
     Server.Select(entity);
 }
Exemplo n.º 15
0
        public ClientEditWindow(DemonSaw.Entity.Entity entity)
        {
            _entity = entity;

            InitializeComponent();
        }