public ExpressionFilterEditor(ExpressionArguments arguments, Action<FilterExpression> addFilterExpression) {
			InitializeComponent();
			this.arguments = arguments;
			this.addFilterExpression = addFilterExpression;

			Localization();
			Init();
		}
Exemple #2
0
        public void Init(ExpressionArguments arguments, bool IsIncludeEvents = true)
        {
            this.arguments = arguments;
            if (IsIncludeEvents)
            {
                includeEvents.Visibility = System.Windows.Visibility.Visible;
            }
            //panelFilterEditor.Children.Add(new ExpressionFilterEditor());
            if (AppDefaults.visualSettings.UseOnlyCommonFilterView)
            {
                exprEditor = new ExpressionDefaultEditor(arguments, AddFilter);
            }
            else
            {
                exprEditor = new ExpressionFilterEditor(arguments, AddFilter);
            }
            panelFilterEditor.Children.Add((UserControl)exprEditor);


            filtersList = new ObservableCollection <FilterExpression>();

            //buttons initialization
            //Delete filter button
            btnDeleteFilter.IsEnabled = valueFilters.SelectedItem == null ? false : true;
            //Current filter list
            valueFilters.ItemsSource       = filtersList;
            valueFilters.SelectionChanged += new SelectionChangedEventHandler((o, e) => {
                if (valueFilters.SelectedItem == null)
                {
                    btnDeleteFilter.IsEnabled = false;
                }
                else
                {
                    btnDeleteFilter.IsEnabled = true;
                    FilterSelected((FilterExpression)valueFilters.SelectedItem);
                }
            });

            btnDeleteFilter.Click += new RoutedEventHandler((o, e) => {
                if (valueFilters.SelectedItem == null)
                {
                    return;
                }
                FilterExpression sitem = valueFilters.SelectedItem as FilterExpression;
                if (sitem != null)
                {
                    filtersList.Remove(sitem);
                }
            });

            //fill startup filters
            arguments.messageContentFilters.ForEach(f => {
                filtersList.Add(ContentFilterExpression.CreateFilter(f));
            });
            arguments.topicExpressionFilters.ForEach(f => {
                filtersList.Add(TopicFilterExpression.CreateFilter(f));
            });
        }
        public ExpressionDefaultEditor(ExpressionArguments arguments, Action <FilterExpression> addFilterExpression)
        {
            InitializeComponent();
            this.arguments           = arguments;
            this.addFilterExpression = addFilterExpression;

            Localization();
            Init();
        }
		public void Init(ExpressionArguments arguments, bool IsIncludeEvents = true) {
			this.arguments = arguments;
			if (IsIncludeEvents) {
				includeEvents.Visibility = System.Windows.Visibility.Visible;
			}
			//panelFilterEditor.Children.Add(new ExpressionFilterEditor());
			if (AppDefaults.visualSettings.UseOnlyCommonFilterView)
				exprEditor = new ExpressionDefaultEditor(arguments, AddFilter);
			else { 
				exprEditor = new ExpressionFilterEditor(arguments, AddFilter);
			}
			panelFilterEditor.Children.Add((UserControl)exprEditor);


			filtersList = new ObservableCollection<FilterExpression>();

			//buttons initialization
			//Delete filter button
			btnDeleteFilter.IsEnabled = valueFilters.SelectedItem == null ? false : true;
			//Current filter list
			valueFilters.ItemsSource = filtersList;
			valueFilters.SelectionChanged += new SelectionChangedEventHandler((o, e) => {
				if (valueFilters.SelectedItem == null)
					btnDeleteFilter.IsEnabled = false;
				else {
					btnDeleteFilter.IsEnabled = true;
					FilterSelected((FilterExpression)valueFilters.SelectedItem);
				}
			});

			btnDeleteFilter.Click += new RoutedEventHandler((o, e) => {
				if (valueFilters.SelectedItem == null)
					return;
				FilterExpression sitem = valueFilters.SelectedItem as FilterExpression;
				if (sitem != null) {
					filtersList.Remove(sitem);
				}
			});

			//fill startup filters
			arguments.messageContentFilters.ForEach(f => {
				filtersList.Add(ContentFilterExpression.CreateFilter(f));
			});
			arguments.topicExpressionFilters.ForEach(f => {
				filtersList.Add(TopicFilterExpression.CreateFilter(f));
			});
		}
		private void Init(Model model) {
			this.DataContext = model;
			this.model = model;
			if (model.topicSet != null && model.topicSet.Any != null) {
				ExploreNamespaces(model.topicSet.Any);
			}
			
			InitializeComponent();

			//TODO: possible incorrect behaviour when multiple instances of odm are running
			if (AppDefaults.visualSettings.EventsCollect_IsEnabled) {
				var fi = AppDefaults.MetadataFileInfo;
				if (fi.Exists) {
					fi.Delete();
				}
			}

			ExpressionArguments args = new ExpressionArguments(
				model.messageContentFilterDialects, model.messageContentFilters,
				model.topicExpressionDialects, model.topicExpressionFilters, model.topicSet, namespaces);
			expressionFilters.Init(args);

			//commands
			OnCompleted += () => {
				disposables.Dispose();
				subscription.Dispose();
			};
			ApplyCmd = new DelegateCommand(
				() => {
					FillModel();
					Success(new Result.Apply(model)); 
				},() => true
			);

			//Start meta stream
			profile = activityContext.container.Resolve<Profile>();
			dispatch = Dispatcher.CurrentDispatcher;
			MetaData = new ObservableCollection<MetadataUnit>();

			VideoInfo = activityContext.container.Resolve<IVideoInfo>();
			VideoInfo.Resolution = new Size(800, 600);
			Reload(activityContext.container.Resolve<INvtSession>());

			includeAnalitycs.CreateBinding(CheckBox.IsCheckedProperty, model, x => x.includeAnalitycs, (m, v) => { m.includeAnalitycs = v; });
			includePtzPosition.CreateBinding(CheckBox.IsCheckedProperty, model, x => x.includePtzPosition, (m, v) => { m.includePtzPosition = v; });
			includePtzStatus.CreateBinding(CheckBox.IsCheckedProperty, model, x => x.includePtzStatus, (m, v) => { m.includePtzStatus = v; });
			expressionFilters.CreateBinding(ExpressionFilterControl.IsIncludeEventsProperty, model, x => { return x.includeEvents; }, (m, v) => { m.includeEvents = v; });
			//includeEvents.CreateBinding(CheckBox.IsCheckedProperty, model, x => x.includeEvents, (m, v) => { m.includeEvents = v; });

			includePtzPosition.CreateBinding(CheckBox.VisibilityProperty, model, x => x.isPtzPositionSupported ? Visibility.Visible : Visibility.Collapsed);
			includePtzStatus.CreateBinding(CheckBox.VisibilityProperty, model, x => x.isPtzStatusSupported ? Visibility.Visible : Visibility.Collapsed);
		}
        public void Init(DeviceEventsEventArgs evarg)
        {
            this.session = evarg.session;
            this.account = evarg.currentAccount;
            this.filters = evarg.filters;
            this.evarg   = evarg;

            eventAggregator = container.Resolve <EventAggregator>();

            this.CreateBinding(StateCommonProperty, this, x => {
                return(x.Current == States.Common ? Visibility.Visible : Visibility.Collapsed);
            });
            this.CreateBinding(StateLoadingProperty, this, x => {
                return(x.Current == States.Loading ? Visibility.Visible : Visibility.Collapsed);
            });
            this.CreateBinding(StateErrorProperty, this, x => {
                return(x.Current == States.Error ? Visibility.Visible : Visibility.Collapsed);
            });

            Current = States.Loading;
            eventPropSubscription = session.GetEventProperties()
                                    .ObserveOnCurrentDispatcher()
                                    .Subscribe(responce => {
                Current = States.Common;

                if (responce.TopicSet != null && responce.TopicSet.Any != null)
                {
                    ExploreNamespaces(responce.TopicSet.Any);
                }

                List <MessageContentFilter> contList = new List <MessageContentFilter>();
                List <TopicExpressionFilter> topList = new List <TopicExpressionFilter>();

                evarg.filters.Where(f => f.FilterType == FilterExpression.ftype.CONTENT).ForEach(x => {
                    var fex = (FilterExpression)x;
                    contList.Add(new MessageContentFilter()
                    {
                        dialect = fex.Dialect, expression = fex.Value, namespaces = fex.Namespaces
                    });
                });
                evarg.filters.Where(f => f.FilterType == FilterExpression.ftype.TOPIC).ForEach(x => {
                    var fex = (FilterExpression)x;
                    topList.Add(new TopicExpressionFilter()
                    {
                        dialect = fex.Dialect, expression = fex.Value, namespaces = fex.Namespaces
                    });
                });

                ExpressionArguments args = new ExpressionArguments(
                    responce.MessageContentFilterDialect, contList.ToArray(),
                    responce.TopicExpressionDialect, topList.ToArray(),
                    responce.TopicSet, namespaces);

                expressionFilters.Init(args, false);
            }, err => {
                Current      = States.Error;
                ErrorMessage = err.Message;
                dbg.Error(err);
            });

            btnApplyFilters.Click += new RoutedEventHandler((o, e) => {
                // resubscribe to events.
                evarg.filters.Clear();
                expressionFilters.filtersList.ForEach(item => {
                    evarg.filters.Add(item);
                });
                eventAggregator.GetEvent <AddEventsFilterClick>().Publish(evarg);
            });
            //Filter settings
            //ExpressionArguments args = new ExpressionArguments(
            //    model.messageContentFilterDialects, model.messageContentFilters,
            //    model.topicExpressionDialects, model.topicExpressionFilters, model.topicSet, namespaces);
            //expressionFilters.Init(args);
        }