示例#1
0
        /// <summary>
        /// Adds another file (child) item below the parent item.
        /// This will throw an Exception if parent is null.
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="parent"></param>
        /// <param name="itemType"></param>
        /// <returns></returns>
        public ISolutionBaseItem AddChild(
            string itemName,
            SolutionItemType itemType,
            ISolutionBaseItem parent)
        {
            var internalItem = parent as ISolutionItem;

            if (internalItem == null)
            {
                throw new System.ArgumentException("Paremeter parent cannot have children.");
            }

            switch (itemType)
            {
            case SolutionItemType.SolutionRootItem:
                return(AddSolutionRootItem(itemName));

            case SolutionItemType.File:
                return(internalItem.AddFile(itemName));

            case SolutionItemType.Folder:
                return(internalItem.AddFolder(itemName));

            case SolutionItemType.Project:
                return(internalItem.AddProject(itemName));

            default:
                throw new ArgumentOutOfRangeException(itemType.ToString());
            }
        }
示例#2
0
 public void ResetTicTacToe()
 {
     ynWon                   = false;
     goSolutionWin           = null;
     solutionItemTypeCurrent = SolutionItemType.empty;
     g.goAsset               = null;
 }
示例#3
0
        public SolutionItem(Connect connect, Solution solution, bool recursive)
        {
            this._subItems    = new List <SolutionItem>();
            this._projectType = LanguageType.None;

            if (connect == null)
            {
                throw new ArgumentNullException("connect");
            }

            if (solution == null)
            {
                throw new ArgumentNullException("solution");
            }

            this._incrementSetting = new SolutionItemIncrementSettings(this);
            this._connect          = connect;
            this._item             = solution;
            this._itemType         = SolutionItemType.Solution;
            this._name             = Path.GetFileNameWithoutExtension(solution.FileName);
            this._filename         = solution.FileName;
            this._uniqueName       = this._name;
            this.GetGlobalVariables();
            if (recursive)
            {
                SolutionItem.FillSolutionTree(connect, this, solution.Projects);
            }
        }
示例#4
0
    void ScoreSolution(Transform tSolution)
    {
        List <GameObject> listX     = GetSolutionItemsOfType(tSolution, SolutionItemType.X);
        List <GameObject> listO     = GetSolutionItemsOfType(tSolution, SolutionItemType.O);
        List <GameObject> listEmpty = GetSolutionItemsOfType(tSolution, SolutionItemType.empty);

        tSolution.name = "Solution cntX " + listX.Count + " cntO " + listO.Count;
        if (listX.Count == 3)
        {
            solutionItemTypeWin = SolutionItemType.X;
            goSolutionWin       = tSolution.gameObject;
            HighlightSolutionSpots(tSolution, colorWin);
            return;
        }
        if (listO.Count == 3)
        {
            solutionItemTypeWin = SolutionItemType.O;
            goSolutionWin       = tSolution.gameObject;
            HighlightSolutionSpots(tSolution, colorWin);
            return;
        }
        if (listX.Count == 2 && listEmpty.Count == 1)
        {
            HighlightGoChildrenOfList(listX, colorX);
            HighlightGoChildrenOfList(listEmpty, colorAlmost);
        }
        if (listO.Count == 2 && listEmpty.Count == 1)
        {
            HighlightGoChildrenOfList(listO, colorO);
            HighlightGoChildrenOfList(listEmpty, colorAlmost);
        }
    }
        public SolutionItem(Connect connect, Solution solution, bool recursive)
        {
            this._subItems = new List<SolutionItem>();
            this._projectType = LanguageType.None;

            if (connect == null)
            {
                throw new ArgumentNullException("connect");
            }

            if (solution == null)
            {
                throw new ArgumentNullException("solution");
            }

            this._incrementSetting = new SolutionItemIncrementSettings(this);
            this._connect = connect;
            this._item = solution;
            this._itemType = SolutionItemType.Solution;
            this._name = Path.GetFileNameWithoutExtension(solution.FileName);
            this._filename = solution.FileName;
            this._uniqueName = this._name;
            this.GetGlobalVariables();
            if (recursive)
            {
                SolutionItem.FillSolutionTree(connect, this, solution.Projects);
            }
        }
