Example #1
0
        private void EditPass_Clicked(object?sender, EventArgs e)
        {
            var passwd = GtkHelper.GetSelectedValue <PasswordEntry?>(this.LvPasswords, 2);

            if (passwd.HasValue)
            {
                using var dlg = PasswordDialog.CreateFromGladeFile(this, this.group);
                dlg.SetPassword(passwd.Value);
                dlg.Run();
                dlg.Destroy();
                if (dlg.Result)
                {
                    var password = new PasswordEntry
                    {
                        Host     = dlg.Host,
                        User     = dlg.UserName,
                        Password = dlg.Password
                    };
                    if (LvPasswords.Selection.GetSelected(out var iter))
                    {
                        passwordStore.SetValues(iter, password.Host, password.User, password);
                    }
                }
            }
        }
Example #2
0
        private void CatEdit_Clicked(object?sender, EventArgs e)
        {
            var cat = GtkHelper.GetSelectedValue <Category?>(this.LvCategories, 3);

            if (cat.HasValue)
            {
                using var dlg = CategoryEditDialog.CreateFromGladeFile(this, this.group);
                dlg.SetCategory(cat.Value);
                dlg.Run();
                dlg.Destroy();
                if (dlg.Result)
                {
                    var cat1 = new Category
                    {
                        Name           = cat.Value.Name,
                        DisplayName    = dlg.DisplayName !,
                        DefaultFolder  = dlg.Folder !,
                        FileExtensions = new HashSet <string>(dlg.FileTypes !.Replace("\r\n", "")
                                                              .Split(',').Select(x => x.Trim()).Where(x => x.Length > 0))
                    };
                    if (LvCategories.Selection.GetSelected(out var iter))
                    {
                        categoryStore.SetValues(iter, cat1.DisplayName, string.Join(",", cat1.FileExtensions), cat1.DefaultFolder, cat1);
                    }
                }
            }
        }
Example #3
0
        private void BtnStart_Clicked(object?sender, EventArgs e)
        {
            SaveQueues();
            var queue = GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1);

            QueueStartRequested?.Invoke(this, new DownloadListEventArgs(queue.DownloadIds));
        }
Example #4
0
 private void BtnMoveTo_Clicked(object?sender, EventArgs e)
 {
     if (this.filesListStore.IterNChildren() > 0 &&
         this.queueListStore.IterNChildren() > 1 &&
         LbQueues.Selection.CountSelectedRows() > 0)
     {
         var qsd          = QueueSelectionDialog.CreateFromGladeFile(this, this.group);
         var queueNames   = new List <string>();
         var queueIds     = new List <string>();
         var selectedItem = GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1);
         var index        = 0;
         foreach (DownloadQueue item in GtkHelper.GetListStoreValues <DownloadQueue>(queueListStore, 1))
         {
             if (item != selectedItem)
             {
                 queueNames.Add(item.Name);
                 queueIds.Add(item.ID);
             }
             index++;
         }
         var downloadIds = new string[this.lvFiles.Selection.CountSelectedRows()];
         index = 0;
         foreach (InProgressDownloadItem lvi in GtkHelper.GetSelectedValues <InProgressDownloadItem>(lvFiles, 3))
         {
             downloadIds[index++] = lvi.Id;
         }
         qsd.SetData(queueNames, queueIds, downloadIds);
         qsd.QueueSelected += Qsd_QueueSelected;
         qsd.Run();
         qsd.Destroy();
         qsd.Dispose();
     }
 }
Example #5
0
        private void Qsd_QueueSelected(object?sender, QueueSelectionEventArgs e)
        {
            var qid           = e.SelectedQueueId;
            var queue         = GtkHelper.GetListStoreValues <DownloadQueue>(queueListStore, 1).Find(x => x.ID == qid);// GtkHelper.GetValueAt<DownloadQueue>(LbQueues, e.SelectedQueueIndex, 1);
            var downloadIds   = e.DownloadIds;
            var selectedQueue = GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1);

            foreach (var id in downloadIds)
            {
                selectedQueue.DownloadIds.Remove(id);
                queue.DownloadIds.Add(id);
            }
            LoadQueueDetails(selectedQueue);
        }
Example #6
0
        private void BtnAdd_Clicked(object?sender, EventArgs e)
        {
            var index = GtkHelper.GetSelectedIndex(LbQueues);

            if (index < 0)
            {
                return;
            }

            var dlg = NewQueueDialog.CreateFromGladeFile(this, this.group, (queue, newQueue) =>
            {
                LoadQueueDetails(queue);
            }, GtkHelper.GetSelectedValue <DownloadQueue>(this.LbQueues, 1));

            dlg.Run();
            dlg.Destroy();
            dlg.Dispose();
        }
Example #7
0
        public void RefreshView()
        {
            if (GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1) is DownloadQueue queue)
            {
                filesListStore.Clear();
                var realQueue = QueueManager.GetQueue(queue.ID);

                if (realQueue != null)
                {
                    foreach (var id in realQueue.DownloadIds)
                    {
                        var ent = ApplicationContext.Application.GetInProgressDownloadEntry(id);
                        if (ent != null)
                        {
                            filesListStore.AppendValues(ent.Name, FormattingHelper.FormatSize(ent.Size), ent.Status.ToString(), ent);
                        }
                    }
                }
            }
        }
