示例#1
0
        public void UpdateObject(int index, IWipeObject wipeObject)
        {
            Debug.AssertNotNull(wipeObject, "WipeObject is null");

            try {
                string[] itemStrings = new string[5];
                long fileSize = 0;
                int imageIndex = 0;

                if(wipeObject.Type == WipeObjectType.File) {
                    FileWipeObject file = (FileWipeObject)wipeObject;

                    try {
                        itemStrings[0] = Path.GetFileNameWithoutExtension(file.Path);
                        itemStrings[1] = Path.GetExtension(file.Path).ToLower();
                        itemStrings[4] = file.Path;
                        FileInfo info = new FileInfo(file.Path);

                        if(info.Length < 1024) {
                            itemStrings[2] = ((int)info.Length).ToString() + " B";
                        }
                        else {
                            itemStrings[2] = ((int)(info.Length / 1024)).ToString() + " KB";
                        }

                        fileSize = info.Length;
                        itemStrings[3] = info.CreationTime.ToString();
                    }
                    catch { }

                    // update the icon
                    imageIndex = 0;
                }
                else if(wipeObject.Type == WipeObjectType.Folder) {
                    FolderWipeObject folder = (FolderWipeObject)wipeObject;

                    try {
                        DirectoryInfo info = new DirectoryInfo(folder.Path);
                        itemStrings[0] = info.Name;
                        itemStrings[3] = info.CreationTime.ToString();
                        itemStrings[4] = folder.Path;
                    }
                    catch {
                        if(itemStrings[0] == null) {
                            itemStrings[0] = "FOLDER NOT FOUND";
                        }
                    }

                    // update the icon
                    imageIndex = 1;
                }
                else if(wipeObject.Type == WipeObjectType.Drive) {
                    DriveWipeObject drive = (DriveWipeObject)wipeObject;

                    try {
                        itemStrings[0] = "Free space ";

                        if(drive.Drives != null && drive.Drives.Count > 0) {
                            for(int i = 0; i < drive.Drives.Count; i++) {
                                itemStrings[0] += drive.Drives[i] + " ";
                            }
                        }
                    }
                    catch { }

                    imageIndex = 2;
                }
                else if(wipeObject.Type == WipeObjectType.Plugin) {
                    itemStrings[0] = "Plugins";
                    imageIndex = 3;
                }

                // update
                if(index == ObjectList.Items.Count) {
                    // add a new ListViewItem
                    ListViewItem item = ObjectList.Items.Add(new ListViewItem(itemStrings, imageIndex));
                    item.SubItems[2].Tag = fileSize;
                    item.Tag = wipeObject;
                }
                else {
                    ListViewItem item = ObjectList.Items[index];
                    item.SubItems.Clear();
                    item.Text = itemStrings[0];
                    item.SubItems.Add(itemStrings[1]);
                    item.SubItems.Add(itemStrings[2]);
                    item.SubItems.Add(itemStrings[3]);
                    item.SubItems.Add(itemStrings[4]);
                    item.SubItems[2].Tag = fileSize;
                    item.Tag = wipeObject;
                }

                if(_scheduleMode) {
                    SaveButton.Enabled = true;
                }
            }
            catch(Exception e) {
                Debug.ReportError("Error while generating WipeObject category member. Exception: {0}", e.Message);
            }
        }
示例#2
0
        private bool SendSingleWipeObject(IWipeObject item)
        {
            Debug.AssertNotNull(item, "Item is null");

            bool result = false;
            activeObject = item;

            if(item.SingleObject) {
                result = context.InsertObject(item.GetObject());
            }
            else {
                result = context.InserObjectRange(item.GetObjects());
            }

            // reset active object
            activeObject = null;
            return result;
        }
示例#3
0
        public void InsertObject(IWipeObject wipeObject)
        {
            Debug.AssertNotNull(wipeObject, "WipeObject is null");

            UpdateObject(ObjectList.Items.Count, wipeObject);
            HandleItemNumber();
        }