private List <ProjectItemAndType> FindDocumentsContainingTypes(
            LocationDescriptor options,
            Project project,
            Project excludeProject,
            ProjectItem excludeProjectItem,
            List <string> typesToFind)
        {
            var results = new List <ProjectItemAndType>();

            if (typesToFind.Count == 0)
            {
                return(results);
            }

            IEnumerable <ProjectItem> itemsToSearch;

            if (options != null)
            {
                itemsToSearch = LocateProjectItemsWithinFolders(project, options.PathOffProject);
            }
            else
            {
                itemsToSearch = project.ProjectItems.Cast <ProjectItem>();
            }

            FindDocumentsContainingTypesRecursive(excludeProjectItem, excludeProject, itemsToSearch, typesToFind, null, results);

            return(results);
        }
Exemple #2
0
 private void _read()
 {
     _threadId      = m_io.ReadU4le();
     _reserved      = m_io.ReadU4le();
     _exceptionRec  = new ExceptionRecord(m_io, this, m_root);
     _threadContext = new LocationDescriptor(m_io, this, m_root);
 }
Exemple #3
0
        public async void OnGeolocationReady_ShouldSucceed()
        {
            // Arrange
            SetUp();
            var locDescriptor = new LocationDescriptor
            {
                Longitude = 1,
                Latitude  = 2,
                Altitude  = 3
            };

            // Act
            var sit = CreateViewModel();

            sit.NavigationParam = new SnapshotDetailsViewNavParams {
                LocationSnapshot = new LocationSnapshot()
            };
            await sit.OnLoaded();

            _eventAggregator.GetEvent <GeolocationReadyEvent>().Publish(locDescriptor);

            // Assert
            Assert.Equal(locDescriptor.Longitude, sit.SnapshotDetails.Longitude);
            Assert.Equal(locDescriptor.Latitude, sit.SnapshotDetails.Latitude);
            Assert.Equal(locDescriptor.Altitude, sit.SnapshotDetails.Altitude);
            Assert.True(sit.IsGeolocationDataAvailable);
        }
 public MachineRemove(LocationDescriptor location, IntPoint tileLocation, int machineParentSheetIndex, string machineName)
 {
     this.Location                = location;
     this.TileLocation            = tileLocation;
     this.MachineParentSheetIndex = machineParentSheetIndex;
     this.MachineName             = machineName;
 }
Exemple #5
0
    //private Vector3 GetMousePositionInWorld(Transform heldObject) {
    //    //float distance_to_screen = Camera.main.WorldToScreenPoint(heldObject.transform.position).z;
    //    //return Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen));
    //    float distance_to_screen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
    //    Vector3 pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen));
    //    return new Vector3(pos_move.x, transform.position.y, pos_move.z);
    //}
    public void resetPositionCausedByDragging()
    {
        print("MouseDragger.resetPositionCausedByDragging");

        if (agent.location.Equals(preDragLocation)) {
            transform.localPosition = Vector3.zero;
            preDragLocation = null;
        }
    }
        private void OnGeolocationReady(LocationDescriptor locationDescriptor)
        {
            SnapshotDetails.Longitude = locationDescriptor.Longitude;
            SnapshotDetails.Latitude  = locationDescriptor.Latitude;
            SnapshotDetails.Altitude  = locationDescriptor.Altitude;

            RaisePropertyChanged(nameof(IsGeolocationDataAvailable));
            RaisePropertyChanged(nameof(SnapshotDetails));
        }
Exemple #7
0
        public void Init(IList <ProjectOptions> projects, LocationDescriptor descriptor, ProjectOptions settingsProject)
        {
            Projects = projects;

            // If descriptor's ProjectId is null, use settingsProject's.
            ProjectIdentifier = descriptor.ProjectIdentifier ?? settingsProject.ProjectModel.ProjectIdentifier;
            PathOffProject    = descriptor.PathOffProject;
            Namespace         = descriptor.Namespace;
        }
