protected virtual void OnElementChanged(ElementChangedEventArgs <Label> e) { ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement)); if (e.OldElement != null) { e.OldElement.PropertyChanged -= OnElementPropertyChanged; } if (e.NewElement != null) { this.EnsureId(); if (_visualElementTracker == null) { _visualElementTracker = new VisualElementTracker(this); } e.NewElement.PropertyChanged += OnElementPropertyChanged; SkipNextInvalidate(); UpdateText(); UpdateLineHeight(); UpdateTextDecorations(); if (e.OldElement?.LineBreakMode != e.NewElement.LineBreakMode) { UpdateLineBreakMode(); } if (e.OldElement?.HorizontalTextAlignment != e.NewElement.HorizontalTextAlignment || e.OldElement?.VerticalTextAlignment != e.NewElement.VerticalTextAlignment) { UpdateGravity(); } if (e.OldElement?.MaxLines != e.NewElement.MaxLines) { UpdateMaxLines(); } UpdatePadding(); ElevationHelper.SetElevation(this, e.NewElement); } }
void OnElementChanged(ElementChangedEventArgs <Button> e) { if (e.NewElement != null && !_isDisposed) { this.EnsureId(); _textColorSwitcher = new Lazy <TextColorSwitcher>( () => new TextColorSwitcher(TextColors, e.NewElement.UseLegacyColorManagement())); UpdateFont(); UpdateText(); UpdateBitmap(); UpdateTextColor(); UpdateIsEnabled(); UpdateInputTransparent(); UpdateBackgroundColor(); ElevationHelper.SetElevation(this, e.NewElement); } ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement)); }
void OnElementChanged(ElementChangedEventArgs <Button> e) { if (e.OldElement != null) { _backgroundTracker?.Reset(); } if (e.NewElement != null && !_isDisposed) { this.EnsureId(); UpdateFont(); UpdateText(); UpdateBitmap(); UpdateTextColor(); UpdateIsEnabled(); UpdateInputTransparent(); UpdateBackgroundColor(); UpdateDrawable(); ElevationHelper.SetElevation(this, e.NewElement); } ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(e.OldElement, e.NewElement)); }
private void MenuButton_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(txtTargetComputer.Text)) { return; } var selectedButton = sender as Button; SetMenuColors(selectedButton); SelectedItem.Text = selectedButton.Content.ToString(); SelectedTarget.Text = txtTargetComputer.Text; SelectedTarget.Visibility = Visibility.Visible; txtTargetComputer.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#000000")); switch (SelectedItem.Text) { case "System Info": contentControl.Content = new SystemInfoView(txtTargetComputer.Text.Trim()); break; case "Processes": // Elevate the process if targeting local computer and is not run as administrator. if (txtTargetComputer.Text == Environment.MachineName && !ElevationHelper.IsRunAsAdmin()) { // Launch itself as administrator ProcessStartInfo proc = new ProcessStartInfo(); proc.UseShellExecute = true; proc.WorkingDirectory = Environment.CurrentDirectory; proc.FileName = System.Reflection.Assembly.GetExecutingAssembly().Location; proc.Verb = "runas"; proc.Arguments = "Elevate Processes"; try { Process.Start(proc); } catch { // The user refused the elevation. // Do nothing and return directly ... contentControl.Content = new ProcessesView(txtTargetComputer.Text.Trim()); break; } Application.Current.Shutdown(); } else { contentControl.Content = new ProcessesView(txtTargetComputer.Text.Trim()); } break; case "Services": contentControl.Content = new ServicesView(txtTargetComputer.Text.Trim()); break; case "Networking": contentControl.Content = new NetworkingView(txtTargetComputer.Text.Trim()); break; case "Storage": contentControl.Content = new StorageView(txtTargetComputer.Text.Trim()); break; case "Applications": contentControl.Content = new ApplicationsView(txtTargetComputer.Text.Trim()); break; case "Updates": contentControl.Content = new UpdatesView(txtTargetComputer.Text.Trim()); break; case "Users": contentControl.Content = new LogonSessionsView(txtTargetComputer.Text.Trim()); break; case "Tasks": SelectedTarget.Visibility = Visibility.Collapsed; contentControl.Content = new TasksView(); break; case "Bulk Query": SelectedTarget.Visibility = Visibility.Collapsed; txtTargetComputer.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#999")); contentControl.Content = _BulkQueryView; break; default: MessageBox.Show("Button not defined."); break; } }
private void setVersionSettings(ServerVersionId serverVersion) { // _view.ToolTipManager.Enabled = false; _view.ToolTipManager.ResetUltraToolTip(_view.cboVendors); _view.ToolTipManager.HideToolTip(); _currentVersion = serverVersion; if (serverVersion == ServerVersionId.SQLite_3) { _view.chkWindowsAuthentication.Checked = false; _view.chkWindowsAuthentication.Enabled = false; _view.txtServer.Enabled = false; _view.txtServer.Width = 100; _view.txtUser.Enabled = false; _view.txtPassword.Enabled = false; setFileBasedDb(true, true, true); if (_view.txtServer.Text.Equals(".")) { _view.txtServer.Text = ""; } } else if (serverVersion == ServerVersionId.FireBird_2) { _view.chkWindowsAuthentication.Checked = false; _view.chkWindowsAuthentication.Enabled = false; _view.txtServer.Enabled = false; _view.txtServer.Width = 100; _view.txtUser.Enabled = false; _view.txtPassword.Enabled = false; setFileBasedDb(true, true, true); if (_view.txtServer.Text.Equals(".")) { _view.txtServer.Text = ""; } if (!ElevationHelper.IsAdmin()) { // TODO specify with privilege we need var ctrl = _view.cboVendors; UltraToolTipInfo tip = _view.ToolTipManager.GetUltraToolTip(ctrl); if (string.IsNullOrEmpty(tip.ToolTipText)) { var info = new UltraToolTipInfo("Requires elevation, please restart SQL8r with more privileges", ToolTipImage.Warning, "Warning", DefaultableBoolean.Default); _view.ToolTipManager.SetUltraToolTip(ctrl, info); } _view.ToolTipManager.ShowToolTip(ctrl, ctrl.PointToScreen(ctrl.Location)); } } else if (serverVersion == ServerVersionId.ODBC_Access || serverVersion == ServerVersionId.ODBC_Excel) { _view.chkWindowsAuthentication.Checked = false; _view.chkWindowsAuthentication.Enabled = false; _view.txtServer.Enabled = false; _view.txtServer.Width = 100; _view.txtUser.Enabled = false; _view.txtPassword.Enabled = false; setFileBasedDb(true, false, true); if (_view.txtServer.Text.Equals(".")) { _view.txtServer.Text = ""; } } else if (serverVersion == ServerVersionId.MySql_5) { _view.chkWindowsAuthentication.Checked = false; _view.chkWindowsAuthentication.Enabled = false; _view.txtServer.Enabled = true; _view.txtServer.Width = _view.txtDatabase.Width; _view.txtUser.Enabled = true; _view.txtPassword.Enabled = true; setFileBasedDb(false, false, false); } else if (serverVersion == ServerVersionId.SqlServer_2005 || serverVersion == ServerVersionId.SqlServer_2008) { _view.chkWindowsAuthentication.Enabled = true; _view.chkWindowsAuthentication.Checked = true; _view.txtServer.Enabled = true; _view.txtServer.Width = _view.txtDatabase.Width; _view.txtUser.Enabled = false; _view.txtPassword.Enabled = false; setFileBasedDb(false, false, false); if (string.IsNullOrEmpty(_view.txtServer.Text)) { _view.txtServer.Text = "."; } } else { throw new SQL8rException(string.Format("Unsupported ServerVersionId: {0}", serverVersion)); } }
public Color GetBrandedSurfaceColor(ElevationLevel elevation) { var opacity = ElevationHelper.GetOverlayOpacity(elevation); return(ColorHelper.CombineColors(BrandedBackground, Color.White, opacity)); }