예제 #1
0
        private void ToolStripItemBind(ToolStrip toolStrip, DataTable dataTable, Color ToolStripBackColor, string ForeColorColumn, string TextColumn, Font font, EventHandler eventHandler)
        {
            int iCount = 0;

            toolStrip.Refresh();
            toolStrip.Items.Clear();
            toolStrip.Font = font;
            iCount         = dataTable.Rows.Count;
            ToolStripItem[] toolStripItem = new ToolStripItem[iCount];
            for (int i = 0; i < iCount; i++)
            {
                toolStripItem[i] = new ToolStripButton();
                toolStripItem[i].DisplayStyle = ToolStripItemDisplayStyle.Text;
                toolStripItem[i].Text         = dataTable.Rows[i][TextColumn].ToString();
                toolStripItem[i].AutoSize     = false;
                toolStripItem[i].Size         = new Size(150, 100);
                toolStripItem[i].Click       += eventHandler;
                toolStripItem[i].ForeColor    = Color.White;
                toolStripItem[i].Margin       = new System.Windows.Forms.Padding(5, 0, 10, 0);
                toolStripItem[i].BackColor    = Color.Transparent;
            }
            toolStrip.Items.AddRange(toolStripItem);
            toolStrip.BackColor = ToolStripBackColor;
            toolStrip.Items[0].PerformClick();
            toolStrip.Refresh();
        }
예제 #2
0
        private void SetStyleColor(Color style)
        {
            ToolStrip.ItemSelectedColor = style;
            ToolStrip.CheckedItemColor = style;
            ToolStrip.CheckPressItemColors = style;
            ToolStrip.ItemPressedColors = style;
            ToolStrip.Refresh();

            fctbRcv.ServiceLinesColor = style;
            fctbRcv.LineNumberColor = style;
            fctbRcv.SelectionColor = style;
            fctbRcv.BookmarkColor = style;
            fctbRcv.CaretColor = style;

            //panelUpDivide.BackColor = style;
            //panelBottomDivide.BackColor = style;
            btSendSetting.FlatAppearance.BorderColor = style;

            foreach (Control ctl in this.Controls)
            {
                if (ctl is Button)
                {
                    Button btn = ctl as Button;
                    //if (btTopMost != btn)
                    btn.FlatAppearance.MouseOverBackColor = style;
                }
            }
        }
 public static void updateStatus(String newStatus)
 {
     if (statusLabel != null && statusToolStrip != null)
     {
         statusLabel.Text = newStatus;
         statusToolStrip.Refresh();
         Application.DoEvents();
     }
 }
예제 #4
0
 /// <summary>
 /// Sets the automatic scroll.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetAutoScroll(this ToolStrip control, bool value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetAutoScroll(value)));
     }
     else
     {
         control.AutoScroll = value;
         control.Refresh();
     }
 }
예제 #5
0
 /// <summary>
 /// Sets the anchor.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetAnchor(this ToolStrip control, AnchorStyles value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetAnchor(value)));
     }
     else
     {
         control.Anchor = value;
         control.Refresh();
     }
 }
예제 #6
0
 /// <summary>
 /// Sets the text direction.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetTextDirection(this ToolStrip control, ToolStripTextDirection value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetTextDirection(value)));
     }
     else
     {
         control.TextDirection = value;
         control.Refresh();
     }
 }
예제 #7
0
 /// <summary>
 /// Sets the binding context.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetBindingContext(this ToolStrip control, BindingContext value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetBindingContext(value)));
     }
     else
     {
         control.BindingContext = value;
         control.Refresh();
     }
 }
예제 #8
0
 /// <summary>
 /// Sets the render mode.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetRenderMode(this ToolStrip control, ToolStripRenderMode value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetRenderMode(value)));
     }
     else
     {
         control.RenderMode = value;
         control.Refresh();
     }
 }
