public ViewModelLocator()
        {
            var kernel = new StandardKernel();
            kernel.Bind<IKeyboardService>().To<DefaultKeyboardService>();

            if (ViewModelBase.IsInDesignModeStatic)
            {
                kernel.Bind<IConfigurationService>().To<DesignConfigurationService>();
                kernel.Bind<INuiService>().To<MockNuiService>();
            }
            else
            {
                kernel.Bind<IConfigurationService>().To<AppConfigConfigurationService>();
                kernel.Bind<INuiService>().To<KinectNuiService>();
            }

            nuiService = kernel.Get<INuiService>();

            main = new MainViewModel(
                kernel.Get<IConfigurationService>(),
                nuiService,
                kernel.Get<IKeyboardService>());

            boundingBox = new BoundingBoxViewModel(
                nuiService);

            explorer = new ExplorerViewModel(
                nuiService, kernel.Get<IConfigurationService>());

            math = new MathViewModel();
        }
示例#2
0
        public void TestInitialize()
        {
            _shellViewModelMock           = new Mock <IShellViewModel>();
            _localhostServerEnvironmentId = Guid.NewGuid();
            _localhostServerMock          = new Mock <IServer>();
            _localhostServerMock.Setup(it => it.EnvironmentID).Returns(_localhostServerEnvironmentId);
            var mockEnvironmentConnection = SetupMockConnection();

            _localhostServerMock.SetupGet(it => it.Connection).Returns(mockEnvironmentConnection.Object);
            _windowsGroupPermissionMock = new Mock <IWindowsGroupPermission>();
            _localhostServerMock.Setup(it => it.Permissions).Returns(new List <IWindowsGroupPermission>()
            {
                _windowsGroupPermissionMock.Object
            });
            _localhostServerMock.SetupGet(it => it.DisplayName).Returns("localhostServerResourceName");
            _shellViewModelMock.SetupGet(it => it.LocalhostServer).Returns(_localhostServerMock.Object);
            _eventAggregatorMock = new Mock <Microsoft.Practices.Prism.PubSubEvents.IEventAggregator>();

            var connectControlSingleton = new Mock <Dev2.ConnectionHelpers.IConnectControlSingleton>();

            CustomContainer.Register(connectControlSingleton.Object);
            var environmentRepository = new Mock <IServerRepository>();

            CustomContainer.Register(environmentRepository.Object);
            var explorerTooltips = new Mock <IExplorerTooltips>();

            CustomContainer.Register(new Mock <IExplorerTooltips>().Object);
            _target = new ExplorerViewModel(_shellViewModelMock.Object, _eventAggregatorMock.Object, true);
        }
 /// <summary>
 ///		Guarda los datos del formulario en el modelo
 /// </summary>
 private void Save()
 {
     if (ValidateData())
     {
         // Asigna las propiedades
         Deployment.Name              = Name;
         Deployment.Description       = Description;
         Deployment.PathScriptsTarget = PathScriptsTarget;
         Deployment.PathFilesTarget   = PathFilesTarget;
         // Añade los elementos
         ConnectionsListViewModel.GetConnections(Deployment.Connections);
         Deployment.Parameters.Clear();
         Deployment.Parameters.AddRange(ParametersListViewModel.GetParameters());
         Deployment.Scripts.Clear();
         Deployment.Scripts.AddRange(ScriptsTreeViewModel.GetScripts());
         // Añade los formatos de salida
         Deployment.ReportFormatTypes.Clear();
         foreach (ControlItemViewModel item in ReportOutputListViewModel.Items)
         {
             if (item.Tag != null && item.IsChecked)
             {
                 Deployment.ReportFormatTypes.Add(item.Tag.ToString().GetEnum(DeploymentModel.ReportFormat.Xml));
             }
         }
         // Añade el modo de distribución al proyecto si es necesario
         if (IsNew)
         {
             Project.Deployments.Add(Deployment);
             IsNew = false;
         }
         // Graba los datos
         ExplorerViewModel.SaveProject();
         IsUpdated = false;
     }
 }
