Inheritance: INotifyPropertyChanged
コード例 #1
0
        public void SelectedTabItem_WithValidValue_RaisesPropertyChangedEvent()
        {
            // Setup
            var tabControlViewModel = new TabControlViewModel();

            bool propertyChangedTriggered      = false;
            PropertyChangedEventArgs eventArgs = null;

            tabControlViewModel.PropertyChanged += (o, e) =>
            {
                propertyChangedTriggered = true;
                eventArgs = e;
            };

            var tabViewModel = new TestTabViewModel();

            tabControlViewModel.Tabs.Add(tabViewModel);

            // Call
            tabControlViewModel.SelectedTabItem = tabViewModel;

            // Assert
            Assert.That(propertyChangedTriggered, Is.True);

            Assert.That(eventArgs, Is.Not.Null);
            Assert.That(eventArgs.PropertyName, Is.EqualTo(nameof(TabControlViewModel.SelectedTabItem)));
        }
コード例 #2
0
        public void GivenTabControlViewModelWithTabs_WhenRemovingTabAndRemovedTabRaisesPropertyChangedEvent_ThenTabControlDoesNotRaiseEvent()
        {
            // Given
            var tabControlViewModel = new TabControlViewModel();

            PropertyChangedEventArgs eventArgs = null;
            bool propertyChangedTriggered      = false;

            tabControlViewModel.PropertyChanged += (o, e) =>
            {
                eventArgs = e;
                propertyChangedTriggered = true;
            };

            var tabViewModel = new TestTabViewModel();

            tabControlViewModel.Tabs.Add(tabViewModel);

            var random = new Random(21);

            // When
            bool removeSuccessful = tabControlViewModel.Tabs.Remove(tabViewModel);

            Assert.That(removeSuccessful, Is.True);

            tabViewModel.TabProperty = random.Next();

            // Then
            Assert.That(propertyChangedTriggered, Is.False);
            Assert.That(eventArgs, Is.Null);
        }
コード例 #3
0
        public void GivenTabControlViewModelWithTabs_WhenTabRaisesPropertyChangedEvent_ThenTabControlViewRaisesPropertyChangedEvent()
        {
            // Given
            var tabControlViewModel = new TabControlViewModel();

            PropertyChangedEventArgs eventArgs = null;
            bool propertyChangedTriggered      = false;

            tabControlViewModel.PropertyChanged += (o, e) =>
            {
                eventArgs = e;
                propertyChangedTriggered = true;
            };

            var tabViewModel = new TestTabViewModel();

            tabControlViewModel.Tabs.Add(tabViewModel);

            var random = new Random(21);

            // When
            tabViewModel.TabProperty = random.Next();

            // Then
            Assert.That(propertyChangedTriggered, Is.True);
            Assert.That(eventArgs, Is.Not.Null);
            Assert.That(eventArgs.PropertyName, Is.EqualTo(nameof(TestTabViewModel.TabProperty)));
        }
コード例 #4
0
ファイル: MainWindowViewModel.cs プロジェクト: alibghz/urcie
 private void ShowMullionsView()
 {
     TabControlViewModel.OpenTab(
         new MullionsView(MullionsViewViewModel),
         "Mullion Types",
         MullionsViewViewModel,
         MullionsViewViewModel);
 }
コード例 #5
0
ファイル: MainWindowViewModel.cs プロジェクト: alibghz/urcie
 private void ShowFillingsView()
 {
     TabControlViewModel.OpenTab(
         new FillingsView(FillingsViewViewModel),
         "Filling Types",
         FillingsViewViewModel,
         FillingsViewViewModel);
 }
コード例 #6
0
ファイル: MainWindowViewModel.cs プロジェクト: alibghz/urcie
 private void ShowSashesView()
 {
     TabControlViewModel.OpenTab(
         new SashesView(SashesViewViewModel),
         "Sash Types",
         SashesViewViewModel,
         SashesViewViewModel);
 }
コード例 #7
0
ファイル: MainWindowViewModel.cs プロジェクト: alibghz/urcie
 private void ShowAccessories()
 {
     TabControlViewModel.OpenTab(
         new AccessoriesView(AccessoriesViewViewModel),
         "Accessory Types",
         AccessoriesViewViewModel,
         AccessoriesViewViewModel);
 }
コード例 #8
0
ファイル: MainWindowViewModel.cs プロジェクト: alibghz/urcie
 private void ShowProfilesView()
 {
     TabControlViewModel.OpenTab(
         new ProfilesView(ProfilesViewViewModel),
         "Profile Types",
         ProfilesViewViewModel,
         ProfilesViewViewModel);
 }
コード例 #9
0
        public static void Constructor_ExpectedValues()
        {
            // Call
            var tabControlViewModel = new TabControlViewModel();

            // Assert
            Assert.That(tabControlViewModel, Is.InstanceOf <INotifyPropertyChanged>());
            Assert.That(tabControlViewModel, Is.InstanceOf <IDisposable>());
            Assert.That(tabControlViewModel.Tabs, Is.Empty);
        }
