private void LoadShip()
        {
            if (ID == 0)
            {
                var Query = from n in db.StammZahlungsbedingungen
                            select n;

                ViewSource.Source = new ZahlungsbedingungCollection(Query, db);
                View           = (ListCollectionView)ViewSource.View;
                ZBView         = (BindingListCollectionView)ZBViewSource.View;
                ZBSprachenView = (BindingListCollectionView)ZB_SprachenViewSource.View;
                var i = (StammZahlungsbedingungen)View.AddNew();
                // i.name = "schiff Neu";
                View.CommitNew();
                bNew = true;
                this.ZahlungsbedingungenSprachenGrid.IsEnabled = false;
            }
            else
            {
                var Query = from n in db.StammZahlungsbedingungen
                            where n.id == ID
                            select n;

                ViewSource.Source = Query;
                ZBView            = (BindingListCollectionView)ZBViewSource.View;
                ZBSprachenView    = (BindingListCollectionView)ZB_SprachenViewSource.View;
            }
        }
Ejemplo n.º 2
0
        public void AddBet(Bet newBet)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke(new dAddBet(AddBet), newBet);
            }
            else
            {
                //if (Bets.CanRemove)
                while (Bets.Count > UISettings.Settings.LiveBets + 1)
                {
                    //System.Threading.Thread.Sleep(10);
                    //Bets.Remove(Bets.list);
                    Bets.RemoveAt(Bets.Count - 1);
                }

                Bets.AddNewItem(newBet as DiceBet);
                Bets.CommitNew();
                //if (!fitted)
                {
                    tvBets.BestFitColumns();
                    fitted = true;
                }
            }
        }
Ejemplo n.º 3
0
        private void LoadShip()
        {
            if (ID == 0)
            {
                var Query = from n in db.schiffe
                            select n;

                ViewSource.Source = new SchiffCollection(Query, db);
                View          = (ListCollectionView)ViewSource.View;
                AggregateView = (BindingListCollectionView)AggregateViewSource.View;
                var i = (schiff)View.AddNew();
                // i.name = "schiff Neu";
                View.CommitNew();
                bNew = true;
            }
            else
            {
                var Query = from n in db.schiffe
                            where n.id == ID
                            select n;

                ViewSource.Source = Query;
                AggregateView     = (BindingListCollectionView)AggregateViewSource.View;
            }
        }
Ejemplo n.º 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            db         = new SteinbachEntities();
            ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ThisViewSource")));

            var ProjektRepo = new ProjektDB.Repositories.ProjektRepository(db);
            CollectionViewSource FirmaLookupViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("FirmaLookup")));

            FirmaLookupViewSource.Source = ProjektRepo.GetFirmen();

            if (ID == 0)
            {
                var Query = from n in db.Stamm_Aggregate
                            select n;

                ViewSource.Source = new AggregatCollection(Query, db);
                View = (ListCollectionView)ViewSource.View;
                var i = (firma)View.AddNew();
                //i.name = "Neue Firma";
                //i.istFirma = 0;
                View.CommitNew();
                //bNew = true;
            }
            else
            {
                var Query = from n in db.Stamm_Aggregate
                            where n.id == ID
                            select n;

                ViewSource.Source = Query;
            }
        }
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            if (lcv.CanAddNewItem)
            {
                foreach (EmployeeInfo info in dataManager.AllEmployeeList)
                {
                    //离职的不允许添加
                    if (info.StatusID == 0)
                    {
                        continue;
                    }

                    appLog.Info("Add Employee,ID = " + info.ID);
                    lcv.AddNewItem(new SalaryInfo
                    {
                        Year       = (int)(YearComboBox.SelectedItem),
                        Month      = (int)(MonthComboBox.SelectedItem),
                        EmployeeID = info.ID,
                        SelectionEmployeeInfoList   = dataManager.AllEmployeeList.ToList(),
                        SelectionDepartmentInfoList = dataManager.AllDepartmentList.ToList(),
                        SelectionWorkStatusInfoList = AlgorithmClass.GetWorkStatusList()
                    });

                    lcv.CommitNew();
                }
            }
        }
        /// <summary>
        /// Adds the new item to list collection view.
        /// </summary>
        /// <param name="theViewToUpdate">The view to update.</param>
        /// <param name="theNewItem">The new item.</param>
        public static void AddNewItemToListCollectionView(this ListCollectionView theViewToUpdate, object theNewItem)
        {
            theViewToUpdate.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;

            theViewToUpdate.AddNewItem(theNewItem);

            theViewToUpdate.CommitNew();

            theViewToUpdate.NewItemPlaceholderPosition = NewItemPlaceholderPosition.None;
        }
        public void AddItems(IList lst)
        {
            ListCollectionView lcw = this.ItemsSource as ListCollectionView;

            foreach (object obj in lst)
            {
                lcw.AddNewItem(obj);
            }
            lcw.CommitNew();
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Whenever any registered OptionControl raises the FilterChanged property changed event, we need to rebuild
 /// the new predicate used to filter the CollectionView.  Since Multiple Columns can have predicate we need to
 /// iterate over all registered OptionControls and get each predicate.
 /// </summary>
 /// <param name="sender">The object which has risen the event</param>
 /// <param name="e">The property which has been changed</param>
 void filter_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "FilterChanged")
     {
         Predicate <object> predicate = null;
         foreach (var filter in Filters)
         {
             if (filter.HasPredicate)
             {
                 if (predicate == null)
                 {
                     predicate = filter.GeneratePredicate();
                 }
                 else
                 {
                     predicate = predicate.And(filter.GeneratePredicate());
                 }
             }
         }
         bool canContinue = true;
         var  args        = new CancelableFilterChangedEventArgs(predicate);
         if (BeforeFilterChanged != null && !IsResetting)
         {
             BeforeFilterChanged(this, args);
             canContinue = !args.Cancel;
         }
         if (canContinue)
         {
             ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView;
             if (view != null && view.IsEditingItem)
             {
                 view.CommitEdit();
             }
             if (view != null && view.IsAddingNew)
             {
                 view.CommitNew();
             }
             if (CollectionView != null)
             {
                 CollectionView.Filter = predicate;
             }
             if (AfterFilterChanged != null)
             {
                 AfterFilterChanged(this, new FilterChangedEventArgs(predicate));
             }
         }
         else
         {
             IsResetting = true;
             var ctrl = sender as ColumnFilterControl;
             ctrl.ResetControl();
             IsResetting = false;
         }
     }
 }
