コード例 #1
0
 /// <summary>
 /// Initializes a new instance of <seealso cref="ErrorFrameTooltipViewModel"/> class.
 /// </summary>
 /// <param name="errorItem">The error item the tooltip shows.</param>
 public ErrorFrameTooltipViewModel(ErrorGroupItem errorItem)
 {
     OnCloseButtonCommand          = new ProtectedCommand(ShowTooltipUtils.HideTooltip);
     OnBackToErrorReportingCommand = new ProtectedCommand(
         () => ToolWindowCommandUtils.ShowToolWindow <ErrorReportingDetailToolWindow>());
     Error = errorItem;
 }
コード例 #2
0
        public UserPromptWindowViewModel(UserPromptWindow owner, UserPromptWindow.Options options)
        {
            _owner   = owner;
            _options = options;

            ActionCommand = new ProtectedCommand(OnActionCommand);
        }
コード例 #3
0
        public AnalyticsOptInWindowViewModel(AnalyticsOptInWindow owner)
        {
            _owner = owner.ThrowIfNull(nameof(owner));

            OptInCommand = new ProtectedCommand(OnOptInCommand);
            AnalyticsLearnMoreLinkCommand = new ProtectedCommand(() => AnalyticsLearnMoreUtils.OpenLearnMoreLink());
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of <seealso cref="TitleBarViewModel"/> class.
 /// Make it private to enforce the singleton pattern.
 /// </summary>
 public TitleBarViewModel()
 {
     OnGotoAccountManagementCommand = new ProtectedCommand(
         () => GoogleCloudExtensionPackage.Instance.UserPromptService.PromptUser(
             new ManageAccountsWindowContent()));
     CredentialsStore.Default.CurrentProjectIdChanged += (sender, e) => OnAccountProjectIdChanged();
 }
コード例 #5
0
 /// <summary>
 /// Initializes an instance of <seealso cref="LogsViewerViewModel"/> class.
 /// </summary>
 public LogsViewerViewModel()
 {
     _dataSource       = new Lazy <LoggingDataSource>(CreateDataSource);
     RefreshCommand    = new ProtectedCommand(OnRefreshCommand);
     LogItemCollection = new ListCollectionView(_logs);
     LogItemCollection.GroupDescriptions.Add(new PropertyGroupDescription(nameof(LogItem.Date)));
     CancelRequestCommand    = new ProtectedCommand(CancelRequest);
     SimpleTextSearchCommand = new ProtectedCommand(() =>
     {
         EventsReporterWrapper.ReportEvent(LogsViewerSimpleTextSearchEvent.Create());
         ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     });
     FilterSwitchCommand         = new ProtectedCommand(SwapFilter);
     SubmitAdvancedFilterCommand = new ProtectedCommand(() =>
     {
         EventsReporterWrapper.ReportEvent(LogsViewerAdvancedFilterEvent.Create());
         ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     });
     AdvancedFilterHelpCommand = new ProtectedCommand(ShowAdvancedFilterHelp);
     DateTimePickerModel       = new DateTimePickerViewModel(
         TimeZoneInfo.Local, DateTime.UtcNow, isDescendingOrder: true);
     DateTimePickerModel.DateTimeFilterChange += (sender, e) => ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     PropertyChanged     += OnPropertyChanged;
     ResourceTypeSelector = new ResourceTypeMenuViewModel(_dataSource);
     ResourceTypeSelector.PropertyChanged += OnPropertyChanged;
     OnDetailTreeNodeFilterCommand         = new ProtectedCommand <ObjectNodeTree>(FilterOnTreeNodeValue);
     OnAutoReloadCommand = new ProtectedCommand(AutoReload);
 }
コード例 #6
0
 /// <summary>
 /// Creates a new NewSubscriptionViewModel
 /// </summary>
 /// <param name="subscription">The subscription object to model</param>
 /// <param name="owner">The owner dialog.</param>
 public NewSubscriptionViewModel(Subscription subscription, CommonDialogWindowBase owner)
 {
     _owner        = owner;
     Subscription  = subscription;
     CreateCommand = new ProtectedCommand(OnCreateCommand);
     PushConfig    = subscription.PushConfig ?? new PushConfig();
 }
        public AddWindowsCredentialViewModel(AddWindowsCredentialWindow owner, Instance instance)
        {
            _owner    = owner;
            _instance = instance;

            SaveCommand = new ProtectedCommand(OnSaveCommand);
        }
コード例 #8
0
 /// <summary>
 /// Initializes an instance of <seealso cref="MenuItemViewModel"/> class.
 /// </summary>
 /// <param name="parent">The parent menu item view model.</param>
 public MenuItemViewModel(MenuItemViewModel parent)
 {
     IsVisible            = true;
     MenuItemParent       = parent;
     MenuCommand          = new ProtectedCommand(() => CommandBubblingHandler(this));
     MenuItems            = new ObservableCollection <MenuItemViewModel>();
     OnSubmenuOpenCommand = new ProtectedAsyncCommand(AddItemsAsync);
 }
コード例 #9
0
 /// <summary>
 /// Creates a new Console Link tree leaf node.
 /// </summary>
 /// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
 /// <param name="linkFormatInfo">
 /// The link info with the caption and the <see cref="string.Format(string,object[])"/> ready url format.
 /// </param>
 public ConsoleLink(ICloudSourceContext context, LinkInfo linkFormatInfo)
 {
     _context            = context;
     _linkFormatInfo     = linkFormatInfo;
     Caption             = _linkFormatInfo.Caption;
     NavigateCommand     = new ProtectedCommand(OnNavigateCommand);
     NavigateInfoCommand = new ProtectedCommand(OnNavigateHelpCommand, false);
 }
コード例 #10
0
        public AnalyticsOptInWindowViewModel()
        {
            _browserService = GoogleCloudExtensionPackage.Instance.GetMefServiceLazy <IBrowserService>();

            OptInCommand = new ProtectedCommand(OnOptInCommand);
            AnalyticsLearnMoreLinkCommand = new ProtectedCommand(
                () => BrowserService.OpenBrowser(AnalyticsLearnMoreConstants.AnalyticsLearnMoreLink));
        }
コード例 #11
0
 /// <summary>
 /// Create a instance of <seealso cref="DateTimePickerViewModel"/> class.
 /// </summary>
 /// <param name="timeZone">Current selected time zone.</param>
 /// <param name="dateTimeUtc">Initial UTC date time.</param>
 /// <param name="isDescendingOrder">Initial time stamp sort order.</param>
 public DateTimePickerViewModel(TimeZoneInfo timeZone, DateTime dateTimeUtc, bool isDescendingOrder)
 {
     _timeZone         = timeZone;
     DateTimeUtc       = dateTimeUtc;
     IsDescendingOrder = isDescendingOrder;
     GoCommand         = new ProtectedCommand(OnGoButtonCommand);
     CancelCommand     = new ProtectedCommand(() => IsDropDownOpen = false);
 }
コード例 #12
0
 public CsrAddRepoWindowViewModel(CsrAddRepoWindow owner, IList <Repo> repos, Project project)
 {
     _owner         = owner.ThrowIfNull(nameof(owner));
     _repos         = repos.ThrowIfNull(nameof(repos));
     _project       = project.ThrowIfNull(nameof(project));
     OkCommand      = new ProtectedAsyncCommand(CreateRepoAsync, canExecuteCommand: false);
     CsrLinkCommand = new ProtectedCommand(() => Process.Start(CsrConsoleLink));
 }
コード例 #13
0
        public PortManagerViewModel(PortManagerWindow owner, Instance instance)
        {
            _owner    = owner;
            _instance = instance;

            Ports     = CreatePortModels();
            OkCommand = new ProtectedCommand(OnOkCommand);
        }
コード例 #14
0
        private GceStepViewModel(GceStepContent content)
        {
            _content = content;

            Instances = AsyncPropertyValueUtils.CreateAsyncProperty(GetAllWindowsInstances());

            ManageCredentialsCommand = new ProtectedCommand(OnManageCredentialsCommand, canExecuteCommand: false);
        }
コード例 #15
0
        private GkeStepViewModel(GkeStepContent content)
        {
            _content = content;

            Clusters                   = new AsyncPropertyValue <IList <Cluster> >(GetAllClustersAsync());
            CreateClusterCommand       = new ProtectedCommand(OnCreateClusterCommand);
            RefreshClustersListCommand = new ProtectedCommand(OnRefreshClustersListCommand);
        }
コード例 #16
0
 private ListProcessStepViewModel(
     ListProcessStepContent content,
     AttachDebuggerContext context)
     : base(context)
 {
     Content        = content;
     RefreshCommand = new ProtectedCommand(() => GetAllProcessesList());
 }
コード例 #17
0
 /// <summary>
 /// Internal constructor for testing.
 /// </summary>
 /// <param name="linkFormatInfo">
 /// The link info with the caption and the <see cref="string.Format(string,object[])"/> ready url format.
 /// </param>
 /// <param name="context">The <see cref="ICloudSourceContext"/>.</param>
 /// <param name="startProcess">
 /// Dependency injecion of the static function <see cref="Process.Start(string)"/>.
 /// </param>
 internal ConsoleLink(LinkInfo linkFormatInfo, ICloudSourceContext context, Func <string, Process> startProcess)
 {
     _startProcess   = startProcess;
     _context        = context;
     _linkFormatInfo = linkFormatInfo;
     Caption         = _linkFormatInfo.Caption;
     NavigateCommand = new ProtectedCommand(OnNavigateCommand);
 }
コード例 #18
0
        public AddTrafficSplitViewModel(AddTrafficSplitWindow owner, IEnumerable <string> versions)
        {
            _owner = owner;

            Versions        = versions;
            SelectedVersion = Versions.FirstOrDefault();
            AddSplitCommand = new ProtectedCommand(OnAddSplitCommand);
        }
コード例 #19
0
 public RepoItemViewModel(Repo cloudRepo, string localGitRoot)
 {
     cloudRepo.ThrowIfNull(nameof(cloudRepo));
     LocalPath       = localGitRoot.ThrowIfNullOrEmpty(nameof(localGitRoot));
     Name            = cloudRepo.Name?.Split('/').LastOrDefault();
     RepoFullName    = cloudRepo.Name;
     VisitUrlCommand = new ProtectedCommand(() => Process.Start(cloudRepo.Url));
 }
コード例 #20
0
 private HelpStepViewModel(
     HelpStepContent content,
     AttachDebuggerContext context)
     : base(context)
 {
     Content         = content;
     HelpLinkCommand = new ProtectedCommand(() => Process.Start(HelpLink));
 }
コード例 #21
0
        private void UpdateContextMenu()
        {
            var getPublishSettingsCommand = new ProtectedCommand(OnSavePublishSettingsCommand, canExecuteCommand: Instance.IsAspnetInstance());
            var openWebSite = new ProtectedCommand(OnOpenWebsite, canExecuteCommand: Instance.IsAspnetInstance() && Instance.IsRunning());
            var openTerminalServerSessionCommand = new ProtectedCommand(
                OnOpenTerminalServerSessionCommand,
                canExecuteCommand: Instance.IsWindowsInstance() && Instance.IsRunning());
            var startInstanceCommand     = new ProtectedCommand(OnStartInstanceCommand);
            var stopInstanceCommand      = new ProtectedCommand(OnStopInstanceCommand);
            var manageFirewallPorts      = new ProtectedCommand(OnManageFirewallPortsCommand);
            var manageWindowsCredentials = new ProtectedCommand(OnManageWindowsCredentialsCommand, canExecuteCommand: Instance.IsWindowsInstance());

            var menuItems = new List <MenuItem>
            {
                new MenuItem {
                    Header = Resources.CloudExplorerGceSavePublishSettingsMenuHeader, Command = getPublishSettingsCommand
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceOpenTerminalSessionMenuHeader, Command = openTerminalServerSessionCommand
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceOpenWebSiteMenuHeader, Command = openWebSite
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceManageFirewallPortsMenuHeader, Command = manageFirewallPorts
                },
                new MenuItem {
                    Header = Resources.CloudExplorerGceManageWindowsCredentialsMenuHeader, Command = manageWindowsCredentials
                }
            };

            if (Instance.IsRunning())
            {
                menuItems.Add(new MenuItem {
                    Header = Resources.CloudExplorerGceStopInstanceMenuHeader, Command = stopInstanceCommand
                });
            }
            else
            {
                menuItems.Add(new MenuItem {
                    Header = Resources.CloudExplorerGceStartInstanceMenuHeader, Command = startInstanceCommand
                });
            }

            menuItems.Add(new MenuItem {
                Header = Resources.UiOpenOnCloudConsoleMenuHeader, Command = new ProtectedCommand(OnOpenOnCloudConsoleCommand)
            });
            menuItems.Add(new MenuItem {
                Header = Resources.UiPropertiesMenuHeader, Command = new ProtectedCommand(OnPropertiesWindowCommand)
            });

            ContextMenu = new ContextMenu {
                ItemsSource = menuItems
            };

            SyncContextMenuState();
        }
コード例 #22
0
        private GceStepViewModel(GceStepContent content, IGceDataSource dataSource, IApiManager apiManager)
            : base(apiManager)
        {
            _content    = content;
            _dataSource = dataSource;

            ManageCredentialsCommand = new ProtectedCommand(OnManageCredentialsCommand, canExecuteCommand: false);
            EnableApiCommand         = new ProtectedAsyncCommand(OnEnableApiCommandAsync);
        }
コード例 #23
0
        public AuthorizedNetworkModel(AclEntry acl, bool newNetwork = false)
        {
            _acl         = acl;
            _newNetwork  = newNetwork;
            _toBeDeleted = false;

            DeleteCommand     = new ProtectedCommand(OnDeleteCommand);
            UndoDeleteCommand = new ProtectedCommand(OnUndoDeleteCommand);
        }
コード例 #24
0
            public void TestExecute_InvokesProvidedAction()
            {
                var actionMock      = new Mock <Action>();
                var objectUnderTest = new ProtectedCommand(actionMock.Object);

                objectUnderTest.Execute(null);

                actionMock.Verify(f => f(), Times.Once);
            }
コード例 #25
0
        /// <summary>
        /// Constructor used for testing.
        /// </summary>
        internal AppEngineManagementViewModel(ICloseable owner, string projectId, IGaeDataSource dataSource)
        {
            _owner      = owner;
            _dataSource = dataSource;

            Locations        = new AsyncProperty <IEnumerable <string> >(ListAllLocationsAsync(), s_loadingPlaceholder);
            SelectedLocation = s_loadingPlaceholder.First();
            ActionCommand    = new ProtectedCommand(OnActionCommand);
            ProjectId        = projectId;
        }
コード例 #26
0
 /// <param name="closeWindow">The action that closes the related dialog.</param>
 protected TemplateChooserViewModelBase(Action closeWindow)
 {
     GcpProjectId = CredentialsStore.Default.CurrentProjectId ?? "";
     OkCommand    = new ProtectedCommand(
         () =>
     {
         Result = CreateResult();
         closeWindow();
     });
 }
コード例 #27
0
        public NamePromptViewModel(NamePromptWindow owner, NamePromptWindow.Options options)
        {
            _owner = owner;

            Name    = options?.InitialName;
            Message = options?.Message ?? Resources.EnterNameDialogNameMessage;

            OkCommand     = new ProtectedCommand(OnOkCommand);
            CancelCommand = new ProtectedCommand(OnCancelCommand);
        }
        public AttachDebuggerWindowViewModel(Instance gceInstance, AttachDebuggerWindow dialogWindow)
        {
            OKCommand     = new ProtectedAsyncCommand(() => ExceuteAsync(OnOKCommand), canExecuteCommand: false);
            CancelCommand = new ProtectedCommand(OnCancelCommand, canExecuteCommand: false);

            var context   = new AttachDebuggerContext(gceInstance, dialogWindow);
            var firstStep = SetCredentialStepViewModel.CreateStep(context);

            ErrorHandlerUtils.HandleExceptionsAsync(() => ExceuteAsync(() => GotoStep(firstStep)));
        }
コード例 #29
0
        public PickProjectIdViewModel(string helpText, bool allowAccountChange)
        {
            AllowAccountChange = allowAccountChange;
            HelpText           = helpText;

            ChangeUserCommand = new ProtectedCommand(OnChangeUserCommand);
            OkCommand         = new ProtectedCommand(OnOkCommand, canExecuteCommand: false);
            RefreshCommand    = new ProtectedCommand(OnRefreshCommand, canExecuteCommand: false);
            StartLoadProjects();
        }
コード例 #30
0
        /// <inheritdoc />
        protected PublishDialogStepBase(IApiManager apiManager)
        {
            _apiManager = apiManager;

            SelectProjectCommand = new ProtectedCommand(OnSelectProjectCommand);
            CredentialsStore.Default.CurrentProjectIdChanged += (sender, args) =>
            {
                RaisePropertyChanged(nameof(GcpProjectId));
            };
        }