Changeset 16433 for branches/2965_CancelablePersistence/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Timestamp:
- 12/21/18 14:05:46 (5 years ago)
- Location:
- branches/2965_CancelablePersistence
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2965_CancelablePersistence
- Property svn:mergeinfo changed
-
branches/2965_CancelablePersistence/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
-
branches/2965_CancelablePersistence/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r15583 r16433 24 24 using System.Drawing; 25 25 using System.Linq; 26 using System.Threading; 26 27 using System.Threading.Tasks; 27 28 using System.Windows.Forms; … … 40 41 private readonly ISymbolicDataAnalysisSolutionImpactValuesCalculator impactCalculator; 41 42 42 private readonly IProgress progress = new Progress(); 43 private readonly Progress progress = new Progress(); 44 private CancellationTokenSource cancellationTokenSource; 43 45 44 46 private enum TreeState { Valid, Invalid } … … 152 154 Content.ProblemDataChanged += Content_Changed; 153 155 treeChart.Repainted += treeChart_Repainted; 154 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(grpSimplify, progress); 156 Progress.ShowOnControl(grpSimplify, progress); 157 progress.StopRequested += progress_StopRequested; 155 158 } 156 159 protected override void DeregisterContentEvents() { … … 159 162 Content.ProblemDataChanged -= Content_Changed; 160 163 treeChart.Repainted -= treeChart_Repainted; 161 MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(grpSimplify, false); 164 Progress.HideFromControl(grpSimplify, false); 165 progress.StopRequested -= progress_StopRequested; 162 166 } 163 167 … … 178 182 } 179 183 184 private void progress_StopRequested(object sender, EventArgs e) { 185 cancellationTokenSource.Cancel(); 186 } 187 180 188 private async void UpdateView() { 181 189 if (Content == null || Content.Model == null || Content.ProblemData == null) return; … … 184 192 185 193 progress.Start("Calculate Impact and Replacement Values ..."); 194 progress.CanBeStopped = true; 195 cancellationTokenSource = new CancellationTokenSource(); 186 196 var impactAndReplacementValues = await Task.Run(() => CalculateImpactAndReplacementValues(tree)); 187 await Task.Delay(500); // wait for progressbar to finish animation 197 try { 198 await Task.Delay(500, cancellationTokenSource.Token); // wait for progressbar to finish animation 199 } catch (OperationCanceledException) { } 188 200 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 189 201 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { … … 192 204 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 193 205 progress.Finish(); 206 progress.CanBeStopped = false; 194 207 PaintNodeImpacts(); 195 208 } … … 198 211 var impactAndReplacementValues = new Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>>(); 199 212 foreach (var node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) { 213 if (progress.ProgressState == ProgressState.StopRequested) continue; 200 214 double impactValue, replacementValue, newQualityForImpactsCalculation; 201 215 impactCalculator.CalculateImpactAndReplacementValues(Content.Model, node, Content.ProblemData, Content.ProblemData.TrainingIndices, out impactValue, out replacementValue, out newQualityForImpactsCalculation); -
branches/2965_CancelablePersistence/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Plugin.cs.frame
r16309 r16433 24 24 using System.Text; 25 25 using HeuristicLab.PluginInfrastructure; 26 using System.Runtime.InteropServices; 27 using System.IO; 26 28 27 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { … … 47 49 [PluginDependency("HeuristicLab.Problems.DataAnalysis.Symbolic", "3.4")] 48 50 public class HeuristicLabProblemsDataAnalysisSymbolicViewsPlugin : PluginBase { 51 // HeuristicLab is marked with zone identifier 'Internet' after download. 52 // This propagates to all extracted files and can be checked in the file properties. 53 // IE prevents execution of MathJax JavaScript inside of untrusted html 54 // Therefore we need to programmatically unblock the displayModelFrame.html file before extracting. 55 // see http://engram404.net/programmatically-unblocking-downloaded-files/ 56 57 // for removing the Zone.Identifier alternative NTFS stream (effectively unblocking the file) 58 [DllImport("kernel32.dll", SetLastError = true)] 59 private static extern bool DeleteFile(string lpFileName); 60 61 public override void OnLoad() { 62 base.OnLoad(); 63 64 // unblock mathjax.zip () 65 DeleteFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "displayModelFrame.html:Zone.Identifier")); 66 } 49 67 } 50 68 } -
branches/2965_CancelablePersistence/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/displayModelFrame.html
r13984 r16433 7 7 <meta http-equiv="X-UA-Compatible" content="IE=edge" /> 8 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 9 <meta name="viewport" content="width=device-width, initial-scale=1" >9 <meta name="viewport" content="width=device-width, initial-scale=1" /> 10 10 11 11 <!-- title change by HEAL --> … … 46 46 <hr> 47 47 </noscript> 48 <p id="model"> 48 <p id="model">$\cos(x^2)$ 49 49 </p> 50 50 </body>
Note: See TracChangeset
for help on using the changeset viewer.