Ejemplo n.º 9
0
 public void FirePredicationGeneration()
 {
     {
         Predicate <object> predicate = null;
         foreach (var filter in Filters)
         {
             if (filter.HasPredicate)
             {
                 if (predicate == null)
                 {
                     predicate = filter.GeneratePredicate();
                 }
                 else
                 {
                     predicate = predicate.And(filter.GeneratePredicate());
                 }
             }
         }
         bool canContinue = true;
         var  args        = new CancelableFilterChangedEventArgs(predicate);
         if (BeforeFilterChanged != null && !IsResetting)
         {
             BeforeFilterChanged(this, args);
             canContinue = !args.Cancel;
         }
         if (canContinue)
         {
             ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView;
             if (view != null && view.IsEditingItem)
             {
                 view.CommitEdit();
             }
             if (view != null && view.IsAddingNew)
             {
                 view.CommitNew();
             }
             if (CollectionView != null)
             {
                 CollectionView.Filter = predicate;
             }
             if (AfterFilterChanged != null)
             {
                 AfterFilterChanged(this, new FilterChangedEventArgs(predicate));
             }
         }
         else
         {
             IsResetting = true;
             IsResetting = false;
         }
     }
 }
        /// <summary>
        /// Adds the new items to list collection view.
        /// </summary>
        /// <param name="theViewToUpdate">The view to update.</param>
        /// <param name="theNewList">The new list.</param>
        public static void AddNewItemsToListCollectionView(this ListCollectionView theViewToUpdate, List <object> theNewList)
        {
            theViewToUpdate.NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtBeginning;

            foreach (var item in theNewList)
            {
                theViewToUpdate.AddNewItem(item);
            }

            theViewToUpdate.CommitNew();

            theViewToUpdate.NewItemPlaceholderPosition = NewItemPlaceholderPosition.None;
        }
Ejemplo n.º 11
0
        void AddCommandExecute(Object parameter)
        {
            MainWork           mw        = parameter as MainWork;
            ListCollectionView lcv       = (ListCollectionView)CollectionViewSource.GetDefaultView(mw.lvCredentialInfo.ItemsSource);
            CredentialInfo     newRecord = new CredentialInfo();

            lcv.AddNewItem(newRecord);
            lcv.CommitNew();
            SelectedCredential            = newRecord;
            _status                       = "Add";
            Editable                      = !Editable;
            mw.lvCredentialInfo.IsEnabled = false;
        }
        //Added by Aaron 02/24/2013
        //The code below is modified to not fire the drag and drop when I am dragging the scroll bar
        //If I am dragging and dropping the scroll bar and I accidently mouse over an item in the variable  list,
        //the problem was the drag and drop was initiated
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (renderVars)
            {
                return;
            }
            BSkyCanvas.sourceDrag = (DragDropList)this;
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                //Added by Aaron 02/24/2013
                //The function below checks whether the origin of the drag and drop was the scroll bar
                if (isscrollbarclickedon(e) == true)
                {
                    return;
                }
                object data = GetDataFromListBox(this, e.GetPosition(this)) as object;

                //02/23/2013 Aaron
                //Code below could be used for multi drag and drop
                //object data = ((ListBox)(FrameworkElement)this).SelectedItem;

                //If the drag and drop was initiated on the scroll bar,data =null
                if (data != null)
                {
                    DragDropEffects    effs;
                    ListCollectionView lst = this.ItemsSource as ListCollectionView;

                    //We have the option to move or copy variables from a listbox
                    //This is governed by the movevariables property
                    if (this.MoveVariables)
                    {
                        effs = DragDrop.DoDragDrop(this, data, DragDropEffects.Copy | DragDropEffects.Move);

                        //
                        if (effs == DragDropEffects.Copy)
                        {
                            if (lst.IsAddingNew)
                            {
                                lst.CommitNew();
                            }
                            lst.Remove(data);
                        }
                    }
                    else
                    {
                        effs = DragDrop.DoDragDrop(this, data, DragDropEffects.Copy);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Commits any editing and then refreshs the given view. Typically used when filter parameters have changed.
        /// </summary>
        /// <param name="lcv"></param>
        static public void refreshViewFilter(ListCollectionView lcv)
        {
            if (lcv.IsEditingItem)
            {
                lcv.CommitEdit();
            }

            else if (lcv.IsAddingNew)
            {
                lcv.CommitNew();
            }

            lcv.Refresh();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ti          = new DispatcherTimer();
            ti.Tick    += ti_Tick;
            ti.Interval = new TimeSpan(0, 0, 0, 0, 500);
            ti.Start();

            ViewSource          = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ThisViewSource")));
            GruppenViewSource   = ((System.Windows.Data.CollectionViewSource)(this.FindResource("GruppenViewSource")));
            SprachenViewSource  = ((System.Windows.Data.CollectionViewSource)(this.FindResource("SprachenViewSource")));
            TextbausteineSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("TextBausteineSortSource")));

            GruppenViewSource.Source  = CommonTools.Tools.HelperTools.GetAuswahlEintraegeList("TypTextbausteine", 1);
            SprachenViewSource.Source = CommonTools.Tools.HelperTools.GetAuswahlEintraegeList("TypSprache", 1);
            StammTextbaustein textbaustein;

            OrderChanged = false;

            if (ID == 0)
            {
                var Query = from n in db.StammTextbausteine
                            select n;

                ViewSource.Source = new TextbausteinCollection(Query, db);

                View = (ListCollectionView)ViewSource.View;
                var i = (StammTextbaustein)View.AddNew();
                i.Caption = "Neu . . . ";
                View.CommitNew();
                bNew         = true;
                textbaustein = i;
                ListboxSelectedBelegarten.IsEnabled = false;
                TabItemReihenfolge.IsEnabled        = false;
            }
            else
            {
                var Query = from n in db.StammTextbausteine
                            where n.id == ID
                            select n;

                ViewSource.Source = Query;
                textbaustein      = Query.SingleOrDefault();
            }


            ListboxSelectedBelegartenVM = new ViewModels.CheckListBoxes.ListboxSelectedBelegartenViewModel(db, textbaustein);
            Caliburn.Micro.ViewModelBinder.Bind(ListboxSelectedBelegartenVM, this.ListboxSelectedBelegarten, null);
        }
Ejemplo n.º 15
0
        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            if (lcv.CanAddNewItem)
            {
                lcv.AddNewItem(new EmployeeInfo
                {
                    EmployeeSex                 = EmployeeSexType.boy,
                    StatusID                    = 1,
                    DepartmentID                = (DepartmentComboBox.SelectedItem as DepartmentInfo).ID,
                    PostID                      = 1,
                    SelectionPostInfoList       = dataManager.AllPostList.ToList(),
                    SelectionDepartmentInfoList = dataManager.AllDepartmentList.ToList(),
                    SelectionWorkStatusInfoList = AlgorithmClass.GetWorkStatusList()
                });

                lcv.CommitNew();
            }
        }
