public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); Item item = context.Items[0]; ProgressBox.Execute("ItemSync", "Translate", this.GetIcon(context, string.Empty), TranslateItem, "item:load(id=" + item.ID + ")", new object[] { item, context }); }
protected virtual void Run(ClientPipelineArgs args) { ItemUri itemUri = ItemUri.Parse(args.Parameters["uri"]); Item item = Database.GetItem(itemUri); Error.AssertItemFound(item); bool flag = true; string str1 = string.Concat(Settings.DataFolder.TrimStart(new char[] { '/' }), "\\", Settings.GetSetting("Sitecore.Scientist.MediaExportImport.ExportFolderName", "MediaExports")); if (!IsValidPath(str1)) { str1 = HttpContext.Current.Server.MapPath("~/") + str1; } str1 = str1.Replace("/", "\\"); FileUtil.CreateFolder(FileUtil.MapPath(str1)); var innerfolders = item.Paths.FullPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); foreach (var folder in innerfolders) { str1 = str1 + "\\" + folder; FileUtil.CreateFolder(FileUtil.MapPath(str1)); } Log.Info(string.Concat("Starting export of media items to: ", string.Concat(Settings.DataFolder.TrimStart(new char[] { '/' }), "\\", Settings.GetSetting("Sitecore.Scientist.MediaExportImport.ExportFolderName", "MediaExports"))), this); ProgressBoxMethod progressBoxMethod = new ProgressBoxMethod(StartProcess); object[] objArray = new object[] { item, str1, flag }; ProgressBox.Execute("Export Media Items...", "Export Media Items", progressBoxMethod, objArray); }
public void OnUserDeletedUnlockFiles(object sender, EventArgs args) { if (EventDisabler.IsActive) { return; } var objList = new List <Item>(); var userName = Event.ExtractParameter <string>(args, 0); Assert.IsNotNullOrEmpty(userName, "User name was null or empty"); var lockedItems = Client.ContentDatabase.SelectItems($"search://*[@__lock='%{userName}%']"); if (lockedItems == null || !lockedItems.Any()) { return; } foreach (var lockedItem in lockedItems) { objList.AddRange(lockedItem.Versions.GetVersions(true).Where(version => string.Compare(version.Locking.GetOwner(), userName, StringComparison.OrdinalIgnoreCase) == 0)); } ProgressBox.Execute(nameof(RemovedUserEventHandler), "Unlocking items", "Network/16x16/lock.png", UnlockAllItems, "lockeditems:refresh", Context.User, objList); SheerResponse.Alert($"Successfully unlocked {objList.Count} item(s) checked out by {userName}", Array.Empty <string>()); }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (this.cboLayer.Text == "") { MessageBox.Show("Please select a polyline layer"); return; } IFeatureLayer layer = m_Layers[this.cboLayer.SelectedIndex]; IFeatureSet feaset = (layer as FeatureLayer).FeatureSet; ProgressBox p = new ProgressBox(0, 100, "Self intersection check progress"); p.ShowPregress(); p.SetProgressValue(0); p.SetProgressDescription("Checking Self intersection..."); double pi = Math.Round((double)(1.0 * 100 / feaset.Features.Count), 2); List <int> FidList = new List <int>(); //DateTime dt = DateTime.Now; for (int i = 0; i < feaset.Features.Count; i++) { p.SetProgressValue(i * pi + pi); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) checked, the remaining {1} feature(s) is(are) being queried", i + 1, feaset.Features.Count - i - 1)); var LineList = GetLinesFromGeometry(feaset.Features[i].Geometry); //var LineList = GetAllLine(feaset.Features[i].Geometry); bool IsCrossed = false; for (int j = 0; j < LineList.Count; j++) { for (int k = j + 1; k < LineList.Count; k++) { if (LineList[j].Crosses(LineList[k])) { FidList.Add(feaset.Features[i].Fid); IsCrossed = true; break; } } if (IsCrossed) { break; } } } //DateTime dt2 = DateTime.Now; //var span = dt2 - dt; //MessageBox.Show(span.ToString()); p.CloseProgress(); if (FidList.Count == 0) { MessageBox.Show(string.Format("{0} has no Self intersection.", layer.LegendText)); } else { layer.UnSelectAll(); MainWindow.m_DotMap.Refresh(); layer.Select(FidList); MessageBox.Show(string.Format("{0} has {1} Self intersection", layer.LegendText, FidList.Count.ToString())); } this.Close(); }
public void UpdateStatus(string line) { Dispatcher.Invoke(() => { ProgressBox.AppendText(line + "\n"); ProgressBox.ScrollToEnd(); }); }
public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); if (context.Items.Length >= 0) { ProgressBox.Execute("Image", "Optimize images", new ProgressBoxMethod(this.StartProcess), new object[] { context.Items }); } }
public Progress(Item item, ItemCard card) { InitializeComponent(); ProgressBox.Text = item.progress; _item = item; _card = card; ProgressBox.Focus(); }
public override void Execute(CommandContext context) { var database = Factory.GetDatabase("master"); var contextItem = SitecoreCommandHelper.GetContextItem(context, database); ProgressBox.Execute("Running Tests", "Test Preview", new ProgressBoxMethod(RunTests), new object[] { database, contextItem }); ModalDialogHelper.ShowTestingModalDialog(contextItem.ID, contextItem.Language, PageMode.Live); }
public Progress ShowDialog(string text = "", Window owner = null) { Log.Debug($"Progress status: {text}"); owner = owner ?? windowsOwner; ProgressBox progress = new ProgressBox(owner, text); progress.StartShowDialog(); currentProgress = progress; return(progress); }
protected void Run(ClientPipelineArgs args) { string parameter = args.Parameters["itemPath"]; if (string.IsNullOrEmpty(parameter)) { return; } ProgressBox.ExecuteSync($"Re-Index Tree. ({parameter})", "Re-indexing the current item with subitems.", "Applications/16x16/replace2.png", this.Refresh, this.RefreshDone); }
public override void Execute(CommandContext context) { if (!context.Items.Any(t => t.Paths.IsMediaItem)) { return; } ProgressBox.Execute("Shrink Image", "Shrink Image", new ProgressBoxMethod(this.Shrink), new object[1] { context.Items[0] }); }
public override void Execute(CommandContext context) { var item = context.Items.First(); ProgressBox.Execute( "DeleteSqlData", Translate.Text("Delete"), GetIcon(context, string.Empty), Process, $"item:load(id={item.ID})", item, context); }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (this.cboLayer.Text == "") { MessageBox.Show("Please select a polygon layer"); return; } IFeatureLayer layer = m_Layers[this.cboLayer.SelectedIndex]; IFeatureSet feaset = (layer as FeatureLayer).FeatureSet; ProgressBox p = new ProgressBox(0, 100, "Faying surface check progress"); p.ShowPregress(); p.SetProgressValue(0); p.SetProgressDescription("Checking faying surface..."); double pi = Math.Round((double)(1.0 * 100 / feaset.Features.Count)); List <int> FidList = new List <int>(); for (int i = 0; i < feaset.Features.Count; i++) { p.SetProgressValue(i * pi + pi); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) checked, the remaining {1} feature(s) is(are) being queried", i + 1, feaset.Features.Count - i - 1)); for (int j = i + 1; j < feaset.Features.Count; j++) { if (feaset.Features[i].Geometry.Overlaps(feaset.Features[j].Geometry)) { if (!FidList.Contains(i)) { FidList.Add(i); } if (!FidList.Contains(j)) { FidList.Add(j); } } } } p.CloseProgress(); if (FidList.Count == 0) { MessageBox.Show(string.Format("{0} has no faying surface.", layer.LegendText)); } else { layer.UnSelectAll(); MainWindow.m_DotMap.Refresh(); layer.Select(FidList); MessageBox.Show(string.Format("{0} has {1} faying surfaces.", layer.LegendText, FidList.Count.ToString())); } this.Close(); }
protected void Confirm(ClientPipelineArgs args) { if (!args.IsPostBack) { SheerResponse.Confirm("Are you sure you want to rebuild the WeBlog search index?"); args.WaitForPostBack(); } else { if (args.Result == "yes") { ProgressBox.Execute("weblog-index-rebuild", "Rebuilding WeBlog Search Index", new ProgressBoxMethod(Run)); } } }
public override void Execute(CommandContext context) { if (!context.Items.Any(t => t.Paths.IsMediaItem)) { return; } objFillSetting = null; //Sitecore.Context.ClientPage. string JobName = "Shrink Image - " + ValidationHelper.ValidateToString(Sitecore.Data.ID.NewID, Guid.NewGuid().ToString()); ProgressBox.Execute(JobName, "Shrink Image", new ProgressBoxMethod(this.Shrink), new object[1] { context.Items[0] }); }
public override void Execute(CommandContext context) { if (SessionManager.Instance.CurrentIndex == null) { SheerResponse.Alert(Translate.Text("The index is not selected. Please select the index.")); } else { ProgressBox.Execute("IndexRebuild", "Rebuild", this.GetIcon(context, string.Empty), new ProgressBoxMethod(this.Optimize), "indexviewer:indexoptimized", new object[] { SessionManager.Instance.CurrentIndex, context }); } }
public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); var item = context.Items[0]; Assert.IsNotNull(item, "context item cannot be null"); var progressBoxMethod = new ProgressBoxMethod(Refresh); ProgressBox.Execute( string.Format("{0} ({1})", "Re-Index Elastic Tree.", item.Paths.ContentPath), "Re-indexing the current item and its descendants in Elastic", progressBoxMethod, new object[] { item }); }
public override void Execute(CommandContext context) { Assert.ArgumentNotNull(context, "context"); var item = context.Items[0]; Assert.IsNotNull(item, "context item cannot be null"); var progressBoxMethod = new ProgressBoxMethod(Recreate); ProgressBox.Execute( "Recreate Elastic Indexes.", "Recreating all Elastic indexes.", progressBoxMethod, new object[] { item }); }
public void DialogProcessor(ClientPipelineArgs args) { if (!args.IsPostBack) { SheerResponse.YesNoCancel("Are you sure you want to sync synonyms?", "500px", "200px", true); args.WaitForPostBack(true); } else { if (args.Result == "yes") { ProgressBox.Execute("Sync Synonyms", "Sync Synonyms", Sync); SheerResponse.Alert("Sync has been completed"); } } }
private FeatureSet IntersectFeatures(IFeatureSet targetFeatures, IFeatureSet sourceFeatures) { if (targetFeatures == null || sourceFeatures == null) { return(null); } FeatureSet resultFeatures = new FeatureSet(); // the resulting featureset resultFeatures.CopyTableSchema(targetFeatures); // set up the data table in the new feature set ProgressBox p = new ProgressBox(0, 100, "Self intersection check progress"); p.ShowPregress(); p.SetProgressValue(0); p.SetProgressDescription("Overlay Intersect..."); double pi = Math.Round((double)(1.0 * 100 / targetFeatures.Features.Count), 2); for (int i = 0; i < targetFeatures.Features.Count; i++) { p.SetProgressValue(i * pi + pi); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) checked, the remaining {1} feature(s) is(are) being queried", i + 1, targetFeatures.Features.Count - i - 1)); var tf = targetFeatures.GetFeature(i); // get the full undifferenced feature for (int j = 0; j < sourceFeatures.Features.Count; j++) { var sf = sourceFeatures.GetFeature(j); if (sf.Geometry.Intersects(tf.Geometry)) { tf = tf.Intersection(sf.Geometry); // clip off any pieces of SF that overlap FR } if (tf == null) { break; } } if (tf != null) { resultFeatures.AddFeature(tf.Geometry).CopyAttributes(targetFeatures.GetFeature(i)); } } p.CloseProgress(); return(resultFeatures); }
/// <summary> /// Called when the item copied event runs. Will update the Context references contained in the copied tree structure. /// </summary> /// <param name="sender">The sender.</param> /// <param name="args">The <see cref="System.EventArgs" /> instance containing the event data.</param> protected void OnItemCopied(object sender, EventArgs args) { var itemThatWasCopied = Event.ExtractParameter(args, 0) as Item; var itemRootCreatedByCopy = Event.ExtractParameter(args, 1) as Item; Error.AssertNotNull(itemThatWasCopied, "No sourceItem in parameters"); Error.AssertNotNull(itemRootCreatedByCopy, "No targetItem in parameters"); var updater = new LayoutDataSourceReferenceUpdater { NewRoot = itemRootCreatedByCopy, OriginalRoot = itemThatWasCopied }; ProgressBox.Execute( Translate.Text("Updating context references"), Translate.Text("Updating context references"), "Applications/16x16/form_blue.png", updater.UpdateReferences, Event.ExtractParameter(args, 0), Event.ExtractParameter(args, 1)); }
public override void Execute(CommandContext context) { ProgressBox.Execute("Exporting Site", "Generating Configuration, Databases, Files, Update Packages", StartProcess, new object[] { context.Items[0].ID.ToString() }); //Step 1: Move over empty deploy template //Step 2: Create Item Packages //Step 3: Move Project Output //Step 4: Fill in Deploy Scripts //Step 5: Generate Output //Step 6: Run Go.cmd to generate nuget package //Step 7: Deploy script to stop IIS install, and warm up. //Step 8: Hit site and warm cache //Step 9: Run Smoke Tests //Step 10: Send Deployment Confirmation Email. Sitecore.Data.Database db = Factory.GetDatabase("master"); var items = context.Items[0]; foreach (Item project in items.Children) { RunPowershellScript(@"C:\Export\" + project.Name + "\\SiteName\\SiteEnvironment", "go.cmd", "package"); } }
protected virtual void Run(ClientPipelineArgs args) { ItemUri itemUri = ItemUri.Parse(args.Parameters["uri"]); Item item = Database.GetItem(itemUri); Error.AssertItemFound(item); bool flag = true; string str1 = string.Concat(Settings.DataFolder.TrimStart(new char[] { '/' }), "\\", Settings.GetSetting("Sitecore.Scientist.MediaExportImport.ExportFolderName", "MediaExports")) + item.Paths.FullPath; if (!IsValidPath(str1)) { str1 = HttpContext.Current.Server.MapPath("~/") + str1; } str1 = str1.Replace("/", "\\"); if (FileUtil.FolderExists(FileUtil.MapPath(str1))) { Log.Info(string.Concat("Starting import media items from: ", string.Concat(Settings.DataFolder.TrimStart(new char[] { '/' }), "\\", Settings.GetSetting("Sitecore.Scientist.MediaExportImport.ExportFolderName", "MediaExports"))), this); ProgressBoxMethod progressBoxMethod = new ProgressBoxMethod(StartProcess); object[] objArray = new object[] { item, str1, flag }; ProgressBox.Execute("Import Media Items...", "Import Media Items", progressBoxMethod, objArray); } }
protected void Execute(Message message) { if (!(AgentTaskList.SelectedItems.Any() || ScheduledTaskList.SelectedItems.Any())) { Context.ClientPage.ClientResponse.Alert("Please select an task"); } else { List <XmlNode> agents = AgentTaskList.SelectedItems.Select(task => GetAgentNode(task.Value)).ToList(); List <Item> scheduledTasks = ScheduledTaskList.SelectedItems.Select(task => Context.ContentDatabase.GetItem(task.Value)).ToList(); if (agents.Any() || scheduledTasks.Any()) { ProgressBox.Execute("XCoreScheduledTaskHelper", "XCore Scheduled Task Helper", "", RunAgent, "XCore:refresh", new object[] { agents, scheduledTasks }); } else { Context.ClientPage.ClientResponse.Alert("Cannot retreive tasks"); } } }
public void Start(ProgressBox progress) { Queue <ThreadWorker> threadQueue = new Queue <ThreadWorker>(); for (int i = 0; i < databases.Count; i++) { string database = databases[i]; ThreadWorker _worker = new ThreadWorker() { WorkerReportsProgress = true }; _worker.DoWork += StartScan; _worker.ProgressChanged += progress.ProgressChanged; threadQueue.Enqueue(_worker); } SqlConnection connection = Connection.Create(host, ConnectionType.DefaultDatabase); foreach (var _worker in threadQueue) { _worker.RunWorkerCompleted += progress.FinishScan; if (!canceled) { try { connection.Open(); currentWorker = _worker; _worker.RunWorkerAsync(); } finally { connection.Close(); } } } OnFinish(); }
private void btnApply_Click(object sender, RoutedEventArgs e) { if (hasQueried) { return; } var TargetLayerList = (from u in TargetLayers where u.IsChecked select u).ToList(); if (TargetLayerList.Count == 0) { MessageBox.Show("Please select at least one target layer"); return; } if (SelectedSourceLayer == null) { MessageBox.Show("Please select a source layer"); return; } ProgressBox p = new ProgressBox(0, 100, "Location query progress"); p.ShowPregress(); p.SetProgressValue(0); IFeatureSet srcFeaset; if (this.UsingSelectedFeas) { srcFeaset = SelectedSourceLayer.Layer.Selection.ToFeatureSet(); } else { srcFeaset = SelectedSourceLayer.Layer.FeatureSet; } Dictionary <IFeatureLayer, List <int> > DicFidList = new Dictionary <IFeatureLayer, List <int> >(); switch (m_SpatialMethod) { case SpatialMethod.Intersect: foreach (var layer in TargetLayerList) { List <int> FidList = new List <int>(); var tarFeaList = GetTargetFeaList(layer.Layer); int tarCount = tarFeaList.Count; double pi = Math.Round((double)(100 * 1.0 / tarCount), 2); p.SetProgressDescription("Querying " + layer.Layer.LegendText); for (int i = 0; i < tarCount; i++) { p.SetProgressValue(pi * (i + 1)); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) queried, the remaining {1} feature(s) is(are) being queried", i + 1, tarCount - i - 1)); foreach (var fea in srcFeaset.Features) { if (tarFeaList[i].Geometry.Intersects(fea.Geometry)) { FidList.Add(tarFeaList[i].Fid); break; } } } DicFidList.Add(layer.Layer, FidList); } break; case SpatialMethod.Contains: foreach (var layer in TargetLayerList) { List <int> FidList = new List <int>(); var tarFeaList = GetTargetFeaList(layer.Layer); int tarCount = tarFeaList.Count; double pi = Math.Round((double)(100 * 1.0 / tarCount), 2); p.SetProgressDescription("Querying " + layer.Layer.LegendText); for (int i = 0; i < tarCount; i++) { p.SetProgressValue(pi * (i + 1)); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) queried, the remaining {1} feature(s) is(are) being queried", i + 1, tarCount - i - 1)); foreach (var fea in srcFeaset.Features) { if (tarFeaList[i].Geometry.Contains(fea.Geometry)) { FidList.Add(tarFeaList[i].Fid); break; } } } DicFidList.Add(layer.Layer, FidList); } break; case SpatialMethod.Within: foreach (var layer in TargetLayerList) { List <int> FidList = new List <int>(); var tarFeaList = GetTargetFeaList(layer.Layer); int tarCount = tarFeaList.Count; double pi = Math.Round((double)(100 * 1.0 / tarCount), 2); p.SetProgressDescription("Querying " + layer.Layer.LegendText); for (int i = 0; i < tarCount; i++) { p.SetProgressValue(pi * (i + 1)); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) queried, the remaining {1} feature(s) is(are) being queried", i + 1, tarCount - i - 1)); foreach (var fea in srcFeaset.Features) { if (tarFeaList[i].Geometry.Within(fea.Geometry)) { FidList.Add(tarFeaList[i].Fid); break; } } } DicFidList.Add(layer.Layer, FidList); } break; } //select features foreach (var value in DicFidList) { if (value.Value.Count > 0) { switch (m_SelectionMethod) { case SelectionMethod.Add: value.Key.Select(value.Value); break; case SelectionMethod.RemoveFromSelected: value.Key.UnSelect(value.Value); break; case SelectionMethod.SelectFromSelected: case SelectionMethod.Select: value.Key.UnSelectAll(); value.Key.Select(value.Value); break; } MainWindow.m_DotMap.Refresh(); } } p.CloseProgress(); hasQueried = true; }
private void UpdateTextBox(string text) { ProgressBox.AppendText(text + "\r\n"); }
public void TagCache() { if (HiyobiTags.Tags == null) { HiyobiTags.LoadTags(); } try { List <Hitomi.HTag> tags = HiyobiTags.Tags; Dispatcher patcher = Global.dispatcher; ProgressBox progressBox = null; patcher.Invoke(() => { progressBox = new ProgressBox(); progressBox.Title = "태그 캐시 다운로드"; progressBox.Show(); progressBox.ProgressBar.Maximum = tags.Count; }); for (int i = 0; i < tags.Count; i++) { Hitomi.HTag tag = tags[i]; Thread th = new Thread(new ThreadStart(async() => { try { string dir = Path.Combine(rootDir, tag.type.ToString()); string file = Path.Combine(dir, tag.tag + ".json"); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (File.Exists(file)) { //patcher.Invoke(() => progressBox.ProgressBar.Value++); return; } InternetP parser = new InternetP(); int[] ids = parser.ByteArrayToIntArrayBig(await parser.LoadNozomiTag(tag.type.ToString(), tag.tag, false, 0, 9999)); JArray arr = JArray.FromObject(ids); File.WriteAllText(file, arr.ToString()); Console.WriteLine("{0}/{1}: {2}", i, tags.Count, tag.full); } catch (IOException) { Console.WriteLine("Faild {0}/{1}: {2}", i, tags.Count, tag.full); } catch (Exception ex) { Console.WriteLine("Error {0} : {1}", tag.full, ex.Message); } finally { patcher.Invoke(() => { progressBox.ProgressBar.Value++; if (progressBox.ProgressBar.Value == progressBox.ProgressBar.Maximum) { progressBox.Close(); MessageBox.Show("캐시 다운로드가 끝났습니다."); } }); } })); th.Start(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
IEnumerable<FarFile> InvokeWithProgress() { using (var progress = new ProgressBox(Res.Searching)) { progress.LineCount = 2; return DoInvoke(progress); } }
IEnumerable<FarFile> DoInvokeXPath(ProgressBox progress) { // object context var objectContext = new XPathObjectContext() { Filter = this.Filter, IncrementDirectoryCount = delegate(int count) { ProcessedDirectoryCount += count; if (progress == null) return; var directoryPerSecond = ProcessedDirectoryCount / progress.ElapsedFromStart.TotalSeconds; progress.Activity = string.Format(null, Res.SearchActivityDeep, FoundFileCount, ProcessedDirectoryCount, directoryPerSecond); progress.ShowProgress(); }, Stopping = delegate { return Stopping || progress != null && UIUserStop(); } }; var xsltContext = new XPathXsltContext(objectContext.NameTable); if (_XVariables != null) { foreach (var kv in _XVariables) xsltContext.AddVariable(kv.Key, kv.Value); } // XPath text string xpath; if (string.IsNullOrEmpty(XFile)) { xpath = XPath; } else { var input = XPathInput.ParseFile(XFile); xpath = input.Expression; foreach (var kv in input.Variables) xsltContext.AddVariable(kv.Key, kv.Value); } var expression = XPathExpression.Compile(xpath); if (expression.ReturnType != XPathResultType.NodeSet) throw new InvalidOperationException("Invalid expression return type."); expression.SetContext(xsltContext); ++ProcessedDirectoryCount; var args = new GetFilesEventArgs(ExplorerModes.Find); foreach (var file in _RootExplorer.GetFiles(args)) { // stop? if (Stopping || progress != null && UIUserStop()) //???? progress to navigator break; // filter out a leaf if (Filter != null && !file.IsDirectory && !Filter(_RootExplorer, file)) continue; var xfile = new SuperFile(_RootExplorer, file); var navigator = new XPathObjectNavigator(xfile, objectContext); var iterator = navigator.Select(expression); while (iterator.MoveNext()) { // stop? if (Stopping || progress != null && UIUserStop()) //???? progress to navigator break; // found file or directory, ignore anything else var currentFile = iterator.Current.UnderlyingObject as SuperFile; if (currentFile == null) continue; // filter out directory, it is already done for files if (Filter != null && currentFile.IsDirectory && (!Directory || !Filter(currentFile.Explorer, currentFile.File))) continue; // add yield return currentFile; ++FoundFileCount; } } }
IEnumerable<FarFile> DoInvokeWide(ProgressBox progress) { var queue = new Queue<Explorer>(); queue.Enqueue(_RootExplorer); while (queue.Count > 0 && !Stopping) { // cancel? if (progress != null && UIUserStop()) break; // current var explorer = queue.Dequeue(); ++ProcessedDirectoryCount; // progress if (progress != null && progress.ElapsedFromShow.TotalMilliseconds > 500) { var directoryPerSecond = ProcessedDirectoryCount / progress.ElapsedFromStart.TotalSeconds; progress.Activity = string.Format(null, Res.SearchActivityWide, FoundFileCount, ProcessedDirectoryCount, queue.Count, directoryPerSecond); progress.ShowProgress(); } var args = new GetFilesEventArgs(ExplorerModes.Find); foreach (var file in explorer.GetFiles(args)) { // stop? if (Stopping) break; // process and add bool add = Directory || !file.IsDirectory; if (add && Filter != null) add = Filter(explorer, file); if (add) { ++FoundFileCount; yield return new SuperFile(explorer, file); } // skip if flat or leaf if (!Recurse || !file.IsDirectory) continue; Explorer explorer2 = SuperExplorer.ExploreSuperDirectory(explorer, ExplorerModes.Find, file); if (explorer2 != null) queue.Enqueue(explorer2); } } }
IEnumerable<FarFile> DoInvokeDeep(ProgressBox progress, Explorer explorer, int depth) { // stop? if (Stopping || progress != null && UIUserStop()) yield break; ++ProcessedDirectoryCount; // progress if (progress != null && progress.ElapsedFromShow.TotalMilliseconds > 500) { var directoryPerSecond = ProcessedDirectoryCount / progress.ElapsedFromStart.TotalSeconds; progress.Activity = string.Format(null, Res.SearchActivityDeep, FoundFileCount, ProcessedDirectoryCount, directoryPerSecond); progress.ShowProgress(); } var args = new GetFilesEventArgs(ExplorerModes.Find); foreach (var file in explorer.GetFiles(args)) { // stop? if (Stopping) break; // process and add bool add = Directory || !file.IsDirectory; if (add && Filter != null) add = Filter(explorer, file); if (add) { ++FoundFileCount; yield return new SuperFile(explorer, file); } // skip if deep or leaf if (Depth > 0 && depth >= Depth || !file.IsDirectory) continue; Explorer explorer2 = SuperExplorer.ExploreSuperDirectory(explorer, ExplorerModes.Find, file); if (explorer2 == null) continue; foreach (var file2 in DoInvokeDeep(progress, explorer2, depth + 1)) yield return file2; } }
//! It returns immediately and then only iterates, do not try/catch in here. IEnumerable<FarFile> DoInvoke(ProgressBox progress) { FoundFileCount = 0; ProcessedDirectoryCount = 0; if (!string.IsNullOrEmpty(XFile) || !string.IsNullOrEmpty(XPath)) return DoInvokeXPath(progress); else if (Depth == 0) return DoInvokeWide(progress); else return DoInvokeDeep(progress, _RootExplorer, 0); }
private void btnOK_Click(object sender, RoutedEventArgs e) { if (this.cboLayer.Text == "") { MessageBox.Show("Please select a polyline layer"); return; } IFeatureLayer layer = m_Layers[this.cboLayer.SelectedIndex]; IFeatureSet feaset = (layer as FeatureLayer).FeatureSet; ProgressBox p = new ProgressBox(0, 100, "Suspension point check progress"); p.ShowPregress(); p.SetProgressValue(0); p.SetProgressDescription("Checking suspension point..."); Dictionary <int, List <GeoAPI.Geometries.IPoint> > AllPoints = new Dictionary <int, List <GeoAPI.Geometries.IPoint> >();//线图层所有端点 for (int i = 0; i < feaset.Features.Count; i++) { IFeature pFea = feaset.Features[i]; if (pFea.Geometry.GeometryType == "LineString") { GeoAPI.Geometries.Coordinate coord1 = pFea.Geometry.Coordinates[0]; GeoAPI.Geometries.IPoint pPoint1 = new NetTopologySuite.Geometries.Point(coord1); int count = pFea.Geometry.Coordinates.Count() - 1; GeoAPI.Geometries.Coordinate coord2 = pFea.Geometry.Coordinates[count]; GeoAPI.Geometries.IPoint pPoint2 = new NetTopologySuite.Geometries.Point(coord2); AllPoints.Add(pFea.Fid, new List <GeoAPI.Geometries.IPoint>() { pPoint1, pPoint2 }); } else//多线 { for (int j = 0; j < pFea.Geometry.NumGeometries; j++) { var geometry = pFea.Geometry.GetGeometryN(j); GeoAPI.Geometries.Coordinate coord1 = geometry.Coordinates[0]; GeoAPI.Geometries.IPoint pPoint1 = new NetTopologySuite.Geometries.Point(coord1); int count = geometry.Coordinates.Count() - 1; GeoAPI.Geometries.Coordinate coord2 = geometry.Coordinates[count]; GeoAPI.Geometries.IPoint pPoint2 = new NetTopologySuite.Geometries.Point(coord2); if (AllPoints.ContainsKey(pFea.Fid)) { if (!AllPoints[pFea.Fid].Contains(pPoint1)) { AllPoints[pFea.Fid].Add(pPoint1); } if (!AllPoints[pFea.Fid].Contains(pPoint2)) { AllPoints[pFea.Fid].Add(pPoint2); } } else { AllPoints.Add(pFea.Fid, new List <GeoAPI.Geometries.IPoint>() { pPoint1, pPoint2 }); } } } } List <GeoAPI.Geometries.IPoint> resultPoint = new List <GeoAPI.Geometries.IPoint>(); double pi = Math.Round((double)(1.0 * 100 / feaset.Features.Count), 2); int number = 1; foreach (var value in AllPoints) { p.SetProgressValue(number * pi); p.SetProgressDescription2(string.Format("{0} feature(s) is(are) checked, the remaining {1} feature(s) is(are) being queried", number, feaset.Features.Count - number)); number++; foreach (var point in value.Value) { bool IsSuspension = true; foreach (var fea in feaset.Features) { if (fea.Fid == value.Key) { continue; } //一旦相交,必不是悬点 if (fea.Geometry.Intersects(point)) { IsSuspension = false; break; } } if (IsSuspension && !resultPoint.Contains(point)) { resultPoint.Add(point); } } } AllPoints.Clear(); p.CloseProgress(); if (resultPoint.Count == 0) { MessageBox.Show(string.Format("{0} has no suspension point.", layer.LegendText)); } else { IFeatureSet pSet = new FeatureSet(FeatureType.Point); string[] Fields = new string[3] { "ID", "X", "Y" }; foreach (string field in Fields) { pSet.DataTable.Columns.Add(field); } int s = 0; foreach (var point in resultPoint) { IFeature pFea = pSet.AddFeature(point); pFea.DataRow[0] = s; pFea.DataRow[1] = point.X; pFea.DataRow[2] = point.Y; s++; } pSet.Projection = MainWindow.m_DotMap.Projection; pSet.Name = m_Layers[this.cboLayer.SelectedIndex].LegendText + "_suspenion points"; var feaLayer = MainWindow.m_DotMap.Layers.Add(pSet); PointSymbolizer symbol = new PointSymbolizer(System.Drawing.Color.Red, DotSpatial.Symbology.PointShape.Ellipse, 5); feaLayer.Symbolizer = symbol; MessageBox.Show(string.Format("{0} has {1} suspension point.", layer.LegendText, resultPoint.Count.ToString())); } this.Close(); }
public void UpdateProgress(string update) { ProgressBox.AppendText(update + '\n'); }
protected virtual void prepare() { stopWatch = Stopwatch.StartNew(); progressBox = new ProgressBox(); }
public static double[] ETCToPTC(double[][] Octave_ETC, double CutOffTime, int sample_frequency_in, int sample_frequency_out, double Rho_C) { int length = 4096; double[] IR = new double[(int)Math.Floor(sample_frequency_out * CutOffTime) + (int)length]; double BW = (double)sample_frequency_out / (double)sample_frequency_in; //Convert to Pressure & Interpolate full resolution IR int ct = 0; System.Threading.Semaphore S = new System.Threading.Semaphore(0, 1); S.Release(1); double[] time = new double[(int)Math.Floor(sample_frequency_out * CutOffTime) + (int)length]; double dt = 1f/(float)sample_frequency_out; for (int i = 0; i < time.Length; i++) { time[i] = i * dt; } int proc = UI.PachydermAc_PlugIn.Instance.ProcessorSpec(); double[][] output = new double[proc][]; double[][] samplep = new double[proc][]; System.Threading.Thread[] T = new System.Threading.Thread[proc]; int[] to = new int[proc]; int[] from = new int[proc]; System.Threading.CountdownEvent CDE = new System.Threading.CountdownEvent(Octave_ETC[0].Length); for (int p = 0; p < proc; p++) { output[p] = new double[length]; samplep[p] = new double[length * 2]; to[p] = p * Octave_ETC[0].Length / proc; from[p] = (p + 1) * Octave_ETC[0].Length / proc; T[p] = new System.Threading.Thread((thread) => { int thr = (int)thread; for (int t = to[thr]; t < from[thr]; t++) { ct++; double[] pr = new double[8]; for (int oct = 0; oct < 8; oct++) pr[oct] = Math.Sqrt(Octave_ETC[oct][t] * Rho_C); double sum = 0; foreach (double d in pr) sum += d; if (sum > 0) { output[thr] = Filter.Signal(pr, sample_frequency_out, 4096, thr); //Audio.Pach_SP.Raised_Cosine_Window(ref output[thr]); for (int k = 0; k < length; k++) { IR[(int)Math.Floor(t * BW) + k] += output[thr][k]; } } CDE.Signal(); } }); T[p].Start(p); } ProgressBox VB = new ProgressBox("Signal Production Progress"); VB.Show(); do { if (CDE.IsSet) { break; } VB.Populate((int)(100 * (1f - ((float)CDE.CurrentCount / (float)IR.Length)))); System.Threading.Thread.Sleep(500); } while (true); //CDE.Wait(); VB.Close(); return IR; }
protected virtual void finish() { if (stopWatch != null) { stopWatch.Stop(); stopWatch = null; } if (progressBox != null) { progressBox.Dispose(); progressBox = null; } }