示例#4
0
        private void MoveExplorerViewModel(ExplorerViewModel source, bool beforeTarget, ExplorerViewModel target)
        {
            if (source.AreEqual(target))
            {
                return;
            }

            //Remove source item first
            _explorerService.ExplorerViewModels.Remove(source);

            //Determine target element index in flat collection
            var targetFlatIndex = _explorerService.ExplorerViewModels.IndexOf(target);

            //Offset index if we need place source item after target item
            if (!beforeTarget)
            {
                targetFlatIndex++;
            }

            //Synchronize items area
            source.Container = target.Container;

            //Insert source item before or after target
            _explorerService.ExplorerViewModels.SafeInsert(targetFlatIndex, source);
        }
        public ViewModelLocator()
        {
            var kernel = new StandardKernel();

            kernel.Bind <IKeyboardService>().To <DefaultKeyboardService>();

            if (ViewModelBase.IsInDesignModeStatic)
            {
                kernel.Bind <IConfigurationService>().To <DesignConfigurationService>();
                kernel.Bind <INuiService>().To <MockNuiService>();
            }
            else
            {
                kernel.Bind <IConfigurationService>().To <AppConfigConfigurationService>();
                kernel.Bind <INuiService>().To <KinectNuiService>();
            }

            nuiService = kernel.Get <INuiService>();

            main = new MainViewModel(
                kernel.Get <IConfigurationService>(),
                nuiService,
                kernel.Get <IKeyboardService>());

            boundingBox = new BoundingBoxViewModel(
                nuiService);

            explorer = new ExplorerViewModel(
                nuiService, kernel.Get <IConfigurationService>());

            math = new MathViewModel();
        }
示例#6
0
 public void OpenWindow(object context = null)
 {
     if (UseScriptCommandInitializer)
     {
         OpenWindowUsingScriptCommand();
     }
     else
     {
         #region Obsoluting - Use ExplorerInitializer
         IExplorerInitializer initializer = new ExplorerInitializer(_windowManager, _events, RootModels.ToArray())
         {
             Initializers = new List <IViewModelInitializer <IExplorerViewModel> >()
             {
                 new BasicParamInitalizers(_expandRootDirectories, _enableMultiSelect, _enableDrag, _enableDrop),
                 new ColumnInitializers(),
                 new ScriptCommandsInitializers(_windowManager, _events, _profiles),
                 new ToolbarCommandsInitializers(_windowManager)
             }
         };
         ExplorerViewModel evm = new ExplorerViewModel(_windowManager, _events)
         {
             Initializer = initializer
         };
         _windowManager.ShowWindow(evm);
         #endregion
     }
 }
示例#7
0
 public ExplorerView(ExplorerViewModel viewModel)
 {
     InitializeComponent();
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         DataContext = viewModel;
     }
 }
示例#8
0
        public static void SetLifetime(ExplorerViewModel explorer, IClassicDesktopStyleApplicationLifetime lifetime)
        {
            var window = new MainWindow();

            explorer.LoadingProcess.Status = window.Title;
            window.DataContext             = explorer;
            lifetime.MainWindow            = window;
        }
