Ignore:
Timestamp:
Dec 14, 2008, 7:30:57 PM (13 years ago)
Author:
Thomas Schmid
Message:
  • fixed plugin selection after workspace loading
  • fixed message text when opening presentation
  • fixed double plugin unselect call
  • added file and filesize message to FileInput
Location:
trunk/CrypPlugins/FileInput
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/FileInput/FileInput.cs

    r4 r151  
    244244      {
    245245        fileInputPresentation.OpenFile(settings.OpenFilename);
     246        GuiLogMessage("Opened file: " + settings.OpenFilename + " " + FileHelper.FilesizeReadable(settings.OpenFilename), NotificationLevel.Info);
    246247      }
    247248      else if (e.PropertyName == "OpenFilename" && settings.OpenFilename == null)
     
    287288    }
    288289
    289     /* TODO:
    290      *
    291      * removed due to converter memory exeptions when using large files
    292      * stream2byte should be done using an separate converter.
    293      *
    294     [PropertyInfo(Direction.Output, "ByteArray Output", "Selected file as byteArray.", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Hex, null)]
    295     public byte[] ByteOutput
    296     {
    297       get
    298       {
    299         try
    300         {
    301           if (File.Exists(settings.OpenFilename))
    302           {
    303             Progress(0.5, 1.0);
    304             FileStream tempStream = FileHelper.GetFileStreamReadOnly(settings.OpenFilename);
    305             byte[] returnValue = StreamHelper.ReadFully(tempStream, Math.Min(MAX_BYTE_ARRAY_SIZE, System.Convert.ToInt32(tempStream.Length)));
    306             tempStream.Close();
    307             Progress(1.0, 1.0);
    308             return returnValue;
    309           }
    310           return null;
    311         }
    312         catch (Exception exception)
    313         {
    314           GuiLogMessage(exception.Message, NotificationLevel.Error);
    315           return null;
    316         }
    317       }
    318       set { } // readonly
    319     }
    320     */
    321 
    322290    #endregion
    323291
  • trunk/CrypPlugins/FileInput/Helper/FileHelper.cs

    r4 r151  
    265265      {
    266266        FileInfo fi = new FileInfo(filename);
    267         return fi.Length / 1024 / 1024;
     267        return fi.Length;
    268268      }
    269269      else return 0;
    270270    }
    271271
     272    public static string FilesizeReadable(string filename)
     273    {
     274      double size = Filesize(filename);
     275      if (size > 1073741824)
     276      {
     277        return string.Format("{0:##.##}", size / 1024 / 1024 / 1024) + " GB";
     278      }
     279      else if (size > 1048576)
     280      {
     281        return string.Format("{0:##.##}", size / 1024 / 1024) + " MB";
     282      }
     283      else if (size > 1024)
     284      {
     285        return string.Format("{0:##.##}", size / 1024) + " KB";
     286      }
     287      else if (size > 0)
     288      {
     289        return string.Format("{0:##.##}", size) + " Byte";
     290      }
     291      return string.Empty;
     292    }
    272293
    273294    public static string OpenFile()
Note: See TracChangeset for help on using the changeset viewer.