Beispiel #1
0
        void GenerateCode()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(GenerateCode));
                return;
            }

            if (op != null)
            {
                op.Cancel();
                cancellation.Cancel();
            }

            if (Model == null)
            {
                view.Clear();
            }
            else
            {
                cancellation = new CancellationTokenSource();
                var state = new RunState(Model.Definition, App.Languages.ActiveLanguage, cancellation.Token);
                op = new ResponsiveOperation <CodeViewData>(state.Run);
                op.LoadingThreshold = 50;
                op.Completed       += OnCompleted;
                op.Loading         += OnLoading;
                op.Begin();
            }
        }
Beispiel #2
0
		void SetChildren(object sender, OperationResultEventArgs<ICollection<IDataModel>> e) {
			lock (sync) {
				if (e.Result.Count > 0x200) {
					using (Children.BeginUpdate()) {
						Children.Clear();
						Children.Add(new Loading());
					}
				}
				using (Children.BeginUpdate()) {
					Children.Clear();
					foreach (var child in e.Result)
						Children.Add(child);
				}
				loadOp = null;
			}
		}
Beispiel #3
0
		public ResponsiveOperation<ICollection<IDataModel>> Load() {
			if (loadOp != null)
				return loadOp;

			lock (sync) {
				if (loadOp != null || (Children.Count == 0 || Children[0] != NullModel.Instance))
					return loadOp;
			}

			loadOp = new ResponsiveOperation<ICollection<IDataModel>>(PopulateChildrenInternal);
			loadOp.Loading += (sender, e) => {
				using (Children.BeginUpdate()) {
					Children.Clear();
					Children.Add(new Loading());
				}
			};
			loadOp.Completed += SetChildren;

			return loadOp;
		}
Beispiel #4
0
 void OnCompleted(object sender, OperationResultEventArgs <CodeViewData> e)
 {
     view.SetData(e.Result);
     op           = null;
     cancellation = null;
 }