コード例 #10
0
        private TabControlViewModel CreateTabControlViewModel()
        {
            var tabControlViewModel = new TabControlViewModel();
            var generalSettingsTab  = new GeneralSimulationSettingsTabViewModel(calculation.SimulationSettings);

            tabControlViewModel.Tabs.Add(generalSettingsTab);
            tabControlViewModel.Tabs.Add(new EngineSettingsTabViewModel(calculation.EngineData));
            tabControlViewModel.Tabs.Add(new AircraftDataTabViewModel(calculation.AircraftData));
            tabControlViewModel.SelectedTabItem = generalSettingsTab;
            return(tabControlViewModel);
        }
コード例 #11
0
        public void SelectedTabItem_WithItemNotInTabs_ThrowsArgumentException()
        {
            // Setup
            var tabControlViewModel = new TabControlViewModel();

            // Call
            TestDelegate call = () => tabControlViewModel.SelectedTabItem = new TestTabViewModel();

            // Assert
            Assert.That(call, Throws.ArgumentException.And.Message.EqualTo("Item could not be found."));
        }
コード例 #12
0
        public void GivenViewModelWithInvalidCalculation_WhenCalculationPressed_ThenErrorLoggedAndInputNotSent()
        {
            // Given
            var random = new Random(21);

            var viewModel = new MainViewModel();
            TabControlViewModel tabControlViewModel   = viewModel.TabControlViewModel;
            ObservableCollection <ITabViewModel> tabs = tabControlViewModel.Tabs;

            // Precondition
            Assert.That(tabs, Has.Count.EqualTo(3));
            Assert.That(tabs[0], Is.TypeOf <GeneralSimulationSettingsTabViewModel>());
            Assert.That(tabs[1], Is.TypeOf <EngineSettingsTabViewModel>());
            Assert.That(tabs[2], Is.TypeOf <AircraftDataTabViewModel>());

            var generalSimulationSettingsViewModel = (GeneralSimulationSettingsTabViewModel)tabs[0];
            var engineSettingsViewModel            = (EngineSettingsTabViewModel)tabs[1];
            var aircraftDataViewModel = (AircraftDataTabViewModel)tabs[2];

            SetGeneralSettings(generalSimulationSettingsViewModel, random.Next());
            SetEngineData(engineSettingsViewModel, random.Next());
            SetAircraftData(aircraftDataViewModel, random.Next());

            aircraftDataViewModel.TakeOffWeight = double.NaN; // Set an invalid value

            using (new BalancedFieldLengthCalculationModuleFactoryConfig())
            {
                var instance = (TestBalancedFieldLengthCalculationModuleFactory)
                               BalancedFieldLengthCalculationModuleFactory.Instance;

                TestBalancedFieldLengthCalculationModule testModule = instance.TestModule;

                // Precondition
                MessageWindowViewModel messageWindowViewModel = viewModel.MessageWindowViewModel;
                Assert.That(messageWindowViewModel.Messages, Is.Empty);

                // When
                viewModel.CalculateCommand.Execute(null);

                // Then
                Assert.That(testModule.InputCalculation, Is.Null);

                OutputViewModel outputViewModel = viewModel.OutputViewModel;
                Assert.That(outputViewModel, Is.Null);

                IEnumerable <MessageType> messageTypes = messageWindowViewModel.Messages.Select(m => m.MessageType);
                Assert.That(messageTypes, Is.All.EqualTo(MessageType.Error));

                MessageContext firstMessage = messageWindowViewModel.Messages.First();
                Assert.That(firstMessage.Message, Is.EqualTo("Calculation failed."));
            }
        }
コード例 #13
0
        public MainControlViewModel()
        {
            context  = new ApplicationContext();
            mediator = new MainControlContextMediator(context, this);

            ToolbarTray       = new ToolbarTrayContainerViewModel();
            TabManager        = new TabControlViewModel();
            MainMenuViewModel = new MainMenuViewModel(context);

            ToolbarTray.Toolbars.Add(FileToolbar.Create(context));

            Initialize();
        }
コード例 #14
0
 /// <summary>
 /// Подпрограмма сохранения привязки тестов к форме в словарь
 /// </summary>
 /// <param name="indexTab1"></param>
 /// <param name="indexTab2"></param>
 /// <param name="indexPage"></param>
 /// <param name="data"></param>
 public void SetControl(int?indexTab1, int?indexTab2, int?indexPage, TabControlViewModel data)
 {
     if (indexTab1 == null || indexTab2 == null || indexPage == null)
     {
         return;
     }
     // Сохранение данных наприсованных элементов
     foreach (var item in DictCfgTest.Values.Where(i =>
                                                   indexTab1 == i.IndexTabL1 &&
                                                   indexTab2 == i.IndexTabL2 &&
                                                   indexPage == i.IndexPage))
     {
         item.SetControl(data);
     }
 }
