Наследование: EditableCollectionView, IDeferRefresh
Пример #1
0
        public PositionUsersVM(PositionVM position, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentPosition = position;
            PositionDataService = new PositionDataService(UnitOfWork);
            PositionDataService.UserAdded += OnUserAdded;
            PositionDataService.UserRemoved += OnUserRemoved;
            UserDataService = new UserDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<UserPositionVM>();
            foreach (var positionUser in PositionDataService.GetUsers(position.Id))
            {
                selectedVms.Add(new UserPositionVM(positionUser, Access, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<UserVM>();
            foreach (var user in UserDataService.GetActives(SoheilEntityType.Positions, CurrentPosition.Id))
            {
                allVms.Add(new UserVM(user, Access, UserDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
            
        }
 public AnalyzerConfigurationViewModel()
 {
     _issuesAnalyzer = ServiceLocator.Resolve<IssuesAnalyzerService>();
     Analyzers = new ListCollectionView(_issuesAnalyzer.AnalyzerContext.Analyzers);
     Analyzers.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
     Analyzers.MoveCurrentToFirst();
 }
Пример #3
0
		public MachineStationsVM(MachineVM machine, AccessType access)
			: base(access)
		{
            UnitOfWork = new SoheilEdmContext();
			CurrentMachine = machine;
            MachineDataService = new MachineDataService(UnitOfWork);
			MachineDataService.StationAdded += OnStationAdded;
			MachineDataService.StationRemoved += OnStationRemoved;
            StationDataService = new StationDataService(UnitOfWork);

			var selectedVms = new ObservableCollection<StationMachineVM>();
			foreach (var stationMachine in MachineDataService.GetStations(machine.Id))
			{
				selectedVms.Add(new StationMachineVM(stationMachine, Access, StationMachineDataService, RelationDirection.Reverse));
			}
			SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<StationVM>();
            foreach (var station in StationDataService.GetActives(SoheilEntityType.Machines, CurrentMachine.Id))
            {
                allVms.Add(new StationVM(station, Access, StationDataService));
            }
            AllItems = new ListCollectionView(allVms);

			IncludeCommand = new Command(Include, CanInclude);
			ExcludeCommand = new Command(Exclude, CanExclude);
		}
Пример #4
0
        public NewTabViewModel(ChatClient client)
        {
            this.client = client;

            StartChatCommand = new RelayCommand(_ =>
                {
                    StartChat.SafeInvoke(this, new StartChatEventArgs((contactsView.CurrentItem as ContactViewModel).Contact));
                });
            AddFriendCommand = new RelayCommand(_ =>
                {
                    if (AddFriendText.Length > 0)
                        client.AddFriend(AddFriendText);
                    AddFriendText = "";
                }, _ =>
                {
                    return AddFriendText.Length > 0;
                });

            contactsView = new ListCollectionView(contactVMs);
            contactsView.CustomSort = new ContactComparer();

            client.UserDetailsChange += OnUserDetailsChange;
            client.GroupDetailsChange += OnGroupDetailsChange;

            UpdateContacts(client.Friends, Enumerable.Empty<IUser>());
            UpdateContacts(client.Groups, Enumerable.Empty<IGroup>());
        }
Пример #5
0
 public EnumPropertyItem(PropertyDescriptor property, object instance)
     : base(property, instance)
 {
     EnumValues = new ListCollectionView(Enum.GetValues(property.PropertyType));
     EnumValues.MoveCurrentTo(property.GetValue(instance));
     EnumValues.CurrentChanged += OnEnumValueChanged;
 }
        public CatalogNodeViewModel(Catalog catalog)
        {
            CurrentEntity = catalog;
            _articlesObservableList = new ObservableCollection<ArticleViewModel>();
            ArticlesCollectionView = new ListCollectionView(_articlesObservableList);

        }
        private void LookupComboboxBindingWindow_Loaded(object sender, RoutedEventArgs e)
        {
            IQueryable<Order> query = from o in db.Orders
                                      //where o.OrderDate >= System.Convert.ToDateTime("1/1/2009")
                                      orderby o.OrderDate descending, o.Customer.LastName
                                      select o;

            this.OrderData = new OrdersCollection(query, db);

            //  Make sure the lookup list is pulled from the same ObjectContext 
            //  (OMSEntities) that the order query uses above.
            //  Also have to make sure you return a list of Customer entites and not a 
            //  projection of just a few fields otherwise the binding won't work).
            IQueryable<Customer> customerList = from c in db.Customers
                                                where c.Orders.Count > 0
                                                orderby c.LastName, c.FirstName
                                                select c;

            CollectionViewSource orderSource = (CollectionViewSource)this.FindResource("OrdersSource");
            orderSource.Source = this.OrderData;

            CollectionViewSource customerSource = (CollectionViewSource)this.FindResource("CustomerLookup");
            customerSource.Source = customerList;   //.ToArray(); //.ToList();  // A simple list is OK here since we are not editing Customers

            this.View = (ListCollectionView)orderSource.View;
        }
        public StatementVm(List<StatementDataModel> statementList, IEnumerable<Signal> avalibleSignals)
        {
            IS_SAVED = false;
            _avalibleSignals = avalibleSignals;
            _statementValuesList = statementList;

            //var statementvalue = new StatementDataModel(_avalibleSignals, StatementDataModelType.RegularStatement);
            //statementvalue.IsAlgebraOperatorVisible = false;
            //statementvalue.PropertyChanged += StatementValueField_Changed;
            //_statementValuesList.Add(statementvalue);

            ObservableStatements = new ListCollectionView(_statementValuesList);
            ObservableStatements.CollectionChanged += ObservableStatements_CollectionChanged;

            _addRegularExpressionCommand = new DelegateCommand<string>(
                (s) => { AddRegularExpression(); }, //Execute
                (s) => { return true; } //CanExecute
                );

            _addTimeExpressionCommand = new DelegateCommand<string>(
                (s) => { AddTimeExpression(); }, //Execute
                (s) => { return true; } //CanExecute
                );

            _removeExpressionCommand = new DelegateCommand<string>(
                (s) => { RemoveRow(); }, //Execute
                (s) => { return true; } //CanExecute
                );

            _saveStatementCommand = new DelegateCommand<string>(
                (s) => { Save(); }, //Execute
                (s) => { return IsDataValid(); } //CanExecute
                );
        }
Пример #9
0
        public UserPositionsVM(UserVM user, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentUser = user;
            UserDataService = new UserDataService(UnitOfWork);
            PositionDataService = new PositionDataService(UnitOfWork);
            AccessRuleDataService = new AccessRuleDataService(UnitOfWork);
            UserDataService.PositionAdded += OnPositionAdded;
            UserDataService.PositionRemoved += OnPositionRemoved;


            var selectedVms = new ObservableCollection<UserPositionVM>();
            foreach (var userPosition in UserDataService.GetPositions(user.Id))
            {
                selectedVms.Add(new UserPositionVM(userPosition, Access, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<PositionVM>();
            foreach (var position in PositionDataService.GetActives(SoheilEntityType.Users, CurrentUser.Id))
            {
                allVms.Add(new PositionVM(position, Access, PositionDataService));
            }
            AllItems = new ListCollectionView(allVms);

            //AllItems = new ListCollectionView(PositionDataService.GetActives());
            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Пример #10
0
        public VideoSettingsViewModel() :
            base("Video", new Uri(typeof(VideoSettingsView).FullName, UriKind.Relative))
        {                       
            DirectoryPickerCommand = new Command(() =>
            {
                DirectoryPickerView directoryPicker = new DirectoryPickerView();
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;           
                vm.SelectedPath = VideoScreenShotLocation;
                vm.PathHistory = VideoScreenShotLocationHistory;

                if (directoryPicker.ShowDialog() == true)
                {
                    VideoScreenShotLocation = vm.SelectedPath;
                }
            });

            VideoScreenShotLocationHistory = Settings.Default.VideoScreenShotLocationHistory;

            if (String.IsNullOrEmpty(Settings.Default.VideoScreenShotLocation))
            {
                Settings.Default.VideoScreenShotLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            }

            VideoScreenShotSaveMode = new ListCollectionView(Enum.GetValues(typeof(Infrastructure.Constants.SaveLocation)));
            VideoScreenShotSaveMode.MoveCurrentTo(Settings.Default.VideoScreenShotSaveMode);
           
            VideoScreenShotLocation = Settings.Default.VideoScreenShotLocation;
            VideoScreenShotTimeOffset = Settings.Default.VideoScreenShotTimeOffset;          
            MinNrBufferedPackets = Settings.Default.VideoMinBufferedPackets;
            StepDurationSeconds = Settings.Default.VideoStepDurationSeconds;

            MaxNrBufferedPackets = 1000;
        }
Пример #11
0
        public override void CreateItems(object param)
        {
            var groupViewModels = new ObservableCollection<ProductVM>();
            foreach (var product in ProductDataService.GetActives())
            {
                groupViewModels.Add(new ProductVM(product, Access, ProductDataService, ProductGroupDataService));
            }
            GroupItems = new ListCollectionView(groupViewModels);

            var viewModels = new ObservableCollection<FpcVm>();
			foreach (var model in FpcDataService.GetAll().Where(x => x.RecordStatus != Status.Deleted && x.Product.RecordStatus == Status.Active))
			{
				viewModels.Add(new FpcVm(model, GroupItems, Access, FpcDataService));
			}
            Items = new ListCollectionView(viewModels);

            if (viewModels.Count > 0)
            {
                CurrentContent = (ISplitItemContent)Items.CurrentItem;
                CurrentContent.IsSelected = true;
            }

            if (Items.GroupDescriptions != null)
                Items.GroupDescriptions.Add(new PropertyGroupDescription("SelectedGroupVM.Id"));
        }
Пример #12
0
        public DefectionProductsVM(DefectionVM defection, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentDefection = defection;
            DefectionDataService = new DefectionDataService(UnitOfWork);
            DefectionDataService.ProductAdded += OnProductAdded;
            DefectionDataService.ProductRemoved += OnProductRemoved;
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductGroupDataService = new ProductGroupDataService(UnitOfWork);
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ProductDefectionVM>();
            foreach (var productDefection in DefectionDataService.GetProducts(defection.Id))
            {
                selectedVms.Add(new ProductDefectionVM(productDefection, Access, ProductDefectionDataService, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<ProductVM>();
            foreach (var product in ProductDataService.GetActives(SoheilEntityType.Defections, CurrentDefection.Id))
            {
                allVms.Add(new ProductVM(product, Access, ProductDataService, ProductGroupDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     var collection = value as IList;
     var view = new ListCollectionView(collection);
     view.CustomSort = new SortByTypeComparer();
     return view;
 }
Пример #14
0
        public ChangeCarParentDialog(CarObject car) {
            InitializeComponent();
            DataContext = this;

            Buttons = new[] {
                OkButton, 
                CreateExtraDialogButton(ControlsStrings.CarParent_MakeIndependent, () => {
                    Car.ParentId = null;
                    Close();
                }),
                CancelButton
            };

            Car = car;
            Filter = car.Brand == null ? "" : @"brand:" + car.Brand;

            CarsListView = new ListCollectionView(CarsManager.Instance.LoadedOnly.Where(x => x.ParentId == null && x.Id != Car.Id).ToList()) {
                CustomSort = this
            };

            UpdateFilter();
            if (car.Parent == null) {
                CarsListView.MoveCurrentToPosition(0);
            } else {
                CarsListView.MoveCurrentTo(car.Parent);
            }

            Closing += CarParentEditor_Closing;
        }
        public ImageSearchSettingsViewModel() : base("Image Search Plugin", new Uri(typeof(ImageSearchSettingsView).FullName, UriKind.Relative))
        {            
            DirectoryPickerCommand = new Command(() =>
            {                            
                DirectoryPickerView directoryPicker = new DirectoryPickerView();                
                DirectoryPickerViewModel vm = (DirectoryPickerViewModel)directoryPicker.DataContext;
                vm.SelectedPath = FixedDownloadPath;

                if (directoryPicker.ShowDialog() == true)
                {
                    FixedDownloadPath = vm.SelectedPath;
                    MiscUtils.insertIntoHistoryCollection(FixedDownloadPathHistory, FixedDownloadPath);
                }
            });

            ImageSaveMode = new ListCollectionView(Enum.GetValues(typeof(MediaViewer.Infrastructure.Constants.SaveLocation)));
            ImageSaveMode.MoveCurrentTo(ImageSearchPlugin.Properties.Settings.Default.ImageSaveMode);
            
            if (String.IsNullOrEmpty(ImageSearchPlugin.Properties.Settings.Default.FixedDownloadPath))
            {
                FixedDownloadPath = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            }
            else
            {
                FixedDownloadPath = ImageSearchPlugin.Properties.Settings.Default.FixedDownloadPath;
            }
           
            FixedDownloadPathHistory = ImageSearchPlugin.Properties.Settings.Default.FixedDownloadPathHistory;
            
        }      
Пример #16
0
        public ActionPlanFishbonesVM(ActionPlanVM actionPlan, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentActionPlan = actionPlan;
            ActionPlanDataService = new ActionPlanDataService(UnitOfWork);
            ActionPlanDataService.FishboneNodeAdded += OnFishboneNodeAdded;
            ActionPlanDataService.FishboneNodeRemoved += OnFishboneNodeRemoved;
            FishboneActionPlanDataService = new FishboneActionPlanDataService(UnitOfWork);
            FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ActionPlanFishboneVM>();
            foreach (var fishboneNodeActionPlan in ActionPlanDataService.GetFishboneNodes(actionPlan.Id))
            {
                selectedVms.Add(new ActionPlanFishboneVM(fishboneNodeActionPlan,access,RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<FishboneNodeVM>();
            foreach (var fishboneNode in FishboneNodeDataService.GetActives())
            {
                allVms.Add(new FishboneNodeVM(fishboneNode, Access, FishboneNodeDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Пример #17
0
        public FishboneNodeActionPlansVM(FishboneNodeVM defection, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentFishboneNode = defection;
            FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);
            FishboneNodeDataService.ActionPlanAdded += OnActionPlanAdded;
            FishboneNodeDataService.ActionPlanRemoved += OnActionPlanRemoved;
            ActionPlanDataService = new ActionPlanDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ActionPlanFishboneVM>();
            foreach (var productFishboneNode in FishboneNodeDataService.GetActionPlans(defection.Id))
            {
                selectedVms.Add(new ActionPlanFishboneVM(productFishboneNode, Access, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<ActionPlanVM>();
            foreach (var actionPlan in ActionPlanDataService.GetActives())
            {
                allVms.Add(new ActionPlanVM(actionPlan, Access, ActionPlanDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Пример #18
0
        public override void CreateItems(object param)
        {
            RootNode = new CauseVM(Access, CauseDataService) { Title = string.Empty, Id = -1, ParentId = -2 };

            var viewModels = new ObservableCollection<CauseVM>();
            foreach (var model in CauseDataService.GetAll())
            {
                viewModels.Add(new CauseVM(model, Access, CauseDataService));
            }

            foreach (CauseVM item in viewModels)
            {
                if (item.ParentId == RootNode.Id)
                {
                    RootNode.ChildNodes.Add(item);
                    break;
                }
            }


            Items = new ListCollectionView(viewModels);

            if (viewModels.Count > 0)
            {
                CurrentContent = (ISplitNodeContent)Items.CurrentItem;
                CurrentContent.IsSelected = true;
            }
        }
        public PositionOrganizationChartsVM(PositionVM position, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentPosition = position;
            PositionDataService = new PositionDataService(UnitOfWork);
            PositionDataService.OrganizationChartAdded += OnOrganizationChartAdded;
            PositionDataService.OrganizationChartRemoved += OnOrganizationChartRemoved;
            OrganizationChartDataService = new OrganizationChartDataService(UnitOfWork);
            OrganizationChartPositionDataService = new OrganizationChartPositionDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<OrganizationChartPositionVM>();
            foreach (var positionOrganizationChart in PositionDataService.GetOrganizationCharts(position.Id))
            {
                selectedVms.Add(new OrganizationChartPositionVM(positionOrganizationChart, Access, OrganizationChartPositionDataService));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<OrganizationChartVM>();
            foreach (var organizationChart in OrganizationChartDataService.GetActives())
            {
                allVms.Add(new OrganizationChartVM(organizationChart, Access, OrganizationChartDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
            
        }
Пример #20
0
        //----------------------------------------------------- 
        //
        //  Constructors 
        // 
        //-----------------------------------------------------
 
        // Set up a ListCollectionView over the
        // snapshot.  We will delegate all CollectionView functionality
        // to this view.
        internal EnumerableCollectionView(IEnumerable source) 
            : base(source, -1)
        { 
            _snapshot = new ObservableCollection<object>(); 

            LoadSnapshotCore(source); 

            if (_snapshot.Count > 0)
            {
                SetCurrent(_snapshot[0], 0, 1); 
            }
            else 
            { 
                SetCurrent(null, -1, 0);
            } 

            // if the source doesn't raise collection change events, try to
            // detect changes by polling the enumerator
            _pollForChanges = !(source is INotifyCollectionChanged); 

            _view = new ListCollectionView(_snapshot); 
 
            INotifyCollectionChanged incc = _view as INotifyCollectionChanged;
            incc.CollectionChanged += new NotifyCollectionChangedEventHandler(_OnViewChanged); 

            INotifyPropertyChanged ipc = _view as INotifyPropertyChanged;
            ipc.PropertyChanged += new PropertyChangedEventHandler(_OnPropertyChanged);
 
            _view.CurrentChanging += new CurrentChangingEventHandler(_OnCurrentChanging);
            _view.CurrentChanged += new EventHandler(_OnCurrentChanged); 
        } 
Пример #21
0
        public ProductDefectionsVM(ProductVM product, AccessType access):base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentProduct = product;
            ProductDataService = new ProductDataService(UnitOfWork);
            ProductDataService.DefectionAdded += OnDefectionAdded;
            ProductDataService.DefectionRemoved += OnDefectionRemoved;
            DefectionDataService = new DefectionDataService(UnitOfWork);
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ProductDefectionVM>();
            foreach (var productDefection in ProductDataService.GetDefections(product.Id))
            {
                selectedVms.Add(new ProductDefectionVM(productDefection, Access, ProductDefectionDataService, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<DefectionVM>();
            foreach (var defection in DefectionDataService.GetActives(SoheilEntityType.Products, CurrentProduct.Id))
            {
                allVms.Add(new DefectionVM(defection, Access, DefectionDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
            IncludeRangeCommand = new Command(IncludeRange, CanIncludeRange);
            ExcludeRangeCommand = new Command(ExcludeRange, CanExcludeRange);
        }
Пример #22
0
        public OperatorActivitiesVM(OperatorVM opr, AccessType access) : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentOperator = opr;
            OperatorDataService = new OperatorDataService(UnitOfWork);
            OperatorDataService.ActivityAdded += OnActivityAdded;
            OperatorDataService.ActivityRemoved += OnActivityRemoved;
            ActivityDataService = new ActivityDataService(UnitOfWork);
            ActivityOperatorDataService = new ActivitySkillDataService(UnitOfWork);
            ActivityGroupDataService = new ActivityGroupDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ActivityOperatorVM>();
            foreach (var generalActivitySkill in OperatorDataService.GetActivities(opr.Id))
            {
                selectedVms.Add(new ActivityOperatorVM(generalActivitySkill, Access, ActivityOperatorDataService, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<ActivityVM>();
            foreach (var activity in ActivityDataService.GetActives()
				.Where(activity => !selectedVms.Any(activityOperator => activityOperator.ActivityId == activity.Id)))
            {
                allVms.Add(new ActivityVM(activity, Access, ActivityDataService, ActivityGroupDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
            
        }
        public TriggerVm(Trigger trigger, IEnumerable<Signal> avalibleSignals)
        {
            IS_SAVED = false;
            _trigger = trigger;
            _avalibleSignals = avalibleSignals;

            //Testing
            var triggerstatedata = new TriggerStateData(_avalibleSignals);
            var statement = new Statement.Equals(new Signal() { Name = "A1" }, 0);
            triggerstatedata.StateNumber = 1;

            //The trigger will always start with one state initially
            _triggerStateDatas = new List<TriggerStateData>();
            _triggerStateDatas.Add(triggerstatedata);

            ObservableTriggerStates = new ListCollectionView(_triggerStateDatas);

            _saveCommand = new DelegateCommand<string>(
                     (s) => { SaveTrigger(); }, //Execute
                     (s) => { return _canSave; } //CanExecute
                     );
            _saveCommand = new DelegateCommand<string>(
                    (s) => { SaveTrigger(); }, //Execute
                    (s) => { return _canSave; } //CanExecute
                    );

            _saveCommand = new DelegateCommand<string>(
                    (s) => { SaveTrigger(); }, //Execute
                    (s) => { return _canSave; } //CanExecute
                    );
        }
Пример #24
0
 public OpenProject(IMainWindow main)
 {
     Instance       = this;
     FilteredSource = ((System.Windows.Data.ListCollectionView)System.Windows.Data.CollectionViewSource.GetDefaultView(Projects));
     Log.FunctionIndent("OpenProject", "OpenProject");
     try
     {
         InitializeComponent();
         if (RobotInstance.instance.Window is AgentWindow)
         {
             EditXAMLPanel.Visibility = Visibility.Hidden;
         }
         if (RobotInstance.instance.Window is AgentWindow)
         {
             PackageManagerPanel.Visibility = Visibility.Hidden;
         }
         this.main   = main;
         DataContext = this;
         RobotInstance.instance.PropertyChanged += Instance_PropertyChanged;
         UpdateProjectsList(true, true);
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     Log.FunctionOutdent("OpenProject", "OpenProject");
 }
 public ProcessorDetails(string code, params FileDetailViewModel[] fileDetails)
 {
     Code = code;
     FileDetails = new ListCollectionView(fileDetails);
     if(fileDetails.Length>0)
         FileDetails.MoveCurrentToFirst();
 }
Пример #26
0
        /// <summary>
        ///     Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            LoadUrlCommand = new RelayCommand(OnLoadUrl);
            ParseUrlCommand = new RelayCommand(OnParseUrl, () => !string.IsNullOrEmpty(URL));
            ExportCommand = new RelayCommand(OnExport);
            GetUrlsCommand = new RelayCommand(OnGetUrls);

            _catalogObservableList = new ObservableCollection<CatalogNodeViewModel>();
            CatalogCollectionView = new ListCollectionView(_catalogObservableList);

            if (IsInDesignMode)
            {
                // Code runs in Blend --> create design time data.
                URL = "http://hqfz.cnblgos.com";
                CnBlogName = "hqfz";
                var catalog = new CatalogNodeViewModel();
                catalog.CurrentEntity.Title = "Catalog1";
                var article = new ArticleViewModel();
                article.CurrentEntity.Title = "Article1";
                catalog.AddArticle(article);

                _catalogObservableList.Add(catalog);
            }
            else
            {
                // Code runs "for real"
                URL = "http://www.cnblogs.com/artech/default.html?page=1";
                CnBlogName = "artech";
            }
        }
        private void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            IQueryable<Order> query = from o in db.Orders.Include("OrderDetails")
                                        //where o.OrderDate >= System.Convert.ToDateTime("1/1/2009")
                                        orderby o.OrderDate descending, o.Customer.LastName
                                        select o;

            this.OrderData = new OrdersCollection(query, db);

            IQueryable<Customer> customerList = from c in db.Customers
                                                where c.Orders.Count > 0
                                                orderby c.LastName, c.FirstName
                                                select c;

            IQueryable<Product> productList = from p in db.Products
                                              orderby p.Name
                                              select p;

            this.MasterViewSource = (CollectionViewSource)this.FindResource("MasterViewSource");
            this.DetailViewSource = (CollectionViewSource)this.FindResource("DetailsViewSource");
            this.MasterViewSource.Source = this.OrderData;

            CollectionViewSource customerSource = (CollectionViewSource)this.FindResource("CustomerLookup");
            customerSource.Source = customerList.ToList();  //  A simple list is OK here since we are not editing Customers

            CollectionViewSource productSource = (CollectionViewSource)this.FindResource("ProductLookup");
            productSource.Source = productList.ToList();    //  A simple list is OK here since we are not editing Products

            this.MasterView = (ListCollectionView)this.MasterViewSource.View;
            MasterView.CurrentChanged += new EventHandler(MasterView_CurrentChanged);

            this.DetailsView = (BindingListCollectionView)this.DetailViewSource.View;
        }
        public TriggerVm(Trigger trigger, IEnumerable<Signal> avalibleSignals)
        {
            IS_SAVED = false;
            _trigger = trigger;
            _avalibleSignals = avalibleSignals;

            //The trigger will always start with one state initially
            _triggerStateDatas = new List<TriggerStateDataModel>();
            _triggerStateDatas.Add(new TriggerStateDataModel(_avalibleSignals));

            ObservableTriggerStates = new ListCollectionView(_triggerStateDatas);

            _saveCommand = new DelegateCommand<string>(
                     (s) => { SaveTrigger(); }, //Execute
                     (s) => { return true; } //CanExecute
                     );

            _addCommand = new DelegateCommand<string>(
                    (s) => { AddState(); }, //Execute
                    (s) => { return true; } //CanExecute
                    );

            _removeCommand = new DelegateCommand<string>(
                    (s) => { RemoveState(); }, //Execute
                    (s) => { return true; } //CanExecute
                    );
        }
Пример #29
0
        public AccessRulePositionsVM(AccessRuleVM accessRule, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentAccessRule = accessRule;
            AccessRuleDataService = new AccessRuleDataService(UnitOfWork);
            AccessRuleDataService.PositionAdded += OnPositionAdded;
            AccessRuleDataService.PositionRemoved += OnPositionRemoved;
            PositionDataService = new PositionDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<PositionAccessRuleVM>();
            foreach (var accessRulePosition in AccessRuleDataService.GetPositions(accessRule.Id))
            {
                selectedVms.Add(new PositionAccessRuleVM(accessRulePosition, Access, RelationDirection.Reverse));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<PositionVM>();
            foreach (var position in PositionDataService.GetActives())
            {
                allVms.Add(new PositionVM(position, Access,PositionDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include,CanInclude);
            ExcludeCommand = new Command(Exclude,CanExclude);
        }
Пример #30
0
        public UnitViewModel(AppConfig config, MainViewModel mvm)
        {
            m_config = config;
            m_mvm = mvm;

            SendToSlotCommand = new DelegateCommand<string>(SendToSlot, x => SelectedIdol != null);
            SaveCommand = new DelegateCommand(Save, () => !string.IsNullOrEmpty(UnitName));
            DeleteCommand = new DelegateCommand(Delete, () => Units.Contains(SelectedUnit));
            MoveToSlotCommand = new DelegateCommand<string>(MoveToSlot, CanMoveToSlot);
            ResetSlotCommand = new DelegateCommand<string>(ResetSlot, CanResetSlot);
            HighlightCommand = new DelegateCommand<string>(Highlight, CanHighlight);
            CopyIidCommand = new DelegateCommand(CopyIid, () => SelectedIdol != null);
            SetGuestCenterCommand = new DelegateCommand(SetGuestCenter, () => SelectedIdol != null);
            CopyIidFromSlotCommand = new DelegateCommand<string>(CopyIidFromSlot);
            SetGuestCenterFromSlotCommand = new DelegateCommand<string>(SetGuestCenterFromSlot);

            Idols = new ListCollectionView(m_config.OwnedIdols);
            Filter = new IdolFilter(config, Idols, false);
            Filter.SetConfig(config.UnitIdolFilterConfig);

            Units = m_config.Units;

            TemporalUnit = new Unit();
            SelectedUnit = Units.FirstOrDefault();

            foreach (var option in config.UnitIdolSortOptions)
            {
                Idols.SortDescriptions.Add(option.ToSortDescription());
            }
        }
Пример #31
0
        public ActivityOperatorsVM(ActivityVM activity, AccessType access)
            : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentActivity = activity;
            ActivityDataService = new ActivityDataService(UnitOfWork);
            ActivityDataService.OperatorAdded += OnOperatorAdded;
            ActivityDataService.OperatorRemoved += OnOperatorRemoved;
            OperatorDataService = new OperatorDataService(UnitOfWork);
            ActivityOperatorDataService = new ActivitySkillDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<ActivityOperatorVM>();
            foreach (var activityOperator in ActivityDataService.GetOperators(activity.Id))
            {
                selectedVms.Add(new ActivityOperatorVM(activityOperator, Access, ActivityOperatorDataService, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<OperatorVM>();
            foreach (var opr in OperatorDataService.GetActives(SoheilEntityType.Activities, CurrentActivity.Id))
            {
                allVms.Add(new OperatorVM(opr, Access, OperatorDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
        }
Пример #32
0
        public static void ChangeSortMethod <FI, DI, FSI>(
            this System.Collections.ObjectModel.ObservableCollection <NavigationItemViewModel <FI, DI, FSI> > collection,
            SortCriteria sortBy, System.ComponentModel.ListSortDirection sortDirection)
            where FI : FSI
            where DI : FSI
        {
            System.Windows.Data.ListCollectionView dataView =
                (System.Windows.Data.ListCollectionView)
                    (System.Windows.Data.CollectionViewSource.GetDefaultView(collection));

            dataView.SortDescriptions.Clear();
            dataView.CustomSort = null;

            SortDirectionType direction = sortDirection == System.ComponentModel.ListSortDirection.Ascending ?
                                          SortDirectionType.sortAssending : SortDirectionType.sortDescending;

            dataView.CustomSort = new EntryComparer <FI, DI, FSI>(sortBy, direction)
            {
                IsFolderFirst = true
            };
        }
Пример #33
0
 public static void ResetComparisons(ListCollectionView lcv)
 {
     lcv.ResetComparisons();
 }
Пример #34
0
 public static void ResetAverageCopy(ListCollectionView lcv)
 {
     lcv.ResetAverageCopy();
 }
Пример #35
0
 public static int GetComparisons(ListCollectionView lcv)
 {
     return(lcv.GetComparisons());
 }
Пример #36
0
 public static int GetCopies(ListCollectionView lcv)
 {
     return(lcv.GetCopies());
 }
Пример #37
0
 public static double GetAverageCopy(ListCollectionView lcv)
 {
     return(lcv.GetAverageCopy());
 }
Пример #38
0
 public static void ResetCopies(ListCollectionView lcv)
 {
     lcv.ResetCopies();
 }