public LogEntryCounter(ObservableCollection<LogEntry> entries)
 {
     this.Entries = entries;
     Entries.CollectionChanged += Entries_CollectionChanged;
     Count = new Observable<LogEntryLevelCount>();
     Count.Value = GetCount(Entries);
 }
        private void LoadIndex(Observable<IndexDefinitionModel> observable)
        {
            var serverModel = ApplicationModel.Current.Server.Value;
            if (serverModel == null)
            {
                ApplicationModel.Current.Server.RegisterOnce(() => LoadIndex(observable));
                return;
            }

            ApplicationModel.Current.RegisterOnceForNavigation(() => LoadIndex(observable));

            var asyncDatabaseCommands = serverModel.SelectedDatabase.Value.AsyncDatabaseCommands;
            var name = ApplicationModel.Current.GetQueryParam("name");
            if (name == null)
                return;

            asyncDatabaseCommands.GetIndexAsync(name)
                .ContinueOnSuccess(index =>
                                   {
                                   	if (index == null)
                                   	{
                                   		ApplicationModel.Current.Navigate(new Uri("/DocumentNotFound?id=" + name, UriKind.Relative));
                                   		return;
                                   	}
                                   	observable.Value = new IndexDefinitionModel(index, asyncDatabaseCommands);
                                   }
                )
                .Catch();
        }
示例#3
0
		public NewDatabase()
		{
			LicensingStatus = new Observable<LicensingStatus>();
			InitializeComponent();
			var req = ApplicationModel.DatabaseCommands.ForDefaultDatabase().CreateRequest("/license/status", "GET");

			req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(doc =>
			{
				LicensingStatus.Value = ((RavenJObject)doc).Deserialize<LicensingStatus>(new DocumentConvention());
				var hasPeriodic =(bool) new BundleNameToActiveConverter().Convert(LicensingStatus.Value, typeof (bool), "PeriodicBackup",
				                                                            CultureInfo.InvariantCulture);
				if (hasPeriodic)
				{
					Bundles.Add("PeriodicBackup");
				}
			});

			
			Bundles = new List<string>();
			KeyDown += (sender, args) =>
			{
				if (args.Key == Key.Escape)
					DialogResult = false;
			};
		}
示例#4
0
		public AlertsModel()
		{
			Alerts = new ObservableCollection<AlertProxy>();
			UnobservedAlerts = new ObservableCollection<AlertProxy>();
			ServerAlerts = new ObservableCollection<Alert>();
			ShowObserved = new Observable<bool>();

			AlertsToSee = Alerts;

			ShowObserved.PropertyChanged += (sender, args) =>
			{
				AlertsToSee = ShowObserved.Value ? Alerts : UnobservedAlerts;
				OnPropertyChanged(() => AlertsToSee);
			};

			ServerAlerts.CollectionChanged += (sender, args) =>
			{
				Alerts.Clear();
				foreach (var serverAlert in ServerAlerts)
				{
					Alerts.Add(new AlertProxy(serverAlert));
				}
			};

			ShowObserved.Value = false;

			Alerts.CollectionChanged += (sender, args) => UpdateUnobserved();

			GetAlertsFromServer();

			OnPropertyChanged(() => Alerts);
		}
		static AllDocumentsModel()
		{
			Documents = new Observable<DocumentsModel>();
			Documents.Value = new DocumentsModel();
			SetTotalResults();
			ApplicationModel.Database.PropertyChanged += (sender, args) => SetTotalResults();
		}
示例#6
0
    public SettingsMenu(IEventAggregator eventAggregator)
    {
        _eventAggregator = eventAggregator;

        DisplayName = Observable("DisplayName", "Settings");
        Volume = Observable("Volume", .25f);
    }