コード例 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="nameTest"></param>
 /// <param name="indexTabL1"></param>
 /// <param name="indexTabL2"></param>
 /// <param name="indexPage"></param>
 /// <param name="nameTabL1"></param>
 /// <param name="nameTabL2"></param>
 /// <param name="maxProgress"></param>
 /// <param name="kindTask"></param>
 /// <param name="func"></param>
 public ConfigTestsClass(TypeTask kindTask, string nameTest,
                         int?indexTabL1, int?indexTabL2, int?indexPage, string nameTabL1, string nameTabL2,
                         double maxProgress, Func <int, int> func)
 {
     Type        = kindTask;
     NameTest    = nameTest;
     IndexTabL1  = indexTabL1;
     IndexTabL2  = indexTabL2;
     IndexPage   = indexPage;
     NameTabL1   = nameTabL1;
     NameTabL2   = nameTabL2;
     NameButton  = nameTest;
     Control     = null;
     MaxProgress = maxProgress;
     Function    = func;
 }
コード例 #16
0
ファイル: MainWindowViewModel.cs プロジェクト: alibghz/urcie
        private void EditUnit()
        {
            if (SelectedProject == null)
            {
                return;
            }

            if (TabControlViewModel.IsOpen(SelectedUnit))
            {
                TabControlViewModel.SelectTab(SelectedUnit);
            }
            else
            {
                TabControlViewModel.OpenTab(new UnitView(SelectedUnit, Storage), SelectedUnit.Code, SelectedUnit, SelectedUnit);
            }
        }
コード例 #17
0
        public static void Constructor_ExpectedValues()
        {
            // Call
            var mainViewModel = new MainViewModel();

            // Assert
            Assert.That(mainViewModel.OutputViewModel, Is.Null);
            Assert.That(mainViewModel.MessageWindowViewModel, Is.Not.Null);
            Assert.That(mainViewModel.TabControlViewModel, Is.Not.Null);
            Assert.That(mainViewModel.CalculateCommand, Is.Not.Null);

            TabControlViewModel tabControlViewModel   = mainViewModel.TabControlViewModel;
            ObservableCollection <ITabViewModel> tabs = tabControlViewModel.Tabs;

            Assert.That(tabs, Has.Count.EqualTo(3));
            Assert.That(tabs[0], Is.TypeOf <GeneralSimulationSettingsTabViewModel>());
            Assert.That(tabs[1], Is.TypeOf <EngineSettingsTabViewModel>());
            Assert.That(tabs[2], Is.TypeOf <AircraftDataTabViewModel>());
            Assert.That(tabControlViewModel.SelectedTabItem, Is.SameAs(tabs[0]));
        }
コード例 #18
0
        /// <summary>
        /// Creates a new instance of <see cref="MainViewModel"/>.
        /// </summary>
        public MainViewModel()
        {
            calculation = new BalancedFieldLengthCalculation();

#if DEBUG
            ConfigureSimulationSettings(calculation.SimulationSettings);
            ConfigureAircraftData(calculation.AircraftData);
            ConfigureEngineData(calculation.EngineData);
#endif

            InitializeValidationRuleProviders();
            TabControlViewModel tabControlViewModel = CreateTabControlViewModel();

            TabControlViewModel = tabControlViewModel;

            MessageWindowViewModel = new MessageWindowViewModel();
            OutputViewModel        = null;

            CalculateCommand = new RelayCommand(Calculate);
        }
コード例 #19
0
        public void GivenViewModel_WhenCalculationPressed_ThenInputArgumentSent()
        {
            // Given
            var random = new Random(21);

            var viewModel = new MainViewModel();
            TabControlViewModel tabControlViewModel   = viewModel.TabControlViewModel;
            ObservableCollection <ITabViewModel> tabs = tabControlViewModel.Tabs;

            // Precondition
            Assert.That(tabs, Has.Count.EqualTo(3));
            Assert.That(tabs[0], Is.TypeOf <GeneralSimulationSettingsTabViewModel>());
            Assert.That(tabs[1], Is.TypeOf <EngineSettingsTabViewModel>());
            Assert.That(tabs[2], Is.TypeOf <AircraftDataTabViewModel>());

            var generalSimulationSettingsViewModel = (GeneralSimulationSettingsTabViewModel)tabs[0];
            var engineSettingsViewModel            = (EngineSettingsTabViewModel)tabs[1];
            var aircraftDataViewModel = (AircraftDataTabViewModel)tabs[2];

            SetGeneralSettings(generalSimulationSettingsViewModel, random.Next());
            SetEngineData(engineSettingsViewModel, random.Next());
            SetAircraftData(aircraftDataViewModel, random.Next());

            using (new BalancedFieldLengthCalculationModuleFactoryConfig())
            {
                var instance = (TestBalancedFieldLengthCalculationModuleFactory)
                               BalancedFieldLengthCalculationModuleFactory.Instance;

                TestBalancedFieldLengthCalculationModule testModule = instance.TestModule;
                testModule.Output = new BalancedFieldLengthOutput(random.NextDouble(), random.NextDouble());

                // When
                viewModel.CalculateCommand.Execute(null);

                // Then
                BalancedFieldLengthCalculation calculationInput = testModule.InputCalculation;
                AssertGeneralSettings(generalSimulationSettingsViewModel, calculationInput.SimulationSettings);
                AssertEngineData(engineSettingsViewModel, calculationInput.EngineData);
                AssertAircraftData(aircraftDataViewModel, calculationInput.AircraftData);
            }
        }
