コード例 #1
0
ファイル: frmArchiveConf.cs プロジェクト: cucacutexice/AIGA
        // TODO: Investigate columns sorting feature

        //        #region sorting feature stolen from MSDN docs example (verbatim cut&paste)
        //        // so, umm, that's like (c) Microsoft 2000 (2002? '04? <shrug>) ... (thanks!)  :-)
        //        // ColumnClick event handler.
        //        private void ColumnClick(object o, ColumnClickEventArgs e)
        //        {
        //            // Set the ListViewItemSorter property to a new ListViewItemComparer
        //            // object. Setting this property immediately sorts the
        //            // ListView using the ListViewItemComparer object.
        //            this.lvwStreams.ListViewItemSorter = new ListViewItemComparer(e.Column);
        //        }
        //
        //        // Implements the manual sorting of items by columns.
        //        class ListViewItemComparer : IComparer
        //        {
        //            private int col;
        //            public ListViewItemComparer()
        //            {
        //                col = 0;
        //            }
        //            public ListViewItemComparer(int column)
        //            {
        //                col = column;
        //            }
        //            public int Compare(object x, object y)
        //            {
        //                return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
        //            }
        //        }
        //        #endregion

        /// <summary>
        /// Populate the conferences in the list view lvwConferences
        /// </summary>
        private void PopulateConferences()
        {
            try
            {
                conferences = archiver.GetConferences();

                if (conferences.Length > 0)
                {
                    lvwConferences.Enabled = true;

                    for (int i = 0; i < conferences.Length; i++)
                    {
                        TimeSpan duration          = conferences[i].End - conferences[i].Start;
                        string   formattedDuration = duration.Hours.ToString("00") + ":" + duration.Minutes.ToString("00") + ":" + duration.Seconds.ToString("00");

                        // Add conferences to the list view
                        // TODO: Uses something like Enum.GetNames(ColumnsLvwConferences).Length instead of hardcoded value 5
                        string[] cols = new string[5];

                        cols[(int)ColumnsLvwConferences.Name]         = conferences[i].Description;
                        cols[(int)ColumnsLvwConferences.Date]         = conferences[i].Start.ToShortDateString();
                        cols[(int)ColumnsLvwConferences.Time]         = conferences[i].Start.ToLongTimeString();
                        cols[(int)ColumnsLvwConferences.Duration]     = formattedDuration;
                        cols[(int)ColumnsLvwConferences.ConferenceID] = conferences[i].ConferenceID.ToString();
                        ListViewItem conferenceItem = new ListViewItem(cols);
                        // TODO: use the LVI.Tag feature and remove the private variable 'conferences'
                        conferenceItem.Tag = conferences[i];
                        lvwConferences.Items.Add(conferenceItem);
                    }
                }
                else
                {
                    lvwConferences.Enabled = false;
                }
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                MessageBox.Show(this,
                                "The Archive Service did not respond. Make sure the Archive Service you \n" +
                                "specified in ConferenceXP is correct and that server is online. \n" +
                                "For further assistance, contact your server's administrator. \n" +
                                "\nException Message: " + ex.Message,
                                "Archive Service Unavailable", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this,
                                "The Archive Service is currently unavailable or may have encountered an \n" +
                                "unexpected error. For further assistance contact your server's administrator. \n" +
                                "\nException:\n" + ex.ToString(), "Archive Service Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
コード例 #2
0
        /// <summary>
        /// Populate the conferences in the list view lvwConferences
        /// </summary>
        private void PopulateConferences()
        {
            try
            {
                conferences = archiver.GetConferences();

                if (conferences.Length > 0)
                {
                    lvwConferences.Enabled = true;

                    for (int i = 0; i < conferences.Length; i++)
                    {
                        TimeSpan duration          = conferences[i].End - conferences[i].Start;
                        string   formattedDuration = duration.Hours.ToString("00", CultureInfo.InvariantCulture) +
                                                     ":" + duration.Minutes.ToString("00", CultureInfo.InvariantCulture) + ":" +
                                                     duration.Seconds.ToString("00", CultureInfo.InvariantCulture);

                        // Add conferences to the list view
                        // TODO: Uses something like Enum.GetNames(ColumnsLvwConferences).Length instead of hardcoded value 5
                        string[] cols = new string[5];

                        cols[(int)ColumnsLvwConferences.Name]         = conferences[i].Description;
                        cols[(int)ColumnsLvwConferences.Date]         = conferences[i].Start.ToShortDateString();
                        cols[(int)ColumnsLvwConferences.Time]         = conferences[i].Start.ToLongTimeString();
                        cols[(int)ColumnsLvwConferences.Duration]     = formattedDuration;
                        cols[(int)ColumnsLvwConferences.ConferenceID] = conferences[i].ConferenceID.ToString(CultureInfo.InvariantCulture);
                        ListViewItem conferenceItem = new ListViewItem(cols);
                        // TODO: use the LVI.Tag feature and remove the private variable 'conferences'
                        conferenceItem.Tag = conferences[i];
                        lvwConferences.Items.Add(conferenceItem);
                    }
                }
                else
                {
                    lvwConferences.Enabled = false;
                }
            }
            catch (System.Net.Sockets.SocketException ex)
            {
                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture,
                                                            Strings.ArchiveServiceUnavailableText, ex.Message), Strings.ArchiveServiceUnavailableTitle,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                        (MessageBoxOptions)0);
                this.Close();
            }
            catch (Exception ex)
            {
                RtlAwareMessageBox.Show(this, string.Format(CultureInfo.CurrentCulture,
                                                            Strings.ArchiveServiceErrorText, ex.ToString()), Strings.ArchiveServiceErrorTitle,
                                        MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                                        (MessageBoxOptions)0);
                this.Close();
            }
        }