Beispiel #1
0
        public void LockInterface(bool lockIt)
        {
            bool lockInterface = false;

            foreach (InternalRootObject obj in this.mVolumeListView.Objects)
            {
                if (obj.IsBusy)
                {
                    lockInterface = true;
                    break;
                }
            }

            mInterfaceLockedOverride = lockIt;
            mInterfaceLocked         = lockInterface || mInterfaceLockedOverride;

            if (mSelectedObject != null)
            {
                mVolumeListView.UncheckObject(mSelectedObject);
            }
            mSelectedObject = null;
            mVolumeListView_SelectedIndexChanged(null, null);

            mBackupAllNowButton.Enabled = !mInterfaceLocked;
            mAddVolumeButton.Enabled    = !mInterfaceLocked;
        }
Beispiel #2
0
        public void Reset()
        {
            mObjectList.Clear();

            // Add active volumes
            foreach (VolumeDescriptor desc in VolumeDescriptorList.Instance.Descriptors)
            {
                if (desc.IsAvailable)
                {
                    bool isUsbDevice = desc.Volume.Source.VolumeType == VolumeType.UsbDevice;
                    mObjectList.Add(new InternalRootObject(desc, isUsbDevice ? mIconIndex : mFolderIconIndex, isUsbDevice ? mBusyIconIndex : mFolderBusyIconIndex, ""));
                }
                else
                {
                    mObjectList.Add(new InternalRootObject(desc, mNullIconIndex, mNullIconIndex, desc.VolumeName));
                }
            }

            mVolumeListView.SetObjects(mObjectList);

            if (mSelectedObject != null)
            {
                mVolumeListView.UncheckObject(mSelectedObject);
            }
            mSelectedObject = null;
            mVolumeListView_SelectedIndexChanged(null, null);

            mVolumeListView.Refresh();
        }
Beispiel #3
0
 public override bool Equals(object obj)
 {
     if (obj is InternalRootObject)
     {
         InternalRootObject lvo = (InternalRootObject)obj;
         return(lvo.mVolumeDescriptor.Equals(this.mVolumeDescriptor));
     }
     return(false);
 }
Beispiel #4
0
 public override int CompareTo(object obj)
 {
     if (obj is WelcomeListView)
     {
         InternalRootObject lvo = (InternalRootObject)obj;
         return(string.Compare(lvo.mVolumeDescriptor.VolumeName, this.mVolumeDescriptor.VolumeName, true));
     }
     else
     {
         return(1);
     }
 }
Beispiel #5
0
        public void SetVolumeAsBusy(VolumeDescriptor vid, bool busy)
        {
            InternalRootObject rootObj = FindRootObject(vid);

            if (rootObj != null)
            {
                if (rootObj.IsBusy && !busy)
                {
                    rootObj.Dirty = true;                     // operation has just finished, contents may have changed
                }
                rootObj.IsBusy    = busy;
                rootObj.IsChecked = false;

//				Log.WriteLine( "Setting " + rootObj.VolumeIdentifier.Name + " to " + ( busy ? "busy" : "not busy" ) );
                this.mVolumeListView.RefreshObject(rootObj);
            }

            LockInterface(mInterfaceLockedOverride);
        }
Beispiel #6
0
        CheckState CheckStateSetterMethod(object x, CheckState checkState)
        {
            InternalRootObject oldObject = mSelectedObject;

            mSelectedObject = checkState == CheckState.Checked ? ( InternalRootObject )x : null;

            if (mVolumeListView.SelectedObject == null || !mVolumeListView.SelectedObject.Equals(mSelectedObject))
            {
                mVolumeListView.Focus();
                mVolumeListView.SelectedObject = mSelectedObject;
            }

            mVolumeListView.RefreshObject(oldObject);
            mVolumeListView.RefreshObject(mSelectedObject);

            UpdateButtonStates();

            return(checkState);
        }
