Clear() public method

public Clear ( ) : void
return void
Beispiel #1
0
        //────────────────────────────────────────
        /// <summary>
        /// リスト・ビュー1の内容を、リスト・ビュー2へ、コピーします。
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="listView"></param>
        public void CopyTo(ListView listView1, ListView listView2, Log_Reports log_Reports)
        {
            // リスト・ビュー2を空にします。
            listView2.Clear();

            // 編集テーブルを、並び順変更先テーブルにコピーします。
            foreach (ColumnHeader columnHeader in listView1.Columns)
            {
                listView2.Columns.Add(columnHeader.Text);
            }

            foreach (ListViewItem listViewItem in listView1.Items)
            {
                // [0]列目を初期値として設定します。
                ListViewItem newItem = new ListViewItem(listViewItem.Text);

                // 最初の[0]列目は既に追加済みなので、[1]列目以降から追加します。
                for (int nIndex = 1; nIndex < listViewItem.SubItems.Count; nIndex++)
                {
                    newItem.SubItems.Add(listViewItem.SubItems[nIndex]);
                }
                listView2.Items.Add(newItem);
            }

            goto gt_EndMethod;
            //
            gt_EndMethod:
            ;
        }
Beispiel #2
0
 public void InitialListView(ListView listView)
 {
     listView.Clear();
     InsertAllColumns(listView);
     listView.BeginUpdate();
     AddFlowItem(listView);
     listView.EndUpdate();
 }
Beispiel #3
0
        public void RefreshUpdate(ListView listview, TabPage tab)
        {
            getpack = new GetPackage(packages);
            IEnumerable<IPackage> localPackages = getpack.GetPackagesFromExtensions(App.Extensions);
            if (localPackages.Count() > 0)
            {
                IEnumerable<IPackage> list = null;
                try
                {
                    list = packages.Repo.GetUpdates(localPackages, false, false);
                }
                catch (WebException)
                {
                    listview.Invoke((Action)(() =>
                        {
                            listview.Clear();
                            listview.Items.Add("Updates could not be retrieved for the selected feed.");
                            listview.Items.Add("Try again later or change the feed.");
                        }));
                }

                listview.Invoke((Action)(() =>
                {
                    listview.Clear();
                    int Count = list.Count();
                    tab.Text = String.Format("Updates ({0})", Count);
                    Add.AddPackages(list, listview, 0);
                    if (listview.Items.Count == 0)
                    {
                        listview.Clear();
                        listview.Items.Add("No updates available for the selected feed.");
                    }
                }));
            }
            else
            {
                listview.Invoke((Action)(() =>
                {
                    listview.Clear();
                    listview.Items.Add("No packages are installed.");
                }));
            }
        }
 public static void FillListView(ListView _listView, List<IBaseElement> _listEl)
 {
     _listView.Clear();
     _listView.BeginUpdate();
     foreach (IBaseElement row in _listEl)
     {
         var item = new ListViewItem(row.name);
         _listView.Items.Add(item);
     }
     _listView.EndUpdate();
 }
        private void affichLstRdvEnreg()
        {
            int i;

            rdvEnreg = service.getAllRdvFix(calendrier.SelectionStart, cmbMed.Text);
            lstRdvExist.Clear();
            lstRdvExist.Columns.Add("patient", 200, System.Windows.Forms.HorizontalAlignment.Center);
            lstRdvExist.Columns.Add("Heure", 200, System.Windows.Forms.HorizontalAlignment.Center);
            for (i = 0; i <= rdvEnreg.Tables[0].Rows.Count - 1; i++)
            {
                lstRdvExist.Items.Add(rdvEnreg.Tables[0].Rows[i][0].ToString()).SubItems.Add(rdvEnreg.Tables[0].Rows[i][1].ToString());
            }
        }
        /// <summary>
        /// Sets the columns shown in the list view.
        /// </summary>
        private void SetColumns(string[] columns)
        {
            AttributesLV.Clear();

            foreach (string column in columns)
            {
                ColumnHeader header = new ColumnHeader();
                header.Text = column;
                AttributesLV.Columns.Add(header);
            }

            AdjustColumns();
        }
        /// <summary>
        /// Sets the columns shown in the list view.
        /// </summary>
        private void SetColumns(string[] columns)
        {
            itemListLv_.Clear();

            foreach (string column in columns)
            {
                ColumnHeader header = new ColumnHeader();
                header.Text = column;
                itemListLv_.Columns.Add(header);
            }

            AdjustColumns();
        }
        private void NewRequest()
        {
            _tableRequest.ColumnRequests.Clear();
            ColumnRequest newCol = new ColumnRequest();

            newCol.Width = 1f;
            _tableRequest.ColumnRequests.Add(newCol);
            _tableRequest.DocumentArea = null;
            if (_ExtractionFrame != null)
            {
                _ExtractionFrame.AdjustColumnsToRequest();
            }
            listView1.Clear();
        }
Beispiel #9
0
 private void ClearViews(ViewAreas v)
 {
     if (v == ViewAreas.Update_All ||
         ((v & ViewAreas.Update_Plugins) == ViewAreas.Update_Plugins))
     {
         PluginList.Clear();
         PluginList.Columns.Clear();
     }
     if (v == ViewAreas.Update_Text ||
         ((v & ViewAreas.Update_Text) == ViewAreas.Update_Text))
     {
         TextLog.Clear();
     }
 }
Beispiel #10
0
        /// <summary>
        /// Populates the list box from the values of an enumeration.
        /// </summary>
        private void UpdateMasks(System.Type type)
        {
            bitMaskLv_.Clear();
            bitMaskLv_.Tag = type;

            // check if an enum type was specified
            if (type == null)
            {
                return;
            }

            Array values = Enum.GetValues(type);

            foreach (object enumValue in values)
            {
                uint bits = System.Convert.ToUInt32(enumValue);

                // ignore values that combine multiple bits.
                switch (bits)
                {
                case 0x0001:
                case 0x0002:
                case 0x0004:
                case 0x0008:
                case 0x0010:
                case 0x0020:
                case 0x0040:
                case 0x0080:
                case 0x0100:
                case 0x0200:
                case 0x0400:
                case 0x0800:
                case 0x1000:
                case 0x2000:
                case 0x4000:
                case 0x8000:
                {
                    ListViewItem item = new ListViewItem(enumValue.ToString())
                    {
                        Tag       = enumValue,
                        BackColor = (ReadOnly) ? SystemColors.Control : SystemColors.Window
                    };

                    bitMaskLv_.Items.Add(item);
                    break;
                }
                }
            }
        }
        /// <summary>
        /// Sets the columns shown in the list view.
        /// </summary>
        private void SetColumns(string[] columns)
        {
            ItemListLV.Clear();

            foreach (string column in columns)
            {
                ColumnHeader header = new ColumnHeader();
                header.Text = column;
                header.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
                header.TextAlign = HorizontalAlignment.Center;
                ItemListLV.Columns.Add(header);
            }

            AdjustColumns();
        }
Beispiel #12
0
 public void updateOnlineUserList(ListView onlineUserList)
 {
     if (onlineUserList.InvokeRequired)
     {
         // We're on a thread other than the GUI thread
         onlineUserList.Invoke(new MethodInvoker(() => updateOnlineUserList(onlineUserList)));
         return;
     }
     onlineUserList.Clear();
     foreach (var user in Main.ludo.Users)
     {
         onlineUserList.Items.Add(user.UserName);
     }
     onlineUserList.Items[ClientBase.myUserListIndex].BackColor = System.Drawing.Color.Gold; // Set this user background color
 }
Beispiel #13
0
    //</snippet2>

    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        // Create new values for the ListView, clear the list,
        // and repopulate it.
        string[] lunch = new string[] { "Hamburger", "Grilled Cheese",
                                        "Soup & Salad", "Club Sandwich", "Hotdog" };

        string[] lunchPrices = new string[] { "4.09", "5.09", "5.19",
                                              "4.79", "2.09" };

        ListView1.Clear();

        PopulateMenu("Lunch", lunch, lunchPrices);
        Button1.Enabled = false;
    }