示例#9
0
        public override async Task <IScriptCommand> ExecuteAsync(ParameterDic pm)
        {
            IWindowManager   wm     = pm.GetValue <IWindowManager>(WindowManagerKey) ?? new WindowManager();
            IEventAggregator events = pm.GetValue <IEventAggregator>(EventAggregatorKey) ?? new EventAggregator();

            IExplorerInitializer initializer = new ScriptCommandInitializer()
            {
                StartupParameters = pm,
                WindowManager     = wm,
                Events            = events,
                OnModelCreated    = ScriptCommands.Run(OnModelCreatedKey),
                OnViewAttached    = ScriptCommands.Run(OnViewAttachedKey)
            };

            ExplorerViewModel evm = null;

            switch (ExplorerMode)
            {
            case Script.ExplorerMode.Normal:
                evm = new ExplorerViewModel(wm, events)
                {
                    Initializer = initializer
                };
                break;

            case Script.ExplorerMode.FileOpen:
                evm = new FilePickerViewModel(wm, events)
                {
                    Initializer = initializer,
                    PickerMode  = FilePickerMode.Open
                };
                break;

            case Script.ExplorerMode.FileSave:
                evm = new FilePickerViewModel(wm, events)
                {
                    Initializer = initializer,
                    PickerMode  = FilePickerMode.Save
                };
                break;

            case Script.ExplorerMode.DirectoryOpen:
                evm = new DirectoryPickerViewModel(wm, events)
                {
                    Initializer = initializer
                };
                break;

            default:
                return(ResultCommand.Error(new NotSupportedException(ExplorerMode.ToString())));
            }

            logger.Info(String.Format("Creating {0}", evm));
            pm.SetValue(DestinationKey, evm, false);

            return(NextCommand);
        }
        public MainViewModel()
        {
            Help   = new HelpViewModel();
            Themes = new ThemesViewModel();

            Explorer    = new ExplorerViewModel();
            QuickAccess = new QuickAccessViewModel();
            QuickAccess.NavigateCallback = Explorer.NavigateToDirectory;
        }
示例#11
0
        public MainWindow()
        {
            this.InitializeComponent();
            App.AttachDevTools(this);
            MangaReader.Core.Client.Init();
            var processTest = new ProcessTest();

            processTest.StateChanged += ProcessTestOnStateChanged;
            Task.Run(() => MangaReader.Core.Client.Start(processTest));
            explorer         = new ExplorerViewModel();
            this.DataContext = explorer;
        }
        public ExplorerWindow(ExplorerViewModel viewModel)
            : base(viewModel, DataWindowMode.Custom)
        {
            InitializeComponent();
            ShowInTaskbar         = false;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            var screenHeight = SystemParameters.PrimaryScreenHeight;

            TopGrid.Height = screenHeight * 2 / 3;

            Title = viewModel.Title;
        }
示例#13
0
        public Explorer()
        {
            _wm     = new WindowManager();
            _events = new EventAggregator();
            _evm    = new ExplorerViewModel(_wm, _events);

            this.SetBinding(CurrentDirectoryProperty, new Binding("FileList.CurrentDirectory")
            {
                Source = _evm, Mode = BindingMode.TwoWay
            });
            this.SetBinding(SelectedEntriesProperty, new Binding("FileList.Selection.SelectedModels")
            {
                Source = _evm, Mode = BindingMode.TwoWay
            });
        }
        public ActionResult Explorer(string drive, string path)
        {
            var fullPath = string.Concat(drive, ":\\", path);

            if (System.IO.File.Exists(fullPath))
            {
                var fileBytes = System.IO.File.ReadAllBytes(fullPath);
                return(File(fileBytes, "application/downloads"));
            }
            else if (Directory.Exists(fullPath))
            {
                var dirListModel  = _explorerService.MapDirs(fullPath);
                var fileListModel = _explorerService.MapFiles(fullPath);
                var explorerModel = new ExplorerViewModel(dirListModel, fileListModel);

                //For using browser ability to correctly browsing the folders,
                //Every path needs to end with slash
                if (fullPath.Last() != '/' && fullPath.Last() != '\\')
                {
                    explorerModel.URL = "/Explorer/" + fullPath + "/";
                }
                else
                {
                    explorerModel.URL = "/Explorer/" + fullPath;
                }

                UriBuilder uriBuilder = new UriBuilder
                {
                    Path = HttpContext.Request.Path.ToString()
                };

                //Show the current directory name using page URL.
                explorerModel.FolderName = WebUtility.UrlDecode(uriBuilder.Uri.Segments.Last());

                //Making a URL to going up one level.
                Uri uri = new Uri(uriBuilder.Uri.AbsoluteUri.Remove
                                      (uriBuilder.Uri.AbsoluteUri.Length -
                                      uriBuilder.Uri.Segments.Last().Length));

                explorerModel.ParentFolderName = uri.AbsolutePath;

                return(View(explorerModel));
            }
            else
            {
                return(Content(fullPath + " is not a valid file or directory."));
            }
        }