示例#7
0
		static CollectionsModel()
		{
			Collections = new BindableCollection<CollectionModel>(model => model.Name, new KeysComparer<CollectionModel>(model => model.Count));
			SelectedCollection = new Observable<CollectionModel>();

			SelectedCollection.PropertyChanged += (sender, args) => PutCollectionNameInTheUrl();
		}
        public void ShouldBeAbleToChangeUnderlyingItemsAfterConstruction()
        {
            var item1 = new Observable<int>(1);
            var item2 = new Observable<int>(2);
            var observable = ReadOnlyObservable.Create(new[] { item1 }, x => x.Sum(y => y.Value));

            var propertyChangedCount = 0;
            observable.PropertyChanged += delegate { propertyChangedCount++; };
            observable.Configure(x =>
            {
                x.Items.Remove(item1);
                x.Items.Add(item2);
            });

            propertyChangedCount.ShouldBe(1);
            observable.Value.ShouldBe(2);

            item1.Value = 1;
            propertyChangedCount.ShouldBe(1);
            observable.Value.ShouldBe(2);

            item2.Value = 1;
            propertyChangedCount.ShouldBe(2);
            observable.Value.ShouldBe(1);
        }
		public WindowsAuthSettingsSectionModel()
		{
			SectionName = "Windows Authentication";
			Document = new Observable<WindowsAuthDocument>();
			RequiredUsers = new ObservableCollection<WindowsAuthData>();
			RequiredGroups = new ObservableCollection<WindowsAuthData>();
			SelectedList = new ObservableCollection<WindowsAuthData>();
			DatabaseSuggestionProvider = new DatabaseSuggestionProvider();
			WindowsAuthName = new WindowsAuthName();

			ApplicationModel.DatabaseCommands.ForSystemDatabase()
				.GetAsync("Raven/Authorization/WindowsSettings")
				.ContinueOnSuccessInTheUIThread(doc =>
				{
					if (doc == null)
					{
						Document.Value = new WindowsAuthDocument();
						return;
					}
					Document.Value = doc.DataAsJson.JsonDeserialization<WindowsAuthDocument>();
					RequiredUsers = new ObservableCollection<WindowsAuthData>(Document.Value.RequiredUsers);
					RequiredGroups = new ObservableCollection<WindowsAuthData>(Document.Value.RequiredGroups);
					SelectedList = RequiredUsers;
					
					OnPropertyChanged(() => Document);
					OnPropertyChanged(() => RequiredUsers);
					OnPropertyChanged(() => RequiredGroups);
				});
		}
		public PeriodicBackupSettingsSectionModel()
		{
			SectionName = "Periodic Backup";
			SelectedOption = new Observable<int>();
			ShowPeriodicBackup = new Observable<bool>();

			var req = ApplicationModel.DatabaseCommands.ForSystemDatabase().CreateRequest("/license/status".NoCache(), "GET");

			req.ReadResponseJsonAsync().ContinueOnSuccessInTheUIThread(doc =>
			{
				var licensingStatus = ((RavenJObject)doc).Deserialize<LicensingStatus>(new DocumentConvention());
				if (licensingStatus != null && licensingStatus.Attributes != null)
				{
					string active;
					if (licensingStatus.Attributes.TryGetValue("PeriodicBackup", out active) == false)
						ShowPeriodicBackup.Value = true;
					else
					{
						bool result;
						bool.TryParse(active, out result);
						ShowPeriodicBackup.Value = result;
					}

					OnPropertyChanged(() => ShowPeriodicBackup);
				}
			});
		}
        public PersonViewModel()
        {
            this.FirstName = Knockout.Observable("Matthew");
            this.LastName = Knockout.Observable("Leibowitz");
            this.FullName = Knockout.Computed(() => this.FirstName.Value + " " + this.LastName.Value);

            // AND, there is way to perform the updates to the computed object

            //var options = new DependentObservableOptions<string>();
            //options.GetValueFunction = () => self.FirstName.Value + " " + self.LastName.Value;
            //options.SetValueFunction = s =>
            //{
            //    s = s.Trim();
            //    var index = s.IndexOf(" ");
            //    if (index == -1)
            //    {
            //        self.FirstName.Value = s;
            //        self.LastName.Value = string.Empty;
            //    }
            //    else
            //    {
            //        self.FirstName.Value = s.Substring(0, index);
            //        self.LastName.Value = s.Substring(index + 1, s.Length);
            //    }
            //};
            //this.FullName = Knockout.Computed(options);
        }
 public MainWindowViewModel()
 {
     Directories = new Observable<string>(string.Empty);
     IsExecuting = new Observable<bool>();
     Candidates = new Observable<IEnumerable<DuplicateCandidateGroup>>();
     ExecuteCommand = new RelayCommand(Execute, CanExecute);
 }
