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 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.º 3
0
        private void RouterEditWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Router
            ServerComponent server = _entity.Get <ServerComponent>();

            RouterName.Text = server.Name;
            Address.Text    = server.Address;
            Port.Text       = server.Port.ToString();
            Passphrase.Text = server.Passphrase;
            RouterName.Focus();
        }
Exemplo n.º 4
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.º 5
0
        private void ClientEditWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Client
            ClientComponent client = _entity.Get <ClientComponent>();

            ClientName.Text   = client.Name;
            DownloadPath.Text = client.Download;
            ClientName.Focus();

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

            GroupPath.Text = group.Path;
            SetGroup();

            // Options
            ClientOptionsComponent options = _entity.Get <ClientOptionsComponent>();

            MaxDownloads.Text = options.MaxDownloads.ToString();
            MaxUploads.Text   = options.MaxUploads.ToString();
        }
Exemplo n.º 6
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.º 7
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.º 8
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.º 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 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;
            }
        }