コード例 #20
0
        public void GivenTabControlViewModelWithTabs_WhenViewModelDisposedAndTabRaisesPropertyChangedEvent_ThenTabControlDoesNotRaiseEvent()
        {
            // Given
            var tabControlViewModel = new TabControlViewModel();

            PropertyChangedEventArgs eventArgs = null;
            bool propertyChangedTriggered      = false;

            tabControlViewModel.PropertyChanged += (o, e) =>
            {
                eventArgs = e;
                propertyChangedTriggered = true;
            };

            var tabViewModel = new TestTabViewModel();

            tabControlViewModel.Tabs.Add(tabViewModel);

            var random = new Random(21);

            // Precondition
            CollectionAssert.AreEqual(new[]
            {
                tabViewModel
            }, tabControlViewModel.Tabs);

            // When
            tabControlViewModel.Dispose();

            tabViewModel.TabProperty = random.Next();

            // Then
            Assert.That(propertyChangedTriggered, Is.False);
            Assert.That(eventArgs, Is.Null);
            Assert.That(tabControlViewModel.Tabs, Is.Empty);
        }
コード例 #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="control"></param>
 public void SetControl(TabControlViewModel control)
 {
     Control = control;
 }
コード例 #22
0
        public TabControlView()
        {
            InitializeComponent();

            DataContext = new TabControlViewModel();
        }
コード例 #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="indexTab1"></param>
        /// <param name="indexTab2"></param>
        /// <param name="indexPage"></param>
        /// <param name="textbox"></param>
        /// <param name="checkCycleWork"></param>
        /// <param name="checkCycleWorkToErr"></param>
        private void create_binding_data(int?indexTab1, int?indexTab2, int?indexPage,
                                         TextBox textbox, CheckBox checkCycleWork, CheckBox checkCycleWorkToErr)
        {
            if (indexTab1 == null || indexTab2 == null || indexPage == null)
            {
                return;
            }
            // Создание oбъекта привязки
            var binding_data = new TabControlViewModel();

            // Создание привязки
            // Установка привязки для элемента-передатчика
            var binding_cycle_work = new Binding {
                Source = binding_data,
                Path   = new PropertyPath("CycleWorkEnable"),
                Mode   = BindingMode.TwoWay
            };
            var binding_cycle_work_to_err = new Binding {
                Source = binding_data,
                Path   = new PropertyPath("CycleWorkToErrorEnable"),
                Mode   = BindingMode.TwoWay
            };
            var binding_signal_field_1 = new Binding {
                Source = binding_data,
                Path   = new PropertyPath("SignalFieldBrush1"),
                Mode   = BindingMode.TwoWay
            };
            var binding_signal_field_2 = new Binding {
                Source = binding_data,
                Path   = new PropertyPath("SignalFieldBrush2"),
                Mode   = BindingMode.TwoWay
            };
            var binding_result_text = new Binding {
                Source = binding_data,
                Path   = new PropertyPath("ResultText"),
                Mode   = BindingMode.TwoWay
            };
            var binding_result_text_brush = new Binding {
                Source = binding_data,
                Path   = new PropertyPath("ResultTextBrush"),
                Mode   = BindingMode.TwoWay
            };

            // Установка привязки для элемента-приемника
            checkCycleWork.SetBinding(ToggleButton.IsCheckedProperty, binding_cycle_work);
            checkCycleWorkToErr.SetBinding(ToggleButton.IsCheckedProperty, binding_cycle_work_to_err);

            _rectangleControlL1[0][( int )indexTab1].SetBinding(Shape.FillProperty, binding_signal_field_1);
            _rectangleControlL1[( int )indexTab1 + 1][( int )indexTab2]
            .SetBinding(Shape.FillProperty, binding_signal_field_2);
            textbox.SetBinding(TextBox.TextProperty, binding_result_text);
            textbox.SetBinding(BackgroundProperty, binding_result_text_brush);
            // Первоначальная инициализация
            binding_data.CycleWorkEnable        = false;
            binding_data.CycleWorkToErrorEnable = false;
            binding_data.ResultText             = @"НЕТ ДАННЫХ";
            binding_data.ResultTextBrush        = Brushes.Transparent;
            binding_data.SignalFieldBrush1      = Brushes.Transparent;
            binding_data.SignalFieldBrush2      = Brushes.Transparent;
            // Сохранение в словаре тестов
            App.TaskManager.ConfigProgram.SetControl(indexTab1, indexTab2, indexPage, binding_data);
        }