示例#15
0
        private void AttachLoadingAdorner(UIElement view, ExplorerViewModel viewModel)
        {
            LoadingAdorner loading = new LoadingAdorner(view);

            //We can set font information and text.
            loading.FontSize      = 14;
            loading.OverlayedText = "Please Wait! Extracting folders/files information from Selected Drive.";
            loading.Typeface      = new Typeface(new FontFamily("Arial"), FontStyles.Italic, FontWeights.Bold, FontStretches.Normal);

            Binding bind = new Binding();

            bind.Source    = viewModel;
            bind.Path      = new PropertyPath("Isbusy");
            bind.Converter = new VisibilityConverter();
            loading.SetBinding(LoadingAdorner.VisibilityProperty, bind);
            System.Windows.Documents.AdornerLayer.GetAdornerLayer(view).Add(loading);
        }
示例#16
0
        /// <summary>
        /// handle a item double click (using Interaction.Triggers is not working because on list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void Item_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                ExplorerViewModel model = DataContext as ExplorerViewModel;
                if (model == null)
                {
                    return;
                }

                model.ForwardCommand.Execute("BookReadCommand");
            }
            catch (Exception err)
            {
                LogHelper.Manage("ExplorerView:Grouping", err);
            }
        }
示例#17
0
 public void TestInitialize()
 {
     _shellViewModelMock           = new Mock <IShellViewModel>();
     _localhostServerEnvironmentId = Guid.NewGuid();
     _localhostServerMock          = new Mock <IServer>();
     _localhostServerMock.Setup(it => it.EnvironmentID).Returns(_localhostServerEnvironmentId);
     _windowsGroupPermissionMock = new Mock <IWindowsGroupPermission>();
     _localhostServerMock.Setup(it => it.Permissions).Returns(new List <IWindowsGroupPermission>()
     {
         _windowsGroupPermissionMock.Object
     });
     //_localhostServerMock.Setup(it => it.GetServerConnections()).Returns(new List<IServer>());
     _localhostServerMock.SetupGet(it => it.DisplayName).Returns("localhostServerResourceName");
     _shellViewModelMock.SetupGet(it => it.LocalhostServer).Returns(_localhostServerMock.Object);
     _eventAggregatorMock = new Mock <Microsoft.Practices.Prism.PubSubEvents.IEventAggregator>();
     _target = new ExplorerViewModel(_shellViewModelMock.Object, _eventAggregatorMock.Object, true);
 }
示例#18
0
        public ActionResult Explore(ExplorerViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("Explorer", model));
                }

                var uri        = new Uri(model.Url);
                var loadResult = _htmlParser.Load(uri);

                if (loadResult != ParsingResult.Success)
                {
                    if (loadResult == ParsingResult.NotFound)
                    {
                        ModelState.AddModelError("Url", "The URL cannot to be resolved");
                        return(View("Explorer", model));
                    }
                    else
                    {
                        return(View("Error"));
                    }
                }

                var wordParsingResult  = _htmlParser.ParseWords();
                var imageParsingResult = _htmlParser.ParseImages();

                model.TotalWordCount = wordParsingResult.TotalCount;
                // Select top 12 words by occurrence
                model.TopWords = wordParsingResult.GetWordCounts(true)
                                 .OrderByDescending(w => w.Count)
                                 .Take(12);

                model.TotalImageCount = imageParsingResult.TotalCount;
                model.ImageUrls       = imageParsingResult.ImageUrls;

                return(View("Explorer", model));
            }
            catch (Exception)
            {
                return(View("Error"));
            }
        }