예제 #9
0
 /// <summary>
 /// Sets the layout style.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetLayoutStyle(this ToolStrip control, ToolStripLayoutStyle value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetLayoutStyle(value)));
     }
     else
     {
         control.LayoutStyle = value;
         control.Refresh();
     }
 }
예제 #10
0
 /// <summary>
 /// Sets the size of the image scaling.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetImageScalingSize(this ToolStrip control, Size value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetImageScalingSize(value)));
     }
     else
     {
         control.ImageScalingSize = value;
         control.Refresh();
     }
 }
예제 #11
0
 /// <summary>
 /// Sets the image list.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetImageList(this ToolStrip control, ImageList value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetImageList(value)));
     }
     else
     {
         control.ImageList = value;
         control.Refresh();
     }
 }
예제 #12
0
 /// <summary>
 /// Sets the grip margin.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetGripMargin(this ToolStrip control, Padding value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetGripMargin(value)));
     }
     else
     {
         control.GripMargin = value;
         control.Refresh();
     }
 }
예제 #13
0
 /// <summary>
 /// Sets the allow item reorder.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetAllowItemReorder(this ToolStrip control, bool value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetAllowItemReorder(value)));
     }
     else
     {
         control.AllowItemReorder = value;
         control.Refresh();
     }
 }
예제 #14
0
 /// <summary>
 /// Sets the color of the fore.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetForeColor(this ToolStrip control, Color value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetForeColor(value)));
     }
     else
     {
         control.ForeColor = value;
         control.Refresh();
     }
 }
예제 #15
0
 /// <summary>
 /// Sets the dock.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">The value.</param>
 public static void SetDock(this ToolStrip control, DockStyle value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetDock(value)));
     }
     else
     {
         control.Dock = value;
         control.Refresh();
     }
 }
예제 #16
0
 /// <summary>
 /// Sets the causes validation.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetCausesValidation(this ToolStrip control, bool value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetCausesValidation(value)));
     }
     else
     {
         control.CausesValidation = value;
         control.Refresh();
     }
 }
예제 #17
0
 /// <summary>
 /// Sets the show item tool tips.
 /// </summary>
 /// <param name="control">The control.</param>
 /// <param name="value">if set to <c>true</c> [value].</param>
 public static void SetShowItemToolTips(this ToolStrip control, bool value)
 {
     if (control.InvokeRequired)
     {
         control.BeginInvoke(new MethodInvoker(() => control.SetShowItemToolTips(value)));
     }
     else
     {
         control.ShowItemToolTips = value;
         control.Refresh();
     }
 }
예제 #18
0
        // Reads the info from the model / views and fills-out the
        // UI with that info, refreshing the components.
        public void readAndShow()
        {
            CleanUpView();

            //SetUpInfoLabel();
            foreach (Section s in model.sections)
            {
                sectionMenu.Items.Add(s.Button);
                sectionTabControl.TabPages.Add(s.Tab);

                // Set the handlers event. Safe in case of duplicated handlers.
                s.Button.Click -= ToolStripButton_Click;
                s.Button.Click += ToolStripButton_Click;

                if (s.Selected)
                {
                    SetUpInfoTextBox();
                    s.Button.PerformClick();
                }
            }

            sectionMenu.Refresh();
            sectionTabControl.Refresh();
        }
예제 #19
0
        public void UpdateFontForeColor()
        {
            viewImagingControl.UpdateFontForeColor();
            List <Control> controls = GetControls(this).ToList();

            foreach (Control c in controls)
            {
                if (c is ToolStrip)
                {
                    ToolStrip l = c as ToolStrip;
                    {
                        for (int i = 0; i < l.Items.Count; i++)
                        {
                            l.Items[i].ForeColor = IVLVariables.GradientColorValues.FontForeColor;
                            l.Refresh();
                        }
                    }
                }
            }
        }