示例#13
0
 protected override void CreateBindings()
 {
     checkboxBinder = AddBinding<bool>(ObservableBoolName, value => checkbox.isChecked = value);
     if (!String.IsNullOrEmpty(ObservableStringLabel)) {
         AddBinding<string>(ObservableStringLabel, value => checkboxLabel.text = value);
     }
 }
示例#14
0
        public void CanHaveManyComputeds()
        {
            var prefix = new Observable<string>("Before");

            var contacts = new ObservableList<Contact>(
                Enumerable.Range(0, 10000)
                    .Select(i => new Contact()
                    {
                        FirstName = "FirstName" + i,
                        LastName = "LastName" + i
                    }));

            var projections = new ComputedList<Projection>(() =>
                from c in contacts
                select new Projection(prefix, c));
            string dummy;
            foreach (var projection in projections)
                dummy = projection.Name;
            Assert.AreEqual("BeforeFirstName3LastName3", projections.ElementAt(3).Name);

            prefix.Value = "After";
            foreach (var projection in projections)
                dummy = projection.Name;
            Assert.AreEqual("AfterFirstName3LastName3", projections.ElementAt(3).Name);
        }
示例#15
0
        protected override void OnBeforeClientInit(Observable sender)
        {
            base.OnBeforeClientInit(sender);

            string apiKey = HttpContext.Current.Items["GMapApiKey"] as string;
            this.ScriptManager.RegisterClientScriptInclude("GMapApiKey", string.Format(this.APIBaseUrl, apiKey ?? this.APIKey));
        }
示例#16
0
		private ServerModel(string url)
		{
			this.url = url;
			Databases = new BindableCollection<DatabaseModel>(model => model.Name);
			SelectedDatabase = new Observable<DatabaseModel>();
			Initialize();
		}
 public SearchPresenter(IYearToVerseSearchService searchService, IHebrewNumberConverter hebrewNumberConverter)
 {
     this.searchService = searchService;
     this.hebrewNumberConverter = hebrewNumberConverter;
     jewishYear = new Observable<string>("5770");
     Verses = new BindableCollection<Verse>();
 }
 public LogEntryCounter(ObservableCollection<LogEntryViewModel> entries)
 {
     this.Entries = entries;
     Count = new Observable<LogEntryLevelCount>();
     Count.Value = GetCount(Entries.ToArray());
     Entries.CollectionChanged += EntriesCollectionChanged;
 }
        public void ValidValueShouldNotResultInAnyValidationErrors()
        {
            var observable = new Observable<int>();

            observable.Error.ShouldBe(string.Empty);
            observable["Value"].ShouldBe(string.Empty);
        }
        private void LoadDocument(Observable<EditableDocumentModel> observable)
        {
            var serverModel = ApplicationModel.Current.Server.Value;
            if (serverModel == null)
            {
                ApplicationModel.Current.Server.RegisterOnce(() => LoadDocument(observable));
                return;
            }

            ApplicationModel.Current.RegisterOnceForNavigation(() => LoadDocument(observable));

            var asyncDatabaseCommands = serverModel.SelectedDatabase.Value.AsyncDatabaseCommands;
            var docId = ApplicationModel.Current.GetQueryParam("id");

            if (docId == null)
                return;

            asyncDatabaseCommands.GetAsync(docId)
                .ContinueOnSuccess(document =>
                                   {
                                   	if (document == null)
                                   	{
                                   		ApplicationModel.Current.Navigate(new Uri("/DocumentNotFound?id=" + docId, UriKind.Relative));
                                   		return;
                                   	}
                                   	observable.Value = new EditableDocumentModel(document, asyncDatabaseCommands);
                                   }
                )
                .Catch();
        }
        public ContactsEditorViewModel()
        {
            SelectedContact = (Observable<ObservableContact>)ValidatedObservableFactory.ValidatedObservable(new ObservableContact());

            Contacts = new EntityDataViewModel(10, typeof(Contact),true);

            Contacts.OnSelectedRowsChanged += OnSelectedRowsChanged;
            Contacts.FetchXml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' returntotalrecordcount='true' no-lock='true' distinct='false' count='{0}' paging-cookie='{1}' page='{2}'>
                <entity name='contact'>
                    <attribute name='firstname' />
                    <attribute name='lastname' />
                    <attribute name='telephone1' />
                    <attribute name='birthdate' />
                    <attribute name='accountrolecode' />
                    <attribute name='parentcustomerid'/>
                    <attribute name='transactioncurrencyid'/>
                    <attribute name='creditlimit'/>
                    <attribute name='numberofchildren'/>
                    <attribute name='contactid' />{3}
                  </entity>
                </fetch>";

            // Register validation
            ContactValidation.Register(Contacts.ValidationBinder);
            ContactValidation.Register(new ObservableValidationBinder(this.SelectedContact));
        }
