コード例 #1
0
ファイル: VisualCanvas.cs プロジェクト: tablesmit/Yuhan
        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();
            }
        }
コード例 #2
0
ファイル: window1.xaml.cs プロジェクト: yashbajra/samples
        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();
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        /// <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"));
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        // 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"
            }));
        }
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: VisualCanvas.cs プロジェクト: tablesmit/Yuhan
 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);
         }
     }
 }
コード例 #9
0
        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);
                    }
                }
            }
        }
コード例 #10
0
ファイル: VisualCanvas.cs プロジェクト: tablesmit/Yuhan
 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);
     }
 }
コード例 #11
0
        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;
        }
コード例 #12
0
        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;
        }
コード例 #13
0
        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;
        }
コード例 #14
0
        public void Loaded()
        {
            _uow = new SainaDbContext();

            Products = new QueryableCollectionView(_uow.Products.ToList());
        }