Ejemplo n.º 16
0
        private void HeaderFilter_FilterFinsh(object sender, RoutedEventArgs e)
        {
            Predicate <object> predicate = null;

            foreach (var item in DataGridColumnHeaders)
            {
                DataGridColumnHeaderFilter dataGridColumnHeaderFilter = item.Tag as DataGridColumnHeaderFilter;
                if (dataGridColumnHeaderFilter.Predicate == null)
                {
                    continue;
                }
                if (predicate == null)
                {
                    predicate = dataGridColumnHeaderFilter.Predicate;
                }
                else
                {
                    predicate = predicate.Or(dataGridColumnHeaderFilter.Predicate);
                }
            }
            ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView;

            if (view != null && view.IsEditingItem)
            {
                view.CommitEdit();
            }
            if (view != null && view.IsAddingNew)
            {
                view.CommitNew();
            }
            if (CollectionView != null)
            {
                try
                {
                    CollectionView.Filter = predicate;
                }
                catch
                {
                }
            }
        }
        /// <summary>
        /// Removes the items from list collection view.
        /// </summary>
        /// <param name="theViewToUpdate">The view to update.</param>
        /// <param name="theRemoveList">The remove list.</param>
        public static void RemoveItemsFromListCollectionView(this ListCollectionView theViewToUpdate, List <object> theRemoveList)
        {
            //Finish all other state before remove item

            if (theViewToUpdate.IsAddingNew)
            {
                theViewToUpdate.CommitNew();
            }

            if (theViewToUpdate.IsEditingItem)
            {
                theViewToUpdate.CommitEdit();
            }

            //Remove items

            foreach (var item in theRemoveList)
            {
                theViewToUpdate.Remove(item);
            }

            //theViewToUpdate.Refresh();
        }
Ejemplo n.º 18
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            db         = new SteinbachEntities();
            ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ThisViewSource")));
            ZahlungsbedingungenLookup        = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ZahlungsbedingungenLookup")));
            ZahlungsbedingungenLookup.Source = db.StammZahlungsbedingungen;

            if (ID == 0)
            {
                var Query = from n in db.firmen
                            select n;

                ViewSource.Source = new FirmaCollection(Query, db);
                View = (ListCollectionView)ViewSource.View;

                var i = (firma)View.AddNew();
                i.name = "Neue Firma";

                i.istFirma = 3;
                i.IstKunde = 1;
                //kunde.KdNr = (int)db.firmen.Max(f => f.KdNr) + 1;
                i.KdNr           = (int)db.firmen.Max(id => id.id) + 10001;
                i.istVerarbeitet = 1;
                // kunde.KdNr = KdNr;
                i.created = DateTime.Now;
                View.CommitNew();
                bNew = true;
            }
            else
            {
                var Query = from n in db.firmen
                            where n.id == ID
                            select n;

                ViewSource.Source = Query;
            }
        }
Ejemplo n.º 19
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            db         = new SteinbachEntities();
            ViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ThisViewSource")));



            if (ID == 0)
            {
                var Query = from n in db.personen
                            select n;

                ViewSource.Source = new PersonCollection(Query, db);
                View = (ListCollectionView)ViewSource.View;
                var i = (person)View.AddNew();

                View.CommitNew();
            }
            else
            {
                if (Session.User.rights != "admin")
                {
                    this.SPBerechtigungen.Visibility    = Visibility.Collapsed;
                    this.SPPasswort.Visibility          = Visibility.Collapsed;
                    this.SPMailTimerActive.Visibility   = Visibility.Collapsed;
                    this.SPMailTimerInterval.Visibility = Visibility.Collapsed;
                }
                var Query = from n in db.personen
                            where n.id == ID
                            select n;



                ViewSource.Source = Query;
            }
        }
        public static void Clear(this ListCollectionView view)
        {
            if (view.IsAddingNew)
            {
                view.CommitNew();
            }
            if (view.IsEditingItem)
            {
                view.CommitEdit();
            }

            if (view.NewItemPlaceholderPosition != NewItemPlaceholderPosition.None)
            {
                view.NewItemPlaceholderPosition = NewItemPlaceholderPosition.None;
            }

            while (view.Count > 0)
            {
                var theItem = view.GetItemAt(0);
                view.Remove(theItem);
            }

            view.Refresh();
        }
