Пример #1
0
        private void InitControls()
        {
            if (!this.useSourceConnector)
            {
                int increaseHeight = this.sourceDbProfile.Height;
                this.sourceDbProfile.Visible = false;
                this.btnCompare.Height       = this.targetDbProfile.ClientHeight;
                this.targetDbProfile.Top    -= increaseHeight;
                this.splitContainer1.Top    -= increaseHeight;
                this.splitContainer1.Height += increaseHeight;
            }

            this.colType.ImageGetter = delegate(object x)
            {
                DbDifference difference = x as DbDifference;

                if (difference.DatabaseObjectType == DatabaseObjectType.None)
                {
                    return("tree_Folder.png");
                }
                else
                {
                    return($"tree_{difference.DatabaseObjectType}.png");
                }
            };

            TreeRenderer treeColumnRenderer = this.tlvDifferences.TreeColumnRenderer;

            treeColumnRenderer.IsShowGlyphs = true;
            treeColumnRenderer.UseTriangles = true;

            TreeRenderer renderer = this.tlvDifferences.TreeColumnRenderer;

            renderer.LinePen           = new Pen(Color.LightGray, 0.5f);
            renderer.LinePen.DashStyle = DashStyle.Dot;

            FlagRenderer differenceTypeRenderer = new FlagRenderer();

            differenceTypeRenderer.ImageList = this.imageList2;
            differenceTypeRenderer.Add(DbDifferenceType.Added, "Add.png");
            differenceTypeRenderer.Add(DbDifferenceType.Modified, "Edit.png");
            differenceTypeRenderer.Add(DbDifferenceType.Deleted, "Remove.png");

            this.colChangeType.Renderer = differenceTypeRenderer;

            this.colChangeType.ClusteringStrategy = new FlagClusteringStrategy(typeof(DbDifferenceType));

            this.tlvDifferences.Refresh();
        }
Пример #2
0
        private void SetupColumns()
        {
            // Get the size of the file system entity.
            // Folders and errors are represented as negative numbers
            this.olvColumnSize.AspectGetter = delegate(object x) {
                if (x is DirectoryInfo)
                {
                    return((long)-1);
                }

                try {
                    return(((FileInfo)x).Length);
                }
                catch (System.IO.FileNotFoundException) {
                    // Mono 1.2.6 throws this for hidden files
                    return((long)-2);
                }
            };

            // Show the size of files as GB, MB and KBs. By returning the actual
            // size in the AspectGetter, and doing the conversion in the
            // AspectToStringConverter, sorting on this column will work off the
            // actual sizes, rather than the formatted string.
            this.olvColumnSize.AspectToStringConverter = delegate(object x) {
                long sizeInBytes = (long)x;
                if (sizeInBytes < 0) // folder or error
                {
                    return("");
                }
                return(Coordinator.FormatFileSize(sizeInBytes));
            };
            this.olvColumnSize.MakeGroupies(new long[] { 0, 1024 * 1024, 512 * 1024 * 1024 },
                                            new string[] { "Folders", "Small", "Big", "Disk space chewer" });

            // Group by month-year, rather than date
            // This code is duplicated for FileCreated and FileModified, so we really should
            // create named methods rather than using anonymous delegates.
            this.olvColumnCreated.GroupKeyGetter = delegate(object x) {
                DateTime dt = ((FileSystemInfo)x).CreationTime;
                return(new DateTime(dt.Year, dt.Month, 1));
            };
            this.olvColumnCreated.GroupKeyToTitleConverter = delegate(object x) {
                return(((DateTime)x).ToString("MMMM yyyy"));
            };

            // Group by month-year, rather than date
            this.olvColumnModified.GroupKeyGetter = delegate(object x) {
                DateTime dt = ((FileSystemInfo)x).LastWriteTime;
                return(new DateTime(dt.Year, dt.Month, 1));
            };
            this.olvColumnModified.GroupKeyToTitleConverter = delegate(object x) {
                return(((DateTime)x).ToString("MMMM yyyy"));
            };

            // Show the system description for this object
            this.olvColumnFileType.AspectGetter = delegate(object x) {
                return(ShellUtilities.GetFileType(((FileSystemInfo)x).FullName));
            };

            // Show the file attributes for this object
            // A FlagRenderer masks off various values and draws zero or more images based
            // on the presence of individual bits.
            this.olvColumnAttributes.AspectGetter = delegate(object x) {
                return(((FileSystemInfo)x).Attributes);
            };
            FlagRenderer attributesRenderer = new FlagRenderer();

            attributesRenderer.ImageList = imageList1;
            attributesRenderer.Add(FileAttributes.Archive, "archive");
            attributesRenderer.Add(FileAttributes.ReadOnly, "readonly");
            attributesRenderer.Add(FileAttributes.System, "system");
            attributesRenderer.Add(FileAttributes.Hidden, "hidden");
            attributesRenderer.Add(FileAttributes.Temporary, "temporary");
            this.olvColumnAttributes.Renderer = attributesRenderer;

            // Tell the filtering subsystem that the attributes column is a collection of flags
            this.olvColumnAttributes.ClusteringStrategy = new FlagClusteringStrategy(typeof(FileAttributes));
        }
