Exemplo n.º 1
0
        public void AddWeakEventListenerTest2()
        {
            // Add a weak event listener and check if the eventhandler is called
            DocumentManager documentManager = new DocumentManager();
            ShellViewModel viewModel = new ShellViewModel(new MockView(), documentManager);
            Assert.IsFalse(viewModel.DocumentsHasChanged);
            Assert.IsFalse(viewModel.ActiveDocumentHasChanged);
            documentManager.Open();
            Assert.IsTrue(viewModel.DocumentsHasChanged);
            Assert.IsTrue(viewModel.ActiveDocumentHasChanged);

            // Remove the weak event listener and check that the eventhandler is not anymore called
            viewModel.RemoveWeakEventListeners();
            viewModel.DocumentsHasChanged = false;
            viewModel.ActiveDocumentHasChanged = false;
            documentManager.Open();
            Assert.IsFalse(viewModel.DocumentsHasChanged);
            Assert.IsFalse(viewModel.ActiveDocumentHasChanged);

            // Remove again the same weak event listeners although they are not anymore registered
            viewModel.RemoveWeakEventListeners();

            // Check that the garbage collector is able to collect the controller although the service lives longer
            viewModel.AddWeakEventListeners();
            documentManager.Open();
            Assert.IsTrue(viewModel.DocumentsHasChanged);
            Assert.IsTrue(viewModel.ActiveDocumentHasChanged);
            WeakReference weakController = new WeakReference(viewModel);
            viewModel = null;
            GC.Collect();

            Assert.IsFalse(weakController.IsAlive);
        }
Exemplo n.º 2
0
        public ApplicationController(IEnvironmentService environmentService, IPresentationService presentationService, ShellService shellService,
            Lazy<FileController> fileController, Lazy<RichTextDocumentController> richTextDocumentController, Lazy<PrintController> printController,
            Lazy<ShellViewModel> shellViewModel, Lazy<MainViewModel> mainViewModel, Lazy<StartViewModel> startViewModel)
        {
            // Upgrade the settings from a previous version when the new version starts the first time.
            if (Settings.Default.IsUpgradeNeeded)
            {
                Settings.Default.Upgrade();
                Settings.Default.IsUpgradeNeeded = false;
            }

            // Initializing the cultures must be done first. Therefore, we inject the Controllers and ViewModels lazy.
            InitializeCultures();
            presentationService.InitializeCultures();

            this.environmentService = environmentService;
            this.fileController = fileController.Value;
            this.richTextDocumentController = richTextDocumentController.Value;
            this.printController = printController.Value;
            this.shellViewModel = shellViewModel.Value;
            this.mainViewModel = mainViewModel.Value;
            this.startViewModel = startViewModel.Value;

            shellService.ShellView = this.shellViewModel.View;
            this.shellViewModel.Closing += ShellViewModelClosing;
            this.exitCommand = new DelegateCommand(Close);
        }
