示例#1
0
		public override BaseItem Copy()
		{
			TextBoxItem objCopy=new TextBoxItem(this.Name);
			this.CopyToItem(objCopy);
			return objCopy;
		}
示例#2
0
        private Bar CreateToolbar()
        {
            Bar bar = new Bar();
            bar.Dock = DockStyle.Top;
            bar.RoundCorners = false;

            ButtonItem item = new ButtonItem("sys_Category");
            item.Image = BarFunctions.LoadBitmap("SystemImages.Category.png");
            item.OptionGroup = "sorting";
            item.Checked = true;
            item.OptionGroupChanging += new OptionGroupChangingEventHandler(SortToolbarButtonOptionGroupChanging);
            item.Tooltip = _SystemText.CategorizeToolbarTooltip;
            bar.Items.Add(item);
            _CategoryToolbarButton = item;

            item = new ButtonItem("sys_Sort");
            item.Image = BarFunctions.LoadBitmap("SystemImages.Sort.png");
            item.OptionGroup = "sorting";
            item.OptionGroupChanging += new OptionGroupChangingEventHandler(SortToolbarButtonOptionGroupChanging);
            item.Tooltip = _SystemText.AlphabeticalToolbarTooltip;
            bar.Items.Add(item);
            _SortToolbarButton = item;

            TextBoxItem textBox = new TextBoxItem();
            textBox.WatermarkEnabled = true;
            textBox.WatermarkText = _SystemText.SearchBoxWatermarkText;
            textBox.WatermarkBehavior = eWatermarkBehavior.HideNonEmpty;
            textBox.TextBoxWidth = 90;
            textBox.BeginGroup = true;
            textBox.InputTextChanged += new DevComponents.DotNetBar.TextBoxItem.TextChangedEventHandler(SearchTextChanged);
            textBox.TextBox.GotFocus += new EventHandler(SearchTextBoxGotFocus);
            textBox.Enabled = false;
            _SearchTextBox = textBox;
            bar.Items.Add(textBox);

            bar.Style = eDotNetBarStyle.Office2007;

            return bar;
        }
示例#3
0
文件: ModelForm.cs 项目: viticm/pap2
        /// <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);
            }
        }
示例#4
0
		public void DesignTimeContextMenu(BaseItem objItem)
		{
			using(LocalizationManager lm=new LocalizationManager(m_DotNetBar))
			{
				ButtonItem btn;
				m_EditItem=objItem;
				if(m_PopupMenu!=null)
					m_PopupMenu.Dispose();

				m_PopupMenu=new ButtonItem("syscustomizepopupmenu");
				m_PopupMenu.Style=objItem.Style;

				btn=new ButtonItem("reset");
				btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuReset);
				btn.Click+=new EventHandler(this.ResetItemClick);
				m_PopupMenu.SubItems.Add(btn);
				
				btn=new ButtonItem("delete");
				btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuDelete);
				btn.Click+=new System.EventHandler(this.DeleteClick);
				m_PopupMenu.SubItems.Add(btn);

				TextBoxItem tx=new TextBoxItem("name");
				tx.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuChangeName);
				tx.BeginGroup=true;
				tx.ControlText=objItem.Text;
				tx.LostFocus+=new System.EventHandler(this.ItemNameLostFocus);
				
				m_PopupMenu.SubItems.Add(tx);

				if(m_EditItem is ButtonItem)
				{
					ButtonItem objButton=m_EditItem as ButtonItem;
					btn=new ButtonItem("defaultstyle");
					btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuDefaultStyle);
					btn.BeginGroup=true;
					btn.Click+=new System.EventHandler(this.ButtonStyleClick);
					if(objButton.ButtonStyle==eButtonStyle.Default)
						btn.Checked=true;
					m_PopupMenu.SubItems.Add(btn);

					btn=new ButtonItem("textonly");
					btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuTextOnly);
					btn.Click+=new System.EventHandler(this.ButtonStyleClick);
					if(objButton.ButtonStyle==eButtonStyle.TextOnlyAlways)
						btn.Checked=true;
					m_PopupMenu.SubItems.Add(btn);

					btn=new ButtonItem("imageandtext");
					btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuImageAndText);
					btn.Click+=new System.EventHandler(this.ButtonStyleClick);
					if(objButton.ButtonStyle==eButtonStyle.ImageAndText)
						btn.Checked=true;
					m_PopupMenu.SubItems.Add(btn);

				}

				btn=new ButtonItem("begingroup");
				btn.BeginGroup=true;
				btn.Text=lm.GetLocalizedString(LocalizationKeys.CustomizeMenuBeginGroup);
				btn.Checked=m_EditItem.BeginGroup;
				btn.Click+=new System.EventHandler(this.BeginGroupClick);
			
				m_PopupMenu.SubItems.Add(btn);
	
				m_DotNetBar.OnCustomizeContextMenu(this,m_PopupMenu);
		        
				//m_DotNetBar.RegisterPopup(m_PopupMenu);
				m_PopupMenu.SetOwner(m_DotNetBar);
				m_PopupMenu.PopupMenu(Control.MousePosition);
			}
		}