示例#19
0
        public MainWindow()
        {
            InitializeComponent();
            List <String> extensions = new List <String>()
            {
                ".mp4", ".avi", ".mkv", ".flv"
                , ".flac", ".mp3", "wav", ".ogg", ".jpg", ".jpeg", ".png", ".ico", ".bmp"
            };
            Playlist playlist = new Playlist();
            Explorer explorer = new Explorer();

            this.controlViewModel = new ControlViewModel(this, this.ScreenView, extensions, explorer, this.ExplorerView);
            PlaylistViewModel playlistViewModel = new PlaylistViewModel(playlist, explorer);
            ExplorerViewModel explorerViewModel = new ExplorerViewModel(explorer, playlist, this.ScreenView, extensions, this.controlViewModel);

            this.PlaylistView.DataContext = playlistViewModel;
            this.ControlView.DataContext  = controlViewModel;
            this.ExplorerView.DataContext = explorerViewModel;
        }
示例#20
0
        public async Task <IActionResult> Index(string type)
        {
            type = string.IsNullOrEmpty(type) ? Constants.Patient : type;
            ExplorerViewModel model = new ExplorerViewModel();

            model.DataType = type;
            model.Fields   = GetFields(type);

            //Get total patients
            ExplorerService service = new ExplorerService();

            model.TotalPatients = await service.TotalPatients(configuration);

            model.TotalTransactions = await service.TotalTransactions(configuration);

            model.TotalIssues = await service.TotalIssues(configuration);

            model.TotalFacilities = await service.TotalFacilityInConsultation(configuration);

            return(View(model));
        }
示例#21
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);


            //CREATE INSTANCE OF VIEW
            ExplorerView view = new MVVMConcepts.ExplorerView();

            //INITIALIZE EXTERNAL SERVICE FOR VIEW MODEL.
            IFolderExplorer folderExplorerService = new FolderExplorerService();

            //CREATE INSTANCE OF VIEWMODEL AND PASS EXTERNAL SERVICE TO IT.
            ExplorerViewModel viewModel = new ExplorerViewModel(folderExplorerService);

            //BIND VIEW'S DATA CONTEXT  TO VIEWMODEL
            view.DataContext = viewModel;

            //ATTACH ADORNER TO THE WINDOW.
            AttachLoadingAdorner(view.grd, viewModel); //COMMENT OUT THIS LINE TO REMOVE ADORNER EFFECT.

            view.ShowDialog();
        }
        public override IScriptCommand Execute(ParameterDic pm)
        {
            var viewModel = new ExplorerViewModel(_initializer);

            pm["Explorer"] = viewModel;
            var view = new ExplorerView();

            Caliburn.Micro.Bind.SetModel(view, viewModel); //Set the ViewModel using this command.
            var mdiChild = new MdiChild
            {
                DataContext = viewModel,
                ShowIcon    = true,
                Content     = view,
                Width       = 500,
                Height      = 334,
                Position    = new Point(0, 0)
            };

            mdiChild.SetBinding(MdiChild.TitleProperty, new Binding("DisplayName")
            {
                Mode = BindingMode.OneWay
            });
            mdiChild.SetBinding(MdiChild.IconProperty, new Binding("CurrentDirectory.Icon")
            {
                Mode = BindingMode.OneWay
            });
            _container.Children.Add(mdiChild);

            var selection = _getSelectionFunc == null ? null : _getSelectionFunc(pm);

            if (selection != null && selection.Count() > 0)
            {
                return(UIScriptCommands.ExplorerGoToValue(selection.First()));
            }

            return(ResultCommand.NoError);
        }
示例#23
0
 public MyViewModel(ExplorerViewModel explorer)
 {
     AddFolderCommand = new DelegateCommand(ExecuteAddFolderCommand, (x) => true);
 }
示例#24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExplorerWindow"/> class.
 /// </summary>
 public ExplorerWindow(ExplorerViewModel viewModel)
     : base(viewModel, DataWindowMode.Custom)
 {
     InitializeComponent();
 }
