public static void Remove(this WidgetId id, bool msg = false) { var settings = id.GetSettings(); if (settings == null) { return; } if (msg && Popup.Show($"Are you sure you want to delete \"{settings.Name}\"?", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes) == MessageBoxResult.No) { return; } settings.Backup(); App.WidgetsSettingsStore.Widgets.Remove(settings); var view = id.GetView(); if (view != null) { view.Close(); App.WidgetViews.Remove(view); } }
public static void Edit(this WidgetId id, bool dismiss = false) { var settings = id.GetSettings(); if (settings == null) { return; } var view = id.GetView(); var name = id.GetName(); var previousHorizontalAlignment = settings.HorizontalAlignment; var previousVerticalAlignment = settings.VerticalAlignment; var previousIsDocked = settings.IsDocked; if (dismiss) { view?.Dismiss(); } new WidgetEditor(name, settings).ShowDialog(); if (view != null && !view.IsClosed) { view.UpdateUi(isDocked: previousIsDocked, dockHorizontalAlignment: previousHorizontalAlignment, dockVerticalAlignment: previousVerticalAlignment); } }
public void MenuItem(string itemText, Action itemSelected) { if (m_currentMenu == null) { return; } // menu isn't open, don't worry about items if (m_activeWidget == null || m_activeWidget.Value != new WidgetId(m_currentMenu.Title, WidgetId.ParentKind.MenuBar)) { return; } var id = new WidgetId($"{ m_currentMenu.Title }|{ itemText }", WidgetId.ParentKind.MenuBar); if (!m_currentMenu.MenuItems.TryGetValue(id, out var item)) { item = new MenuItemData(itemText); m_currentMenu.MenuItems[id] = item; } item.UsedThisFrame = true; item.Callback = itemSelected; item.Index = m_currentMenu.CurrentMenuItemIndex++; }
private void RegisterGizmoHandlers(Gizmo gizmo, WidgetId widgetId) { RegisterHighlightable(gizmo, widgetId); gizmo.OnGizmoDragStart += g => NotifyMouseUnavailability(); gizmo.OnGizmoDragEnd += g => NotifyMouseAvailability(); }
public void TestCtor() { var guid = Guid.NewGuid(); var id = new WidgetId(guid); id.Value.Should().Be(guid); }
protected WidgetViewModelBase(WidgetId id) { Id = id; _settings = id.GetSettings(); DismissWidget = new RelayCommand(DismissWidgetExecute); EditWidget = new RelayCommand(EditWidgetExecute); ReloadWidget = new RelayCommand(ReloadWidgetExecute); DisableWidget = new RelayCommand(DisableWidgetExecute); MuteWidget = new RelayCommand(MuteWidgetExecute); MuteUnmuteWidget = new RelayCommand(MuteUnmuteWidgetExecute); ManageAllWidgets = new RelayCommand(ManageAllWidgetsExecute); MouseMove = new RelayCommand <MouseEventArgs>(MouseMoveExecute); MouseDown = new RelayCommand <MouseButtonEventArgs>(MouseDownExecute); MouseUp = new RelayCommand <MouseButtonEventArgs>(MouseUpExecute); KeyDown = new RelayCommand <KeyEventArgs>(KeyDownExecute); KeyUp = new RelayCommand <KeyEventArgs>(KeyUpExecute); PreviewKeyDown = new RelayCommand <KeyEventArgs>(PreviewKeyDownExecute); PreviewKeyUp = new RelayCommand <KeyEventArgs>(PreviewKeyUpExecute); MouseDoubleClick = new RelayCommand <MouseButtonEventArgs>(MouseDoubleClickExecute); WidgetDockHorizontal = new RelayCommand <HorizontalAlignment>(WidgetDockHorizontalExecute); WidgetDockVertical = new RelayCommand <VerticalAlignment>(WidgetDockVerticalExecute); WidgetUndock = new RelayCommand(WidgetUndockExecute); }
public ViewModel(WidgetId id) : base(id) { Settings = id.GetSettings() as Settings; if (Settings == null) { return; } IconCache = new Dictionary <string, ImageSource>(); Refresh = new RelayCommand(RefreshExecute); NewShortcut = new RelayCommand(NewShortcutExecute); NewSeparator = new RelayCommand(NewSeparatorExecute); ShortcutFocus = new RelayCommand <Shortcut>(ShortcutFocusExecute); ShortcutEdit = new RelayCommand(ShortcutEditExecute); ShortcutRemove = new RelayCommand(ShortcutRemoveExecute); ShortcutOpenFolder = new RelayCommand(ShortcutOpenFolderExecute); ShortcutExecute = new RelayCommand <Shortcut>(ShortcutExecuteExecute); if (Settings.DefaultShortcutsMode != DefaultShortcutsMode.DontChange) { Settings.Shortcuts = new ObservableCollection <Shortcut>(ShortcutHelper.GetDefaultShortcuts(Settings.DefaultShortcutsMode)); Settings.DefaultShortcutsMode = DefaultShortcutsMode.DontChange; } }
private void SetNotActive(WidgetId id) { if (m_activeWidget.HasValue && m_activeWidget.Value == id) { m_activeWidget = null; } }
private void SetNotHot(WidgetId id) { if (m_hotWidget.HasValue && m_hotWidget.Value == id) { m_hotWidget = null; } }
public ViewModel(WidgetId id) : base(id) { Settings = id.GetSettings() as Settings; if (Settings == null) { } }
protected WidgetViewModelBase(WidgetId id) { Id = id; _settings = id.GetSettings(); DismissWidget = new RelayCommand(DismissWidgetExecute); EditWidget = new RelayCommand(EditWidgetExecute); ReloadWidget = new RelayCommand(ReloadWidgetExecute); ToggleEnableWidget = new RelayCommand(ToggleEnableWidgetExecute); MuteWidget = new RelayCommand(MuteWidgetExecute); MuteUnmuteWidget = new RelayCommand(MuteUnmuteWidgetExecute); ManageAllWidgets = new RelayCommand(ManageAllWidgetsExecute); Drop = new RelayCommand<DragEventArgs>(DropExecute); MouseMove = new RelayCommand<MouseEventArgs>(MouseMoveExecute); MouseDown = new RelayCommand<MouseButtonEventArgs>(MouseDownExecute); MouseUp = new RelayCommand<MouseButtonEventArgs>(MouseUpExecute); KeyDown = new RelayCommand<KeyEventArgs>(KeyDownExecute); KeyUp = new RelayCommand<KeyEventArgs>(KeyUpExecute); PreviewKeyDown = new RelayCommand<KeyEventArgs>(PreviewKeyDownExecute); PreviewKeyUp = new RelayCommand<KeyEventArgs>(PreviewKeyUpExecute); MouseDoubleClick = new RelayCommand<MouseButtonEventArgs>(MouseDoubleClickExecute); WidgetDockHorizontal = new RelayCommand<HorizontalAlignment>(WidgetDockHorizontalExecute); WidgetDockVertical = new RelayCommand<VerticalAlignment>(WidgetDockVerticalExecute); WidgetUndock = new RelayCommand(WidgetUndockExecute); }
private bool IsHot(WidgetId id) { if (m_hotWidget == null) { return(false); } return(m_hotWidget.Value == id); }
public ViewModel(WidgetId guid) : base(guid) { Settings = guid.GetSettings() as Settings; if (Settings == null) { return; } }
private bool IsActive(WidgetId id) { if (m_activeWidget == null) { return(false); } return(m_activeWidget.Value == id); }
public static string GetName(this WidgetId id) { var settings = id.GetSettings(); var index = App.WidgetsSettingsStore.Widgets.IndexOf(settings); var name = settings.Name == "" ? $"Widget {index + 1}" : settings.Name; return($"{name} ({id.GetFriendlyName()})"); }
private void SetHot(WidgetId id) { // don't set something as hot if there's an active widget. if (m_activeWidget != null) { return; } m_hotWidget = id; }
private void RegisterHighlightable(IHighlightable highlightable, WidgetId widgetId) { highlightable.OnHighlight += () => { _selectedWidget.Set(widgetId); }; highlightable.OnUnHighlight += () => { _selectedWidget.Set(null); }; }
public ViewModel(WidgetId id) : base(id, false) { Settings = id.GetSettings() as Settings; if (Settings == null) { return; } StartStopCommand = new RelayCommand(StartStop); StartTime = CurrentTime; }
public ViewModel(WidgetId id) : base(id) { Settings = id.GetSettings() as Settings; if (Settings == null) { return; } Go = new RelayCommand(GoExecute); OnKeyUp = new RelayCommand <KeyEventArgs>(OnKeyUpExecute); }
public static void ToggleMute(this WidgetId id, TimeSpan duration) { if (id.IsMuted()) { id.Unmute(); } else { id.Mute(duration); } }
public static WidgetSettingsBase Clone(this WidgetId id) { var newWidget = SettingsHelper.CloneObject(id.GetSettings()) as WidgetSettingsBase; if (newWidget != null) { newWidget.Identifier.GenerateNewGuid(); AddNewWidget(newWidget); } return(newWidget); }
public ClockViewModelBase(WidgetId id, bool startTicking = true) : base(id) { _settings = id.GetSettings() as WidgetClockSettingsBase; if (_settings == null) return; _clockUpdateTimer = new DispatcherTimer(); _clockUpdateTimer.Tick += (sender, args) => UpdateCurrentTime(); UpdateCurrentTime(); if (startTicking) StartClockUpdateTimer(); }
public bool TryReadAttribute(string name, out WidgetId value) { Guid tmp; if (!TryReadAttribute(name, out tmp)) { value = default(WidgetId); return(false); } value = new WidgetId(tmp); return(true); }
public void EndMenu() { var id = new WidgetId(m_currentMenu.Title, WidgetId.ParentKind.MenuBar); m_currentMenu.RemoveAllUnused(); if (IsActive(id)) { var items = from item in m_currentMenu.MenuItems.Values orderby item.Index select item; int yCur = 0; // TODO(local): calculate width int width = 200; foreach (var item in items) { int itemHeight = 22; int y = 23 + yCur; yCur += itemHeight; if (RegionHovered(null, m_currentMenu.X + 3, y, width, itemHeight)) { if (Mouse.IsPressed(MouseButton.Left)) { item.Callback?.Invoke(); } m_grq.DrawRect(Transform.Translation(m_currentMenu.X + 3, y, 2), new Rect(0, 0, width, itemHeight), Texture.Empty, new Vector4(144 / 255.0f, 200 / 255.0f, 246 / 255.0f, 1)); } } m_grq.DrawRect(Transform.Translation(m_currentMenu.X, 20, 1), new Rect(0, 0, width + 6, yCur + 6), Texture.Empty, new Vector4(204 / 255.0f, 204 / 255.0f, 204 / 255.0f, 1)); m_grq.DrawRect(Transform.Translation(m_currentMenu.X + 1, 21, 1), new Rect(0, 0, width + 4, yCur + 4), Texture.Empty, new Vector4(242 / 255.0f, 242 / 255.0f, 242 / 255.0f, 1)); } if (m_currentMenu.MarkInactive) { SetNotActive(id); } m_currentMenu = null; }
public ViewModel(WidgetId id) : base(id) { Settings = id.GetSettings() as Settings; if (Settings == null) { return; } LatencyHistory = new ObservableCollection <TextBlock>(); _lastLatency = -1; _lastDownloadUsage = GetDownloadedBytes(); _lastUploadUsage = GetUploadedBytes(); _scanLatency = true; StartLatencyReader(); }
/// <summary> /// Handles the OnDataBound event of the rrPrompt control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void rrPrompt_OnDataBound(object sender, EventArgs e) { if (rrPrompt.Items.Count == 0) { FindControlRecursive(Page, WidgetId.ToString()).Visible = false; } else if (rrPrompt.Items.Count == 1) { plNavigation.Visible = false; } else { AddNavigationButtons(); } }
public ViewModel(WidgetId id) : base(id) { Settings = id.GetSettings() as Settings; if (Settings == null) { return; } _updateTimer = new DispatcherTimer(); UpdateTimerInterval(); _updateTimer.Tick += async(sender, args) => await UpdateWeatherAsync(); _updateTimer.Start(); Task.Run(async() => await UpdateWeatherAsync()); }
public ClockViewModelBase(WidgetId id, bool startTicking = true) : base(id) { _settings = id.GetSettings() as WidgetClockSettingsBase; if (_settings == null) { return; } _clockUpdateTimer = new DispatcherTimer(); _clockUpdateTimer.Tick += UpdateTimer_Tick; UpdateCurrentTime(); if (startTicking) { StartClockUpdateTimer(); } }
public void TestClone3() { var template = new WidgetTemplate { Id = WidgetId.CreateNew(), AnalyserId = AnalyserId.CreateNew(), LogAnalyserFactoryId = new LogAnalyserFactoryId("Company.Namespace.MyFactory") }; var clone = template.Clone(); clone.Should().NotBeNull(); clone.Should().NotBeSameAs(template); clone.Id.Should().Be(template.Id); clone.AnalyserId.Should().Be(template.AnalyserId); clone.LogAnalyserFactoryId.Should().Be(template.LogAnalyserFactoryId); }
public static void ToggleEnable(this WidgetId id) { var settings = id.GetSettings(); if (settings == null) { return; } if (settings.Disabled) { id.Enable(); } else { id.Disable(); } }
public static void Unmute(this WidgetId id) { var settings = id.GetSettings(); settings.MuteEndTime = DateTime.Now; foreach (var eventPair in App.WidgetsSettingsStore.EventActionPairs) { var evnt = eventPair.Event as WidgetMuteUnmuteEvent; if (evnt == null || eventPair.Disabled || !(evnt.Mode == MuteEventMode.Both || evnt.Mode == MuteEventMode.Unmute)) { continue; } eventPair.Action.Execute(); } }
public ViewModel(WidgetId id) : base(id) { Settings = id.GetSettings() as Settings; if (Settings == null) { return; } NavigateHyperlink = new RelayCommand <RequestNavigateEventArgs>(NavigateHyperlinkExecute); FeedItems = new ObservableCollection <FeedItem>(); UpdateTimer = new DispatcherTimer { Interval = Settings.RefreshInterval }; UpdateTimer.Tick += (sender, args) => UpdateFeed(); UpdateFeed(); UpdateTimer.Start(); }