示例#22
0
		private ApplicationModel()
		{
			Notifications = new BindableCollection<Notification>(x=>x.Message);
			LastNotification = new Observable<string>();
			Server = new Observable<ServerModel> {Value = new ServerModel()};
		    State = new ApplicationState();
		}
示例#23
0
        public AllDocumentsModel()
        {
            ModelUrl = "/documents";

            Documents = new Observable<DocumentsModel>();
            Documents.Value = new DocumentsModel(GetFetchDocumentsMethod);
            Documents.Value.Pager.SetTotalResults(new Observable<long>(Database.Value.Statistics, v => ((DatabaseStatistics)v).CountOfDocuments));
        }
示例#24
0
        public void Value_passed_in_to_ctor_should_be_returned()
        {
            const string value = "test";

            var observable = new Observable<string>(value);

            Assert.AreEqual(value, observable.Value);
        }
        public void BrokenValidationRuleShouldResultInValidationError()
        {
            var errorMessage = "Value can't be zero.";
            var observable = new Observable<int>(0, x => x.Validators.Add(i => i == 0 ? errorMessage : string.Empty));

            observable.Error.ShouldBe(errorMessage);
            observable["Value"].ShouldBe(errorMessage);
        }
示例#26
0
		public Group(string groupName)
		{
			GroupName = groupName;
			Items = new ObservableCollection<GroupItem>();
			Collapse = new Observable<bool>();

			Items.CollectionChanged += (sender, args) => OnPropertyChanged("ItemCount");
		}
示例#27
0
        public void Value_should_be_implicit()
        {
            const string value = "test";
            
            var observable = new Observable<string>(value);

            Assert.AreEqual(value, observable);
        }
 public void AssigningSameValueShouldTriggerPropertyChangedEvent()
 {
     var observable = new Observable<int>(1);
     var propertyChanged = false;
     observable.PropertyChanged += (sender, args) => propertyChanged = true;
     observable.Value = 1;
     propertyChanged.ShouldBe(false);
 }