示例#25
0
        public bool Load(string[] args)
        {
            // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far.
            GlobalSettings.Default.SEVersion = SpaceEngineersConsts.GetSEVersion();

            // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with!
            // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly.
            if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true))
            {
                MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Application.Current.Shutdown();
                return(false);
            }

            //string loadWorld = null;

            //foreach (var arg in args)
            //{
            //    if (arg.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 && !File.Exists(arg))
            //        continue;

            //    string file = Path.GetFileName(arg);
            //    if (file.Equals("Sandbox.sbc", StringComparison.InvariantCultureIgnoreCase)
            //        || file.Equals("SANDBOX_0_0_0_.sbs", StringComparison.InvariantCultureIgnoreCase))
            //        loadWorld = Path.GetDirectoryName(arg);
            //}

            // Force pre-loading of any Space Engineers resources.
            SpaceEngineersCore.LoadDefinitions();

            // Load the Space Engineers assemblies, or dependant classes after this point.
            var explorerModel = new ExplorerModel();

            if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR"))
            {
                ResourceReportModel.GenerateOfflineReport(explorerModel, args);
                Application.Current.Shutdown();
                return(false);
            }

            var eViewModel = new ExplorerViewModel(explorerModel);
            var eWindow    = new WindowExplorer(eViewModel);

            //if (allowClose)
            //{
            eViewModel.CloseRequested += (sender, e) =>
            {
                SaveSettings(eWindow);
                Application.Current.Shutdown();
            };
            //}
            eWindow.Loaded += (sender, e) =>
            {
                Splasher.CloseSplash();
                if (GlobalSettings.Default.WindowLeft.HasValue)
                {
                    eWindow.Left = GlobalSettings.Default.WindowLeft.Value;
                }
                if (GlobalSettings.Default.WindowTop.HasValue)
                {
                    eWindow.Top = GlobalSettings.Default.WindowTop.Value;
                }
                if (GlobalSettings.Default.WindowWidth.HasValue)
                {
                    eWindow.Width = GlobalSettings.Default.WindowWidth.Value;
                }
                if (GlobalSettings.Default.WindowHeight.HasValue)
                {
                    eWindow.Height = GlobalSettings.Default.WindowHeight.Value;
                }
                if (GlobalSettings.Default.WindowState.HasValue)
                {
                    eWindow.WindowState = GlobalSettings.Default.WindowState.Value;
                }
            };
            eWindow.ShowDialog();

            return(true);
        }
