Example #1
0
        private void btnPrintPreview_Click(object sender, EventArgs e)
        {
            if (NotReceivingList.Count == 0)
            {
                return;
            }

            frmMain.btnPurchaseOrders_Click(frmMain.btnPurchaseOrders, new EventArgs());
            frmMain.purchaseorders.RestoreMode = true;
            ComboBox cb =  (ComboBox)frmMain.purchaseorders.Controls.Find(cbSupplier.Name, true)[0];
            frmMain.purchaseorders.cbSupplier_DropDown(cb, new EventArgs());
            cb.SelectedValue = NotReceivingList[0].SupplierID;
            CheckedListBox clb = (CheckedListBox)frmMain.purchaseorders.Controls.Find(clbOrderNumbers.Name, true)[0];
            for (int i = 0; i < clbOrderNumbers.Items.Count; i++)
            {
                if (clbOrderNumbers.GetItemChecked(i))
                {
                    frmMain.purchaseorders.clbOrderNumbers_ItemCheck(clb,new ItemCheckEventArgs(i,CheckState.Checked,CheckState.Unchecked));
                }
            }
            clb.Refresh();

            foreach (POLogObj item in NotReceivingList)
            {
                frmMain.purchaseorders.Receive(item.SKU, item.QtyReceived, item.PONumber);
            }
            frmMain.purchaseorders.RestoreMode = false;
            frmMain.purchaseorders.Refresh();
        }
Example #2
0
        private void MoveListRow(int offset, CheckedListBox lb)
        {
            if (lb.SelectedIndex < 0)
            {
                return;
            }
            int idx = lb.SelectedIndex;

            if ((offset == -1 && idx == 0) || (offset == 1 && idx == lb.Items.Count - 1))
            {
                return;
            }

            string s  = lb.Items[idx].ToString();
            bool   ch = false;

            ch = lb.GetItemChecked(idx);
            lb.Items.RemoveAt(idx);
            lb.Items.Insert(idx + offset, s);
            lb.SetItemChecked(idx + offset, ch);
            lb.Refresh();
            lb.SetSelected(idx, false);
            lb.Focus();
            lb.SetSelected(idx + offset, true);
        }
Example #3
0
        public void SetItemChecked(int index, bool isChecked)
        {
            _checkedListBox.Refresh();
            _checkedListBox.SetItemChecked(index, isChecked);

            Invalidate();
        }
Example #4
0
        private void ClearCheckedItems(CheckedListBox checkedListBox)
        {
            for (int i = 0; i < checkedListBox.Items.Count; i++)
            {
                checkedListBox.SetItemChecked(i, false);
            }

            checkedListBox.Refresh();
        }
Example #5
0
 /// <summary>
 /// Add the rating for all checked users in the CheckedListBox.
 /// </summary>
 private void AddAllRatings(CheckedListBox clb)
 {
     foreach (User checkedUser in clb.CheckedItems)
     {
         //add chosen rating to each selected users
         checkedUser.AddRating(chosenRating);
     }
     //refresh the view
     clb.Refresh();
 }
Example #6
0
        private void SetItemChecked(CheckedListBox checkedListBox, List <string> permissionCodes)
        {
            ClearCheckedItems(checkedListBox);
            for (int i = 0; i < checkedListBox.Items.Count; i++)
            {
                if (permissionCodes.Any(p => checkedListBox.Items[i].ToString().Contains(p)))
                {
                    checkedListBox.SetItemChecked(i, true);
                }
            }

            checkedListBox.Refresh();
        }