Exemple #8
0
 private void _read()
 {
     _threadId      = m_io.ReadU4le();
     _suspendCount  = m_io.ReadU4le();
     _priorityClass = m_io.ReadU4le();
     _priority      = m_io.ReadU4le();
     _teb           = m_io.ReadU8le();
     _stack         = new MemoryDescriptor(m_io, this, m_root);
     _threadContext = new LocationDescriptor(m_io, this, m_root);
 }
        public List <ProjectItemAndType> GetRelatedDocuments(
            LocationDescriptor viewModelsLocation,
            LocationDescriptor viewsLocation,
            ProjectItem pi,
            IEnumerable <string> typeNamesInFile,
            string[] viewPrefixes,
            string[] viewSuffixes,
            string viewModelSuffix)
        {
            GetTypeCandidates(typeNamesInFile, viewPrefixes, viewSuffixes, viewModelSuffix,
                              out var viewCandidateTypeNames,
                              out var viewModelCandidateTypeNames);

            List <ProjectItemAndType> rval;

            if (viewModelsLocation == null)
            {
                // Search whole solution.
                var allCandidateTypes = viewModelCandidateTypeNames.Union(viewCandidateTypeNames).Distinct().ToList();

                // Look for the candidate types in current project first, excluding the selected project item.
                rval = FindDocumentsContainingTypes(null, pi.ContainingProject, null, pi, allCandidateTypes);

                // Then add candidates from the rest of the solution.
                var solution = pi.DTE?.Solution;
                if (solution == null)
                {
                    return(rval);
                }
                foreach (Project project in solution.Projects)
                {
                    if (project == pi.ContainingProject)
                    {
                        continue;
                    }

                    var docs = FindDocumentsContainingTypes(null, project, pi.ContainingProject, pi, allCandidateTypes);
                    rval.AddRange(docs);
                }
                return(rval);
            }

            var viewModelsProject = GetProject(viewModelsLocation.ProjectIdentifier);
            var viewsProject      = GetProject(viewsLocation.ProjectIdentifier);

            // Search views project first.
            rval = FindDocumentsContainingTypes(viewsLocation, viewsProject, null, pi, viewCandidateTypeNames);
            // Then, search view models project, excluding any xaml files.
            var vmDocs = FindDocumentsContainingTypes(viewModelsLocation, viewModelsProject, null, pi, viewModelCandidateTypeNames);

            rval.AddRange(vmDocs.Where(d => d.ProjectItem.Name.IndexOf(".xaml.", StringComparison.OrdinalIgnoreCase) == -1));

            return(rval);
        }
Exemple #10
0
    public static LocationDescriptorData fromComponent(LocationDescriptor descriptor)
    {
        if (descriptor == null) {
            return null;
        }

        LocationDescriptorData descriptorData = new LocationDescriptorData();
        descriptorData.countryDescriptorData = fromComponent(descriptor.country.descriptor);
        descriptorData.provinceDescriptorData = fromComponent(descriptor.province.descriptor);
        //descriptorData.cityDescriptorData = fromComponent(descriptor.city.descriptor);
        return descriptorData;
    }
        public async Task <LocationDescriptor> GetCurrentLocationAsync()
        {
            var retryCount   = 0;
            var result       = new LocationDescriptor();
            var accessStatus = GeolocationAccessStatus.Unspecified;

            while (accessStatus != GeolocationAccessStatus.Allowed)
            {
                accessStatus = await Geolocator.RequestAccessAsync();

                retryCount++;
                if (retryCount >= MaxRetryCount)
                {
                    break;
                }
                await Task.Delay(RetryIntervalInMiliseconds);
            }

            switch (accessStatus)
            {
            case GeolocationAccessStatus.Allowed:
                var geolocator = new Geolocator {
                    DesiredAccuracy = PositionAccuracy.High
                };
                var position = await geolocator.GetGeopositionAsync();

                var basicGeoposition = position.Coordinate.Point.Position;
                result = new LocationDescriptor
                {
                    Longitude = basicGeoposition.Longitude,
                    Latitude  = basicGeoposition.Latitude,
                    Altitude  = basicGeoposition.Altitude
                };
                break;

            case GeolocationAccessStatus.Denied:
                _loggingService.Warning("Access to location is denied.");
                await _dialogService.ShowAsync("Access to location is denied.");

                break;

            case GeolocationAccessStatus.Unspecified:
                _loggingService.Warning("Unspecified error occurred while accessing location.");
                await _dialogService.ShowAsync("Unspecified error occurred while accessing location.");

                break;
            }

            return(result);
        }
 public BinaryResourceDescriptor(string name,
                                 eBinaryResourceContentType contentType,
                                 eBinaryResourceLocationType locationType,
                                 ContentDescriptor contentDescriptor,
                                 LocationDescriptor locationDescriptor,
                                 int size           = 0,
                                 string description = "")
 {
     this.FriendlyName        = name;
     this.FriendlyDescription = description;
     this.Size                   = size;
     this.ContentType            = contentType;
     this.LocationType           = locationType;
     this.ContentDescriptorJson  = contentDescriptor.ToJSON();
     this.LocationDescriptorJson = locationDescriptor.ToJSON();
 }
