public void TestBehaviorRegular_AttachInDesignTime_InteractionHelperOnAssociatedObject() { ViewModelDesignHelper.IsInDesignModeOverride = true; Grid element = new Grid(); InteractionHelper.SetBehaviorInDesignMode(element, InteractionBehaviorInDesignMode.AsWellAsNotInDesignMode); CheckAttach(new TestBehaviorRegular(), element); }
protected virtual ApplicationJumpItemInfo GetItem(int index) { if (InteractionHelper.IsInDesignMode(this)) { return(designModeItems[index]); } return(ApplicationJumpItemWrapper.Unwrap(nativeJumpList[index])); }
/// <inheritdoc /> public async Task ModifyAsync <TArg>(Action <TArg> func, RequestOptions options = null) where TArg : ApplicationCommandProperties { var command = IsGlobalCommand ? await InteractionHelper.ModifyGlobalCommandAsync(Discord, this, func, options).ConfigureAwait(false) : await InteractionHelper.ModifyGuildCommandAsync(Discord, this, GuildId.Value, func, options); Update(command); }
public void TestBehaviorNotAllowAttachInDesignMode_AttachInDesignTime_InteractionHelperOnBehavior() { ViewModelDesignHelper.IsInDesignModeOverride = true; var b = new TestBehaviorNotAllowAttachInDesignMode(); InteractionHelper.SetBehaviorInDesignMode(b, InteractionBehaviorInDesignMode.AsWellAsNotInDesignMode); CheckNotAttach(b); }
protected virtual int ItemsCount() { if (InteractionHelper.IsInDesignMode(this)) { return(designModeItems.Count); } return(nativeJumpList.Count); }
bool ShouldAttachItem(T item) { if (!InteractionHelper.IsInDesignMode(AssociatedObject)) { return(true); } return(!InteractionHelper.IsInDesignMode(item)); }
protected virtual IEnumerable <ApplicationJumpItemInfo> GetItems() { if (InteractionHelper.IsInDesignMode(this)) { return(designModeItems); } return(nativeJumpList.Select(i => ApplicationJumpItemWrapper.Unwrap(i))); }
protected virtual bool ContainsItem(ApplicationJumpItemInfo item) { if (InteractionHelper.IsInDesignMode(this)) { return(designModeItems.Contains(item)); } return(nativeJumpList.Contains(ApplicationJumpItemWrapper.Wrap(item))); }
protected virtual int IndexOfItem(ApplicationJumpItemInfo item) { if (InteractionHelper.IsInDesignMode(this)) { return(designModeItems.IndexOf(item)); } return(nativeJumpList.IndexOf(ApplicationJumpItemWrapper.Wrap(item))); }
public virtual void AddToRecentCategory(string jumpPath) { if (InteractionHelper.IsInDesignMode(this)) { return; } nativeJumpList.AddToRecentCategory(jumpPath); }
protected virtual void ClearItems() { if (InteractionHelper.IsInDesignMode(this)) { designModeItems.Clear(); return; } nativeJumpList.Clear(); }
public void SubjectViewModel_WhenReadingText_ReturnsSubject() { var viewModel = BuildEditEmailTextViewModel(); var interactionHelper = new InteractionHelper <EditEmailTextInteraction>(viewModel, new EditEmailTextInteraction("", "", true, false)); viewModel.Interaction.Subject = "Test"; Assert.AreEqual("Test", viewModel.SubjectTextViewModel.Text); }
protected virtual void SetItem(int index, ApplicationJumpItemInfo item) { if (InteractionHelper.IsInDesignMode(this)) { designModeItems[index] = item; return; } nativeJumpList[index] = PrepareItem(item, nativeJumpList[index]); }
protected virtual void InsertItem(int index, ApplicationJumpItemInfo item) { if (InteractionHelper.IsInDesignMode(this)) { designModeItems.Insert(index, item); return; } nativeJumpList.Insert(index, PrepareItem(item, null)); }
protected virtual void RemoveItemAt(int index) { if (InteractionHelper.IsInDesignMode(this)) { designModeItems.RemoveAt(index); return; } nativeJumpList.RemoveAt(index); }
public void BodyViewModel_WhenSettingText_UpdatesBody() { var viewModel = BuildEditEmailTextViewModel(); var interactionHelper = new InteractionHelper <EditEmailTextInteraction>(viewModel, new EditEmailTextInteraction("", "", true, false)); viewModel.BodyTextViewModel.Text = "Test"; Assert.AreEqual("Test", viewModel.Interaction.Content); }
public void AddSignature_WhenSet_UpdatesInteraction() { var viewModel = BuildEditEmailTextViewModel(); var interactionHelper = new InteractionHelper <EditEmailTextInteraction>(viewModel, new EditEmailTextInteraction("", "", false, false)); viewModel.AddSignature = true; Assert.IsTrue(viewModel.Interaction.AddSignature); }
protected virtual void AddItem(ApplicationJumpItemInfo item) { if (InteractionHelper.IsInDesignMode(this)) { designModeItems.Add(item); return; } nativeJumpList.Add(PrepareItem(item, null)); }
protected virtual ApplicationJumpTaskInfo Find(string commandId) { if (InteractionHelper.IsInDesignMode(this)) { return(null); } ApplicationJumpTaskWrap task = (ApplicationJumpTaskWrap)nativeJumpList.Find(commandId); return(task == null ? null : task.ApplicationJumpTask); }
/// <summary> /// Initializes a new instance of the AccordionItem class. /// </summary> public AccordionItem() { // initialize to no action. ScheduledAction = AccordionAction.None; #if SILVERLIGHT DefaultStyleKey = typeof(AccordionItem); #endif _interaction = new InteractionHelper(this); }
public void SetProperties_AfterCallingOk_InteractionIsSuccessful() { var viewModel = BuildEditEmailTextViewModel(); var interactionHelper = new InteractionHelper <EditEmailTextInteraction>(viewModel, new EditEmailTextInteraction("", "", true, false)); viewModel.OkCommand.Execute(null); Assert.IsTrue(interactionHelper.InteractionIsFinished); Assert.IsTrue(viewModel.Interaction.Success); }
public static async Task <int> GetDataLimit(string group, CancellationToken cancellationToken = default) { var(loadedNodes, loadNodesErrMsg) = await Nodes.LoadNodesAsync(cancellationToken); if (loadNodesErrMsg is not null) { Console.WriteLine(loadNodesErrMsg); return(1); } using var nodes = loadedNodes; if (nodes.Groups.TryGetValue(group, out var targetGroup)) { Console.WriteLine($"{"Group",-24}{group,-32}"); if (targetGroup.DataLimitInBytes != 0UL) { Console.WriteLine($"{"Global data limit",-24}{InteractionHelper.HumanReadableDataString1024(targetGroup.DataLimitInBytes),-32}"); } if (targetGroup.PerUserDataLimitInBytes != 0UL) { Console.WriteLine($"{"Per-user data limit",-24}{InteractionHelper.HumanReadableDataString1024(targetGroup.PerUserDataLimitInBytes),-32}"); } var outlineAccessKeyCustomLimits = targetGroup.OutlineAccessKeys?.Where(x => x.DataLimit is not null).Select(x => (x.Name, x.DataLimit !.Bytes)); if (outlineAccessKeyCustomLimits is null || !outlineAccessKeyCustomLimits.Any()) { return(0); } var maxNameLength = outlineAccessKeyCustomLimits.Select(x => x.Name.Length) .DefaultIfEmpty() .Max(); var nameFieldWidth = maxNameLength > 4 ? maxNameLength + 2 : 6; ConsoleHelper.PrintTableBorder(nameFieldWidth, 19); Console.WriteLine($"|{"User".PadRight(nameFieldWidth)}|{"Custom Data Limit",19}|"); ConsoleHelper.PrintTableBorder(nameFieldWidth, 19); foreach ((var username, var dataLimitInBytes) in outlineAccessKeyCustomLimits) { Console.WriteLine($"|{username.PadRight(nameFieldWidth)}|{InteractionHelper.HumanReadableDataString1024(dataLimitInBytes),19}|"); } ConsoleHelper.PrintTableBorder(nameFieldWidth, 19); return(0); } else { Console.WriteLine($"Error: group {group} doesn't exist."); return(-2); } }
private void UpdateTriggers() { if (partListBox != null) { partListBox.ItemsSource = null; if (SelectedItems != null && SelectedItems.Any()) { partListBox.ItemsSource = InteractionHelper.GetTriggers(SelectedItems); } } }
public void TestEnableBehaviorsInDesignTimeForEventTriggers() { ViewModelDesignHelper.IsInDesignModeOverride = true; var trigger = new FakeTrigger(); var border = new Border(); var button = new Button(); border.Child = button; InteractionHelper.SetEnableBehaviorsInDesignTime(border, true); CheckAttach(trigger, button); }
public void OkCommand_OnExecute_CompletesInteraction() { var viewModel = CreateViewModel(); var interaction = new PasswordOverlayInteraction(PasswordMiddleButton.Skip, "", ""); var helper = new InteractionHelper <PasswordOverlayInteraction>(viewModel, interaction); viewModel.OkCommand.Execute(null); Assert.AreEqual(PasswordResult.StorePassword, interaction.Result); Assert.IsTrue(helper.InteractionIsFinished); }
public void Setup() { _osHelper = Substitute.For <IOsHelper>(); _uacAssistant = Substitute.For <IUacAssistant>(); var applicationNameProvider = new ApplicationNameProvider(EditionName); _interactionRequest = new UnitTestInteractionRequest(); _storeLicenseForAllUsersWindowViewModel = new StoreLicenseForAllUsersWindowViewModel(applicationNameProvider, _osHelper, _uacAssistant, _interactionRequest, new DesignTimeTranslationUpdater()); var interaction = new StoreLicenseForAllUsersInteraction("", ""); _interactionHelper = new InteractionHelper <StoreLicenseForAllUsersInteraction>(_storeLicenseForAllUsersWindowViewModel, interaction); }
bool ShouldAttachItem(T item) { if (InteractionHelper.GetEnableBehaviorsInDesignTime(AssociatedObject)) { return(true); } if (!InteractionHelper.IsInDesignMode(AssociatedObject)) { return(true); } return(!InteractionHelper.IsInDesignMode(item)); }
public void OkCommand_OnExecute_CompletesInteraction() { var viewModel = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation()); var interaction = new EncryptionPasswordInteraction(false, true, true); var helper = new InteractionHelper <EncryptionPasswordInteraction>(viewModel, interaction); viewModel.OkCommand.Execute(null); Assert.AreEqual(PasswordResult.StorePassword, interaction.Response); Assert.IsTrue(helper.InteractionIsFinished); }
protected ApplicationJumpListService(INativeJumpList nativeJumpList, IJumpActionsManager jumpActionsManager) { IconStorage = CreateDefaultIconStorage(); jumpList = new ApplicationJumpList(this); Items = new ApplicationJumpItemCollectionInternal(this); if (InteractionHelper.IsInDesignMode(this)) { return; } this.nativeJumpList = nativeJumpList ?? currentNativeJumpList; this.jumpActionsManager = jumpActionsManager ?? JumpActionsManager.Current; }
public void TestEnableBehaviorsInDesignTime() { ViewModelDesignHelper.IsInDesignModeOverride = true; var b = new TestBehaviorNotAllowAttachInDesignMode(); var border = new Border(); InteractionHelper.SetEnableBehaviorsInDesignTime(border, true); var button = new Button(); border.Child = button; CheckAttach(b, button); }
/// <summary> /// Initializes a new instance of the RepeatButton class. /// </summary> public RepeatButton () { ClickMode = ClickMode.Press; Delay = 500; Interval = 33; this.DefaultStyleKey = typeof (RepeatButton); Interaction = new InteractionHelper (this); }
/// <summary> /// Initializes a new instance of the /// <see cref="T:Microsoft.Silverlight.Testing.Controls.TreeView" /> class. /// </summary> public TreeView() { DefaultStyleKey = typeof(TreeView); ItemsControlHelper = new ItemsControlHelper(this); Interaction = new InteractionHelper(this); }
/// <summary> /// Initializes a new instance of the UpDownBase class. /// </summary> internal UpDownBase() { DefaultStyleKey = typeof(UpDownBase); Interaction = new InteractionHelper(this); }
/// <summary> /// Initializes a new instance of the /// <see cref="T:Microsoft.Silverlight.Testing.Controls.TreeViewItem" /> class. /// </summary> public TreeViewItem() { DefaultStyleKey = typeof(TreeViewItem); Interaction = new InteractionHelper(this); }
/// <summary> /// Initializes a new instance of the <see cref="Accordion"/> class. /// </summary> public Accordion() { DefaultStyleKey = typeof(Accordion); ItemsControlHelper = new ItemsControlHelper(this); ObservableCollection<object> items = new ObservableCollection<object>(); ObservableCollection<int> indices = new ObservableCollection<int>(); SelectedItems = items; SelectedIndices = indices; items.CollectionChanged += OnSelectedItemsCollectionChanged; indices.CollectionChanged += OnSelectedIndicesCollectionChanged; _scheduledActions = new List<AccordionItem>(); SizeChanged += OnAccordionSizeChanged; Interaction = new InteractionHelper(this); }
/// <summary> /// Initializes a new instance of the ButtonSpinner class. /// </summary> public ButtonSpinner() : base() { DefaultStyleKey = typeof(ButtonSpinner); Interaction = new InteractionHelper(this); }
/// <summary> /// Initializes a new instance of the /// <see cref="T:ModernUI.ExtendedToolkit.AutoCompleteBox" /> class. /// </summary> public AutoCompleteBox() { #if SILVERLIGHT DefaultStyleKey = typeof(AutoCompleteBox); Loaded += (sender, e) => ApplyTemplate(); #endif IsEnabledChanged += ControlIsEnabledChanged; Interaction = new InteractionHelper(this); // Creating the view here ensures that View is always != null ClearView(); }