Example #1
0
        protected static string GetText(System.Windows.Controls.ContentControl npdview, string name)
        {
            var d = ControlFinder.FindChildren <FrameworkElement>(npdview).FirstOrDefault(_ => _.Name == name);

            if (d is System.Windows.Controls.ContentControl)
            {
                return(((System.Windows.Controls.ContentControl)d).Content?.ToString());
            }
            if (d is System.Windows.Controls.Primitives.TextBoxBase)
            {
                return(((TextBlock)d).Text);
            }
            return(null);
        }
Example #2
0
 protected override bool GetTexts(System.Windows.Controls.ContentControl npdview)
 {
     this.header_recent = ControlFinder.FindChildren <TextBlock>(npdview).FirstOrDefault(_ => _.Name == "RecentProjectTemplatesTitle")?.Text;
     return(this.header_recent != null);
 }
Example #3
0
        public bool Initialize(IOption option)
        {
            System.Windows.Window wnd
                = System.Windows.Application.Current.Windows
                  .OfType <System.Windows.Window>().Reverse()
                  .FirstOrDefault(_ => _.DataContext?.GetType().Name == "WorkflowHostViewModel");

            if (wnd?.DataContext == null)
            {
                return(false);
            }

            this.commands = GetBackNextCommand(wnd);

            if (!this.commands.HasAllCommands || !this.commands.GoNextCommand.CanExecute(null))
            {
                return(false);
            }

            var piCurrentWorkflowId = wnd.DataContext.GetType().GetProperty("CurrentWorkflowId");

            if (piCurrentWorkflowId == null)
            {
                return(false);
            }

            string workflowId = piCurrentWorkflowId.GetValue(wnd.DataContext)?.ToString();

            if (workflowId != "VS.IDE.NewProject")
            {
                return(false);
            }

            var npdview = ControlFinder.FindChildren <System.Windows.Controls.ContentControl>(wnd)
                          .FirstOrDefault(_ => _.Name == "NPDView");

            if (npdview?.Content == null)
            {
                return(false);
            }

            if (!this.CustomProjectTemplatesModel.Initialize(option, npdview))
            {
                return(false);
            }

            var grid = npdview.Parent as System.Windows.Controls.Grid;

            if (grid == null)
            {
                return(false);
            }
            var view = new View.CustomProjectCreationView()
            {
                DataContext = this
            };

            view.Margin = new Thickness(5);

            grid.Children.Add(view);

            if (!this.CustomProjectConfigurationModel.Initialize(option, npdview))
            {
                grid.Children.Remove(view);
                return(false);
            }

            this.customView = view;
            this.CustomProjectTemplatesModel.SelectedTemplateChanged += CustomProjectTemplatesModel_SelectedItemChanged;


            var wfcc = ControlFinder.FindChildren <ContentControl>(wnd).FirstOrDefault(_ => _.Name == "WorkflowContentControl");

            if (wfcc != null)
            {
                if (wfcc.Parent is Grid)
                {
                    Grid parent = (Grid)wfcc.Parent;
                    parent.RowDefinitions.Last().Height = GridLength.Auto;

                    if (Grid.GetColumn(wfcc) > 0)
                    {
                        Grid.SetColumn(wfcc, 0);
                        Grid.SetColumnSpan(wfcc, parent.ColumnDefinitions.Count);
                    }
                }
            }


            wnd.ResizeMode     = ResizeMode.CanResizeWithGrip;
            npdview.Visibility = Visibility.Hidden;

            wnd.Closing += (s, e) =>
            {
                this.CustomProjectTemplatesModel.WriteToOption(option);
                this.CustomProjectConfigurationModel.WriteToOption(option);
                option.SaveSettingsToStorage();
            };

            return(true);
        }