Beispiel #14
0
        private void TimerEvent(object PassedObject, EventArgs TimerArgs)
        {
            try
            {
                if (NewSubscriber.IsUpdated == true)
                {
                    /// redraw the list box
                    listViewSubscriptions.Clear();
                    ListViewItem lvItem;

                    ArrayList      temp = NewSubscriber.GetDataList;
                    SubscriberData tempSubscriber;

                    ColumnHeader header = new ColumnHeader();
                    header.Width = 100;
                    header.Text  = "Subscription";
                    listViewSubscriptions.Columns.Add(header);
                    ColumnHeader header2 = (ColumnHeader)header.Clone();
                    header2.Text = "Value";
                    listViewSubscriptions.Columns.Add(header2);

                    for (int i = 0; i < temp.Count; i++)
                    {
                        tempSubscriber = (SubscriberData)temp[i];

                        lvItem = listViewSubscriptions.Items.Add(tempSubscriber.Name);
                        lvItem.SubItems.Add(tempSubscriber.Value.ToString());
                    }

                    if (NewPublisher != null && NewPublisher.FakeTickerList != null)
                    {
                        for (int i = 0; i < NewPublisher.FakeTickerList.Count; i++)
                        {
                            tempSubscriber = (SubscriberData)temp[i];

                            lvItem = listViewSubscriptions.Items.Add("H" + tempSubscriber.Name);
                            lvItem.SubItems.Add(tempSubscriber.Value.ToString());
                        }
                    }

                    NewSubscriber.IsUpdated = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #15
0
        public void fillImagenSystem(CapaDatos.Clases.Conexion conn, System.Windows.Forms.ListView listView, String query)
        {
            try
            {
                int x = 0;
                int y = 0;

                conn.querySQL(query);
                conn.fillDataset("", "");
                listView.Clear();

                if (conn.getDataSet().Tables.Count != 0)
                {
                    while (y < conn.getDataSet().Tables[0].Rows.Count)
                    {
                        x = 0;
                        while (x < conn.getDataSet().Tables[0].Columns.Count)
                        {
                            if (y == 0)
                            {
                                listView.Columns.Add(conn.getDataSet().Tables[0].Columns[x].ColumnName, 150, HorizontalAlignment.Left);
                            }
                            if (x == 0)
                            {
                                listView.Items.Add(conn.getDataSet().Tables[0].Rows[y].ItemArray[x].ToString());
                            }
                            else
                            {
                                listView.Items[y].SubItems.Add(conn.getDataSet().Tables[0].Rows[y].ItemArray[x].ToString());
                            }
                            x += 1;
                        }

                        if (y % 2 == 0)
                        {
                            // Damos color gris a las filas pares para dar un efecto de resaltado intercalado
                            listView.Items[y].BackColor = Color.WhiteSmoke;
                        }
                        y += 1;
                    }
                }
            }
            catch (Exception ex)
            {
                mssg.showMessage(ex.Message, "error", "");
            }
        }
            private void fill_tab()
            {
                slasher_list_view.Clear();
                slasher_list_view.Columns.Clear();
                slasher_list_view.Columns.Add("Item", -2, HorizontalAlignment.Left);
                slasher_list_view.Columns.Add("Count", -2, HorizontalAlignment.Left);
                slasher_list_view.View    = View.Details;
                slasher_list_view.Sorting = System.Windows.Forms.SortOrder.Ascending;

                foreach (var element in dbd_char.Inventory)
                {
                    var item = new ListViewItem(new[] { element.Key, "" + element.Value });
                    slasher_list_view.Items.Add(item);
                }
                slasher_list_view.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                slasher_list_view.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
Beispiel #17
0
        public void BindData(DataTable minutsTable, DataRow current)
        {
            slnList.Clear();

            resultSetData = minutsTable;

            stockName = current["name"].ToString();
            double price = Double.Parse(current["price"].ToString());
            double close = Double.Parse(current["closeP"].ToString());

            stockPrice   = "�勺 " + price.ToString("0.00");
            stockUpdown  = "嫻鋸 " + (price - close).ToString("0.00");
            stockPercent = "嫻嫌 " + ((price - close) / close * 100).ToString("0.00") + ("%");
            stockState   = Math.Sign(price - close);

            ReadData(Double.Parse(current["closeP"].ToString()), Double.Parse(current["high"].ToString()), Double.Parse(current["low"].ToString()));
        }
Beispiel #18
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            // raise event to allow take over the items from local userIdentities and nntpServers
            // to app.FeedHandler.Identity and app.FeedHandler.NntpServers
            if (DefinitionsModified != null)
            {
                DefinitionsModified(this, EventArgs.Empty);
            }

            userIdentities.Clear();
            nntpServers.Clear();
            listAccounts.Clear();
            treeServers.Nodes.Clear();

            this.InitializeWidgets(application.Identities, application.CurrentNntpServers);

            this.btnApply.Enabled = false;
        }
Beispiel #19
0
        public void MetaData_AfterActivation()
        {
            listViewClassificazioni.Clear();
            listViewClassificazioni.BeginUpdate();

            foreach (DataRow R in DescrClass.Select())
            {
                ListViewItem listViewOD = new ListViewItem(R["description"].ToString());
                listViewOD.Tag = R["idsorkind"].ToString();
                listViewClassificazioni.Items.Add(listViewOD);
            }

            listViewClassificazioni.CheckBoxes = true;
            listViewClassificazioni.Columns.Add("Descrizione", 300, HorizontalAlignment.Left);
            listViewClassificazioni.View = View.Details;
            listViewClassificazioni.EndUpdate();
            listViewClassificazioni.Refresh();
        }
Beispiel #20
0
        public void SetListview(string filtro)
        {
            listViewLog.Clear();
            listViewLog.BeginUpdate();

            DataTable TabellaDescrClass = Conn.RUN_SELECT("columntypes", "*", null, filtro, null, null, true);

            foreach (DataRow R1 in TabellaDescrClass.Select(null, "field"))
            {
                ListViewItem listViewOD = new ListViewItem(R1["field"].ToString());
                listViewOD.Tag = R1;
                listViewLog.Items.Add(listViewOD);
            }
            listViewLog.Columns.Add("Descrizione", 300, HorizontalAlignment.Left);
            listViewLog.CheckBoxes = true;
            listViewLog.View       = View.Details;
            listViewLog.EndUpdate();
            listViewLog.Refresh();
        }
Beispiel #21
0
        private void affichRdv()
        {
            lstRendezVous.Clear();

            DataSet monDs;

            monDs = service.getAllRdvFix(calendrier.SelectionStart, nomMed);
            //parcour du dataset et affichage dans la listeView


            int i;

            lstRendezVous.Columns.Add("Nom Patient", 90, System.Windows.Forms.HorizontalAlignment.Center);
            lstRendezVous.Columns.Add("Heure", 190, System.Windows.Forms.HorizontalAlignment.Center);

            for (i = 0; i <= monDs.Tables[0].Rows.Count - 1; i++)
            {
                lstRendezVous.Items.Add(monDs.Tables[0].Rows[i][0].ToString()).SubItems.Add(monDs.Tables[0].Rows[i][1].ToString());
            }
        }
        private void loadFiles()
        {
            try
            {
                lvwFiles.Clear();
                foreach (FileItem file in fileExplorer.GetFiles(carpetaEntrada))
                {
                    ListViewItem fileItem = new ListViewItem();

                    fileItem.Text       = file.FileName;
                    fileItem.Tag        = file;
                    fileItem.ImageIndex = 0;
                    lvwFiles.Items.Add(fileItem);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
        //TODO this is duplicated almost entirely (without ListView) in ReportBuilder)
        public void PopulateExceptionTab(Exception rootException)
        {
            TheException = rootException;
            listviewExceptions.Clear();
            listviewExceptions.Columns.Add("Level", 100, HorizontalAlignment.Left);
            listviewExceptions.Columns.Add("Exception Type", 150, HorizontalAlignment.Left);
            listviewExceptions.Columns.Add("Target Site / Method", 150, HorizontalAlignment.Left);

            var listViewItem = new ListViewItem
            {
                Text = "Top Level"
            };

            listViewItem.SubItems.Add(rootException.GetType().ToString());

            AddTargetSite(listViewItem, rootException);
            listViewItem.Tag = "0";
            listviewExceptions.Items.Add(listViewItem);
            listViewItem.Selected = true;

            int       index            = 0;
            Exception currentException = rootException;

            while (currentException.InnerException != null)
            {
                index++;
                currentException = currentException.InnerException;
                listViewItem     = new ListViewItem
                {
                    Text = string.Format("Inner Exception {0}", index)
                };
                listViewItem.SubItems.Add(currentException.GetType().ToString());
                AddTargetSite(listViewItem, currentException);
                listViewItem.Tag = index.ToString();
                listviewExceptions.Items.Add(listViewItem);
            }

            txtExceptionTabStackTrace.Text = rootException.StackTrace;
            txtExceptionTabMessage.Text    = rootException.Message;
        }
Beispiel #24
0
        /// <summary>
        /// Sets the columns shown in the list view.
        /// </summary>
        protected virtual void SetColumns(object[][] columns)
        {
            ItemsLV.Clear();

            m_columns = columns;

            foreach (object[] column in columns)
            {
                ColumnHeader header = new ColumnHeader();

                header.Text      = column[0] as string;
                header.TextAlign = (HorizontalAlignment)column[1];

                ItemsLV.Columns.Add(header);
            }

            ColumnHeader blank = new ColumnHeader();

            blank.Text = String.Empty;
            ItemsLV.Columns.Add(blank);

            AdjustColumns();
        }
Beispiel #25
0
        /// <summary>
        /// Aborts the current thread loading messages, if a thread is running.
        /// </summary>
        private void AttemptMessageLoadStart()
        {
            lock (this)
            {
                //abort any current load
                if (_messageLoadThread != null)
                {
                    FinishMessageLoad(true);
                }

                messagesListView.Items.Clear();

                if (_qSetQueueItem != null)
                {
                    workingPanel.Visible = true;
                }

                //create the required column headers
                messagesListView.Clear();
                foreach (string columnName in _userSettings.MessageBrowserColumnListCollection)
                {
                    messagesListView.Columns.Add(columnName, (messagesListView.Width - 10) / _userSettings.MessageBrowserColumnListCollection.Count, HorizontalAlignment.Left);
                }

                if (_qSetQueueItem != null)
                {
                    //start the worker thread
                    _startedEvent.Reset();
                    ThreadPool.QueueUserWorkItem(new WaitCallback(GetSnapShotCallBack));
                    _startedEvent.WaitOne();

                    //set up the visualisable process
                    _workingProcess = new VisualizableProcess(Locale.UserMessages.RetrievingMessages, true);
                    OnBeforeMessageListLoaded(new VisualizableProcessEventArgs(_workingProcess));
                }
            }
        }
Beispiel #26
0
        public static void BindResultSet(ResultSet resultSet, ListView listView) {
            listView.BeginUpdate();
            try {
                listView.Clear();

                listView.Columns.Add("No");

                foreach(var name in resultSet.FieldNames)
                    listView.Columns.Add(name);

                var i = 0;
                foreach(var row in resultSet) {
                    var item = new ListViewItem(i.ToString());
                    foreach(var name in resultSet.FieldNames)
                        item.SubItems.Add(row[name].AsText());

                    listView.Items.Add(item);
                    i++;
                }
            }
            finally {
                listView.EndUpdate();
            }
        }
        public void createListView(ListView listView, String responseDate, String responseString)
        {
            // Add the group, using the date for the response data as the group name.
            ListViewGroup responseDateGroup = new ListViewGroup (responseDate);
            listView.Groups.Add (responseDateGroup);

            // This ensures that each entry is put on a separate line.
            listView.AutoResizeColumns (ColumnHeaderAutoResizeStyle.ColumnContent);

            // Without clearing the listview first, duplicate elements will appear.
            if (listView.Groups.Count == 1)
            {
                listView.Clear ();
            }

            // Display each response on a separate line.
            ListViewItem responseStringItem;
            String[] responses = responseString.Split ('\n');
            foreach (string word in responses)
            {
                responseStringItem = new ListViewItem (word, responseDateGroup);
                listView.Items.Add (responseStringItem);
            }
        }
Beispiel #28
0
        public DialogNew()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            listNewChoices.Clear();
            listNewChoices.BeginUpdate();

            ListViewItem lvi = new ListViewItem("Blank");

            listNewChoices.Items.Add(lvi);

            lvi = new ListViewItem("Data Base");
            listNewChoices.Items.Add(lvi);

            listNewChoices.LabelWrap = true;
            listNewChoices.Select();
            listNewChoices.EndUpdate();
        }
        public void ShowJsonItemData(ListView listView)
        {
            listView.Clear();

            BuildJsonItemDataList(listView, m_JsonCollection);
        }
 private void closeListDialog()
 {
     this.Height = 52;
     listView.Clear();
 }
        /// <summary>
        /// 将服务器状态放入ListView
        /// </summary>
        /// <param name="lstSvr"></param>
        public static void FillSrvStatusToList(ListView lstSvr)
        {
            lstSvr.Clear();
            lstSvr.Columns.Add("名称");
            lstSvr.Columns.Add("数据集数量");
            lstSvr.Columns.Add("数据大小");
            lstSvr.Columns.Add("文件大小");
            lstSvr.Columns.Add("索引数量");
            lstSvr.Columns.Add("索引数量大小");
            lstSvr.Columns.Add("对象数量");
            lstSvr.Columns.Add("占用大小");
            foreach (String mongoSvrKey in _mongoSrvLst.Keys)
            {
                try
                {
                    MongoServer mongoSvr = _mongoSrvLst[mongoSvrKey];
                    List<string> databaseNameList = mongoSvr.GetDatabaseNames().ToList<string>();
                    foreach (String strDBName in databaseNameList)
                    {
                        MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);
                        DatabaseStatsResult dbStatus = mongoDB.GetStats();
                        ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName);
                        try
                        {
                            lst.SubItems.Add(dbStatus.CollectionCount.ToString());

                        }
                        catch (Exception)
                        {

                            lst.SubItems.Add(string.Empty);
                        }

                        lst.SubItems.Add(GetSize(dbStatus.DataSize));
                        lst.SubItems.Add(GetSize(dbStatus.FileSize));
                        lst.SubItems.Add(dbStatus.IndexCount.ToString());
                        lst.SubItems.Add(GetSize(dbStatus.IndexSize));
                        lst.SubItems.Add(dbStatus.ObjectCount.ToString());
                        lst.SubItems.Add(GetSize(dbStatus.StorageSize));
                        lstSvr.Items.Add(lst);
                    }

                }
                catch (Exception)
                {
                    //throw;
                }
            }
        }
        /// <summary>
        /// 将数据Opr放入ListView
        /// </summary>
        /// <param name="lstSrvOpr"></param>
        public static void FillSrvOprToList(ListView lstSrvOpr)
        {
            lstSrvOpr.Clear();
            Boolean hasHeader = false;
            foreach (string mongoSvrKey in _mongoSrvLst.Keys)
            {
                try
                {
                    MongoServer mongosvr = _mongoSrvLst[mongoSvrKey];
                    List<string> databaseNameList = mongosvr.GetDatabaseNames().ToList<string>();
                    foreach (string strDBName in databaseNameList)
                    {
                        MongoDatabase mongoDB = mongosvr.GetDatabase(strDBName);
                        BsonDocument dbStatus = mongoDB.GetCurrentOp();
                        if (dbStatus.GetValue("inprog").AsBsonArray.Count > 0)
                        {
                            if (!hasHeader)
                            {

                                lstSrvOpr.Columns.Add("Name");
                                foreach (string item in dbStatus.GetValue("inprog").AsBsonArray[0].AsBsonDocument.Names)
                                {
                                    lstSrvOpr.Columns.Add(item);
                                }
                                hasHeader = true;
                            }

                            BsonArray doc = dbStatus.GetValue("inprog").AsBsonArray;
                            foreach (BsonDocument item in doc)
                            {
                                ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName);
                                foreach (string itemName in item.Names)
                                {
                                    lst.SubItems.Add(item.GetValue(itemName).ToString());
                                }
                                lstSrvOpr.Items.Add(lst);
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    //throw;
                }

            }
        }
 protected void InitListView(ListView lvFiles)
 {
     //init ListView control
     lvFiles.Clear();		//clear control
     //create column header for ListView
     lvFiles.Columns.Add("",22,System.Windows.Forms.HorizontalAlignment.Center);
     lvFiles.Columns.Add("Name",140,System.Windows.Forms.HorizontalAlignment.Left);
     lvFiles.Columns.Add("Size",60, System.Windows.Forms.HorizontalAlignment.Right);
     lvFiles.Columns.Add("Date", 90, System.Windows.Forms.HorizontalAlignment.Left);
 }
Beispiel #34
0
 //clears the list view
 private void ListClear()
 {
     listViewErrors.Clear();
 }
Beispiel #35
0
        private void UpdateFriendListView(ListView listview ,List<InboxUser> user, bool showNewMessage = false)
        {
            try
            {
                listview.Clear();
                ImageList il = new ImageList();
                il.TransparentColor = Color.Blue;
                il.ColorDepth = ColorDepth.Depth32Bit;
                il.ImageSize = new Size(50, 50);
                for (int i = 0; i < user.Count; i++)
                {
                    il.Images.Add(Image.FromFile(user[i].ProfilePath));
                    il.Images.SetKeyName(i, user[i].UserName);
                }
                listview.View = View.LargeIcon;
                //listview.LargeImageList = il;
                listview.Invoke(new Action(()=>listview.LargeImageList = il));
                for (int j = 0; j < user.Count; j++)
                {
                    ListViewItem item = new ListViewItem();
                    if (showNewMessage)
                    {
                        item.Text = GetInboxText(il.Images.Keys[j].ToString(), user[j].CountNew);
                        UpdateNewMessageLabel(null, lbReceiverNewMessage, user[j]);
                    }
                    else
                    {
                        item.Text = il.Images.Keys[j].ToString();
                    }

                    item.Name = user[j].UserID;
                    item.ImageIndex = j;
                   // listview.Items.Add(item);
                    listview.Invoke(new Action(()=>listview.Items.Add(item)));

                }
            }
            catch (Exception e)
            {
                Form1.Log(e);
            }
        }
        protected virtual void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            TreeNode node   = treeView1.SelectedNode;
            NodeType ioType = (NodeType)node.Tag;

            listView1.BeginUpdate();
            listView1.Clear();
            listView1.View = View.Details;

            switch (ioType)
            {
            case NodeType.DigitalInput:
                listView1.Columns.Add("State", 70, HorizontalAlignment.Center);
                listView1.Columns.Add("Digital Input Name", 300, HorizontalAlignment.Left);
                foreach (IDigitalInput ioPoint in ioManifest.digitalInputMap.Values)
                {
                    ListViewItem item = new ListViewItem((ioPoint.State == DigitalIOState.On)?"ON ":"OFF", 0);
                    item.Tag = ioPoint;
                    item.SubItems.Add(ioPoint.Name);
                    listView1.Items.Insert(0, item);
                }
                break;

            case NodeType.DigitalOutput:
                listView1.Columns.Add("State", 70, HorizontalAlignment.Center);
                listView1.Columns.Add("Digital Output Name", 300, HorizontalAlignment.Left);

                foreach (IDigitalOutput ioPoint in ioManifest.digitalOutputMap.Values)
                {
                    ListViewItem item = new ListViewItem((ioPoint.State == DigitalIOState.On)?"ON ":"OFF", 0);
                    item.Tag = ioPoint;
                    item.SubItems.Add(ioPoint.Name);
                    listView1.Items.Insert(0, item);
                }
                break;

            case NodeType.AnalogInput:
                listView1.Columns.Add("Value", 100, HorizontalAlignment.Center);
                listView1.Columns.Add("Unit", 100, HorizontalAlignment.Center);
                listView1.Columns.Add("Analog Input Name", 250, HorizontalAlignment.Left);

                foreach (IAnalogInput ioPoint in ioManifest.analogInputMap.Values)
                {
                    ListViewItem item = new ListViewItem(ioPoint.Value.ToString(), 0);
                    item.Tag = ioPoint;
                    item.SubItems.Add(ioPoint.Unit);
                    item.SubItems.Add(ioPoint.Name);
                    listView1.Items.Insert(0, item);
                }
                break;

            case NodeType.AnalogOutput:
                listView1.Columns.Add("Value", 100, HorizontalAlignment.Center);
                listView1.Columns.Add("Unit", 100, HorizontalAlignment.Center);
                listView1.Columns.Add("Analog Output Name", 250, HorizontalAlignment.Left);
                foreach (IAnalogOutput ioPoint in ioManifest.analogOutputMap.Values)
                {
                    ListViewItem item = new ListViewItem(ioPoint.Value.ToString(), 0);
                    item.Tag = ioPoint;
                    item.SubItems.Add(ioPoint.Unit);
                    item.SubItems.Add(ioPoint.Name);
                    listView1.Items.Insert(0, item);
                }
                break;
            }

            listView1.EndUpdate();

            if (ioType == NodeType.Axis)
            {
                listView1.Visible = false;
                listView1.Dock    = DockStyle.None;

                panelAxis1.Enabled = true;
                panelAxis1.Visible = true;
                panelAxis1.Dock    = DockStyle.Fill;

                // assign the one and only axis for this node
                panelAxis1.AssignAxisMap(ioManifest.axisMap);
            }
            else
            {
                listView1.Visible = true;
                listView1.Dock    = DockStyle.Fill;

                panelAxis1.Enabled = false;
                panelAxis1.Visible = false;
                panelAxis1.Dock    = DockStyle.Fill;
                panelAxis1.AssignAxis(null);
            }
        }
Beispiel #37
0
        private int fillCollumn(ListView.ListViewItemCollection items, string tableName,bool type)
        {
            bool flag = true;
            int counter = 0;
            if (type)
                items.Clear();

            List<object[]> fstDBNERows = new List<object[]> { };
            List<object[]> sndDBNERows = new List<object[]> { };
            List<ListViewItem> tItems = new List<ListViewItem> { };
            List<int> sI= new List<int> { };

            if (!flags.ContainsKey(tableName))
                flags.Add(tableName, new List<int> { });

            if (type)
                if (sTableChange)
                {
                    if (selectedTableIndex != null)
                        clearColumnsCheckers();
                    createColumnsCheckers(tableName);
                    selectedTableIndex = comboBox1.SelectedText;
                }

            if (type)
                sI = flags[tableName];

            SQLiteConnection fstDBConnection = new SQLiteConnection("Data Source=" + fstFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;");
            fstDBConnection.Open();
            SQLiteCommand read = new SQLiteCommand("SELECT * FROM " + tableName);
            read.Connection = fstDBConnection;
            SQLiteDataReader fstDBReader = read.ExecuteReader();

            SQLiteConnection sndDBConnection = new SQLiteConnection("Data Source=" + sndFilePath.Text + ";" + "FailIfMissing=True;Read Only=True;");
            sndDBConnection.Open();
            SQLiteCommand sndRead = new SQLiteCommand("SELECT * FROM " + tableName);
            sndRead.Connection = sndDBConnection;
            SQLiteDataReader sndDBReader = sndRead.ExecuteReader();

            while (sndDBReader.Read())
            {
                object[] tmp = new object[sndDBReader.FieldCount];
                for (int i = 0; i < tmp.Length; i++)
                    if (!sndDBReader.IsDBNull(i))
                        if (sndDBReader.GetFieldType(i) != typeof(DateTime))
                            tmp[i] = sndDBReader.GetValue(i);
                        else
                        {
                            tmp[i] = sndDBReader.GetString(i);
                        }
                    else
                        tmp[i] = "null";

                sndDBNERows.Add(tmp);
            }

            while (fstDBReader.Read())
            {
                object[] row = new object[fstDBReader.FieldCount];
                for (int i = 0; i < row.Length; i++)
                    if (!fstDBReader.IsDBNull(i))
                        if (fstDBReader.GetFieldType(i) != typeof(DateTime))
                            row[i] = fstDBReader.GetValue(i);
                        else
                        {
                            row[i] = fstDBReader.GetString(i);
                        }
                    else
                        row[i] = "null";

                if (!addEqRowInList(row, sndDBNERows, tItems, sI, type))
                   fstDBNERows.Add(row);

            }
            for (int i = 0; i < sndDBNERows.Count;i++ )
                if (addEqRowInList(sndDBNERows[i], fstDBNERows, tItems, sI, type))
                    sndDBNERows.RemoveAt(i);

            while (fstDBNERows.Count != 0 && sndDBNERows.Count != 0)
            {
                if (fstDBNERows.Count == 0)
                {
                    foreach (object[] row in sndDBNERows)
                        if (type)
                            addRow2List(null, row, tItems, 1, sI, null);
                    sndDBNERows.Clear();
                    counter += sndDBNERows.Count;
                }
                else if (sndDBNERows.Count == 0)
                {
                    foreach (object[] row in fstDBNERows)
                        if (type)
                            addRow2List(row, null, tItems, 1, sI, null);
                    fstDBNERows.Clear();
                    counter += fstDBNERows.Count;
                }
                else
                    for (int i = 0; i < fstDBNERows.Count; i++)
                    {
                        List<int> count = new List<int> { };
                        int pos=-1;
                        List<int> tcount = new List<int> { };
                        for (int j = 0; j < sndDBNERows.Count; j++)
                        {
                            tcount = findEqValInRows(fstDBNERows[i], sndDBNERows[j], sI);
                            if (tcount.Count >= count.Count)
                            {
                                count = tcount;
                                pos = j;
                            }
                        }
                        if (pos >= 0)
                        {
                            if (type)
                                addRow2List(fstDBNERows[i], sndDBNERows[pos], tItems, 2, sI, count);
                            fstDBNERows.RemoveAt(i);
                            sndDBNERows.RemoveAt(pos);
                            counter++;
                        }
                    }
            }
            listView2.Items.AddRange(tItems.ToArray());
            if(type)
                sTableChange = false;
            return counter;
        }
        /// <summary>
        /// Fill Database status to ListView
        /// </summary>
        /// <param name="lstSvr"></param>
        public static void FillDataBaseStatusToList(ListView lstSvr)
        {
            lstSvr.Clear();
            if (SystemManager.IsUseDefaultLanguage())
            {
                lstSvr.Columns.Add("DataBaseName");
                lstSvr.Columns.Add("CollectionCount");
                lstSvr.Columns.Add("DataSize");
                lstSvr.Columns.Add("FileSize");
                lstSvr.Columns.Add("IndexCount");
                lstSvr.Columns.Add("IndexSize");
                lstSvr.Columns.Add("ObjectCount");
                lstSvr.Columns.Add("StorageSize");
            }
            else
            {
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_DataBaseName));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_CollectionCount));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_DataSize));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_FileSize));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_IndexCount));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_IndexSize));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_ObjectCount));
                lstSvr.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.DataBase_Status_StorageSize));

            }
            foreach (String mongoSvrKey in _mongoConnSvrLst.Keys)
            {
                try
                {
                    MongoServer mongoSvr = _mongoConnSvrLst[mongoSvrKey];
                    //感谢 魏琼东 的Bug信息,一些命令必须以Admin执行
                    if (!SystemManager.GetCurrentServerConfig(mongoSvrKey).Health ||
                        !SystemManager.GetCurrentServerConfig(mongoSvrKey).LoginAsAdmin) { continue; }
                    List<String> databaseNameList = mongoSvr.GetDatabaseNames().ToList<String>();
                    foreach (String strDBName in databaseNameList)
                    {
                        MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);
                        DatabaseStatsResult dbStatus = mongoDB.GetStats();
                        ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName);
                        try
                        {
                            lst.SubItems.Add(dbStatus.CollectionCount.ToString());
                        }
                        catch (Exception)
                        {
                            lst.SubItems.Add("0");
                        }
                        lst.SubItems.Add(GetSize(dbStatus.DataSize));
                        lst.SubItems.Add(GetSize(dbStatus.FileSize));
                        lst.SubItems.Add(dbStatus.IndexCount.ToString());
                        lst.SubItems.Add(GetSize(dbStatus.IndexSize));
                        lst.SubItems.Add(dbStatus.ObjectCount.ToString());
                        lst.SubItems.Add(GetSize(dbStatus.StorageSize));
                        lstSvr.Items.Add(lst);
                    }

                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
      void showFiles(FilesResult files, ListView listToShow)
      {
        
         listToShow.BeginInvoke(new Action(() =>
         {

            //clear contents
            listToShow.Clear();
            // Create columns for the items and subitems.
            listToShow.Columns.Add("Filename", 400, HorizontalAlignment.Left);
            foreach (var file in files.FilesEntry)
            {
               ListViewItem item = new ListViewItem(file.Label, 0);
               item.Tag = file;
               listToShow.Items.Add(item);
            }

            listToShow.Show();

         }));
         StopProgress();
      }