示例#29
0
            public Projection(Observable<string> prefix, Contact contact)
            {
                _prefix = prefix;
                _contact = contact;

                _name = new Computed<string>(() =>
                    prefix.Value + _contact.FirstName + _contact.LastName);
            }
 public void AssigningNewValueShouldTriggerPropertyChangedEvent()
 {
     var observable = new Observable<int>();
     var changedProperty = string.Empty;
     observable.PropertyChanged += (sender, args) => changedProperty = args.PropertyName;
     observable.Value = 1;
     changedProperty.ShouldBe("Value");
 }
		public static IObservable<EventPattern<StylusEventArgs>> LostStylusCaptureObserver(this Page This)
		{
			return Observable.FromEventPattern<StylusEventHandler, StylusEventArgs>(h => This.LostStylusCapture += h, h => This.LostStylusCapture -= h);
		}
		public static IObservable<EventPattern<StylusButtonEventArgs>> StylusButtonDownObserver(this Page This)
		{
			return Observable.FromEventPattern<StylusButtonEventHandler, StylusButtonEventArgs>(h => This.StylusButtonDown += h, h => This.StylusButtonDown -= h);
		}
		public static IObservable<EventPattern<StylusButtonEventArgs>> PreviewStylusButtonUpObserver(this Page This)
		{
			return Observable.FromEventPattern<StylusButtonEventHandler, StylusButtonEventArgs>(h => This.PreviewStylusButtonUp += h, h => This.PreviewStylusButtonUp -= h);
		}
		public static IObservable<EventPattern<GiveFeedbackEventArgs>> GiveFeedbackObserver(this Page This)
		{
			return Observable.FromEventPattern<GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h);
		}
		public static IObservable<EventPattern<StylusEventArgs>> StylusOutOfRangeObserver(this Page This)
		{
			return Observable.FromEventPattern<StylusEventHandler, StylusEventArgs>(h => This.StylusOutOfRange += h, h => This.StylusOutOfRange -= h);
		}
		public static IObservable<EventPattern<TouchEventArgs>> TouchLeaveObserver(this Page This)
		{
			return Observable.FromEventPattern<EventHandler<TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h);
		}
		public static IObservable<EventPattern<TouchEventArgs>> LostTouchCaptureObserver(this Page This)
		{
			return Observable.FromEventPattern<EventHandler<TouchEventArgs>, TouchEventArgs>(h => This.LostTouchCapture += h, h => This.LostTouchCapture -= h);
		}
		public static IObservable<EventPattern<MouseEventArgs>> MouseLeaveObserver(this Page This)
		{
			return Observable.FromEventPattern<MouseEventHandler, MouseEventArgs>(h => This.MouseLeave += h, h => This.MouseLeave -= h);
		}
		public static IObservable<EventPattern<QueryCursorEventArgs>> QueryCursorObserver(this Page This)
		{
			return Observable.FromEventPattern<QueryCursorEventHandler, QueryCursorEventArgs>(h => This.QueryCursor += h, h => This.QueryCursor -= h);
		}
		public static IObservable<EventPattern<RequestBringIntoViewEventArgs>> RequestBringIntoViewObserver(this Page This)
		{
			return Observable.FromEventPattern<RequestBringIntoViewEventHandler, RequestBringIntoViewEventArgs>(h => This.RequestBringIntoView += h, h => This.RequestBringIntoView -= h);
		}
		public static IObservable<EventPattern<DragEventArgs>> PreviewDragLeaveObserver(this Page This)
		{
			return Observable.FromEventPattern<DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h);
		}
		public static IObservable<EventPattern<StylusSystemGestureEventArgs>> StylusSystemGestureObserver(this Page This)
		{
			return Observable.FromEventPattern<StylusSystemGestureEventHandler, StylusSystemGestureEventArgs>(h => This.StylusSystemGesture += h, h => This.StylusSystemGesture -= h);
		}
		public static IObservable<EventPattern<DependencyPropertyChangedEventArgs>> DataContextChangedObserver(this Page This)
		{
			return Observable.FromEventPattern<DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.DataContextChanged += h, h => This.DataContextChanged -= h);
		}
		public static IObservable<EventPattern<StylusEventArgs>> PreviewStylusInAirMoveObserver(this Page This)
		{
			return Observable.FromEventPattern<StylusEventHandler, StylusEventArgs>(h => This.PreviewStylusInAirMove += h, h => This.PreviewStylusInAirMove -= h);
		}
		public static IObservable<EventPattern<QueryContinueDragEventArgs>> QueryContinueDragObserver(this Page This)
		{
			return Observable.FromEventPattern<QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h);
		}
		public static IObservable<EventPattern<KeyboardFocusChangedEventArgs>> LostKeyboardFocusObserver(this Page This)
		{
			return Observable.FromEventPattern<KeyboardFocusChangedEventHandler, KeyboardFocusChangedEventArgs>(h => This.LostKeyboardFocus += h, h => This.LostKeyboardFocus -= h);
		}
		public static IObservable<EventPattern<TextCompositionEventArgs>> TextInputObserver(this Page This)
		{
			return Observable.FromEventPattern<TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h);
		}
		public static IObservable<EventPattern<SizeChangedEventArgs>> SizeChangedObserver(this Page This)
		{
			return Observable.FromEventPattern<SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h);
		}
		public static IObservable<EventPattern<DataTransferEventArgs>> SourceUpdatedObserver(this Page This)
		{
			return Observable.FromEventPattern<EventHandler<DataTransferEventArgs>, DataTransferEventArgs>(h => This.SourceUpdated += h, h => This.SourceUpdated -= h);
		}
		public static IObservable<EventPattern<KeyEventArgs>> PreviewKeyDownObserver(this Page This)
		{
			return Observable.FromEventPattern<KeyEventHandler, KeyEventArgs>(h => This.PreviewKeyDown += h, h => This.PreviewKeyDown -= h);
		}
		public static IObservable<EventPattern<MouseEventArgs>> GotMouseCaptureObserver(this Page This)
		{
			return Observable.FromEventPattern<MouseEventHandler, MouseEventArgs>(h => This.GotMouseCapture += h, h => This.GotMouseCapture -= h);
		}
		public static IObservable<EventPattern<KeyEventArgs>> KeyUpObserver(this Page This)
		{
			return Observable.FromEventPattern<KeyEventHandler, KeyEventArgs>(h => This.KeyUp += h, h => This.KeyUp -= h);
		}
		public static IObservable<EventPattern<MouseButtonEventArgs>> MouseRightButtonUpObserver(this Page This)
		{
			return Observable.FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseRightButtonUp += h, h => This.MouseRightButtonUp -= h);
		}
 void Start()
 {
     Observable.Throw <string>(new Exception("error"))
     .Subscribe(_ => Debug.Log("不会输出"), e => Debug.LogFormat("发现异常:{0}", e.Message));
 }
