<commit_before>﻿using System;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
using Plainion.Flames.Controls;
using Plainion.Flames.Infrastructure.Services;
using Plainion.Flames.Infrastructure.ViewModels;
using Plainion.Flames.Presentation;

namespace Plainion.Flames.Viewer.ViewModels
{
    // https://rachel53461.wordpress.com/2011/12/
    [Export]
    class FlamesBrowserViewModel : ViewModelBase
    {
        private bool myFlamesVisible;

        internal FlamesBrowserViewModel()
        {
            myFlamesVisible = true;

            ExpandCollapseCommand = new DelegateCommand<FlameHeader>( h => h.Flame.IsExpanded = !h.Flame.IsExpanded );
            HideCommand = new DelegateCommand<FlameHeader>( h => h.Flame.Visibility = ContentVisibility.Invisible );
            RenameCommand = new DelegateCommand<FlameHeader>( h => h.IsInEditMode = true );
            ZoomHomeCommand = new DelegateCommand( OnZoomHome );
            ZoomInCommand = new DelegateCommand( OnZoomIn );
            ZoomOutCommand = new DelegateCommand( OnZoomOut );
            ClearSelectionsCommand = new DelegateCommand( ClearSelections );

            ToggleViewCommand = new DelegateCommand( () => FlamesVisible = !FlamesVisible );
            SpawnSettingsWindowCommand = new DelegateCommand( OnSpawnSettingsWindow );
            SpawnSettingsRequest = new InteractionRequest<Notification>();
        }

        protected override void OnProjectChanged()
        {
            if( ProjectService.Project != null && ProjectService.Project.WasDeserialized )
            {
                // http://stackoverflow.com/questions/13026826/execute-command-after-view-is-loaded-wpf-mvvm
                Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.ApplicationIdle, new Action( () =>
                {
                    // we loaded user settings from disk which might filter out certain threads or calls.
                    // lets display settings window to the user so that it is more obvious that everything
                    // is visible in the flames.
                    SpawnSettingsWindowCommand.Execute( null );

                    // TODO: we want to navigate to process-threads-view but currently we cannot access viewmodel :(
                    //Settings.SelectedTabIndex = 1;
                } ) );
            }
        }

        public bool FlamesVisible
        {
            get { return myFlamesVisible; }
            set { SetProperty( ref myFlamesVisible, value ); }
        }

        public ICommand ExpandCollapseCommand { get; private set; }
        public ICommand HideCommand { get; private set; }
        public ICommand RenameCommand { get; private set; }
        public ICommand ZoomHomeCommand { get; private set; }
        public ICommand ZoomInCommand { get; private set; }
        public ICommand ZoomOutCommand { get; private set; }
        public ICommand ClearSelectionsCommand { get; private set; }
<commit_msg>Settings view first opened when tracelog loaded<commit_after>﻿using System;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
using Plainion.Flames.Controls;
using Plainion.Flames.Infrastructure.Services;
using Plainion.Flames.Infrastructure.ViewModels;
using Plainion.Flames.Model;
using Plainion.Flames.Presentation;

namespace Plainion.Flames.Viewer.ViewModels
{
    // https://rachel53461.wordpress.com/2011/12/
    [Export]
    class FlamesBrowserViewModel : ViewModelBase
    {
        private bool myFlamesVisible;

        internal FlamesBrowserViewModel()
        {
            myFlamesVisible = true;

            ExpandCollapseCommand = new DelegateCommand<FlameHeader>( h => h.Flame.IsExpanded = !h.Flame.IsExpanded );
            HideCommand = new DelegateCommand<FlameHeader>( h => h.Flame.Visibility = ContentVisibility.Invisible );
            RenameCommand = new DelegateCommand<FlameHeader>( h => h.IsInEditMode = true );
            ZoomHomeCommand = new DelegateCommand( OnZoomHome );
            ZoomInCommand = new DelegateCommand( OnZoomIn );
            ZoomOutCommand = new DelegateCommand( OnZoomOut );
            ClearSelectionsCommand = new DelegateCommand( ClearSelections );

            ToggleViewCommand = new DelegateCommand( () => FlamesVisible = !FlamesVisible );
            SpawnSettingsWindowCommand = new DelegateCommand( OnSpawnSettingsWindow );
            SpawnSettingsRequest = new InteractionRequest<Notification>();
        }

        protected override void OnTraceLogChanged( ITraceLog oldValue )
        {
            if( ProjectService.Project != null && ProjectService.Project.WasDeserialized && TraceLog != null )
            {
                // http://stackoverflow.com/questions/13026826/execute-command-after-view-is-loaded-wpf-mvvm
                Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.ApplicationIdle, new Action( () =>
                {
                    // we loaded user settings from disk which might filter out certain threads or calls.
                    // lets display settings window to the user so that it is more obvious that everything
                    // is visible in the flames.
                    SpawnSettingsWindowCommand.Execute( null );

                    // TODO: we want to navigate to process-threads-view but currently we cannot access viewmodel :(
                    //Settings.SelectedTabIndex = 1;
                } ) );
            }
        }

        public bool FlamesVisible
        {
            get { return myFlamesVisible; }
            set { SetProperty( ref myFlamesVisible, value ); }
        }

        public ICommand ExpandCollapseCommand { get; private set; }
        public ICommand HideCommand { get; private set; }
        public ICommand RenameCommand { get; private set; }
        public ICommand ZoomHomeCommand { get; private set; }
        public ICommand ZoomInCommand { get; private set; }
        public ICommand ZoomOutCommand { get; private set; }
        public ICommand ClearSelectionsCommand { get; private set; }

{'fraction_non_alphanumeric': 0.07809076682316118, 'fraction_numerical': 0.006259780907668232, 'mean_word_length': 2.5387596899224807, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5450848', 'n_tokens_mistral': 1681, 'n_tokens_neox': 1570, 'n_words': 412}