Beispiel #40
0
        private void UpdateDisplay()
        {
            selectedPoint = (PointStorage)pointStore.Points[listPoints.SelectedItem];

            // publish event
            if (OnTreeViewSelect != null)
            {
                OnTreeViewSelect();
            }

            listView1.BeginUpdate();
            if (radioViewList.Checked)
            {
                listView1.Clear();

                listView1.Columns.Add("Index", 50, HorizontalAlignment.Center);
                listView1.Columns.Add("Time Stamp", 150, HorizontalAlignment.Center);
                for (int col = 0; col < selectedPoint.Dimension; col++)
                {
                    listView1.Columns.Add(selectedPoint.DimensionName[col], 70, HorizontalAlignment.Right);
                }
                for (int index = 0; index < selectedPoint.History.Count; index++)
                {
                    RobotPoint   point = (RobotPoint)selectedPoint.History[index];
                    ListViewItem item  = new ListViewItem(index.ToString());
                    item.Tag = point;
                    item.SubItems.Add(point.TimeStamp.ToString());
                    foreach (double val in point.Coordinate)
                    {
                        item.SubItems.Add(val.ToString("0.000"));
                    }
                    listView1.Items.Add(item);
                }
            }
            else if (radioStatistics.Checked)
            {
                listView1.Clear();
                listView1.Columns.Add("Dimension", 100, HorizontalAlignment.Center);
                listView1.Columns.Add("Average", 70, HorizontalAlignment.Center);
                listView1.Columns.Add("Stdev", 70, HorizontalAlignment.Center);
                listView1.Columns.Add("Min", 70, HorizontalAlignment.Center);
                listView1.Columns.Add("Max", 70, HorizontalAlignment.Center);

                for (int dimension = 0; dimension < selectedPoint.Dimension; dimension++)
                {
                    ListViewItem item = new ListViewItem(selectedPoint.DimensionName[dimension]);
                    item.SubItems.Add(selectedPoint.Average[dimension].ToString("0.000"));
                    item.SubItems.Add(selectedPoint.Stdev[dimension].ToString("0.000"));
                    item.SubItems.Add(selectedPoint.Min[dimension].ToString("0.000"));
                    item.SubItems.Add(selectedPoint.Max[dimension].ToString("0.000"));
                    listView1.Items.Add(item);
                }
            }
            else if (radioGraph.Checked)
            {
                comboBox1.Items.Clear();
                foreach (string dimension in selectedPoint.DimensionName)
                {
                    comboBox1.Items.Add(dimension);
                }
                if (comboBox1.Items.Count > 0)
                {
                    comboBox1.SelectedIndex = 0;
                }
            }

            listView1.EndUpdate();

            if (radioGraph.Checked)
            {
                comboBox1.Dock    = DockStyle.Top;
                comboBox1.Visible = true;

                simpleChart1.BringToFront();
                simpleChart1.Dock    = DockStyle.Fill;
                simpleChart1.Visible = true;

                listView1.Dock    = DockStyle.None;
                listView1.Visible = false;
            }
            else
            {
                comboBox1.Dock    = DockStyle.None;
                comboBox1.Visible = false;

                simpleChart1.Dock    = DockStyle.None;
                simpleChart1.Visible = false;

                listView1.Dock    = DockStyle.Fill;
                listView1.Visible = true;
            }
        }
 /// <summary>
 /// 用户列表
 /// </summary>
 /// <param name="dataList"></param>
 /// <param name="lstData"></param>
 private static void SetUserListToListView(List<BsonDocument> dataList, ListView lstData)
 {
     //2.4以后的用户,没有ReadOnly属性,取而代之的是roles属性
     //这里为了向前兼容暂时保持ReadOnle属性
     //Ref:http://docs.mongodb.org/manual/reference/method/db.addUser/
     lstData.Clear();
     if (!SystemManager.IsUseDefaultLanguage)
     {
         lstData.Columns.Add("ID");
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Username));
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Roles));
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Password));
         lstData.Columns.Add("userSource");
         lstData.Columns.Add("otherDBRoles");
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_ReadOnly));
     }
     else
     {
         lstData.Columns.Add("ID");
         lstData.Columns.Add("user");
         lstData.Columns.Add("roles");
         lstData.Columns.Add("password");
         lstData.Columns.Add("userSource");
         lstData.Columns.Add("otherDBRoles");
         lstData.Columns.Add("readonly");
     }
     foreach (BsonDocument docFile in dataList)
     {
         ListViewItem lstItem = new ListViewItem();
         //ID
         lstItem.Text = docFile.GetValue(KEY_ID).ToString();
         //User
         lstItem.SubItems.Add(docFile.GetValue("user").ToString());
         //roles
         BsonValue strRoles;
         docFile.TryGetValue("roles", out strRoles);
         if (strRoles == null)
         {
             lstItem.SubItems.Add("N/A");
         }
         else
         {
             lstItem.SubItems.Add(strRoles.ToString());
         }
         //密码是Hash表示的,这里没有安全隐患
         //Password和userSource不能同时设置,所以password也可能不存在
         BsonValue strPassword;
         docFile.TryGetValue("pwd", out strPassword);
         if (strPassword == null)
         {
             lstItem.SubItems.Add("N/A");
         }
         else
         {
             lstItem.SubItems.Add(strPassword.ToString());
         }
         //userSource
         BsonValue strUserSource;
         docFile.TryGetValue("userSource", out strUserSource);
         if (strUserSource == null)
         {
             lstItem.SubItems.Add("N/A");
         }
         else
         {
             lstItem.SubItems.Add(strUserSource.ToString());
         }
         //OtherDBRoles
         BsonValue strOtherDBRoles;
         docFile.TryGetValue("otherDBRoles", out strOtherDBRoles);
         if (strOtherDBRoles == null)
         {
             lstItem.SubItems.Add("N/A");
         }
         else
         {
             lstItem.SubItems.Add(strOtherDBRoles.ToString());
         }
         //ReadOnly
         //20130802 roles列表示。ReadOnly可能不存在!
         BsonValue strReadOnly;
         docFile.TryGetValue("readOnly", out strReadOnly);
         if (strReadOnly == null)
         {
             lstItem.SubItems.Add("N/A");
         }
         else
         {
             lstItem.SubItems.Add(strReadOnly.ToString());
         }
         lstData.Items.Add(lstItem);
     }
     lstData.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
 }