示例#26
0
        public async Task <IActionResult> Search(ExplorerViewModel model, IFormCollection form)
        {
            string[] fields = form["Field"].ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string[] values = form["Value"].ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            ExplorerService service = new ExplorerService();

            try
            {
                if (model.DataType.Equals(Constants.Patient))
                {
                    var patients = await service.FilterPatientsByDataType(configuration, fields, values);

                    return(Json(new { type = model.DataType, data = patients }));
                }

                if (model.DataType.Equals(Constants.Consultation))
                {
                    var consults = await service.FilterConsultationsByDataType(configuration, fields, values);

                    return(Json(new { type = model.DataType, data = consults }));
                }

                if (model.DataType.Equals(Constants.Prescription))
                {
                    List <PrescriptionViewModel> result = new List <PrescriptionViewModel>();
                    var prescriptions = await service.FilterPrescriptionsByDataType(configuration, fields, values);

                    foreach (var p in prescriptions)
                    {
                        foreach (var m in p.Medicines)
                        {
                            PrescriptionViewModel prescription = new PrescriptionViewModel
                            {
                                PatientId   = p.PatientId,
                                Description = p.Description,
                                Dose        = m.Dose,
                                DrugName    = m.DrugName,
                                DrugType    = m.DrugType,
                                Facility    = p.Facility,
                                Frequency   = m.Frequency,
                                Quantity    = m.Quantity,
                                Route       = m.Route,
                                VisitCode   = p.VisitCode
                            };
                            result.Add(prescription);
                        }
                    }

                    return(Json(new { type = model.DataType, data = result }));
                }

                if (model.DataType.Equals(Constants.Issue))
                {
                    var issues = await service.FilterIssuesByDataType(configuration, fields, values);

                    return(Json(new { type = model.DataType, data = issues }));
                }
            }
            catch (Exception ex)
            {
                return(View(new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }


            model.Fields = GetFields(model.DataType);
            return(View("Index", model));
        }
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new ExplorerViewModel();
 }
示例#28
0
 public SearchDirectory(ExplorerViewModel explorer, string s)
 {
     Explorer  = explorer;
     Directory = explorer.Parameter;
     Str       = s;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExplorerWindow"/> class.
 /// </summary>
 public ExplorerWindow(ExplorerViewModel viewModel)
     : base(viewModel, DataWindowMode.Custom)
 {
     InitializeComponent();
 }
示例#30
0
        public bool Load(string[] args)
        {
            // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far.
            Version gameVersion = SpaceEngineersConsts.GetSEVersion();
            bool    newVersion  = GlobalSettings.Default.SEVersion != gameVersion;

            GlobalSettings.Default.SEVersion = gameVersion;

            // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with!
            // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly.
            if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true))
            {
                MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Application.Current.Shutdown();
                return(false);
            }

            // the /B argument indicates the SEToolboxUpdate had started SEToolbox after fetching updated game binaries.
            if (newVersion && args.Any(a => a.Equals("/B", StringComparison.OrdinalIgnoreCase) || a.Equals("-B", StringComparison.OrdinalIgnoreCase)))
            {
                // Reset the counter used to indicate if the game binaries have updated.
                GlobalSettings.Default.TimesStartedLastGameUpdate = null;
            }

            //string loadWorld = null;

            //foreach (var arg in args)
            //{
            //    if (arg.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 && !File.Exists(arg))
            //        continue;

            //    string file = Path.GetFileName(arg);
            //    if (file.Equals("Sandbox.sbc", StringComparison.InvariantCultureIgnoreCase)
            //        || file.Equals("SANDBOX_0_0_0_.sbs", StringComparison.InvariantCultureIgnoreCase))
            //        loadWorld = Path.GetDirectoryName(arg);
            //}

            // Force pre-loading of any Space Engineers resources.
            SpaceEngineersCore.LoadDefinitions();

            // Load the Space Engineers assemblies, or dependant classes after this point.
            var explorerModel = new ExplorerModel();

            if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR"))
            {
                ResourceReportModel.GenerateOfflineReport(explorerModel, args);
                Application.Current.Shutdown();
                return(false);
            }

            var eViewModel = new ExplorerViewModel(explorerModel);
            var eWindow    = new WindowExplorer(eViewModel);

            //if (allowClose)
            //{
            eViewModel.CloseRequested += (sender, e) =>
            {
                SaveSettings(eWindow);
                Application.Current.Shutdown();
            };
            //}
            eWindow.Loaded += (sender, e) =>
            {
                Splasher.CloseSplash();

                double left   = GlobalSettings.Default.WindowLeft ?? eWindow.Left;
                double top    = GlobalSettings.Default.WindowTop ?? eWindow.Top;
                double width  = GlobalSettings.Default.WindowWidth ?? eWindow.Width;
                double height = GlobalSettings.Default.WindowHeight ?? eWindow.Height;

                System.Drawing.Rectangle windowRect = new System.Drawing.Rectangle((int)left, (int)top, (int)width, (int)height);
                bool isInsideDesktop = false;

                foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens)
                {
                    try
                    {
                        isInsideDesktop |= screen.Bounds.IntersectsWith(windowRect);
                    }
                    catch
                    {
                        // some virtual screens have been know to cause issues.
                    }
                }
                if (isInsideDesktop)
                {
                    eWindow.Left   = left;
                    eWindow.Top    = top;
                    eWindow.Width  = width;
                    eWindow.Height = height;
                    if (GlobalSettings.Default.WindowState.HasValue)
                    {
                        eWindow.WindowState = GlobalSettings.Default.WindowState.Value;
                    }
                }
            };

            if (!GlobalSettings.Default.TimesStartedTotal.HasValue)
            {
                GlobalSettings.Default.TimesStartedTotal = 0;
            }
            GlobalSettings.Default.TimesStartedTotal++;
            if (!GlobalSettings.Default.TimesStartedLastReset.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastReset = 0;
            }
            GlobalSettings.Default.TimesStartedLastReset++;
            if (!GlobalSettings.Default.TimesStartedLastGameUpdate.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastGameUpdate = 0;
            }
            GlobalSettings.Default.TimesStartedLastGameUpdate++;
            GlobalSettings.Default.Save();

            eWindow.ShowDialog();

            return(true);
        }
