void VisualCanvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Released || NewCanvasItem == null) { return; } if (IsDragStart) { CurrentMousePoint = e.GetPosition(sender as IInputElement); Debug.WriteLine(CurrentMousePoint); var x = Math.Min(CurrentMousePoint.X, StartMousePoint.X); var y = Math.Min(CurrentMousePoint.Y, StartMousePoint.Y); var width = Math.Max(CurrentMousePoint.X, StartMousePoint.X) - x; var height = Math.Max(CurrentMousePoint.Y, StartMousePoint.Y) - y; NewCanvasItem.SetCurrentValue(FrameworkElement.WidthProperty, width); NewCanvasItem.SetCurrentValue(FrameworkElement.HeightProperty, height); Canvas.SetLeft(NewCanvasItem, x); Canvas.SetTop(NewCanvasItem, y); IEditableCollectionViewAddNewItem items = this.Items; items.CommitEdit(); } }
private void Button_Click(object sender, RoutedEventArgs e) { IEditableCollectionViewAddNewItem viewToAddDisparateItems = catalogList.Items as IEditableCollectionViewAddNewItem; if (!viewToAddDisparateItems.CanAddNewItem) { MessageBox.Show("You cannot add items to the list."); return; } // Create a window that prompts the user to enter a new // item to sell. AddItemWindow win = new AddItemWindow(); // Create an item, depending on which RadioButton is selected. // Radio buttons correspond to book, cd, dvd, or other. LibraryItem newItem; if ((bool)book.IsChecked) { newItem = new Book("Enter the book title", "Enter an Author", "Enter a Genre", "Enter a call number", DateTime.Now + new TimeSpan(21, 0, 0, 0)); } else if ((bool)cd.IsChecked) { newItem = new MusicCD("Enter the Album", "Enter the artist", 0, "CD.******", DateTime.Now + new TimeSpan(14, 0, 0, 0)); } else if ((bool)dvd.IsChecked) { newItem = new MovieDVD("Enter the movie title", "Enter the director", "Enter the genre", new TimeSpan(), "DVD.******", DateTime.Now + new TimeSpan(7, 0, 0, 0)); } else { newItem = new LibraryItem("Enter the title", "Enter the call number", DateTime.Now + new TimeSpan(14, 0, 0, 0)); } // Add the new item to the collection by calling // IEditableCollectionViewAddNewItem.AddNewItem. // Set the DataContext of the AddItemWindow to the // returned item. win.DataContext = viewToAddDisparateItems.AddNewItem(newItem); // If the user submits the new item, commit the new // object to the collection. If the user cancels // adding the new item, discard the new item. if ((bool)win.ShowDialog()) { viewToAddDisparateItems.CommitNew(); } else { viewToAddDisparateItems.CancelNew(); } }
private async void Window_Loaded(object sender, RoutedEventArgs e) { _uow = SmObjectFactory.Container.GetInstance <Saina.Data.Context.SainaDbContext>(); typeDocumentIdComboBox.ItemsSource = await _uow.TypeDocuments.ToListAsync(); _virtualQueryableCollectionView = new QueryableCollectionView(_uow.AccDocumentHeaders.ToList()); //new VirtualQueryableCollectionView(_uow.AccDocumentHeaders.OrderByDescending(x => x.AccDocumentHeaderId)) { LoadSize = 10 }; mainGrid.DataContext = _virtualQueryableCollectionView; }
/// <summary> /// Add a new item to the underlying collection. Returns the new item. /// After calling AddNewItem and changing the new item as desired, either /// <seealso cref="IEditableCollectionView.CommitNew"/> or <seealso cref="IEditableCollectionView.CancelNew"/> should be /// called to complete the transaction. /// </summary> object IEditableCollectionViewAddNewItem.AddNewItem(object newItem) { IEditableCollectionViewAddNewItem ani = ProxiedView as IEditableCollectionViewAddNewItem; if (ani != null) { return(ani.AddNewItem(newItem)); } else { throw new InvalidOperationException(SR.Get(SRID.MemberNotAllowedForView, "AddNewItem")); } }
private void ItemsLoaded() { using (var uow = new SainaDbContext()) { Items = new QueryableCollectionView(uow.ProductRacks.ToList()); } //ProductRack root = new ProductRack(); //root.ProductRackTitle = "Personal Folders"; //root.ImageUrl = "../../Images/ContextMenu/Outlook/1PersonalFolders.png"; //root.IsExpanded = true; //this.Items.Add(root); }
// Token: 0x06007417 RID: 29719 RVA: 0x002130E4 File Offset: 0x002112E4 object IEditableCollectionViewAddNewItem.AddNewItem(object newItem) { IEditableCollectionViewAddNewItem editableCollectionViewAddNewItem = this.ProxiedView as IEditableCollectionViewAddNewItem; if (editableCollectionViewAddNewItem != null) { return(editableCollectionViewAddNewItem.AddNewItem(newItem)); } throw new InvalidOperationException(SR.Get("MemberNotAllowedForView", new object[] { "AddNewItem" })); }
public async void Initialize(IServicePool servicePool) { _sessionService = servicePool.GetService <ISessionService>(); this.AddCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteAddCommand); this.EditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteEditCommand); this.OkCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteOkCommand); this.CancelEditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelEditCommand); this.DeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteDeleteCommand); this.CancelDeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelDeleteCommand); this.IsBusy = true; _speakerList = await _sessionService.GetSpeakerListAsync(); _speakerList.Insert(0, new Speaker { Id = 0, Name = " " }); this.SpeakersView = new ListCollectionView(_speakerList); var trackList = await _sessionService.GetTrackListAsync(); _uiTrackList = new List <UITrack>(); foreach (var track in trackList) { var uiTrack = new UITrack(track); _uiTrackList.Add(uiTrack); uiTrack.PropertyChanged += this.OnUITrackPropertyChanged; } this.TracksView = new ListCollectionView(_uiTrackList); var sessionTypeList = await _sessionService.GetSessionTypesAsync(); this.SessionTypesView = new ListCollectionView(sessionTypeList); this.Sessions = await _sessionService.GetSessionListAsync(); this.SessionsView = new ListCollectionView(this.Sessions); this.SessionsView.CurrentChanged += this.OnCurrentSessionChanged; this.SessionsView.CurrentChanging += this.OnCurrentSessionChanging; _editView = this.SessionsView as IEditableCollectionViewAddNewItem; if (this.SessionsView.CurrentItem != null) { this.SetCurrentSession(this.SessionsView.CurrentItem as SessionDto); } this.IsBusy = false; }
void VisualCanvas_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (IsEditable) { Mouse.Capture(this, CaptureMode.SubTree); this.IsDragStart = true; IEditableCollectionViewAddNewItem items = this.Items; StartMousePoint = e.GetPosition(sender as IInputElement); Debug.WriteLine(StartMousePoint); if (items.CanAddNewItem) { NewItem = items.AddNew(); items.CommitNew(); Canvas.SetLeft(NewCanvasItem, StartMousePoint.X); Canvas.SetTop(NewCanvasItem, StartMousePoint.Y); } } }
private void button3_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog openFileDialog2 = new Microsoft.Win32.OpenFileDialog(); openFileDialog2.ShowReadOnly = true; openFileDialog2.Multiselect = true; openFileDialog2.Title = "Select file names to copy after a scenario run"; if (openFileDialog2.ShowDialog().Value) { IEditableCollectionViewAddNewItem items = listBox2.Items; if (items.CanAddNewItem) { foreach (var fi in openFileDialog2.FileNames) { items.AddNewItem(fi); } } } }
void VisualCanvas_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (IsDragStart) { IsDragStart = false; if (MinItemWidth != Double.NaN && (Double)NewCanvasItem.GetValue(FrameworkElement.WidthProperty) < MinItemWidth) { NewCanvasItem.SetCurrentValue(FrameworkElement.WidthProperty, MinItemWidth); } if (MinItemHeight != Double.NaN && (Double)NewCanvasItem.GetValue(FrameworkElement.HeightProperty) < MinItemHeight) { NewCanvasItem.SetCurrentValue(FrameworkElement.HeightProperty, MinItemHeight); } IEditableCollectionViewAddNewItem items = this.Items; items.CommitEdit(); NewItem = null; NewCanvasItem = null; e.Handled = true; Mouse.Capture(this, CaptureMode.None); } }
public async void Initialize(IServicePool servicePool) { _sessionService = servicePool.GetService<ISessionService>(); this.AddCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteAddCommand); this.EditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteEditCommand); this.OkCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteOkCommand); this.CancelEditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelEditCommand); this.DeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteDeleteCommand); this.CancelDeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelDeleteCommand); this.IsBusy = true; this.Speakers = await _sessionService.GetSpeakerListAsync(); this.SpeakersView = new ListCollectionView(this.Speakers); this.SpeakersView.CurrentChanging += this.OnCurrentSpeakerChanging; this.SpeakersView.CurrentChanged += this.OnCurrentSpeakerChanged; _editView = this.SpeakersView as IEditableCollectionViewAddNewItem; this.OnCurrentSpeakerChanged(null, EventArgs.Empty); this.IsBusy = false; }
public async void Initialize(IServicePool servicePool) { _sessionService = servicePool.GetService<ISessionService>(); this.AddCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteAddCommand); this.EditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteEditCommand); this.OkCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteOkCommand); this.CancelEditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelEditCommand); this.DeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteDeleteCommand); this.CancelDeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelDeleteCommand); this.IsBusy = true; _speakerList = await _sessionService.GetSpeakerListAsync(); _speakerList.Insert(0, new Speaker { Id = 0, Name = " " }); this.SpeakersView = new ListCollectionView(_speakerList); var trackList = await _sessionService.GetTrackListAsync(); _uiTrackList = new List<UITrack>(); foreach (var track in trackList) { var uiTrack = new UITrack(track); _uiTrackList.Add(uiTrack); uiTrack.PropertyChanged += this.OnUITrackPropertyChanged; } this.TracksView = new ListCollectionView(_uiTrackList); var sessionTypeList = await _sessionService.GetSessionTypesAsync(); this.SessionTypesView = new ListCollectionView(sessionTypeList); this.Sessions = await _sessionService.GetSessionListAsync(); this.SessionsView = new ListCollectionView(this.Sessions); this.SessionsView.CurrentChanged += this.OnCurrentSessionChanged; this.SessionsView.CurrentChanging += this.OnCurrentSessionChanging; _editView = this.SessionsView as IEditableCollectionViewAddNewItem; if (this.SessionsView.CurrentItem != null) this.SetCurrentSession(this.SessionsView.CurrentItem as SessionDto); this.IsBusy = false; }
public async void Initialize(IServicePool servicePool) { _sessionService = servicePool.GetService <ISessionService>(); this.AddCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteAddCommand); this.EditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteEditCommand); this.OkCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteOkCommand); this.CancelEditCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelEditCommand); this.DeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteDeleteCommand); this.CancelDeleteCommand = new DelegateCommand(p => !this.IsBusy, this.ExecuteCancelDeleteCommand); this.IsBusy = true; this.Speakers = await _sessionService.GetSpeakerListAsync(); this.SpeakersView = new ListCollectionView(this.Speakers); this.SpeakersView.CurrentChanging += this.OnCurrentSpeakerChanging; this.SpeakersView.CurrentChanged += this.OnCurrentSpeakerChanged; _editView = this.SpeakersView as IEditableCollectionViewAddNewItem; this.OnCurrentSpeakerChanged(null, EventArgs.Empty); this.IsBusy = false; }
public void Loaded() { _uow = new SainaDbContext(); Products = new QueryableCollectionView(_uow.Products.ToList()); }