Esempio n. 1
0
        /// <summary>
        /// Add child nodes during expansion 
        /// </summary>
        private void Expand()
        {
            int foundChildren = 10;

            // report progress
            expandStatus.ReportProgress(0, foundChildren, "Loading Sample children...");

            // find results
            for (int child = 1; child < foundChildren; child++)
            {
                // The Thread.Sleep statement below is for demo purposes only. When doing your 
                // development you should not block your snap-in thread to service an 
                // async request like OnExpand unless you only use the scope tree and 
                // list view and never show any WinForms views or WinForms property pages.  
                // The reason is that your WinForms views and property pages will be blocked, 
                // and in certain cases that can also block MMC.  

                // sleep for a second
                Thread.Sleep(1000);

                // New scope nodes must be created on the snapin's thread
                DelegateWithNode delegateWithNode = new DelegateWithNode(AddChildNode);
                this.SnapIn.BeginInvoke(delegateWithNode, new object[] {this});

                // update the progress
                expandStatus.ReportProgress(child, foundChildren, "Loading Sample children...");
            }

            // update progress
            expandStatus.Complete("Loading Sample complete.", true);
        }
Esempio n. 2
0
        /// <summary>
        /// Node plus sign clicked to expand the node. Load in children.
        /// </summary>
        /// <param name="status">asynchronous status for updating the console</param>
        protected override void OnExpand(AsyncStatus status)
        {
            int foundChildren = 10;

            // report progress
            status.ReportProgress(0, foundChildren, "Loading Sample children...");

            // find results
            for (int child = 1; child < foundChildren; child++)
            {
                // The Thread.Sleep statement below is for demo purposes only. When doing your 
                // development you should not block your snap-in thread to service an 
                // async request like OnExpand unless you only use the scope tree and 
                // list view and never show any WinForms views or WinForms property pages.  
                // The reason is that your WinForms views and property pages will be blocked, 
                // and in certain cases that can also block MMC.  

                // Sleep for a second.
                Thread.Sleep(1000);

                // add the child 
                ScopeNode childNode = new StatusNode();
                childNode.DisplayName = "Added " + System.DateTime.Now.ToLongTimeString();
                this.Children.Add(childNode);

                // update the progress
                status.ReportProgress(child, foundChildren, "Loading Sample children...");
            }

            // update progress
            status.Complete("Loading Sample complete.", true);
        }
Esempio n. 3
0
 public CollectionObserver(ScopeNode parent, AsyncStatus status, Func <TModel, ScopeNode> mapper)
 {
     _snapIn   = parent.SnapIn;
     _children = parent.Children;
     _status   = status;
     _mapper   = mapper;
     _status.ReportProgress(0, 0, "Fetching...");
 }
Esempio n. 4
0
 public SingleObserver(ScopeNode parent, AsyncStatus status, Func <TModel, ScopeNode[]> builder)
 {
     _snapIn   = parent.SnapIn;
     _children = parent.Children;
     _status   = status;
     _builder  = builder;
     _status.ReportProgress(0, 0, "Fetching...");
 }
Esempio n. 5
0
        /// <summary>
        /// Load in any saved data
        /// </summary>
        /// <param name="status">asynchronous status for updating the console</param>
        /// <param name="persistenceData">binary data stored in the console file</param>
        protected override void OnLoadCustomData(AsyncStatus status, byte[] persistenceData)
        {
            status.ReportProgress(0, 10, "Loading..");

            // Deserialize the object
            try
            {
                MemoryStream    stream       = new MemoryStream(persistenceData);
                BinaryFormatter deserializer = new BinaryFormatter();
                mgrConfig.SetInitData((InitialisationData)deserializer.Deserialize(stream));

                // Initialise the config object
                mgrConfig.Initialise();

                // Load the CA data into the root node
                ((OSCAroot)RootNode).Load();

                status.Complete("Manager configuration: " + mgrConfig.InitData.configFile, true);
            }
            catch (SerializationException)
            {
                MessageBox.Show("No configuration data defined", "OSCA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 6
0
 public void OnNext(TModel[] models)
 {
     _snapIn.BeginInvoke((Action <TModel[]>)AddChildren, new object[] { models });
     _status.ReportProgress(0, 0, "Loading...");
 }