示例#55
0
 public IObservable <Unit> SoftDelete(IThreadSafeTimeEntry timeEntry)
 => Observable.Return(timeEntry)
 .Select(TimeEntry.DirtyDeleted)
 .SelectMany(Repository.Update)
 .Do(entity => DeletedSubject.OnNext(entity.Id))
 .Select(_ => Unit.Default);
		public static IObservable<EventPattern<MouseWheelEventArgs>> PreviewMouseWheelObserver(this Page This)
		{
			return Observable.FromEventPattern<MouseWheelEventHandler, MouseWheelEventArgs>(h => This.PreviewMouseWheel += h, h => This.PreviewMouseWheel -= h);
		}
		public static IObservable<EventPattern<EventArgs>> InitializedObserver(this Page This)
		{
			return Observable.FromEventPattern<EventHandler, EventArgs>(h => This.Initialized += h, h => This.Initialized -= h);
		}
		public static IObservable<EventPattern<TouchEventArgs>> PreviewTouchUpObserver(this Page This)
		{
			return Observable.FromEventPattern<EventHandler<TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h);
		}
		public static IObservable<EventPattern<DragEventArgs>> DropObserver(this Page This)
		{
			return Observable.FromEventPattern<DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h);
		}
示例#60
0
 public void push_totitle_button()
 {
     Observable.Timer(TimeSpan.FromSeconds(0.5)).Subscribe(_ =>
                                                           push_totitle_button_2()
                                                           );
 }