private void Page_Loaded(object sender, RoutedEventArgs e) { ThumbnailList.ItemsSource = Model.Items; // Populate the Effect combobox IList<ComboBoxItem> effectList = new List<ComboBoxItem>(); foreach (EffectTypes type in Enum.GetValues(typeof(EffectTypes))) { ComboBoxItem item = new ComboBoxItem(); item.Tag = type; item.Content = type.ToString(); effectList.Add(item); } EffectSelection.ItemsSource = effectList; EffectSelection.SelectedIndex = 0; // Get the current compositor _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; // Create the destinatio sprite, sized to cover the entire list _destinationSprite = _compositor.CreateSpriteVisual(); _destinationSprite.Size = new Vector2((float)ThumbnailList.ActualWidth, (float)ThumbnailList.ActualHeight); // Start out with the destination layer invisible to avoid any cost until necessary _destinationSprite.IsVisible = false; ElementCompositionPreview.SetElementChildVisual(ThumbnailList, _destinationSprite); // Update the effect to set the appropriate brush UpdateEffect(); }
private void Page_Loaded(object sender, RoutedEventArgs e) { // Populate the BlendEffectMode combobox IList<ComboBoxItem> blendList = new List<ComboBoxItem>(); foreach (BlendEffectMode type in Enum.GetValues(typeof(BlendEffectMode))) { // Exclude unsupported types if (type != BlendEffectMode.Dissolve && type != BlendEffectMode.Saturation && type != BlendEffectMode.Color && type != BlendEffectMode.Hue && type != BlendEffectMode.Luminosity ) { ComboBoxItem item = new ComboBoxItem(); item.Tag = type; item.Content = type.ToString(); blendList.Add(item); } } BlendSelection.ItemsSource = blendList; BlendSelection.SelectedIndex = 0; BitmapImage image = new BitmapImage(new Uri("ms-appx:///Assets/Landscapes/Landscape-7.jpg")); BackgroundImage.Source = image; }
private void InitControls() { if (currNotification == null) return; DateTime dateNow = currNotification == null ? new DateTime() : currNotification.Time; for (int i = 0; i < 24; i++) { int itemHour = i; ComboBoxItem cbItem = new ComboBoxItem(); cbItem.Content = string.Format("{0:00}", itemHour); cbItem.Tag = itemHour; cbItem.IsSelected = itemHour == dateNow.Hour; cbHour.Items.Add(cbItem); } for (int i = 0; i < 60; i++) { int itemMinute = i; ComboBoxItem cbItem = new ComboBoxItem(); cbItem.Content = string.Format("{0:00}", itemMinute); cbItem.Tag = itemMinute; cbItem.IsSelected = dateNow.Minute == itemMinute; cbMinute.Items.Add(cbItem); } }
/// <summary> /// Grouped chennels /// </summary> private void Grouped() { _groups = new ObservableCollection<GroupChannel>(); foreach (ChannelGroup item in App.ViewModel.UserAccount.channel_group) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Name = item.name; cbi.Content = item.name; ind++; var g = new GroupChannel { GroupName = item.name }; foreach (Channel it in item.Channels) { Channel c = new Channel(); c = it; c.icon = "http://sovok.tv" + c.icon; g.Channels.Add(c); } _groups.Add(g); } ComboBoxItem fcbi = new ComboBoxItem(); fcbi.Content = fcbi.Name = "Favorite"; ind++; CList.Source = _groups; App.ViewModel.ChanneLisrRange = ChannelListView.Items.Count; }
public MainPage() { this.InitializeComponent(); canvas.PointerMoved += canvas_PointerMoved; canvas.PointerReleased += canvas_PointerReleased; canvas.PointerPressed += canvas_PointerPressed; canvas.PointerExited += canvas_PointerExited; for (int i = 1; i < 21; i++) { ComboBoxItem Items = new ComboBoxItem(); Items.Content = i; cbStrokeThickness.Items.Add(Items); } cbStrokeThickness.SelectedIndex = 0; //var t = typeof(Colors); //var ti = t.GetTypeInfo(); //var dp = ti.DeclaredProperties; var colors = typeof(Colors).GetTypeInfo().DeclaredProperties; foreach (var item in colors) { cbBorderColor.Items.Add(item); cbFillColor.Items.Add(item); } }
void GenerateLists() { foreach (league l in App.Instance.Leagues) { ComboBoxItem temp = new ComboBoxItem(); temp.Content = l.name; LeagueList.Items.Add(temp); } }
void AddItemForLanguageTag(string languageTag) { var language = new Language(languageTag); var item = new ComboBoxItem { Content = language.DisplayName, Tag = languageTag }; LanguageOverrideCombo.Items.Add(item); // Select this item if it is the primary language override. if (languageTag == ApplicationLanguages.PrimaryLanguageOverride) { LanguageOverrideCombo.SelectedItem = item; } }
public SettingsView() { this.InitializeComponent(); this.DataContext = App.ViewModel; foreach (Streamers item in App.ViewModel.StreamServer) { ComboBoxItem boxitem = new ComboBoxItem(); boxitem.Content = item.id; boxitem.Name = item.name; Stream.Items.Add(boxitem); } set_value(); }
public VideoPage() { this.InitializeComponent(); MS2Tester.Instance.initVideo(); bool isSelected = true; foreach (String device in MS2Tester.Instance.VideoDevices) { ComboBoxItem item = new ComboBoxItem(); item.Content = device; item.IsSelected = isSelected; isSelected = false; CameraComboBox.Items.Add(item); } }
public FontPickerComboBox() { var fontFamilyNames = CanvasTextFormat.GetSystemFontFamilies(ApplicationLanguages.Languages).OrderBy(k => k); foreach (string fontFamilyName in fontFamilyNames) { ComboBoxItem item = new ComboBoxItem(); item.Content = fontFamilyName; item.FontFamily = new FontFamily(fontFamilyName); this.Items.Add(item); } this.SelectedIndex = 0; this.SelectionChanged += FontPickerComboBox_SelectionChanged; }
private void InitControls() { if (currBudget == null) return; DateTime dateForYear = DateTime.Now.AddYears(-1); List<string> monthList = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames.Take(12).ToList(); DateTime dateNowFrom = currBudget == null ? new DateTime() : currBudget.FromDate; DateTime dateNowTo = currBudget == null ? new DateTime() : currBudget.ToDate; //Do day part first because month & year interracts with day cb InitDayControl(cbFromDay, currBudget.FromDate); for (int i = 0; i < 4; i++) { int itemYear = dateForYear.AddYears(i).Year; ComboBoxItem cbItemFrom = new ComboBoxItem(); ComboBoxItem cbItemTo = new ComboBoxItem(); cbItemFrom.Content = cbItemTo.Content = itemYear; cbItemFrom.Tag = cbItemTo.Tag = itemYear; cbItemFrom.IsSelected = itemYear == dateNowFrom.Year; cbItemTo.IsSelected = itemYear == dateNowTo.Year; cbFromYear.Items.Add(cbItemFrom); cbToYear.Items.Add(cbItemTo); } for (int i = 0; i < monthList.Count(); i++) { ComboBoxItem cbItemFrom = new ComboBoxItem(); ComboBoxItem cbItemTo = new ComboBoxItem(); cbItemFrom.Content = cbItemTo.Content = string.Format("{0:00} {1}", i + 1, monthList[i]); cbItemFrom.Tag = cbItemTo.Tag = i + 1; cbItemFrom.IsSelected = dateNowFrom.Month == i + 1; cbItemTo.IsSelected = dateNowTo.Month == i + 1; cbFromMonth.Items.Add(cbItemFrom); cbToMonth.Items.Add(cbItemTo); } }
private void Grouped() { _groups = new ObservableCollection<GroupChannel>(); foreach (ChannelGroup item in App.ViewModel.UserAccount.channel_group) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Name = item.name; cbi.Content = item.name; ChCategory.Items.Add(cbi); var g = new GroupChannel { GroupName = item.name }; foreach (Channel it in item.Channels) { Channel c = new Channel(); c = it; c.icon = "http://sovok.tv" + c.icon; g.Channels.Add(c); } _groups.Add(g); } //var fg = new GroupChannel { GroupName = "Favorite" }; ComboBoxItem fcbi = new ComboBoxItem(); fcbi.Content = fcbi.Name = "Favorite"; ChCategory.Items.Add(fcbi); /*foreach (FavoriteChannel item in App.ViewModel.UserAccount.favorite_channel) { Channel fc = new Channel(); foreach (СhannelItem it in App.ViewModel.ChannelList) { if (item.id_channel==it.ChannelId) { fc.epg_end = it.epg_end; fc.epg_progname = it.Epg; fc.epg_start = it.epg_start; fc.icon = it.Image_Source.ToString(); fc.name = it.ChannelName; break; } } fg.Channels.Add(fc); } _groups.Add(fg);*/ CList.Source = _groups; }
private void InitControls() { if (currCategory == null) return; DateTime dateNowFrom = currCategory == null ? new DateTime() : currCategory.FromDate; DateTime dateNowTo = currCategory == null ? new DateTime() : currCategory.ToDate; for (int i = 0; i < 24; i++) { int itemHour = i; ComboBoxItem cbItemFrom = new ComboBoxItem(); ComboBoxItem cbItemTo = new ComboBoxItem(); cbItemFrom.Content = cbItemTo.Content = string.Format("{0:00}", itemHour) ; cbItemFrom.Tag = cbItemTo.Tag = itemHour; cbItemFrom.IsSelected = itemHour == dateNowFrom.Hour; cbItemTo.IsSelected = itemHour == dateNowTo.Hour; cbFromHour.Items.Add(cbItemFrom); cbToHour.Items.Add(cbItemTo); } for (int i = 0; i < 60; i++) { int itemMinute = i; ComboBoxItem cbItemFrom = new ComboBoxItem(); ComboBoxItem cbItemTo = new ComboBoxItem(); cbItemFrom.Content = cbItemTo.Content = string.Format("{0:00}", itemMinute); cbItemFrom.Tag = cbItemTo.Tag = itemMinute; cbItemFrom.IsSelected = dateNowFrom.Minute == itemMinute; cbItemTo.IsSelected = dateNowTo.Minute == itemMinute; cbFromMinute.Items.Add(cbItemFrom); cbToMinute.Items.Add(cbItemTo); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor; // Populate the Effect combobox IList<ComboBoxItem> effectList = new List<ComboBoxItem>(); foreach (PointerEffectTechniques.EffectTechniques.EffectTypes type in Enum.GetValues(typeof(PointerEffectTechniques.EffectTechniques.EffectTypes))) { ComboBoxItem item = new ComboBoxItem(); item.Tag = type; item.Content = type.ToString(); effectList.Add(item); } EffectSelection.ItemsSource = effectList; EffectSelection.SelectedIndex = 0; ThumbnailList.ItemsSource = Model.Items; }
protected override void OnNavigatedTo(NavigationEventArgs e) { foreach (var item in category) { ComboBoxItem i1 = new ComboBoxItem(); i1.Content = item; //i1.Foreground = new SolidColorBrush(Colors.Green); categoryList.Items.Add(i1); } if(e.Parameter.ToString() == "add") { categoryList.IsEnabled = false; amount.Text = "Enter amount to add"; addOrMinus = "add"; actionButton.Content = "Add Amount"; headBlock.Text = "Add Amount"; categoryList.Visibility = Windows.UI.Xaml.Visibility.Collapsed; categoryBlock.Visibility = Windows.UI.Xaml.Visibility.Collapsed; Thickness margin = Date.Margin; margin.Top = 197; margin.Right = 20; Date.Margin = margin; Thickness margin1 = dateBlock.Margin; margin1.Top = 207; margin1.Left = 20; dateBlock.Margin = margin1; } else if (e.Parameter.ToString() == "minus") { categoryList.IsEnabled = true; amount.Text = "Enter expense amount"; addOrMinus = "minus"; actionButton.Content = "Add Expense"; headBlock.Text = "Add Expense"; } Windows.Phone.UI.Input.HardwareButtons.BackPressed += Hardwarebuttons_BackPressed; }
// A pointer back to the main page. This is needed if you want to call methods in MainPage such // as NotifyUser() //MainPage rootPage = MainPage.Current; public SettingsFlyout() { this.InitializeComponent(); ComboBoxItem light = new ComboBoxItem(); light.Name = "Light"; ComboBoxItem dark = new ComboBoxItem(); dark.Name = "Dark"; ComboBoxItem gators = new ComboBoxItem(); gators.Name = "Gators"; ThemeBox.Items.Add(light); ThemeBox.Items.Add(dark); ThemeBox.Items.Add(gators); FlyoutContent.Transitions = new TransitionCollection(); FlyoutContent.Transitions.Add(new EntranceThemeTransition() { FromHorizontalOffset = (SettingsPane.Edge == SettingsEdgeLocation.Right) ? ContentAnimationOffset : (ContentAnimationOffset * -1) }); ThemeBox = new ComboBox(); }
public MainPage() { this.InitializeComponent(); Image img = new Image(); img.Source = new BitmapImage(new Uri("ms-appx:///Pictures/2.jpg", UriKind.RelativeOrAbsolute)); canvas.Children.Insert(0, img); canvas.Height = img.ActualHeight; canvas.Width = img.ActualWidth; clr.R = 212; LoadImage(); canvas.PointerMoved += canvas_PointerMoved; canvas.PointerReleased += canvas_PointerReleased; canvas.PointerPressed += canvas_PointerPressed; canvas.PointerExited += canvas_PointerExited; for (int i = 1; i < 21; i++) { ComboBoxItem Items = new ComboBoxItem(); Items.Content = i; cbStrokeThickness.Items.Add(Items); } cbStrokeThickness.SelectedIndex = 0; //var t = typeof(Colors); //var ti = t.GetTypeInfo(); //var dp = ti.DeclaredProperties; var colors = typeof(Colors).GetTypeInfo().DeclaredProperties; foreach (var item in colors) { cbBorderColor.Items.Add(item); // cbFillColor.Items.Add(item); } }
/// <summary> /// Look up the supported languages for this speech recognition scenario, /// that are installed on this machine, and populate a dropdown with a list. /// </summary> private void PopulateLanguageDropdown() { // disable the callback so we don't accidentally trigger initialization of the recognizer // while initialization is already in progress. cbLanguageSelection.SelectionChanged -= cbLanguageSelection_SelectionChanged; Language defaultLanguage = SpeechRecognizer.SystemSpeechLanguage; IEnumerable<Language> supportedLanguages = SpeechRecognizer.SupportedGrammarLanguages; foreach(Language lang in supportedLanguages) { ComboBoxItem item = new ComboBoxItem(); item.Tag = lang; item.Content = lang.DisplayName; cbLanguageSelection.Items.Add(item); if(lang.LanguageTag == defaultLanguage.LanguageTag) { item.IsSelected = true; cbLanguageSelection.SelectedItem = item; } } cbLanguageSelection.SelectionChanged += cbLanguageSelection_SelectionChanged; }
/// <summary> /// This is invoked when the form is initialized, and is used to initialize the list box /// this simply enumerates all of the installed voices /// </summary> private void ListboxVoiceChooser_Initialize() { // get all of the installed voices var voices = Windows.Media.SpeechSynthesis.SpeechSynthesizer.AllVoices; // get the currently selected voice VoiceInformation currentVoice = this.synthesizer.Voice; foreach (VoiceInformation voice in voices) { ComboBoxItem item = new ComboBoxItem(); item.Name = voice.DisplayName; item.Tag = voice; item.Content = voice.DisplayName; this.listboxVoiceChooser.Items.Add(item); // check to see if this is the current voice, so that we can set it to be selected if (currentVoice.Id == voice.Id) { item.IsSelected = true; this.listboxVoiceChooser.SelectedItem = item; } } }
private void UpdateDescriptionVisibility(ComboBoxItem item, Visibility visibility) { TextBlock textBlock = null; CompressAlgorithm? Algorithm = CompressAlgorithmFromComboBoxItem(item); switch (Algorithm) { case null: textBlock = DefaultTextBlock; break; case CompressAlgorithm.Xpress: textBlock = XpressTextBlock; break; case CompressAlgorithm.XpressHuff: textBlock = XpressHuffTextBlock; break; case CompressAlgorithm.Mszip: textBlock = MszipTextBlock; break; case CompressAlgorithm.Lzms: textBlock = LzmsTextBlock; break; default: return; } textBlock.Visibility = visibility; }
private CompressAlgorithm? CompressAlgorithmFromComboBoxItem(ComboBoxItem item) { CompressAlgorithm? Algorithm = null; if (item == DefaultComboBoxItem) { Algorithm = null; } else if (item == XpressComboBoxItem) { Algorithm = CompressAlgorithm.Xpress; } else if (item == XpressHuffComboBoxItem) { Algorithm = CompressAlgorithm.XpressHuff; } else if (item == MszipComboBoxItem) { Algorithm = CompressAlgorithm.Mszip; } else if (item == LzmsComboBoxItem) { Algorithm = CompressAlgorithm.Lzms; } else { Algorithm = CompressAlgorithm.InvalidAlgorithm; } return Algorithm; }
/// <summary> /// loadSection loads on ComboBox with an specific DateSection ( Year , Month , Day ) /// </summary> /// <param name="time">The time to display</param> /// <param name="section">The ComboBox position</param> /// <param name="kindOfDisplay">The DateSection to display</param> /// <param name="additionalZero">Display Day and Month with addition Zero (02 / 2) and the Year long or short ( 13 / 2013 )</param> private void loadSection(DateTime time, section section, kindOfDisplay kindOfDisplay, bool additionalZero = false) { ///For the correct ComboBox or TextBlock ComboBox sectionBox = null; TextBlock sectionText = null; ///ComboBox Item for adding new Items to the list ComboBoxItem item = null; ///The Selection Changed Event Handler to delete and add again ///so the Event is not raised while adding items and set the ///selected item SelectionChangedEventHandler handler = null; ///Each section has its own ComboBox, TextBox and Selection Changed Handler ///The switch ensures getting the wright one switch (section) { case section.first: sectionBox = firstSectionComboBox; sectionText = firstSectionTextBlock; handler = firstSectionComboBox_SelectionChanged; sectionBox.SelectionChanged -= handler; break; case section.second: sectionBox = secondSectionComboBox; sectionText = secondSectionTextBlock; handler = secondSectionComboBox_SelectionChanged; sectionBox.SelectionChanged -= handler; break; case section.third: sectionBox = thirdSectionComboBox; sectionText = thirdSectionTextBlock; handler = thirdSectionComboBox_SelectionChanged; sectionBox.SelectionChanged -= handler; break; } ///Clears the sectionBox before recreating sectionBox.Items.Clear(); ///Creates different items for different Date Sections switch (kindOfDisplay) { case kindOfDisplay.day: ///Creates the Days for the Month ( 31 , 30 , 29 , 28 ) for (int i = 1; i <= DateTime.DaysInMonth(time.Year, time.Month); i++) { item = new ComboBoxItem(); ///Displayes a Day with an addition Zero or not ( 8 , 08 ) if (additionalZero && i < 10) item.Content += "0"; item.Content += i.ToString(); ///marks the correct day as selected if (i == time.Day) item.IsSelected = true; ///Adds the item sectionBox.Items.Add(item); } ///Adds the Day of the Week ( Monday ... ) sectionText.Text = time.DayOfWeek.ToString(); break; case kindOfDisplay.month: ///Creats the different Month for (int i = 1; i <= 12; i++) { item = new ComboBoxItem(); ///Displayes a Month with an addition Zero or not ( 8 , 08 ) if (additionalZero && i < 10) item.Content += "0"; item.Content += i.ToString(); ///marks the correct month as selected if (i == time.Month) item.IsSelected = true; ///Adds the item sectionBox.Items.Add(item); } ///Adds the Month as its long form ( January ) sectionText.Text = time.ToString("MMM"); break; case kindOfDisplay.year: ///Creates the Yearitems for (int i = MinYear; i <= MaxYear; i++) { item = new ComboBoxItem(); ///Displayes a Year in two different ways ( 13 , 2013 ) if (additionalZero) item.Content += i.ToString().Substring(3); else item.Content += i.ToString(); ///marks the correct year as selected if (i == time.Year) item.IsSelected = true; ///Adds the item sectionBox.Items.Add(item); } ///Clears the sectionText sectionText.Text = ""; ///Adds the DayLightSaving Flag if (DaylightSavingFlag) { if (time.IsDaylightSavingTime()) sectionText.Text += "S"; else sectionText.Text += "N"; } ///Adds the Leap Year Flag if it is a LeapYear if (LeapYearFlag && DateTime.IsLeapYear(time.Year)) sectionText.Text += " L"; break; } sectionBox.SelectionChanged += handler; }
private void RecycleButton_Click(object sender, RoutedEventArgs e) { activityNameComboBox.Items.Clear(); activityNameComboBox.Visibility = Visibility.Visible; for (int i = 0; i < rtrackact.activity.Count; i++) { ComboBoxItem cbitem = new ComboBoxItem(); cbitem.Content = rtrackact.activity[i].name; activityNameComboBox.Items.Add(cbitem); } activityName.Visibility = Visibility.Collapsed; NewActivityName.Visibility = Visibility.Collapsed; }
/// <summary> /// Look up the supported languages for this speech recognition scenario, /// that are installed on this machine, and populate a dropdown with a list. /// </summary> private void PopulateLanguageDropDown() { Language defaultLanguage = SpeechRecognizer.SystemSpeechLanguage; IEnumerable<Language> supportedLanguages = SpeechRecognizer.SupportedTopicLanguages; foreach (Language lang in supportedLanguages) { ComboBoxItem item = new ComboBoxItem(); item.Tag = lang; item.Content = lang.DisplayName; cbLanguageSelection.Items.Add(item); if (lang.LanguageTag == defaultLanguage.LanguageTag) { item.IsSelected = true; cbLanguageSelection.SelectedItem = item; } } }
// Image io= public main1() { this.InitializeComponent(); this.NavigationCacheMode = Windows.UI.Xaml.Navigation.NavigationCacheMode.Enabled; canvas.PointerMoved += canvas_pointer_moved; canvas.PointerPressed += canvas_pointer_pressed; canvas.PointerExited += canvas_pointer_exited; canvas.PointerReleased += canvas_pointer_released; tool = "pencil"; FillColor = Colors.Blue; BorderColor = Colors.Black; var colors = typeof(Colors).GetTypeInfo().DeclaredProperties; foreach (var item in colors) { //ImageBrush i= i Rectangle r = new Rectangle(); //r.Fill=I //fill.Items.Add(item); } for (int i = 1; i < 20; i++) { ComboBoxItem Items = new ComboBoxItem(); Items.Content = i; thick.Items.Add(Items); } thick.SelectedIndex = 0; }
/// <summary> /// Populates the combo boxes with preview settings and matching ratio settings for the video stream /// </summary> private void PopulateComboBoxes() { // Query all properties of the device IEnumerable<StreamResolution> allPreviewProperties = _previewer.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Select(x => new StreamResolution(x)); // Order them by resolution then frame rate allPreviewProperties = allPreviewProperties.OrderByDescending(x => x.Height * x.Width).ThenByDescending(x => x.FrameRate); // Populate the preview combo box with the entries foreach (var property in allPreviewProperties) { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = property.GetFriendlyName() + String.Format(" A. Ratio: {0}", property.AspectRatio.ToString("#.##")); comboBoxItem.Tag = property; PreviewSettings.Items.Add(comboBoxItem); } // Keep the same aspect ratio with the video stream MatchPreviewAspectRatio(); }
/// <summary> /// Finds all the available video resolutions that match the aspect ratio of the preview stream /// Note: This should also be done with photos as well. This same method can be modified for photos /// by changing the MediaStreamType from VideoPreview to Photo. /// </summary> private void MatchPreviewAspectRatio() { // Query all properties of the device IEnumerable<StreamResolution> allVideoProperties = _previewer.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoRecord).Select(x => new StreamResolution(x)); // Query the current preview settings StreamResolution previewProperties = new StreamResolution(_previewer.MediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview)); // Get all formats that have the same-ish aspect ratio as the preview // Allow for some tolerance in the aspect ratio comparison const double ASPECT_RATIO_TOLERANCE = 0.015; var matchingFormats = allVideoProperties.Where(x => Math.Abs(x.AspectRatio - previewProperties.AspectRatio) < ASPECT_RATIO_TOLERANCE); // Order them by resolution then frame rate allVideoProperties = matchingFormats.OrderByDescending(x => x.Height * x.Width).ThenByDescending(x => x.FrameRate); // Clear out old entries and populate the video combo box with new matching entries VideoSettings.Items.Clear(); foreach (var property in allVideoProperties) { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = property.GetFriendlyName(); comboBoxItem.Tag = property; VideoSettings.Items.Add(comboBoxItem); } VideoSettings.SelectedIndex = -1; }
async void getContext() { var req = await client.GetAsync(new Uri(string.Format("{0}/api/v1/Context?", targetProcessServer))); if (req.IsSuccessStatusCode) { string responseText = await req.Content.ReadAsStringAsync(); req.Dispose(); var doc = XDocument.Parse(responseText); ComboBoxItem firstComboBoxItem = null; bool selectedItemFound = false; gettingContext = true; projectComboBox.Items.Clear(); foreach (XElement e in doc.Root.Element("SelectedProjects").Elements("ProjectInfo")) { ComboBoxItem i = new ComboBoxItem(); i.Content = e.Attribute("Name").Value; int id = int.Parse(e.Attribute("Id").Value); i.Tag = id; if (firstComboBoxItem == null) { firstComboBoxItem = i; } if (id == selectedProjectId) { selectedItemFound = true; i.IsSelected = true; } projectComboBox.Items.Add(i); } if (!selectedItemFound) { firstComboBoxItem.IsSelected = true; selectedProjectId = (int)firstComboBoxItem.Tag; settings. Values[SELECTEDPROJECTID_SETTINGSKEY] = selectedProjectId; } firstComboBoxItem = null; selectedItemFound = false; teamComboBox.Items.Clear(); foreach (XElement e in doc.Root.Element("SelectedTeams").Elements("TeamInfo")) { ComboBoxItem i = new ComboBoxItem(); i.Content = e.Attribute("Name").Value; int id = int.Parse(e.Attribute("Id").Value); i.Tag = id; if (firstComboBoxItem == null) { firstComboBoxItem = i; } if (id == selectedTeamId) { selectedItemFound = true; i.IsSelected = true; } teamComboBox.Items.Add(i); } if (!selectedItemFound) { firstComboBoxItem.IsSelected = true; selectedTeamId = (int)firstComboBoxItem.Tag; settings.Values[SELECTEDTEAMID_SETTINGSKEY] = selectedTeamId; } gettingContext = false; projectLabel.Visibility = Visibility.Visible; projectComboBox.Visibility = Visibility.Visible; teamLabel.Visibility = Visibility.Visible; teamComboBox.Visibility = Visibility.Visible; getAcid(); } else if (req.StatusCode == HttpStatusCode.Unauthorized || req.StatusCode == HttpStatusCode.Forbidden) { var popup = new MessageDialog("Check username/password and try again.", "Access denied"); req.Dispose(); await popup.ShowAsync(); client.Dispose(); resetUserNamePasswordField(); } else { var popup = new MessageDialog("Check network settings and try again.", string.IsNullOrWhiteSpace(req.ReasonPhrase) ? "Network error" : ToSentenceCase(req.ReasonPhrase)); req.Dispose(); await popup.ShowAsync(); client.Dispose(); resetUserNamePasswordField(); } }
/// <summary> /// Populates the combo box with all possible combinations of settings returned by the camera driver /// </summary> private void PopulateSettingsComboBox() { // Query all properties of the device IEnumerable<StreamResolution> allProperties = _previewer.MediaCapture.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.VideoPreview).Select(x => new StreamResolution(x)); // Order them by resolution then frame rate allProperties = allProperties.OrderByDescending(x => x.Height * x.Width).ThenByDescending(x => x.FrameRate); // Populate the combo box with the entries foreach (var property in allProperties) { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = property.GetFriendlyName(); comboBoxItem.Tag = property; CameraSettings.Items.Add(comboBoxItem); } }
private async void FillDevicesList() { DeviceInformationCollection videoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture); foreach (var device in videoDevices) { ComboBoxItem item = new ComboBoxItem(); item.Content = device.Name; item.Name = device.Id; VideoSelect.Items.Add(item); } DeviceInformationCollection audioDevices = await DeviceInformation.FindAllAsync(DeviceClass.AudioCapture); foreach (var device in audioDevices) { ComboBoxItem item = new ComboBoxItem(); item.Content = device.Name; item.Name = device.Id; AudioSelect.Items.Add(item); } if (VideoSelect.Items.Count > 0) { VideoSelect.SelectedIndex = 0; } if (AudioSelect.Items.Count > 0) { AudioSelect.SelectedIndex = 0; } }