Changeset 975


Ignore:
Timestamp:
Dec 10, 2009, 2:32:26 PM (12 years ago)
Author:
Matthäus Wander
Message:

CrypPluginBase:

  • centralized directory pathes to static DirectoryHelper
  • adapted Enigma and QuadraticSieve to use tempdir pathes from DirectoryHelper

BooleanOperators:

  • surrounded broken UI code snippet with Dispatcher call

Gate:

  • removed broken sample
Location:
trunk
Files:
1 added
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPluginBase/CrypPluginBase.csproj

    r948 r975  
    6464    <Compile Include="Control\IControlCost.cs" />
    6565    <Compile Include="Control\IControlEncryption.cs" />
     66    <Compile Include="IO\DirectoryHelper.cs" />
    6667    <Compile Include="Miscellaneous\DataManager.cs" />
    6768    <Compile Include="IApplication.cs" />
     
    8788      <SubType>Code</SubType>
    8889    </Compile>
    89     <Compile Include="Miscellaneous\PluginResource.cs" />
    9090    <Compile Include="Miscellaneous\Tokenizer.cs" />
    9191    <Compile Include="PluginExtension.cs" />
  • trunk/CrypPluginBase/IO/CryptoolStream.cs

    r947 r975  
    2222    public class CryptoolStream : Stream
    2323    {
    24         private const string TempDirectoryName = "CrypTool Temp Files";
    2524        private const string TempFileExtension = "csf";
    2625
    27         private static readonly string directoryName;
    2826        private string fileName;
    2927        private FileStream fileStream;
    3028        private bool isReadOnly;
    31 
    32         static CryptoolStream()
    33         {
    34           directoryName = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), TempDirectoryName), Guid.NewGuid().ToString());
    35           if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);
    36         }
    37 
    38         public static string TemporaryDirectoryName
    39         {
    40             get { return directoryName; }
    41         }
    4229
    4330        public string FileName
     
    11299          try
    113100          {
    114             this.fileName = Path.Combine(directoryName, Guid.NewGuid() + "." + TempFileExtension);
     101            if (!Directory.Exists(DirectoryHelper.DirectoryLocalTemp)) Directory.CreateDirectory(DirectoryHelper.DirectoryLocalTemp);
     102
     103            this.fileName = DirectoryHelper.GetNewTempFilePath(TempFileExtension);
    115104            this.fileStream = new FileStream(this.fileName, FileMode.CreateNew);
    116105
     
    179168            else
    180169            {
    181                 this.fileName = Path.Combine(directoryName, Guid.NewGuid() + "." + TempFileExtension);
     170                if (!Directory.Exists(DirectoryHelper.DirectoryLocalTemp)) Directory.CreateDirectory(DirectoryHelper.DirectoryLocalTemp);
     171
     172                this.fileName = DirectoryHelper.GetNewTempFilePath(TempFileExtension);
    182173                this.fileStream = new FileStream(this.fileName, FileMode.CreateNew);
    183174            }
     
    242233        public static void CleanTempFiles()
    243234        {
    244             foreach (FileInfo fInfo in new DirectoryInfo(directoryName).GetFiles("*." + TempFileExtension))
     235            foreach (FileInfo fInfo in new DirectoryInfo(DirectoryHelper.DirectoryLocalTemp).GetFiles("*." + TempFileExtension))
    245236            {
    246237              fInfo.Delete();
     
    251242        {
    252243          CleanTempFiles();
    253           Directory.Delete(directoryName);
     244          Directory.Delete(DirectoryHelper.DirectoryLocalTemp);
    254245        }
    255246
  • trunk/CrypPlugins/BooleanOperators/ButtonInputPresentation.xaml.cs

    r765 r975  
    1212using System.Windows.Navigation;
    1313using System.Windows.Shapes;
     14using System.Windows.Threading;
     15using System.Threading;
    1416
    1517namespace BooleanOperators
     
    3638        public void update()
    3739        {
    38             try
    39             { 
     40            Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     41            {
    4042                this.myButton.Content = Value;
    4143                if (Value)
     
    4345                else
    4446                { this.myButton.Background = Brushes.Tomato; }
    45             }
    46             catch { }
     47            }, null);
    4748        }
    4849        public void ExecuteThisMethodWhenButtonIsClicked(object sender, EventArgs e)
  • trunk/CrypPlugins/Enigma/Enigma.cs

    r945 r975  
    212212            Dictionary<string, double[]> grams = new Dictionary<string, double[]>();
    213213
    214             StreamReader reader = new StreamReader(Path.Combine(PluginResource.directoryPath, GetStatisticsFilename(length)));
     214            StreamReader reader = new StreamReader(Path.Combine(DirectoryHelper.DirectoryCrypPlugins, GetStatisticsFilename(length)));
    215215
    216216            string line;
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSieve.cs

    r755 r975  
    4646        #region private variables
    4747
    48         private const string TempDirectoryName = "CrypTool Temp Files";
    49         private static readonly string directoryName;
     48        private readonly string directoryName;
    5049        private QuadraticSieveSettings settings = new QuadraticSieveSettings();
    5150        private BigInteger inputNumber;
     
    8281        static QuadraticSieve()
    8382        {
    84             directoryName = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), TempDirectoryName), "msieve");
    85             if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);
    86 
    8783            //Load msieve.dll:
    8884            string s = Directory.GetCurrentDirectory();
     
    105101        public QuadraticSieve()
    106102        {
     103            directoryName = Path.Combine(DirectoryHelper.DirectoryLocalTemp, "msieve");
     104            if (!Directory.Exists(directoryName)) Directory.CreateDirectory(directoryName);
     105
    107106            QuickWatchPresentation = new QuadraticSievePresentation();
    108107           
Note: See TracChangeset for help on using the changeset viewer.