Exemple #13
0
        public bool InheritsFully(LocationDescriptor inherited)
        {
            if (PathOffProject != inherited.PathOffProject)
            {
                return(false);
            }
            if (Namespace != inherited.Namespace)
            {
                return(false);
            }
            if (ProjectIdentifier != inherited.ProjectIdentifier)
            {
                return(false);
            }

            return(true);
        }
Exemple #14
0
 internal void ApplyInherited(LocationDescriptor inherited)
 {
     PathOffProject    = inherited.PathOffProject;
     Namespace         = inherited.Namespace;
     ProjectIdentifier = inherited.ProjectIdentifier;
 }
        public async void OnCaptureSnapshot_ShouldSucceed()
        {
            // Arrange
            SetUp();
            var navParam = new SnapshotsViewNavParams
            {
                SnapshotsIdsource = new Location {
                    Id = 2
                }
            };
            var locDescriptor = new LocationDescriptor
            {
                Longitude = 1,
                Latitude  = 2,
                Altitude  = 3
            };
            LocationSnapshot   newSnapshot     = null;
            LocationDescriptor receivedLocDesc = null;

            _locationSnapshotDataService.AddSnapshotAsync(Arg.Any <LocationSnapshot>())
            .Returns(_ =>
            {
                var snapshot = _.Arg <LocationSnapshot>();
                var tcs      = new TaskCompletionSource <LocationSnapshot>();
                tcs.SetResult(snapshot);
                return(tcs.Task);
            });
            _pictureService.SaveSnapshotContentAsync(Arg.Any <LocationSnapshot>(), Arg.Any <byte[]>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <int>();
                tcs.SetResult(0);
                return(tcs.Task);
            });
            _locationService.GetCurrentLocationAsync()
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <LocationDescriptor>();
                tcs.SetResult(locDescriptor);
                return(tcs.Task);
            });
            _locationSnapshotDataService.GetSnapshotsByIdsAsync(Arg.Any <IEnumerable <int> >())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
                tcs.SetResult(new List <LocationSnapshot> {
                    new LocationSnapshot()
                });
                return(tcs.Task);
            });
            _locationSnapshotDataService.AddSnapshotAsync(Arg.Any <LocationSnapshot>())
            .Returns(_ =>
            {
                newSnapshot = _.Arg <LocationSnapshot>();
                var tcs     = new TaskCompletionSource <LocationSnapshot>();
                tcs.SetResult(newSnapshot);
                return(tcs.Task);
            });
            _eventAggregator.GetEvent <GeolocationReadyEvent>().Subscribe(_ => receivedLocDesc = _);

            // Act
            var sit = CreateViewModel();

            sit.NavigationParam = navParam;
            await sit.OnCaptureSnapshot();

            // Assert
            Assert.Equal(((Location)navParam.SnapshotsIdsource).Id, newSnapshot.LocationId);
            Assert.True(newSnapshot.PictureFileName.StartsWith("LocationCapture_") &&
                        newSnapshot.PictureFileName.EndsWith(".jpg"));
            Assert.Equal(locDescriptor.Longitude, newSnapshot.Longitude);
            Assert.Equal(locDescriptor.Latitude, newSnapshot.Latitude);
            Assert.Equal(locDescriptor.Altitude, newSnapshot.Altitude);
            Assert.Equal(newSnapshot.PictureFileName.Substring(16, 17), newSnapshot.DateCreated.ToString("yyyyMMdd_HH_mm_ss"));
            Assert.Equal(locDescriptor, receivedLocDesc);
        }
        protected override async void OnExecute()
        {
            try
            {
                base.OnExecute();

                var pi = Package.ActiveDocument?.ProjectItem;

                if (pi != null)
                {
                    var classesInFile = SolutionService.GetClassesInProjectItem(pi);

                    if (classesInFile.Count == 0)
                    {
                        MessageBox.Show("No classes found in file.", "MVVM Tools");
                        return;
                    }

                    var settings = await SettingsService.LoadSettings();

                    // Solution not fully loaded so settings not loaded either.
                    if (settings?.SolutionOptions == null)
                    {
                        return;
                    }

                    List <ProjectItemAndType> docs;

                    if (!settings.GoToViewOrViewModelSearchSolution)
                    {
                        // ProjectModel from which to derive initial settings.
                        var settingsPm =
                            settings.ProjectOptions.FirstOrDefault(
                                p => p.ProjectModel.ProjectIdentifier == pi.ContainingProject.UniqueName);

                        // This shouldn't be null unless the user adds a new project and then
                        // quickly invokes this command, but better to check it.
                        if (settingsPm == null)
                        {
                            settingsPm = settings.SolutionOptions;
                        }

                        var viewModelLocationOptions = new LocationDescriptor
                        {
                            Namespace         = settingsPm.ViewModelLocation.Namespace,
                            PathOffProject    = settingsPm.ViewModelLocation.PathOffProject,
                            ProjectIdentifier = settingsPm.ViewModelLocation.ProjectIdentifier ?? pi.ContainingProject.UniqueName
                        };

                        var viewLocationOptions = new LocationDescriptor()
                        {
                            Namespace         = settingsPm.ViewLocation.Namespace,
                            PathOffProject    = settingsPm.ViewLocation.PathOffProject,
                            ProjectIdentifier = settingsPm.ViewLocation.ProjectIdentifier ?? pi.ContainingProject.UniqueName
                        };

                        docs = SolutionService.GetRelatedDocuments(
                            viewModelLocationOptions,
                            viewLocationOptions,
                            pi,
                            classesInFile.Select(c => c.Class),
                            new[] { "uc" },
                            settings.ViewSuffixes,
                            settingsPm.ViewModelSuffix);
                    }
                    else
                    {
                        // Passing the first two parameters as null tells GetRelatedDocuments() to
                        // search the entire solution.
                        docs = SolutionService.GetRelatedDocuments(
                            null,
                            null,
                            pi,
                            classesInFile.Select(c => c.Class),
                            new[] { "uc" },
                            settings.ViewSuffixes,
                            settings.SolutionOptions.ViewModelSuffix);
                    }

                    if (docs.Count == 0)
                    {
                        string classes = "\n        ";
                        foreach (var c in classesInFile)
                        {
                            classes += c.Class + "\n        ";
                        }

                        MessageBox.Show(
                            $"Couldn't find any matching views or view models.\n\nClasses in this file:\n\n{classes}", "MVVM Tools");

                        return;
                    }

                    if (docs.Count == 1 || settings.GoToViewOrViewModelOption == GoToViewOrViewModelOption.ChooseFirst)
                    {
                        var win = docs[0].ProjectItem.Open();
                        win.Visible = true;
                        win.Activate();

                        return;
                    }

                    // Multiple results.
                    if (settings.GoToViewOrViewModelOption == GoToViewOrViewModelOption.ShowUi)
                    {
                        PresentViewViewModelOptions(docs);
                        return;
                    }

                    // If there are more than one .xaml files or there are more than one code
                    // behind files, then we must show the UI.
                    var countXaml = docs.Count(d => d.ProjectItem.Name.EndsWith(".xaml", StringComparison.OrdinalIgnoreCase));
                    if (countXaml > 1)
                    {
                        PresentViewViewModelOptions(docs);
                        return;
                    }
                    var countCodeBehind = docs.Count(d => d.ProjectItem.Name.EndsWith(".xaml.cs", StringComparison.OrdinalIgnoreCase) ||
                                                     d.ProjectItem.Name.EndsWith(".xaml.vb", StringComparison.OrdinalIgnoreCase));
                    if (countCodeBehind > 1)
                    {
                        PresentViewViewModelOptions(docs);
                        return;
                    }

                    // If the count of files is > 2 now, then we must show UI.
                    var count = docs.Count;
                    if (count > 2)
                    {
                        PresentViewViewModelOptions(docs);
                        return;
                    }

                    // If the remaining two files are xaml and code behind, we can apply the
                    // 'prefer xaml' or 'prefer code behind' setting.
                    if (string.Compare(docs[0].ProjectItem.Name, docs[1].ProjectItem.Name + ".cs", StringComparison.OrdinalIgnoreCase) == 0 ||
                        string.Compare(docs[0].ProjectItem.Name, docs[1].ProjectItem.Name + ".vb", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        // First file is code behind, second is XAML.
                        if (settings.GoToViewOrViewModelOption == GoToViewOrViewModelOption.ChooseCodeBehind)
                        {
                            //await (new JoinableTaskFactory(null)).SwitchToMainThreadAsync();
                            var win = docs[0].ProjectItem.Open();
                            win.Visible = true;
                            win.Activate();
                        }
                        else
                        {
                            var win = docs[1].ProjectItem.Open();
                            win.Visible = true;
                            win.Activate();
                        }
                    }
                    else if (string.Compare(docs[1].ProjectItem.Name, docs[0].ProjectItem.Name + ".cs", StringComparison.OrdinalIgnoreCase) == 0 ||
                             string.Compare(docs[1].ProjectItem.Name, docs[0].ProjectItem.Name + ".vb", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        // First file is XAML, second is code behind.
                        if (settings.GoToViewOrViewModelOption == GoToViewOrViewModelOption.ChooseXaml)
                        {
                            var win = docs[0].ProjectItem.Open();
                            win.Visible = true;
                            win.Activate();
                        }
                        else
                        {
                            var win = docs[1].ProjectItem.Open();
                            win.Visible = true;
                            win.Activate();
                        }
                    }
                    else
                    {
                        // The two files are unrelated, must show UI.
                        PresentViewViewModelOptions(docs);
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                //throw;
            }
        }
Exemple #17
0
    private void DragAgentBegin()
    {
        print("DRAG BEGIN");
        clearAndSetupDraggingContext();
        draggingContext.isDragInProgress = true;

        MapSelector.Instance.selectAgent(agent, MapSelector.ALLOW_RESELECT_TRUE);

        preDragLocation = agent.location;
    }
Exemple #18
0
    public static void toComponent(LocationDescriptorData locationData, LocationDescriptor location)
    {
        //TODO for all this, use factories
        if (locationData.countryDescriptorData != null) {
            location.country = DynamicObjectRegistry.COUNTRIES[locationData.countryDescriptorData.countryName];//TODO use getter
        }

        if (locationData.provinceDescriptorData != null) {
            location.province = DynamicObjectRegistry.PROVINCES[locationData.provinceDescriptorData.provinceName];
        }

        if (locationData.cityDescriptorData != null) {
            //location.country = DynamicObjectRegistry.CITIES[locationData.cityDescriptorData.name];
        }
    }
 public BinaryResourceDescriptor(string name,
                                 eBinaryResourceContentType contentType,
                                 eBinaryResourceLocationType locationType,
                                 ContentDescriptor contentDescriptor,
                                 LocationDescriptor locationDescriptor,
                                 int size = 0,
                                 string description = "")
 {
     this.FriendlyName = name;
     this.FriendlyDescription = description;
     this.Size = size;
     this.ContentType = contentType;
     this.LocationType = locationType;
     this.ContentDescriptorJson = contentDescriptor.ToJSON();
     this.LocationDescriptorJson = locationDescriptor.ToJSON();
 }
 public void SetFromDescriptor(LocationDescriptor descriptor)
 {
     _projectIdentifier = descriptor.ProjectIdentifier;
     _pathOffProject    = descriptor.PathOffProject;
     _namespace         = descriptor.Namespace;
 }
Exemple #21
0
 private void _read()
 {
     _addrMemoryRange = m_io.ReadU8le();
     _memory          = new LocationDescriptor(m_io, this, m_root);
 }
 internal static PropGraphNodeDescriptor Demarshal(LocationDescriptor locationDescriptor)
 {
     throw new NotImplementedException();
 }