Пример #3
0
        void InitializeTreeListExample()
        {
            this.treeListView.HierarchicalCheckboxes = true;
            this.treeListView.HideSelection          = false;
            this.treeListView.CanExpandGetter        = delegate(object x) {
                return(((MyFileSystemInfo)x).IsDirectory);
            };
            this.treeListView.ChildrenGetter = delegate(object x) {
                MyFileSystemInfo myFileSystemInfo = (MyFileSystemInfo)x;
                try
                {
                    return(myFileSystemInfo.GetFileSystemInfos());
                }
                catch (UnauthorizedAccessException ex)
                {
                    MessageBox.Show(this, ex.Message, "ObjectListViewDemo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(new ArrayList());
                }
            };

            // You can change the way the connection lines are drawn by changing the pen
            TreeListView.TreeRenderer renderer = this.treeListView.TreeColumnRenderer;
            renderer.LinePen           = new Pen(Color.Firebrick, 0.5f);
            renderer.LinePen.DashStyle = DashStyle.Dot;

            //-------------------------------------------------------------------
            // Eveything after this is the same as the Explorer example tab --
            // nothing specific to the TreeListView. It doesn't have the grouping
            // delegates, since TreeListViews can't show groups.

            // Draw the system icon next to the name
            SysImageListHelper helper = new SysImageListHelper(this.treeListView);

            this.colName.ImageGetter = delegate(object x) {
                return(helper.GetImageIndex(((MyFileSystemInfo)x).FullName));
            };

            // Show the size of files as GB, MB and KBs. Also, group them by
            // some meaningless divisions
            this.colSize.AspectGetter = delegate(object x) {
                MyFileSystemInfo myFileSystemInfo = (MyFileSystemInfo)x;

                if (myFileSystemInfo.IsDirectory)
                {
                    return((long)-1);
                }

                try
                {
                    return(myFileSystemInfo.Length);
                }
                catch (System.IO.FileNotFoundException)
                {
                    // Mono 1.2.6 throws this for hidden files
                    return((long)-2);
                }
            };
            this.colSize.AspectToStringConverter = delegate(object x) {
                if ((long)x == -1) // folder
                {
                    return("");
                }

                return(FormatFileSize((long)x));
            };

            // Show the system description for this object
            this.colType.AspectGetter = delegate(object x) {
                return(ShellUtilities.GetFileType(((MyFileSystemInfo)x).FullName));
            };

            // Show the file attributes for this object
            this.colAttrs.AspectGetter = delegate(object x) {
                return(((MyFileSystemInfo)x).Attributes);
            };
            FlagRenderer attributesRenderer = new FlagRenderer();

            attributesRenderer.Add(FileAttributes.Archive, "archive");
            attributesRenderer.Add(FileAttributes.ReadOnly, "readonly");
            attributesRenderer.Add(FileAttributes.System, "system");
            attributesRenderer.Add(FileAttributes.Hidden, "hidden");
            attributesRenderer.Add(FileAttributes.Temporary, "temporary");
            this.colAttrs.Renderer           = attributesRenderer;
            this.colAttrs.ClusteringStrategy = new FlagClusteringStrategy(typeof(FileAttributes));

            // List all drives as the roots of the tree
            ArrayList roots = new ArrayList();

            foreach (DriveInfo di in DriveInfo.GetDrives())
            {
                if (di.IsReady)
                {
                    roots.Add(new MyFileSystemInfo(new DirectoryInfo(di.Name)));
                    break;
                }
            }
            this.treeListView.Roots = roots;
        }
Пример #4
0
        private void SetupColumns()
        {
            // The column setup here is identical to the File Explorer example tab --
            // nothing specific to the TreeListView.

            // The only difference is that we don't setup anything to do with grouping,
            // since TreeListViews can't show groups.

            SysImageListHelper helper = new SysImageListHelper(this.treeListView);

            this.olvColumnName.ImageGetter = delegate(object x) {
                return(helper.GetImageIndex(((MyFileSystemInfo)x).FullName));
            };

            // Get the size of the file system entity.
            // Folders and errors are represented as negative numbers
            this.olvColumnSize.AspectGetter = delegate(object x) {
                MyFileSystemInfo myFileSystemInfo = (MyFileSystemInfo)x;

                if (myFileSystemInfo.IsDirectory)
                {
                    return((long)-1);
                }

                try {
                    return(myFileSystemInfo.Length);
                }
                catch (System.IO.FileNotFoundException) {
                    // Mono 1.2.6 throws this for hidden files
                    return((long)-2);
                }
            };

            // Show the size of files as GB, MB and KBs. By returning the actual
            // size in the AspectGetter, and doing the conversion in the
            // AspectToStringConverter, sorting on this column will work off the
            // actual sizes, rather than the formatted string.
            this.olvColumnSize.AspectToStringConverter = delegate(object x) {
                long sizeInBytes = (long)x;
                if (sizeInBytes < 0) // folder or error
                {
                    return("");
                }
                return(Coordinator.FormatFileSize(sizeInBytes));
            };

            // Show the system description for this object
            this.olvColumnFileType.AspectGetter = delegate(object x) {
                return(ShellUtilities.GetFileType(((MyFileSystemInfo)x).FullName));
            };

            // Show the file attributes for this object
            // A FlagRenderer masks off various values and draws zero or images based
            // on the presence of individual bits.
            this.olvColumnAttributes.AspectGetter = delegate(object x) {
                return(((MyFileSystemInfo)x).Attributes);
            };
            FlagRenderer attributesRenderer = new FlagRenderer();

            attributesRenderer.ImageList = imageListSmall;
            attributesRenderer.Add(FileAttributes.Archive, "archive");
            attributesRenderer.Add(FileAttributes.ReadOnly, "readonly");
            attributesRenderer.Add(FileAttributes.System, "system");
            attributesRenderer.Add(FileAttributes.Hidden, "hidden");
            attributesRenderer.Add(FileAttributes.Temporary, "temporary");
            this.olvColumnAttributes.Renderer = attributesRenderer;

            // Tell the filtering subsystem that the attributes column is a collection of flags
            this.olvColumnAttributes.ClusteringStrategy = new FlagClusteringStrategy(typeof(FileAttributes));
        }
Пример #5
0
        void InitializeTreeListExample()
        {
            //TreeListViewItem it = new TreeListViewItem("Deepak");
            //it.SubItems.Add("Rupam");
            //treeListView2.Items.Add(it);

            this.treeListView.CanExpandGetter = delegate(object x)
            {
                return(x is DirectoryInfo);
            };
            this.treeListView.ChildrenGetter = delegate(object x)
            {
                DirectoryInfo dir = (DirectoryInfo)x;
                //dir.GetFileSystemInfos().
                return(new ArrayList(dir.GetFileSystemInfos()));
            };

            this.treeListView.CheckBoxes = true;

            // You can change the way the connection lines are drawn by changing the pen
            //((TreeListView.TreeRenderer)this.treeListView.TreeColumnRenderer).LinePen = Pens.Firebrick;
            // ((TreeListView.TreeRenderer)this.treeListView.TreeColumnRenderer).LinePen.Color = Color.Black;
            //((TreeListView.TreeRenderer)this.treeListView.TreeColumnRenderer).LinePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //-------------------------------------------------------------------
            // Eveything after this is the same as the Explorer example tab --
            // nothing specific to the TreeListView. It doesn't have the grouping
            // delegates, since TreeListViews can't show groups.

/*           // Draw the system icon next to the name
 #if !MONO
 *          SysImageListHelper helper = new SysImageListHelper(this.treeListView);
 *          this.treeColumnName.ImageGetter = delegate(object x)
 *          {
 *              return helper.GetImageIndex(((FileSystemInfo)x).FullName);
 *          };
 #endif
 */         // Show the size of files as GB, MB and KBs. Also, group them by
            // some meaningless divisions
            this.treeColumnSize.AspectGetter = delegate(object x)
            {
                if (x is DirectoryInfo)
                {
                    return((long)-1);
                }

                try
                {
                    return(((FileInfo)x).Length);
                }
                catch (System.IO.FileNotFoundException)
                {
                    // Mono 1.2.6 throws this for hidden files
                    return((long)-2);
                }
            };
            this.treeColumnSize.AspectToStringConverter = delegate(object x)
            {
                if ((long)x == -1) // folder
                {
                    return("");
                }
                else
                {
                    //return this.FormatFileSize((long)x);
                    return((string)"Deepak");
                }
            };

            // Show the system description for this object
            this.treeColumnFileType.AspectGetter = delegate(object x)
            {
                //return ShellUtilities.GetFileType(((FileSystemInfo)x).FullName);
                return("Jagruti");
            };

            // Show the file attributes for this object
            this.treeColumnAttributes.AspectGetter = delegate(object x)
            {
                return(((FileSystemInfo)x).Attributes);
            };
            FlagRenderer <FileAttributes> attributesRenderer = new FlagRenderer <FileAttributes>();

            attributesRenderer.Add(FileAttributes.Archive, "archive");
            attributesRenderer.Add(FileAttributes.ReadOnly, "readonly");
            attributesRenderer.Add(FileAttributes.System, "system");
            attributesRenderer.Add(FileAttributes.Hidden, "hidden");
            attributesRenderer.Add(FileAttributes.Temporary, "temporary");
            this.treeColumnAttributes.Renderer = attributesRenderer;

            // List all drives as the roots of the tree
            ArrayList roots = new ArrayList();

            foreach (DriveInfo di in DriveInfo.GetDrives())
            {
                if (di.IsReady)
                {
                    roots.Add(new DirectoryInfo(di.Name));
                }
            }
            this.treeListView.Roots = roots;
            this.treeListView.CellEditActivation = ObjectListView.CellEditActivateMode.F2Only;
        }