Ejemplo n.º 21
0
        private void FillProject()
        {
            db                      = new SteinbachEntities();
            dbArt                   = new SteinbachEntities();
            ViewSource              = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ThisViewSource")));
            DetailsViewSource       = ((System.Windows.Data.CollectionViewSource)(this.FindResource("DetailsViewSource")));
            UnterartikelViewSource  = ((System.Windows.Data.CollectionViewSource)(this.FindResource("UnterartikelViewSource")));
            ParentartikelViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ParentartikelViewSource")));
            OberArtikelViewSource   = ((System.Windows.Data.CollectionViewSource)(this.FindResource("OberArtikelViewSource")));
            LagerortViewSource      = ((System.Windows.Data.CollectionViewSource)(this.FindResource("LagerortViewSource")));
            BewegungsartViewSource  = ((System.Windows.Data.CollectionViewSource)(this.FindResource("BewegungsartViewSource")));
            LieferantenViewSource   = ((System.Windows.Data.CollectionViewSource)(this.FindResource("LieferantenViewSource")));
            KategorieViewSource     = ((System.Windows.Data.CollectionViewSource)(this.FindResource("KategorieViewSource")));


            var pTemplate  = (DataTemplate)this.FindResource("ParentsTemplate");
            var oaTemplate = (DataTemplate)this.FindResource("OberArtikelTemplate");

            //OberartkelComboBox.onfcbChanged += new UserControls.FilteredComboBox.FiteredBoxChanged(OberartkelComboBox_onfcbChanged);
            //OberartkelComboBox.OnFcb_SelectionChanged += new UserControls.FilteredComboBox.FilteredBoxSelectionChanged(OberartkelComboBox_OnFcb_SelectionChanged);

            //OberartkelComboBox.SetSimpleBinding("id_parent", "id", pTemplate, BindingMode.TwoWay, UpdateSourceTrigger.PropertyChanged);


            //fcbArtikel.cBoxItemTemplate = pTemplate;
            //fcbArtikel.onfcbChanged += new UserControls.FilteredComboBox.FiteredBoxChanged(fcbArtikel_onfcbChanged);
            //fcbArtikel.OnFcb_SelectionChanged += new UserControls.FilteredComboBox.FilteredBoxSelectionChanged(fcbArtikel_OnFcb_SelectionChanged);


            LieferantenViewSource.Source = db.firmen.Where(id => id.istFirma == 1);
            KategorieViewSource.Source   = CommonTools.Tools.HelperTools.GetAuswahlEintraege("ArtikelKategorie", 1);
            var WaehrungenLookUp = ((CollectionViewSource)(this.FindResource("WaehrungenLookUp")));
            var curQuery         = from c in db.StammWaehrungen select c;
            var cQ = db.StammWaehrungen;

            WaehrungenLookUp.Source = curQuery;



            if (ID == 0)
            {
                var Query = from n in db.lagerlisten
                            select n;

                ViewSource.Source = new ArtikelCollection(Query, db);
                View = (ListCollectionView)ViewSource.View;
                var i = (lagerliste)View.AddNew();
                i.bezeichnung = "Artikel Neu";
                i.einheit     = "Pcs";
                View.CommitNew();

                c1GridDetails.Visibility = System.Windows.Visibility.Hidden;

                // bNew = true;
            }
            else
            {
                var Query = from n in db.lagerlisten
                            where n.id == ID
                            select n;

                ViewSource.Source = Query;


                CheckStandardRadioButtonListeBewegungen();

                // LoadBewegungen(90);

                //this.fcbArtikel.ComboBoxViewSource = FillParentArtikelListe("", ID);
                // this.OberartkelComboBox.ComboBoxViewSource = FillParentArtikelListe("", ID);
                c1GridDetails.Visibility = System.Windows.Visibility.Visible;
                var tools = new libc1DatagridTools.ManageC1GridColumns(c1GridDetails);
                tools.LoadGridSettings(Properties.Settings.Default.DatagridSettingsArtikelDetails);
            }
        }
        public virtual void ListBox_Drop(object sender, DragEventArgs e)
        {
            string[] formats = e.Data.GetFormats();

            //BSkyCanvas.destDrag = (ListBox)sender;
            //The code below disables drag and drop on the source list, added June 16th


            int destindex, i, j, sourceindex, noofitems;


            //object[] newlist =null;

            //Aaron Modified 11/04
            if (AutoPopulate == true && this == BSkyCanvas.sourceDataset)
            {
                e.Effects = DragDropEffects.None;
                return;
            }


            if (formats.Length > 0)
            {
                object sourcedata = e.Data.GetData(formats[0]) as object;

                // List<DatasetDisplay> listOfDisplayStrings = new List<DatasetDisplay>();
                //  this.ItemsSource = new ListCollectionView(new ObservableCollection<object>());
                ListCollectionView list = this.ItemsSource as ListCollectionView;



                if (sourcedata != null)
                {
                    //Soure and destination are different
                    //if (this != BSkyCanvas.sourceDrag)
                    if (this != BSkyCanvas.sourceDataset)
                    {
                        if (list.IndexOf(sourcedata) < 0)
                        {
                            //  this.ItemsSource = new ListCollectionView(new ObservableCollection<DatasetDisplay>());
                            // ListCollectionView list = this.ItemsSource as ListCollectionView;
                            list.AddNewItem(sourcedata);
                            list.CommitNew();

                            //this.SelectedItem = d;
                            //e.Effects =  DragDropEffects.All;
                            this.ScrollIntoView(sourcedata);//AutoScroll
                        }

                        //Aaron 09/11/2013 Commented 2 lines below
                        //else
                        //   e.Effects =  DragDropEffects.None;
                        //this.UnselectAll();
                        //02/24 Aaron
                        //This is to signify that since the source and destination are different, we have finished the copy.
                        //We will go back to the initiation of the drag and drop to see if the source needs to be removed or kept
                        // in the source listbox. This will be determined by the value of movevariables property
                        e.Effects         = DragDropEffects.Copy;
                        this.SelectedItem = sourcedata;
                        Focus();
                    }

                    //The source and the destination are the same i.e. the target variable
                    else
                    {
                        object destdata = GetDataFromListBox(this, e.GetPosition(this)) as object;
                        if (destdata == sourcedata)
                        {
                            return;
                        }
                        destindex = list.IndexOf(destdata);
                        noofitems = list.Count;
                        object[] newlist = new object[noofitems];
                        sourceindex = list.IndexOf(sourcedata);
                        if (destindex != sourceindex)
                        {
                            //This is the case of move to the end

                            if (destindex == -1)
                            {
                                for (i = 0; i < noofitems; i++)
                                {
                                    if (i == sourceindex)
                                    {
                                        while (i <= (noofitems - 2))
                                        {
                                            newlist[i] = list.GetItemAt(i + 1);
                                            i          = i + 1;
                                        }
                                        newlist[i] = list.GetItemAt(sourceindex);
                                        i          = i + 1;
                                    }

                                    else
                                    {
                                        newlist[i] = list.GetItemAt(i);
                                    }
                                }
                            } //End of move to the end

                            else
                            {
                                if (destindex < sourceindex)
                                {
                                    for (i = 0; i < noofitems; i++)
                                    {
                                        j = i;


                                        if (i == destindex)
                                        {
                                            newlist[i] = list.GetItemAt(sourceindex);
                                            i          = i + 1;


                                            while (j < noofitems)
                                            {
                                                if (j != sourceindex)
                                                {
                                                    newlist[i] = list.GetItemAt(j);
                                                    i          = i + 1;
                                                }
                                                j = j + 1;
                                            }
                                        }

                                        else
                                        {
                                            newlist[i] = list.GetItemAt(i);
                                        }
                                    }
                                } ////End when sourceindex > destindex

                                else if (sourceindex < destindex) //I have tested this
                                {
                                    for (i = 0; i < noofitems; i++)
                                    {
                                        j = i;


                                        if (i == sourceindex)
                                        {
                                            j = j + 1;


                                            while (i < noofitems)
                                            {
                                                if (i == destindex)
                                                {
                                                    newlist[i] = list.GetItemAt(sourceindex);
                                                    i          = i + 1;
                                                }


                                                else
                                                {
                                                    newlist[i] = list.GetItemAt(j);
                                                    j          = j + 1;
                                                    i          = i + 1;
                                                }
                                            }
                                        }


                                        else
                                        {
                                            newlist[i] = list.GetItemAt(i);
                                        }
                                    }

                                    //End of for loop
                                }  //end of destindex > sourceindex

                                //end of else if
                            }

                            //end of else


                            //End of the case move to end
                        }

                        //end of case destindex !=source index
                        if (list.IsAddingNew)
                        {
                            list.CommitNew();
                        }

                        for (i = 0; i < noofitems; i++)
                        {
                            list.Remove(newlist[i]);
                        }

                        for (i = 0; i < noofitems; i++)
                        {
                            list.AddNewItem(newlist[i]);
                            list.CommitNew();
                            //this.ScrollIntoView(newlist[i]);//AutoScroll
                        }
                        list.Refresh();
                        this.SelectedItem = sourcedata;
                        //02/24 Aaron
                        //This is to signify that since the source and destination is the same, we have performed a move
                        e.Effects = DragDropEffects.Move;
                    }

                    //end of source and destination and the same (target listbox
                }

                //sourcedata |=null
            }

            //formats.length >0
        }
        public virtual void ListBox_Drop(object sender, DragEventArgs e)
        {
            string[] formats = e.Data.GetFormats();

            //BSkyCanvas.destDrag = (ListBox)sender;
            //The code below disables drag and drop on the source list, added June 16th


            int destindex, i, j, sourceindex, noofitems;


            //object[] newlist =null;

            //Aaron Modified 11/04
            if (AutoVar == false && this == BSkyCanvas.sourceDrag)
            {
                e.Effects = DragDropEffects.None;
                return;
            }


            if (formats.Length > 0)
            {
                object             sourcedata = e.Data.GetData(formats[0]) as object;
                ListCollectionView list       = this.ItemsSource as ListCollectionView;

                if (sourcedata != null)
                {
                    //Soure and destination are different
                    if (this != BSkyCanvas.sourceDrag)
                    {
                        //AARON ADD YOUR CODE HERE
                        //Added by Aaron 10/02/2015
                        //Dragdroplist for summarize is used in 2 places
                        //The aggregatre control and the sort control
                        //In the aggregate control, I need to support copying variables as I need                                    //to support mean(var1), median(var1)...
                        //To support the above use case, I create a new data variable object
                        //The new object when moved from the target to the source can create a
                        //duplicate variable
                        //The line below, prevents the addition of the new variable and gets triggered only on the sort
                        //SO BASICALLY IF I AM MOVING ITEMS TO THE SOURCE VARIABLE FROM THE AGGREGATE CONTROL NO NEW VARIABLES ARE EVER CREATED IN THE SOURCE VARIABLE
                        //NEW VARIABLES ARE CREATED ONLY WITH THE SORT CONTROL

                        if (this.MoveVariables == true)
                        {
                            if (list.IndexOf(sourcedata) < 0)
                            {
                                list.AddNewItem(sourcedata);
                                list.CommitNew();

                                //this.SelectedItem = d;
                                //e.Effects =  DragDropEffects.All;
                                this.ScrollIntoView(sourcedata);//AutoScroll
                            }
                        }

                        //Aaron 09/11/2013 Commented 2 lines below
                        //else
                        //   e.Effects =  DragDropEffects.None;
                        //this.UnselectAll();
                        //02/24 Aaron
                        //This is to signify that since the source and destination are different, we have finished the copy.
                        //We will go back to the initiation of the drag and drop to see if the source needs to be removed or kept
                        // in the source listbox. This will be determined by the value of movevariables property
                        e.Effects         = DragDropEffects.Copy;
                        this.SelectedItem = sourcedata;
                        Focus();
                    }

                    //The source and the destination are the same i.e. the target variable
                    else


                    {
                        object destdata = GetDataFromListBox(this, e.GetPosition(this)) as object;
                        if (destdata == sourcedata)
                        {
                            return;
                        }
                        destindex = list.IndexOf(destdata);
                        noofitems = list.Count;
                        object[] newlist = new object[noofitems];
                        sourceindex = list.IndexOf(sourcedata);
                        if (destindex != sourceindex)
                        {
                            //This is the case of move to the end

                            if (destindex == -1)
                            {
                                for (i = 0; i < noofitems; i++)
                                {
                                    if (i == sourceindex)
                                    {
                                        while (i <= (noofitems - 2))
                                        {
                                            newlist[i] = list.GetItemAt(i + 1);
                                            i          = i + 1;
                                        }
                                        newlist[i] = list.GetItemAt(sourceindex);
                                        i          = i + 1;
                                    }

                                    else
                                    {
                                        newlist[i] = list.GetItemAt(i);
                                    }
                                }
                            } //End of move to the end

                            else
                            {
                                if (destindex < sourceindex)
                                {
                                    for (i = 0; i < noofitems; i++)
                                    {
                                        j = i;


                                        if (i == destindex)
                                        {
                                            newlist[i] = list.GetItemAt(sourceindex);
                                            i          = i + 1;


                                            while (j < noofitems)
                                            {
                                                if (j != sourceindex)
                                                {
                                                    newlist[i] = list.GetItemAt(j);
                                                    i          = i + 1;
                                                }
                                                j = j + 1;
                                            }
                                        }

                                        else
                                        {
                                            newlist[i] = list.GetItemAt(i);
                                        }
                                    }
                                } ////End when sourceindex > destindex

                                else if (sourceindex < destindex) //I have tested this
                                {
                                    for (i = 0; i < noofitems; i++)
                                    {
                                        j = i;


                                        if (i == sourceindex)
                                        {
                                            j = j + 1;


                                            while (i < noofitems)
                                            {
                                                if (i == destindex)
                                                {
                                                    newlist[i] = list.GetItemAt(sourceindex);
                                                    i          = i + 1;
                                                }


                                                else
                                                {
                                                    newlist[i] = list.GetItemAt(j);
                                                    j          = j + 1;
                                                    i          = i + 1;
                                                }
                                            }
                                        }


                                        else
                                        {
                                            newlist[i] = list.GetItemAt(i);
                                        }
                                    }

                                    //End of for loop
                                }  //end of destindex > sourceindex

                                //end of else if
                            }

                            //end of else


                            //End of the case move to end
                        }

                        //end of case destindex !=source index
                        if (list.IsAddingNew)
                        {
                            list.CommitNew();
                        }

                        for (i = 0; i < noofitems; i++)
                        {
                            list.Remove(newlist[i]);
                        }

                        for (i = 0; i < noofitems; i++)
                        {
                            list.AddNewItem(newlist[i]);
                            list.CommitNew();
                            //this.ScrollIntoView(newlist[i]);//AutoScroll
                        }
                        list.Refresh();
                        this.SelectedItem = sourcedata;
                        //02/24 Aaron
                        //This is to signify that since the source and destination is the same, we have performed a move
                        e.Effects = DragDropEffects.Move;
                    }

                    //end of source and destination and the same (target listbox
                }

                //sourcedata |=null
            }

            //formats.length >0
        }