コード例 #24
0
        public ShellViewModel([ImportMany] IEnumerable <IExtension> extensions, [ImportMany] IEnumerable <ICodeTemplate> codeTemplates)
        {
            _languageServices            = new List <ILanguageService>();
            _projectTemplates            = new List <IProjectTemplate>();
            _debugger2s                  = new List <IDebugger>();
            _codeTemplates               = new List <ICodeTemplate>();
            _projectTypes                = new List <IProjectType>();
            _solutionTypes               = new List <ISolutionType>();
            _testFrameworks              = new List <ITestFramework>();
            _toolChains                  = new List <IToolChain>();
            _menuBarDefinitions          = new List <MenuBarDefinition>();
            _menuDefinitions             = new List <MenuDefinition>();
            _menuItemGroupDefinitions    = new List <MenuItemGroupDefinition>();
            _menuItemDefinitions         = new List <MenuItemDefinition>();
            _commandDefinitions          = new List <CommandDefinition>();
            _keyBindings                 = new List <KeyBinding>();
            _toolBarDefinitions          = new List <ToolBarDefinition>();
            _toolBarItemGroupDefinitions = new List <ToolBarItemGroupDefinition>();
            _toolBarItemDefinitions      = new List <ToolBarItemDefinition>();

            IoC.RegisterConstant(this, typeof(IShell));

            foreach (var extension in extensions)
            {
                extension.BeforeActivation();
            }

            _codeTemplates.AddRange(codeTemplates);

            CurrentPerspective = Perspective.Editor;

            StatusBar    = new StatusBarViewModel();
            DocumentTabs = new DocumentTabControlViewModel();

            Console   = IoC.Get <IConsole>();
            ErrorList = IoC.Get <IErrorList>();

            tools = new ObservableCollection <object>();

            LeftTabs        = new TabControlViewModel();
            RightTabs       = new TabControlViewModel();
            BottomTabs      = new TabControlViewModel();
            BottomRightTabs = new TabControlViewModel();
            RightBottomTabs = new TabControlViewModel();
            RightMiddleTabs = new TabControlViewModel();
            RightTopTabs    = new TabControlViewModel();
            MiddleTopTabs   = new TabControlViewModel();

            ModalDialog = new ModalDialogViewModelBase("Dialog");

            foreach (var extension in extensions)
            {
                extension.Activation();

                _languageServices.ConsumeExtension(extension);
                _toolChains.ConsumeExtension(extension);
                _projectTemplates.ConsumeExtension(extension);
                _debugger2s.ConsumeExtension(extension);
                _solutionTypes.ConsumeExtension(extension);
                _projectTypes.ConsumeExtension(extension);
                _testFrameworks.ConsumeExtension(extension);

                _commandDefinitions.ConsumeExtension(extension);
            }

            _menuBarDefinitions.AddRange(IoC.GetServices <MenuBarDefinition>(typeof(MenuBarDefinition)));
            _menuDefinitions.AddRange(IoC.GetServices <MenuDefinition>(typeof(MenuDefinition)));
            _menuItemGroupDefinitions.AddRange(IoC.GetServices <MenuItemGroupDefinition>(typeof(MenuItemGroupDefinition)));
            _menuItemDefinitions.AddRange(IoC.GetServices <MenuItemDefinition>(typeof(MenuItemDefinition)));

            _toolBarDefinitions.AddRange(IoC.GetServices <ToolBarDefinition>(typeof(ToolBarDefinition)));
            _toolBarItemDefinitions.AddRange(IoC.GetServices <ToolBarItemDefinition>(typeof(ToolBarItemDefinition)));
            _toolBarItemGroupDefinitions.AddRange(IoC.GetServices <ToolBarItemGroupDefinition>(typeof(ToolBarItemGroupDefinition)));

            foreach (var definition in _toolBarItemDefinitions)
            {
                definition.Activation();
            }

            foreach (var menuItemDefinition in _menuDefinitions)
            {
                menuItemDefinition.Activation();
            }

            foreach (var menuItemDefinition in _menuItemGroupDefinitions)
            {
                menuItemDefinition.Activation();
            }

            foreach (var extension in _menuItemDefinitions)
            {
                extension.Activation();
            }

            var menuBar = IoC.Get <MenuBarDefinition>("MainMenu");

            foreach (var commandDefinition in _commandDefinitions)
            {
                if (commandDefinition.Command != null && commandDefinition.Gesture != null)
                {
                    _keyBindings.Add(new KeyBinding {
                        Gesture = commandDefinition.Gesture, Command = commandDefinition.Command
                    });
                }
            }

            ToolBarDefinition = ToolBarDefinitions.MainToolBar;

            var menuBuilder = new MenuBuilder(_menuBarDefinitions.ToArray(), _menuDefinitions.ToArray(), _menuItemGroupDefinitions.ToArray(), _menuItemDefinitions.ToArray(), new ExcludeMenuDefinition[0], new ExcludeMenuItemGroupDefinition[0], new ExcludeMenuItemDefinition[0]);

            var mainMenu = new Extensibility.MainMenu.ViewModels.MainMenuViewModel(menuBuilder);

            menuBuilder.BuildMenuBar(menuBar, mainMenu.Model);

            MainMenu = mainMenu;

            foreach (var tool in extensions.OfType <ToolViewModel>())
            {
                tools.Add(tool);

                switch (tool.DefaultLocation)
                {
                case Location.Bottom:
                    BottomTabs.Tools.Add(tool);
                    break;

                case Location.BottomRight:
                    BottomRightTabs.Tools.Add(tool);
                    break;

                case Location.RightBottom:
                    RightBottomTabs.Tools.Add(tool);
                    break;

                case Location.RightMiddle:
                    RightMiddleTabs.Tools.Add(tool);
                    break;

                case Location.RightTop:
                    RightTopTabs.Tools.Add(tool);
                    break;

                case Location.MiddleTop:
                    MiddleTopTabs.Tools.Add(tool);
                    break;

                case Location.Left:
                    LeftTabs.Tools.Add(tool);
                    break;

                case Location.Right:
                    RightTabs.Tools.Add(tool);
                    break;
                }
            }

            LeftTabs.SelectedTool        = LeftTabs.Tools.FirstOrDefault();
            RightTabs.SelectedTool       = RightTabs.Tools.FirstOrDefault();
            BottomTabs.SelectedTool      = BottomTabs.Tools.FirstOrDefault();
            BottomRightTabs.SelectedTool = BottomRightTabs.Tools.FirstOrDefault();
            RightTopTabs.SelectedTool    = RightTopTabs.Tools.FirstOrDefault();
            RightMiddleTabs.SelectedTool = RightMiddleTabs.Tools.FirstOrDefault();
            RightBottomTabs.SelectedTool = RightBottomTabs.Tools.FirstOrDefault();
            MiddleTopTabs.SelectedTool   = MiddleTopTabs.Tools.FirstOrDefault();

            StatusBar.LineNumber     = 1;
            StatusBar.Column         = 1;
            StatusBar.PlatformString = Platform.OSDescription + " " + Platform.AvalonRID;

            ProcessCancellationToken = new CancellationTokenSource();

            CurrentPerspective = Perspective.Editor;

            IoC.RegisterConstant(this);
        }