Example #8
0
        private void BtnRemove_Clicked(object?sender, EventArgs e)
        {
            var selectedQueue = GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1);

            if (selectedQueue == null)
            {
                return;
            }
            var selectedIds = new List <string>();

            foreach (var item in GtkHelper.GetSelectedValues <InProgressDownloadItem>(lvFiles, 3))
            {
                if (item != null)
                {
                    selectedIds.Add(item.Id);
                }
            }
            foreach (var id in selectedIds)
            {
                selectedQueue.DownloadIds.Remove(id);
            }
            LoadQueueDetails(selectedQueue);
        }
Example #9
0
        private QueueSchedulerDialog(Builder builder, Window parent, WindowGroup group) : base(builder.GetRawOwnedObject("dialog"))
        {
            builder.Autoconnect(this);
            Modal = true;
            SetPosition(WindowPosition.CenterAlways);
            TransientFor = parent;
            this.group   = group;
            this.group.AddWindow(this);

            GtkHelper.AttachSafeDispose(this);
            Title = TextResource.GetText("DESC_Q_TITLE");
            SetDefaultSize(700, 500);
            LoadTexts();
            queueListStore = new ListStore(typeof(string), typeof(DownloadQueue));
            LbQueues.Model = queueListStore;

            var queueNameRendererText = new CellRendererText();
            var queueNameColumn       = new TreeViewColumn("", queueNameRendererText, "text", 0)
            {
                Resizable   = false,
                Reorderable = false,
                Sizing      = TreeViewColumnSizing.Autosize,
                Expand      = true
            };

            LbQueues.HeadersVisible = false;
            LbQueues.AppendColumn(queueNameColumn);
            queueScroll.SetSizeRequest(150, 100);

            filesListStore = new ListStore(typeof(string), typeof(string), typeof(string), typeof(InProgressDownloadItem));
            lvFiles.Model  = filesListStore;

            var k = 0;

            foreach (var key in new string[] { "ND_FILE", "SORT_SIZE", "SORT_STATUS" })
            {
                var cellRendererText = new CellRendererText();
                var treeViewColumn   = new TreeViewColumn(TextResource.GetText(key), cellRendererText, "text", k++)
                {
                    Resizable   = true,
                    Reorderable = false,
                    Sizing      = TreeViewColumnSizing.Fixed,
                    FixedWidth  = 150
                };
                lvFiles.AppendColumn(treeViewColumn);
            }

            this.SchedulerPanel = new SchedulerPanelControl(
                chkEveryday,
                new CheckButton[] { chkSun, chkMon, chkTue, chkWed, chkThu, chkFri, chkSat },
                new TimePickerControl(CmbHour1, CmbMinute1, CmbAmPm1, LblQueueStart),
                new TimePickerControl(CmbHour2, CmbMinute2, CmbAmPm2, LblQueueStop)
                );

            this.SchedulerPanel.Schedule = defaultSchedule;

            this.SchedulerPanel.ValueChanged += (_, _) =>
            {
                DownloadSchedule?schedule = null;
                if (ChkEnableScheduler.Active)
                {
                    schedule = this.SchedulerPanel.Schedule;
                }
                if (GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1) is DownloadQueue queue)
                {
                    queue.Schedule = schedule;
                }
            };

            this.LbQueues.Selection.Changed += (_, _) =>
            {
                var selected = GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1);
                if (selected != null)
                {
                    UpdateControls(selected);
                }
            };

            this.lvFiles.Selection.Changed += (_, _) => ListSelectionChanged();

            this.ChkEnableScheduler.Toggled += (_, _) =>
            {
                SchedulerPanel.Enabled = this.ChkEnableScheduler.Active;
                if (GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1) is DownloadQueue queue)
                {
                    queue.Schedule = this.ChkEnableScheduler.Active ? this.SchedulerPanel.Schedule : null;
                }
            };

            Hidden            += QueueSchedulerDialog_Hidden;
            BtnNew.Clicked    += BtnNew_Clicked;
            BtnStart.Clicked  += BtnStart_Clicked;
            BtnStop.Clicked   += BtnStop_Clicked;
            BtnDel.Clicked    += BtnDel_Clicked;
            BtnCancel.Clicked += BtnCancel_Clicked;
            BtnAdd.Clicked    += BtnAdd_Clicked;
            BtnRemove.Clicked += BtnRemove_Clicked;
            BtnUp.Clicked     += BtnUp_Clicked;
            BtnDown.Clicked   += BtnDown_Clicked;
            BtnMoveTo.Clicked += BtnMoveTo_Clicked;
            BtnSave.Clicked   += BtnSave_Clicked;

            lvFiles.Selection.Mode = SelectionMode.Multiple;

            SchedulerPanel.Enabled = false;
        }