Exemplo n.º 1
0
                public override StateRefreshChanges ToggleState(int row, int column)
                {
                    StateRefreshChanges retVal            = StateRefreshChanges.None;
                    IORMGenerator       selectedGenerator = _selectedORMGenerator;

                    if (selectedGenerator == null)
                    {
                        retVal = _mainBranch.ToggleOnRequiredBranches(this, row);
                    }
                    else
                    {
                        IORMGenerator newGenerator = _ormGenerators[row];
                        if (object.ReferenceEquals(newGenerator, selectedGenerator))
                        {
                            retVal = _mainBranch.ToggleOnRequiredBranches(this, row, true);
                        }
                        else
                        {
                            _mainBranch.RemoveGenerator(this);
                            retVal = _mainBranch.ToggleOnRequiredBranches(this, row, false);
                        }
                    }
                    if (retVal != StateRefreshChanges.None && retVal != StateRefreshChanges.Entire)
                    {
                        retVal = StateRefreshChanges.ParentsChildren;
                    }
                    return(retVal);
                }
Exemplo n.º 2
0
 /// <summary>
 ///     Allows providers listening to synchronization events to communicate state changes back to the tree.  This
 ///     is required so that the tree sends out the appropriate notifications, which, when the tree is attached to a
 ///     control, will result in things like correct repaint and firing accessibility state change events.
 /// </summary>
 /// <param name="stateChanges">Description of changes.</param>
 /// <param name="row">Row that changed.</param>
 /// <param name="column">Column that changed.</param>
 public void NotifyStateChange(StateRefreshChanges stateChanges, int row, int column)
 {
     Debug.Assert(myTree != null, "unable to notify state change.");
     if (myTree != null)
     {
         myTree.NotifyStateChange(row, column, stateChanges);
     }
 }