示例#5
0
 internal static BaseItem CreateItemFromXml(System.Xml.XmlElement xmlItem)
 {
     string cl = xmlItem.GetAttribute("class");
     BaseItem returnItem = null;
     switch (cl)
     {
         case "DevComponents.DotNetBar.ButtonItem":
             returnItem = new ButtonItem();
             break;
         case "DevComponents.DotNetBar.TextBoxItem":
             returnItem = new TextBoxItem();
             break;
         case "DevComponents.DotNetBar.ComboBoxItem":
             returnItem = new ComboBoxItem();
             break;
         case "DevComponents.DotNetBar.LabelItem":
             returnItem = new LabelItem();
             break;
         case "DevComponents.DotNetBar.CustomizeItem":
             returnItem = new CustomizeItem();
             break;
         case "DevComponents.DotNetBar.ControlContainerItem":
             returnItem = new ControlContainerItem();
             break;
         case "DevComponents.DotNetBar.DockContainerItem":
             returnItem = new DockContainerItem();
             break;
         case "DevComponents.DotNetBar.MdiWindowListItem":
             returnItem = new MdiWindowListItem();
             break;
         case "DevComponents.DotNetBar.SideBarContainerItem":
             returnItem = new SideBarContainerItem();
             break;
         case "DevComponents.DotNetBar.SideBarPanelItem":
             returnItem = new SideBarPanelItem();
             break;
         case "DevComponents.DotNetBar.ExplorerBarGroupItem":
             returnItem = new ExplorerBarGroupItem();
             break;
         case "DevComponents.DotNetBar.ExplorerBarContainerItem":
             returnItem = new ExplorerBarContainerItem();
             break;
         case "DevComponents.DotNetBar.ProgressBarItem":
             returnItem = new ProgressBarItem();
             break;
         case "DevComponents.DotNetBar.ColorPickerDropDown":
             returnItem = new ColorPickerDropDown();
             break;
         default:
             {
                 try
                 {
                     //System.Windows.Forms.MessageBox.Show("Loading custom: "+xmlItem.GetAttribute("assembly")+"   "+xmlItem.GetAttribute("class"));
                     System.Reflection.Assembly a = System.Reflection.Assembly.Load(xmlItem.GetAttribute("assembly"));
                     if (a == null)
                         return null;
                     BaseItem item = a.CreateInstance(xmlItem.GetAttribute("class")) as BaseItem;
                     returnItem = item;
                 }
                 catch (Exception e)
                 {
                     throw new ArgumentException("Could not create item from XML. Assembly=" + xmlItem.GetAttribute("assembly") + ", Class=" + xmlItem.GetAttribute("class") + ", Inner Exception: " + e.Message + ", Source=" + e.Source);
                 }
                 break;
             }
     }
     return returnItem;
 }
示例#6
0
 private void WireUpTextBox(ref TextBoxItem oldTextBox, TextBoxItem newTextBox, KeyEventHandler keyUpHandler, EventHandler lostFocusHandler)
 {
     if (oldTextBox != newTextBox)
     {
         if (oldTextBox != null)
         {
             oldTextBox.KeyUp -= keyUpHandler;
             oldTextBox.LostFocus -= lostFocusHandler;
         }
         if (newTextBox != null)
         {
             newTextBox.KeyUp += keyUpHandler;
             newTextBox.LostFocus += lostFocusHandler;
         }
         oldTextBox = newTextBox;
         this.RefreshStateInternal();
     }
 }
示例#7
0
 internal void InvokeTextBoxItemTextChanged(TextBoxItem ti)
 {
     if (TextBoxItemTextChanged != null)
         TextBoxItemTextChanged(ti, new EventArgs());
 }