protected override bool SetCreateTypeInfo(IComponent pComponent) { if (pComponent is RibbonPageItem) { RibbonPageItem item = (RibbonPageItem)pComponent; IRibbonControl pRibbonControl = item.TryGetDependRibbonControl(); if (pRibbonControl != null) { item.LineDistance = 2; item.ColumnDistance = 2; //item.ShowBackgroud = true; } } else if (pComponent is RibbonBarItem) { RibbonBarItem item = (RibbonBarItem)pComponent; IRibbonControl pRibbonControl = item.TryGetDependRibbonControl(); if (pRibbonControl != null) { item.Padding = new Padding(3, 3, 3, 2); } } else if (pComponent is TextBoxItem) { TextBoxItem item = (TextBoxItem)pComponent; IRibbonControl pRibbonControl = item.TryGetDependRibbonControl(); if (pRibbonControl != null) { item.Size = new Size(100, 21); } } // return(base.SetCreateTypeInfo(pComponent)); }
/// <summary> /// 保存数据 /// </summary> private void SaveData() { foreach (object o in itemPanel1.Items) { string text = string.Empty; ItemContainer container = o as ItemContainer; TextBoxItem textBox = container.SubItems[1] as TextBoxItem; if (textBox != null) // 存在文本框 { text += textBox.TextBox.Text; if ((container.SubItems.Count == 3) && (container.SubItems[2] is ComboBoxItem)) // 添加下拉框的内容 { text += (container.SubItems[2] as ComboBoxItem).SelectedItem.ToString(); } } else // 不存在文本框,检查下拉框 { if ((container.SubItems.Count == 2) && (container.SubItems[1] is ComboBoxItem)) // 添加下拉框的内容 { text += (container.SubItems[1] as ComboBoxItem).SelectedItem.ToString(); } } inputList.Add(text); } }
private void Initialize() { NameScope.SetNameScope(this, new NameScope()); ResourceDictionary resource = new ResourceDictionary(); Uri resourcePath = new Uri("/WPF.Tools;component/Templates/ControlsTemplate.xaml", UriKind.Relative); resource.Source = resourcePath; this.Resources.MergedDictionaries.Add(resource); this.Template = this.FindResource("WatermarkText") as ControlTemplate; this.ApplyTemplate(); this.box = (TextBoxItem)this.Template.FindName("uxUsetText", this); this.block = (TextBlock)this.Template.FindName("uxWaterMark", this); this.mainGrid = (Grid)this.Template.FindName("uxMainGrid", this); this.box.TextChanged += this.box_TextChanged; this.box.GotFocus += this.Box_GotFocus; this.box.LostFocus += this.Box_LostFocus; this.box.ActionKeyPresed += this.BoxActionKey_Pressed; this.HorizontalAlignment = HorizontalAlignment.Stretch; this.VerticalAlignment = VerticalAlignment.Stretch; }
private void ButtonIncluirItem_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(TextBoxItem.Text)) { itensCompra.Add(new ViewModelItemCompra { Descricao = TextBoxItem.Text }); TextBoxItem.Text = string.Empty; TextBoxItem.Focus(); } }
public void SetValue(object value) { switch (this.ObjectType) { case ModelItemTypeEnum.CheckBox: ((CheckBoxItem)this.contentObject).IsChecked = value.TryToBool(); break; case ModelItemTypeEnum.ComboBox: case ModelItemTypeEnum.EnumBox: ((ComboBoxTool)this.contentObject).SelectedValue = value; break; case ModelItemTypeEnum.DatePicker: ((DatePicker)this.contentObject).SelectedDate = value.TryToDate(); break; case ModelItemTypeEnum.SecureString: ((PasswordBoxBindable)this.contentObject).Password = value.ParseToString(); break; case ModelItemTypeEnum.ColorBox: TextBoxItem color = (TextBoxItem)this.contentObject; color.Background = ColourConverters.GetBrushfromHex(value.ParseToString()); color.Foreground = ColourConverters.InvertFromHex(value.ParseToString()); goto default; case ModelItemTypeEnum.TextBox: default: ((TextBoxItem)this.contentObject).Text = value.ParseToString(); break; } }
private void LoadBuildParamaters() { ResourceOption resourceOps = new ResourceOption(); foreach (DataItemModel arg in resourceOps.ScriptParameterOptions()) { TextBoxItem item = new TextBoxItem { Text = arg.ItemKey.ToString(), ToolTip = arg.DisplayValue, IsReadOnly = true, BorderThickness = new Thickness(0) }; this.uxParametersList.Children.Add(item); } }
private void Item_Focuesd(object sender, RoutedEventArgs e) { try { if (this.ModelViewItemGotFocus != null) { this.ModelViewItemGotFocus(this, this.contentObject); } if (this.ObjectType == ModelItemTypeEnum.ColorBox) { TextBoxItem text = (TextBoxItem)sender; text.Background = ColourConverters.GetBrushfromHex(text.Text); text.Foreground = ColourConverters.InvertFromHex(text.Text); } } catch { // DO NOTHING } }
private void Form1_Load(object sender, System.EventArgs e) { ExplorerBarGroupItem group = new ExplorerBarGroupItem("group1", "Search"); group.SetDefaultAppearance(); explorerBar1.Groups.Add(group); LabelItem label = new LabelItem("searchLabel", "Search by any or all of the criteria below."); label.Stretch = true; label.WordWrap = true; label.Font = new Font(explorerBar1.Font, FontStyle.Bold); group.SubItems.Add(label); label = new LabelItem("searchLabel1", "All or part of the file name:"); label.Stretch = true; label.WordWrap = true; group.SubItems.Add(label); // Hosting Text Box on Explorer Bar TextBoxItem textItem = new TextBoxItem("txtFileName"); textItem.Stretch = true; group.SubItems.Add(textItem); // Hosting Label on Explorer Bar label = new LabelItem("searchLabel2", "Look in:"); label.Stretch = true; label.WordWrap = true; group.SubItems.Add(label); // Hosting Combo Box on Explorer Bar ComboBoxItem combo = new ComboBoxItem("cboLookIn"); combo.Stretch = true; DevComponents.Editors.ComboItem cboItem = new DevComponents.Editors.ComboItem(); cboItem.Text = "My Computer"; combo.Items.Add(cboItem); combo.SelectedIndex = 0; group.SubItems.Add(combo); group.Expanded = true; group = new ExplorerBarGroupItem("group2", "When was it modified?"); group.SetDefaultAppearance(); explorerBar1.Groups.Add(group); // Hosting any .NET controls on Explorer Bar in this case RadioButton // Don't remember Option ControlContainerItem cont = new ControlContainerItem("chk1", "Don't Remember"); RadioButton option = new RadioButton(); option.Name = "chkDontRemember"; option.Text = "Don't Remember"; option.Font = new Font(explorerBar1.Font, FontStyle.Bold); option.Checked = true; option.BackColor = Color.Transparent; cont.Control = option; group.SubItems.Add(cont); // Within last week cont = new ControlContainerItem("chk1", "Within last week"); option = new RadioButton(); option.Name = "chkLastweek"; option.Text = "Within last week"; option.BackColor = Color.Transparent; cont.Control = option; group.SubItems.Add(cont); // Past month cont = new ControlContainerItem("chk1", "Past month"); option = new RadioButton(); option.Name = "chkLastMonth"; option.Text = "Past month"; option.BackColor = Color.Transparent; cont.Control = option; group.SubItems.Add(cont); // Within the past year cont = new ControlContainerItem("chk1", "Within the past year"); option = new RadioButton(); option.Name = "chkLastYear"; option.Text = "Within the past year"; option.BackColor = Color.Transparent; cont.Control = option; group.SubItems.Add(cont); group = new ExplorerBarGroupItem("group3", "Additional Options"); group.SetDefaultAppearance(); explorerBar1.Groups.Add(group); group.Expanded = true; // Other Search Options ButtonItem btn = new ButtonItem("bSearchOptions", "Other search options"); btn.HotFontUnderline = true; btn.HotTrackingStyle = eHotTrackingStyle.None; btn.Image = new Bitmap(this.GetType(), "Options.png"); btn.ImagePosition = eImagePosition.Left; btn.ButtonStyle = eButtonStyle.ImageAndText; btn.Cursor = Cursors.Hand; group.SubItems.Add(btn); // Change Preferences btn = new ButtonItem("bPreferences", "Change Preferences"); btn.HotFontUnderline = true; btn.HotTrackingStyle = eHotTrackingStyle.None; btn.Image = new Bitmap(this.GetType(), "Preferences.png"); btn.ImagePosition = eImagePosition.Left; btn.ButtonStyle = eButtonStyle.ImageAndText; btn.Cursor = Cursors.Hand; group.SubItems.Add(btn); // Applies all layout changes and refreshes display explorerBar1.RecalcLayout(); }
/// <summary> /// 初始化数据 /// </summary> private void InitData() { // 调整label的宽度 int maxLabelLength = 0; int length = 0; foreach (string s in data) { string[] t = s.Split(new char[] { ',' }); length = 0; foreach (char c in t[0].ToCharArray()) { if (c == 60 || c > 128) // 中文字符 { length += 15; } else // 英文字符 { length += 8; } } if (length > maxLabelLength) { maxLabelLength = length; } } for (int i = 0; i < data.Length; i++) { string[] values = data[i].Split(new char[] { ',' }); ItemContainer container = new ItemContainer(); LabelItem label = new LabelItem("labelItem" + i, values[0]); label.Width = maxLabelLength; TextBoxItem textBox = new TextBoxItem("textBoxItem" + i, values[2]); textBox.Tag = values[1]; textBox.TextBoxWidth = 200; textBox.TextBox.BorderStyle = BorderStyle.Fixed3D; textBox.TextBox.Text = values[2]; container.SubItems.Add(label); container.SubItems.Add(textBox); switch (values[1]) // 检查输入的类型 { case "text": // 文本类型 { ButtonItem buttonItem = new ButtonItem("buttonItem" + i, "编辑"); buttonItem.Click += new EventHandler(editText); buttonItem.Tag = textBox.TextBox; // 绑定文本框 container.SubItems.Add(buttonItem); while (maxLabelLength + 270 + 30 > this.Width) // 自动调整宽度 { this.Width += 30; } break; } case "int": // 整数类型 { textBox.TextBox.TextChanged += new EventHandler(textBoxTextChanged); while (maxLabelLength + 270 > this.Width) // 自动调整宽度 { this.Width += 30; } break; } case "readonly": // 只读类型 { textBox.Enabled = false; while (maxLabelLength + 270 > this.Width) // 自动调整宽度 { this.Width += 30; } break; } case "list": // 下拉菜单类型 { ComboBoxItem comboBox = new ComboBoxItem("comboBox" + i, ""); string s = values[2]; string[] sections = s.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries); switch (sections.Length) { case 1: // 无内容有列表值 { if (s.Contains("@")) // 带文本的下拉框 { textBox.TextBox.Text = ""; // 更改文本内容 string[] t = sections[0].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string r in t) { comboBox.Items.Add(r); } comboBox.SelectedIndex = 0; container.SubItems.Add(comboBox); while (maxLabelLength + 270 + comboBox.ComboWidth > this.Width) // 自动调整宽度 { this.Width += 30; } } else // 不带文本的下拉框 { container.SubItems.Remove(textBox); string[] t = sections[0].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string r in t) { comboBox.Items.Add(r); } comboBox.SelectedIndex = 0; comboBox.ComboWidth = 200; container.SubItems.Add(comboBox); while (maxLabelLength + 270 > this.Width) // 自动调整宽度 { this.Width += 30; } } break; } case 2: // 有内容和列表值 { textBox.TextBox.Text = sections[0]; // 更改文本内容 string[] t = sections[1].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string r in t) { comboBox.Items.Add(r); } comboBox.SelectedIndex = 0; container.SubItems.Add(comboBox); while (maxLabelLength + 270 + comboBox.ComboWidth > this.Width) // 自动调整宽度 { this.Width += 30; } break; } } break; } } itemPanel1.Items.Add(container); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Control tabControl = this.GetType().BaseType.GetField("tabControl", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.ExactBinding) .GetValue(this) as Control; barMain = new ContextMenuBar(); itemRoot = new ButtonItem("Root"); item1 = new ComboBoxItem("item1"); item1.Text = "显示比例"; ButtonItem btn1 = new ButtonItem("b1", "标准"); ButtonItem btn2 = new ButtonItem("b2", "适应"); ButtonItem btn3 = new ButtonItem("b3", "页面宽度"); item1.Items.AddRange(new BaseItem[] { btn1, btn2, btn3 }); item1.ComboWidth = 80; item1.DropDownStyle = ComboBoxStyle.DropDownList; item1.SelectedIndex = 0; item1.Click += (obj, args) => { switch (item1.SelectedIndex) { case 0: this.Zoom = 1f; break; case 1: this.ZoomWholePage(); break; case 2: this.ZoomPageWidth(); break; default: break; } }; item2 = new ComboBoxItem("item2"); item2.Text = "页面位置"; ButtonItem btn4 = new ButtonItem("b4", "前一页"); ButtonItem btn5 = new ButtonItem("b5", "后一页"); ButtonItem btn6 = new ButtonItem("b7", "首页"); ButtonItem btn7 = new ButtonItem("b8", "尾页"); item2.Items.AddRange(new BaseItem[] { btn4, btn5, btn6, btn7 }); item2.ComboWidth = 80; item2.DropDownStyle = ComboBoxStyle.DropDownList; item2.SelectedIndex = 0; item2.Click += (obj, args) => { switch (item2.SelectedIndex) { case 0: this.Prior(); break; case 1: this.Next(); break; case 2: this.First(); break; case 3: this.Last(); break; default: break; } }; item3 = new ButtonItem("item3"); item3.BeginGroup = true; item3.Text = "打印"; item3.Image = Res.GetImage(195); item3.Click += (obj, args) => { this.Print(); }; item4 = new ButtonItem("item4"); item4.Text = "打印当前页"; item4.Click += (obj, args) => { this.Report.PrintSettings.PageNumbers = this.PageNo.ToString(); this.Report.PrintSettings.PageRange = FastReport.PageRange.PageNumbers; this.Report.Print(); this.Report.PrintSettings.PageNumbers = ""; this.Report.PrintSettings.PageRange = FastReport.PageRange.All; }; item5 = new TextBoxItem("item5"); item5.Text = "页码范围"; item5.Click += (obj, args) => { try { this.Report.PrintSettings.PageNumbers = item5.ControlText; this.Report.PrintSettings.PageRange = FastReport.PageRange.PageNumbers; this.Report.Print(); this.Report.PrintSettings.PageNumbers = ""; this.Report.PrintSettings.PageRange = FastReport.PageRange.All; } catch { MessageBoxEx.Show("输入的页码范围无效,请核对后重试", "提示"); } }; itemRoot.SubItems.AddRange(new BaseItem[] { item1, item2, item3, item4, item5 }); barMain.SetContextMenuEx(tabControl, itemRoot); this.Controls.Add(barMain); tabControl.Controls[0].MouseDown += (obj, args) => { itemRoot.ClosePopup(); }; //tabControl.Controls[0].LostFocus += (obj, args) => //{ // itemRoot.ClosePopup(); //}; }
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; }
protected void vSendButton_Click(object sender, EventArgs e) { try { List <string> Errors = new List <string>(); #region QuestionResult; string QuestionResult = ""; int QuestionnaireItemIndex = 0; foreach (RepeaterItem RepeaterItem in this.vQuestionnaire_List.Items) { QuestionnaireItem QuestionnaireItem = _QuestionnaireItems[QuestionnaireItemIndex]; switch (QuestionnaireItem.OptionType) { case OptionType.單選: RadioButtonList vRadioButtonList = (RadioButtonList)RepeaterItem.FindControl("vRadioButtonList"); if (string.IsNullOrWhiteSpace(vRadioButtonList.SelectedValue)) { Errors.Add(string.Format("請填寫第{0}題的答案", QuestionnaireItem.Sort)); } QuestionResult += string.Format("{0}:{1}<br />", QuestionnaireItem.ShortTitle, vRadioButtonList.SelectedValue); break; case OptionType.多選: CheckBoxList vCheckBoxList = (CheckBoxList)RepeaterItem.FindControl("vCheckBoxList"); if (string.IsNullOrWhiteSpace(vCheckBoxList.SelectedValue)) { Errors.Add(string.Format("請填寫第{0}題的答案", QuestionnaireItem.Sort)); } QuestionResult += string.Format("{0}:{1}<br />", QuestionnaireItem.ShortTitle, vCheckBoxList.SelectedValue); break; case OptionType.單行文字方塊: List <string> OptionResult = new List <string>(); Repeater vTextBoxList = (Repeater)RepeaterItem.FindControl("vTextBoxList"); foreach (RepeaterItem TextBoxItem in vTextBoxList.Items) { string Option = ((TextBox)TextBoxItem.FindControl("vResult")).Text.Trim().Replace(" ", ""); if (string.IsNullOrWhiteSpace(Option)) { Errors.Add(string.Format("請填寫第{0}題第{1}項的答案", QuestionnaireItem.Sort, TextBoxItem.ItemIndex + 1)); } OptionResult.Add(Option); } QuestionResult += string.Format("{0}:{1}<br />", QuestionnaireItem.ShortTitle, string.Join(",", OptionResult)); break; } QuestionnaireItemIndex += 1; } #endregion #region vSystemRemark; string SystemRemark = this.vSystemRemark.Value.Trim(); #endregion if (Errors.Count > 0) { throw new Exception(string.Join("\\r\\n", Errors)); } _CurrentOrderItem.QuestionResult = QuestionResult; _CurrentOrderItem.SyatemRemark = SystemRemark; OrderItemManager.Save(_CurrentOrderItem); ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Message", "top.location.replace('Finish_Form.aspx');", true); } catch (Exception ex) { LeftHand.Gadget.Dialog.Alert(ex.Message); } }