Exemplo n.º 1
0
        /// <summary>
        /// registers various property listeners
        /// </summary>
        private void registerListeners()
        {
            try
            {
                if (refreshPagePropertiesTimer != null)
                {
                    refreshPagePropertiesTimer.Stop(); refreshPagePropertiesTimer.Dispose();
                }
                refreshPagePropertiesTimer = new System.Timers.Timer(5000);
                XPropertySet pageProperties = DrawPage as XPropertySet;
                if (pageProperties != null)
                {
                    //Debug.PrintAllProperties(pageProperties);

                    onRefreshPage(this, null);

                    pageProperties.addPropertyChangeListener("Orientation", eventForwarder);
                    pageProperties.addVetoableChangeListener("Orientation", eventForwarder);

                    pageProperties.addPropertyChangeListener("", eventForwarder);

                    refreshPagePropertiesTimer.Elapsed += new System.Timers.ElapsedEventHandler(onRefreshPage);

                    // start the refresh timer with some delay so not all pages will update their properties at the same time!
                    Task t = new Task(new Action(() =>
                    {
                        Thread.Sleep(rnd.Next(1000));
                        refreshPagePropertiesTimer.Start();
                    }));
                    t.Start();

                    //eventForwarder.Modified += eventForwarder_Modified;
                    //eventForwarder.NotifyEvent += eventForwarder_NotifyEvent;
                    //eventForwarder.PropertiesChange += eventForwarder_PropertiesChange;
                    //eventForwarder.PropertyChange += eventForwarder_PropertyChange;
                    //eventForwarder.VetoableChange += eventForwarder_VetoableChange;
                }
                XMultiPropertySet pageMultiProperties = (XMultiPropertySet)DrawPage;
                if (pageMultiProperties != null)
                {
                    pageMultiProperties.addPropertiesChangeListener(new string[] { }, eventForwarder);
                }
            }
            catch (DisposedException) { ((IDisposable)this).Dispose(); }
            catch (Exception) { }
        }