コード例 #25
0
 public MainWindowViewModel()
 {
     TabControlVM = new TabControlViewModel();
 }
コード例 #26
0
        public ShellViewModel([ImportMany] IEnumerable <ToolViewModel> importedTools,
                              [ImportMany] IEnumerable <ILanguageService> languageServices, [ImportMany] IEnumerable <ISolutionType> solutionTypes, [ImportMany] IEnumerable <IProject> projectTypes,
                              [ImportMany] IEnumerable <IProjectTemplate> projectTemplates, [ImportMany] IEnumerable <IToolChain> toolChains,
                              [ImportMany] IEnumerable <IDebugger> debuggers, [ImportMany] IEnumerable <ITestFramework> testFrameworks,
                              [ImportMany] IEnumerable <ICodeTemplate> codeTemplates, [ImportMany] IEnumerable <IExtension> extensions,
                              [Import] IMenu mainMenu)
        {
            MainMenu         = mainMenu;
            LanguageServices = languageServices;
            ProjectTemplates = projectTemplates;
            ToolChains       = toolChains;
            Debuggers        = debuggers;
            SolutionTypes    = solutionTypes;
            ProjectTypes     = projectTypes;
            TestFrameworks   = testFrameworks;
            CodeTemplates    = codeTemplates;

            IoC.RegisterConstant(this, typeof(IShell));

            foreach (var extension in extensions)
            {
                extension.BeforeActivation();
            }

            CurrentPerspective = Perspective.Editor;

            StatusBar    = new StatusBarViewModel();
            DocumentTabs = new DocumentTabControlViewModel();

            Console   = IoC.Get <IConsole>();
            ErrorList = IoC.Get <IErrorList>();

            tools = new ObservableCollection <object>();

            LeftTabs        = new TabControlViewModel();
            RightTabs       = new TabControlViewModel();
            BottomTabs      = new TabControlViewModel();
            BottomRightTabs = new TabControlViewModel();
            RightBottomTabs = new TabControlViewModel();
            RightMiddleTabs = new TabControlViewModel();
            RightTopTabs    = new TabControlViewModel();
            MiddleTopTabs   = new TabControlViewModel();

            ModalDialog = new ModalDialogViewModelBase("Dialog");

            foreach (var extension in extensions)
            {
                extension.Activation();
            }

            foreach (var tool in importedTools)
            {
                tools.Add(tool);

                switch (tool.DefaultLocation)
                {
                case Location.Bottom:
                    BottomTabs.Tools.Add(tool);
                    break;

                case Location.BottomRight:
                    BottomRightTabs.Tools.Add(tool);
                    break;

                case Location.RightBottom:
                    RightBottomTabs.Tools.Add(tool);
                    break;

                case Location.RightMiddle:
                    RightMiddleTabs.Tools.Add(tool);
                    break;

                case Location.RightTop:
                    RightTopTabs.Tools.Add(tool);
                    break;

                case Location.MiddleTop:
                    MiddleTopTabs.Tools.Add(tool);
                    break;

                case Location.Left:
                    LeftTabs.Tools.Add(tool);
                    break;

                case Location.Right:
                    RightTabs.Tools.Add(tool);
                    break;
                }
            }

            LeftTabs.SelectedTool        = LeftTabs.Tools.FirstOrDefault();
            RightTabs.SelectedTool       = RightTabs.Tools.FirstOrDefault();
            BottomTabs.SelectedTool      = BottomTabs.Tools.FirstOrDefault();
            BottomRightTabs.SelectedTool = BottomRightTabs.Tools.FirstOrDefault();
            RightTopTabs.SelectedTool    = RightTopTabs.Tools.FirstOrDefault();
            RightMiddleTabs.SelectedTool = RightMiddleTabs.Tools.FirstOrDefault();
            RightBottomTabs.SelectedTool = RightBottomTabs.Tools.FirstOrDefault();
            MiddleTopTabs.SelectedTool   = MiddleTopTabs.Tools.FirstOrDefault();

            StatusBar.LineNumber     = 1;
            StatusBar.Column         = 1;
            StatusBar.PlatformString = Platform.PlatformString;

            ProcessCancellationToken = new CancellationTokenSource();

            CurrentPerspective = Perspective.Editor;

            ToolBarDefinition = ToolBarDefinitions.MainToolBar;
        }
