/// <summary> /// Refreshes the orders. /// </summary> /// <param name="dcbOrder">The DCB order.</param> protected void RefreshOrders(DictionaryComboBox dcbOrder) { dcbOrder.Filters.Clear(); var ucContact = dcbOrder.Parent.FindControl("ucContact") as ContactComboBox; var dcbContractor = dcbOrder.Parent.FindControl("dcbContractor") as DictionaryComboBox; if (ucContact.SelectedValue.HasValue && ucContact.SelectedValue.Value != Guid.Empty) { dcbOrder.Filters.Add(new DictionaryComboBox.DictionaryFilterColumn() { Name = "BuyerContactID", DbType = DbType.Guid, Value = ucContact.SelectedValue.Value.ToString() }); } if (dcbContractor.SelectedIdNullable.HasValue && dcbContractor.SelectedIdNullable.Value != Guid.Empty) { dcbOrder.Filters.Add(new DictionaryComboBox.DictionaryFilterColumn() { Name = "BuyerCompanyID", DbType = DbType.Guid, Value = dcbContractor.SelectedIdNullable.Value.ToString() }); } dcbOrder.BindData(); }
public HeaderWidget(Shuffler shuffler, string shuffle_mode_id, string source_name) : base(0, 0, 0, 0) { ThreadAssist.AssertInMainThread (); var box = new HBox (); box.Spacing = 6; var fill_label = new Label (Catalog.GetString ("_Fill")); mode_combo = new DictionaryComboBox<RandomBy> (); foreach (var random_by in shuffler.RandomModes.OrderBy (r => r.Adverb)) { mode_combo.Add (random_by.Adverb, random_by); if (random_by.Id == "off") { mode_combo.Default = random_by; } } fill_label.MnemonicWidget = mode_combo; mode_combo.Changed += OnModeComboChanged; var from_label = new Label (Catalog.GetString ("f_rom")); var source_combo_box = new QueueableSourceComboBox (source_name); from_label.MnemonicWidget = source_combo_box; sensitive_widgets.Add (source_combo_box); sensitive_widgets.Add (from_label); source_combo_box.Changed += delegate { var handler = SourceChanged; if (handler != null) { handler (this, new EventArgs<DatabaseSource> (source_combo_box.Source)); } }; box.PackStart (fill_label, false, false, 0); box.PackStart (mode_combo, false, false, 0); box.PackStart (from_label, false, false, 0); box.PackStart (source_combo_box, false, false, 0); this.SetPadding (0, 0, 6, 6); this.Add (box); // Select the saved population mode. var default_randomby = shuffler.RandomModes.FirstOrDefault (r => r.Id == shuffle_mode_id); if (default_randomby != null) { mode_combo.ActiveValue = default_randomby; } else if (mode_combo.Default != null) { mode_combo.ActiveValue = mode_combo.Default; } shuffler.RandomModeAdded += (r) => mode_combo.Add (r.Adverb, r); shuffler.RandomModeRemoved += (r) => mode_combo.Remove (r); }
public LibrarySyncOptions(DapLibrarySync library_sync) { this.library_sync = library_sync; var library = library_sync.Library; // Translators: {0} is the name of a library, eg 'Music' or 'Podcasts' var label = new Label(String.Format(Catalog.GetString("{0}:"), library.Name)) { Xalign = 1f }; // Create the combo for selecting what type of sync to do for this library combo = new DictionaryComboBox <DatabaseSource> (); combo.RowSeparatorFunc = (model, iter) => { return((string)model.GetValue(iter, 0) == "---"); }; combo.Add(null, Catalog.GetString("Manage manually"), -10); combo.Add(null, Catalog.GetString("Sync entire library"), -9); foreach (var child in library.Children) { AddPlaylist(child); } library.ChildSourceAdded += OnChildSourceAdded; library.ChildSourceRemoved += OnChildSourceRemoved; if (!library_sync.Enabled) { combo.Active = 0; } else if (library_sync.SyncEntireLibrary) { combo.Active = 1; } else if (library_sync.SyncSource != null) { combo.ActiveValue = library_sync.SyncSource; } combo.Changed += (o, a) => { library_sync.Enabled = combo.Active != 0; library_sync.SyncEntireLibrary = combo.Active == 1; if (combo.Active > 1) { library_sync.SyncSource = combo.ActiveValue; } library_sync.MaybeTriggerAutoSync(); }; RowCells = new Widget [] { label, combo }; }
public LibrarySyncOptions(DapLibrarySync library_sync) { this.library_sync = library_sync; var library = library_sync.Library; // Translators: {0} is the name of a library, eg 'Music' or 'Podcasts' var label = new Label (String.Format (Catalog.GetString ("{0}:"), library.Name)) { Xalign = 1f }; // Create the combo for selecting what type of sync to do for this library combo = new DictionaryComboBox<DatabaseSource> (); combo.RowSeparatorFunc = (model, iter) => { return (string)model.GetValue (iter, 0) == "---"; }; combo.Add (null, Catalog.GetString ("Manage manually"), -10); combo.Add (null, Catalog.GetString ("Sync entire library"), -9); foreach (var child in library.Children) { AddPlaylist (child); } library.ChildSourceAdded += OnChildSourceAdded; library.ChildSourceRemoved += OnChildSourceRemoved; if (!library_sync.Enabled) combo.Active = 0; else if (library_sync.SyncEntireLibrary) combo.Active = 1; else if (library_sync.SyncSource != null) combo.ActiveValue = library_sync.SyncSource; combo.Changed += (o, a) => { library_sync.Enabled = combo.Active != 0; library_sync.SyncEntireLibrary = combo.Active == 1; if (combo.Active > 1) { library_sync.SyncSource = combo.ActiveValue; } library_sync.MaybeTriggerAutoSync (); }; RowCells = new Widget [] { label, combo }; }
public HeaderWidget(Shuffler shuffler, string shuffle_mode_id, string source_name) : base(0, 0, 0, 0) { ThreadAssist.AssertInMainThread(); var box = new HBox(); box.Spacing = 6; var fill_label = new Label(Catalog.GetString("_Fill")); mode_combo = new DictionaryComboBox <RandomBy> (); foreach (var random_by in shuffler.RandomModes.OrderBy(r => r.Adverb)) { mode_combo.Add(random_by.Adverb, random_by); if (random_by.Id == "off") { mode_combo.Default = random_by; } } fill_label.MnemonicWidget = mode_combo; mode_combo.Changed += OnModeComboChanged; var from_label = new Label(Catalog.GetString("f_rom")); var source_combo_box = new QueueableSourceComboBox(source_name); from_label.MnemonicWidget = source_combo_box; sensitive_widgets.Add(source_combo_box); sensitive_widgets.Add(from_label); source_combo_box.Changed += delegate { var handler = SourceChanged; if (handler != null) { handler(this, new EventArgs <DatabaseSource> (source_combo_box.Source)); } }; box.PackStart(fill_label, false, false, 0); box.PackStart(mode_combo, false, false, 0); box.PackStart(from_label, false, false, 0); box.PackStart(source_combo_box, false, false, 0); this.SetPadding(0, 0, 6, 6); this.Add(box); // Select the saved population mode. var default_randomby = shuffler.RandomModes.FirstOrDefault(r => r.Id == shuffle_mode_id); if (default_randomby != null) { mode_combo.ActiveValue = default_randomby; } else if (mode_combo.Default != null) { mode_combo.ActiveValue = mode_combo.Default; } shuffler.RandomModeAdded += (r) => mode_combo.Add(r.Adverb, r); shuffler.RandomModeRemoved += (r) => mode_combo.Remove(r); }
private Control GetControl(BaseEntityObject obj, PropertyInfo propertyInfo, int controlWidth, bool controlEnabled) { #region ЭУ для прикрепленного файла if (propertyInfo.PropertyType.Name == nameof(AttachedFile) || propertyInfo.PropertyType.IsSubclassOf(typeof(AttachedFile))) { object val = propertyInfo.GetValue(obj, null); return(new AttachedFileControl { AttachedFile = (AttachedFile)val, Enabled = controlEnabled, Filter = "PDF file (*.pdf)|*.pdf", Icon = Properties.Resources.PDFIconSmall, MaximumSize = new Size(350, 100), Size = new Size(350, 75), Tag = propertyInfo }); } #endregion #region ЭУ для StaticDictionary if (propertyInfo.PropertyType.IsSubclassOf(typeof(StaticDictionary))) { object val = propertyInfo.GetValue(obj, null); if (propertyInfo.PropertyType.GetCustomAttributes(typeof(TableAttribute), false).Length > 0) { DictionaryComboBox dc = new DictionaryComboBox { Enabled = controlEnabled, Name = propertyInfo.Name, SelectedItem = (StaticDictionary)val, Tag = propertyInfo, Type = propertyInfo.PropertyType, }; //для возможности вызова новой вкладки Program.MainDispatcher.ProcessControl(dc); // return(dc); } ComboBox nc = new ComboBox { Enabled = controlEnabled, Tag = propertyInfo, Width = controlWidth, }; //поиск своиства Items у типа StaticDictionary Type t = propertyInfo.PropertyType; PropertyInfo p = t.GetProperty("Items"); ConstructorInfo ci = t.GetConstructor(new Type[0]); StaticDictionary instance = (StaticDictionary)ci.Invoke(null); IEnumerable staticList = (IEnumerable)p.GetValue(instance, null); foreach (StaticDictionary o in staticList) { nc.Items.Add(o); } nc.SelectedItem = val; return(nc); } #endregion #region ЭУ для AbstractDictionary if (propertyInfo.PropertyType.IsSubclassOf(typeof(AbstractDictionary))) { AbstractDictionary val = (AbstractDictionary)propertyInfo.GetValue(obj, null); DictionaryComboBox dc = new DictionaryComboBox { Enabled = controlEnabled, SelectedItem = val, Tag = propertyInfo, Type = propertyInfo.PropertyType, }; //для возможности вызова новой вкладки Program.MainDispatcher.ProcessControl(dc); // return(dc); } #endregion #region ЭУ для BaseEntityObject if (propertyInfo.PropertyType.IsSubclassOf(typeof(BaseEntityObject))) { object val = propertyInfo.GetValue(obj, null); TextBox tb = new TextBox { AutoSize = true, Enabled = controlEnabled, Tag = propertyInfo, Text = val != null?val.ToString() : "", Width = controlWidth, }; return(tb); } #endregion #region ЭУ для Enum if (propertyInfo.PropertyType.IsEnum) { object val = propertyInfo.GetValue(obj, null); if (propertyInfo.PropertyType.GetCustomAttributes(typeof(FlagsAttribute), false).Length > 0) { CommonFlagsControl cfc = new CommonFlagsControl { Enabled = controlEnabled, SourceEnum = propertyInfo.PropertyType, Tag = propertyInfo }; return(cfc); } ComboBox nc = new ComboBox { Enabled = controlEnabled, Tag = propertyInfo }; foreach (object o in Enum.GetValues(propertyInfo.PropertyType)) { nc.Items.Add(o); } nc.SelectedItem = val; return(nc); } #endregion //#region ЭУ для базовых типов //string typeName = propertyInfo.PropertyType.Name.ToLower(); //switch (typeName) //{ // case "string": // { // string val = (string)propertyInfo.GetValue(obj, null); // Control control; // if (richTextBox) // { // RichTextBox richText = new RichTextBox // { // AutoSize = true, // Enabled = controlEnabled, // MinimumSize = new Size(20, 17), // Multiline = controlLines > 1, // Tag = propertyInfo, // Width = controlWidth, // }; // try // { // richText.Rtf = val; // } // catch (Exception) // { // richText.Text = val; // } // if (controlLines > 1) // { // richText.ScrollBars = RichTextBoxScrollBars.Both; // richText.Height = richText.Font.Height * controlLines + 7; // } // control = richText; // } // else // { // TextBox textBox = new TextBox // { // AutoSize = true, // Enabled = controlEnabled, // MinimumSize = new Size(20, 17), // Multiline = controlLines > 1, // Tag = propertyInfo, // Text = val, // Width = controlWidth, // }; // if (controlLines > 1) // { // textBox.ScrollBars = ScrollBars.Vertical; // textBox.Height = textBox.Font.Height * controlLines + 7; // } // control = textBox; // } // return control; // } // case "int32": // { // Int32 val = (Int32)propertyInfo.GetValue(obj, null); // MinMaxValueAttribute mmValue = // (MinMaxValueAttribute)propertyInfo.GetCustomAttributes(typeof(MinMaxValueAttribute), false).FirstOrDefault(); // NumericUpDown nud = new NumericUpDown(); // if (mmValue != null) // { // nud.Maximum = (decimal)mmValue.Max; // nud.Minimum = (decimal)mmValue.Min; // if (val < (Int32)mmValue.Min) val = (Int32)mmValue.Min; // if (val > (Int32)mmValue.Max) val = (Int32)mmValue.Max; // } // nud.Enabled = controlEnabled; // nud.Value = val; // nud.DecimalPlaces = 0; // nud.MinimumSize = new Size(20, 17); // nud.Tag = propertyInfo; // return nud; // } // case "int16": // { // object val = propertyInfo.GetValue(obj, null); // MinMaxValueAttribute mmValue = // (MinMaxValueAttribute)propertyInfo.GetCustomAttributes(typeof(MinMaxValueAttribute), false).FirstOrDefault(); // NumericUpDown nud = new NumericUpDown(); // if (mmValue != null) // { // nud.Maximum = (decimal)mmValue.Max; // nud.Minimum = (decimal)mmValue.Min; // } // nud.Enabled = controlEnabled; // nud.Value = (Int16)val; // nud.DecimalPlaces = 0; // nud.MinimumSize = new Size(20, 17); // nud.Tag = propertyInfo; // return nud; // } // case "datetime": // { // DateTime val = (DateTime)propertyInfo.GetValue(obj, null); // return new DateTimePicker // { // Enabled = controlEnabled, // MinDate = new DateTime(1950,1,1), // MinimumSize = new Size(20, 17), // //AutoSize = true, // Tag = propertyInfo, // Value = val > DateTimePicker.MinimumDateTime ? new DateTime(val.Ticks) : DateTimePicker.MinimumDateTime // }; // } // case "bool": // case "boolean": // { // object val = propertyInfo.GetValue(obj, null); // return new CheckBox // { // Checked = (bool)val, // Enabled = controlEnabled, // MinimumSize = new Size(20, 17), // //AutoSize = true, // Tag = propertyInfo // }; // } // case "double": // { // object val = propertyInfo.GetValue(obj, null); // MinMaxValueAttribute mmValue = // (MinMaxValueAttribute)propertyInfo.GetCustomAttributes(typeof(MinMaxValueAttribute), false).FirstOrDefault(); // NumericUpDown nud = new NumericUpDown(); // if (mmValue != null) // { // nud.Maximum = (decimal)mmValue.Max; // nud.Minimum = (decimal)mmValue.Min; // } // nud.Enabled = controlEnabled; // nud.Value = (decimal) (double) val; // nud.DecimalPlaces = 2; // nud.MinimumSize = new Size(20, 17); // nud.Tag = propertyInfo; // return nud; // } // case "directivethreshold": // { // object val = propertyInfo.GetValue(obj, null); // return new DirectiveThresholdControl { Enabled = controlEnabled, Threshold = (DirectiveThreshold)val, Tag = propertyInfo }; // } // case "detaildirectivethreshold": // { // object val = propertyInfo.GetValue(obj, null); // return new DetailDirectiveThresholdControl { Enabled = controlEnabled, Threshold = (DetailDirectiveThreshold)val, Tag = propertyInfo }; // } // case "lifelength": // { // object val = propertyInfo.GetValue(obj, null); // return new LifelengthViewer // { // Enabled = controlEnabled, // Lifelength = (Lifelength) val, // MinimumSize = new Size(20, 17), // Tag = propertyInfo // }; // } // case "timespan": // { // TimeSpan val = (TimeSpan)propertyInfo.GetValue(obj, null); // return new DateTimePicker // { // CustomFormat = "HH:mm", // Enabled = controlEnabled, // Format = DateTimePickerFormat.Custom, // MinDate = new DateTime(1950, 1, 1), // MinimumSize = new Size(20, 17), // //AutoSize = true, // ShowUpDown = true, // Tag = propertyInfo, // Value = DateTime.Today.Add(val) // }; // } // default: // return null; //} //#endregion return(null); }