private void BlankPage_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args) { SettingsCommand cmd = new SettingsCommand("sample", "Sample Custom Setting", (x) => { SettingsFlyout settings = new SettingsFlyout(); settings.FlyoutWidth = (Callisto.Controls.SettingsFlyout.SettingsFlyoutWidth)Enum.Parse(typeof(Callisto.Controls.SettingsFlyout.SettingsFlyoutWidth), settingswidth.SelectionBoxItem.ToString()); //settings.HeaderBrush = new SolidColorBrush(Colors.Orange); //settings.Background = new SolidColorBrush(Colors.White); settings.HeaderText = "Foo Bar Custom Settings"; BitmapImage bmp = new BitmapImage(new Uri("ms-appx:///Assets/SmallLogo.png")); settings.SmallLogoImageSource = bmp; StackPanel sp = new StackPanel(); ToggleSwitch ts = new ToggleSwitch(); ts.Header = "Download updates automatically"; Button b = new Button(); b.Content = "Test"; sp.Children.Add(ts); sp.Children.Add(b); settings.Content = sp; settings.IsOpen = true; ObjectTracker.Track(settings); }); args.Request.ApplicationCommands.Add(cmd); }
public void VectorChanged_BehaviorChangedToNonBehavior_ExceptionThrown() { BehaviorCollection behaviorCollection = new BehaviorCollection(); behaviorCollection.Add(new StubBehavior()); TestUtilities.AssertThrowsException(() => behaviorCollection[0] = new ToggleSwitch()); }
private void ToggleSwitch_Toggled(object sender, RoutedEventArgs e) { ToggleSwitch ToggleSwitchBase = new ToggleSwitch(); ToggleSwitchBase.Header = "Ativado Programaticamente"; ToggleSwitchBase.OnContent = "On"; ToggleSwitchBase.OffContent = "Off"; ToggleSwitchBase.Toggled += ToggleSwitch_Toggled; MeuStackPanel.Children.Add(ToggleSwitchBase); }
private void ToggleProgressBar(ToggleSwitch TGL, HitachiProgress PRG) { if (TGL == null) return; if (TGL.IsOn == true) PRG.IsActive = true; else PRG.IsActive = false; }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///PreferenceUserControl.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); Remember = (Windows.UI.Xaml.Controls.ToggleSwitch) this.FindName("Remember"); }
public void InitializeComponent() { if (_contentLoaded) return; _contentLoaded = true; Application.LoadComponent(this, new System.Uri("ms-appx:///MainPage.xaml"), Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application); progressBar = (Windows.UI.Xaml.Controls.ProgressBar)this.FindName("progressBar"); DesktopArrows = (Windows.UI.Xaml.Controls.ToggleSwitch)this.FindName("DesktopArrows"); MetroStart = (Windows.UI.Xaml.Controls.ToggleSwitch)this.FindName("MetroStart"); AutoLogin = (Windows.UI.Xaml.Controls.ToggleSwitch)this.FindName("AutoLogin"); SmartScreen = (Windows.UI.Xaml.Controls.ToggleSwitch)this.FindName("SmartScreen"); }
private async void OnSublayersButtonClicked(object sender, RoutedEventArgs e) { // Make sure that layer and it's sublayers are loaded // If layer is already loaded, this returns directly await _imageLayer.LoadAsync(); var dialog = new ContentDialog() { Title = "Sublayers", FullSizeDesired = true }; // Create list for layers var sublayersListView = new ListView(); // Create cells for each of the sublayers foreach (ArcGISSublayer sublayer in _imageLayer.Sublayers) { // Using a toggle that provides on/off functionality var toggle = new ToggleSwitch() { Header = sublayer.Name, IsOn = sublayer.IsVisible, Margin = new Thickness(5) }; // Hook into the On/Off changed event toggle.Toggled += OnSublayerToggled; // Add cell into the table view sublayersListView.Items.Add(toggle); } // Set listview to the dialog dialog.Content = sublayersListView; // Show dialog as a full screen overlay. await dialog.ShowAsync(); }
/// <summary> /// Adds the necessary analog controls to a StackPanel created for the PWM page. This will only be called on navigation from the Connections page. /// </summary> private void loadPWMControls() { //add controls and value sliders for each pwm pin the board supports for (byte i = 0; i < numberOfPwmPins; ++i) { // Container stack to hold all pieces of new row of pins. var containerStack = new StackPanel(); containerStack.Orientation = Orientation.Horizontal; containerStack.FlowDirection = FlowDirection.LeftToRight; containerStack.HorizontalAlignment = HorizontalAlignment.Stretch; containerStack.Margin = new Thickness(8, 0, 0, 20); // Set up the pin text. var textStack = new StackPanel(); textStack.Orientation = Orientation.Vertical; textStack.FlowDirection = FlowDirection.LeftToRight; textStack.HorizontalAlignment = HorizontalAlignment.Stretch; var text = new TextBlock(); text.HorizontalAlignment = HorizontalAlignment.Stretch; text.VerticalAlignment = VerticalAlignment.Center; text.Margin = new Thickness(0, 0, 0, 0); text.Text = "Pin " + pwmPins[i]; text.FontSize = 14; text.FontWeight = FontWeights.SemiBold; var text2 = new TextBlock(); text2.HorizontalAlignment = HorizontalAlignment.Stretch; text2.VerticalAlignment = VerticalAlignment.Center; text2.Margin = new Thickness(0, 0, 0, 0); text2.Text = "PWM"; text2.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 106, 107, 106)); text2.FontSize = 14; text2.FontWeight = FontWeights.SemiBold; textStack.Children.Add(text); textStack.Children.Add(text2); containerStack.Children.Add(textStack); // Set up the mode toggle button. var modeStack = new StackPanel(); modeStack.Orientation = Orientation.Horizontal; modeStack.FlowDirection = FlowDirection.LeftToRight; modeStack.HorizontalAlignment = HorizontalAlignment.Stretch; modeStack.Margin = new Thickness(88, 0, 0, 0); var toggleSwitch = new ToggleSwitch(); toggleSwitch.HorizontalAlignment = HorizontalAlignment.Left; toggleSwitch.VerticalAlignment = VerticalAlignment.Center; if (pwmPins[i] == 10 || pwmPins[i] == 13) { toggleSwitch.Margin = new Thickness(13, 0, 5, 0); } else { toggleSwitch.Margin = new Thickness(15, 0, 5, 0); } toggleSwitch.Name = "pwmmode_" + pwmPins[i]; toggleSwitch.Toggled += OnClick_PwmModeToggleSwitch; var onContent = new TextBlock(); onContent.Text = "Enabled"; onContent.FontSize = 14; toggleSwitch.OnContent = onContent; var offContent = new TextBlock(); offContent.Text = "Disabled"; offContent.FontSize = 14; toggleSwitch.OffContent = offContent; pwmModeToggleSwitches.Add(pwmPins[i], toggleSwitch); modeStack.Children.Add(toggleSwitch); containerStack.Children.Add(modeStack); //set up the value change slider var slider = new Slider(); slider.Visibility = Visibility.Collapsed; slider.Orientation = Orientation.Horizontal; slider.HorizontalAlignment = HorizontalAlignment.Stretch; slider.SmallChange = 32; slider.StepFrequency = 32; slider.TickFrequency = 32; slider.ValueChanged += OnValueChanged_PwmSlider; slider.PointerReleased += OnPointerReleased_PwmSlider; slider.Minimum = 0; slider.Maximum = 255; slider.Name = "pwmslider_" + pwmPins[i]; slider.Width = 180; slider.Height = 34; slider.Margin = new Thickness(3, 0, 0, 0); pwmSliders.Add(pwmPins[i], slider); containerStack.Children.Add(slider); //set up the indication text var text3 = new TextBlock(); text3.HorizontalAlignment = HorizontalAlignment.Stretch; text3.VerticalAlignment = VerticalAlignment.Center; text3.Margin = new Thickness(3, 0, 0, 0); text3.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 106, 107, 106)); text3.Text = "Enable PWM to write values."; text3.FontSize = 14; text3.Name = "pwmtext_" + pwmPins[i]; text3.Visibility = Visibility.Visible; pwmTextBlocks.Add(pwmPins[i], text3); containerStack.Children.Add(text3); PWMPins.Children.Add(containerStack); } }
/// <summary> /// Adds the necessary digital controls to a StackPanel created for the Digital page. This will only be called on navigation from the Connections page. /// </summary> private void loadDigitalControls() { //add controls and state change indicators/buttons for each digital pin the board supports for (byte i = 0; i < numberOfDigitalPins; ++i) { // Container stack to hold all pieces of new row of pins. var containerStack = new StackPanel(); containerStack.Orientation = Orientation.Horizontal; containerStack.FlowDirection = FlowDirection.LeftToRight; containerStack.HorizontalAlignment = HorizontalAlignment.Stretch; containerStack.Margin = new Thickness(8, 0, 0, 20); // Set up the pin text. var textStack = new StackPanel(); textStack.Orientation = Orientation.Vertical; textStack.FlowDirection = FlowDirection.LeftToRight; textStack.HorizontalAlignment = HorizontalAlignment.Stretch; var text = new TextBlock(); text.HorizontalAlignment = HorizontalAlignment.Stretch; text.VerticalAlignment = VerticalAlignment.Center; text.Margin = new Thickness(0, 0, 0, 0); text.Text = "Pin " + i; text.FontSize = 14; text.FontWeight = FontWeights.SemiBold; var text2 = new TextBlock(); text2.HorizontalAlignment = HorizontalAlignment.Stretch; text2.VerticalAlignment = VerticalAlignment.Center; text2.Margin = new Thickness(0, 0, 0, 0); text2.Text = "Digital"; text2.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 106, 107, 106)); text2.FontSize = 14; text2.FontWeight = FontWeights.SemiBold; textStack.Children.Add(text); textStack.Children.Add(text2); containerStack.Children.Add(textStack); // Set up the mode toggle button. var modeStack = new StackPanel(); modeStack.Orientation = Orientation.Horizontal; modeStack.FlowDirection = FlowDirection.LeftToRight; modeStack.HorizontalAlignment = HorizontalAlignment.Stretch; modeStack.Margin = new Thickness(92, 0, 0, 0); var toggleSwitch = new ToggleSwitch(); toggleSwitch.HorizontalAlignment = HorizontalAlignment.Left; toggleSwitch.VerticalAlignment = VerticalAlignment.Center; toggleSwitch.Margin = new Thickness(5, 0, 5, 0); toggleSwitch.Name = "digitalmode_" + i; toggleSwitch.Toggled += OnClick_DigitalModeToggleSwitch; if (i == 1 || i == 0) { toggleSwitch.IsEnabled = false; } var onContent = new TextBlock(); onContent.Text = "Input"; onContent.FontSize = 14; toggleSwitch.OnContent = onContent; var offContent = new TextBlock(); offContent.Text = "Output"; if (i == 1 || i == 0) { offContent.Text = "Disabled"; } offContent.FontSize = 14; toggleSwitch.OffContent = offContent; digitalModeToggleSwitches.Add(i, toggleSwitch); modeStack.Children.Add(toggleSwitch); containerStack.Children.Add(modeStack); // Set up the state toggle button. var stateStack = new StackPanel(); stateStack.Orientation = Orientation.Horizontal; stateStack.FlowDirection = FlowDirection.LeftToRight; stateStack.HorizontalAlignment = HorizontalAlignment.Stretch; var toggleSwitch2 = new ToggleSwitch(); toggleSwitch2.HorizontalAlignment = HorizontalAlignment.Left; toggleSwitch2.VerticalAlignment = VerticalAlignment.Center; toggleSwitch2.Margin = new Thickness(1, 0, 5, 0); toggleSwitch2.Name = "digitalstate_" + i; toggleSwitch2.Toggled += OnClick_DigitalStateToggleSwitch; if (i == 1 || i == 0) { toggleSwitch2.IsEnabled = false; } var onContent2 = new TextBlock(); onContent2.Text = "5v"; onContent2.FontSize = 14; toggleSwitch2.OnContent = onContent2; var offContent2 = new TextBlock(); offContent2.Text = "0v"; if (i == 1 || i == 0) { offContent2.Text = "Disabled"; } offContent2.FontSize = 14; toggleSwitch2.OffContent = offContent2; digitalStateToggleSwitches.Add(i, toggleSwitch2); var text3 = new TextBlock(); text3.HorizontalAlignment = HorizontalAlignment.Stretch; text3.VerticalAlignment = VerticalAlignment.Center; text3.Margin = new Thickness(0, 0, 0, 0); if (i == 1 || i == 0) { text3.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 106, 107, 106)); text3.Text = "Disabled for serial connection."; } else { text3.Text = "0v"; } text3.FontSize = 14; text3.Visibility = Visibility.Collapsed; digitalStateTextBlocks.Add(i, text3); stateStack.Children.Add(text3); stateStack.Children.Add(toggleSwitch2); containerStack.Children.Add(stateStack); // Add entire row to page. DigitalPins.Children.Add(containerStack); } }
/// <summary> /// Adds the necessary analog controls to a StackPanel created for the Analog page. This will only be called on navigation from the Connections page. /// </summary> private void loadAnalogControls() { //add controls and text fields for each analog pin the board supports for( byte i = 0; i < numberOfAnalogPins; ++i ) { // Container stack to hold all pieces of new row of pins. var containerStack = new StackPanel(); containerStack.Orientation = Orientation.Horizontal; containerStack.FlowDirection = FlowDirection.LeftToRight; containerStack.HorizontalAlignment = HorizontalAlignment.Stretch; containerStack.Margin = new Thickness(8, 0, 0, 20); // Set up the pin text. var textStack = new StackPanel(); textStack.Orientation = Orientation.Vertical; textStack.FlowDirection = FlowDirection.LeftToRight; textStack.HorizontalAlignment = HorizontalAlignment.Stretch; var text = new TextBlock(); text.HorizontalAlignment = HorizontalAlignment.Stretch; text.VerticalAlignment = VerticalAlignment.Center; text.Margin = new Thickness(0, 0, 0, 0); text.Text = "Pin A" + i; text.FontSize = 14; text.FontWeight = FontWeights.SemiBold; var text2 = new TextBlock(); text2.HorizontalAlignment = HorizontalAlignment.Stretch; text2.VerticalAlignment = VerticalAlignment.Center; text2.Margin = new Thickness(0, 0, 0, 0); text2.Text = "Analog"; text2.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 106, 107, 106)); text2.FontSize = 14; text2.FontWeight = FontWeights.SemiBold; textStack.Children.Add(text); textStack.Children.Add(text2); containerStack.Children.Add(textStack); // Set up the mode toggle button. var modeStack = new StackPanel(); modeStack.Orientation = Orientation.Horizontal; modeStack.FlowDirection = FlowDirection.LeftToRight; modeStack.HorizontalAlignment = HorizontalAlignment.Stretch; modeStack.Margin = new Thickness(88, 0, 0, 0); var toggleSwitch = new ToggleSwitch(); toggleSwitch.HorizontalAlignment = HorizontalAlignment.Left; toggleSwitch.VerticalAlignment = VerticalAlignment.Center; toggleSwitch.Margin = new Thickness(5, 0, 5, 0); toggleSwitch.Name = "analogmode_" + i; toggleSwitch.Toggled += OnClick_AnalogModeToggleSwitch; var onContent = new TextBlock(); onContent.Text = "Input"; onContent.FontSize = 14; toggleSwitch.OnContent = onContent; var offContent = new TextBlock(); offContent.Text = "Output"; offContent.FontSize = 14; toggleSwitch.OffContent = offContent; analogModeToggleSwitches.Add(i, toggleSwitch); modeStack.Children.Add(toggleSwitch); containerStack.Children.Add(modeStack); //set up the indication text var text3 = new TextBlock(); text3.HorizontalAlignment = HorizontalAlignment.Stretch; text3.VerticalAlignment = VerticalAlignment.Center; text3.Margin = new Thickness( 2, 0, 0, 0 ); text3.Foreground = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 106, 107, 106)); text3.Text = "Cannot write to analog pins."; text3.FontSize = 14; analogTextBlocks.Add( i, text3 ); containerStack.Children.Add( text3 ); AnalogPins.Children.Add( containerStack ); } }
//****************************************************************************** //* Utility Functions //****************************************************************************** /// <summary> /// retrieves the pin number associated with a button object /// </summary> /// <param name="button">the button to retrieve a pin number from</param> /// <returns>the pin number</returns> private byte GetPinFromButtonObject( ToggleSwitch button ) { return Convert.ToByte( button.Name.Substring( button.Name.IndexOf( '_' ) + 1 ) ); }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. /// This parameter is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { // TODO: Prepare page for display here. // TODO: If your application contains multiple pages, ensure that you are // handling the hardware Back button by registering for the // Windows.Phone.UI.Input.HardwareButtons.BackPressed event. // If you are using the NavigationHelper provided by some templates, // this event is handled for you. DevicesListView.Items.Clear(); if (e.Parameter != null) { try { Room room = (Room)e.Parameter; RoomTextBlock.Text = "Room " + room.Name; Rect.Fill = new SolidColorBrush(Color.FromArgb(15,15,23,0)); if (App.connected) { App.proxy.Invoke<String>("getDevices",room.ID).ContinueWith(async task => { String result = task.Result; ICollection<Models.Device> devices = JsonConvert.DeserializeObject<ICollection<Models.Device>>(result); App.devices = devices; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { if (App.devices != null) { ChooseAnotherTextBlock.Visibility = Visibility.Visible; foreach (Device b in App.devices) { switch (b.DeviceType){ case DeviceType.DIMMER: Slider slider = new Slider(); slider.MinWidth = 280; slider.Margin = new Thickness(10, 0, 10, 0); slider.Header = b.Name; slider.Minimum = 0; slider.Maximum = 255; ControlTag tag = new ControlTag(); tag.deviceID = b.ID; tag.changing = false; slider.Tag = tag; slider.ValueChanged += slider_ValueChanged; slider.PointerCaptureLost += slider_PointerCaptureLost; DevicesListView.Items.Add(slider); App.proxy.Invoke<int>("getDeviceValue", b.ID).ContinueWith(async task2 => { int value = task2.Result; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { slider.Value = value; ((ControlTag)slider.Tag).lastValue = value; }); }); break; case DeviceType.POWER_SWITCH: ToggleSwitch newSwitch = new ToggleSwitch(); newSwitch.Header = b.Name; newSwitch.MinWidth = 280; tag = new ControlTag(); tag.deviceID = b.ID; tag.changing = false; newSwitch.Tag = tag; newSwitch.Toggled += newSwitch_Toggled; DevicesListView.Items.Add(newSwitch); App.proxy.Invoke<int>("getDeviceValue", b.ID).ContinueWith(async task2 => { int value = task2.Result; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (value == 0) { newSwitch.IsOn = false; } else { newSwitch.IsOn = true; } }); }); break; case DeviceType.THERMOMETER: TextBlock NameTextBlock = new TextBlock(); NameTextBlock.FontSize = 24; NameTextBlock.Text = b.Name; tag = new ControlTag(); tag.deviceID = -1; tag.changing = false; NameTextBlock.Tag = tag; TextBlock tempTextBlock = new TextBlock(); tempTextBlock.FontSize = 20; tempTextBlock.Text = "0"; tempTextBlock.MinWidth = 300; tempTextBlock.HorizontalAlignment = HorizontalAlignment.Stretch; tempTextBlock.TextAlignment = TextAlignment.Center; tag = new ControlTag(); tag.deviceID = b.ID; tag.changing = false; tempTextBlock.Tag = tag; DevicesListView.Items.Add(NameTextBlock); DevicesListView.Items.Add(tempTextBlock); App.proxy.Invoke<int>("getDeviceValue", b.ID).ContinueWith(async task2 => { int value = task2.Result; await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { tempTextBlock.Text = value.ToString(); }); }); break; } } } if (App.devices == null || App.devices.Count == 0) { TextBlock textBlock2 = new TextBlock(); textBlock2.FontSize = 24; textBlock2.Text = "It's empty here"; DevicesListView.IsEnabled = false; DevicesListView.Items.Add(textBlock2); } }); }); } ChooseRoomLabel.Visibility = Visibility.Collapsed; } catch (InvalidCastException) { ChooseRoomLabel.Visibility = Visibility.Visible; RoomTextBlock.Text = ""; ChooseAnotherTextBlock.Visibility = Visibility.Collapsed; Rect.Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); } } else { Rect.Fill = new SolidColorBrush(Color.FromArgb(0, 0, 0, 0)); ChooseRoomLabel.Visibility = Visibility.Visible; RoomTextBlock.Text = ""; ChooseAnotherTextBlock.Visibility = Visibility.Collapsed; } }
protected override void OnApplyTemplate() { _colors = base.GetTemplateChild("colors") as ComboBox; _combo = base.GetTemplateChild("combo") as ComboBox; _slider = base.GetTemplateChild("slider") as Slider; _toggle = base.GetTemplateChild("toggle") as ToggleSwitch; _textBox = base.GetTemplateChild("textBox") as TextBox; _isInitialized = true; ExploreProperty(); this.SetValue(this.Value); if (string.IsNullOrEmpty(Label)) { Label = Property; } _combo.SelectionChanged += ComboSelectionChanged; base.OnApplyTemplate(); }
public ToggleSwitchEvents(ToggleSwitch This) : base(This) { this.This = This; }
private void UnloadControl(InputType type) { if (type == InputType.text) { _udfTB1.KeyUp -= ittext_KeyUp; } else if (type == InputType.password) { _udfPB1.PasswordChanged -= itpassword_PasswordChanged; } else if (type == InputType.checkbox) { } else if (type == InputType.radio) { } else if (type == InputType.combobox) { if (_ccInput != null) { var sp = (Grid)_ccInput.Content; var cb = (ComboBox)sp.Children[1]; cb.SelectionChanged -= itcombobox_SelectionChanged; Value2 = null; //if (cb.Items != null && cb.Items.Count > 0) cb.Items.Clear(); //if (cb.ItemsSource != null) cb.ItemsSource = null; } } if (_udfTS1 != null) { _udfTS1.Toggled -= ittoggleswitch_Toggled; } if (_udfProgBr1 != null) { _udfProgBr1.ValueChanged -= itProgBr_ValueChanged; } if (_udfSl1 != null) { _udfSl1.ValueChanged -= itSl_ValueChanged; } if (_udfRB1 != null) { _udfRB1.Checked -= itradio_Changed; _udfRB1.Unchecked -= itradio_Changed; } if (_udfChkB1 != null) { _udfChkB1.Checked -= itcheckbox_Changed; _udfChkB1.Unchecked -= itcheckbox_Changed; } if (_udfTBut1 != null) { _udfTBut1.Checked -= ittogglebutton_changed; _udfTBut1.Unchecked -= ittogglebutton_changed; } if (_udfProgRn1 != null) { _udfProgRn1.IsActive = false; } if (_udfg1 != null) { _udfg1.Children.Clear(); _udfg1 = null; } if (dtInvalidate != null) { dtInvalidate.Stop(); dtInvalidate.Tick += DtInvalidate_Tick; } _sbHideBgLayer?.Stop(); _sbHideBgLayer = null; _sbShowBgLayer?.Stop(); _sbShowBgLayer = null; _udfProgBr1 = null; _udfPB1 = null; _udfTB1 = null; _udfTBL1 = null; _udfCB1 = null; _udfChkB1 = null; _udfRB1 = null; _udfTS1 = null; _udfProgRn1 = null; _udfTBut1 = null; dtInvalidate = null; if (_ccInput != null && _ccInput.Content != null) _ccInput.Content = null; if (_ccInput != null) _ccInput = null; _grdContainer = null; if (_grdRoot != null) { _grdRoot.DataContext = null; _grdRoot = null; } _model = null; hasInitialized = false; }
private void BuildControl(InputType type, string label, string placeholderText, double labelFontSize, double labelTranslateY, string groupName, ContentControl ccInput) { FrameworkElement fe = null; if (type == InputType.text) { _udfTB1 = new TextBox(); _udfTB1.PlaceholderText = placeholderText; _udfTB1.Style = _GeneralTextBoxStyle; _udfTB1.SetBinding(TextBox.DataContextProperty, new Binding() { Path= new PropertyPath("{x:Null}") }); _udfTB1.SetBinding(TextBox.TextProperty, new Binding() { Source = Value }); _udfTB1.KeyUp += ittext_KeyUp; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment= VerticalAlignment.Top}; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(_udfTB1); fe = gd; } else if (type == InputType.password) { _udfPB1 = new PasswordBox(); _udfPB1.PlaceholderText = placeholderText; _udfPB1.Style = _GeneralPasswordBoxStyle; _udfPB1.PasswordChanged += itpassword_PasswordChanged; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(_udfPB1); fe = gd; } else if (type == InputType.combobox) { _udfCB1 = new ComboBox(); _udfCB1.Style = _GeneralComboBoxStyle; _udfCB1.PlaceholderText = placeholderText; _udfCB1.SetBinding(ComboBox.ItemsSourceProperty, new Binding() { Source = Items }); _udfCB1.Width = this.Width; _udfCB1.SelectionChanged += itcombobox_SelectionChanged; _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; _udfTBL1 = new TextBlock(); _udfTBL1.Text = label; _udfTBL1.FontSize = labelFontSize; _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0); _udfg1.Visibility = Visibility.Collapsed; _udfg1.Children.Add(_udfTBL1); var gd = new Grid(); gd.Children.Add(_udfg1); gd.Children.Add(_udfCB1); fe = gd; } else if (type == InputType.checkbox) { var sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; var lb = new TextBlock(); lb.Text = label; lb.FontSize = LabelFontSize; lb.Margin = new Thickness(0, LabelTranslateY, 0, 0); _udfChkB1 = new CheckBox(); _udfChkB1.Checked += itcheckbox_Changed; _udfChkB1.Unchecked += itcheckbox_Changed; _udfChkB1.Content = lb; _udfChkB1.Style = _GeneralCheckBoxStyle; sp.Children.Add(_udfChkB1); fe = sp; } else if (type == InputType.toggleButton) { _udfTBut1 = new ToggleButton(); _udfTBut1.Style = _GeneralToggleButtonStyle; _udfTBut1.Checked += ittogglebutton_changed; _udfTBut1.Unchecked += ittogglebutton_changed; _udfTBut1.FontSize = FontSize; _udfTBut1.Content = Content1; fe = _udfTBut1; } else if (type == InputType.toggleSwitch) { _udfTS1 = new ToggleSwitch(); _udfTS1.Style = _GeneralToggleSwitchStyle; _udfTS1.Toggled += ittoggleswitch_Toggled; _udfTS1.FontSize = FontSize; _udfTS1.OnContent = Content1; _udfTS1.OffContent = Content2; fe = _udfTS1; } else if (type == InputType.radio) { var sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; var lb = new TextBlock(); lb.Text = label; lb.FontSize = LabelFontSize; lb.Margin = new Thickness(0, LabelTranslateY, 0, 0); _udfRB1 = new RadioButton(); _udfRB1.GroupName = groupName; _udfRB1.Checked += itradio_Changed; _udfRB1.Unchecked += itradio_Changed; _udfRB1.Content = lb; _udfRB1.Style = _GeneralRadioButtonStyle; sp.Children.Add(_udfRB1); fe = sp; } else if (type == InputType.progress) { _udfProgBr1 = new ProgressBar(); _udfProgBr1.Style = _GeneralProgressBarStyle; _udfProgBr1.ValueChanged += itProgBr_ValueChanged; _udfProgBr1.FontSize = FontSize; _udfProgBr1.DataContext = this; _udfProgBr1.SetBinding(ProgressBar.MaximumProperty, new Binding() { Path= new PropertyPath("Maximum1") }); _udfProgBr1.SetBinding(ProgressBar.MinimumProperty, new Binding() { Path = new PropertyPath("Minimum1") }); _udfProgBr1.SetBinding(ProgressBar.ValueProperty, new Binding() { Path = new PropertyPath("Value1") }); _udfProgBr1.SetBinding(ProgressBar.SmallChangeProperty, new Binding() { Path = new PropertyPath("SmallChange1") }); _udfProgBr1.SetBinding(ProgressBar.LargeChangeProperty, new Binding() { Path = new PropertyPath("LargeChange1") }); fe = _udfProgBr1; } else if (type == InputType.progressRing) { _udfProgRn1 = new ProgressRing(); _udfProgRn1.Style = _GeneralProgressRingStyle; //_udfProgRn1.val += itProgBr_ValueChanged; _udfProgRn1.FontSize = FontSize; _udfProgRn1.DataContext = this; _udfProgRn1.SetBinding(ProgressRing.IsActiveProperty, new Binding() { Path = new PropertyPath("IsActive") }); fe = _udfProgRn1; } else if (type == InputType.slider) { _udfSl1 = new Slider(); _udfSl1.Style = _GeneralSliderStyle; _udfSl1.ValueChanged += itSl_ValueChanged; _udfSl1.FontSize = FontSize; _udfSl1.DataContext = this; _udfSl1.SetBinding(Slider.MaximumProperty, new Binding() { Path = new PropertyPath("Maximum1") }); _udfSl1.SetBinding(Slider.MinimumProperty, new Binding() { Path = new PropertyPath("Minimum1") }); _udfSl1.SetBinding(Slider.ValueProperty, new Binding() { Path = new PropertyPath("Value1") }); _udfSl1.SetBinding(Slider.SmallChangeProperty, new Binding() { Path = new PropertyPath("SmallChange1") }); _udfSl1.SetBinding(Slider.StepFrequencyProperty, new Binding() { Path = new PropertyPath("SmallChange1") }); _udfSl1.SetBinding(Slider.LargeChangeProperty, new Binding() { Path = new PropertyPath("LargeChange1") }); fe = _udfSl1; } fe.HorizontalAlignment = HorizontalAlignment.Stretch; fe.VerticalAlignment = VerticalAlignment.Stretch; ccInput.Content = fe; }