Exemplo n.º 3
0
 public Shell(ShellViewModel viewModel)
 {
     InitializeComponent();
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         DataContext = viewModel;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the Shell class.
        /// </summary>
        public Shell()
        {
            this.InitializeComponent();
            this.shellViewModel = DIContainer.Instance.Resolve<ShellViewModel>();
            this.DataContext = this.shellViewModel;

            this.RegisterEvents();
        }
Exemplo n.º 5
0
 public LoginViewModel(BusinessCoreService businessCoreService, ShellViewModel parent)
 {
     _businessCoreService = businessCoreService;
     _parent = parent;
     ////_userName = "******";
     ////_password = "******";
     MessageParser.SetCoreBusinessService(_businessCoreService);
 }
Exemplo n.º 6
0
        public AboutViewModel(ShellViewModel _shell)
        {
            this.vmShell = _shell;
            this.DisplayName = Properties.Resources.menu_About;

            if (this.dbRepo == null)
                this.dbRepo = new BombaJobRepository();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the TabFileItem class.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="title"></param>
        public TabFileItem(ShellViewModel viewModel, string fileName, string title, TailService tailService)
        {
            _viewModel = viewModel;
            _fileName = fileName;
            _title = title;

            TailService = tailService;
        }
Exemplo n.º 8
0
        public Shell(
            ShellViewModel shellViewModel, 
            IEventAggregator eventAggregator, 
            IMainMenuApplicationService mainMenuApplicationService,
            ILayoutDataFactory layoutDataFactory,
            ILayoutApplicationService layoutApplicationService,
            IRestBoxStateService restBoxStateService)
        {
            this.mainMenuApplicationService = mainMenuApplicationService;
            this.layoutDataFactory = layoutDataFactory;
            this.layoutApplicationService = layoutApplicationService;
            this.restBoxStateService = restBoxStateService;
            this.eventAggregator = eventAggregator;
            this.shellViewModel = shellViewModel;
            DataContext = shellViewModel;
            shellViewModel.ApplicationTitle = "REST Box";

            InitializeComponent();

            layoutApplicationService.Load(dockingManager);

            httpRequestFilesLayout = GetLayoutAnchorableById("HttpRequestFilesLayoutId");
            environmentsLayout = GetLayoutAnchorableById("EnvironmentsLayoutId");
            requestExtensions = GetLayoutAnchorableById("RequestExtensionsId");
            sequenceFiles = GetLayoutAnchorableById("SequenceFilesId");
            interceptorFiles = GetLayoutAnchorableById("InterceptorFilesId");

            httpRequestFilesLayout.Content = ServiceLocator.Current.GetInstance<HttpRequestFiles>();
            environmentsLayout.Content = ServiceLocator.Current.GetInstance<RequestEnvironments>();
            requestExtensions.Content = ServiceLocator.Current.GetInstance<RequestExtensions>();
            sequenceFiles.Content = ServiceLocator.Current.GetInstance<HttpRequestSequenceFiles>();
            interceptorFiles.Content = ServiceLocator.Current.GetInstance<HttpInterceptorFiles>();

            eventAggregator.GetEvent<AddInputBindingEvent>().Subscribe(AddInputBinding);
            eventAggregator.GetEvent<RemoveInputBindingEvent>().Subscribe(RemoveInputBindings);
            eventAggregator.GetEvent<RemoveTabEvent>().Subscribe(RemoveTabById);
            eventAggregator.GetEvent<IsDirtyEvent>().Subscribe(IsDirtyHandler);

            eventAggregator.GetEvent<AddLayoutDocumentEvent>().Subscribe(AddLayoutDocument);
            eventAggregator.GetEvent<UpdateTabTitleEvent>().Subscribe(UpdateTabTitle);
            eventAggregator.GetEvent<GetLayoutDataEvent>().Subscribe(GetLayoutContent);

            eventAggregator.GetEvent<ShowErrorEvent>().Subscribe(ShowError);

            eventAggregator.GetEvent<ShowLayoutEvent>().Subscribe(ShowLayout);
            eventAggregator.GetEvent<UpdateViewMenuItemChecksEvent>().Subscribe(UpdateViewMenuChecks);

            eventAggregator.GetEvent<SaveAllEvent>().Subscribe(SaveAllHandler);

            eventAggregator.GetEvent<ResetLayoutEvent>().Subscribe(ResetLayoutOnRestart);
            eventAggregator.GetEvent<SaveRestBoxStateEvent>().Subscribe(SaveRestBoxState);
            eventAggregator.GetEvent<CreateStartPageEvent>().Subscribe(CreateStartPage);
            eventAggregator.GetEvent<UpdateStatusBarEvent>().Subscribe(UpdateStatusBar);

            Closing += OnClosing;
            CreateStartPage(true);
        }
 public AppExceptionHandler(
     IWindowManagerEx windowManager,
     IEventAggregator eventAggregator,
     ShellViewModel shell)
 {
     this.windowManager = windowManager;
     this.eventAggregator = eventAggregator;
     this.shell = shell;
 }
 public EntityController(EntityService entityService, IMessageService messageService, IShellService shellService, 
     ShellViewModel shellViewModel)
 {
     this.entityService = entityService;
     this.messageService = messageService;
     this.shellService = shellService;
     this.shellViewModel = shellViewModel;
     this.saveCommand = new DelegateCommand(() => Save(), CanSave);
 }
Exemplo n.º 11
0
        public void TestShell()
        {
            var mockCoordinator = new Mock<IDialogCoordinator>();
            ISettings settings = new Settings.Settings(Settings.Serializers.SettingsSerializerFactory.Get("JSON"), "settings.TEST");
            settings.InitializeDefaults();
            ShellViewModel svm = new ShellViewModel(new StubbedWindowManager(), mockCoordinator.Object, settings);
            var mock = new Mock<IrcConnection>();

            svm.ActivateItem(new IrcTabViewModel(mock.Object) {DisplayName = "Test"});
            Assert.IsTrue(svm.Tabs.Count == 1);
        }
 public void TestInitialize()
 {
     shell = Substitute.For<ShellViewModel>();
     serviceControl = Substitute.For<IServiceControl>();
     settingsProvider = Substitute.For<ISettingsProvider>();
     connection = Substitute.For<ServiceControlConnectionProvider>();
     container = RegisterContainer();
     storedSetting = GetReloadedSettings();
     settingsProvider.GetSettings<ProfilerSettings>().Returns(storedSetting);
     connectTo = new ServiceControlConnectionViewModel(settingsProvider, container) { Parent = shell }; //TODO: Do we need to pass the full container here?
 }
Exemplo n.º 13
0
        public static WorkspaceViewModel Load(ShellViewModel shell, string path)
        {
            Contract.Requires(path != null);

            if (!Directory.Exists(path))
                throw new ArgumentException("Directory does not exist");

            var workspace = new WorkspaceViewModel(shell, path);
            workspace.Initialize();
            return workspace;
        }
Exemplo n.º 14
0
 public UsersController(IEventBus eventBus, IMapper mapper, ShellViewModel shell,
     IListUsersRequestBoundary listUsers,
     IShowUserRequestBoundary showUser, IDestroyUserRequestBoundary destroyUser,
     ICreateUserRequestBoundary createUser, IUpdateUserRequestBoundary updateUser) {
     _eventBus = eventBus;
     _mapper = mapper;
     _shell = shell;
     _listUsers = listUsers;
     _showUser = showUser;
     _destroyUser = destroyUser;
     _createUser = createUser;
     _updateUser = updateUser;
 }
Exemplo n.º 15
0
        public PrintController(IFileService fileService, IPrintDialogService printDialogService, 
            ShellViewModel shellViewModel, ExportFactory<PrintPreviewViewModel> printPreviewViewModelFactory)
        {
            this.fileService = fileService;
            this.printDialogService = printDialogService;
            this.shellViewModel = shellViewModel;
            this.printPreviewViewModelFactory = printPreviewViewModelFactory;
            this.printPreviewCommand = new DelegateCommand(ShowPrintPreview, CanShowPrintPreview);
            this.printCommand = new DelegateCommand(PrintDocument, CanPrintDocument);
            this.closePrintPreviewCommand = new DelegateCommand(ClosePrintPreview);

            PropertyChangedEventManager.AddHandler(fileService, FileServicePropertyChanged, "");
        }
Exemplo n.º 16
0
        public ShellController(ShellViewModel shellViewModel, ISyncService syncService,
            ISettingsSerializationService settingsSerializationService,
            ISummarySerializationService summarySerializationService,
            SystemTrayNotifierViewModel systemTrayNotifierViewModel,
            ApplicationLogger applicationLogger)
        {
            _shellViewModel = shellViewModel;
            _syncService = syncService;
            _settingsSerializationService = settingsSerializationService;
            _summarySerializationService = summarySerializationService;

            _systemTrayNotifierViewModel = systemTrayNotifierViewModel;
            _applicationLogger = applicationLogger;
        }
Exemplo n.º 17
0
        public Shell()
        {
            this.InitializeComponent();

            var vm = new ShellViewModel();
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Welcome", PageType = typeof(WelcomePage) });
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Page 1", PageType = typeof(Page1) });
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Page 2", PageType = typeof(Page2) });
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Page 3", PageType = typeof(Page3) });

            // select the first menu item
            vm.SelectedMenuItem = vm.MenuItems.First();

            this.ViewModel = vm;
        }
        public PrintController(CompositionContainer container, IShellService shellService, ShellViewModel shellViewModel, 
            MainViewModel mainViewModel, IFileService fileService, IPrintDialogService printDialogService)
        {
            this.container = container;
            this.shellService = shellService;
            this.shellViewModel = shellViewModel;
            this.mainViewModel = mainViewModel;
            this.fileService = fileService;
            this.printDialogService = printDialogService;
            this.printPreviewCommand = new DelegateCommand(ShowPrintPreview, CanPrintDocument);
            this.printCommand = new DelegateCommand(PrintDocument, CanPrintDocument);
            this.closePrintPreviewCommand = new DelegateCommand(ClosePrintPreview);

            AddWeakEventListener(fileService, FileServicePropertyChanged);
        }
        public ApplicationController(CompositionContainer container, IMessageService messageService, IPresentationService presentationService,
            ShellService shellService, ShellViewModel shellViewModel, MessageListViewModel msgListViewModel,
            AboutBoxViewModel abViewModel)
        {
            presentationService.InitializeCultures();
            this.container = container;
            this.messageService = messageService;
            this.shellService = shellService;
            this.shellViewModel = shellViewModel;
            this.msgListViewModel = msgListViewModel;
            this.abViewModel = abViewModel;
            shellService.ShellView = shellViewModel.View;
            exitCommand = new DelegateCommand(Close);

            msgQueue = new Queue<MessageItem>();
        }
Exemplo n.º 20
0
        public SystemTrayViewModel(IWindowManager windowManager, MetroDialogService dialogService,
            ShellViewModel shellViewModel, MainManager mainManager)
        {
            _windowManager = windowManager;
            _shellViewModel = shellViewModel;

            DialogService = dialogService;
            MainManager = mainManager;

            MainManager.EnableProgram();
            MainManager.OnEnabledChangedEvent += MainManagerOnOnEnabledChangedEvent;

            var generalSettings = SettingsProvider.Load<GeneralSettings>();
            Enabled = !generalSettings.Suspended;
            if (generalSettings.ShowOnStartup)
                ShowWindow();
        }
Exemplo n.º 21
0
        public Shell()
        {
            this.InitializeComponent();

            var vm = new ShellViewModel();
            vm.TopItems.Add(new NavigationItem { Icon = "", DisplayName = "Welcome", PageType = typeof(WelcomePage) });
            vm.TopItems.Add(new NavigationItem { Icon = "", DisplayName = "Page 1", PageType = typeof(Page1) });
            vm.TopItems.Add(new NavigationItem { Icon = "", DisplayName = "Page 2", PageType = typeof(Page2) });
            vm.TopItems.Add(new NavigationItem { Icon = "", DisplayName = "Page 3", PageType = typeof(Page3) });

            vm.BottomItems.Add(new NavigationItem { Icon = "", DisplayName = "Settings", PageType = typeof(SettingsPage) });

            // select the first top item
            vm.SelectedItem = vm.TopItems.First();

            this.ViewModel = vm;
        }
Exemplo n.º 22
0
        public WorkspaceViewModel(ShellViewModel shell, string path)
            : base(null, path)
        {
            var runtime = Kvm.GetRuntime(shell.SelectedRuntime);
            _host = new Host(path);
            _host.Connected += HostConnected;
            _host.Configurations += HostConfigurations;
            _host.References += HostReferences;
            _host.Start(runtime);

            _watcher = new FileSystemWatcher(path);
            _watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.DirectoryName | NotifyFilters.LastAccess;
            _watcher.Filter = "*.*";
            _watcher.Changed += FileChanged;

            _workspace = new CustomWorkspace();
        }
        public ApplicationController(CompositionContainer container, IEnvironmentService environmentService,
            IPresentationService presentationService, ShellService shellService, FileController fileController)
        {
            InitializeCultures();
            presentationService.InitializeCultures();

            this.environmentService = environmentService;
            this.fileController = fileController;

            this.solutionDocumentController = container.GetExportedValue<SolutionDocumentController>();
            this.shellViewModel = container.GetExportedValue<ShellViewModel>();
            this.mainViewModel = container.GetExportedValue<MainViewModel>();
            this.startViewModel = container.GetExportedValue<StartViewModel>();

            shellService.ShellView = shellViewModel.View;
            this.shellViewModel.Closing += ShellViewModelClosing;
            this.exitCommand = new DelegateCommand(Close);
        }
Exemplo n.º 24
0
        public WorkspaceViewModel(ShellViewModel shell, string path)
            : base(null, path)
        {
            _host = new Host(path);
            _host.Connected += HostConnected;
            _host.Configurations += HostConfigurations;
            _host.References += HostReferences;

            _watcher = new FileSystemWatcher(path);
            _watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.DirectoryName | NotifyFilters.LastAccess;
            _watcher.Filter = "*.*";
            _watcher.Changed += FileChanged;

            _workspace = new CustomWorkspace();
            _shell = shell;

            InitializeWorkspace();
        }
Exemplo n.º 25
0
        public ModuleController(IMessageService messageService, IPresentationService presentationService, 
            IEntityController entityController, BookController bookController, PersonController personController, 
            ShellService shellService, ShellViewModel shellViewModel)
        {
            presentationService.InitializeCultures();
            
            this.messageService = messageService;
            this.entityController = entityController;
            this.bookController = bookController;
            this.personController = personController;
            this.shellService = shellService;
            this.shellViewModel = shellViewModel;
            
            shellService.ShellView = shellViewModel.View;

            this.shellViewModel.Closing += ShellViewModelClosing;
            this.exitCommand = new DelegateCommand(Close);
        }
Exemplo n.º 26
0
        public void When_nowplaying_is_visible_then_active_item_should_not_be_visible()
        {
            var widgets = new Mock<IAppWidget>();
            var eventAgg = new Mock<IEventAggregator>();
            var vm = new ShellViewModel(new[] { widgets.Object }, eventAgg.Object, new Mock<IWindowManager>().Object, null, null);

            Assert.IsFalse(vm.NowPlayingVisible);
            Assert.IsTrue(vm.ActiveItemVisible);

            var capturedEvents = new List<string>();
            vm.PropertyChanged += (s, e) => capturedEvents.Add(e.PropertyName);
            vm.NowPlayingVisible = true;

            Assert.IsTrue(vm.NowPlayingVisible);
            Assert.IsFalse(vm.ActiveItemVisible);
            Assert.AreEqual(2, capturedEvents.Count);
            Assert.IsTrue(capturedEvents.Contains("NowPlayingVisible"));
            Assert.IsTrue(capturedEvents.Contains("ActiveItemVisible"));
        }
Exemplo n.º 27
0
        public void Handling_main_request_with_main_already_active_should_work_but_not_create_a_new_instance()
        {
            /* Arrange */
            var mocks = new TestAssistant().MockAll();
            var main = A.Dummy<MainViewModel>();

            var vm = new ShellViewModel(main, mocks.Messenger, mocks.ViewModelFactory);
            var handler = vm as IHandle<ViewRequest>;
            vm.MonitorEvents();

            /* Act */
            (vm as IActivate).Activate();
            handler.Handle(ViewRequest.MainView);

            /* Assert */
            A.CallTo(() => mocks.ViewModelFactory.Get(typeof(DummyViewModel))).MustNotHaveHappened();
            vm.ActiveItem.Should().BeSameAs(main);
            vm.ShouldNotRaisePropertyChangeFor((svm) => svm.ActiveItem);
        }
Exemplo n.º 28
0
        public void Handling_view_requests_should_work()
        {
            /* Arrange */
            var mocks = new TestAssistant().MockAll();
            var main = A.Dummy<MainViewModel>();

            A.CallTo(() => mocks.ViewModelFactory.Get(typeof(DummyViewModel))).Returns(new DummyViewModel());

            var optionsReq = new ViewRequest(typeof(DummyViewModel));
            var vm = new ShellViewModel(main, mocks.Messenger, mocks.ViewModelFactory);
            var handler = vm as IHandle<ViewRequest>;

            /* Act */
            (vm as IActivate).Activate();
            handler.Handle(optionsReq);

            /* Assert */
            A.CallTo(() => mocks.ViewModelFactory.Get(typeof(DummyViewModel))).MustHaveHappened(Repeated.Exactly.Once);
            vm.ActiveItem.Should().BeOfType<DummyViewModel>();
        }
Exemplo n.º 29
0
        public Shell(Frame frame)
        {

            this.InitializeComponent();
            this.ShellSplitView.Content = frame;
            frame.Navigated += Frame_Navigated;
            this.DataContext = this;
            ViewModel = new ShellViewModel();

            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
            {
                Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            }
            else
            {
                backButton.Click += BackButton_Click;
            }

            HideStatusBar();
        }
Exemplo n.º 30
0
        public Shell()
        {
            this.InitializeComponent();

            var vm = new ShellViewModel();
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Welcome", PageType = typeof(WelcomePage) });
            //vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Page 1", PageType = typeof(Page1) });
            //vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Page 2", PageType = typeof(Page2) });
            //vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Page 3", PageType = typeof(Page3) });
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Listar Notas", PageType = typeof(NotesPage) });
            vm.MenuItems.Add(new MenuItem { Icon = "", Title = "Agregar Nota", PageType = typeof(NotePage) });

            // select the first menu item
            vm.SelectedMenuItem = vm.MenuItems.First();

            this.ViewModel = vm;

            this.Loaded += (s, e) => {
                App.MainViewModel.onedrive = new OneDriveService();
            };
        }
Exemplo n.º 31
0
 public MainWindow(ShellViewModel viewModel)
     : this()
 {
     DataContext = viewModel;
 }
Exemplo n.º 32
0
 public RecentFontsMenuItem(ShellViewModel shell)
 {
     this.shell       = shell;
     this.DisplayName = Resources.MenuItem_RecentFonts;
     this.shell.RecentFonts.CollectionChanged += RecentFonts_CollectionChanged;
 }
 public void Teardown()
 {
     _viewModel   = null;
     _dataService = null;
 }
Exemplo n.º 34
0
 public ShellView()
 {
     DataContext = new ShellViewModel();
     InitializeComponent();
 }
        private void navigationButton_Click(object sender, RoutedEventArgs e)
        {
            ShellViewModel vm = (ShellViewModel)DataContext;

            vm.navigateToImageView();
        }
Exemplo n.º 36
0
 private void SyncStatusChangedHandler()
 {
     ShellViewModel.ErrorMessageChanged(SyncService.SyncStatus);
 }
 public void Setup()
 {
     _dataService = new Mock <IExampleDataService>();        //We can new up mocks no problem.
     _viewModel   = new ShellViewModel(_dataService.Object); //Pass the mock's Object property in as the required service.
 }
Exemplo n.º 38
0
 public NotificationService(ShellViewModel host)
 {
     _host = host;
 }
Exemplo n.º 39
0
 public Shell(ShellViewModel viewmodel)
 {
     this.DataContext = viewmodel;
     InitializeComponent();
 }
Exemplo n.º 40
0
        public VsixShellViewModel([NotNull] ResourceManager resourceManager, [NotNull] ResourceViewModel resourceViewModel, [NotNull] ShellViewModel shellViewModel)
        {
            _resourceViewModel      = resourceViewModel;
            _shellViewModel         = shellViewModel;
            resourceManager.Loaded += (_, __) => SelectedCodeGeneratorsChanged();

            resourceViewModel.SelectedEntities.CollectionChanged += (_, __) => SelectedCodeGeneratorsChanged();
        }
        public ShellViewModelTests()
        {
            _mainViewModelMock = new Mock <IMainViewModel>();

            _shellViewModel = new ShellViewModel(_mainViewModelMock.Object);
        }
        private void SendPhotoInternal(TLMessage25 message)
        {
            var photo = ((TLMessageMediaPhoto)message.Media).Photo as TLPhoto;

            if (photo == null)
            {
                return;
            }

            var photoSize = photo.Sizes[0] as TLPhotoSize;

            if (photoSize == null)
            {
                return;
            }

            var fileLocation = photoSize.Location;

            if (fileLocation == null)
            {
                return;
            }

            byte[] bytes    = null;
            var    fileName = String.Format("{0}_{1}_{2}.jpg",
                                            fileLocation.VolumeId,
                                            fileLocation.LocalId,
                                            fileLocation.Secret);

            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                using (var fileStream = store.OpenFile(fileName, FileMode.Open, FileAccess.Read))
                {
                    if (fileStream.Length > 0)
                    {
                        bytes = new byte[fileStream.Length];
                        fileStream.Read(bytes, 0, bytes.Length);
                    }
                }
            }

            if (bytes == null)
            {
                return;
            }

            var md5Bytes    = Telegram.Api.Helpers.Utils.ComputeMD5(bytes);
            var md5Checksum = BitConverter.ToInt64(md5Bytes, 0);

            StateService.GetServerFilesAsync(
                results =>
            {
                var serverFile = results.FirstOrDefault(result => result.MD5Checksum.Value == md5Checksum);

#if MULTIPLE_PHOTOS
                serverFile = null;
#endif

                if (serverFile != null)
                {
                    var media        = serverFile.Media;
                    var captionMedia = media as IInputMediaCaption;
                    if (captionMedia == null)
                    {
                        var inputMediaPhoto = serverFile.Media as TLInputMediaPhoto;
                        if (inputMediaPhoto != null)
                        {
                            var inputMediaPhoto28 = new TLInputMediaPhoto28(inputMediaPhoto, TLString.Empty);
                            captionMedia          = inputMediaPhoto28;
                            media            = inputMediaPhoto28;
                            serverFile.Media = inputMediaPhoto28;
                            StateService.SaveServerFilesAsync(results);
                        }
                        var inputMediaUploadedPhoto = serverFile.Media as TLInputMediaUploadedPhoto;
                        if (inputMediaUploadedPhoto != null)
                        {
                            var inputMediaUploadedPhoto28 = new TLInputMediaUploadedPhoto28(inputMediaUploadedPhoto, TLString.Empty);
                            captionMedia     = inputMediaUploadedPhoto28;
                            media            = inputMediaUploadedPhoto28;
                            serverFile.Media = inputMediaUploadedPhoto28;
                            StateService.SaveServerFilesAsync(results);
                        }
                    }

                    if (captionMedia != null)
                    {
                        captionMedia.Caption = ((TLMessageMediaPhoto28)message.Media).Caption ?? TLString.Empty;
                    }

                    message.InputMedia = media;
                    ShellViewModel.SendMediaInternal(message, MTProtoService, StateService, CacheService);
                }
                else
                {
                    var fileId                      = TLLong.Random();
                    message.Media.FileId            = fileId;
                    message.Media.UploadingProgress = 0.001;
                    UploadFileManager.UploadFile(fileId, message, bytes);
                }
            });
        }
Exemplo n.º 43
0
 ViewModelContainer()
 {
     ShellViewModel = new ShellViewModel();
 }
Exemplo n.º 44
0
 public FeedsController(IMessageService messageService, INavigationService navigationService, ISyndicationService syndicationService,
                        INetworkInfoService networkInfoService, ILauncherService launcherService, ShellViewModel shellViewModel,
                        Lazy <AddEditFeedViewModel> addEditFeedViewModel, Lazy <FeedViewModel> feedViewModel, Lazy <FeedItemViewModel> feedItemViewModel)
 {
     this.messageService       = messageService;
     this.navigationService    = navigationService;
     this.syndicationService   = syndicationService;
     this.networkInfoService   = networkInfoService;
     this.launcherService      = launcherService;
     this.shellViewModel       = shellViewModel;
     this.addEditFeedViewModel = new Lazy <AddEditFeedViewModel>(() => InitializeViewModel(addEditFeedViewModel.Value));
     this.feedViewModel        = new Lazy <FeedViewModel>(() => InitializeViewModel(feedViewModel.Value));
     this.feedItemViewModel    = new Lazy <FeedItemViewModel>(() => InitializeViewModel(feedItemViewModel.Value));
     addFeedCommand            = new AsyncDelegateCommand(AddFeed);
     addEditLoadFeedCommand    = new AsyncDelegateCommand(AddEditLoadFeed);
     addUpdateFeedCommand      = new AsyncDelegateCommand(AddUpdateFeed, CanAddUpdateFeed);
     showFeedViewCommand       = new AsyncDelegateCommand(ShowFeedView);
     editFeedCommand           = new AsyncDelegateCommand(EditFeed);
     moveFeedUpCommand         = new DelegateCommand(MoveFeedUp, CanMoveFeedUp);
     moveFeedDownCommand       = new DelegateCommand(MoveFeedDown, CanMoveFeedDown);
     removeFeedCommand         = new AsyncDelegateCommand(RemoveFeed);
     refreshFeedCommand        = new AsyncDelegateCommand(RefreshFeed);
     readUnreadCommand         = new DelegateCommand(MarkAsReadUnread);
     showFeedItemViewCommand   = new AsyncDelegateCommand(ShowFeedItemView);
     launchBrowserCommand      = new AsyncDelegateCommand(LaunchBrowser, CanLaunchBrowser);
 }
Exemplo n.º 45
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                this.ShellViewModel = Ioc.Container.Resolve <ShellViewModel>();
                this.ShellViewModel.Initialize();

                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                Ioc.Container.Resolve <INavigator>().NavigateToViewModel <MainViewModel>();
            }

            if (!string.IsNullOrWhiteSpace(args.Arguments))
            {
                var             storage         = Ioc.Container.Resolve <IStorage>();
                List <FeedItem> pinnedFeedItems = await storage.LoadAsync <List <FeedItem> >(Constants.PinnedFeedItemsKey);

                if (pinnedFeedItems != null)
                {
                    int id;
                    if (int.TryParse(args.Arguments, out id))
                    {
                        var pinnedFeedItem = pinnedFeedItems.FirstOrDefault(fi => fi.Id == id);
                        if (pinnedFeedItem != null)
                        {
                            Ioc.Container.Resolve <INavigator>().NavigateToViewModel <FeedItemViewModel>(pinnedFeedItem);
                        }
                    }
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }
Exemplo n.º 46
0
 public void Call()
 {
     ShellViewModel.StartVoiceCall(With as TLUser, IoC.Get <IVoIPService>(), IoC.Get <ICacheService>());
 }
Exemplo n.º 47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Shell"/> class.
 /// </summary>
 /// <param name="viewModel">The view model.</param>
 public Shell(ShellViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Exemplo n.º 48
0
 public PrintController(IFileService fileService, IPrintDialogService printDialogService, ShellViewModel shellViewModel, ExportFactory <PrintPreviewViewModel> printPreviewViewModelFactory)
 {
     this.fileService                  = fileService;
     this.printDialogService           = printDialogService;
     this.shellViewModel               = shellViewModel;
     this.printPreviewViewModelFactory = printPreviewViewModelFactory;
     printPreviewCommand               = new DelegateCommand(ShowPrintPreview, CanShowPrintPreview);
     printCommand                 = new DelegateCommand(PrintDocument, CanPrintDocument);
     closePrintPreviewCommand     = new DelegateCommand(ClosePrintPreview);
     fileService.PropertyChanged += FileServicePropertyChanged;
 }
Exemplo n.º 49
0
 public Shell()
 {
     this.InitializeComponent();
     ShellViewModel.FrameManager(this.MainFrame);
 }
Exemplo n.º 50
0
 public OpenMasterFileCommand(ShellViewModel shellViewModel)
 {
     this.shellViewModel = shellViewModel;
 }
Exemplo n.º 51
0
 public ShellImpl(ModuleLoader loader, ShellViewModel shellViewModel)
 {
     _loader         = loader;
     _shellViewModel = shellViewModel;
 }
Exemplo n.º 52
0
        public override void Create()
        {
            if (IsWorking)
            {
                return;
            }
            if (_newChannel == null)
            {
                return;
            }

            var participants = new TLVector <TLInputUserBase>();

            foreach (var item in SelectedUsers)
            {
                participants.Add(item.ToInputUser());
            }
            participants.Add(new TLInputUser {
                UserId = new TLInt(StateService.CurrentUserId), AccessHash = new TLLong(0)
            });

            if (participants.Count == 0)
            {
                MessageBox.Show(AppResources.PleaseChooseAtLeastOneParticipant, AppResources.Error, MessageBoxButton.OK);
                return;
            }

            _newChannel.ParticipantIds = new TLVector <TLInt> {
                Items = SelectedUsers.Select(x => x.Id).ToList()
            };

            IsWorking = true;
            MTProtoService.InviteToChannelAsync(_newChannel.ToInputChannel(), participants,
                                                result => Execute.BeginOnUIThread(() =>
            {
                IsWorking = false;

                StateService.With = _newChannel;
                StateService.RemoveBackEntries = true;
                NavigationService.UriFor <DialogDetailsViewModel>().Navigate();
            }),
                                                error => Execute.BeginOnUIThread(() =>
            {
                if (error.TypeEquals(ErrorType.PEER_FLOOD))
                {
                    //MessageBox.Show(AppResources.PeerFloodAddContact, AppResources.Error, MessageBoxButton.OK);
                    ShellViewModel.ShowCustomMessageBox(AppResources.PeerFloodAddContact, AppResources.Error, AppResources.MoreInfo.ToLowerInvariant(), AppResources.Ok.ToLowerInvariant(),
                                                        result =>
                    {
                        if (result == CustomMessageBoxResult.RightButton)
                        {
                            TelegramViewBase.NavigateToUsername(MTProtoService, Constants.SpambotUsername, null, null, null);
                        }
                    });
                }
                else if (error.TypeEquals(ErrorType.USERS_TOO_MUCH))
                {
                    MessageBox.Show(AppResources.UsersTooMuch, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.USER_CHANNELS_TOO_MUCH))
                {
                    MessageBox.Show(AppResources.UserChannelsTooMuch, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.BOTS_TOO_MUCH))
                {
                    MessageBox.Show(AppResources.BotsTooMuch, AppResources.Error, MessageBoxButton.OK);
                }
                else if (error.TypeEquals(ErrorType.USER_NOT_MUTUAL_CONTACT))
                {
                    MessageBox.Show(AppResources.UserNotMutualContact, AppResources.Error, MessageBoxButton.OK);
                }

                IsWorking = false;
                Execute.ShowDebugMessage("channels.inviteToChannel error " + error);
            }));
        }
Exemplo n.º 53
0
 public ApplicationController(ShellViewModel shellViewModel)
 {
     this.shellViewModel = shellViewModel;
 }
        private void ShellLoaded(object sender, RoutedEventArgs e)
        {
            _model = (ShellViewModel)DataContext;

            DoUpdateLayout();
        }
Exemplo n.º 55
0
 public NavigationService(ShellViewModel host)
 {
     _host = host;
 }
Exemplo n.º 56
0
 public BalansViewModel(ShellViewModel svm)
 {
     shellVM = svm;
 }
Exemplo n.º 57
0
        public INewTabHost <Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source)
        {
            var view = new ShellViewModel(false).View;

            return(new NewTabHost <Window>(view, view.ShellTabablzControl));
        }
Exemplo n.º 58
0
        private ShellViewModel CreateShell()
        {
            var shellViewModel = new ShellViewModel(_documentManager, CreateApplicationMenuMock().Object, _eventAggregatorMock.Object);

            return(shellViewModel);
        }
Exemplo n.º 59
0
        public MobileShell()
        {
            InitializeComponent();

            BindingContext = new ShellViewModel();
        }
Exemplo n.º 60
0
 public Shell(ShellViewModel viewModel)
 {
     InitializeComponent();
     Loaded += (sender, args) => { DataContext = viewModel; };
 }