示例#31
0
        public bool Load(string[] args)
        {
            // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far.
            Version gameVersion = SpaceEngineersConsts.GetSEVersion();
            bool    newVersion  = GlobalSettings.Default.SEVersion != gameVersion;

            GlobalSettings.Default.SEVersion = gameVersion;

            // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with!
            // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly.
            if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true))
            {
                MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                Application.Current.Shutdown();
                return(false);
            }

            // the /B argument indicates the SEToolboxUpdate had started SEToolbox after fetching updated game binaries.
            if (newVersion && args.Any(a => a.Equals("/B", StringComparison.OrdinalIgnoreCase) || a.Equals("-B", StringComparison.OrdinalIgnoreCase)))
            {
                // Reset the counter used to indicate if the game binaries have updated.
                GlobalSettings.Default.TimesStartedLastGameUpdate = null;
            }

            // Force pre-loading of any Space Engineers resources.
            SpaceEngineersCore.LoadDefinitions();

            // Load the Space Engineers assemblies, or dependant classes after this point.
            var explorerModel = new ExplorerModel();

            if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR"))
            {
                ResourceReportModel.GenerateOfflineReport(explorerModel, args);
                Application.Current.Shutdown();
                return(false);
            }

            var eViewModel = new ExplorerViewModel(explorerModel);
            var eWindow    = new WindowExplorer(eViewModel);

            //if (allowClose)
            //{
            eViewModel.CloseRequested += (sender, e) =>
            {
                SaveSettings(eWindow);
                Application.Current.Shutdown();
            };
            //}
            eWindow.Loaded += (sender, e) =>
            {
                Splasher.CloseSplash();
                if (GlobalSettings.Default.WindowLeft.HasValue)
                {
                    eWindow.Left = GlobalSettings.Default.WindowLeft.Value;
                }
                if (GlobalSettings.Default.WindowTop.HasValue)
                {
                    eWindow.Top = GlobalSettings.Default.WindowTop.Value;
                }
                if (GlobalSettings.Default.WindowWidth.HasValue)
                {
                    eWindow.Width = GlobalSettings.Default.WindowWidth.Value;
                }
                if (GlobalSettings.Default.WindowHeight.HasValue)
                {
                    eWindow.Height = GlobalSettings.Default.WindowHeight.Value;
                }
                if (GlobalSettings.Default.WindowState.HasValue)
                {
                    eWindow.WindowState = GlobalSettings.Default.WindowState.Value;
                }
            };

            if (!GlobalSettings.Default.TimesStartedTotal.HasValue)
            {
                GlobalSettings.Default.TimesStartedTotal = 0;
            }
            GlobalSettings.Default.TimesStartedTotal++;
            if (!GlobalSettings.Default.TimesStartedLastReset.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastReset = 0;
            }
            GlobalSettings.Default.TimesStartedLastReset++;
            if (!GlobalSettings.Default.TimesStartedLastGameUpdate.HasValue)
            {
                GlobalSettings.Default.TimesStartedLastGameUpdate = 0;
            }
            GlobalSettings.Default.TimesStartedLastGameUpdate++;
            GlobalSettings.Default.Save();

            eWindow.ShowDialog();

            return(true);
        }
示例#32
0
        private void ExplorerViewControl_OnLoaded(object sender, RoutedEventArgs e)
        {
            var explorerViewModel = new ExplorerViewModel();

            ExplorerViewControl.DataContext = explorerViewModel;
        }