示例#6
0
    void UpdateIndicatorsTicTacToe(SolutionItemType solutionItemType)
    {
        Color colorOn          = (Color.blue * 1.5f + Color.clear) / 2;
        Color colorOff         = (Color.white * 1.5f + Color.clear) / 2;
        int   numCompletedProg = g.numCompletedProgressX;

        if (solutionItemType == SolutionItemType.O)
        {
            numCompletedProg = g.numCompletedProgressO;
            colorOn          = (Color.red * 1.5f + Color.clear) / 2;
        }
        foreach (GameObject goList in g.goProgressLists)
        {
            if (g.progressMgr.GetProgressListType(goList) == solutionItemType)
            {
                for (int n = 0; n < goList.transform.childCount; n++)
                {
                    GameObject go = goList.transform.GetChild(n).gameObject;
                    if (n < numCompletedProg)
                    {
                        go.GetComponentInChildren <Renderer>().material.color = colorOn;
                    }
                    else
                    {
                        go.GetComponentInChildren <Renderer>().material.color = colorOff;
                    }
                }
            }
        }
    }
示例#7
0
        /// <summary>
        /// This will generate a sort key fit for sorting
        /// (not for unique identification of an item)
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public string GenSortKey(IItem item)
        {
            string           key      = item.DisplayName;
            SolutionItemType itemType = item.ItemType;

            // Compute a prefix to establish a group, sort order to diplay items in:
            // Projects (group sorted within alpabetically)
            // Folders  (group sorted within alpabetically)
            // Files    (group sorted within alpabetically)
            string prefix = "";

            switch (itemType)
            {
            case SolutionItemType.SolutionRootItem:
            default:
                prefix = "000_";
                break;

            case SolutionItemType.Folder:
                prefix = "222_";
                break;

            case SolutionItemType.Project:
                prefix = "444_";
                break;

            case SolutionItemType.File:
                prefix = "666_";
                break;
            }

            return(prefix + key);
        }
        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="itemType"></param>
        /// <param name="addDummyChild"></param>
        protected ItemChildrenViewModel(IItem parent
                                        , SolutionItemType itemType
                                        , bool addDummyChild = true)
            : base(parent, itemType)
        {
            _Children = new SortableObservableDictionaryCollection();
            BindingOperations.EnableCollectionSynchronization(_Children, _itemsLock);

            ResetChildren(addDummyChild); // Lets lazy Load child items
        }
示例#9
0
 public void SwitchSolutionItemTypeCurrent()
 {
     if (solutionItemTypeCurrent == SolutionItemType.X)
     {
         solutionItemTypeCurrent = SolutionItemType.O;
     }
     else
     {
         solutionItemTypeCurrent = SolutionItemType.X;
     }
 }
示例#10
0
        /// <summary>
        /// Adds another child item below the root item in the collection.
        /// This will throw an Exception if parent is null.
        /// </summary>
        /// <param name="itemName"></param>
        /// <param name="itemType"></param>
        /// <returns></returns>
        public ISolutionBaseItem AddRootChild(
            string itemName,
            SolutionItemType itemType)
        {
            if (_SolutionRootItem == null)
            {
                throw new System.Exception("Solution Root Item must be created BEFORE adding children!");
            }

            return(AddChild(itemName, itemType, _SolutionRootItem));
        }
        /// <summary>
        /// Creates a new instance of the solution item.
        /// </summary>
        protected SolutionItem(IVsHierarchyItem item, SolutionItemType type)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            _item = item;

            _hierarchy = item.HierarchyIdentity.IsNestedItem ? item.HierarchyIdentity.NestedHierarchy : item.HierarchyIdentity.Hierarchy;
            _itemId    = item.HierarchyIdentity.IsNestedItem ? item.HierarchyIdentity.NestedItemID : item.HierarchyIdentity.ItemID;

            Name     = item.Text;
            Type     = type;
            FullPath = GetFullPath();
        }
