private void btnNext_Click(object sender, RoutedEventArgs e) { ICollectionView navigationView = CollectionViewSource.GetDefaultView(phoneNumbersDataSet.PhoneNumbers); navigationView.MoveCurrentToNext(); }
public EmployeeViewModel() { LoadEmployees(); _view = (CollectionView)CollectionViewSource.GetDefaultView(Employees); _view.Filter = EmployeeFilter; }
// Filtra los contactos por su Nombre private void filtrarContactos(object sender, TextChangedEventArgs e) { CollectionViewSource.GetDefaultView(Lista.ItemsSource).Refresh(); }
public SortHelper(CollectionViewSource source) : base(source) { // default sort Firstname = true; Ascending = true; }
private void Button_Click_PrintStation(object sender, RoutedEventArgs e) { SandboxDataSet ds = ((SandboxDataSet)(FindResource("sandboxDataSet"))); CollectionViewSource stViewSource = ((CollectionViewSource)(FindResource("wasteTrackerStationsViewSource"))); #region Setup Excel Sheet //create new excel application Microsoft.Office.Interop.Excel.Application xla = new Microsoft.Office.Interop.Excel.Application(); //create workbook and worksheet Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet); Worksheet ws = (Worksheet)xla.ActiveSheet; ws.PageSetup.FitToPagesWide = 1; ws.PageSetup.Orientation = XlPageOrientation.xlLandscape; //start at row 3 row 1 is the Station, row 3 is header int i = 3; //create header ws.Range["A1"].Cells.Value = wasteTrackerStationsComboBox.SelectedValue.ToString(); ws.Range["A2"].Cells.ColumnWidth = 8; ws.Range["A2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["A2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["A2"].Cells.Rows.RowHeight = 30; ws.Range["A2"].Value = "Station Id"; ws.Range["B2"].Cells.ColumnWidth = 26; ws.Range["B2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["B2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["B2"].Value = "Menu Item"; ws.Range["C2"].Cells.ColumnWidth = 4; ws.Range["C2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["C2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["C2"].Value = "UoM"; ws.Range["D2"].Cells.ColumnWidth = 6.2; ws.Range["D2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["D2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["D2"].Value = "Fri"; ws.Range["E2"].Cells.ColumnWidth = 6.2; ws.Range["E2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["E2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["E2"].Value = "Mon"; ws.Range["F2"].Cells.ColumnWidth = 6.2; ws.Range["F2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["F2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["F2"].Value = "Tue"; ws.Range["G2"].Cells.ColumnWidth = 6.2; ws.Range["G2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["G2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["G2"].Value = "Wed"; ws.Range["H2"].Cells.ColumnWidth = 6.2; ws.Range["H2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["H2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["H2"].Value = "Thu"; ws.Range["I2"].Cells.ColumnWidth = 40; ws.Range["I2"].Cells.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter; ws.Range["I2"].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["I2"].Value = "Comments"; foreach (DataRow dr in ds.MenuItems.Rows) { ws.Range["A" + i].Value = dr[1]; ws.Range["A" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["A" + i].Cells.Rows.RowHeight = 30; ws.Range["B" + i].Value = dr[2]; ws.Range["B" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["C" + i].Value = dr[3]; ws.Range["C" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["D" + i].Value = ""; ws.Range["D" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["E" + i].Value = ""; ws.Range["E" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["F" + i].Value = ""; ws.Range["F" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["G" + i].Value = ""; ws.Range["G" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["H" + i].Value = ""; ws.Range["H" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; ws.Range["I" + i].Value = ""; ws.Range["I" + i].Cells.Borders.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous; i++; } #endregion xla.Visible = true; }
private void PrepareFiltering() { this._iconsCollectionView = CollectionViewSource.GetDefaultView(this.Icons); this._iconsCollectionView.Filter = o => this.FilterIconsPredicate(this.FilterText, (IIconViewModel)o); }
public MainWindowViewModel(IDialogCoordinator dialogCoordinator) { this.Title = "Flyout Binding Test"; this._dialogCoordinator = dialogCoordinator; SampleData.Seed(); // create accent color menu items for the demo this.AccentColors = ThemeManager.Current.Themes .GroupBy(x => x.ColorScheme) .OrderBy(a => a.Key) .Select(a => new AccentColorMenuData { Name = a.Key, ColorBrush = a.First().ShowcaseBrush }) .ToList(); // create metro theme color menu items for the demo this.AppThemes = ThemeManager.Current.Themes .GroupBy(x => x.BaseColorScheme) .Select(x => x.First()) .Select(a => new AppThemeMenuData() { Name = a.BaseColorScheme, BorderColorBrush = a.Resources["MahApps.Brushes.ThemeForeground"] as Brush, ColorBrush = a.Resources["MahApps.Brushes.ThemeBackground"] as Brush }) .ToList(); this.Albums = new ObservableCollection <Album>(SampleData.Albums); var cvs = CollectionViewSource.GetDefaultView(this.Albums); cvs.GroupDescriptions.Add(new PropertyGroupDescription("Artist")); this.Artists = SampleData.Artists; this.FlipViewImages = new Uri[] { new Uri("pack://application:,,,/MahApps.Metro.Demo;component/Assets/Photos/Home.jpg", UriKind.RelativeOrAbsolute), new Uri("pack://application:,,,/MahApps.Metro.Demo;component/Assets/Photos/Privat.jpg", UriKind.RelativeOrAbsolute), new Uri("pack://application:,,,/MahApps.Metro.Demo;component/Assets/Photos/Settings.jpg", UriKind.RelativeOrAbsolute) }; this.BrushResources = this.FindBrushResources(); this.CultureInfos = CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures).OrderBy(c => c.DisplayName).ToList(); try { HotkeyManager.Current.AddOrReplace("demo", this.HotKey.Key, this.HotKey.ModifierKeys, (sender, e) => this.OnHotKey(sender, e)); } catch (HotkeyAlreadyRegisteredException exception) { System.Diagnostics.Trace.TraceWarning("Uups, the hotkey {0} is already registered!", exception.Name); } this.EndOfScrollReachedCmdWithParameter = new SimpleCommand(o => true, async x => { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("End of scroll reached!", $"Parameter: {x}"); }); this.CloseCmd = new SimpleCommand(o => this.CanCloseFlyout, x => ((Flyout)x).IsOpen = false); this.TextBoxButtonCmd = new SimpleCommand( o => true, async x => { if (x is string s) { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("Wow, you typed Return and got", s).ConfigureAwait(false); } else if (x is RichTextBox richTextBox) { var text = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd).Text; await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("RichTextBox Button was clicked!", text).ConfigureAwait(false); } else if (x is TextBox textBox) { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("TextBox Button was clicked!", textBox.Text).ConfigureAwait(false); } else if (x is PasswordBox passwordBox) { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("PasswordBox Button was clicked!", passwordBox.Password).ConfigureAwait(false); } else if (x is DatePicker datePicker) { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("DatePicker Button was clicked!", datePicker.Text).ConfigureAwait(false); } } ); this.TextBoxButtonCmdWithParameter = new SimpleCommand( o => true, async x => { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("TextBox Button with parameter was clicked!", $"Parameter: {x}"); } ); this.SingleCloseTabCommand = new SimpleCommand( o => true, async x => { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("Closing tab!", $"You are now closing the '{x}' tab"); } ); this.NeverCloseTabCommand = new SimpleCommand(o => false); this.ShowInputDialogCommand = new SimpleCommand( o => true, async x => { await this._dialogCoordinator.ShowInputAsync(this, "From a VM", "This dialog was shown from a VM, without knowledge of Window").ContinueWith(t => Console.WriteLine(t.Result)); } ); this.ShowLoginDialogCommand = new SimpleCommand( o => true, async x => { await this._dialogCoordinator.ShowLoginAsync(this, "Login from a VM", "This login dialog was shown from a VM, so you can be all MVVM.").ContinueWith(t => Console.WriteLine(t.Result)); } ); this.ShowMessageDialogCommand = new SimpleCommand( o => true, x => PerformDialogCoordinatorAction(this.ShowMessage((string)x), (string)x == "DISPATCHER_THREAD") ); this.ShowProgressDialogCommand = new SimpleCommand(o => true, x => this.RunProgressFromVm()); this.ShowCustomDialogCommand = new SimpleCommand(o => true, x => this.RunCustomFromVm()); this.ToggleIconScalingCommand = new SimpleCommand(o => true, this.ToggleIconScaling); this.OpenFirstFlyoutCommand = new SimpleCommand(o => true, o => (o as Flyout).IsOpen = !(o as Flyout).IsOpen); this.ArtistsDropDownCommand = new SimpleCommand(o => false); this.GenreDropDownMenuItemCommand = new SimpleCommand( o => true, async x => { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("DropDownButton Menu", $"You are clicked the '{x}' menu item."); } ); this.GenreSplitButtonItemCommand = new SimpleCommand( o => true, async x => { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("Split Button", $"The selected item is '{x}'."); } ); this.ShowHamburgerAboutCommand = ShowAboutCommand.Command; this.ToggleSwitchCommand = new SimpleCommand(execute: async x => { await((MetroWindow)Application.Current.MainWindow).ShowMessageAsync("ToggleSwitch", $"The ToggleSwitch is now {((ToggleSwitch)x).IsOn}."); }, canExecute: x => this.CanUseToggleSwitch); }
public Foo() { _payees = GetPayees(); _filteredPayees = CollectionViewSource.GetDefaultView(_payees); _filteredPayees.Filter = FilterPayees; }
private void ItemFilter_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) { CollectionViewSource.GetDefaultView(ItemNameView.ItemsSource).Refresh(); }
public MainViewModel() { var schools = new ObservableCollection <SchoolViewModel> { new SchoolViewModel { Name = "Bloomfield School", Pupils = new ObservableCollection <PupilViewModel> { new PupilViewModel { FullName = "Adam James" }, new PupilViewModel { FullName = "Sophie Johnston" }, new PupilViewModel { FullName = "Kevin Sandler" }, new PupilViewModel { FullName = "Oscar Peterson" } } }, new SchoolViewModel { Name = "Redacre School", Pupils = new ObservableCollection <PupilViewModel> { new PupilViewModel { FullName = "Tom Jefferson" }, new PupilViewModel { FullName = "Tony Potts" } } }, new SchoolViewModel { Name = "Top Valley School", Pupils = new ObservableCollection <PupilViewModel> { new PupilViewModel { FullName = "Alex Thompson" }, new PupilViewModel { FullName = "Tabitha Smith" }, new PupilViewModel { FullName = "Carl Pederson" }, new PupilViewModel { FullName = "Sarah Jones" }, new PupilViewModel { FullName = "Paul Lowcroft" } } } }; Schools = CollectionViewSource.GetDefaultView(schools); Pupils = new ObservableCollection <PupilViewModel> { new PupilViewModel { FullName = "TestPupil1" }, new PupilViewModel { FullName = "TestPupil2" }, new PupilViewModel { FullName = "TestPupil3" }, new PupilViewModel { FullName = "TestPupil4" }, new PupilViewModel { FullName = "TestPupil5" } }; }
/// <summary> /// Initializes a new instance of the <see cref="TargetPlatformWindow"/>. /// </summary> public TargetPlatformWindow() { InitializeComponent(); Title = TypeHelper.ApplicationNameWithVersion; var app = (BaseApplication)Application.Current; var features = new[] { new TargetPlatformFeature("Quik", Languages.Russian), new TargetPlatformFeature("SmartCOM", Languages.Russian), new TargetPlatformFeature("Plaza2", Languages.Russian), new TargetPlatformFeature("Transaq", Languages.Russian), new TargetPlatformFeature("Micex", Languages.Russian), new TargetPlatformFeature("Alfa Direct", Languages.Russian, Platforms.x86), new TargetPlatformFeature("OpenECry"), new TargetPlatformFeature("Interactive Brokers"), new TargetPlatformFeature("E*Trade"), new TargetPlatformFeature("Blackwood/Fusion"), new TargetPlatformFeature("LMAX"), new TargetPlatformFeature("IQFeed"), new TargetPlatformFeature("BarChart"), new TargetPlatformFeature("OANDA"), new TargetPlatformFeature("Rithmic"), new TargetPlatformFeature("FIX/FAST"), new TargetPlatformFeature("ITCH"), new TargetPlatformFeature("BTCE"), new TargetPlatformFeature("BitStamp"), new TargetPlatformFeature("RSS") }; _features.AddRange(features); _features.AddRange(app.ExtendedFeatures); _featuresView = (ListCollectionView)CollectionViewSource.GetDefaultView(_features); _featuresView.CustomSort = new LanguageSorter(SelectedLanguage); AppIcon = app.AppIcon; if (!Environment.Is64BitOperatingSystem) { PlatformCheckBox.IsEnabled = false; PlatformCheckBox.IsChecked = false; } else { SelectedPlatform = Platforms.x64; UpdatePlatformCheckBox(); } SelectedLanguage = LocalizedStrings.ActiveLanguage; UpdateLangButtons(); var configFile = BaseApplication.PlatformConfigurationFile; if (configFile.IsEmptyOrWhiteSpace() || !File.Exists(configFile)) { return; } var settings = new XmlSerializer <AppStartSettings>().Deserialize(configFile); SelectedPlatform = PlatformCheckBox.IsEnabled ? settings.Platform : Platforms.x86; AutoStart = settings.AutoStart; LocalizedStrings.ActiveLanguage = SelectedLanguage = settings.Language; UpdateLangButtons(); UpdatePlatformCheckBox(); }
public View_DSKhamBenh_ViewModel(ObservableCollection <BENHNHAN> ds_KhamBenh, DateTime pickedDate) { DS_KhamBenh = ds_KhamBenh; DatePicked = pickedDate; ViewSource = (CollectionView)CollectionViewSource.GetDefaultView(DS_KhamBenh); }
private void textBox_search_TextChanged(object sender, TextChangedEventArgs e) { CollectionViewSource.GetDefaultView(listView_iconList.ItemsSource).Refresh(); ButtonEnableCheck(); }
public ViewModel() { ViewSource = new CollectionViewSource(); m_controlCodes = PopulateCodeDictionary(); }
private void FillList(string table, int index) { // SET THE DATABASE CONNECTION VARS string file = vari.DefaultDirectory + "Lists.accdb"; string ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source =" + file + ";"; // Attempt to connect to the database using (var connection1 = new OleDbConnection(ConnectionString)) { OleDbCommand OComm = new OleDbCommand(); OComm.Connection = connection1; try { connection1.Open(); // Query the database to find all entries without a FINISH TIME OleDbDataAdapter DA = new OleDbDataAdapter("SELECT * FROM " + table + ";", connection1); var DataSet = new DataSet(); DA.Fill(DataSet, "*"); // Set the dataset from OleDBAdapter to the item source of the data grid object //SWITCH VISIBILITY OF THE LISTBOX FOR THE SELECTED DEPARTMENT switch (index) { case 1: LBVisib(); lb = lbBH; lbBH.Visibility = Visibility.Visible; break; case 2: LBVisib(); lb = lbSH; lbCB.Visibility = Visibility.Visible; break; case 3: LBVisib(); lb = lbCB; lbCB.Visibility = Visibility.Visible; break; case 4: LBVisib(); lb = lbC; lbCB.Visibility = Visibility.Visible; break; case 5: LBVisib(); lb = lbCS; lbCB.Visibility = Visibility.Visible; break; case 6: LBVisib(); lb = lbMisc; lbCB.Visibility = Visibility.Visible; break; } lb.DataContext = DataSet.Tables[0]; lb.ItemsSource = DataSet.Tables[0].DefaultView; ICollectionView dataView = CollectionViewSource.GetDefaultView(lb.ItemsSource); dataView.SortDescriptions.Clear(); dataView.SortDescriptions.Add(new SortDescription("file", ListSortDirection.Ascending)); dataView.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { connection1.Close(); } } }
/// <summary> /// 转换为ICollectionView /// </summary> /// <param name="data"></param> /// <returns></returns> public static ICollectionView AsICV(this IEnumerable data) { return(CollectionViewSource.GetDefaultView(data)); }
public void FillData() { SpellVisualEffects.GetAllSpellVisualEffects(); spellVisualEffectsView = CollectionViewSource.GetDefaultView(SpellVisualEffects); }
public DependencyModuleList() { InitializeComponent(); ModulesItemsView = CollectionViewSource.GetDefaultView(this.ModulesList.Items.SourceCollection); }
private void FilterData(string filterPredicate) { // Execute live filter CollectionViewSource.GetDefaultView(this.Persons).Filter = item => (item as Person).FirstName.StartsWith(filterPredicate, StringComparison.OrdinalIgnoreCase); }
internal StyleViewModel(OptionSet optionSet, IServiceProvider serviceProvider) : base(optionSet, serviceProvider, LanguageNames.CSharp) { var collectionView = (ListCollectionView)CollectionViewSource.GetDefaultView(CodeStyleItems); collectionView.GroupDescriptions.Add(new PropertyGroupDescription(nameof(AbstractCodeStyleOptionViewModel.GroupName))); var qualifyGroupTitle = CSharpVSResources.this_preferences_colon; var predefinedTypesGroupTitle = CSharpVSResources.predefined_type_preferences_colon; var varGroupTitle = CSharpVSResources.var_preferences_colon; var nullCheckingGroupTitle = CSharpVSResources.null_checking_colon; var fieldGroupTitle = ServicesVSResources.Field_preferences_colon; var codeBlockPreferencesGroupTitle = ServicesVSResources.Code_block_preferences_colon; var expressionPreferencesGroupTitle = ServicesVSResources.Expression_preferences_colon; var variablePreferencesGroupTitle = ServicesVSResources.Variable_preferences_colon; var qualifyMemberAccessPreferences = new List <CodeStylePreference> { new CodeStylePreference(CSharpVSResources.Prefer_this, isChecked: true), new CodeStylePreference(CSharpVSResources.Do_not_prefer_this, isChecked: false), }; var predefinedTypesPreferences = new List <CodeStylePreference> { new CodeStylePreference(ServicesVSResources.Prefer_predefined_type, isChecked: true), new CodeStylePreference(ServicesVSResources.Prefer_framework_type, isChecked: false), }; var typeStylePreferences = new List <CodeStylePreference> { new CodeStylePreference(CSharpVSResources.Prefer_var, isChecked: true), new CodeStylePreference(CSharpVSResources.Prefer_explicit_type, isChecked: false), }; CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyFieldAccess, CSharpVSResources.Qualify_field_access_with_this, s_fieldDeclarationPreviewTrue, s_fieldDeclarationPreviewFalse, this, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyPropertyAccess, CSharpVSResources.Qualify_property_access_with_this, s_propertyDeclarationPreviewTrue, s_propertyDeclarationPreviewFalse, this, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyMethodAccess, CSharpVSResources.Qualify_method_access_with_this, s_methodDeclarationPreviewTrue, s_methodDeclarationPreviewFalse, this, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.QualifyEventAccess, CSharpVSResources.Qualify_event_access_with_this, s_eventDeclarationPreviewTrue, s_eventDeclarationPreviewFalse, this, optionSet, qualifyGroupTitle, qualifyMemberAccessPreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInDeclaration, ServicesVSResources.For_locals_parameters_and_members, s_intrinsicPreviewDeclarationTrue, s_intrinsicPreviewDeclarationFalse, this, optionSet, predefinedTypesGroupTitle, predefinedTypesPreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIntrinsicPredefinedTypeKeywordInMemberAccess, ServicesVSResources.For_member_access_expressions, s_intrinsicPreviewMemberAccessTrue, s_intrinsicPreviewMemberAccessFalse, this, optionSet, predefinedTypesGroupTitle, predefinedTypesPreferences)); // Use var CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.UseImplicitTypeForIntrinsicTypes, CSharpVSResources.For_built_in_types, s_varForIntrinsicsPreviewTrue, s_varForIntrinsicsPreviewFalse, this, optionSet, varGroupTitle, typeStylePreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.UseImplicitTypeWhereApparent, CSharpVSResources.When_variable_type_is_apparent, s_varWhereApparentPreviewTrue, s_varWhereApparentPreviewFalse, this, optionSet, varGroupTitle, typeStylePreferences)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.UseImplicitTypeWherePossible, CSharpVSResources.Elsewhere, s_varWherePossiblePreviewTrue, s_varWherePossiblePreviewFalse, this, optionSet, varGroupTitle, typeStylePreferences)); // Code block CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferBraces, ServicesVSResources.Prefer_braces, s_preferBraces, s_preferBraces, this, optionSet, codeBlockPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferAutoProperties, ServicesVSResources.analyzer_Prefer_auto_properties, s_preferAutoProperties, s_preferAutoProperties, this, optionSet, codeBlockPreferencesGroupTitle)); AddParenthesesOptions(Options); // Expression preferences CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferObjectInitializer, ServicesVSResources.Prefer_object_initializer, s_preferObjectInitializer, s_preferObjectInitializer, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCollectionInitializer, ServicesVSResources.Prefer_collection_initializer, s_preferCollectionInitializer, s_preferCollectionInitializer, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferPatternMatchingOverIsWithCastCheck, CSharpVSResources.Prefer_pattern_matching_over_is_with_cast_check, s_preferPatternMatchingOverIsWithCastCheck, s_preferPatternMatchingOverIsWithCastCheck, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferPatternMatchingOverAsWithNullCheck, CSharpVSResources.Prefer_pattern_matching_over_as_with_null_check, s_preferPatternMatchingOverAsWithNullCheck, s_preferPatternMatchingOverAsWithNullCheck, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferConditionalExpressionOverAssignment, ServicesVSResources.Prefer_conditional_expression_over_if_with_assignments, s_preferConditionalExpressionOverIfWithAssignments, s_preferConditionalExpressionOverIfWithAssignments, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferConditionalExpressionOverReturn, ServicesVSResources.Prefer_conditional_expression_over_if_with_returns, s_preferConditionalExpressionOverIfWithReturns, s_preferConditionalExpressionOverIfWithReturns, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferExplicitTupleNames, ServicesVSResources.Prefer_explicit_tuple_name, s_preferExplicitTupleName, s_preferExplicitTupleName, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferSimpleDefaultExpression, ServicesVSResources.Prefer_simple_default_expression, s_preferSimpleDefaultExpression, s_preferSimpleDefaultExpression, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredTupleNames, ServicesVSResources.Prefer_inferred_tuple_names, s_preferInferredTupleName, s_preferInferredTupleName, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInferredAnonymousTypeMemberNames, ServicesVSResources.Prefer_inferred_anonymous_type_member_names, s_preferInferredAnonymousTypeMemberName, s_preferInferredAnonymousTypeMemberName, this, optionSet, expressionPreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferLocalOverAnonymousFunction, ServicesVSResources.Prefer_local_function_over_anonymous_function, s_preferLocalFunctionOverAnonymousFunction, s_preferLocalFunctionOverAnonymousFunction, this, optionSet, expressionPreferencesGroupTitle)); AddExpressionBodyOptions(optionSet, expressionPreferencesGroupTitle); // Variable preferences CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferInlinedVariableDeclaration, ServicesVSResources.Prefer_inlined_variable_declaration, s_preferInlinedVariableDeclaration, s_preferInlinedVariableDeclaration, this, optionSet, variablePreferencesGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferDeconstructedVariableDeclaration, ServicesVSResources.Prefer_deconstructed_variable_declaration, s_preferDeconstructedVariableDeclaration, s_preferDeconstructedVariableDeclaration, this, optionSet, variablePreferencesGroupTitle)); // Null preferences. CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferThrowExpression, CSharpVSResources.Prefer_throw_expression, s_preferThrowExpression, s_preferThrowExpression, this, optionSet, nullCheckingGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CSharpCodeStyleOptions.PreferConditionalDelegateCall, CSharpVSResources.Prefer_conditional_delegate_call, s_preferConditionalDelegateCall, s_preferConditionalDelegateCall, this, optionSet, nullCheckingGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferCoalesceExpression, ServicesVSResources.Prefer_coalesce_expression, s_preferCoalesceExpression, s_preferCoalesceExpression, this, optionSet, nullCheckingGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferNullPropagation, ServicesVSResources.Prefer_null_propagation, s_preferNullPropagation, s_preferNullPropagation, this, optionSet, nullCheckingGroupTitle)); CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferIsNullCheckOverReferenceEqualityMethod, CSharpVSResources.Prefer_is_null_over_ReferenceEquals, s_preferIsNullOverReferenceEquals, s_preferIsNullOverReferenceEquals, this, optionSet, nullCheckingGroupTitle)); // Field preferences. CodeStyleItems.Add(new BooleanCodeStyleOptionViewModel(CodeStyleOptions.PreferReadonly, ServicesVSResources.Prefer_readonly, s_preferReadonly, s_preferReadonly, this, optionSet, fieldGroupTitle)); }
public PropertyGrid() { PropertiesSource = new CollectionViewSource(); PropertiesSource.GroupDescriptions.Add(new PropertyGroupDescription(CategoryPropertyName)); }
//---------------------------------------------------------- public static void parameter_symbol(Document doc, ElementType type, ListView thong_tin_kich_thuoc, ObservableCollection <data_parameters> my_parameters, string unit_length) { try { foreach (Parameter para in type.Parameters) { if (para.Definition.ParameterGroup == BuiltInParameterGroup.PG_GEOMETRY && para.IsReadOnly == false) { my_parameters.Add(new data_parameters() { ten_parameter = para.Definition.Name, gia_tri_parameter = get_value(para, unit_length), group_parameter = "Dimensions", parameter = para }); } else if (para.Definition.ParameterGroup == BuiltInParameterGroup.PG_DATA && para.IsReadOnly == false) { my_parameters.Add(new data_parameters() { ten_parameter = para.Definition.Name, gia_tri_parameter = get_value(para, unit_length), group_parameter = "Data", parameter = para }); } else if (para.Definition.ParameterGroup == BuiltInParameterGroup.PG_VISIBILITY && para.IsReadOnly == false) { string value = "0"; if (para.StorageType == StorageType.Integer) { if (ParameterType.YesNo == para.Definition.ParameterType) { if (para.AsInteger() == 0) { value = "False"; } else { value = "True"; } } else { value = para.AsInteger().ToString(); } } my_parameters.Add(new data_parameters() { ten_parameter = para.Definition.Name, gia_tri_parameter = value, group_parameter = "Visibility (Example: True or False)", parameter = para, }); } } thong_tin_kich_thuoc.ItemsSource = my_parameters; ListCollectionView view = CollectionViewSource.GetDefaultView(thong_tin_kich_thuoc.ItemsSource) as ListCollectionView; PropertyGroupDescription groupDescription1 = new PropertyGroupDescription("group_parameter"); view.GroupDescriptions.Add(groupDescription1); view.CustomSort = new sort_data_parameters(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { //runs second //tab1dataGrid1.ItemsSource = RimworldXmlLoader.Mods; //List<ModView> modsView = new List<ModView>(); //new list of ModView ModsView = new List <ModView>(); //new list of ModView var i = 0; //crashes if Mods is empty. wow what.... try { foreach (var mod in RimworldXmlLoader.Mods) { ModsView.Add(new ModView()); ModsView[i].Index = i; ModsView[i].Loadposition = mod.ModRank; ModsView[i].Enabled = mod.ModEnabled; ModsView[i].Version = mod.ModXmlDetails.ModTargetVersion; ModsView[i].Modname = mod.ModXmlDetails.ModName; ModsView[i].Nummodconflicts = mod.ConflictedMods.Count; mod.ConflictedMods.Each((item, n) => { ModsView[i].Modconflicts.Add(item.ModXmlDetails.ModName); }); ModsView[i].Numdllconflicts = mod.ConflictedDlls.Count; ModsView[i].Numcoreconflicts = mod.CoreOverrights; ModsView[i].Numxmlfiles = mod.XmlFiles.Count; ModsView[i].Moddir = mod.DirName; ModsView[i].Fullmoddir = mod.FullDirName; i++; } //tab1dataGrid1.ItemsSource = modsView; var viewmodsView = CollectionViewSource.GetDefaultView(ModsView); viewmodsView.SortDescriptions.Add(new SortDescription("Loadposition", ListSortDirection.Ascending)); //initial sort //filtering. needs INotifyCollectionChanged to update display... BindingErrorTraceListener.SetTrace(); tab1dataGrid1.ItemsSource = viewmodsView; //instead of ItemsSource="{Binding viewmodsView}" //from datagrid1 removed Style="{DynamicResource DGHeaderStyle}" //modsView.CustomSort = new CustomerSorter(); //modsView.SortDescriptions.Add(new SortDescription("loadposition", ListSortDirection.Ascending)); //tab2dataGrid1.UpdateLayout(); //tab2grid1.UpdateLayout(); //foreach (DataGridColumn c in tab2dataGrid1.Columns) //c.Width = DataGridLength.Auto; MyDatagrid.ItemsSource = viewmodsView; //InitializeComponent(); } catch (Exception ex) { Logger.Instance.LogError("Crash in populating results form.", ex); //throw; } }
public MainWindow() { InitializeComponent(); _collectionView = CollectionViewSource.GetDefaultView(DataContext); }
public string DumpListToString(bool fCSV, IEnumerable srcColl = null) { var sb = new StringBuilder(); var gridview = this.View as GridView; var isFirst = true; _ = CollectionViewSource.GetDefaultView(this.ItemsSource); var colNames = new List <string>(); var priorPadding = 0; int[] widths = new int[gridview.Columns.Count]; var colndx = 0; foreach (var col in gridview.Columns) { if (isFirst) { isFirst = false; } else { if (fCSV) { sb.Append(","); } else { for (var i = 0; i < priorPadding; i++) { sb.Append(" "); } } } var txt = (col.Header as GridViewColumnHeader).Content.ToString(); colNames.Add(txt); widths[colndx] = (int)(col.ActualWidth / 6); priorPadding = widths[colndx] - txt.Length; sb.Append(txt); colndx++; } sb.AppendLine(); if (srcColl == null) { if (this.SelectedItems.Count > 0) { srcColl = this.SelectedItems; } else { srcColl = this.Items; } } void doit(string strval) { if (string.IsNullOrEmpty(strval)) { strval = string.Empty; } strval = strval.Trim(); if (isFirst) { isFirst = false; } else { if (fCSV) { sb.Append(","); } else { for (var i = 0; i < priorPadding; i++) { sb.Append(" "); } } } if (!string.IsNullOrEmpty(strval)) { strval = strval.ToString(); if (fCSV) { if (strval.Contains(",") || strval.Contains(" ")) { strval = "\"" + strval + "\""; } } sb.Append(strval); } else { strval = string.Empty; } if (colndx < widths.Length) { priorPadding = widths[colndx] - strval.Length; } } foreach (var row in srcColl) { isFirst = true; priorPadding = 0; for (colndx = 0; colndx < colNames.Count; colndx++) { var colName = colNames[colndx]; //if (colName.Contains(".")) // could it be a dynobj? like "Request.username" //{ // var propName = "_x" + colName.Substring(0, colName.IndexOf(".")); // like "_xRequest // var dict = ObjectFromXml.GetProps(propName, row); // foreach (var val in dict.Values) // { // doit(val); // } //} try { var typeDescProp = TypeDescriptor.GetProperties(row)[colName]; if (typeDescProp != null) { var rawval = typeDescProp.GetValue(row); if (rawval == null) { doit(string.Empty); } else { var val = rawval.ToString(); doit(val); } } else { var typdesc = TypeDescriptor.GetProperties(row); var baseValtDesc = typdesc?[0]; var baseVal = baseValtDesc?.GetValue(row); var baseType = baseVal?.GetType(); var len = baseType?.GetMember(colName).Length; if (len > 0) { var propInfo = (PropertyInfo)baseType?.GetMember(colName)?[0]; var val = propInfo?.GetValue(baseVal); doit(val?.ToString()); } } } catch (Exception) { } } sb.AppendLine(); } return(sb.ToString()); }
private void cbbMaa_SelectionChanged(object sender, SelectionChangedEventArgs e) { CollectionViewSource.GetDefaultView(lvUsers.ItemsSource).Refresh(); }
public void Save() { //Get an instance of the service using Helper class var client = Helper.getServiceClient(); try { //Get the current object in the EditGrid var EmployeeTDToSave = (HR_EMPLOYEE_TD)CollectionViewSource.GetDefaultView(employee.EmployeeTDGrid.DataContext).CurrentItem; //This is used incase a user never enters a textbox but still needs validating employee.TDDropDown.GetBindingExpression(CustomSearchDropDown.CustomSelectedItemProperty).UpdateSource(); //employee.txt_LastEmployeeSerialNoLTI.GetBindingExpression(TextBox.TextProperty).UpdateSource(); //employee.txt_LastVoucherNoLTI.GetBindingExpression(TextBox.TextProperty).UpdateSource(); //employee.txt_ProductCodeLTI.GetBindingExpression(TextBox.TextProperty).UpdateSource(); //employee.txt_SubSystemCodeLTI.GetBindingExpression(TextBox.TextProperty).UpdateSource(); //Checking if all controls are in valid state if (!Helper.IsValid(employee.EmployeeTDGrid)) { MessageBox.Show("Please fix errors before continuing", "Message", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } //A user is trying to add a record here if (employee.BtnAdd.IsChecked == true) { if (!client.EmployeeTDExists(EmployeeTDToSave)) { ApiAck ack = client.CreateEmployeeTD(EmployeeTDToSave); if (ack.CallStatus == EApiCallStatus.Success) { MessageBox.Show("Record Added Successfully", "Message", MessageBoxButton.OK, MessageBoxImage.Information); //Complete the Add operation. i.e.; Re-enable tabs,textboxes and datagrid CompleteAdd(); } else { MessageBox.Show(ack.ReturnedMessage, "Message", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("Record Already Exists", "Message", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } //Else the user is trying to update a record else { ApiAck ack = client.UpdateEmployeeTD(EmployeeTDToSave); if (ack.CallStatus == EApiCallStatus.Success) { MessageBox.Show("Record Updated Successfully", "Message", MessageBoxButton.OK, MessageBoxImage.Information); CompleteUpdate(); } else { MessageBox.Show(ack.ReturnedMessage, "Message", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } } catch (NullReferenceException) { MessageBox.Show("Nothing to Update", "Message", MessageBoxButton.OK, MessageBoxImage.Exclamation); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
// Store SortDescriptions in dictionary private void UpdateSorting() { ICollectionView view = CollectionViewSource.GetDefaultView(ItemsSource); m_SortDescriptions[ItemsSource] = new List <SortDescription>(view.SortDescriptions); }
public WorldViewModel() { if (IsInDesignModeStatic) { return; } CheckUpdates = Settings.Default.CheckUpdates; if (CheckUpdates) { CheckVersion(); } IsAutoSaveEnabled = Settings.Default.Autosave; _undoManager = new UndoManager(this); _clipboard = new ClipboardManager(this); World.ProgressChanged += OnProgressChanged; Brush.BrushChanged += OnPreviewChanged; UpdateTitle(); _spriteFilter = string.Empty; _spritesView = (ListCollectionView)CollectionViewSource.GetDefaultView(World.Sprites); _spritesView.Filter = o => { if (string.IsNullOrWhiteSpace(_spriteFilter)) { return(true); } var sprite = (Sprite)o; string[] _spriteFilterSplit = _spriteFilter.Split('/'); foreach (string _spriteWord in _spriteFilterSplit) { if (sprite.TileName == _spriteWord) { return(true); } if (sprite.Name == _spriteWord) { return(true); } if (sprite.TileName != null && sprite.TileName.IndexOf(_spriteWord, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } if (sprite.Name != null && sprite.Name.IndexOf(_spriteWord, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } if (sprite.TileName == _spriteFilter) { return(true); } if (sprite.Name == _spriteFilter) { return(true); } if (sprite.TileName != null && sprite.TileName.IndexOf(_spriteFilter, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } if (sprite.Name != null && sprite.Name.IndexOf(_spriteFilter, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } return(false); }; _spritesView2 = (ListCollectionView)CollectionViewSource.GetDefaultView(World.Sprites2); _spritesView2.Filter = o => { if (string.IsNullOrWhiteSpace(_spriteFilter)) { return(true); } var sprite = (SpriteFull)o; string[] _spriteFilterSplit = _spriteFilter.Split(new char[] { '/', ',' }, StringSplitOptions.RemoveEmptyEntries); if (sprite.Tile.ToString().StartsWith(_spriteFilter)) { return(true); } foreach (string _spriteWord in _spriteFilterSplit) { if (sprite.Name == _spriteWord) { return(true); } if (sprite.Name != null && sprite.Name.IndexOf(_spriteWord, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } foreach (var style in sprite.Styles) { if (style.Value.Name != null && style.Value.Name.IndexOf(_spriteWord, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } } return(false); }; UpdateSpriteStyleView(); _saveTimer.AutoReset = true; _saveTimer.Elapsed += SaveTimerTick; // 3 minute save timer _saveTimer.Interval = 3 * 60 * 1000; _undoManager.Redid += UpdateMinimap; _undoManager.Undid += UpdateMinimap; _undoManager.UndoSaved += UpdateMinimap; // Test File Association and command line if (Application.Current.Properties["OpenFile"] != null) { string filename = Application.Current.Properties["OpenFile"].ToString(); LoadWorld(filename); } }
private void HandleClick(object sender, RoutedEventArgs e) { _disposable.Disposable = Observable.Return(new GriColumnAndDirection(AssociatedObject.GetDataGrid(), AssociatedObject.GetColumn(), Direction)) .Select(x => new ColumnCollectionViewAndDirection(x.Column, CollectionViewSource.GetDefaultView(x.Grid.ItemsSource), x.Direction)) .Where(x => x.HasSortDescriptions) .ActivateGestures() .Subscribe(x => { x.Column.SortDirection = x.Direction; x.View.SortDescriptions.Clear(); x.View.SortDescriptions.Add(new SortDescription(x.Column.SortMemberPath, x.Direction)); }); }