Beispiel #42
0
        void generation(List<rule> rl, ListView to, List<chain> el, List<String> neterm)
        {

            to.Clear();
            debv.Clear();
            DateTime date1 = DateTime.Now;
            debv.Items.Add(date1.ToLongTimeString());
            List<chain> chl = new List<chain>();
            List<String> exort = new List<String>();
            el.Clear();
            el.Add(new chain("", ""));
            chl.Add(new chain(targ, targ));
            pb.Value = pb.Minimum;
            int jj = 0;
            rule Res = new rule();
            
            for (int i = 0; i<chl.Count; i++)
            {

                it.Text = i.ToString();
                chain c = new chain("", "");
                c = chl[i];

                String str = c.data;
                String ts = "";
                foreach (char ch in str)
                {
                    if (!neterm.Contains(ch.ToString()))
                    {
                        ts += ch;
                    }
                }

                if (ts.Length <= max.Value && ts.Length != str.Length)
                {
                    foreach (char ch in str)
                    {
                        if (neterm.Contains(ch.ToString()))
                        {
                            rule B = new rule();
                            foreach (rule R in rl)
                            {
                                if (R.head == ch)
                                {
                                    B = R;
                                    break;
                                }
                            }

                            foreach (String s in B.sub)
                            {
                                Application.DoEvents();
                                if (str.Length == 1)
                                {
                                    chl.Add(new chain(s, c.parents + "->" + s));
                                    exort.Add(s);
                                }
                                else
                                {


                                    String beg = "";
                                    String fin = "";
                                    try
                                    {
                                        beg = str.Substring(0, str.IndexOf(ch));
                                    }
                                    catch (Exception)
                                    {
                                        throw;
                                    }

                                    try
                                    {
                                        fin = str.Substring(str.IndexOf(ch) + 1, str.Length - str.IndexOf(ch) - 1);
                                    }
                                    catch (Exception)
                                    {
                                        throw;
                                    }
                                    String sw = beg + s + fin;
                                    sw = sw.Replace(ex.ToString(), "");
                                    int kost = sw.Length - ts.Length;
                                    if (!exort.Contains(sw) && kost<30)
                                    {
                                        chl.Add(new chain(sw, c.parents + "->" + sw));
                                        exort.Add(sw);
                                    }

                                    //debv.Items.Add(" из " + str + " заменили первое вхождение " + ch.ToString() + " получили " +sw);
                                }

                            }
                            break;

                        }
                    }
                }
                else if (ts.Length == str.Length)
                {
                    el.Add(c);
                    

                }
                double j = ((double)i / (int)(chl.Count)) * 100;
                if (jj < Convert.ToInt32(j))
                {
                    jj = Convert.ToInt32(j);
                }

                pb.Value = jj;
                pb.CreateGraphics().DrawString(jj.ToString() + "%", new Font("Microsoft Sans Serif", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(pb.Width / 2 - 10, pb.Height / 2 - 7));

            }

            el.Remove(el.First());
            el.Sort(delegate (chain p1, chain p2) { return p1.data.Length.CompareTo(p2.data.Length); });
            pb.Value = pb.Maximum;
            pb.CreateGraphics().DrawString(pb.Maximum + "%", new Font("Microsoft Sans Serif", (float)8.25, FontStyle.Regular), Brushes.Black, new PointF(pb.Width / 2 - 10, pb.Height / 2 - 7));
            foreach (chain c in el)
            {
                if (c.data.Length >= min.Value && c.data.Length <= max.Value)
                {
                    to.Items.Add(c.data.Replace(ex.ToString(), ""));
                }
            }

            date1 = DateTime.Now;
            debv.Items.Add(date1.ToLongTimeString());

        }
 private static void StyleListView(ListView listView)
 {
     listView.Clear();
     listView.Columns.Add("");
     listView.Columns.Add("");
     listView.View = View.Details;
     listView.FullRowSelect = true;
     listView.BackColor = Color.Black;
     listView.ForeColor = Color.White;
     listView.HeaderStyle = ColumnHeaderStyle.None;
     listView.Font = labelFont;
     listView.Columns[0].Width = 0;
     listView.Columns[1].Width = listView.ClientRectangle.Width - SystemInformation.VerticalScrollBarWidth;
 }
 public static void ConstruireListview(System.Windows.Forms.ListView lv,
                                       Type classType, System.Collections.ArrayList stCollection, int ImageIndex)
 {
     try
     {
         lv.Clear();
         lv.Columns.Clear();
         PropertyInfo[] props = classType.GetProperties();
         foreach (PropertyInfo prop in props)
         {
             foreach (object o in prop.GetCustomAttributes(typeof(DisplayAttribute), false))
             {
                 if (((DisplayAttribute)o).Display)
                 {
                     object[] attributes = prop.GetCustomAttributes(typeof(MappingFieldAttribute), true);
                     if (attributes.Length > 0)
                     {
                         string       colname = ((LabelFieldAttribute)(prop.GetCustomAttributes(typeof(LabelFieldAttribute), true)[0])).FieldName;
                         ColumnHeader ch      = new ColumnHeader();
                         ch.Text  = colname;
                         ch.Tag   = prop;
                         ch.Width = -2;
                         if (prop.PropertyType != typeof(String))
                         {
                             ch.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
                         }
                         else
                         {
                             ch.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
                         }
                         lv.Columns.Add(ch);
                     }
                 }
             }
         }
         lv.View          = System.Windows.Forms.View.Details;
         lv.FullRowSelect = true;
         lv.HideSelection = false;
         if (stCollection != null)
         {
             foreach (object o in stCollection)
             {
                 System.Windows.Forms.ListViewItem li = null;
                 for (int i = 0; i < lv.Columns.Count; i++)
                 {
                     PropertyInfo pop    = (PropertyInfo)lv.Columns[i].Tag;
                     string       _value = string.Empty;
                     if (pop.GetValue(o, null) != null)
                     {
                         _value = ReturnObjectValue(pop, o);
                     }
                     if (li == null)
                     {
                         li = new ListViewItem(_value);
                     }
                     else
                     {
                         li.SubItems.Add(_value);
                     }
                 }
                 li.ImageIndex = ImageIndex;
                 li.Tag        = o;
                 lv.Items.Add(li);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     //AutoResizeByContentAndHeader(lv);
     //lv.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
 }
 private void btnQuery_Click(object sender, System.EventArgs e)
 {
     lv.Clear();
     Querying();
 }
 /// <summary>
 /// 用户列表
 /// </summary>
 /// <param name="dataList"></param>
 /// <param name="lstData"></param>
 private static void SetUserListToListView(List<BsonDocument> dataList, ListView lstData)
 {
     lstData.Clear();
     lstData.Columns.Add("ID");
     lstData.Columns.Add("用户名");
     lstData.Columns.Add("是否只读");
     //密码是密文表示的,这里没有安全隐患
     lstData.Columns.Add("密码");
     foreach (BsonDocument docFile in dataList)
     {
         ListViewItem lstItem = new ListViewItem();
         lstItem.Text = docFile.GetValue("_id").ToString();
         lstItem.SubItems.Add(docFile.GetValue("user").ToString());
         lstItem.SubItems.Add(docFile.GetValue("readOnly").ToString());
         lstItem.SubItems.Add(docFile.GetValue("pwd").ToString());
         lstData.Items.Add(lstItem);
     }
 }
 /// <summary>
 /// 将数据放入ListView中进行展示
 /// </summary>
 /// <param name="collectionName"></param>
 /// <param name="lstData"></param>
 /// <param name="dataList"></param>
 public static void FillDataToListView(string collectionName, ListView lstData, List<BsonDocument> dataList)
 {
     lstData.Clear();
     lstData.SmallImageList = null;
     switch (collectionName)
     {
         case COLLECTION_NAME_GFS_FILES:
             SetGridFileToListView(dataList, lstData);
             break;
         case COLLECTION_NAME_USER:
             SetUserListToListView(dataList, lstData);
             break;
         default:
             List<string> _columnlist = new List<string>();
             foreach (BsonDocument docItem in dataList)
             {
                 ListViewItem lstItem = new ListViewItem();
                 foreach (String item in docItem.Names)
                 {
                     if (!_columnlist.Contains(item))
                     {
                         _columnlist.Add(item);
                         lstData.Columns.Add(item);
                     }
                 }
                 //Key:_id
                 lstItem.Text = docItem.GetValue(_columnlist[0]).ToString();
                 //这里保存真实的主Key数据,删除的时候使用
                 lstItem.Tag = docItem.GetValue(_columnlist[0]);
                 //OtherItems
                 for (int i = 1; i < _columnlist.Count; i++)
                 {
                     BsonValue val;
                     docItem.TryGetValue(_columnlist[i].ToString(), out val);
                     if (val == null)
                     {
                         lstItem.SubItems.Add("");
                     }
                     else
                     {
                         lstItem.SubItems.Add(ConvertForShow(val));
                     }
                 }
                 lstData.Items.Add(lstItem);
             }
             break;
     }
 }
        /// <summary>
        /// 将DB状态放入ListView
        /// </summary>
        /// <param name="lstData"></param>
        public static void FillDBStatusToList(ListView lstData)
        {
            lstData.Clear();
            lstData.Columns.Add("名称");
            lstData.Columns.Add("文档数量");
            lstData.Columns.Add("实际大小");
            lstData.Columns.Add("占用大小");
            lstData.Columns.Add("索引");
            lstData.Columns.Add("平均对象大小");
            lstData.Columns.Add("填充因子");
            foreach (String mongoSvrKey in _mongoSrvLst.Keys)
            {
                try
                {
                    MongoServer mongoSvr = _mongoSrvLst[mongoSvrKey];
                    List<string> databaseNameList = mongoSvr.GetDatabaseNames().ToList<string>();
                    foreach (string strDBName in databaseNameList)
                    {
                        MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);

                        List<string> colNameList = mongoDB.GetCollectionNames().ToList<string>();
                        foreach (string strColName in colNameList)
                        {

                            CollectionStatsResult dbStatus = mongoDB.GetCollection(strColName).GetStats();
                            ListViewItem lst = new ListViewItem(strDBName + "." + strColName);
                            lst.SubItems.Add(dbStatus.ObjectCount.ToString());
                            lst.SubItems.Add(GetSize(dbStatus.DataSize));
                            lst.SubItems.Add(GetSize(dbStatus.StorageSize));
                            lst.SubItems.Add(GetSize(dbStatus.TotalIndexSize));
                            try
                            {
                                //在某些条件下,这个值会抛出异常,IndexKeyNotFound
                                lst.SubItems.Add(GetSize((long)dbStatus.AverageObjectSize));
                            }
                            catch (Exception)
                            {
                                lst.SubItems.Add("-");
                            }
                            try
                            {
                                //在某些条件下,这个值会抛出异常,IndexKeyNotFound
                                lst.SubItems.Add(dbStatus.PaddingFactor.ToString());
                            }
                            catch (Exception)
                            {
                                lst.SubItems.Add("-");
                            }
                            lstData.Items.Add(lst);
                        }
                    }
                }
                catch (Exception)
                {
                    //throw;
                }
            }
        }
        /// <summary>
        /// 将数据放入ListView中进行展示
        /// </summary>
        /// <param name="collectionName"></param>
        /// <param name="lstData"></param>
        /// <param name="dataList"></param>
        public static void FillDataToListView(String collectionName, ListView lstData, List<BsonDocument> dataList)
        {
            lstData.Clear();
            lstData.SmallImageList = null;
            switch (collectionName)
            {
                case COLLECTION_NAME_GFS_FILES:
                    SetGridFileToListView(dataList, lstData);
                    break;
                case COLLECTION_NAME_USER:
                    SetUserListToListView(dataList, lstData);
                    break;
                default:
                    List<String> _columnlist = new List<String>();
                    //可以让_id 不在第一位,昏过去了,很多逻辑需要调整
                    bool isSystem = IsSystemCollection(SystemManager.GetCurrentCollection());
                    if (!isSystem)
                    {
                        _columnlist.Add(KEY_ID);
                        lstData.Columns.Add(KEY_ID);
                    }
                    foreach (BsonDocument docItem in dataList)
                    {
                        ListViewItem lstItem = new ListViewItem();
                        foreach (String item in docItem.Names)
                        {
                            if (!_columnlist.Contains(item))
                            {
                                _columnlist.Add(item);
                                lstData.Columns.Add(item);
                            }
                        }

                        //Key:_id
                        if (!isSystem)
                        {
                            BsonElement id;
                            docItem.TryGetElement(KEY_ID, out id);
                            if (id != null)
                            {
                                lstItem.Text = docItem.GetValue(KEY_ID).ToString();
                                //这里保存真实的主Key数据,删除的时候使用
                                lstItem.Tag = docItem.GetValue(KEY_ID);
                            }
                            else
                            {
                                lstItem.Text = "[Empty]";
                                lstItem.Tag = docItem.GetElement(0).Value;
                            }
                        }
                        else
                        {
                            lstItem.Text = docItem.GetValue(_columnlist[0].ToString()).ToString();
                        }
                        //OtherItems
                        for (int i = isSystem ? 1 : 0; i < _columnlist.Count; i++)
                        {
                            if (_columnlist[i].ToString() == KEY_ID) { continue; }
                            BsonValue val;
                            docItem.TryGetValue(_columnlist[i].ToString(), out val);
                            if (val == null)
                            {
                                lstItem.SubItems.Add("");
                            }
                            else
                            {
                                lstItem.SubItems.Add(ConvertToString(val));
                            }
                        }
                        lstData.Items.Add(lstItem);
                    }
                    break;
            }
        }
Beispiel #50
0
        void SetLV(ListView objLV, bool IsMore)
        {
            if (IsMore)
                objLV.Clear();
            objLV.BeginUpdate();
            objLV.View = View.Details;
            objLV.GridLines = true;
            objLV.HeaderStyle = ColumnHeaderStyle.Nonclickable;

            if (IsMore)
            {
                objLV.Columns.Add("", 20, HorizontalAlignment.Left);
            }
            else
            {
                objLV.CheckBoxes = false;
                objLV.Columns.Add("", 0, HorizontalAlignment.Left);
                objLV.Columns.Add("比例", 80, HorizontalAlignment.Center);
            }

            objLV.Columns.Add("物料編碼", 100, HorizontalAlignment.Center);
            objLV.Columns.Add("物料類型", 180, HorizontalAlignment.Center);
            objLV.Columns.Add("物料名稱", 150, HorizontalAlignment.Center);
            objLV.Columns.Add("描述", 280, HorizontalAlignment.Center);
            objLV.Columns.Add("物料簡稱", 100, HorizontalAlignment.Center);
            objLV.Columns.Add("物料牌子", 100, HorizontalAlignment.Center);
            objLV.Columns.Add("單位", 50, HorizontalAlignment.Center);
            objLV.Columns.Add("闊度(MM)", 100, HorizontalAlignment.Center);
            objLV.Columns.Add("長度(M)", 100, HorizontalAlignment.Center);
            objLV.Columns.Add("是否刪除", 60, HorizontalAlignment.Center);
            objLV.Columns.Add("更新時間", 100, HorizontalAlignment.Center);
            objLV.Columns.Add("是否同步", 60, HorizontalAlignment.Center);
            objLV.Visible = true;
        }
        /// <summary>
        /// 将数据Opr放入ListView
        /// </summary>
        /// <param name="lstSrvOpr"></param>
        public static void FillCurrentOprToList(ListView lstSrvOpr)
        {
            lstSrvOpr.Clear();
            lstSrvOpr.Columns.Add("Name");
            lstSrvOpr.Columns.Add("opid");
            lstSrvOpr.Columns.Add("active");
            lstSrvOpr.Columns.Add("lockType");
            lstSrvOpr.Columns.Add("waitingForLock");
            lstSrvOpr.Columns.Add("secs_running");
            lstSrvOpr.Columns.Add("op");
            lstSrvOpr.Columns.Add("ns");
            lstSrvOpr.Columns.Add("query");
            lstSrvOpr.Columns.Add("client");
            lstSrvOpr.Columns.Add("desc");
            lstSrvOpr.Columns.Add("connectionId");
            lstSrvOpr.Columns.Add("numYields");

            foreach (String mongoSvrKey in _mongoConnSvrLst.Keys)
            {
                try
                {
                    MongoServer mongoSvr = _mongoConnSvrLst[mongoSvrKey];
                    //感谢 魏琼东 的Bug信息,一些命令必须以Admin执行
                    if (!SystemManager.GetCurrentServerConfig(mongoSvrKey).Health ||
                        !SystemManager.GetCurrentServerConfig(mongoSvrKey).LoginAsAdmin) { continue; }
                    List<String> databaseNameList = mongoSvr.GetDatabaseNames().ToList<String>();
                    foreach (String strDBName in databaseNameList)
                    {
                        try
                        {
                            MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);
                            BsonDocument dbStatus = mongoDB.GetCurrentOp();
                            BsonArray doc = dbStatus.GetValue("inprog").AsBsonArray;
                            foreach (BsonDocument item in doc)
                            {
                                ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName);
                                foreach (String itemName in item.Names)
                                {
                                    lst.SubItems.Add(item.GetValue(itemName).ToString());
                                }
                                lstSrvOpr.Items.Add(lst);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        /// <summary>
        /// GFS系统
        /// </summary>
        /// <param name="dataList"></param>
        /// <param name="lstData"></param>
        private static void SetGridFileToListView(List<BsonDocument> dataList, ListView lstData)
        {
            lstData.Clear();
            if (!SystemManager.IsUseDefaultLanguage)
            {
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.GFS_filename));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.GFS_length));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.GFS_chunkSize));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.GFS_uploadDate));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.GFS_md5));
                if (!SystemManager.MONO_MODE)
                {
                    lstData.Columns.Add("ContentType");
                }
            }
            else
            {
                lstData.Columns.Add("filename");
                lstData.Columns.Add("length");
                lstData.Columns.Add("chunkSize");
                lstData.Columns.Add("uploadDate");
                lstData.Columns.Add("MD5");
                if (!SystemManager.MONO_MODE)
                {
                    lstData.Columns.Add("ContentType");
                }
            }
            lstData.SmallImageList = GetSystemIcon.IconImagelist;
            lstData.LargeImageList = GetSystemIcon.IconImagelist;
            lstData.TileSize = new Size(200, 100);

            foreach (BsonDocument docFile in dataList)
            {
                String Filename = docFile.GetValue("filename").ToString();
                ListViewItem lstItem = new ListViewItem();
                lstItem.ImageIndex = GetSystemIcon.GetIconIndexByFileName(Filename, false);
                lstItem.Text = Filename;
                lstItem.ToolTipText = Filename;
                lstItem.SubItems.Add(GetSize(docFile.GetValue("length")));
                lstItem.SubItems.Add(GetSize(docFile.GetValue("chunkSize")));
                lstItem.SubItems.Add(ConvertToString(docFile.GetValue("uploadDate")));
                lstItem.SubItems.Add(ConvertToString(docFile.GetValue("md5")));

                if (!SystemManager.MONO_MODE)
                {
                    lstItem.SubItems.Add(GetSystemIcon.GetContentType(Filename));
                }
                lstData.Items.Add(lstItem);
            }
            // 用新的排序方法对ListView排序
            MongoDBHelper.lvwColumnSorter _lvwGFSColumnSorter = new MongoDBHelper.lvwColumnSorter();
            lstData.ListViewItemSorter = _lvwGFSColumnSorter;
            lstData.ColumnClick += new ColumnClickEventHandler(
                (sender, e) =>
                {
                    switch (e.Column)
                    {
                        case 1:
                        case 2:
                            _lvwGFSColumnSorter.CompareMethod = MongoDBHelper.lvwColumnSorter.SortMethod.SizeCompare;
                            break;
                        default:
                            _lvwGFSColumnSorter.CompareMethod = MongoDBHelper.lvwColumnSorter.SortMethod.StringCompare;
                            break;
                    }
                    // 检查点击的列是不是现在的排序列.
                    if (e.Column == _lvwGFSColumnSorter.SortColumn)
                    {
                        // 重新设置此列的排序方法.
                        if (_lvwGFSColumnSorter.Order == SortOrder.Ascending)
                        {
                            _lvwGFSColumnSorter.Order = SortOrder.Descending;
                        }
                        else
                        {
                            _lvwGFSColumnSorter.Order = SortOrder.Ascending;
                        }
                    }
                    else
                    {
                        // 设置排序列,默认为正向排序
                        _lvwGFSColumnSorter.SortColumn = e.Column;
                        _lvwGFSColumnSorter.Order = SortOrder.Ascending;
                    }
                    lstData.Sort();

                }
                );
        }
        /// <summary>
        /// fill Collection status to ListView
        /// </summary>
        /// <param name="lstData"></param>
        public static void FillCollectionStatusToList(ListView lstData)
        {
            lstData.Clear();

            if (SystemManager.IsUseDefaultLanguage())
            {
                lstData.Columns.Add("CollectionName");
                lstData.Columns.Add("ObjectCount");
                lstData.Columns.Add("DataSize");
                lstData.Columns.Add("LastExtentSize");
                lstData.Columns.Add("StorageSize");
                lstData.Columns.Add("TotalIndexSize");

                //2012-3-6
                lstData.Columns.Add("IsCapped");
                lstData.Columns.Add("MaxDocuments");

                lstData.Columns.Add("AverageObjectSize");
                lstData.Columns.Add("PaddingFactor");
            }
            else
            {
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_CollectionName));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_ObjectCount));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_DataSize));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_LastExtentSize));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_StorageSize));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_TotalIndexSize));

                //2012-3-6
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_IsCapped));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_MaxDocuments));

                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_AverageObjectSize));
                lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Collection_Status_PaddingFactor));
            }
            foreach (String mongoSvrKey in _mongoConnSvrLst.Keys)
            {
                try
                {
                    MongoServer mongoSvr = _mongoConnSvrLst[mongoSvrKey];
                    //感谢 魏琼东 的Bug信息,一些命令必须以Admin执行
                    if (!SystemManager.GetCurrentServerConfig(mongoSvrKey).Health ||
                         !SystemManager.GetCurrentServerConfig(mongoSvrKey).LoginAsAdmin) { continue; }
                    List<String> databaseNameList = mongoSvr.GetDatabaseNames().ToList<String>();
                    foreach (String strDBName in databaseNameList)
                    {
                        MongoDatabase mongoDB = mongoSvr.GetDatabase(strDBName);

                        List<String> colNameList = mongoDB.GetCollectionNames().ToList<String>();
                        foreach (String strColName in colNameList)
                        {
                            try
                            {
                                CollectionStatsResult CollectionStatus = mongoDB.GetCollection(strColName).GetStats();
                                ListViewItem lst = new ListViewItem(mongoSvrKey + "." + strDBName + "." + strColName);
                                lst.SubItems.Add(CollectionStatus.ObjectCount.ToString());
                                lst.SubItems.Add(GetSize(CollectionStatus.DataSize));
                                lst.SubItems.Add(GetSize(CollectionStatus.LastExtentSize));
                                lst.SubItems.Add(GetSize(CollectionStatus.StorageSize));
                                lst.SubItems.Add(GetSize(CollectionStatus.TotalIndexSize));

                                //2012-3-6
                                lst.SubItems.Add(CollectionStatus.IsCapped.ToString());
                                lst.SubItems.Add(CollectionStatus.MaxDocuments.ToString());

                                if (CollectionStatus.ObjectCount != 0)
                                {
                                    //在某些条件下,这个值会抛出异常,IndexKeyNotFound
                                    //同时发现,这个时候Count = 0,TryCatch可能会消耗时间,所以改为条件判断
                                    lst.SubItems.Add(GetSize((long)CollectionStatus.AverageObjectSize));
                                }
                                else
                                {
                                    lst.SubItems.Add("0");
                                }

                                try
                                {
                                    //在某些条件下,这个值会抛出异常,IndexKeyNotFound
                                    lst.SubItems.Add(CollectionStatus.PaddingFactor.ToString());
                                }
                                catch (Exception)
                                {
                                    lst.SubItems.Add("0");
                                }
                                lstData.Items.Add(lst);
                            }
                            catch (Exception)
                            {
                                //throw;
                                //TODO:排序时候会发生错误,所以暂时不对应
                                //lstData.Items.Add(new ListViewItem(strColName + "[Exception]"));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
 /// <summary>
 /// 用户列表
 /// </summary>
 /// <param name="dataList"></param>
 /// <param name="lstData"></param>
 private static void SetUserListToListView(List<BsonDocument> dataList, ListView lstData)
 {
     lstData.Clear();
     if (!SystemManager.IsUseDefaultLanguage)
     {
         lstData.Columns.Add("ID");
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Username));
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_ReadOnly));
         lstData.Columns.Add(SystemManager.mStringResource.GetText(StringResource.TextType.Common_Password));
     }
     else
     {
         lstData.Columns.Add("ID");
         lstData.Columns.Add("user");
         lstData.Columns.Add("readonly");
         lstData.Columns.Add("password");
     }
     foreach (BsonDocument docFile in dataList)
     {
         ListViewItem lstItem = new ListViewItem();
         lstItem.Text = docFile.GetValue(KEY_ID).ToString();
         lstItem.SubItems.Add(docFile.GetValue("user").ToString());
         lstItem.SubItems.Add(docFile.GetValue("readOnly").ToString());
         //密码是密文表示的,这里没有安全隐患
         lstItem.SubItems.Add(docFile.GetValue("pwd").ToString());
         lstData.Items.Add(lstItem);
     }
 }
Beispiel #55
0
		public void ClearTest ()
		{
			Form myform = new Form ();
			myform.ShowInTaskbar = false;
			myform.Visible = true;
			ListView mylistview = new ListView ();
			ListViewItem itemA = mylistview.Items.Add ("A");
			ColumnHeader colA = mylistview.Columns.Add ("Item Column", -2, HorizontalAlignment.Left);
			Assert.AreSame (mylistview, itemA.ListView, "#1");
			Assert.AreSame (mylistview, colA.ListView, "#2");
			mylistview.Visible = true;
			myform.Controls.Add (mylistview);
			Assert.AreEqual (1, mylistview.Columns.Count, "#3");
			Assert.AreEqual (1, mylistview.Items.Count, "#4");
			mylistview.Clear ();
			Assert.AreEqual (0, mylistview.Columns.Count, "#5");
			Assert.AreEqual (0, mylistview.Items.Count, "#6");
			Assert.IsNull (itemA.ListView, "#7");
			Assert.IsNull (colA.ListView, "#8");
			myform.Dispose ();
		}
 /// <summary>
 /// GFS系统
 /// </summary>
 /// <param name="dataList"></param>
 /// <param name="lstData"></param>
 private static void SetGridFileToListView(List<BsonDocument> dataList, ListView lstData)
 {
     lstData.Clear();
     lstData.Columns.Add("文件名称");
     lstData.Columns.Add("文件大小");
     lstData.Columns.Add("块大小");
     lstData.Columns.Add("上传日期");
     lstData.Columns.Add("MD5");
     lstData.SmallImageList = GetSystemIcon.IconImagelist;
     foreach (BsonDocument docFile in dataList)
     {
         ListViewItem lstItem = new ListViewItem();
         lstItem.ImageIndex = GetSystemIcon.GetIconIndexByFileName(docFile.GetValue("filename").ToString(), false);
         lstItem.Text = docFile.GetValue("filename").ToString();
         lstItem.SubItems.Add(GetSize((int)docFile.GetValue("length")));
         lstItem.SubItems.Add(GetSize((int)docFile.GetValue("chunkSize")));
         lstItem.SubItems.Add(ConvertForShow(docFile.GetValue("uploadDate")));
         lstItem.SubItems.Add(ConvertForShow(docFile.GetValue("md5")));
         lstData.Items.Add(lstItem);
     }
 }
Beispiel #57
0
        /// <summary>
        /// Perform Regular Expression Test
        /// </summary>
        private void DoTest()
        {
            // Setup options
            RegexOptions ro = new RegexOptions();

            if (mnuIgnore.Checked)
            {
                ro = ro | RegexOptions.IgnoreCase;
            }
            if (mnuMultiLine.Checked)
            {
                ro = ro | RegexOptions.Multiline;
            }
            ro = ro | RegexOptions.IgnorePatternWhitespace;

            // Create Regular Expression Engine
            Regex           re = null;
            MatchCollection mc = null;

            try {
                string reg = txtRegEx.Text;

                if (txtRegEx.SelectionLength > 0)
                {
                    reg = txtRegEx.SelectedText;
                }

                //reg = reg.Replace("\r\n", "").Replace("\n", "").Replace("\t", "");

                re = new Regex(reg, ro);
                mc = re.Matches(rtbText.Text);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Setup ListView
            int[] ag = re.GetGroupNumbers();

            lvResult.Clear();

            lvResult.Columns.Add("Match", 435, HorizontalAlignment.Left);
            lvResult.Columns.Add("Position", 87, HorizontalAlignment.Left);
            lvResult.Columns.Add("Length", 98, HorizontalAlignment.Left);

            foreach (int c in ag)
            {
                if (c > 0)
                {
                    lvResult.Columns.Add("Group " + c.ToString(), 100, HorizontalAlignment.Left);
                }
            }

            lvResult.Items.Clear();

            // Setup RichTextBox
            rtbText.HideSelection = true;
            rtbText.SelectAll();
            rtbText.SelectionColor = Color.Black;

            // Match!
            foreach (Match m in mc)
            {
                ListViewItem lvi = lvResult.Items.Add(m.ToString());

                lvi.SubItems.Add(m.Index.ToString());
                lvi.SubItems.Add(m.Length.ToString());

                for (int c = 1; c < m.Groups.Count; c++)
                {
                    lvi.SubItems.Add(m.Groups[c].Value);
                }

                rtbText.Select(m.Index, m.Length);
                rtbText.SelectionColor = Color.Red;
            }

            // Reset RichTextBox
            rtbText.Select(0, 0);
            rtbText.SelectionColor = Color.Black;

            // Show matching count
            sbpMatchCount.Text = "Match count: " + mc.Count.ToString();
        }
Beispiel #58
0
        /// <summary>
        /// 
        /// </summary>
        private void updateTagsListView(ListView tagsListView, TagFilesDatabase database, TagsCombinaton tagsCombination, string searchTagText)
        {
            //for (int i = 0; i < 5; i++)
            //{
            //    tagsListView1.Groups.Add("key_"+i.ToString(), "name_" + i.ToString());
            //}
            //tagsListView.BeginUpdate();
            //tagsListView.Clear();
            //for (int i = 0; i < 100; i++)
            //{
            //    ListViewItem item = new ListViewItem();
            //    item.Text = "T".PadLeft(12, 'a');
            //    item.ImageIndex = i % 2;
            //    item.Group = tagsListView1.Groups[i % 5];
            //    item.Tag = new object();
            //    this.tagsListView1.Items.Add(item);
            //}
            //tagsListView.EndUpdate();
            //return;

            this.setTagsListViewObject();

            this.tagsListView1.UpdateItems(database, tagsCombination, searchTagText);

            // Create the groups list. (Skip the default group - index 0)
            tagsListView.Groups.Clear();
            for (int i = 1; i < database.groupsNames.Count; i++)
            {
                string groupName = database.groupsNames[i];
                string groupKey = database.groupsKeys[i];
                tagsListView.Groups.Add(groupKey, groupName);
            }
            // Add the default group (with index 0) as the last group
            tagsListView.Groups.Add(database.groupsKeys[0], database.groupsNames[0]);

            // Create item for the listView:
            List<ListViewItem> tagsList = new List<ListViewItem>();
            ListViewItem tagItem;
            // Add each tag from the database
            for (int i = 0; i < database.Tags.Count; i++)
            {
                // Extract the tag
                FileTag tag = database.Tags[i];

                // Show the tag only if it's not in the history of tags being selected - 
                // (You should not show tag 'X' after selecting tag 'X')
                bool showTagCondition;
                showTagCondition =                   
                    !tagsCombination.ContainsByValue(tag, false) && 
                    tag.Value.ToLower().Contains(searchTagText.ToLower());
                if (showTagCondition)
                {
                    // Set the tag item (including text of the tag with the tag's file-count
                    tagItem = new ListViewItem();
                    tagItem.Text = (tag.Value == "" ? noTagsString : tag.ToString()) +
                        "\n  [" + database.CountFilesByTag(tag).ToString() + "]";
                    tagItem.Tag = tag;

                    // Set image of the tag: special image if the tag's file-count is equals the
                    // database file-count. a regular folder image if not.
                    if (database.Files.Count == database.CountFilesByTag(tag))
                        tagItem.ImageIndex = 1;
                    else
                        tagItem.ImageIndex = 0;

                    // Map the tag to it's group
                    int groupKeyIndex = database.tagGroupMapping[i];
                    string groupKey = database.groupsKeys[groupKeyIndex];
                    tagItem.Group = tagsListView.Groups[groupKey];
                    tagsList.Add(tagItem);
                }
            }

            // ** Sort the tags by groups, and inside of each group
            ListViewItem tmp = new ListViewItem();
            for (int i = 0; i < tagsList.Count; i++)
            {
                for (int j = i + 1; j < tagsList.Count; j++)
                {
                    int comperator = tagsList[i].Group.Name.CompareTo(tagsList[j].Group.Name);
                    if (comperator == 1) // item[i].Group > item[j].Group
                    { // Swap items
                        tmp = (ListViewItem)tagsList[i].Clone();
                        tagsList[i] = (ListViewItem)tagsList[j].Clone();
                        tagsList[j] = tmp;
                    }
                    else if (comperator == 0) // Equal groups
                    { // Sort internally

                        comperator = ((FileTag)tagsList[i].Tag).ToString().CompareTo(
                            ((FileTag)tagsList[j].Tag).ToString());

                        if (comperator == 1)
                        {
                            tmp = (ListViewItem)tagsList[i].Clone();
                            tagsList[i] = (ListViewItem)tagsList[j].Clone();
                            tagsList[j] = tmp;
                        }
                    }
                }
            }


            // ** Add to list view
            tagsListView.BeginUpdate();
            tagsListView.Clear();
            foreach (ListViewItem item in tagsList)
                tagsListView.Items.Add(item);
            
            tagsListView.EndUpdate();
        }