예제 #20
0
            /// <summary>
            /// 【第一步、调用函数 SetUIInChinese 或者 SetUIInUKEnglish】;
            /// 【第二步、调用函数 ChangeLanguageOfUI】;
            /// ------------------------------------------------------------------------
            /// 修改UI界面语言,请先执行设置语言的函数,然后再执行此函数来调用对应的资源来更新UI:
            /// 特别注意:调用此函数后,窗体会恢复到初始状态,还需要根据情况再次设置界面的具体内容,例如 visible/enable等属性;
            /// </summary>
            /// <param name="TargetSource"目标窗体对应的组件资源对象,
            /// 请使用此格式来实例化对象:ComponentResourceManager resource = new ComponentResourceManager(typeof(目标窗体类名称));
            /// 例如:ComponentResourceManager resource = new ComponentResourceManager(typeof(Form1));></param>
            /// <param name="TargetControl">目标控件,可以是窗体(this)或者其它 Control 类型,这里只需要 this 就会自动将窗体里面所有的 Control 更新为对应语言的资源</param>
            public void ChangeLanguageOfUI(ComponentResourceManager TargetSource, Control TargetControl)
            {
                try
                {
                    TargetSource.ApplyResources(TargetControl, TargetControl.Name);
                    TargetControl.ResumeLayout();
                    //TargetControl.Update();
                    TargetControl.Refresh();

                    if (TargetControl is MenuStrip)
                    {
                        //菜单
                        MenuStrip tempMenu = TargetControl as MenuStrip;
                        tempMenu.SuspendLayout();
                        foreach (ToolStripMenuItem item in tempMenu.Items)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                                if (null != item.DropDownItems && item.DropDownItems.Count > 0)
                                {
                                    foreach (ToolStripMenuItem subitem in item.DropDownItems)
                                    {
                                        if (null != subitem)
                                        {
                                            TargetSource.ApplyResources(subitem, subitem.Name);
                                        }
                                    } 
                                }
                            }
                        }
                        tempMenu.ResumeLayout();
                        tempMenu.Update();
                        tempMenu.Refresh();
                    }
                    else if (TargetControl is StatusStrip)
                    {
                        //状态栏
                        StatusStrip tempStatusStrip = TargetControl as StatusStrip;
                        tempStatusStrip.SuspendLayout();
                        foreach (ToolStripStatusLabel item in tempStatusStrip.Items)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                            }
                        }
                        tempStatusStrip.ResumeLayout();
                        tempStatusStrip.Update();
                        tempStatusStrip.Refresh();
                    }
                    else if (TargetControl is ToolStrip)//如果传入的控件是StatusStrip,这里的判断条件也是 true,这可能是因为继承的关系
                    {
                        //工具栏按钮
                        ToolStrip tempToolStrip = TargetControl as ToolStrip;
                        tempToolStrip.SuspendLayout();
                        foreach (ToolStripButton item in tempToolStrip.Items)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                            }
                        }
                        tempToolStrip.ResumeLayout();
                        tempToolStrip.Update();
                        tempToolStrip.Refresh();
                    }
                    else if (TargetControl is Form)
                    {
                        //窗体
                        TargetSource.ApplyResources(TargetControl, "$this");
                        foreach (Control item in TargetControl.Controls)
                        {
                            if (null != item)
                            {
                                ChangeLanguageOfUI(TargetSource, item);
                            }
                        }
                        TargetControl.ResumeLayout();
                        TargetControl.Update();
                        TargetControl.Refresh();
                    }
                    else if (TargetControl is DataGridView)
                    {
                        //DataGridView
                        DataGridView tempDataGridView = TargetControl as DataGridView;
                        foreach (DataGridViewColumn item in tempDataGridView.Columns)
                        {
                            if (null != item)
                            {
                                TargetSource.ApplyResources(item, item.Name);
                            }
                        }
                        //tempDataGridView.Update();
                        tempDataGridView.Refresh();
                    }
                    else if (TargetControl is TreeView)
                    {
                        //TreeView
                        TreeView tempTreeView = TargetControl as TreeView;
                        if (tempTreeView.Nodes.Count > 0)
                        {
                            tempTreeView.SuspendLayout();
                            TreeNode[] tempTreeNodes = new TreeNode[tempTreeView.Nodes.Count];
                            for (int i = 0; i < tempTreeView.Nodes.Count; i++)
                            {
                                if (i == 0)
                                {
                                    tempTreeNodes[i] = (TreeNode)TargetSource.GetObject(tempTreeView.Name + ".Nodes");
                                }
                                else
                                {
                                    tempTreeNodes[i] = (TreeNode)TargetSource.GetObject(tempTreeView.Name + ".Nodes" + i.ToString());
                                }
                            }

                            tempTreeView.Nodes.Clear();
                            tempTreeView.Nodes.AddRange(tempTreeNodes);
                            tempTreeView.ResumeLayout();
                        }
                    }
                    else if (TargetControl is CheckedListBox)
                    {
                        //CheckedListBox
                        CheckedListBox tempCheckedListBox = TargetControl as CheckedListBox;
                        if (tempCheckedListBox.Items.Count > 0)
                        {
                            object[] tempCheckedListBoxItems = new object[tempCheckedListBox.Items.Count];
                            for (int i = 0; i < tempCheckedListBox.Items.Count; i++)
                            {
                                if (i == 0)
                                {
                                    tempCheckedListBoxItems[i] = TargetSource.GetString(tempCheckedListBox.Name + ".Items");
                                }
                                else
                                {
                                    tempCheckedListBoxItems[i] = TargetSource.GetString(tempCheckedListBox.Name + ".Items" + i.ToString());
                                }
                            }

                            tempCheckedListBox.Items.Clear();
                            tempCheckedListBox.Items.AddRange(tempCheckedListBoxItems);

                            tempCheckedListBox.ResumeLayout();
                            tempCheckedListBox.Update();
                            tempCheckedListBox.Refresh();
                        }
                    }
                    else if (TargetControl is ListBox)
                    {
                        //ListBox
                        ListBox tempListBox = TargetControl as ListBox;
                        if (tempListBox.Items.Count > 0)
                        {
                            object[] tempListBoxItems = null;// new object[tempListBox.Items.Count];
                            int iItemIndexCount = 0;
                            string TempItem = "";

                            //发生错误:值不能为 null。
                            //参数名: item;    在 System.Windows.Forms.ListBox.ObjectCollection.AddInternal(Object item)

                            for (int i = 0; i < tempListBox.Items.Count; i++)
                            {
                                if (i == 0)
                                {
                                    TempItem = TargetSource.GetString(tempListBox.Name + ".Items");
                                    if (null != TempItem && TempItem != "")
                                    {
                                        tempListBoxItems = new object[1];
                                        //Array.Resize<object>(ref tempListBoxItems, iItemIndexCount + 1);
                                        tempListBoxItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                }
                                else
                                {
                                    TempItem = TargetSource.GetString(tempListBox.Name + ".Items" + i.ToString());
                                    if (null != TempItem && TempItem != "")
                                    {
                                        Array.Resize<object>(ref tempListBoxItems, iItemIndexCount + 1);
                                        tempListBoxItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                }
                            }

                            if (null != tempListBoxItems)
                            {
                                tempListBox.Items.Clear();
                                tempListBox.Items.AddRange(tempListBoxItems);

                                tempListBox.ResumeLayout();
                                tempListBox.Update();
                                tempListBox.Refresh();
                            }
                            else
                            {
                                ErrorMessage.Enqueue("窗体 " + TargetControl.FindForm().Name + " 的ListBox控件 " + TargetControl.Name + " 子项为空或者没有建立多语言版本的资源");
                            }
                        }
                    }
                    else if (TargetControl is ListView)
                    {
                        //ListView
                        ListView tempListView = TargetControl as ListView;
                        if (tempListView.Items.Count > 0)
                        {
                            ListViewItem[] tempTreeNodes = new ListViewItem[tempListView.Items.Count];
                            for (int i = 0; i < tempListView.Items.Count; i++)
                            {
                                if (i == 0)
                                {
                                    tempTreeNodes[i] = (ListViewItem)TargetSource.GetObject(tempListView.Name + ".Items");
                                }
                                else
                                {
                                    tempTreeNodes[i] = (ListViewItem)TargetSource.GetObject(tempListView.Name + ".Items" + i.ToString());
                                }
                            }

                            tempListView.Items.Clear();
                            tempListView.Items.AddRange(tempTreeNodes);
                        }

                        if (tempListView.Columns.Count > 0)
                        {
                            for (int i = 0; i < tempListView.Columns.Count; i++)
                            {
                                TargetSource.ApplyResources(tempListView.Columns[i], "columnHeader" + (i + 1).ToString());
                            }
                        }

                        tempListView.ResumeLayout();
                        tempListView.Update();
                        tempListView.Refresh();
                    }
                    else if (TargetControl is ComboBox)
                    {
                        //ComboBox
                        ComboBox tempComboBox = TargetControl as ComboBox;
                        
                        if (tempComboBox.Items.Count > 0)
                        {
                            tempComboBox.SuspendLayout();
                            object[] AllItems = null;// new object[1];//tempComboBox.Items.Count
                            int iItemIndexCount = 0;
                            string TempItem = "";

                            // 发生错误:值不能为 null。
                            // 参数名: item;    在 System.Windows.Forms.ComboBox.ObjectCollection.AddInternal(Object item)
                            
                            for (int i = 0; i < tempComboBox.Items.Count; i++)
                            {
                                if (iItemIndexCount == 0)
                                {
                                    //Array.Resize<object>(ref AllItems, iItemIndexCount + 1);
                                    TempItem = TargetSource.GetString(tempComboBox.Name + ".Items");
                                    if (null != TempItem && TempItem != "")
                                    {
                                        AllItems = new object[1];
                                        AllItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                    //
                                }
                                else
                                {
                                    TempItem = TargetSource.GetString(tempComboBox.Name + ".Items" + i.ToString());
                                    if (null != TempItem && TempItem != "")
                                    {
                                        Array.Resize<object>(ref AllItems, iItemIndexCount + 1);
                                        AllItems[iItemIndexCount] = TempItem;
                                        iItemIndexCount++;
                                    }
                                }
                            }

                            if (null != AllItems)
                            {
                                tempComboBox.Items.Clear();
                                tempComboBox.Items.AddRange(AllItems);
                                tempComboBox.SelectedIndex = 0;

                                tempComboBox.ResumeLayout();
                                //tempComboBox.Update();
                                tempComboBox.Refresh();
                            }
                            else
                            {
                                ErrorMessage.Enqueue("窗体 " + TargetControl.FindForm().Name + " 的ComboBox控件 " + TargetControl.Name + " 子项为空或者没有建立多语言版本的资源");
                            }
                        }
                    }
                    else
                    {
                        if (TargetControl.HasChildren == true)
                        {
                            foreach (Control item in TargetControl.Controls)
                            {
                                if (null != item)
                                {
                                    ChangeLanguageOfUI(TargetSource, item);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //throw ex;
                    ErrorMessage.Enqueue(DateTime.Now.ToString() + "*-*" + "发生错误:" + ex.Message + "; " + ex.StackTrace);
                }
            }
예제 #21
0
 public void UpdateToolbar()
 {
     ToolbarService.UpdateToolbar(toolStrip);
     toolStrip.Refresh();
 }
예제 #22
0
 private void ShowSubToolStrip()
 {
     toolStrip.Refresh();
     this.Refresh();
 }