Exemplo n.º 3
0
 internal ToggleStateEventArgs(int row, int column, StateRefreshChanges stateRefreshOptions)
 {
     myRow = row;
     myColumn = column;
     myStateRefreshOptions = stateRefreshOptions;
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Allows providers listening to synchronization events to communicate state changes back to the tree.  This
 ///     is required so that the tree sends out the appropriate notifications, which, when the tree is attached to a
 ///     control, will result in things like correct repaint and firing accessibility state change events.
 /// </summary>
 /// <param name="stateChanges">Description of changes.</param>
 /// <param name="row">Row that changed.</param>
 /// <param name="column">Column that changed.</param>
 public void NotifyStateChange(StateRefreshChanges stateChanges, int row, int column)
 {
     Debug.Assert(myTree != null, "unable to notify state change.");
     if (myTree != null)
     {
         myTree.NotifyStateChange(row, column, stateChanges);
     }
 }
Exemplo n.º 5
0
 internal ToggleStateEventArgs(int row, int column, StateRefreshChanges stateRefreshOptions)
 {
     myRow    = row;
     myColumn = column;
     myStateRefreshOptions = stateRefreshOptions;
 }
Exemplo n.º 6
0
            private StateRefreshChanges ToggleOnRequiredBranches(OutputFormatBranch formatBranch, int branchGeneratorIndex, bool testToggleOff)
            {
                StateRefreshChanges retVal = StateRefreshChanges.None;

                if (formatBranch.IsModifier)
                {
                    if (formatBranch.SelectedORMGenerator == null)
                    {
                        // The build item is associated primarily with the primary generator,
                        // not the modifier. We need to make sure that the primary generator
                        // is turned on.
                        IORMGenerator      modifierGenerator = formatBranch.ORMGenerators[0];
                        OutputFormatBranch primaryBranch     = _branches[modifierGenerator.ProvidesOutputFormat];
                        IORMGenerator      primaryGenerator  = primaryBranch.SelectedORMGenerator;
                        if (primaryGenerator == null)
                        {
                            if (StateRefreshChanges.None != ToggleOnRequiredBranches(primaryBranch, 0, false))
                            {
                                retVal = StateRefreshChanges.Entire;
                            }
                            primaryGenerator = primaryBranch.SelectedORMGenerator;
                            if (primaryGenerator == null)
                            {
                                return(StateRefreshChanges.None);
                            }
                        }
                        formatBranch.SelectedORMGenerator = modifierGenerator;
                        SetItemMetaData(_parent.BuildItemsByGenerator[primaryGenerator.OfficialName], ITEMMETADATA_ORMGENERATOR, primaryBranch.SelectedGeneratorOfficialNames);
                        retVal |= StateRefreshChanges.Children | StateRefreshChanges.Children;
                    }
                    else if (testToggleOff)
                    {
                        // Note that we can always remove a modifier, do not call CanRemoveGenerator
                        RemoveGenerator(formatBranch);
                        retVal |= StateRefreshChanges.Current | StateRefreshChanges.Children;
                    }
                }
                else if (formatBranch.SelectedORMGenerator == null)
                {
#if VISUALSTUDIO_10_0
                    string projectPath = Parent._project.FullPath;
#else
                    string projectPath = Parent._project.FullFileName;
#endif
                    EnvDTE.ProjectItem projectItem = Parent._projectItem;

                    string sourceFileName   = _parent._sourceFileName;
                    string projectItemPath  = (string)projectItem.Properties.Item("LocalPath").Value;
                    string newItemDirectory = (new Uri(projectPath)).MakeRelativeUri(new Uri(projectItemPath)).ToString();
                    newItemDirectory = Path.GetDirectoryName(newItemDirectory);

                    retVal = StateRefreshChanges.Current | StateRefreshChanges.Children;
                    IORMGenerator useGenerator   = formatBranch.ORMGenerators[branchGeneratorIndex];
                    string        outputFileName = useGenerator.GetOutputFileDefaultName(sourceFileName);
                    outputFileName = Path.Combine(newItemDirectory, outputFileName);
#if VISUALSTUDIO_10_0
                    ProjectItemElement newBuildItem;
#else
                    BuildItem newBuildItem;
#endif
                    newBuildItem = useGenerator.AddGeneratedFileItem(_parent._itemGroup, sourceFileName, outputFileName);                     //string.Concat(newItemPath, Path.DirectorySeparatorChar, _parent._sourceFileName));
                    _parent.BuildItemsByGenerator[useGenerator.OfficialName] = newBuildItem;
                    _parent.RemoveRemovedItem(newBuildItem);
                    formatBranch.SelectedORMGenerator = useGenerator;
                    IList <string> requiredFormats      = useGenerator.RequiresInputFormats;
                    int            requiredFormatCount  = requiredFormats.Count;
                    IList <string> companionFormats     = useGenerator.RequiresCompanionFormats;
                    int            companionFormatCount = companionFormats.Count;
                    int            totalCount           = requiredFormatCount + companionFormatCount;
                    for (int i = 0; i < totalCount; ++i)
                    {
                        OutputFormatBranch requiredBranch;
                        if (_branches.TryGetValue(i < requiredFormatCount ? requiredFormats[i] : companionFormats[i - requiredFormatCount], out requiredBranch))
                        {
                            if (StateRefreshChanges.None != ToggleOnRequiredBranches(requiredBranch, 0, false))
                            {
                                retVal = StateRefreshChanges.Entire;
                            }
                        }
                    }
                }
                else if (testToggleOff && CanRemoveGenerator(formatBranch))
                {
                    RemoveGenerator(formatBranch);
                    retVal = StateRefreshChanges.Current | StateRefreshChanges.Children;
                }
                return(retVal);
            }
Exemplo n.º 7
0
 internal void NotifyStateChange(int row, int column, StateRefreshChanges stateRefreshOptions)
 {
     if (StateToggled != null)
     {
         DelayTurnOffRedraw();
         StateToggled(this, new ToggleStateEventArgs(row, column, stateRefreshOptions));
     }
     if (column == 0
         && GetStateFlag(TreeStateFlags.FireSingleColumnStateToggled))
     {
         var singleColumnSubItemAdjust = 0;
         TrackCell(row, ref column, ref singleColumnSubItemAdjust);
         DelayTurnOffSingleColumnRedraw();
         var singleTree = SingleColumnTree;
         (singleTree as SingleColumnView).myStateToggled(
             singleTree, new ToggleStateEventArgs(row - singleColumnSubItemAdjust, 0, stateRefreshOptions));
     }
 }
Exemplo n.º 8
0
            private StateRefreshChanges ToggleOnRequiredBranches(OutputFormatBranch formatBranch, int branchGeneratorIndex, bool testToggleOff)
            {
                StateRefreshChanges retVal = StateRefreshChanges.None;

                if (formatBranch.IsModifier)
                {
                    if (formatBranch.SelectedORMGenerator == null)
                    {
                        // The build item is associated primarily with the output format for
                        // the primary generator, not the modifier. We need to make sure that
                        // the primary generator is turned on.
                        IORMGenerator      modifierGenerator = formatBranch.ORMGenerators[0];
                        OutputFormatBranch primaryBranch     = _branches[modifierGenerator.ProvidesOutputFormat];
                        IORMGenerator      primaryGenerator  = primaryBranch.SelectedORMGenerator;
                        if (primaryGenerator == null)
                        {
                            if (StateRefreshChanges.None != ToggleOnRequiredBranches(primaryBranch, 0, false))
                            {
                                retVal = StateRefreshChanges.Entire;
                            }
                            primaryGenerator = primaryBranch.SelectedORMGenerator;
                            if (primaryGenerator == null)
                            {
                                return(StateRefreshChanges.None);
                            }
                        }
                        formatBranch.SelectedORMGenerator = modifierGenerator;
                        PseudoBuildItem pseudoItem = _parent.PseudoItemsByOutputFormat[primaryGenerator.ProvidesOutputFormat];
                        pseudoItem.CurrentGeneratorNames = primaryBranch.SelectedGeneratorOfficialNames;
                        retVal |= StateRefreshChanges.Children | StateRefreshChanges.Children;
                    }
                    else if (testToggleOff)
                    {
                        // Note that we can always remove a modifier, do not call CanRemoveGenerator
                        RemoveGenerator(formatBranch);
                        retVal |= StateRefreshChanges.Current | StateRefreshChanges.Children;
                    }
                }
                else if (formatBranch.SelectedORMGenerator == null)
                {
                    IORMGenerator generator = formatBranch.ORMGenerators[branchGeneratorIndex];
                    retVal = StateRefreshChanges.Current | StateRefreshChanges.Children;
                    formatBranch.SelectedORMGenerator = generator;
                    _parent.AddPseudoItem(generator, formatBranch.SelectedGeneratorOfficialNames);

                    // Notify related generator branches
                    IList <string> requiredFormats = generator.RequiresInputFormats; int requiredFormatCount = requiredFormats.Count;
                    IList <string> companionFormats     = generator.RequiresCompanionFormats;
                    int            companionFormatCount = companionFormats.Count;
                    int            totalCount           = requiredFormatCount + companionFormatCount;
                    for (int i = 0; i < totalCount; ++i)
                    {
                        OutputFormatBranch requiredBranch;
                        if (_branches.TryGetValue(i < requiredFormatCount ? requiredFormats[i] : companionFormats[i - requiredFormatCount], out requiredBranch))
                        {
                            if (StateRefreshChanges.None != ToggleOnRequiredBranches(requiredBranch, 0, false))
                            {
                                retVal = StateRefreshChanges.Entire;
                            }
                        }
                    }
                }
                else if (testToggleOff && CanRemoveGenerator(formatBranch))
                {
                    RemoveGenerator(formatBranch);
                    retVal = StateRefreshChanges.Current | StateRefreshChanges.Children;
                }
                return(retVal);
            }