Ejemplo n.º 1
0
 void BtnDuration_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrWhiteSpace(this.StartEvent.Text) || String.IsNullOrWhiteSpace(this.StopEvent.Text))
     {
         return;
     }
     QueryModel queryModel = new QueryModel(this.Model);
     DurationWindow durationWindow = new DurationWindow();
     durationWindow.Model = queryModel;
     durationWindow.ShowDuration(this.FilterModel.Resolver,
                                 this.Model.StartTime,
                                 this.Model.StopTime,
                                 this.StartEvent.Text,
                                 this.StopEvent.Text);
 }
Ejemplo n.º 2
0
        private void ShowNewQueryWindow(string fileName,
            bool show,
            Dictionary<string, ParameterResolver> resolvers)
        {
            if (QueryWindows.Activate(fileName))
            {
                return;
            }

            QueryModel queryModel = new QueryModel(this.Model);
            QueryEditorModel editor = new QueryEditorModel();
            editor.ParameterResolvers = resolvers;
            editor.LoadFile(fileName);
            QueryEditorView view = new QueryEditorView(editor, queryModel);
            QueryWindows.Create(view, show);

            // Add to the menu collection.
            MenuItem newMenu = new MenuItem();
            newMenu.Click += (s, eargs) => QueryWindows.Activate(view);
            newMenu.DataContext = view;
            Binding b = new Binding("Title");
            b.Source = view;
            newMenu.SetBinding(MenuItem.HeaderProperty, b);
            int index = QueryWindows.Count();
            if (String.IsNullOrEmpty(fileName))
            {
                //  Add ":" to give create an invalid filename.
                view.Title = string.Format("{0}{1}New Query", index, QueryEditorView.TitleSeperator);
            }
            else
            {
                view.Title = string.Format("{0}{1}{2}", index, QueryEditorView.TitleSeperator, fileName);
            }

            this.QueriesMenu.Items.Add(newMenu);

            // Remove from the menu collection upon close.
            CancelEventHandler closeHandler = (sender, args) =>
            {
                QueryWindows.Activate(view);
                view.Close(args);
            };

            queryModel.OnDisposed += (s, e1) =>
            {
                this.QueriesMenu.Items.Remove(newMenu);
                QueryWindows.Remove(view);
                MainModel.CloseEventHandler -= closeHandler;
            };

            MainModel.CloseEventHandler += closeHandler;
        }