コード例 #27
0
        public ShellViewModel([ImportMany] IEnumerable <IExtension> extensions, [ImportMany] IEnumerable <ICodeTemplate> codeTemplates)
        {
            _languageServices            = new List <ILanguageService>();
            _projectTemplates            = new List <IProjectTemplate>();
            _debugger2s                  = new List <IDebugger>();
            _codeTemplates               = new List <ICodeTemplate>();
            _projectTypes                = new List <IProjectType>();
            _solutionTypes               = new List <ISolutionType>();
            _testFrameworks              = new List <ITestFramework>();
            _toolChains                  = new List <IToolChain>();
            _menuBarDefinitions          = new List <MenuBarDefinition>();
            _menuDefinitions             = new List <MenuDefinition>();
            _menuItemGroupDefinitions    = new List <MenuItemGroupDefinition>();
            _menuItemDefinitions         = new List <MenuItemDefinition>();
            _commandDefinitions          = new List <CommandDefinition>();
            _keyBindings                 = new List <KeyBinding>();
            _toolBarDefinitions          = new List <ToolBarDefinition>();
            _toolBarItemGroupDefinitions = new List <ToolBarItemGroupDefinition>();
            _toolBarItemDefinitions      = new List <ToolBarItemDefinition>();

            IoC.RegisterConstant(this, typeof(IShell));

            foreach (var extension in extensions)
            {
                extension.BeforeActivation();
            }

            _codeTemplates.AddRange(codeTemplates);

            CurrentPerspective = Perspective.Editor;

            StatusBar    = new StatusBarViewModel();
            DocumentTabs = new DocumentTabControlViewModel();

            Console   = IoC.Get <IConsole>();
            ErrorList = IoC.Get <IErrorList>();

            tools = new ObservableCollection <object>();

            LeftTabs        = new TabControlViewModel();
            RightTabs       = new TabControlViewModel();
            BottomTabs      = new TabControlViewModel();
            BottomRightTabs = new TabControlViewModel();
            RightBottomTabs = new TabControlViewModel();
            RightMiddleTabs = new TabControlViewModel();
            RightTopTabs    = new TabControlViewModel();
            MiddleTopTabs   = new TabControlViewModel();

            ModalDialog = new ModalDialogViewModelBase("Dialog");

            OnSolutionChanged = Observable.FromEventPattern <SolutionChangedEventArgs>(this, nameof(SolutionChanged)).Select(s => s.EventArgs.NewValue);

            _taskRunner = new WorkspaceTaskRunner();

            foreach (var extension in extensions)
            {
                extension.Activation();

                _languageServices.ConsumeExtension(extension);
                _toolChains.ConsumeExtension(extension);
                _projectTemplates.ConsumeExtension(extension);
                _debugger2s.ConsumeExtension(extension);
                _solutionTypes.ConsumeExtension(extension);
                _projectTypes.ConsumeExtension(extension);
                _testFrameworks.ConsumeExtension(extension);

                _commandDefinitions.ConsumeExtension(extension);
            }

            _menuBarDefinitions.AddRange(IoC.GetServices <MenuBarDefinition>(typeof(MenuBarDefinition)));
            _menuDefinitions.AddRange(IoC.GetServices <MenuDefinition>(typeof(MenuDefinition)));
            _menuItemGroupDefinitions.AddRange(IoC.GetServices <MenuItemGroupDefinition>(typeof(MenuItemGroupDefinition)));
            _menuItemDefinitions.AddRange(IoC.GetServices <MenuItemDefinition>(typeof(MenuItemDefinition)));

            _toolBarDefinitions.AddRange(IoC.GetServices <ToolBarDefinition>(typeof(ToolBarDefinition)));
            _toolBarItemDefinitions.AddRange(IoC.GetServices <ToolBarItemDefinition>(typeof(ToolBarItemDefinition)));
            _toolBarItemGroupDefinitions.AddRange(IoC.GetServices <ToolBarItemGroupDefinition>(typeof(ToolBarItemGroupDefinition)));

            foreach (var definition in _toolBarItemDefinitions)
            {
                definition.Activation();
            }

            foreach (var menuItemDefinition in _menuDefinitions)
            {
                menuItemDefinition.Activation();
            }

            foreach (var menuItemDefinition in _menuItemGroupDefinitions)
            {
                menuItemDefinition.Activation();
            }

            foreach (var extension in _menuItemDefinitions)
            {
                extension.Activation();
            }

            var menuBar = IoC.Get <MenuBarDefinition>("MainMenu");

            foreach (var commandDefinition in _commandDefinitions)
            {
                if (commandDefinition.Command != null && commandDefinition.Gesture != null)
                {
                    _keyBindings.Add(new KeyBinding {
                        Gesture = commandDefinition.Gesture, Command = commandDefinition.Command
                    });
                }
            }

            ToolBarDefinition = ToolBarDefinitions.MainToolBar;

            var menuBuilder = new MenuBuilder(_menuBarDefinitions.ToArray(), _menuDefinitions.ToArray(), _menuItemGroupDefinitions.ToArray(), _menuItemDefinitions.ToArray(), new ExcludeMenuDefinition[0], new ExcludeMenuItemGroupDefinition[0], new ExcludeMenuItemDefinition[0]);

            var mainMenu = new Extensibility.MainMenu.ViewModels.MainMenuViewModel(menuBuilder);

            menuBuilder.BuildMenuBar(menuBar, mainMenu.Model);

            MainMenu = mainMenu;

            foreach (var tool in extensions.OfType <ToolViewModel>())
            {
                tools.Add(tool);

                switch (tool.DefaultLocation)
                {
                case Location.Bottom:
                    BottomTabs.Tools.Add(tool);
                    break;

                case Location.BottomRight:
                    BottomRightTabs.Tools.Add(tool);
                    break;

                case Location.RightBottom:
                    RightBottomTabs.Tools.Add(tool);
                    break;

                case Location.RightMiddle:
                    RightMiddleTabs.Tools.Add(tool);
                    break;

                case Location.RightTop:
                    RightTopTabs.Tools.Add(tool);
                    break;

                case Location.MiddleTop:
                    MiddleTopTabs.Tools.Add(tool);
                    break;

                case Location.Left:
                    LeftTabs.Tools.Add(tool);
                    break;

                case Location.Right:
                    RightTabs.Tools.Add(tool);
                    break;
                }
            }

            LeftTabs.SelectedTool        = LeftTabs.Tools.FirstOrDefault();
            RightTabs.SelectedTool       = RightTabs.Tools.FirstOrDefault();
            BottomTabs.SelectedTool      = BottomTabs.Tools.FirstOrDefault();
            BottomRightTabs.SelectedTool = BottomRightTabs.Tools.FirstOrDefault();
            RightTopTabs.SelectedTool    = RightTopTabs.Tools.FirstOrDefault();
            RightMiddleTabs.SelectedTool = RightMiddleTabs.Tools.FirstOrDefault();
            RightBottomTabs.SelectedTool = RightBottomTabs.Tools.FirstOrDefault();
            MiddleTopTabs.SelectedTool   = MiddleTopTabs.Tools.FirstOrDefault();

            StatusBar.LineNumber     = 1;
            StatusBar.Column         = 1;
            StatusBar.PlatformString = Platform.OSDescription + " " + Platform.AvalonRID;

            ProcessCancellationToken = new CancellationTokenSource();

            CurrentPerspective = Perspective.Editor;

            var editorSettings = Settings.GetSettings <EditorSettings>();

            _globalZoomLevel = editorSettings.GlobalZoomLevel;

            IoC.RegisterConstant(this);

            this.WhenAnyValue(x => x.GlobalZoomLevel).Subscribe(zoomLevel =>
            {
                foreach (var document in DocumentTabs.Documents.OfType <EditorViewModel>())
                {
                    document.ZoomLevel = zoomLevel;
                }
            });

            this.WhenAnyValue(x => x.GlobalZoomLevel).Throttle(TimeSpan.FromSeconds(2)).Subscribe(zoomLevel =>
            {
                var settings = Settings.GetSettings <EditorSettings>();

                settings.GlobalZoomLevel = zoomLevel;

                Settings.SetSettings(settings);
            });

            EnableDebugModeCommand = ReactiveCommand.Create(() =>
            {
                DebugMode = !DebugMode;
            });
        }