Beispiel #7
0
        public WelcomeListView()
        {
            InitializeComponent();

            MainForm.Instance.EventController.VolumeNeedsRefreshing += new VolumeDescriptorChangedHandler(EventController_VolumeDescriptorActiveChanged);

            this.mVolumeListView.EmptyListMsg = "Press 'Add' to set up a new backup volume";

            mFileImageListTreeViewHelper = new FileImageListViewHelper(mColumn, mImageList);

            mColumn.AspectName = "Name";

            mStatusColumn.Text         = "Status";
            mStatusColumn.Width        = 100;
            mStatusColumn.TextAlign    = HorizontalAlignment.Left;
            mStatusColumn.AspectGetter = delegate(object modelObject)
            {
                InternalRootObject rootObject = (( InternalRootObject )modelObject);
                return(rootObject.VolumeDescriptor.StateString);
            };

            mLastBackupColumn.Text         = "Last backup";
            mLastBackupColumn.Width        = 100;
            mLastBackupColumn.TextAlign    = HorizontalAlignment.Center;
            mLastBackupColumn.AspectGetter = delegate(object modelObject)
            {
                InternalRootObject rootObject = (( InternalRootObject )modelObject);
                if (rootObject.VolumeDescriptor != null && rootObject.VolumeDescriptor.IsAvailable)
                {
                    if (rootObject.VolumeDescriptor.Volume != null && rootObject.VolumeDescriptor.Volume.BackupInProgress)
                    {
                        return("In Progress");
                    }
                    else
                    {
                        return(rootObject.VolumeDescriptor.LastAttemptedBackupFuzzyString);
                    }
                }
                else
                {
                    return("");
                }
            };

            mPathColumn.Text         = "Path";
            mPathColumn.Width        = 180;
            mPathColumn.TextAlign    = HorizontalAlignment.Left;
            mPathColumn.AspectGetter = delegate(object modelObject)
            {
                InternalRootObject rootObject = (( InternalRootObject )modelObject);
                if (rootObject.VolumeDescriptor != null && rootObject.VolumeDescriptor.IsAvailable)
                {
                    return(rootObject.VolumeDescriptor.Volume.Source.GetOnDiskPath(""));
                }
                else
                {
                    return("");
                }
            };

            mSizeOnDiskColumn.Text  = "Size on disk";
            mSizeOnDiskColumn.Width = 80;

            mSizeOnDiskColumn.TextAlign    = HorizontalAlignment.Center;
            mSizeOnDiskColumn.AspectGetter = delegate(object modelObject)
            {
                InternalRootObject rootObject = (( InternalRootObject )modelObject);
                return(rootObject.VolumeDescriptor != null && rootObject.VolumeDescriptor.IsAvailable ? rootObject.VolumeDescriptor.TotalDatabaseSizeString : "");
            };

            mRevisionsAvailableColumn.Text         = "Revisions";
            mRevisionsAvailableColumn.Width        = 60;
            mRevisionsAvailableColumn.TextAlign    = HorizontalAlignment.Center;
            mRevisionsAvailableColumn.AspectGetter = delegate(object modelObject)
            {
                InternalRootObject rootObject = (( InternalRootObject )modelObject);
                return(rootObject.VolumeDescriptor != null && rootObject.VolumeDescriptor.IsAvailable ? rootObject.VolumeDescriptor.Volume.Database.GetRevisionHistory().Count.ToString() : "");
            };

            mVolumeListView.Columns.Add(mStatusColumn);
            mVolumeListView.Columns.Add(mLastBackupColumn);
            mVolumeListView.Columns.Add(mPathColumn);
            mVolumeListView.Columns.Add(mSizeOnDiskColumn);
            mVolumeListView.Columns.Add(mRevisionsAvailableColumn);

            mVolumeListView.SelectedIndexChanged += new EventHandler(mVolumeListView_SelectedIndexChanged);

            mVolumeListView.CustomSorter = new BrightIdeasSoftware.SortDelegate(CustomSortHandler);

            System.Reflection.Assembly assem = System.Reflection.Assembly.GetEntryAssembly();

//			System.Diagnostics.Debug.WriteLine( string.Join( ", ", assem.GetManifestResourceNames() ) );

            CreateIcon(assem, "AutoUSBBackup.Resources.pendrive32x32.png", out mIconIndex, out mIcon);
            CreateIcon(assem, "AutoUSBBackup.Resources.pendrivebusy32x32.png", out mBusyIconIndex, out mBusyIcon);
            CreateIcon(assem, "AutoUSBBackup.Resources.localfolder32x32.png", out mFolderIconIndex, out mFolderIcon);
            CreateIcon(assem, "AutoUSBBackup.Resources.localfolderbusy32x32.png", out mFolderBusyIconIndex, out mFolderBusyIcon);
            CreateIcon(assem, "", out mNullIconIndex, out mNullIcon);

            mVolumeListView.LargeImageList       = mImageList;
            mVolumeListView.SmallImageList       = mImageList;
            mVolumeListView.ShowImagesOnSubItems = true;

            mButtonOptions.Visible = false;

            MainForm.Instance.EventController.BackupFinished += new VolumeBackupHandler(Spine_BackupFinished);

            mVolumeListView.CheckStateGetter = new BrightIdeasSoftware.CheckStateGetterDelegate(CheckStateGetterMethod);
            mVolumeListView.CheckStatePutter = new BrightIdeasSoftware.CheckStatePutterDelegate(CheckStateSetterMethod);
        }
        CheckState CheckStateSetterMethod( object x, CheckState checkState )
        {
            InternalRootObject oldObject = mSelectedObject;
            mSelectedObject = checkState == CheckState.Checked ? ( InternalRootObject )x : null;

            if ( mVolumeListView.SelectedObject == null || !mVolumeListView.SelectedObject.Equals( mSelectedObject ) )
            {
                mVolumeListView.Focus();
                mVolumeListView.SelectedObject = mSelectedObject;
            }

            mVolumeListView.RefreshObject( oldObject );
            mVolumeListView.RefreshObject( mSelectedObject );

            UpdateButtonStates();

            return checkState;
        }
        public void Reset()
        {
            mObjectList.Clear();

            // Add active volumes
            foreach ( VolumeDescriptor desc in VolumeDescriptorList.Instance.Descriptors )
            {
                if ( desc.IsAvailable )
                {
                    bool isUsbDevice = desc.Volume.Source.VolumeType == VolumeType.UsbDevice;
                    mObjectList.Add( new InternalRootObject( desc, isUsbDevice ? mIconIndex : mFolderIconIndex, isUsbDevice ? mBusyIconIndex : mFolderBusyIconIndex, "" ) );
                }
                else
                {
                    mObjectList.Add( new InternalRootObject( desc, mNullIconIndex, mNullIconIndex, desc.VolumeName ) );
                }
            }

            mVolumeListView.SetObjects( mObjectList );

            if ( mSelectedObject != null )
                mVolumeListView.UncheckObject( mSelectedObject );
            mSelectedObject = null;
            mVolumeListView_SelectedIndexChanged( null, null );

            mVolumeListView.Refresh();
        }
        public void LockInterface( bool lockIt )
        {
            bool lockInterface = false;
            foreach ( InternalRootObject obj in this.mVolumeListView.Objects )
            {
                if ( obj.IsBusy )
                {
                    lockInterface = true;
                    break;
                }
            }

            mInterfaceLockedOverride = lockIt;
            mInterfaceLocked = lockInterface || mInterfaceLockedOverride;

            if ( mSelectedObject != null )
                mVolumeListView.UncheckObject( mSelectedObject );
            mSelectedObject = null;
            mVolumeListView_SelectedIndexChanged( null, null );

            mBackupAllNowButton.Enabled = !mInterfaceLocked;
            mAddVolumeButton.Enabled = !mInterfaceLocked;
        }