示例#12
0
    List <GameObject> GetSolutionItemsOfType(Transform tSolution, SolutionItemType solutionItemType)
    {
        List <GameObject> matches = new List <GameObject>();

        foreach (Transform t in tSolution)
        {
            if (GetGoSolutionItemType(t.gameObject) == solutionItemType)
            {
                matches.Add(t.gameObject);
            }
        }
        return(matches);
    }
示例#13
0
 void ScoreSolutions()
 {
     goSolutionWin       = null;
     solutionItemTypeWin = SolutionItemType.empty;
     foreach (Transform tSolution in goSolutions.transform)
     {
         ScoreSolution(tSolution);
         if (goSolutionWin != null)
         {
             break;
         }
     }
 }
示例#14
0
    public SolutionItemType GetProgressListType(GameObject go)
    {
        SolutionItemType solutionItemType = SolutionItemType.empty;

        if (go.name == "ProgressListX")
        {
            solutionItemType = SolutionItemType.X;
        }
        if (go.name == "ProgressListO")
        {
            solutionItemType = SolutionItemType.O;
        }
        return(solutionItemType);
    }
示例#15
0
 void MatchAssetsWithSpots()
 {
     foreach (Transform t in goSpots.transform)
     {
         SolutionItemType solutionItemType = SolutionItemType.empty;
         GameObject       go = GetPieceNearGo(t.gameObject);
         if (go != null)
         {
             solutionItemType = GetAssetSolutionItemType(go);
         }
         AdjustGoSolutionItemType(t.gameObject, solutionItemType);
         Color color = GetColorForSolutionItemType(solutionItemType);
         HighlightGoChildren(t.gameObject, color);
     }
 }
        /// <summary>
        /// Adding a new next child item via In-place Edit Box requires that
        /// we know whether 'New Folder','New Folder 1', 'New Folder 2' ...
        /// is the next appropriate name - this method determines that name
        /// and returns it for a given type of a (to be created) child item.
        /// </summary>
        /// <param name="nextTypeTpAdd"></param>
        /// <returns></returns>
        public string SuggestNextChildName(SolutionItemType nextTypeTpAdd)
        {
            string suggestMask = null;

            switch (nextTypeTpAdd)
            {
            case SolutionItemType.SolutionRootItem:
                suggestMask = "New Solution";
                break;

            case SolutionItemType.File:
                suggestMask = "New File";
                break;

            case SolutionItemType.Folder:
                suggestMask = "New Folder";
                break;

            case SolutionItemType.Project:
                suggestMask = "New Project";
                break;

            default:
                throw new ArgumentOutOfRangeException(nextTypeTpAdd.ToString());
            }

            var nextChild = _Children.TryGet(suggestMask);

            if (nextChild == null)
            {
                return(suggestMask);
            }

            string suggestChild = null;

            for (int i = 1; i < _Children.Count + 100; i++)
            {
                suggestChild = string.Format("{0} {1}", suggestMask, i);

                nextChild = _Children.TryGet(suggestChild);
                if (nextChild == null)
                {
                    break;
                }
            }

            return(suggestChild);
        }
        /// <summary>
        /// Finds the nearest parent matching the specified type.
        /// </summary>
        public SolutionItem?FindParent(SolutionItemType type)
        {
            SolutionItem?parent = Parent;

            while (parent != null)
            {
                if (parent.Type == type)
                {
                    return(parent);
                }

                parent = parent.Parent;
            }

            return(null);
        }
