private void DataBaseTypeLink() { this.uxRelationName.Content = Integrity.BuildForeighKeyName(this.SelectedParentTable.ItemKey.ToString(), this.SelectedChildTable.ItemKey.ToString()); foreach (ColumnObjectModel keyColumn in Integrity.GetObjectModel(this.SelectedParentTable.ItemKey.ToString()).Where(pk => pk.InPrimaryKey)) { ComboBoxTool parentBox = new ComboBoxTool(); ComboBoxTool childBox = new ComboBoxTool(); parentBox.Name = $"{parentComboName}{this.uxParentColumns.Children.Count}"; childBox.Name = $"{childComboName}{this.uxChildColumns.Children.Count}"; parentBox.Items.Add(new DataItemModel { DisplayValue = keyColumn.ColumnName, ItemKey = keyColumn.ColumnName }); foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedChildTable.ItemKey.ToString())) { childBox.Items.Add(item); } parentBox.SelectedValue = keyColumn.ColumnName; this.uxParentColumns.Children.Add(parentBox); this.uxChildColumns.Children.Add(childBox); } }
private void AddSelectFromColumnOption(string selectedValue, int desiredIndex) { DataItemModel fromTable = this.uxFromTable.SelectedItem.To <DataItemModel>(); bool haveChild = desiredIndex < this.uxSelectColumnsStack.Children.Count; ComboBoxTool resultBox = haveChild ? this.uxSelectColumnsStack.Children[desiredIndex].To <ComboBoxTool>() : new ComboBoxTool(); if (!haveChild) { resultBox.Items.Add(new DataItemModel { DisplayValue = Constants.None, ItemKey = Constants.None }); foreach (DataItemModel tableColumn in Integrity.GetColumnsForTable(fromTable.DisplayValue).OrderBy(t => t.DisplayValue)) { DataItemModel optionColumn = new DataItemModel { DisplayValue = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}", ItemKey = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}" }; resultBox.Items.Add(optionColumn); } resultBox.SelectionChanged += this.SelectColumnChanged; this.uxSelectColumnsStack.Children.Add(resultBox); } resultBox.SelectedValue = selectedValue; }
public void run() { if (ServiceManager.Instance.ApplicationName != "Paragon") { //windowManager.WindowLayoutLoaded += windowManager_WindowLayoutLoaded; } else { //create toolbar CommandBar myToolBar = sCommandBarManager.CommandBars.AddCommandBar("mytoolbar"); myToolBar.Caption = "박현수 파라곤 유틸리티"; //CREATE BUTTON ButtonTool bt = sCommandBarManager.RootTools.AddButtonTool("specgenerator", "specgenerator", Image.FromFile(@"Q:\env\Icons\AngleDetail.jpg")); bt.Tooltip = "보바수바"; bt.ToolClick += new System.EventHandler(this.RunCmd); //CREATE BUTTON ButtonTool bt2 = sCommandBarManager.RootTools.AddButtonTool("park2", "33", Image.FromFile(@"Q:\env\Icons\banmok.jpg")); bt2.Tooltip = "보바수바2"; bt2.ToolClick += new System.EventHandler(this.RunCmd); //CREATE COMBOBOX ComboBoxTool cb = sCommandBarManager.RootTools.AddComboBoxTool("park3", "44", null); //ADD VALUE LIST cb.ValueList.Add("11"); cb.ValueList.Add("12"); cb.ValueList.Add("13"); //ADD TOOLBAR ITEM myToolBar.Tools.AddTool("specgenerator"); myToolBar.Tools.AddTool("park2"); myToolBar.Tools.AddTool("park3"); //sCommandBarManager.RootTools.AddButtonTool() //myToolBar.Tools.AddTool("nbCommand2"); //myToolBar.Tools.AddTool("nbCommand3"); //myToolBar.Tools.AddTool("nbCommand4"); //for (int i = 0; i < mDlls.Count; i++) //{ // System.Drawing.Image icon = null; // ButtonTool bt = sCommandBarManager.RootTools.AddButtonTool("babo1", "babo11-1", icon); // bt.Tooltip = "baboya"; // bt.ToolClick += new System.EventHandler(this.RunCmd); // myToolBar.Tools.AddTool(fName); //} } }
public void SetComboBoxItems(DataItemModel[] sourceItems) { ComboBoxTool comboBox = (ComboBoxTool)this.contentObject; comboBox.Items.Clear(); foreach (DataItemModel valueItem in sourceItems) { comboBox.Items.Add(valueItem); } }
public static void AddEnum(this ComboBoxTool destination, Type enumType) { foreach (var item in Enum.GetValues(enumType)) { DataItemModel result = new DataItemModel { DisplayValue = TranslationDictionary.Translate(item.GetDescriptionAttribute()), ItemKey = item }; destination.Items.Add(result); } }
private void RelationEditor_Loaded(object sender, RoutedEventArgs e) { try { this.SelectedParentTable = this.TablesList.FirstOrDefault(pt => pt.ItemKey.ToString() == this.DatabaseRelation.ParentTable); this.SelectedChildTable = this.TablesList.FirstOrDefault(pt => pt.ItemKey.ToString() == this.DatabaseRelation.ChildTable); UIElement[] childBoxes = this.uxChildColumns.FindVisualControls(typeof(ComboBoxTool)); List <ColumnRelationMapModel> actualRelations = new List <ColumnRelationMapModel>(); foreach (ComboBoxTool parentBox in this.uxParentColumns.FindVisualControls(typeof(ComboBoxTool))) { if (parentBox.SelectedValue == null) { // Vertual Relation Empty Box continue; } ColumnRelationMapModel relation = this.DatabaseRelation.Columns.FirstOrDefault(r => r.ParentColumn == parentBox.SelectedValue.ToString()); if (relation == null) { continue; } string parentIndex = parentBox.Name.Split(new char[] { '_' })[1]; string childStartName = $"{childComboName}{parentIndex}"; ComboBoxTool childBox = (ComboBoxTool)childBoxes.FirstOrDefault(c => ((ComboBoxTool)c).Name.StartsWith(childStartName)); actualRelations.Add(relation); childBox.SelectedValue = relation.ChildColumn; } this.DatabaseRelation.Columns.Clear(); this.DatabaseRelation.Columns.AddRange(actualRelations); this.wasLoaded = true; } catch (Exception err) { MessageBox.Show(err.InnerExceptionMessage()); } }
private void LoadContentValues(object parentObject, object tool) { switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: break; case ModelItemTypeEnum.ComboBox: if (this.valuesSource == null) { return; } ComboBoxTool comboBox = (ComboBoxTool)tool; PropertyInfo sourceProp = parentObject.GetType().GetProperty(this.valuesSource.PropertyName); DataItemModel[] sourceItems = (DataItemModel[])sourceProp.GetValue(parentObject); foreach (DataItemModel valueItem in sourceItems) { comboBox.Items.Add(valueItem); } break; case ModelItemTypeEnum.EnumBox: ComboBoxTool enumBox = (ComboBoxTool)tool; foreach (var item in Enum.GetValues(this.PropertyInfo.PropertyType)) { enumBox.Items.Add(new DataItemModel { DisplayValue = item.GetDescriptionAttribute(), ItemKey = item }); } break; case ModelItemTypeEnum.DatePicker: case ModelItemTypeEnum.ColorBox: case ModelItemTypeEnum.TextBox: default: break; } }
void Aveva.ApplicationFramework.IAddin.Start(ServiceManager serviceManager) { sServiceManager = serviceManager; sCommandManager = (CommandManager)sServiceManager.GetService(typeof(CommandManager)); sCommandBarManager = (CommandBarManager)sServiceManager.GetService(typeof(CommandBarManager)); //Add ExampleCommand to Command Manager sCommandManager.Commands.Add(new ExampleCommand()); //Create example toolbar menu CommandBar myToolBar = sCommandBarManager.CommandBars.AddCommandBar("ExampleCommandBar"); //sCommandBarManager.RootTools.AddButtonTool("ExampleCommand", "ExampleCommand", null, "ExampleCommand"); //myToolBar.Tools.AddTool("ExampleCommand"); ComboBoxTool tool = sCommandBarManager.RootTools.AddComboBoxTool("ExampleCommand", "Examples", null, "ExampleCommand"); tool.SelectedIndex = 0; myToolBar.Tools.AddTool("ExampleCommand"); }
private void ChildBox_Closed(object sender, EventArgs e) { try { ComboBoxTool box = (ComboBoxTool)sender; if (box.SelectedItem == null) { return; } box.DropDownClosed -= this.ChildBox_Closed; this.AddColumnSelection(); } catch (Exception err) { MessageBox.Show(err.GetFullExceptionMessage()); } }
public void AddComboBoxItem(DataItemModel sourceItem) { ComboBoxTool comboBox = (ComboBoxTool)this.contentObject; List <string> comboBoxKeys = new List <string>(); foreach (DataItemModel valueItem in comboBox.Items) { comboBoxKeys.Add(valueItem.ItemKey.ParseToString()); } comboBoxKeys.Add(sourceItem.ItemKey.ParseToString()); comboBox.Items.Add(sourceItem); if (this.Binding != null) { ((IsRequiredValidationRule)this.Binding.ValidationRules.First(r => r.GetType() == typeof(IsRequiredValidationRule))).ComboBoxKeys = comboBoxKeys.ToArray(); } }
private void toolbarsManager_ToolKeyPress(object sender, Infragistics.Win.UltraWinToolbars.ToolKeyPressEventArgs e) { switch (e.Tool.Key) { case "mnuFindField": if (e.KeyChar == 0x0D) { ComboBoxTool cbt = (e.Tool as ComboBoxTool); editor.FindNext(cbt.Text, false, false, false); bool found = false; for (int i = 0; i < cbt.ValueList.ValueListItems.Count; i++) { if (cbt.ValueList.ValueListItems[i].DisplayText.Equals(cbt.Text)) { found = true; break; } } if (!found) { cbt.ValueList.ValueListItems.Add(cbt.Text); } } break; case "mnuGotoLine": if (e.KeyChar == 0x0D) { int lineNum = 1; TextBoxTool tbt = (e.Tool as TextBoxTool); int.TryParse(tbt.Text, out lineNum); editor.GotoLine(lineNum - 1); editor.Focus(); } break; default: break; } }
private void CreateContent(object parentObject, FieldInformationAttribute fieldValues) { BindingMode bindingMode = this.PropertyInfo.CanRead && this.PropertyInfo.CanWrite ? BindingMode.TwoWay : this.PropertyInfo.CanWrite ? BindingMode.OneWayToSource : BindingMode.OneWay; Binding binding = new Binding(this.PropertyInfo.Name) { Path = new PropertyPath(this.PropertyInfo.Name), Source = parentObject, Mode = bindingMode, BindsDirectlyToSource = true, }; binding.ValidationRules.Add(new IsRequiredValidationRule { IsRequired = fieldValues.IsRequired, ObjectType = this.ObjectType }); this.IsTabStop = !fieldValues.IsReadOnly; switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: #region CHECK BOX CheckBoxItem check = new CheckBoxItem { IsEnabled = !fieldValues.IsReadOnly }; check.GotFocus += this.Item_Focuesd; this.DependencyProperty = CheckBoxItem.IsCheckedProperty; check.SetBinding(CheckBoxItem.IsCheckedProperty, binding); this.BindingExpression = check.GetBindingExpression(CheckBoxItem.IsCheckedProperty); this.contentObject = check; break; #endregion case ModelItemTypeEnum.ComboBox: case ModelItemTypeEnum.EnumBox: #region COMBO BOX ComboBoxTool comboBox = new ComboBoxTool { IsEnabled = !fieldValues.IsReadOnly, IsEditable = this.isComboBoxEdit }; comboBox.HorizontalAlignment = HorizontalAlignment.Stretch; comboBox.GotFocus += this.Item_Focuesd; this.LoadContentValues(parentObject, comboBox); this.DependencyProperty = this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty; comboBox.SetBinding(this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty, binding); this.BindingExpression = comboBox.GetBindingExpression(this.isComboBoxEdit ? ComboBoxTool.TextProperty : ComboBoxTool.ItemKeyProperty); this.contentObject = comboBox; break; #endregion case ModelItemTypeEnum.DatePicker: #region DATE PICKER DatePicker date = new DatePicker { IsEnabled = !fieldValues.IsReadOnly }; //binding.ValidationRules.Clear(); date.HorizontalAlignment = HorizontalAlignment.Stretch; date.GotFocus += this.Item_Focuesd; this.DependencyProperty = DatePicker.SelectedDateProperty; date.SetBinding(DatePicker.SelectedDateProperty, binding); this.BindingExpression = date.GetBindingExpression(DatePicker.SelectedDateProperty); this.contentObject = date; break; #endregion case ModelItemTypeEnum.SecureString: #region SECURE STRING PasswordBoxBindable pass = new PasswordBoxBindable(parentObject) { IsEnabled = !fieldValues.IsReadOnly }; pass.HorizontalAlignment = HorizontalAlignment.Stretch; pass.HorizontalContentAlignment = HorizontalAlignment.Stretch; pass.LostFocus += this.Item_Focuesd; this.DependencyProperty = PasswordBoxBindable.PasswordTextProperty; pass.SetBinding(PasswordBoxBindable.PasswordTextProperty, binding); this.BindingExpression = pass.GetBindingExpression(PasswordBoxBindable.PasswordTextProperty); this.contentObject = pass; break; #endregion case ModelItemTypeEnum.ColorBox: case ModelItemTypeEnum.TextBox: default: #region TEXT BOX (DEFAULT) TextBoxItem text = new TextBoxItem { IsReadOnly = fieldValues.IsReadOnly, TextWrapping = TextWrapping.WrapWithOverflow }; text.MaxHeight = 250; text.MaxLength = fieldValues.MaxTextLength; text.VerticalScrollBarVisibility = ScrollBarVisibility.Auto; text.HorizontalAlignment = HorizontalAlignment.Stretch; text.HorizontalContentAlignment = HorizontalAlignment.Stretch; text.SpellCheck.IsEnabled = this.isSpellCheck; text.LostFocus += this.Item_Focuesd; this.DependencyProperty = TextBoxItem.TextProperty; text.SetBinding(TextBoxItem.TextProperty, binding); this.BindingExpression = text.GetBindingExpression(TextBoxItem.TextProperty); this.contentObject = text; if (this.ObjectType == ModelItemTypeEnum.ColorBox && !text.Text.IsNullEmptyOrWhiteSpace()) { text.Background = ColourConverters.GetBrushfromHex(text.Text); text.Foreground = ColourConverters.InvertFromHex(text.Text); } break; #endregion } this.uxContent.Content = this.contentObject; }
private void prcCreateButton(RibbonTab rt, RibbonGroup rtg, string strContainerFlag) { try { foreach (DataRow dr in dsMaster.Tables["Menu"].Rows) { if (Int16.Parse(dr["isFormBased"].ToString()) != 0) { ButtonTool btn = new ButtonTool(dr["menuId"].ToString()); btn.SharedProps.Caption = dr["menuCaption"].ToString(); //Picture does not Exist for menu if (Int16.Parse(dr["menuImageExist"].ToString()) == 0) { this.toolMan.Tools.Add(btn); rtg.Tools.AddTool(dr["menuId"].ToString()); } else { alMenuImage.Add(dr["menuId"].ToString()); //Picture Exist for menu prcFillImageList(dr["menuImageName"].ToString(), Int16.Parse(dr["menuImageSize"].ToString())); Common.Classes.clsMain.alMnuFrmName.Add(dr["frmName"].ToString()); if (Int16.Parse(dr["menuImageSize"].ToString()) != 2) { //Small Image btn.SharedProps.AppearancesSmall.Appearance.Image = alMenuImage.Count - 1;//Common.Classes.clsMain.alMnuFrmName.Count - 1; } else { //Large Image btn.SharedProps.AppearancesLarge.Appearance.Image = alMenuImage.Count - 1; } btn.SharedProps.DisplayStyle = ToolDisplayStyle.ImageAndText; this.toolMan.Tools.Add(btn); //Set Large Image ToolBase tb = rtg.Tools.AddTool(dr["MenuId"].ToString()); tb.CustomizedCaption = dr["menuCaption"].ToString(); if (Int16.Parse(dr["menuImageSize"].ToString()) == 2) { tb.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large; } } } if (strContainerFlag == "Combo") { //Crate Combobox tool ComboBoxTool cbo = new ComboBoxTool("cbo" + dr["menuName"].ToString()); //Create ValueList For Loading Combo Data ValueList valueList1 = new ValueList(0); valueList1.DisplayStyle = Infragistics.Win.ValueListDisplayStyle.DisplayText; valueList1.PreferredDropDownSize = new System.Drawing.Size(0, 0); string strDefault = ""; foreach (DataRow dr3 in dsMaster.Tables["Company"].Rows) { if (Int16.Parse(dr3["isDefault"].ToString()) != 0) { strDefault = dr3["comId"].ToString(); } ValueListItem v1 = new ValueListItem(); v1.DataValue = dr3["comId"].ToString(); v1.DisplayText = dr3["comName"].ToString(); valueList1.ValueListItems.Add(v1); } cbo.ValueList = valueList1; this.toolMan.Tools.AddRange(new ToolBase[] { cbo }); ToolBase tbCompany = rtg.Tools.AddTool(cbo.Key); //Set Default Value if (strDefault.Length > 0) { ((ComboBoxTool)toolMan.Tools[cbo.Key]).Value = Int16.Parse(strDefault); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Creating Button"); } }
private void prcInitializeRibbon() { string strCaption = "Initializing Ribbon"; try { //Configure Ribbon this.toolMan.Ribbon.Visible = true; this.toolMan.DockWithinContainer = this; this.toolMan.DockWithinContainerBaseType = typeof(System.Windows.Forms.Form); //Setup Style Of Ribbon toolMan.Style = Infragistics.Win.UltraWinToolbars.ToolbarStyle.Office2010; toolMan.Ribbon.FileMenuStyle = Infragistics.Win.UltraWinToolbars.FileMenuStyle.ApplicationMenu2010; //ImageList this.toolMan.ImageListLarge = ilLarge; this.toolMan.ImageListSmall = ilSmall; // Create Basic Ribbon Tab foreach (DataRow dr in dsMaster.Tables["Module"].Rows) { strCaption = "Creating Tab"; RibbonTab rt = new RibbonTab(dr["moduleId"].ToString(), dr["moduleCaption"].ToString()); this.toolMan.Ribbon.Tabs.Add(rt); } //Creating Ribbon Group foreach (DataRow dr in dsMaster.Tables["Group"].Rows) { strCaption = "Creating Group"; RibbonGroup rg = new RibbonGroup(dr["mMenuGroupId"].ToString(), dr["mMenuGroupCaption"].ToString()); this.toolMan.Ribbon.Tabs[dr["moduleId"].ToString()].Groups.Add(rg); } #region Creating Button //Creating Button foreach (DataRow dr in dsMaster.Tables["Menu"].Rows) { strCaption = "Creating Button : " + dr["MenuCaption"].ToString(); #region Form Based Button if (Int16.Parse(dr["isFormBased"].ToString()) != 0) { ButtonTool btn = new ButtonTool(dr["menuId"].ToString()); btn.SharedProps.Caption = dr["menuCaption"].ToString(); if (Int16.Parse(dr["menuImageExist"].ToString()) == 0) { //Picture does not Exist for menu this.toolMan.Tools.Add(btn); this.toolMan.Ribbon.Tabs[dr["moduleId"].ToString()].Groups[dr["mMenuGroupId"].ToString()].Tools.Add(btn); } else { //Picture Exist for menu alMenuImage.Add(dr["menuId"].ToString()); //Picture Exist for menu prcFillImageList(dr["menuImageName"].ToString(), Int16.Parse(dr["menuImageSize"].ToString())); Common.Classes.clsMain.alMnuFrmName.Add(dr["frmName"].ToString()); if (Int16.Parse(dr["menuImageSize"].ToString()) != 2) { //Small Image btn.SharedProps.AppearancesSmall.Appearance.Image = alMenuImage.Count - 1;//Common.Classes.clsMain.alMnuFrmName.Count - 1; } else { //Large Image btn.SharedProps.AppearancesLarge.Appearance.Image = alMenuImage.Count - 1; } btn.SharedProps.DisplayStyle = ToolDisplayStyle.TextOnlyInMenus; #region Normal Menu [No DropDown Menu] if (Int16.Parse(dr["IsDropDown"].ToString()) == 0) { this.toolMan.Tools.Add(btn); //Set Large Image for tool ToolBase tb = this.toolMan.Ribbon.Tabs[dr["moduleId"].ToString()].Groups[dr["mMenuGroupId"].ToString()].Tools.AddTool(dr["MenuId"].ToString()); tb.CustomizedCaption = dr["menuCaption"].ToString(); if (Int16.Parse(dr["menuImageSize"].ToString()) == 2) { tb.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large; } } #endregion Normal Menu [No DropDown Menu] #region DropDown Menu if (Int16.Parse(dr["IsDropDown"].ToString()) == 1) { if (Int16.Parse(dr["DropDownParentId"].ToString()) == 0) { Infragistics.Win.Appearance ap1 = new Infragistics.Win.Appearance(); ap1.Image = alMenuImage.Count - 1; PopupMenuTool pmt = new PopupMenuTool(dr["menuId"].ToString()); pmt.DropDownArrowStyle = DropDownArrowStyle.Segmented; pmt.SharedPropsInternal.Caption = dr["menuCaption"].ToString(); pmt.SharedPropsInternal.Category = "DROPDOWNPARENT"; //Used to stop working when click on the main menu pmt.SharedPropsInternal.ToolTipText = "Select menu from list"; pmt.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large; //Setup Appearance pmt.SharedPropsInternal.AppearancesSmall.Appearance = ap1; toolMan.Tools.Add(pmt); toolMan.Ribbon.Tabs[dr["moduleId"].ToString()].Groups[dr["mMenuGroupId"].ToString()].Tools.AddTool(pmt.Key.ToString()); } else { StateButtonTool sbt = new StateButtonTool(dr["menuId"].ToString()); sbt.SharedPropsInternal.Caption = dr["menuCaption"].ToString(); sbt.CustomizedImage = ilSmall.Images[alMenuImage.Count - 1]; toolMan.Tools.Add(sbt); ((PopupMenuTool)(this.toolMan.Ribbon.Tabs[dr["moduleId"].ToString()].Groups[dr["mMenuGroupId"].ToString()].Tools[dr["DropdownParentId"].ToString()])).Tools.AddRange(new ToolBase[] { sbt }); } } #endregion DropDown Menu } } #endregion Form Based Button #region Combo Button if ((dr["ContainerType"]).ToString() == "Combo") { //Crate Combobox tool ComboBoxTool cbo = new ComboBoxTool("cbo" + dr["menuName"].ToString()); //Create ValueList For Loading Combo Data ValueList valueList1 = new ValueList(0); valueList1.DisplayStyle = Infragistics.Win.ValueListDisplayStyle.DisplayText; valueList1.PreferredDropDownSize = new System.Drawing.Size(0, 0); string strDefault = ""; foreach (DataRow dr3 in dsMaster.Tables["Company"].Rows) { if (Int16.Parse(dr3["isDefault"].ToString()) != 0) { strDefault = dr3["comId"].ToString(); } ValueListItem v1 = new ValueListItem(); v1.DataValue = dr3["comId"].ToString(); v1.DisplayText = dr3["comName"].ToString(); valueList1.ValueListItems.Add(v1); } cbo.ValueList = valueList1; this.toolMan.Tools.AddRange(new ToolBase[] { cbo }); ToolBase tbCompany = this.toolMan.Ribbon.Tabs[dr["moduleId"].ToString()].Groups[dr["mMenuGroupId"].ToString()].Tools.AddTool(cbo.Key); //ToolBase tbCompany = ((RibbonGroup)dr["mMenuGroupId"]).Tools.AddTool(cbo.Key); //Set Default Value if (strDefault.Length > 0) { ((ComboBoxTool)toolMan.Tools[cbo.Key]).Value = Int16.Parse(strDefault); } } #endregion Combo Button } #endregion Creating Button } catch (Exception ex) { MessageBox.Show(ex.Message, strCaption); } }
private void Accept_Cliked(object sender, RoutedEventArgs e) { try { Dictionary <string, string> childToParentRelation = new Dictionary <string, string>(); string parentTable = this.SelectedParentTable.ItemKey.ToString(); string childTable = this.SelectedChildTable.ItemKey.ToString(); UIElement[] parentBoxes = this.uxParentColumns.FindVisualControls(typeof(ComboBoxTool)); foreach (ComboBoxTool childBox in this.uxChildColumns.Children) { string parentBoxName = childBox.Name.Replace(childComboName, parentComboName); ComboBoxTool parentBox = (ComboBoxTool)parentBoxes.First(b => ((ComboBoxTool)b).Name == parentBoxName); if (childBox.SelectedItem == null || parentBox.SelectedItem == null) { continue; } string childColumnName = ((DataItemModel)childBox.SelectedItem).ItemKey.ToString(); string parentColumnName = ((DataItemModel)parentBox.SelectedItem).ItemKey.ToString(); if (childToParentRelation.ContainsKey(childColumnName)) { throw new ApplicationException($"Cannot have duplicate selections for child {childBox.SelectedItem}."); } if (Integrity.GetGlobalColumnDataType(childColumnName) != Integrity.GetGlobalColumnDataType(parentColumnName)) { throw new ApplicationException($"Inconsistent Data Types {parentColumnName} – {childColumnName}."); } childToParentRelation.Add(childColumnName, parentColumnName); } this.DatabaseRelation.ParentTable = parentTable; this.DatabaseRelation.ChildTable = childTable; this.DatabaseRelation.RelationshipName = this.uxRelationName.Content.ToString(); this.DatabaseRelation.Columns.Clear(); foreach (ColumnObjectModel column in Integrity.GetObjectModel(childTable)) { if (!childToParentRelation.ContainsKey(column.ColumnName)) { continue; } column.ForeignConstraintName = this.DatabaseRelation.RelationshipName; column.ForeignKeyColumn = childToParentRelation[column.ColumnName]; column.ForeignKeyTable = this.DatabaseRelation.ParentTable; column.IsVertualRelation = (this.DatabaseRelation.RelationType == RelationTypesEnum.VirtualRelation); column.IsForeignkey = true; this.DatabaseRelation.Columns.Add(new ColumnRelationMapModel { ChildColumn = column.ColumnName, ChildTable = this.DatabaseRelation.ChildTable, ForeignConstraintName = this.DatabaseRelation.RelationshipName, ParentColumn = childToParentRelation[column.ColumnName], ParentTable = this.DatabaseRelation.ParentTable }); } this.DialogResult = true; //this.Close(); } catch (Exception err) { MessageBox.Show(err.GetFullExceptionMessage()); } }
private void VirtualTypeLink() { this.uxRelationName.Content = Integrity.BuildForeighKeyName(this.SelectedParentTable.ItemKey.ToString(), this.SelectedChildTable.ItemKey.ToString()); if (!this.wasLoaded) { foreach (ColumnRelationMapModel column in this.DatabaseRelation.Columns) { ComboBoxTool parentBox = new ComboBoxTool(); ComboBoxTool childBox = new ComboBoxTool(); parentBox.Name = $"{parentComboName}{this.uxParentColumns.Children.Count}"; childBox.Name = $"{childComboName}{this.uxChildColumns.Children.Count}"; foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedParentTable.ItemKey.ToString())) { parentBox.Items.Add(item); } foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedChildTable.ItemKey.ToString())) { childBox.Items.Add(item); } childBox.DropDownClosed += this.ChildBox_Closed; parentBox.SelectedValue = column.ParentColumn; this.uxParentColumns.Children.Add(parentBox); this.uxChildColumns.Children.Add(childBox); } } ComboBoxTool emptyParentBox = new ComboBoxTool(); ComboBoxTool emptyChildBox = new ComboBoxTool(); emptyParentBox.Name = $"{parentComboName}{this.uxParentColumns.Children.Count}"; emptyChildBox.Name = $"{childComboName}{this.uxChildColumns.Children.Count}"; foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedParentTable.ItemKey.ToString())) { emptyParentBox.Items.Add(item); } foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedChildTable.ItemKey.ToString())) { emptyChildBox.Items.Add(item); } emptyChildBox.DropDownClosed += this.ChildBox_Closed; //parentBox.SelectedValue = keyColumn.ColumnName; this.uxParentColumns.Children.Add(emptyParentBox); this.uxChildColumns.Children.Add(emptyChildBox); }
private void LoadContentValues(object parentObject, object tool) { switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: break; case ModelItemTypeEnum.ComboBox: if (this.valuesSource == null) { return; } ComboBoxTool comboBox = (ComboBoxTool)tool; PropertyInfo sourceProp = parentObject.GetType().GetProperty(this.valuesSource.PropertyName); DataItemModel[] sourceItems = (DataItemModel[])sourceProp.GetValue(parentObject); List <string> comboBoxKeys = new List <string>(); foreach (DataItemModel valueItem in sourceItems) { comboBoxKeys.Add(valueItem.ItemKey.ParseToString()); comboBox.Items.Add(valueItem); } if (this.Binding != null) { ((IsRequiredValidationRule)this.Binding.ValidationRules.First(r => r.GetType() == typeof(IsRequiredValidationRule))).ComboBoxKeys = comboBoxKeys.ToArray(); } break; case ModelItemTypeEnum.EnumBox: ComboBoxTool enumBox = (ComboBoxTool)tool; List <string> enumBoxKeys = new List <string>(); foreach (var item in Enum.GetValues(this.PropertyInfo.PropertyType)) { enumBoxKeys.Add(item.ParseToString()); enumBox.Items.Add(new DataItemModel { DisplayValue = item.GetDescriptionAttribute(), ItemKey = item }); } if (this.Binding != null) { ((IsRequiredValidationRule)this.Binding.ValidationRules.First(r => r.GetType() == typeof(IsRequiredValidationRule))).ComboBoxKeys = enumBoxKeys.ToArray(); } break; case ModelItemTypeEnum.DatePicker: break; case ModelItemTypeEnum.TextBox: default: break; } }