Example #7
0
        /// <summary>
        /// Retrieves audio and subtitle streams through FFDShow
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void getFFDShowStreams_Click(object sender, EventArgs e)
        {
            this.audioStreamlistBox.ItemCheck    -= new System.Windows.Forms.ItemCheckEventHandler(this.audioStreamlistBox_ItemCheck);
            this.subtitleStreamlistBox.ItemCheck -= new System.Windows.Forms.ItemCheckEventHandler(this.subtitleStreamlistBox_ItemCheck);
            audioStreamlistBox.Items.Clear();
            subtitleStreamlistBox.Items.Clear();
            using (FFDShowAPI ffdshowAPI = new FFDShowAPI())
            {
                if (!ffdshowAPI.checkFFDShowActive())
                {
                    return;
                }
                SortedDictionary <int, FFDShowAPI.Stream> audioStreams    = ffdshowAPI.AudioStreams;
                SortedDictionary <int, FFDShowAPI.Stream> subtitleStreams = ffdshowAPI.SubtitleStreams;

                int currentAudioStream    = ffdshowAPI.AudioStream;
                int currentSubtitleStream = ffdshowAPI.SubtitleStream;

                foreach (KeyValuePair <int, FFDShowAPI.Stream> stream in audioStreams)
                {
                    NewCheckboxListItem chk = new NewCheckboxListItem();
                    chk.Text = stream.Value.name + "(" + stream.Value.languageName + ")";
                    chk.Tag  = stream.Key;
                    audioStreamlistBox.Items.Add(chk);
                    if (stream.Key == currentAudioStream)
                    {
                        audioStreamlistBox.SetItemChecked(audioStreamlistBox.Items.Count - 1, true);
                    }
                }

                foreach (KeyValuePair <int, FFDShowAPI.Stream> stream in subtitleStreams)
                {
                    NewCheckboxListItem chk = new NewCheckboxListItem();
                    chk.Text = stream.Value.name + "(" + stream.Value.languageName + ")";
                    chk.Tag  = stream.Key;
                    subtitleStreamlistBox.Items.Add(chk);
                    if (stream.Key == currentSubtitleStream)
                    {
                        subtitleStreamlistBox.SetItemChecked(subtitleStreamlistBox.Items.Count - 1, true);
                    }
                }
                subtitleStreamlistBox.Refresh();
                audioStreamlistBox.Refresh();
                tabControl1.SelectedTab               = tabPage3;
                this.audioStreamlistBox.ItemCheck    += new System.Windows.Forms.ItemCheckEventHandler(this.audioStreamlistBox_ItemCheck);
                this.subtitleStreamlistBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.subtitleStreamlistBox_ItemCheck);
            }
        }
Example #8
0
 private void CheckedChanged(CheckedListBox clb, bool check)
 {
     for (int i = 0; i < clb.Items.Count; i++)
     {
         clb.SetItemChecked(i, check);
     }
     clb.Refresh();
     clb.Focus();
     if (clb.SelectedIndex >= 0)
     {
         clb.SetSelected(clb.SelectedIndex, true);
     }
     else if (clb.Items.Count > 0)
     {
         clb.SetSelected(0, true);
     }
 }
Example #9
0
        private void MoveListViewItem(ref CheckedListBox lv, bool moveUp)
        {
            int selIdx;
            int newIdx;

            selIdx = lv.SelectedIndex;
            if (moveUp)
            {
                // ignore moveup of row(0)
                if (selIdx == 0)
                {
                    return;
                }

                newIdx = selIdx - 1;
            }
            else
            {
                // ignore movedown of last item
                if (selIdx == lv.Items.Count - 1)
                {
                    return;
                }

                newIdx = selIdx + 1;
            }

            Script s = (Script)lv.SelectedItem;

            lv.Items.RemoveAt(selIdx);
            lv.Items.Insert(newIdx, s);
            mAllowCheck = true;
            lv.SetItemChecked(newIdx, s.Enabled);
            mAllowCheck      = false;
            lv.SelectedIndex = newIdx;

            lv.Refresh();
            lv.Focus();
        }
Example #10
0
        public void RefreshList(CheckedListBox list)
        {
            Windows = WindowsLogic.GetNonExplorerWindows();

            foreach (Window window in Windows)
            {
                if (!list.Items.Contains(window.ProcessName))
                {
                    list.Items.Add(window.ProcessName);
                }
            }

            int itemsCount = list.Items.Count - 1;

            for (int i = itemsCount; i > 0; i--)
            {
                if (!Windows.Any(x => x.ProcessName == (string)list.Items[i]))
                {
                    list.Items.Remove(list.Items[i]);
                }
            }

            list.Refresh();
        }
Example #11
0
 private void _ChangeStatusForCurrentProgramInDownloadingStatus(string status)
 {
     _currentProgramInDownloading.ChangeDownloadStatus(status);
     _downloadableProgramsCheckedList.Refresh();
 }
Example #12
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);
                }
            }