示例#18
0
 Color GetColorForSolutionItemType(SolutionItemType solutionItemType)
 {
     if (solutionItemType == SolutionItemType.X)
     {
         return(colorX);
     }
     if (solutionItemType == SolutionItemType.O)
     {
         return(colorO);
     }
     if (solutionItemType == SolutionItemType.empty)
     {
         return(colorEmpty);
     }
     return(Color.magenta);
 }
        /// <summary>
        /// Creates a new instance based on a hierarchy item.
        /// </summary>
        public static SolutionItem?FromHierarchyItem(IVsHierarchyItem?item)
        {
            if (item == null)
            {
                return(null);
            }

            SolutionItemType type = GetSolutionItemType(item.HierarchyIdentity);

            return(type switch
            {
                SolutionItemType.Solution => new Solution(item, type),
                SolutionItemType.Project => new Project(item, type),
                SolutionItemType.PhysicalFile => new File(item, type),
                SolutionItemType.PhysicalFolder => new Folder(item, type),
                SolutionItemType.SolutionFolder => new SolutionFolder(item, type),
                _ => new SolutionItem(item, type)
            });
示例#20
0
 // Update is called once per frame
 void Update()
 {
     if (g.mode == ModeType.place)
     {
         return;
     }
     if (g.gameType != GameType.TicTacToe)
     {
         return;
     }
     UpdateGoAssetNearPointer();
     UpdateScore();
     UpdateWin();
     UpdateSolutionItemTypeCurrent();
     UpdateTicTacToeNumCompletedProgress();
     UpdateProgressTicTacToe();
     UpdateAuto();
     solutionItemTypeCurrentLast = solutionItemTypeCurrent;
     goAssetNearPointerLast      = goAssetNearPointer;
 }
示例#21
0
 void UpdateTicTacToeNumCompletedProgress()
 {
     g.numCompletedProgressX = 0;
     g.numCompletedProgressO = 0;
     foreach (Transform t in goSpots.transform)
     {
         SolutionItemType solutionItemType = SolutionItemType.empty;
         GameObject       go = GetPieceNearGo(t.gameObject);
         if (go != null)
         {
             solutionItemType = GetAssetSolutionItemType(go);
             if (solutionItemType == SolutionItemType.X)
             {
                 g.numCompletedProgressX++;
             }
             else
             {
                 g.numCompletedProgressO++;
             }
         }
     }
 }
示例#22
0
        private SolutionItem(Connect connect, Project project, bool recursive)
        {
            this._subItems    = new List <SolutionItem>();
            this._projectType = LanguageType.None;

            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (connect == null)
            {
                throw new ArgumentNullException("connect");
            }

            this._incrementSetting = new SolutionItemIncrementSettings(this);
            this._connect          = connect;
            this._item             = project;
            this._name             = project.Name;
            this._filename         = project.FileName;
            this._uniqueName       = project.UniqueName;
            if (!string.IsNullOrEmpty(this._filename) && string.IsNullOrEmpty(Path.GetExtension(this._filename)))
            {
                this._filename += Path.GetExtension(project.UniqueName);
            }
            if (string.IsNullOrEmpty(project.FullName))
            {
                this._itemType = SolutionItemType.Folder;
                if (recursive)
                {
                    SolutionItem.FillSolutionTree(connect, this, project.ProjectItems);
                }
            }
            else
            {
                this._itemType = SolutionItemType.Project;
                this.GetGlobalVariables();
            }
        }
示例#23
0
 void UpdateSolutionItemTypeCurrent()
 {
     if (goAssetNearPointerLast != goAssetNearPointer)
     {
         if (goAssetNearPointer != null)
         {
             solutionItemTypeCurrent = GetAssetSolutionItemType(goAssetNearPointer);
             cntSpotsFilled          = GetCountSpotsFilled();
         }
         else
         {
             int cntNow = GetCountSpotsFilled();
             if (cntNow == cntSpotsFilled + 1)
             {
                 SwitchSolutionItemTypeCurrent();
             }
         }
     }
     if (solutionItemTypeCurrentLast != solutionItemTypeCurrent)
     {
         if (solutionItemTypeCurrent == SolutionItemType.empty)
         {
             goPadX.GetComponent <Renderer>().material.color = Color.white;
             goPadO.GetComponent <Renderer>().material.color = Color.white;
         }
         if (solutionItemTypeCurrent == SolutionItemType.X)
         {
             goPadX.GetComponent <Renderer>().material.color = Color.green;
             goPadO.GetComponent <Renderer>().material.color = Color.white;
         }
         if (solutionItemTypeCurrent == SolutionItemType.O)
         {
             goPadX.GetComponent <Renderer>().material.color = Color.white;
             goPadO.GetComponent <Renderer>().material.color = Color.green;
         }
     }
 }
        /// <summary>
        /// Adds a child item with the given type
        /// (<see cref="SolutionItemType.SolutionRootItem"/> cannot be added here).
        /// </summary>
        /// <param name="displayName"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public IItem AddChild(string displayName, SolutionItemType type)
        {
            if (HasDummyChild == true)
            {
                ResetChildren(false);
            }

            switch (type)
            {
            case SolutionItemType.File:
                return(AddChild(displayName, new FileViewModel(this, displayName)));

            case SolutionItemType.Folder:
                return(AddChild(displayName, new FolderViewModel(this, displayName, false)));

            case SolutionItemType.Project:
                return(AddChild(displayName, new ProjectViewModel(this, displayName, false)));

            default:
            case SolutionItemType.SolutionRootItem:
                // this is only constructed in the SolutionViewModel
                throw new System.ArgumentOutOfRangeException(type.ToString());
            }
        }
示例#25
0
        /// <summary>
        /// Get a DynamicResource from ResourceDictionary or a static ImageSource (as fallback) for not expanded folder item.
        /// </summary>
        /// <param name="itemType"></param>
        /// <param name="isItemExpanded"></param>
        /// <returns></returns>
        private object GetImage(SolutionItemType itemType, bool isItemExpanded)
        {
            string uriPath = null;

            switch (itemType)
            {
            case Models.SolutionItemType.SolutionRootItem:
                uriPath = "SolutionIcon";
                break;

            case Models.SolutionItemType.File:
                uriPath = "FileIcon";
                break;

            case Models.SolutionItemType.Folder:
                if (isItemExpanded == true)
                {
                    uriPath = "FolderIconOpen";
                }
                else
                {
                    uriPath = "FolderIcon";
                }
                break;

            case Models.SolutionItemType.Project:
                uriPath = "ProjectIcon";
                break;

            default:
                throw new ArgumentOutOfRangeException(itemType.ToString());
            }

            object item = null;

            // Find Icon source in ResouceDictionary and return it
            if (uriPath != null)
            {
                item = Application.Current.Resources[uriPath];

                if (item != null)
                {
                    return(item);
                }
            }

            // item was not available in resourcedictionary, so as a fallback
            // we try a static reference since that should be better than returning null
            string pathValue = null;

            switch (itemType)
            {
            case Models.SolutionItemType.SolutionRootItem:
                pathValue = "pack://application:,,,/SolutionLib;component/Resources/Solutions/Light/AppFlyout_16x.png";
                break;

            case Models.SolutionItemType.File:
                uriPath = "pack://application:,,,/SolutionLib;component/Resources/Files/Light/Document_16x.png";
                break;

            case Models.SolutionItemType.Folder:
                if (isItemExpanded == true)
                {
                    uriPath = "pack://application:,,,/SolutionLib;component/Resources/Folders/Light/FolderOpen_32x.png";
                }
                else
                {
                    uriPath = "pack://application:,,,/SolutionLib;component/Resources/Folders/Light/Folder_32x.png";
                }
                break;

            case Models.SolutionItemType.Project:
                uriPath = "pack://application:,,,/SolutionLib;component/Resources/Projects/Light/Application_16x.png";
                break;

            default:
                throw new ArgumentOutOfRangeException(itemType.ToString());
            }

            if (pathValue != null)
            {
                try
                {
                    Uri         imagePath = new Uri(pathValue, UriKind.RelativeOrAbsolute);
                    ImageSource source    = new System.Windows.Media.Imaging.BitmapImage(imagePath);

                    return(source);
                }
                catch
                {
                }
            }

            // Attempt to load fallback folder from ResourceDictionary
            item = Application.Current.Resources["FolderIcon"];

            if (item != null)
            {
                return(item);
            }
            else
            {
                // Attempt to load fallback folder from fixed Uri
                pathValue = "pack://application:,,,/SolutionLib;component/Resources/Folders/Light/Folder_32x.png";

                try
                {
                    Uri         imagePath = new Uri(pathValue, UriKind.RelativeOrAbsolute);
                    ImageSource source    = new System.Windows.Media.Imaging.BitmapImage(imagePath);

                    return(source);
                }
                catch
                {
                }
            }

            return(null);
        }
示例#26
0
 internal Solution(IVsHierarchyItem item, SolutionItemType type) : base(item, type)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
 }