Ejemplo n.º 24
0
        void filter_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "FilterChanged")
            {
                ColumnFilterControl cf = sender as ColumnFilterControl;

                Predicate <object> predicate = null;

                foreach (var filter in Filters)
                {
                    if (filter.HasPredicate)
                    {
                        if (predicate == null)
                        {
                            predicate = filter.GeneratePredicate();
                        }
                        else
                        {
                            predicate = predicate.And(filter.GeneratePredicate());
                        }
                    }
                    if (cf.FilterText == null)
                    {
                        if (predicate == null)
                        {
                            predicate = filter.GeneratePredicate();
                        }
                        else
                        {
                            predicate = predicate.And(filter.GeneratePredicate() == null ? predicate : filter.GeneratePredicate());
                        }
                    }
                }
                //bool canContinue = true;
                //var args = new CancelableFilterChangedEventArgs(predicate);
                //if (BeforeFilterChanged != null && !IsResetting)
                //{
                //    BeforeFilterChanged(this, args);
                //    canContinue = !args.Cancel;
                //}
                //if (canContinue)
                //{
                ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView;
                if (view != null && view.IsEditingItem)
                {
                    view.CommitEdit();
                }
                if (view != null && view.IsAddingNew)
                {
                    view.CommitNew();
                }
                if (CollectionView != null)
                {
                    try
                    {
                        CollectionView.Filter = predicate;
                    }
                    catch
                    {
                    }

                    //int count = 1;
                    ObservableCollection <ISelected> list = new ObservableCollection <ISelected>();

                    foreach (var item in CollectionView)
                    {
                        ISelected selectedModel = item as ISelected;
                        //selectedModel.Num= count++;
                        list.Add(selectedModel);
                    }
                    //foreach (var item in list)
                    //{
                    //    if (item == null)
                    //        continue;
                    //    item.Num = count++;
                    //}
                    if (list != null && list.Count > 0)
                    {
                        //FilterFinshItemsSource = list;

                        //if (AfterFilterChanged != null)
                        //    AfterFilterChanged(this, new FilterChangedEventArgs(predicate));
                    }
                }


                //}
                //else
                //{
                //    IsResetting = true;
                //    var ctrl = sender as ColumnFilterControl;
                //    ctrl.ResetControl();
                //    IsResetting = false;
                //}
            }
        }
        //private void ListBox_MouseMove(object sender, MouseButtonEventArgs e)
        //{
        //    if (e.LeftButton == MouseButtonState.Pressed)
        //    {
        //        object data = ((ListBox)(FrameworkElement)sender).SelectedItem;
        //        if (data != null)
        //            DragDrop.DoDragDrop(this, data, DragDropEffects.Copy);
        //    }
        //}

        public override void ListBox_Drop(object sender, DragEventArgs e)
        {
            DragDropList             tempDragDropList             = null;
            DragDropListForSummarize tempDragDropListForSummarize = null;
            Boolean autoVarTemp = false;

            if (BSkyCanvas.sourceDrag is DragDropList)
            {
                tempDragDropList = BSkyCanvas.sourceDrag as DragDropList;
                autoVarTemp      = tempDragDropList.AutoVar;
            }
            else if (BSkyCanvas.sourceDrag is DragDropListForSummarize)
            {
                tempDragDropListForSummarize = BSkyCanvas.sourceDrag as DragDropListForSummarize;
                autoVarTemp = tempDragDropListForSummarize.AutoVar;
            }

            string[] formats = e.Data.GetFormats();

            //BSkyCanvas.destDrag = (ListBox)sender;
            //The code below disables drag and drop on the source list, added June 16th
            int destindex, i, j, sourceindex, noofitems;

            System.Windows.Forms.DialogResult diagResult;
            //object[] newlist =null;
            //Aaron Modified 11/04
            //Code below prevents me from doing a move where the source and destination are the source list
            if (AutoVar == false && this == (ListBox)BSkyCanvas.sourceDrag)
            {
                e.Effects = DragDropEffects.None;
                return;
            }
            if (formats.Length > 0)
            {
                object             sourcedata = e.Data.GetData(formats[0]) as object;
                ListCollectionView list       = this.ItemsSource as ListCollectionView;

                if (sourcedata != null)
                {
                    //Soure and destination are different. I copy the selected item to the target
                    if ((this != (ListBox)BSkyCanvas.sourceDrag) && (AutoVar == false))
                    {
                        if (list.IndexOf(sourcedata) < 0)
                        {
                            list.AddNewItem(sourcedata);
                            list.CommitNew();

                            //this.SelectedItem = d;
                            //e.Effects =  DragDropEffects.All;
                            this.ScrollIntoView(sourcedata);//AutoScroll
                        }

                        else
                        {
                            e.Effects = DragDropEffects.None;
                        }
                        //this.UnselectAll();
                        //02/24 Aaron
                        //This is to signify that since the source and destination are different, we have finished the copy.
                        //We will go back to the initiation of the drag and drop to see if the source needs to be removed or kept
                        // in the source listbox. This will be determined by the value of movevariables property
                        //e.Effects is set to DragDropEffects.Copy to signify that the selected item has been copies to the destination control
                        e.Effects         = DragDropEffects.Copy;
                        this.SelectedItem = sourcedata;
                        Focus();
                    }

                    //Aaron 09/11/2013
                    //Here I am moving to a target that has 0 or 1 item
                    //If the target has 1 item (it cannot have more than one as I prevent this)
                    //I remove the itemin the target and add it back to the source
                    //ONE OF THE LISTBOXES MUST BE THE SOURCE LISTBOXES
                    else if ((this != (ListBox)BSkyCanvas.sourceDrag) && (AutoVar == true) && (autoVarTemp == false))
                    {
                        ListCollectionView srcList = BSkyCanvas.sourceDrag.ItemsSource as ListCollectionView;
                        noofitems = list.Count;
                        object[] arr = new object[noofitems];

                        //Adding the items in the target to the source before adding new item to the target
                        for (i = 0; i < noofitems; i++)
                        {
                            arr[i] = list.GetItemAt(i);
                            srcList.AddNewItem(arr[i]);
                            srcList.CommitNew();
                        }
                        //Removing all items from the target
                        for (i = 0; i < noofitems; i++)
                        {
                            list.Remove(arr[i]);
                        }
                        //Adding new item to the target
                        list.AddNewItem(sourcedata);
                        list.CommitNew();
                        // list.Refresh();
                        this.SelectedItem = sourcedata;
                        e.Effects         = DragDropEffects.Copy;
                        Focus();
                    }

                    //Aaron 09/11/2013
                    //If the grouping variable target list box has an item, we want to disallow dragging and dropping from another target to the grouping variable target.
                    //This could crate problems with filter handling
                    //We want to prompt the user to move the variable in teh grouping variable to the source
                    else if ((this != (ListBox)BSkyCanvas.sourceDrag) && (autoVarTemp == true) && (AutoVar == true))
                    {
                        ListCollectionView srcList = BSkyCanvas.sourceDrag.ItemsSource as ListCollectionView;
                        noofitems = list.Count;
                        object[] arr = new object[noofitems];

                        if (noofitems == 1)
                        {
                            diagResult = System.Windows.Forms.MessageBox.Show("Please remove the variable from the grouping variable list before initiating the drag and drop", "Message", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Question);
                            e.Effects  = DragDropEffects.None;
                            BSkyCanvas.sourceDrag.SelectedItem = null;
                            this.Focus();
                            return;
                        }

                        //Adding the items in the target to the source before adding new item to the target
                        for (i = 0; i < noofitems; i++)
                        {
                            arr[i] = list.GetItemAt(i);
                            srcList.AddNewItem(arr[i]);
                            srcList.CommitNew();
                        }
                        //Removing all items from the target
                        for (i = 0; i < noofitems; i++)
                        {
                            list.Remove(arr[i]);
                        }
                        //Adding new item to the target
                        list.AddNewItem(sourcedata);
                        list.CommitNew();
                        // list.Refresh();
                        // this.Focus();
                        this.SelectedItem = sourcedata;
                        e.Effects         = DragDropEffects.Copy;
                        this.Focus();
                    }
                    //The source and the destination are the same i.e. the target variable
                    else
                    {
                        e.Effects = DragDropEffects.None;
                    }
                } //sourcedata |=null
            }
        }
        public virtual void ListBox_Drop(object sender, DragEventArgs e)
        {
            string functionName;
            bool   doesAggOptionExist = false;

            string[] formats       = e.Data.GetFormats();
            int      firstpos      = 0;
            int      lastpos       = 0;
            bool     filterResults = false;

            //BSkyCanvas.destDrag = (ListBox)sender;
            //The code below disables drag and drop on the source list, added June 16th


            int destindex, i, j, sourceindex, noofitems;


            //object[] newlist =null;

            //Aaron Modified 11/04
            if (AutoVar == false && this == BSkyCanvas.sourceDrag)
            {
                e.Effects = DragDropEffects.None;
                return;
            }


            if (formats.Length > 0)
            {
                object             sourcedata = e.Data.GetData(formats[0]) as object;
                ListCollectionView list       = this.ItemsSource as ListCollectionView;

                if (sourcedata != null)
                {
                    //Soure and destination are different
                    if (this != BSkyCanvas.sourceDrag)
                    {
                        //Added by Aaron 07/22/2015
                        if (list.IndexOf(sourcedata) < 0)
                        {
                            //Added by Aaron 07/22/2015
                            //a dragdrop list class has a property summary control. This indicates that it is used
                            //in a summary control. If this is true, i have to prefix the variable name by the
                            //function name in the combo box
                            //if (this.summaryCtrl == true)
                            //{
                            functionName = getFunctionFromComboBox();
                            DataSourceVariable ds = sourcedata as DataSourceVariable;
                            if (functionName != "asc")
                            {
                                ds.XName = functionName + "(" + ds.RName + ")";
                            }
                            else
                            {
                                ds.XName = ds.RName;
                            }
                            //ds.XName = functionName + "(" + ds.RName + ")";
                            list.AddNewItem(ds);
                            list.CommitNew();
                            //}
                            //else
                            //{
                            //Added by Aaron 07/22/2015
                            //If I am moving the variable back from a drag drop that is associated with a summary control, I need to remove the sumarizing function
                            //if (BSkyCanvas.sourceDrag is DragDropListForSummarize)
                            //{
                            //    DataSourceVariable ds1 = sourcedata as DataSourceVariable;

                            //    firstpos = ds1.Name.IndexOf(@"(");
                            //    lastpos = ds1.Name.IndexOf(@")");
                            //    ds1.XName = ds1.XName.Substring(firstpos+1, (lastpos - (firstpos+1)));
                            //}

                            // list.AddNewItem(sourcedata);
                            // list.CommitNew();
                            //}
                            //this.SelectedItem = d;
                            //e.Effects =  DragDropEffects.All;
                            this.ScrollIntoView(sourcedata);//AutoScroll
                        }
                        else
                        {
                            //Check if the aggregate option is already present
                            functionName       = getFunctionFromComboBox();
                            doesAggOptionExist = checkIfAggregateOptionExists(this, sourcedata as DataSourceVariable, functionName);
                            DataSourceVariable ds = sourcedata as DataSourceVariable;
                            if (!doesAggOptionExist)
                            {
                                DataSourceVariable newds = new DataSourceVariable();
                                //31Jul2016 9:43AM :Anil: line will not work as we moved RNAME out of the Name property in DataSource:  newds.Name = ds.RName; //RName can support A.2 as col name
                                newds.RName     = ds.RName; //Anil: This fixes: 31Jul2016 9:43AM
                                newds.XName     = ds.XName;
                                newds.DataType  = ds.DataType;
                                newds.DataClass = ds.DataClass;
                                newds.Width     = ds.Width;
                                newds.Decimals  = ds.Decimals;
                                newds.Label     = ds.Label;
                                newds.Values    = ds.Values;
                                newds.Missing   = ds.Missing;
                                newds.MissType  = ds.MissType;
                                newds.Columns   = ds.Columns;
                                newds.Measure   = ds.Measure;
                                newds.ImgURL    = ds.ImgURL;
                                filterResults   = this.CheckForFilter(newds);
                                if (filterResults)
                                {
                                    if (functionName != "asc")
                                    {
                                        newds.XName = functionName + "(" + newds.RName + ")";
                                    }
                                    else
                                    {
                                        newds.XName = newds.RName;
                                    }

                                    //newds.XName = functionName + "(" + ds.RName + ")";
                                    list.AddNewItem(newds);
                                    list.CommitNew();

                                    this.ScrollIntoView(newds);//AutoScroll
                                }
                                // else
                                // {
                                //     invalidVars.Add(vInputList.SelectedItems[i]);
                                // }
                            }
                        }

                        //Aaron 09/11/2013 Commented 2 lines below
                        //else
                        //   e.Effects =  DragDropEffects.None;
                        //this.UnselectAll();
                        //02/24 Aaron
                        //This is to signify that since the source and destination are different, we have finished the copy.
                        //We will go back to the initiation of the drag and drop to see if the source needs to be removed or kept
                        // in the source listbox. This will be determined by the value of movevariables property
                        e.Effects         = DragDropEffects.Copy;
                        this.SelectedItem = sourcedata;
                        Focus();
                    }

                    //The source and the destination are the same i.e. the target variable
                    else


                    {
                        object destdata = GetDataFromListBox(this, e.GetPosition(this)) as object;
                        if (destdata == sourcedata)
                        {
                            return;
                        }
                        destindex = list.IndexOf(destdata);
                        noofitems = list.Count;
                        object[] newlist = new object[noofitems];
                        sourceindex = list.IndexOf(sourcedata);
                        if (destindex != sourceindex)
                        {
                            //This is the case of move to the end

                            if (destindex == -1)
                            {
                                for (i = 0; i < noofitems; i++)
                                {
                                    if (i == sourceindex)
                                    {
                                        while (i <= (noofitems - 2))
                                        {
                                            newlist[i] = list.GetItemAt(i + 1);
                                            i          = i + 1;
                                        }
                                        newlist[i] = list.GetItemAt(sourceindex);
                                        i          = i + 1;
                                    }

                                    else
                                    {
                                        newlist[i] = list.GetItemAt(i);
                                    }
                                }
                            } //End of move to the end

                            else
                            {
                                if (destindex < sourceindex)
                                {
                                    for (i = 0; i < noofitems; i++)
                                    {
                                        j = i;


                                        if (i == destindex)
                                        {
                                            newlist[i] = list.GetItemAt(sourceindex);
                                            i          = i + 1;


                                            while (j < noofitems)
                                            {
                                                if (j != sourceindex)
                                                {
                                                    newlist[i] = list.GetItemAt(j);
                                                    i          = i + 1;
                                                }
                                                j = j + 1;
                                            }
                                        }

                                        else
                                        {
                                            newlist[i] = list.GetItemAt(i);
                                        }
                                    }
                                } ////End when sourceindex > destindex

                                else if (sourceindex < destindex) //I have tested this
                                {
                                    for (i = 0; i < noofitems; i++)
                                    {
                                        j = i;


                                        if (i == sourceindex)
                                        {
                                            j = j + 1;


                                            while (i < noofitems)
                                            {
                                                if (i == destindex)
                                                {
                                                    newlist[i] = list.GetItemAt(sourceindex);
                                                    i          = i + 1;
                                                }


                                                else
                                                {
                                                    newlist[i] = list.GetItemAt(j);
                                                    j          = j + 1;
                                                    i          = i + 1;
                                                }
                                            }
                                        }


                                        else
                                        {
                                            newlist[i] = list.GetItemAt(i);
                                        }
                                    }

                                    //End of for loop
                                }  //end of destindex > sourceindex

                                //end of else if
                            }

                            //end of else


                            //End of the case move to end
                        }

                        //end of case destindex !=source index
                        if (list.IsAddingNew)
                        {
                            list.CommitNew();
                        }

                        for (i = 0; i < noofitems; i++)
                        {
                            list.Remove(newlist[i]);
                        }

                        for (i = 0; i < noofitems; i++)
                        {
                            list.AddNewItem(newlist[i]);
                            list.CommitNew();
                            //this.ScrollIntoView(newlist[i]);//AutoScroll
                        }
                        list.Refresh();
                        this.SelectedItem = sourcedata;
                        //02/24 Aaron
                        //This is to signify that since the source and destination is the same, we have performed a move
                        e.Effects = DragDropEffects.Move;
                    }

                    //end of source and destination and the same (target listbox
                }

                //sourcedata |=null
            }

            //formats.length >0
        }
