private PasswordDialog(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); Label1.Text = TextResource.GetText("DESC_HOST"); Label2.Text = TextResource.GetText("DESC_USER"); Label3.Text = TextResource.GetText("DESC_PASS"); BtnOk.Clicked += BtnOk_Clicked; BtnCancel.Clicked += BtnCancel_Clicked; BtnOk.Label = TextResource.GetText("MSG_OK"); BtnCancel.Label = TextResource.GetText("ND_CANCEL"); Title = TextResource.GetText("DESC_PASS"); SetDefaultSize(400, 300); }
public AdvancedDownloadDialog(Builder builder, Window parent, WindowGroup group) : base(builder.GetRawOwnedObject("dialog"))// base(TextResource.GetText("DESC_ADV_TITLE"), parent, DialogFlags.Modal) { SetDefaultSize(550, 450); builder.Autoconnect(this); Title = TextResource.GetText("DESC_ADV_TITLE"); Modal = true; SetPosition(WindowPosition.CenterAlways); TransientFor = parent; this.group = group; this.group.AddWindow(this); GtkHelper.PopulateComboBox(CmbProxyType !, TextResource.GetText("NET_SYSTEM_PROXY"), TextResource.GetText("ND_NO_PROXY"), TextResource.GetText("ND_MANUAL_PROXY")); GtkHelper.ConfigurePasswordField(TxtPassword); GtkHelper.ConfigurePasswordField(TxtProxyPassword); TxtSpeedLimit !.Text = "0"; CmbProxyType !.Changed += CmbProxyType_Changed; btnOk.Clicked += BtnOK_Click; btnCancel.Clicked += BtnCancel_Click; LoadTexts(); GtkHelper.AttachSafeDispose(this); }
private QueueSelectionDialog(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("Q_MOVE_TO"); SetDefaultSize(400, 300); LoadTexts(); listStore = new ListStore(typeof(string)); LbQueues.Model = listStore; 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); BtnCancel.Clicked += BtnCancel_Clicked; BtnOK.Clicked += BtnOK_Clicked; }
private void BtnOk_Clicked(object?sender, EventArgs e) { Result = true; if (string.IsNullOrEmpty(TxtName.Text)) { GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_CAT_NAME_MISSING")); return; } if (string.IsNullOrEmpty(TxtFileTypes.Text)) { GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_CAT_FILE_TYPES_MISSING")); return; } if (string.IsNullOrEmpty(TxtFolder.Text)) { GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_CAT_FOLDER_MISSING")); return; } this.DisplayName = this.TxtName.Text; this.FileTypes = this.TxtFileTypes.Text; this.Folder = this.TxtFolder.Text; Result = true; this.group.RemoveWindow(this); Dispose(); }
protected override bool OnSave() { // Mutable values string currTypString = GtkHelper.ComboBoxActiveString(cbTyp); origDbText = API_Contract.ConvertEditCategorieToDatabse(textEntry.Buffer); // Save on Database int currRang = int.Parse((string)currTreeStore.GetValue(currTreeIter, (int)CategorieColumnID.Rang)); DatabaseTable origElem, newElem; if (IsCurrParent) { int currTyp = API_Contract.CategorieTextParentTypCR[currTypString]; origElem = new Table_Kategorie_Tab_Titel(tabName, origDbText, origTyp, origRang); newElem = new Table_Kategorie_Tab_Titel(tabName, origDbText, currTyp, currRang); } else { int currTyp = API_Contract.CategorieTextChildTypCR[currTypString]; string tmpTitel = (string)currTreeStore.GetValue(currParentIter, (int)CategorieColumnID.Text); origElem = new Table_Kategorie_Tab_Text(tabName, tmpTitel, this.origDbText, origTyp, origRang); newElem = new Table_Kategorie_Tab_Text(tabName, tmpTitel, origDbText, currTyp, currRang); } origElem.Update(newElem); // Save on UI currTreeStore.SetValue(currTreeIter, (int)CategorieColumnID.Text, origDbText); currTreeStore.SetValue(currTreeIter, (int)CategorieColumnID.Typ, currTypString); // Save on this origTyp = cbTyp.Active; origText = textEntry.Buffer.Text; return(true); }
private bool OnApproved() { if (string.IsNullOrEmpty(TxtQueueName.Text)) { GtkHelper.ShowMessageBox(this, TextResource.GetText("MSG_QUEUE_NAME_MISSING")); return(false); } var list2 = new List <string>(this.listStore.IterNChildren()); var list = GtkHelper.GetListStoreValues <EntryWrapper>(this.listStore, 5); foreach (var entry in list) { if (entry.Selected) { list2.Add(entry.Entry.Id); } } if (modifyingQueue == null) { okAction.Invoke(new DownloadQueue(Guid.NewGuid().ToString(), TxtQueueName.Text) { DownloadIds = list2 }, true); } else { modifyingQueue.DownloadIds.AddRange(list2); okAction.Invoke(modifyingQueue, false); } return(true); }
private void ParsePaymentRegistry() { ViewModel.ProgressTitle = ViewModel.ParsingProgress; ViewModel.IsParsingData = true; GtkHelper.WaitRedraw(); ViewModel.ParsePaymentRegistryCommand.Execute(); }
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); } } } }
private void CheckTableVeranstaltung() { bool year, lang; var query = conn.Table <Table_Veranstaltung>(); foreach (var entry in query) { year = entry.Jahr >= 2017; lang = GtkHelper.FindInArray(API_Contract.SupportedLanguages, entry.Sprache) != -1; if (!year || !lang) { var invalid = new InvalidStruct(entry); if (!year) { invalid.errors.Add("JAHR"); } if (!lang) { invalid.errors.Add("SPRACHE"); } invalidEntrys.Add(invalid); } // Add pks EventPKs.Add(entry.Id); } }
public static bool DeleteObject(Type objectClass, int id, IUnitOfWork uow = null, System.Action beforeDeletion = null) { try { //Здесь так все криво, просто чтобы сделать независимую реализация чисто для совместимости со старым кодом. var builder = new ContainerBuilder(); IContainer container = null; builder.Register((ctx) => new AutofacViewModelsGtkPageFactory(container)).As <IViewModelsPageFactory>(); builder.RegisterType <GtkWindowsNavigationManager>().AsSelf().As <INavigationManager>().SingleInstance(); builder.RegisterType <DeleteEntityGUIService>().AsSelf(); builder.Register(x => DeleteConfig.Main).AsSelf(); builder.RegisterType <GtkMessageDialogsInteractive>().As <IInteractiveMessage>(); builder.RegisterType <GtkQuestionDialogsInteractive>().As <IInteractiveQuestion>(); builder.RegisterModule(new DeletionAutofacModule()); builder.Register(ctx => new ClassNamesBaseGtkViewResolver(Assembly.GetAssembly(typeof(DeletionView)))).As <IGtkViewResolver>(); container = builder.Build(); var deleteSerive = container.Resolve <DeleteEntityGUIService>(); var deletion = deleteSerive.DeleteEntity(objectClass, id, uow, beforeDeletion); while (deletion.DeletionExecuted == null) { GtkHelper.WaitRedraw(); System.Threading.Thread.Sleep(50); } return(deletion.DeletionExecuted.Value); } catch (Exception ex) { QSMain.ErrorMessageWithLog("Ошибка удаления.", logger, ex); return(false); } }
private void RunReport() { ViewModel.Progress = ViewModel.LoadingData; ViewModel.IsLoadingData = true; GtkHelper.WaitRedraw(); ViewModel.RunReportCommand.Execute(); }
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(); } }
private void CreateReport() { ViewModel.ProgressTitle = ViewModel.LoadingProgress; ViewModel.IsLoadingData = true; GtkHelper.WaitRedraw(); ViewModel.CreateReportCommand.Execute(); }
private void Export() { var parentW = GtkHelper.GetParentWindow(this); var csvFilter = new FileFilter(); csvFilter.AddPattern("*.csv"); csvFilter.Name = "Comma Separated Values File (*.csv)"; var param = new object[4]; param[0] = "Cancel"; param[1] = ResponseType.Cancel; param[2] = "Save"; param[3] = ResponseType.Accept; var fc = new FileChooserDialog("Save File As", parentW, FileChooserAction.Save, param) { DoOverwriteConfirmation = true, CurrentName = "Аналитика заказов.csv" }; fc.AddFilter(csvFilter); if (fc.Run() == (int)ResponseType.Accept) { ViewModel.FileName = fc.Filename; ViewModel.ExportCommand.Execute(); } fc.Destroy(); }
private CategoryEditDialog(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); Label1.Text = TextResource.GetText("SORT_NAME"); Label2.Text = TextResource.GetText("SETTINGS_CAT_TYPES"); Label3.Text = TextResource.GetText("SETTINGS_CAT_FOLDER"); BtnOk.Clicked += BtnOk_Clicked; BtnCancel.Clicked += BtnCancel_Clicked; Browse.Clicked += Browse_Clicked; BtnOk.Label = TextResource.GetText("MSG_OK"); BtnCancel.Label = TextResource.GetText("ND_CANCEL"); Title = TextResource.GetText("MSG_CATEGORY"); SetDefaultSize(400, 200); }
private void BtnStart_Clicked(object?sender, EventArgs e) { SaveQueues(); var queue = GtkHelper.GetSelectedValue <DownloadQueue>(LbQueues, 1); QueueStartRequested?.Invoke(this, new DownloadListEventArgs(queue.DownloadIds)); }
public void Start(double maxValue = 1, double minValue = 0, string text = null, double startValue = 0) { Adjustment = new Adjustment(startValue, minValue, maxValue, 1, 1, 1); Text = text; Visible = true; GtkHelper.WaitRedraw(); }
private void BtnUp_Clicked(object?sender, EventArgs e) { var indices = GtkHelper.GetSelectedIndices(lvFiles); if (indices.Length > 0 && indices[0] > 0) { var ent = GtkHelper.GetValueAt <InProgressDownloadItem>(lvFiles, indices[0] - 1, 3); if (ent == null) { return; } var index = indices[indices.Length - 1]; GtkHelper.RemoveAt(filesListStore, indices[0] - 1); filesListStore.InsertWithValues(index, ent.Name, FormattingHelper.FormatSize(ent.Size), ent.Status.ToString(), ent); } //var indices = GtkHelper.getse lvFiles.GetSelectedIndices(); //if (indices.Length > 0 && indices[0] > 0) //{ // var item = this.downloads[indices[0] - 1]; // var index = indices[indices.Length - 1]; // this.downloads.Remove(item); // this.downloads.Insert(index, item); // //var index1 = indices[0] - 1; // //var index2 = indices[0] + lvFiles.SelectedItems.Count - 1; // //var value = this.downloads[index1]; // //this.downloads.RemoveAt(index1); // //this.downloads.Insert(index2, value); //} }
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); } } } }
public void LoadConfig() { //Browser monitoring TxtChromeWebStoreUrl.Text = Links.ChromeExtensionUrl; TxtFirefoxAMOUrl.Text = Links.FirefoxExtensionUrl; TxtDefaultFileTypes.Text = string.Join(",", Config.Instance.FileExtensions); TxtDefaultVideoFormats.Text = string.Join(",", Config.Instance.VideoExtensions); TxtExceptions.Text = string.Join(",", Config.Instance.BlockedHosts); GtkHelper.SetSelectedComboBoxValue <int>(CmbMinVidSize, Config.Instance.MinVideoSize); ChkMonitorClipboard.Active = Config.Instance.MonitorClipboard; ChkTimestamp.Active = Config.Instance.FetchServerTimeStamp; //General settings ChkShowPrg.Active = Config.Instance.ShowProgressWindow; ChkShowComplete.Active = Config.Instance.ShowDownloadCompleteWindow; ChkStartAuto.Active = Config.Instance.StartDownloadAutomatically; ChkOverwrite.Active = Config.Instance.FileConflictResolution == FileConflictResolution.Overwrite; ChkDarkTheme.Active = Config.Instance.AllowSystemDarkTheme; TxtTempFolder.Text = Config.Instance.TempDir; GtkHelper.SetSelectedComboBoxValue <int>(CmbMaxParallalDownloads, Config.Instance.MaxParallelDownloads); ChkAutoCat.Active = Config.Instance.FolderSelectionMode == FolderSelectionMode.Auto; TxtDownloadFolder.Text = Config.Instance.DefaultDownloadFolder; CmbDblClickAction.Active = Config.Instance.DoubleClickOpenFile ? 1 : 0; foreach (var cat in Config.Instance.Categories) { categoryStore.AppendValues(cat.DisplayName, string.Join(",", cat.FileExtensions), cat.DefaultFolder, cat); } //Network settings GtkHelper.SetSelectedComboBoxValue <int>(CmbTimeOut, Config.Instance.NetworkTimeout); GtkHelper.SetSelectedComboBoxValue <int>(CmbMaxSegments, Config.Instance.MaxSegments); GtkHelper.SetSelectedComboBoxValue <int>(CmbMaxRetry, Config.Instance.MaxRetry); TxtMaxSpeedLimit.Text = Config.Instance.DefaltDownloadSpeed.ToString(); ChkEnableSpeedLimit.Active = Config.Instance.EnableSpeedLimit; CmbProxyType.Active = (int)(Config.Instance.Proxy?.ProxyType ?? ProxyType.System); TxtProxyHost.Text = Config.Instance.Proxy?.Host; TxtProxyPort.Text = (Config.Instance.Proxy?.Port ?? 0).ToString(); TxtProxyUser.Text = Config.Instance.Proxy?.UserName; TxtProxyPassword.Text = Config.Instance.Proxy?.Password; //Password manager foreach (var password in Config.Instance.UserCredentials) { passwordStore.AppendValues(password.Host, password.User, password); } //Advanced settings ChkHalt.Active = Config.Instance.ShutdownAfterAllFinished; ChkKeepAwake.Active = Config.Instance.KeepPCAwake; ChkRunCmd.Active = Config.Instance.RunCommandAfterCompletion; ChkRunAntivirus.Active = Config.Instance.ScanWithAntiVirus; ChkAutoRun.Active = PlatformHelper.IsAutoStartEnabled(); TxtCustomCmd.Text = Config.Instance.AfterCompletionCommand; TxtAntiVirusCmd.Text = Config.Instance.AntiVirusExecutable; TxtAntiVirusArgs.Text = Config.Instance.AntiVirusArgs; TxtDefaultUserAgent.Text = Config.Instance.FallbackUserAgent; }
public void DataChanged() { currentCategories = dbAdapter.GetCategoriesNames(); int currentIndex = cbCategories.Active; GtkHelper.FillComboBox(cbCategories, currentCategories); cbCategories.Active = currentIndex; }
public void ShowMessageBox(object?window, string message) { if (window is not Window owner) { owner = GetMainWindow(); } GtkHelper.ShowMessageBox(owner, message); }
public void WaitInMainLoop(Func <bool> checkStop, uint sleepMilliseconds = 20) { while (!checkStop()) { GtkHelper.WaitRedraw(); Thread.Sleep((int)sleepMilliseconds); } }
private void BtnDel_Clicked(object?sender, EventArgs e) { var index = GtkHelper.GetSelectedIndex(LbQueues); if (GtkHelper.GetSelectedIndex(LbQueues) >= 0) { GtkHelper.RemoveAt(this.queueListStore, index); } }
public new void Update(double value) { if (Adjustment == null) { return; } Adjustment.Value = value; GtkHelper.WaitRedraw(); }
private void ChkSelectAll_Toggled(object?sender, EventArgs e) { GtkHelper.ListStoreForEach(this.listStore, iter => { this.listStore.SetValue(iter, 0, ChkSelectAll.Active); var ent = (EntryWrapper)this.listStore.GetValue(iter, 5); ent.Selected = ChkSelectAll.Active; }); }
private void BtnBrowse_Clicked(object?sender, EventArgs e) { var file = GtkHelper.SelectFile(this); if (!string.IsNullOrEmpty(file)) { TxtAntiVirusCmd.Text = file; } }
private void BtnTempFolderBrowse_Clicked(object?sender, EventArgs e) { var folder = GtkHelper.SelectFolder(this); if (!string.IsNullOrEmpty(folder)) { TxtTempFolder.Text = folder; } }
private void UpdateBrowserMonitoringConfig() { Config.Instance.FileExtensions = TxtDefaultFileTypes.Text.Split(',').Select(x => x.Trim()).Where(x => x.Length > 0).ToArray(); Config.Instance.VideoExtensions = TxtDefaultVideoFormats.Text.Split(',').Select(x => x.Trim()).Where(x => x.Length > 0).ToArray(); Config.Instance.BlockedHosts = TxtExceptions.Text.Split(',').Select(x => x.Trim()).Where(x => x.Length > 0).ToArray(); Config.Instance.FetchServerTimeStamp = ChkTimestamp.Active; Config.Instance.MonitorClipboard = ChkMonitorClipboard.Active; Config.Instance.MinVideoSize = GtkHelper.GetSelectedComboBoxValue <int>(CmbMinVidSize); }
public override void AddChildEntry() { TreeIter parentIter = editFrameAdapter.ActiveParentTreeIter; if (CurrTabIndex == -1 || parentIter.Equals(TreeIter.Zero)) { return; } ComboBox cbTyp = new ComboBox(API_Contract.CategorieTextTypChildVal); cbTyp.Active = 0; // Text is default Entry textEntry = new Entry(); GetUserArgs[] args = { new GetUserArgs(new Label("Typ"), cbTyp), new GetUserArgs(new Label("Text"), textEntry), }; var diag = new GetUserDataDialog(args, null, "Ok", 0, "Abburch", 1); if (diag.Run() == 0 && AssertNotEmpty(diag, textEntry)) { var treeContent = CurrTreeStore; string text = textEntry.Text; string typString = GtkHelper.ComboBoxActiveString(cbTyp); int typ = API_Contract.CategorieTextChildTypCR[typString]; int row; TreeIter firstIt; // Get row if (treeContent.IterChildren(out firstIt, parentIter)) { var lastIt = GtkHelper.GetLastIter(treeContent, firstIt); row = int.Parse((string)treeContent.GetValue(lastIt, (int)CategorieColumnID.Rang)); row += 1; } else { row = 0; } // Save on UI treeContent.AppendValues(parentIter, row, typString, text); // Save on Database var titelName = (string)treeContent.GetValue(parentIter, (int)CategorieColumnID.Text); var insert = new Table_Kategorie_Tab_Text(tabNames[CurrTabIndex], titelName, text, typ, row); dbAdapter.InsertEntry(insert); } // Free memory diag.Destroy(); foreach (var arg in args) { arg.Dispose(); } }