Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.mediaCenter.ItemManager.Root.SetProgressBar += (val) =>
- {
- this.Invoke((Action)(() =>
- {
- this.progressBarControl1.Position = val;
- }));
- };
- private ItemContainerRoot _myRoot;
- public ItemContainerRoot Root
- {
- get { return this._myRoot; }
- }
- this._myRoot = context.GetTable<Item>().Single(a => a.Id == 0) as ItemContainerRoot;
- class ItemManager : INotifyPropertyChanged
- {
- private ItemContainerRoot _myRoot;
- public ItemContainerRoot Root
- {
- get { return _myRoot; }
- set
- {
- _myRoot = value;
- OnPropertyChanged("Root");
- }
- }
- public event PropertyChangedEventHandler PropertyChanged;
- protected virtual void OnPropertyChanged(string propertyName)
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if (handler != null)
- {
- handler(this, new PropertyChangedEventArgs(propertyName));
- }
- }
- }
- ItemManager.PropertyChanged += (o, args) =>
- {
- if (args.PropertyName == "Root" && ItemManager.Root != null)
- {
- ItemManager.Root.SetProgressBar += (val) =>
- {
- this.Invoke((Action)(() =>
- {
- this.progressBarControl1.Position = val;
- }));
- };
- }
- };
- private Action _myRootDisconnect = null;
- private object _myRootGate = new object();
- private ItemContainerRoot _myRoot;
- public ItemContainerRoot Root
- {
- get { return _myRoot; }
- set
- {
- lock (_myRootGate)
- {
- Action<int> setProgressBar = val =>
- {
- this.Invoke((Action)(() =>
- {
- this.progressBarControl1.Position = val;
- }));
- };
- if (_myRootDisconnect != null)
- {
- _myRootDisconnect();
- _myRootDisconnect = null;
- }
- _myRoot = value;
- _myRoot.SetProgressBar += setProgressBar;
- _myRootDisconnect = () =>
- {
- _myRoot.SetProgressBar -= setProgressBar;
- };
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement