コード例 #1
0
        public SystemFolder(int objectId) : base(objectId)
        {
            ClientMarketData.SystemFolderRow systemFolderRow = ClientMarketData.SystemFolder.FindBySystemFolderId(objectId);

            // These images are used to display the object in TreeViews, Properties Pages, etc.
            System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();

            // 16x16 Image
            SystemFolder.image16x16 =
                new Bitmap(assembly.GetManifestResourceStream("MarkThree.Guardian.SystemFolder 16x16.png"));
            SystemFolder.image16x16.Tag = string.Format("{0}.{1}", typeof(SystemFolder).FullName, "16x16");

            // 16x16 SelectedImage
            SystemFolder.selectedImage16x16 =
                new Bitmap(assembly.GetManifestResourceStream("MarkThree.Guardian.SystemFolder 16x16.png"));
            SystemFolder.selectedImage16x16.Tag = string.Format("{0}.{1}.{2}", typeof(SystemFolder).FullName, "16x16", "Selected");

            // 32x23 Image
            SystemFolder.image32x32 =
                new Bitmap(assembly.GetManifestResourceStream("MarkThree.Guardian.SystemFolder 32x32.png"));
            SystemFolder.image32x32.Tag = string.Format("{0}.{1}", typeof(SystemFolder).FullName, "32x32");

            // 32x32 SelectedImage
            SystemFolder.selectedImage32x32 =
                new Bitmap(assembly.GetManifestResourceStream("MarkThree.Guardian.SystemFolder 32x32.png"));
            SystemFolder.selectedImage32x32.Tag = string.Format("{0}.{1}.{2}", typeof(SystemFolder).FullName, "32x32", "Selected");

            // Start the application off by opening up the start page.
            string onOpenText = ConfigurationManager.AppSettings["OnOpen"];

            if (onOpenText != null)
            {
                string[] onOpenArguments = onOpenText.Split(new char[] { ',' });
                this.Url = onOpenArguments[2].Trim();
            }
        }
コード例 #2
0
        /// <summary>
        /// This procedure is used to update the TreeView control from the background.
        /// </summary>
        private void FolderListThread(object parameter)
        {
            // This node acts as the root that we'll use to build the tree folder list tree.  It will eventually be passed back to
            // the message loop thread and into the TreeView control.
            TreeNode rootNode = new TreeNode();

            // This will hold the set of images associated with the objects in the tree.  It is also passed to the foreground where
            // it is used to generate the ImageList that holds the images for this TreeView.  The images in this list are
            // associated with the nodes in the view through the image tag, which serves as a unique identifier for the images.
            ArrayList images = new ArrayList();

            // The user identifier drives the selection of items for the navigation tree.  The top level item will be the system
            // folder(s) assigned to this user.  But before the tree can be constructed, we need to know what user is currently
            // logged in.
            int userId = Preferences.UserId;

            try
            {
                // Lock all the tables that we'll reference while building a blotter document.
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
                ClientMarketData.BlotterLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.FolderLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.ObjectLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.ObjectTreeLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.SystemFolderLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.TypeLock.AcquireReaderLock(CommonTimeout.LockWait);
                ClientMarketData.UserLock.AcquireReaderLock(CommonTimeout.LockWait);

                // Build the hierarchy by recursing into all the children of the user's folder.
                ClientMarketData.UserRow userRow = ClientMarketData.User.FindByUserId(userId);
                if (userRow != null && !userRow.IsSystemFolderIdNull())
                {
                    ClientMarketData.SystemFolderRow systemFolderRow =
                        ClientMarketData.SystemFolder.FindBySystemFolderId(userRow.SystemFolderId);
                    rootNode.Nodes.Add(CreateTreeNode(images, systemFolderRow.FolderRow.ObjectRow));
                }
            }
            catch (Exception exception)
            {
                // Catch the most general error and send it to the debug console.
                EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace);
            }
            finally
            {
                // Release the tables used to build the folder list.
                if (ClientMarketData.BlotterLock.IsReaderLockHeld)
                {
                    ClientMarketData.BlotterLock.ReleaseReaderLock();
                }
                if (ClientMarketData.FolderLock.IsReaderLockHeld)
                {
                    ClientMarketData.FolderLock.ReleaseReaderLock();
                }
                if (ClientMarketData.ObjectLock.IsReaderLockHeld)
                {
                    ClientMarketData.ObjectLock.ReleaseReaderLock();
                }
                if (ClientMarketData.ObjectTreeLock.IsReaderLockHeld)
                {
                    ClientMarketData.ObjectTreeLock.ReleaseReaderLock();
                }
                if (ClientMarketData.SystemFolderLock.IsReaderLockHeld)
                {
                    ClientMarketData.SystemFolderLock.ReleaseReaderLock();
                }
                if (ClientMarketData.TypeLock.IsReaderLockHeld)
                {
                    ClientMarketData.TypeLock.ReleaseReaderLock();
                }
                if (ClientMarketData.UserLock.IsReaderLockHeld)
                {
                    ClientMarketData.UserLock.ReleaseReaderLock();
                }
                System.Diagnostics.Debug.Assert(!ClientMarketData.IsLocked);
            }

            // At this point, the tree is complete.  Pass the tree to the foreground for drawing.
            Invoke(new TreeNodeDelegate(UpdateTree), new object[] { rootNode, images });
        }