示例#27
0
    SolutionItemType GetGoSolutionItemType(GameObject go)
    {
        SolutionItemType solutionItemType = (SolutionItemType)System.Enum.Parse(typeof(SolutionItemType), go.name);

        return(solutionItemType);
    }
示例#28
0
 void CelebrateTicTacToe(SolutionItemType solutionItemType)
 {
     Debug.Log("Celebrate TicTacToe.................\n");
     //SwitchSides();
     //Invoke("EndCelebration", 2);
 }
示例#29
0
 void AdjustGoSolutionItemType(GameObject go, SolutionItemType solutionItemType)
 {
     go.name = solutionItemType.ToString();
 }
示例#30
0
 /// <summary>
 /// Creates a new instance of the solution item.
 /// </summary>
 protected SolutionItem(IVsHierarchyItem item, SolutionItemType type)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Type = type;
     Update(item);
 }
        private SolutionItem(Connect connect, Project project, bool recursive)
        {
            this._subItems = new List<SolutionItem>();
            this._projectType = LanguageType.None;

            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (connect == null)
            {
                throw new ArgumentNullException("connect");
            }

            this._incrementSetting = new SolutionItemIncrementSettings(this);
            this._connect = connect;
            this._item = project;
            this._name = project.Name;
            this._filename = project.FileName;
            this._uniqueName = project.UniqueName;
            if (!string.IsNullOrEmpty(this._filename) && string.IsNullOrEmpty(Path.GetExtension(this._filename)))
            {
                this._filename += Path.GetExtension(project.UniqueName);
            }
            if (string.IsNullOrEmpty(project.FullName))
            {
                this._itemType = SolutionItemType.Folder;
                if (recursive)
                {
                    SolutionItem.FillSolutionTree(connect, this, project.ProjectItems);
                }
            }
            else
            {
                this._itemType = SolutionItemType.Project;
                this.GetGlobalVariables();
            }
        }
		internal static ObservableCollection<ContextOperation> GetContextoperations(SolutionItemType itemType)
		{
			switch (itemType)
			{
				case SolutionItemType.Solution: return GenerateSolutionContextMenu();

				case SolutionItemType.Project: return GenerateProjectContextMenu();

				case SolutionItemType.XamlFile: return GenerateFileContextMenu();

				case SolutionItemType.XamlCodeFile: return GenerateFileContextMenu();

				case SolutionItemType.CodeFile: return GenerateFileContextMenu();

				default: return GenerateSolutionContextMenu();
			}
		}
 /// <summary>
 /// Class constructor
 /// </summary>
 protected SolutionBaseItemViewModel(ISolutionBaseItem parent, SolutionItemType itemType)
     : this()
 {
     SetParent(parent);
     _ItemType = itemType;
 }