public async Task<bool> RemoveAsync (TorrentManager manager, RemoveMode mode) { CheckDisposed (); Check.Manager (manager); await MainLoop; if (manager.Engine != this) throw new TorrentException ("The manager has not been registered with this engine"); if (manager.State != TorrentState.Stopped) throw new TorrentException ("The manager must be stopped before it can be unregistered"); allTorrents.Remove (manager); publicTorrents.Remove (manager); ConnectionManager.Remove (manager); listenManager.Remove (manager.InfoHashes); manager.DownloadLimiters.Remove (downloadLimiters); manager.UploadLimiters.Remove (uploadLimiters); manager.Dispose (); if (mode.HasFlag (RemoveMode.CacheDataOnly)) { foreach (var path in new[] { Settings.GetFastResumePath (manager.InfoHashes), Settings.GetMetadataPath (manager.InfoHashes) }) if (File.Exists (path)) File.Delete (path); } if (mode.HasFlag (RemoveMode.DownloadedDataOnly)) { foreach (var path in manager.Files.Select (f => f.FullPath)) if (File.Exists (path)) File.Delete (path); // FIXME: Clear the empty directories. } return true; }
async Task <bool> RemoveAsync(InfoHash infohash, RemoveMode mode) { await MainLoop; var manager = allTorrents.FirstOrDefault(t => t.InfoHash == infohash); return(manager != null && await RemoveAsync(manager, mode)); }
public bool RemoveResource(IStorageProviderSession session, ICloudFileSystemEntry resource, RemoveMode mode) { String url; Dictionary<String, String> parameters = null; if (mode == RemoveMode.FromParentCollection) { var pId = (resource.Parent != null ? resource.Parent.Id : GoogleDocsConstants.RootFolderId).ReplaceFirst("_", "%3a"); url = String.Format("{0}/{1}/contents/{2}", GoogleDocsConstants.GoogleDocsFeedUrl, pId, resource.Id.ReplaceFirst("_", "%3a")); } else { url = String.Format(GoogleDocsConstants.GoogleDocsResourceUrlFormat, resource.Id.ReplaceFirst("_", "%3a")); parameters = new Dictionary<string, string> {{"delete", "true"}}; } var request = CreateWebRequest(session, url, "DELETE", parameters); request.Headers.Add("If-Match", "*"); try { var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) return true; } catch (WebException) { } return false; }
/// <summary> /// Called when the radioButton PreviousApplicationRunsRemoveOldestWhenTotalSizeLargerThan checked state has changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> private void radioButtonPreviousApplicationRunsRemoveOldestWhenTotalSizeLargerThan_CheckedChanged(object sender, EventArgs e) { if (this.radioButtonCheckedChangedEventHandlersEnabled && this.radioButtonPreviousApplicationRunsRemoveOldestWhenTotalSizeLargerThan.Checked) { RemoveModePreviousApplicationRuns = RemoveMode.RemoveOldestWhenTotalSizeLargerThan; } }
/// <summary> /// Called when the radioButton PreviousApplicationRunsRemove checked state has changed. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The event arguments.</param> private void radioButtonPreviousApplicationRunsRemove_CheckedChanged(object sender, EventArgs e) { if (this.radioButtonCheckedChangedEventHandlersEnabled && this.radioButtonPreviousApplicationRunsRemove.Checked) { RemoveModePreviousApplicationRuns = RemoveMode.Remove; } }
public static void RemoveRange(this ExcelRange range, RemoveMode Mode) { var sheet = range.Worksheet; if (Mode.Equals(RemoveMode.Column)) { var cs = range.Start.Column; var ce = range.End.Column; sheet.DeleteColumn(cs, ce - cs + 1); } if (Mode.Equals(RemoveMode.Row)) { var rs = range.Start.Row; var re = range.End.Row; sheet.DeleteRow(rs, re - rs + 1); } if (Mode.Equals(RemoveMode.RightShift)) { var cs = range.End.Column + 1; var ce = sheet.Dimension.Columns * 2; var rs = range.Start.Row; var re = range.End.Row; var RightRange = sheet.Cells[rs, cs, re, ce]; cs = range.Start.Column; ce = sheet.Dimension.Columns; rs = range.Start.Row; re = range.End.Row; var newRange = sheet.Cells[rs, cs, re, ce]; RightRange.Copy(newRange); } if (Mode.Equals(RemoveMode.LowerShift)) { var cs = range.Start.Column; var ce = range.End.Column; var rs = range.End.Row + 1; var re = sheet.Dimension.Rows * 2; var LowerRange = sheet.Cells[rs, cs, re, ce]; cs = range.Start.Column; ce = range.End.Column; rs = range.Start.Row; re = sheet.Dimension.Rows; var newRange = sheet.Cells[rs, cs, re, ce]; LowerRange.Copy(newRange); } }
/// <summary> /// Copy settings from the FileGroup instance to this UserControl. /// </summary> private void CopySettingsFromUserConfigurableFileGroup() { RemoveModeCurrentApplicationRun = this.userConfigurableFileGroup.RemoveModeCurrentApplicationRun; this.checkBoxCurrentApplicationRunAskPermissionToRemove.Checked = this.userConfigurableFileGroup.AskPermissionToRemoveCurrentApplicationRun; RemoveModePreviousApplicationRuns = this.userConfigurableFileGroup.RemoveModePreviousApplicationRuns; this.checkBoxPreviousApplicationRunsAskPermissionToRemove.Checked = this.userConfigurableFileGroup.AskPermissionToRemovePreviousApplicationRuns; this.textBoxPreviousApplicationRunsDays.Text = this.userConfigurableFileGroup.DaysPreviousApplicationRuns.ToString(); this.textBoxPreviousApplicationRunsSize.Text = this.userConfigurableFileGroup.SizePreviousApplicationRuns.ToString(); this.textBoxDirectory.Text = this.userConfigurableFileGroup.Directory; }
/// <summary> /// Copy settings from this UserControl to the FileGroup instance. /// </summary> public void CopySettingsToUserConfigurableFileGroupAndSave() { this.userConfigurableFileGroup.RemoveModeCurrentApplicationRun = RemoveModeCurrentApplicationRun; this.userConfigurableFileGroup.AskPermissionToRemoveCurrentApplicationRun = this.checkBoxCurrentApplicationRunAskPermissionToRemove.Checked; this.userConfigurableFileGroup.RemoveModePreviousApplicationRuns = RemoveModePreviousApplicationRuns; this.userConfigurableFileGroup.AskPermissionToRemovePreviousApplicationRuns = this.checkBoxPreviousApplicationRunsAskPermissionToRemove.Checked; this.userConfigurableFileGroup.DaysPreviousApplicationRuns = Convert.ToUInt16(this.textBoxPreviousApplicationRunsDays.Text); this.userConfigurableFileGroup.SizePreviousApplicationRuns = Convert.ToUInt16(this.textBoxPreviousApplicationRunsSize.Text); this.userConfigurableFileGroup.Directory = this.textBoxDirectory.Text; this.userConfigurableFileGroup.Save(); }
public static void RemoveRange(this ExcelRangeBase rangeBase, RemoveMode Mode) { var range = rangeBase.Worksheet.Cells[rangeBase.Address]; RemoveRange(range, Mode); }
public Task <bool> RemoveAsync(MagnetLink magnetLink, RemoveMode mode) { magnetLink = magnetLink ?? throw new ArgumentNullException(nameof(magnetLink)); return(RemoveAsync(magnetLink.InfoHash, mode)); }
private void VerifyMatchExpressions(FoldChangeVolcanoPlot volcanoPlot, MatchExprInfo[] matchExprInfos, int initialRowCount = 0, RemoveMode removeMode = RemoveMode.Cancel) { int count = matchExprInfos.Length; var formattingDlg = ShowDialog <VolcanoPlotFormattingDlg>(volcanoPlot.ShowFormattingDialog); for (var i = 0; i < count; ++i) { var index = i; var exprInfo = matchExprInfos[i]; var createExprDlg = ShowDialog <CreateMatchExpressionDlg>(() => { var bindingList = formattingDlg.GetCurrentBindingList(); Assert.AreEqual(initialRowCount + index, bindingList.Count); bindingList.Add(new MatchRgbHexColor(string.Empty, exprInfo.ExpectedPointsInfo.Labeled, exprInfo.ExpectedPointsInfo.Color, exprInfo.ExpectedPointsInfo.PointSymbol, exprInfo.ExpectedPointsInfo.PointSize)); formattingDlg.ClickCreateExpression(bindingList.Count - 1); }); RunUI(() => { createExprDlg.MatchSelectedItem = CreateMatchExpressionDlg.GetMatchOptionStringPair(createExprDlg.MatchItems.ToArray(), exprInfo.MatchExpression.matchOptions); createExprDlg.FoldChangeSelectedItem = CreateMatchExpressionDlg.GetMatchOptionStringPair(createExprDlg.FoldChangeItems.ToArray(), exprInfo.MatchExpression.matchOptions); createExprDlg.PValueSelectedItem = CreateMatchExpressionDlg.GetMatchOptionStringPair(createExprDlg.PValueItems.ToArray(), exprInfo.MatchExpression.matchOptions); createExprDlg.Expression = exprInfo.MatchExpression.RegExpr; }); WaitForConditionUI(() => exprInfo.ExpectedMatches.Count == createExprDlg.MatchingRows.Count(), () => string.Format("Expected: {0}\nActual: {1}", string.Join(", ", exprInfo.ExpectedMatches), string.Join(", ", createExprDlg.MatchingRows))); RunUI(() => CollectionAssert.AreEqual(exprInfo.ExpectedMatches, createExprDlg.MatchingRows.ToArray())); OkDialog(createExprDlg, createExprDlg.OkDialog); } AssertVolcanoPlotCorrect(volcanoPlot, matchExprInfos.Select(info => info.ExpectedPointsInfo).ToArray()); switch (removeMode) { case RemoveMode.Cancel: OkDialog(formattingDlg, formattingDlg.CancelDialog); break; case RemoveMode.Undo: OkDialog(formattingDlg, formattingDlg.OkDialog); RunUI(SkylineWindow.Undo); break; default: Assert.Fail(); break; } var groupDef = FindGroupComparison(GROUP_COMPARISON_NAME); Assert.AreEqual(initialRowCount, groupDef.ColorRows.Count); }
/// <summary> /// Removes an <see cref="Element"/> from the Datamodel. /// </summary> /// <remarks>This method will access all values in the Datamodel, potentially triggering deferred loading and destubbing.</remarks> /// <param name="item">The Element to remove.</param> /// <param name="mode">The action to take if a reference to this Element is found in another Element.</param> /// <returns>true if item is successfully removed; otherwise, false.</returns> public bool Remove(Element item, RemoveMode mode) { if (item == null) { throw new ArgumentNullException("item"); } ChangeLock.EnterUpgradeableReadLock(); try { if (store.Contains(item.ID)) { ChangeLock.EnterWriteLock(); try { store.Remove(item.ID); Element replacement = (mode == RemoveMode.MakeStubs) ? new Element(Owner, item.ID) : (Element)null; foreach (Element elem in store.Values) { lock (elem.SyncRoot) { foreach (var attr in elem.Where(a => a.Value == item).ToArray()) { elem[attr.Key] = replacement; } foreach (var array in elem.Select(a => a.Value).OfType <IList <Element> >()) { for (int i = 0; i < array.Count; i++) { if (array[i] == item) { array[i] = replacement; } } } } } if (Owner.Root == item) { Owner.Root = replacement; } item.Owner = null; } finally { ChangeLock.ExitWriteLock(); } if (CollectionChanged != null) { CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item)); } return(true); } else { return(false); } } finally { ChangeLock.ExitUpgradeableReadLock(); } }
public bool RemoveResource(IStorageProviderSession session, ICloudFileSystemEntry resource, RemoveMode mode) { String url; Dictionary <String, String> parameters = null; if (mode == RemoveMode.FromParentCollection) { var pId = (resource.Parent != null ? resource.Parent.Id : GoogleDocsConstants.RootFolderId).ReplaceFirst("_", "%3a"); url = String.Format("{0}/{1}/contents/{2}", GoogleDocsConstants.GoogleDocsFeedUrl, pId, resource.Id.ReplaceFirst("_", "%3a")); } else { url = String.Format(GoogleDocsConstants.GoogleDocsResourceUrlFormat, resource.Id.ReplaceFirst("_", "%3a")); parameters = new Dictionary <string, string> { { "delete", "true" } }; } var request = CreateWebRequest(session, url, "DELETE", parameters); request.Headers.Add("If-Match", "*"); try { var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { return(true); } } catch (WebException) { } return(false); }
public Task <bool> RemoveAsync(Torrent torrent, RemoveMode mode) { torrent = torrent ?? throw new ArgumentNullException(nameof(torrent)); return(RemoveAsync(torrent.InfoHash, mode)); }