void UpdateOutput() { for (int i = 0; i < 5; i++) { int index = i + 1; TextBox outputName = (TextBox)RootGrid.FindName("Name" + index); TextBox outputSurname = (TextBox)RootGrid.FindName("Surname" + index); TextBox outputBirthYear = (TextBox)RootGrid.FindName("BirthYear" + index); TextBox outputEducation = (TextBox)RootGrid.FindName("Education" + index); TextBox outputWorkPosition = (TextBox)RootGrid.FindName("WorkPosition" + index); TextBox outputSalary = (TextBox)RootGrid.FindName("Salary" + index); Button deleteButton = (Button)RootGrid.FindName("Delete" + index); if (i < Employees.Count) { outputName.Text = Employees[i].Name; outputSurname.Text = Employees[i].Surname; outputBirthYear.Text = Employees[i].BirthYear.ToString(); outputEducation.Text = Employees[i].Education; outputWorkPosition.Text = Employees[i].WorkPosition; outputSalary.Text = Employees[i].Salary.ToString(); deleteButton.Visibility = Visibility.Visible; } else { outputName.Text = ""; outputSurname.Text = ""; outputBirthYear.Text = ""; outputEducation.Text = ""; outputWorkPosition.Text = ""; outputSalary.Text = ""; deleteButton.Visibility = Visibility.Hidden; } } }
public async Task SetLayout(SettingsModel sm) { lock (_syncRootLayout) { _currentLayout = new RootGrid(); _currentLayout.elements = new List <Element>(); int currRow = 0; if (sm.ShutdownControlEnabled) { _currentLayout.elements.Add(new Button { id = _elementIds[Elements.ButtonShutdown], column = 0, row = currRow++, row_weight = 0.5f, column_weight = 0.5f, text = "Shutdown" }); } if (sm.VolumeControlEnabled) { _currentLayout.elements.Add(new Label { id = "labelVolume", column = 0, row = currRow, row_weight = 2.0f, column_weight = 1.0f, text = "Volume:" }); _currentLayout.elements.Add(new Slider { id = _elementIds[Elements.SliderVolume], column = 1, row = currRow++, min = 0, max = 100, step_size = 3, row_weight = 2.0f, column_weight = 3.0f, progress = VolumeModel.Instance.Volume }); } } if (_anperi.HasControl && _anperi.IsPeripheralConnected) { RootGrid grid; lock (_syncRootLayout) { grid = _currentLayout; } await _anperi.SetLayout(grid, Anperi.ScreenOrientation.portrait).ConfigureAwait(false); } }
private void CreateBindings() { ImageGrid.SetBinding(ToolTipProperty, new Binding("ItemTooltip") { Source = _model, Mode = BindingMode.OneWay }); Label.SetBinding(ContentProperty, new Binding("TransformationLabel") { Source = _model, Mode = BindingMode.OneWay }); RootGrid.SetBinding(VisibilityProperty, new Binding("Visibility") { Source = _model, Mode = BindingMode.OneWay }); Ring.SetBinding(VisibilityProperty, new Binding("RingVisibility") { Source = _model, Mode = BindingMode.OneWay }); }
/// <summary> /// Called when a Mouse Button is pressed on the parent <see cref="SciChartSurface"/> /// </summary> /// <param name="e">Arguments detailing the mouse button operation</param> /// <remarks></remarks> public override void OnModifierMouseDown(ModifierMouseArgs e) { base.OnModifierMouseDown(e); if (_isDragging || !MatchesExecuteOn(e.MouseButtons, ExecuteOn)) { return; } // Exit if the mouse down was outside the bounds of the ModifierSurface if (e.IsMaster && !ModifierSurface.GetBoundsRelativeTo(ModifierSurface).Contains(e.MousePoint)) { return; } e.Handled = true; ModifierSurface.CaptureMouse(); // Translate the mouse point (which is in RootGrid coordiantes) relative to the ModifierSurface // This accounts for any offset due to left Y-Axis Point ptTrans = RootGrid.TranslatePoint(e.MousePoint, ModifierSurface); _startPoint = ptTrans; _rectangle = new Rect(); SetPosition(_startPoint, _startPoint); _isDragging = true; }
bool IsEverythingFilledOut() { bool result = true; foreach (Label ErrorLabel in ErrorLabels) { string controlName = ErrorLabel.Name.Remove(ErrorLabel.Name.IndexOf("Error")); if (!ErrorLabel.Name.ToLower().Contains("education")) { TextBox TBToCheck = (TextBox)RootGrid.FindName(controlName); if (TBToCheck.Name.ToLower().Contains("birth") || TBToCheck.Name.ToLower().Contains("salary")) { try { Convert.ToInt32(TBToCheck.Text); if (TBToCheck.Name.ToLower().Contains("birth")) { if (TBToCheck.Text.Trim().Length != 4) { result = false; } } else { if (TBToCheck.Text.Trim().Length < 4) { result = false; } } } catch { result = false; } } else { if (TBToCheck.Text.Trim().Length < 3) { result = false; } } } else { ComboBox CBToCheck = (ComboBox)RootGrid.FindName(controlName); if (CBToCheck.Text == "") { result = false; } } if (ErrorLabel.IsVisible) { result = false; } } return(result); }
private void Initialize() { // Show the window in normal state WindowState = WindowState.Normal; ServiceInjector.InjectServices(); _coreViewModel = new CoreViewModel(); DataContext = _coreViewModel; _coreViewModel.InitializeEnvironmentVariables(); switch (_coreViewModel.InitResult) { case InitResultType.InitOk: break; case InitResultType.AccessDenied: MessageBox.Show("Cannot access Environment variables! Please restart NVM# as an Administrator.", "NVM#"); Application.Current.Shutdown(); break; case InitResultType.OtherError: MessageBox.Show("NVM# encountered an error and needs to close!", "NVM#"); Application.Current.Shutdown(); break; } UserButton.IsChecked = true; SizeChanged += (o, a) => { switch (WindowState) { case WindowState.Maximized: SplitViewMenu.Width = (int)SplitViewMenuWidth.Wide; break; case WindowState.Normal: SplitViewMenu.Width = (int)SplitViewMenuWidth.Narrow; break; } RootGrid.ColumnDefinitions[0] = new ColumnDefinition { Width = new GridLength(SplitViewMenu.Width) }; RootGrid.InvalidateVisual(); }; // Enable the tooltip for SplitView menu buttons only if the SplitView width is narrow SplitViewMenu.SizeChanged += (o, a) => { var isNarrowMenu = (int)SplitViewMenu.Width == (int)SplitViewMenuWidth.Narrow; ToolTipService.SetIsEnabled(UserButton, isNarrowMenu); ToolTipService.SetIsEnabled(SystemButton, isNarrowMenu); ToolTipService.SetIsEnabled(ImportButton, isNarrowMenu); ToolTipService.SetIsEnabled(ExportButton, isNarrowMenu); ToolTipService.SetIsEnabled(AboutButton, isNarrowMenu); }; }
private void MainWindow_OnKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) { var flyout = RootGrid.GetVisualDescendents().FirstOrDefault(c => c is FlyoutControl) as FlyoutControl; if (flyout != null) { flyout.Close(); } } }
public LoadingControl() { this.InitializeComponent(); this.SizeChanged += LoadingControl_SizeChanged; _compositor = RootGrid.GetVisual().Compositor; _rootVisual = RootGrid.GetVisual(); _e1Visual = E1.GetVisual(); _e2Visual = E2.GetVisual(); Start(); }
private async void OpenFile(object sender, RoutedEventArgs e) { var resourceLoader = new ResourceLoader(); var popupMenu = new PopupMenu(); popupMenu.Commands.Add(new UICommand(resourceLoader.GetString("OpenVideo"), h => OpenVideo())); var transform = RootGrid.TransformToVisual(this); var point = transform.TransformPoint(new Point(Window.Current.Bounds.Width - 110, 200)); await popupMenu.ShowAsync(point); }
public async void CreateVLCMenu() { var resourceLoader = new ResourceLoader(); var popupMenu = new PopupMenu(); popupMenu.Commands.Add(new UICommand(resourceLoader.GetString("PrivacyStatement"), async h => await ExternalStorage())); popupMenu.Commands.Add(new UICommand("Media servers", async h => await MediaServers())); var transform = RootGrid.TransformToVisual(this); var point = transform.TransformPoint(new Point(270, 110)); await popupMenu.ShowAsync(point); }
void OnDropDownClosed(object sender, EventArgs e) { ComboBox SenderCB = (ComboBox)sender; Label ErrorLabel = (Label)RootGrid.FindName(SenderCB.Name + "Error"); if (SenderCB.Text == "") { ErrorLabel.Visibility = Visibility.Visible; } else if (SenderCB.Text != "" && ErrorLabel.IsVisible) { ErrorLabel.Visibility = Visibility.Hidden; } ButtonAddEmployee.IsEnabled = IsEverythingFilledOut(); }
private void ClearAllScenes() { RootGrid.BeginInit(); for (var i = RootGrid.Children.Count - 1; i >= 0; i--) { var oneChild = RootGrid.Children[i]; if (!ReferenceEquals(oneChild, SettingsBorder) && !ReferenceEquals(oneChild, TitleTextBlock)) { RootGrid.Children.Remove(oneChild); } } RootGrid.EndInit(); }
/// <summary> /// Called when the Mouse is moved on the parent <see cref="SciChartSurface"/> /// </summary> /// <param name="e">Arguments detailing the mouse move operation</param> /// <remarks></remarks> public override void OnModifierMouseMove(ModifierMouseArgs e) { if (!_isDragging) { return; } base.OnModifierMouseMove(e); e.Handled = true; // Translate the mouse point (which is in RootGrid coordiantes) relative to the ModifierSurface // This accounts for any offset due to left Y-Axis Point ptTrans = RootGrid.TranslatePoint(e.MousePoint, ModifierSurface); SetPosition(_startPoint, ptTrans); UpdateSurface(); }
public async void Init(MoeItem moeitem, ImageSource imgSource) { CurrentMoeItem = moeitem; Settings = moeitem.Site.Settings; var info = CurrentMoeItem.Urls.GetPreview(); if (info == null) { return; } RootGrid.GoElementState(nameof(LoadingBarShowState)); ImageLoadProgressBar.Value = 0; await LoadImageAsync(); RootGrid.GoElementState(nameof(LoadingBarHideState)); InitImagePosition(); }
public void LostFocus(object sender, RoutedEventArgs eventArgs) { TextBox SenderTB = new TextBox(); SenderTB = (TextBox)sender; Label ErrorLabel = (Label)RootGrid.FindName(SenderTB.Name + "Error"); if (SenderTB.Text.Trim().Length < 3) { ErrorLabel.Visibility = Visibility.Visible; } else if (SenderTB.Name.ToLower().Contains("birth") || SenderTB.Name.ToLower().Contains("salary")) { try { Convert.ToInt32(SenderTB.Text); ErrorLabel.Visibility = Visibility.Visible; if (SenderTB.Name.ToLower().Contains("birth")) { if (SenderTB.Text.Trim().Length == 4) { ErrorLabel.Visibility = Visibility.Hidden; } } else { if (SenderTB.Text.Trim().Length >= 4) { ErrorLabel.Visibility = Visibility.Hidden; } } } catch { ErrorLabel.Visibility = Visibility.Visible; } } else if (ErrorLabel.IsVisible) { ErrorLabel.Visibility = Visibility.Hidden; } ButtonAddEmployee.IsEnabled = IsEverythingFilledOut(); }
/// <summary> /// 显示对话框 /// </summary> /// <param name="contentDialog">ContentDialog</param> public static async void ShowDialog(ContentDialog contentDialog) { ShowedDialog?.Hide(); ShowedDialog = contentDialog; contentDialog.Closed += async delegate { await RootGrid.Blur(0, 0).StartAsync(); contentDialog.Hide(); }; contentDialog.PrimaryButtonClick += async delegate { await RootGrid.Blur(0, 0).StartAsync(); contentDialog.Hide(); }; await RootGrid.Blur(7, 100).StartAsync(); await contentDialog.ShowAsync(); }
static void Main(string[] args) { Trace.Listeners.Add(new ConsoleTraceListener()); Anperi anperi = new Anperi(); anperi.Message += Anperi_Message; bool exit = false; while (!exit) { Console.WriteLine("type a line to do stuff: periinf, perilay"); string text = Console.ReadLine(); anperi.ClaimControl(); switch (text) { case "periinf": anperi.RequestPeripheralInfo(); break; case "perilay": RootGrid rg = new RootGrid(); int rnd = new Random().Next(1, 10); for (int i = 0; i < rnd; i++) { rg.elements.Add(new Button { column = 1, row = i, id = i, text = "button_" + i }); } anperi.SetLayout(rg); break; case "exit": exit = true; break; } } }
async void RowTapped(object sender, ItemTappedEventArgs e) { var item = e.Item as ImageInfo; _lightbox = new Image { WidthRequest = 100, HeightRequest = 100, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Opacity = 0, Source = item.Text }; _lightbox.GestureRecognizers.Add(new TapGestureRecognizer { NumberOfTapsRequired = 1, Command = new Command(CloseLightBox) }); RootGrid.Children.Add(_lightbox); RootGrid.ForceLayout(); _origBounds = _lightbox.Bounds; var fadeIn = _lightbox.FadeTo(1.0); var zoomIn = _lightbox.LayoutTo(RootGrid.Bounds); await Task.WhenAll(new[] { fadeIn, zoomIn }); }
public MainPage() { InitializeComponent(); // Observe slider zooms and window resizes var zooms = ZoomSlider.ObserveDependencyProperty <double>(RangeBase.ValueProperty).Select(n => (int)n); var resizes = RootGrid.ObserveEvent <SizeChangedEventArgs>(nameof(RootGrid.SizeChanged)); // Save the zoom level to settings after it hasn't changed for a while zooms.Throttle(TimeSpan.FromSeconds(1)).UiSubscribe(SaveCurrentZoom); // Resize the webview when the slider changes or the window resizes (with very mild debounce) zooms.DistinctUntilChanged() .CombineLatest(resizes, (n, _) => n) .Throttle(TimeSpan.FromMilliseconds(10)) .UiSubscribe(ResizeWebView); // Set the initial zoom (default 1000) ZoomSlider.Value = ApplicationData.Current.LocalSettings.Values["SliderZoom"] as int? ?? 1000; }
public MainWindow() { InitializeComponent(); InitializeSprocketControls(); _brushes = new Brush[] { new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4cd964")), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#007aff")), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff9600")), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff2d55")), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#5856d6")), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ffcc00")), new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8e8e93")), }; SizeChanged += (o, a) => { switch (WindowState) { case WindowState.Maximized: SplitViewMenu.Width = (int)SplitViewMenuWidth.Wide; break; case WindowState.Normal: SplitViewMenu.Width = (int)SplitViewMenuWidth.Narrow; break; } RootGrid.ColumnDefinitions[0] = new ColumnDefinition { Width = new GridLength(SplitViewMenu.Width) }; RootGrid.InvalidateVisual(); }; // Enable the tooltip for SplitView menu buttons only if the SplitView width is narrow SplitViewMenu.SizeChanged += (o, a) => { var isNarrowMenu = (int)SplitViewMenu.Width == (int)SplitViewMenuWidth.Narrow; ToolTipService.SetIsEnabled(SprocketButton, isNarrowMenu); ToolTipService.SetIsEnabled(ToggleSwitchButton, isNarrowMenu); ToolTipService.SetIsEnabled(FWPButton, isNarrowMenu); ToolTipService.SetIsEnabled(SparkWindowButton, isNarrowMenu); ToolTipService.SetIsEnabled(FPPButton, isNarrowMenu); ToolTipService.SetIsEnabled(FPBButton, isNarrowMenu); ToolTipService.SetIsEnabled(FSBButton, isNarrowMenu); }; Loaded += (s, e) => { DataContext = this; SprocketButton.IsChecked = true; OrientationCB.ItemsSource = new List <string> { "Horizontal", "Vertical" }; OrientationCB.SelectedIndex = 0; }; InitializeFluidPivotPanel(); InitializeFluidProgressBars(); }
private void AssignDataProvider_Click(object sender, RoutedEventArgs e) { RootGrid.Initialize(new DataProvider(1000, 1000)); }
private void AssignSmallProvider_Click(object sender, RoutedEventArgs e) { RootGrid.Initialize(new DataProvider(3, 2)); }