Ejemplo n.º 27
0
        void filter_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "FilterChanged")
            {
                ColumnFilterControl cf = sender as ColumnFilterControl;

                Predicate <object> predicate = null;
                if (!IsFilterWindow)
                {
                    if (window != null)
                    {
                        predicate = FilterDataViewModel.Instance.FilterPredicate;
                        window.Close();
                    }
                }
                else
                {
                    foreach (var filter in Filters)
                    {
                        if (filter.HasPredicate)
                        {
                            if (predicate == null)
                            {
                                predicate = filter.GeneratePredicate();
                            }
                            else
                            {
                                predicate = predicate.And(filter.GeneratePredicate());
                            }
                        }
                        if (cf.FilterText == null)
                        {
                            if (predicate == null)
                            {
                                predicate = filter.GeneratePredicate();
                            }
                            else
                            {
                                predicate = predicate.And(filter.GeneratePredicate());
                            }
                        }
                    }
                }
                bool canContinue = true;
                var  args        = new CancelableFilterChangedEventArgs(predicate);
                if (BeforeFilterChanged != null && !IsResetting)
                {
                    BeforeFilterChanged(this, args);
                    canContinue = !args.Cancel;
                }
                if (canContinue)
                {
                    ListCollectionView view = CollectionViewSource.GetDefaultView(this.ItemsSource) as ListCollectionView;
                    if (view != null && view.IsEditingItem)
                    {
                        view.CommitEdit();
                    }
                    if (view != null && view.IsAddingNew)
                    {
                        view.CommitNew();
                    }
                    if (CollectionView != null)
                    {
                        try
                        {
                            CollectionView.Filter = predicate;
                        }
                        catch
                        {
                        }

                        int count = 1;
                        ObservableCollection <AllSelectedPropertyChanged> list = new ObservableCollection <AllSelectedPropertyChanged>();

                        foreach (var item in CollectionView)
                        {
                            AllSelectedPropertyChanged selectedModel = item as AllSelectedPropertyChanged;
                            //selectedModel.Num= count++;
                            list.Add(selectedModel);
                        }
                        foreach (var item in list)
                        {
                            if (item == null)
                            {
                                continue;
                            }
                            item.Num = count++;
                        }
                        //if(cf.FilterText!=null&& cf.FilterText.Trim() != "")
                        //{
                        if (list != null && list.Count > 0)
                        {
                            FilterFinshItemsSource = list;

                            if (AfterFilterChanged != null)
                            {
                                AfterFilterChanged(this, new FilterChangedEventArgs(predicate));
                            }
                        }

                        //}
                    }
                }
                else
                {
                    IsResetting = true;
                    var ctrl = sender as ColumnFilterControl;
                    ctrl.ResetControl();
                    IsResetting = false;
                }
            }
        }