AutoResizeColumns() public method

public AutoResizeColumns ( ColumnHeaderAutoResizeStyle headerAutoResize ) : void
headerAutoResize ColumnHeaderAutoResizeStyle
return void
Example #1
0
        public void RefreshGUI()
        {
            List <Log> logData = new List <Log>();

            LogManager.GetInstance().GetAllLog(pid, ref logData);

            listLog.Items.Clear();

            foreach (Log log in logData)
            {
                ListViewItem listLogItem = new ListViewItem();
                listLogItem.Text = log.user_id.ToString();
                listLogItem.SubItems.Add(log.date.ToString());
                listLogItem.SubItems.Add(log.comment);
                listLogItem.SubItems.Add(log.cash.ToString("C", CultureInfo.CurrentCulture));

                listLog.Items.Add(listLogItem);
            }

            if (listLog.Items.Count == 0)
            {
                listLog.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            else
            {
                listLog.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            }
        }
Example #2
0
        public static void populateTasksFromCategory(System.Windows.Forms.ListView f_categoryTasks, int f_categoryId)
        {
            f_categoryTasks.Items.Clear();

            //try to open the database
            DBConnect con; //connection to the db

            con = new DBConnect("localhost", "plutodb", "root", "");
            //try to open the connection to db
            if (con.OpenConnection() == true)
            {
                //create command
                MySqlCommand cmd = con.connection.CreateCommand();
                cmd.CommandText = "SELECT * FROM tasks WHERE users_id_user = ?id_user AND categories_id_category =?category_id";
                cmd.Parameters.AddWithValue("?id_user", Login.user_class.getUserId().ToString());
                cmd.Parameters.AddWithValue("?category_id", f_categoryId);

                //Create a data reader and execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        string taskNameDB = dataReader["task_name"].ToString();
                        string deadlineDB = dataReader["deadline"].ToString();
                        bool   doneDB     = Convert.ToBoolean(dataReader["done"]);

                        f_categoryTasks.View = View.Details; // Enables Details view so you can see columns
                        ListViewItem item = new ListViewItem();

                        item.SubItems.Add(taskNameDB);
                        item.SubItems.Add("location unknown");
                        item.SubItems.Add(deadlineDB);
                        if (doneDB == true)
                        {
                            item.SubItems.Add("done");
                            item.ImageIndex = 1;
                        }
                        else
                        {
                            item.SubItems.Add("undone");
                            item.ImageIndex = 0;
                        }



                        f_categoryTasks.Items.Add(item);
                    }
                }
            }
            con.CloseConnection();

            f_categoryTasks.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            f_categoryTasks.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Example #3
0
        public static void populateTaskList(System.Windows.Forms.ListView f_todayTasks, System.Windows.Forms.Label f_today)
        {
            f_todayTasks.Items.Clear();

            //reset the label with Today
            f_today.Text = "Today";

            //try to open the database
            DBConnect con; //connection to the db

            con = new DBConnect("localhost", "plutodb", "root", "");
            //try to open the connection to db
            if (con.OpenConnection() == true)
            {
                //create command
                MySqlCommand cmd = con.connection.CreateCommand();
                cmd.CommandText = "SELECT * FROM tasks WHERE users_id_user = ?id_user AND done=0";
                cmd.Parameters.AddWithValue("?id_user", Login.user_class.getUserId().ToString());

                //Create a data reader and execute the command
                MySqlDataReader dataReader = cmd.ExecuteReader();
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        //verify if the task is from today
                        if (DateTime.Parse(dataReader["deadline"].ToString()).Date == DateTime.Now.Date)
                        {
                            string descriptionDB = dataReader["task_name"].ToString();
                            string deadlineDB    = dataReader["deadline"].ToString();
                            f_todayTasks.View = View.Details; // Enables Details view so you can see columns

                            ListViewItem item = new ListViewItem();

                            item.SubItems.Add(descriptionDB);
                            item.SubItems.Add("location unknown");
                            item.SubItems.Add(deadlineDB);
                            item.SubItems.Add("undone");
                            item.ImageIndex = 0;

                            f_todayTasks.Items.Add(item);
                        }
                    }
                }
            }
            f_todayTasks.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            f_todayTasks.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            con.CloseConnection();
        }
 public static void FillActiveUserFilesListViewDetailView(IList<ActiveUserFile> activeUserFiles, ListView target)
 {
     FillActiveUserFilesListView(activeUserFiles, target);
     target.View = View.Details;
     target.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     target.Columns[target.Columns.Count - 1].Width = -2;
 }
Example #5
0
        private void UpdateView()
        {
            if (mFileName == null)
            {
                return;
            }

            listView1.Items.Clear();
            listView1.SmallImageList = null;
            listView1.SelectedIndices.Clear();
            ImageList myImageList = new ImageList();

            for (int i = 0; i < myIcons.Length; ++i)
            {
                ListViewItem lvi = new ListViewItem(i.ToString() + ": " + myIcons[i].Description, i);

                if (muSmallIcons.Checked)
                {
                    myImageList.Images.Add(i.ToString(), myIcons[i].SmallBitmap);
                }
                else
                {
                    myImageList.Images.Add(i.ToString(), myIcons[i].Bitmap);
                }

                listView1.Items.Add(lvi);
            }
            listView1.SmallImageList = myImageList;
            listView1.SelectedIndices.Add(0);

            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            listView1.Refresh();
            UpdateThumbnail();
        }
        private void InitListView()
        {
            //初始化图标
            ImageList imageList = new ImageList();

            imageList.Images.Add((System.Drawing.Image)(Resources.Display));
            imageList.Images.Add((System.Drawing.Image)(Resources.All));
            imageList.Images.Add((System.Drawing.Image)(Resources.Fatal));
            imageList.Images.Add((System.Drawing.Image)(Resources.Error));
            imageList.Images.Add((System.Drawing.Image)(Resources.Warning));
            imageList.Images.Add((System.Drawing.Image)(Resources.Debug));
            imageList.Images.Add((System.Drawing.Image)(Resources.Info));

            ControlSafeOPeration.CtrlSafeOperation.InvokeSafeOperation(m_ListView, new Action(() =>
            {
                m_ListView.View = View.Details;
                m_ListView.Columns.Clear();
                //Add new Columns
                m_ListView.Columns.Add("Time", (m_ListView.Width - 20) / 3, System.Windows.Forms.HorizontalAlignment.Center);
                m_ListView.Columns.Add("Level", (m_ListView.Width - 20) / 3, System.Windows.Forms.HorizontalAlignment.Center);
                m_ListView.Columns.Add("Info", (m_ListView.Width - 50) / 3, System.Windows.Forms.HorizontalAlignment.Left);

                m_ListView.AutoResizeColumns(System.Windows.Forms.ColumnHeaderAutoResizeStyle.HeaderSize);//自动适应列头宽度
                m_ListView.SmallImageList = imageList;
            }));
        }
            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);
            }
 void doSort(ListView lv)
 {
     lv.Sort();
     if (lv.Items.Count > 0)
         lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     if (lv.SelectedItems.Count > 0)
         lv.EnsureVisible(lv.SelectedIndices[0]);
 }
Example #9
0
 public static void ListViewColumnResize(ListView lstview)
 {
     int[] ColumnWidth = new int[lstview.Columns.Count];
     lstview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     for (int i = 0; i < lstview.Columns.Count; i++)
     {
         ColumnWidth[i] = lstview.Columns[i].Width;
     }
     lstview.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     for (int i = 0; i < lstview.Columns.Count; i++)
     {
         ColumnWidth[i] = Math.Max(lstview.Columns[i].Width, ColumnWidth[i]);
     }
     for (int i = 0; i < lstview.Columns.Count; i++)
     {
         lstview.Columns[i].Width = ColumnWidth[i];
     }
 }
Example #10
0
        protected virtual void UpdateMessageList()
        {
            // display summary of each error in the listview
            MessageList.Items.Clear();
            foreach (IErrorMessage m in Services.ServiceManager.ErrorHandler.ErrorList)
            {
                m.ItemIndex = MessageList.Items.Add(m.Source).Index;                    // add item and record its index
                int n = MessageList.Items.Count - 1;
                MessageList.Items[n].SubItems.Add(m.Text);
            }
            if (MessageList.Items.Count > 0)
            {
//				MessageList.Columns[0].Width = -1;		// size to longest string
//				MessageList.Columns[1].Width = -2;		// autosize
                MessageList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                MessageList.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
        }
 public Results(ListView lv, String[] headers)
 {
     this.listView = lv;
     foreach (String header in headers)
         listView.Columns.Add(new ColumnHeader() {
             Text = header,
             TextAlign = HorizontalAlignment.Left });
     listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
        public static void AutoResizePage(ListView lv, int containerWidth)
        {

            if (lv == null || lv.Columns == null || lv.Columns.Count < 2)
            {
                return;
            }

            int numColumns = lv.Columns.Count;

            int minColumnWidth = (containerWidth / numColumns) / 2;

            int widthExpansion = containerWidth;

            int columnMargin = 10;


            lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);


            for (int i = 1; i < numColumns; i++)
            {
                widthExpansion -= lv.Columns[i].Width;
            }

            if (widthExpansion <= 0)
            {
                return;
            }

            for (int i = 1; i < numColumns; i++)
            {
                int requestedIncrease = 0;

                if (lv.Columns[i].Width + columnMargin < minColumnWidth)
                {
                    requestedIncrease = minColumnWidth - lv.Columns[i].Width;
                }
                else
                {
                    requestedIncrease = columnMargin;
                }

                if (requestedIncrease > 0)
                {
                    if (requestedIncrease > widthExpansion)
                    {
                        requestedIncrease = widthExpansion;
                    }

                    lv.Columns[i].Width += requestedIncrease;
                    widthExpansion -= requestedIncrease;
                }
            }
        }
Example #13
0
 private static void AutoResizeColumns(ListView lv)
 {
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     ListView.ColumnHeaderCollection cc = lv.Columns;
     for (int i = 0; i < cc.Count; i++) {
         int colWidth = TextRenderer.MeasureText(cc[i].Text, lv.Font).Width + 10;
         if (colWidth > cc[i].Width) {
             cc[i].Width = colWidth;
         }
     }
 }
Example #14
0
        private void Update(ListView list)
        {
            list.BeginUpdate();
            list.Items.Clear();
            if (_targetNode != null)
            {
                foreach (RSARFileNode file in _targetNode.Files)
                {
                    list.Items.Add(new SoundPackItem(file));
                }
            }

            list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            list.EndUpdate();
        }
Example #15
0
        private void NodeChanged()
        {
            lstSets.BeginUpdate();

            lstSets.Items.Clear();
            if (_targetNode != null)
            {
                foreach (RSARFileNode file in _targetNode.Files)
                {
                    lstSets.Items.Add(new SoundPackItem(file));
                }
            }

            lstSets.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            lstSets.EndUpdate();
        }
    private void ButtonSearch_Click(object sender, System.EventArgs e)
    {
        Cursor.Current = Cursors.WaitCursor;

        ToolStripLabel.Text = "Projekt(e) werden gesucht...";

        ListViewResult.BeginUpdate();

        GetProjects();

        ListViewResult.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

        ListViewResult.EndUpdate();

        Cursor.Current = Cursors.Default;

        return;
    }
Example #17
0
        public static void LVLoad(System.Windows.Forms.ListView LV,
                                  System.Data.Odbc.OdbcDataReader reader,
                                  bool bUpdateHeaders)
        {
            int    i = 0, nFields = 0, nRows = 0;
            string s;

            try
            {
                LV.BeginUpdate();
                LV.Sorting = SortOrder.None;
                LV.Items.Clear();

                if (bUpdateHeaders == true)
                {
                    LV.Columns.Clear();
                    nFields = reader.FieldCount;
                    for (i = 0; i < nFields; i++)
                    {
                        LV.Columns.Add(reader.GetName(i));
                    }
                }

                nRows = 0;
                while (reader.Read())
                {
                    s = reader.GetValue(0).ToString();
                    LV.Items.Add(s);

                    for (i = 1; i < nFields; i++)
                    {
                        s = reader.GetValue(i).ToString();
                        LV.Items[nRows].SubItems.Add(s);
                    }
                    nRows += 1;
                }

                LV.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                LV.EndUpdate();
            }catch (Exception ex) { MessageBox.Show(ex.Message); }
            finally
            {
            }
        }
    private void btnSearch_Click(object sender, System.EventArgs e)
    {
        Cursor.Current = Cursors.WaitCursor;

        lbl.Text = "Project (s) are searched...";

        liviResult.BeginUpdate();

        GetProjects();

        liviResult.AutoResizeColumns(
            ColumnHeaderAutoResizeStyle.ColumnContent);

        liviResult.EndUpdate();

        Cursor.Current = Cursors.Default;

        return;
    }
Example #19
0
        private void UpdateView()
        {
            if (mFileName == null)
            {
                return;
            }

            if (listView1.Items.Count == 0)
            {
                ImageList myImageList = new ImageList();
                for (int i = 0; i < myIcons.Length; ++i)
                {
                    ListViewItem lvi = new ListViewItem(myIcons[i].Description, i);
                    lvi.SubItems.Add(myIcons[i].HelpText);
                    lvi.SubItems.Add(myIcons[i].Description_2);
                    lvi.SubItems.Add(myIcons[i].HelpText_2);

                    myImageList.Images.Add(i.ToString(), myIcons[i].Bitmap);

                    listView1.Items.Add(lvi);
                }
                listView1.SmallImageList = myImageList;
                listView1.SelectedIndices.Add(0);
            }
            else
            {
                for (int i = 0; i < myIcons.Length; ++i)
                {
                    listView1.Items[i].Text             = myIcons[i].Description;
                    listView1.SmallImageList.Images[i]  = myIcons[i].Bitmap;
                    listView1.Items[i].SubItems[1].Text = myIcons[i].HelpText;
                    listView1.Items[i].SubItems[2].Text = myIcons[i].Description_2;
                    listView1.Items[i].SubItems[3].Text = myIcons[i].HelpText_2;
                }
            }

            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

            listView1.Refresh();
            UpdateThumbnail();
        }
        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);
            }
        }
Example #21
0
        private void SetupColumns(ListView ListView, String[] Headers)
        {
            ListView.Columns.Clear();
            foreach (var Header in Headers)
            {
                AddColumn(ListView, Header);
            }

            ListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            ListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Example #22
0
 //Populates a list view.
 private void PopulateListView(ListView lv, int productID)
 {
     vendorSourceList = _vendorSourceManager.GetVendorSourceItemsByProduct(productID);
     lv.Items.Clear();
     lv.Columns.Clear();
     foreach (var vendorSource in vendorSourceList)
     {
         var item = new ListViewItem();
         item.Text = vendorSource.Name;
         item.SubItems.Add(String.Format("{0:C}", vendorSource.UnitCost));
         item.SubItems.Add(vendorSource.MinQtyToOrder.ToString());
         item.SubItems.Add(vendorSource.ItemsPerCase.ToString());
         lv.Items.Add(item);
     }
     lv.Columns.Add("Vendor Name");
     lv.Columns.Add("Unit Cost");
     lv.Columns.Add("Min Order Qty");
     lv.Columns.Add("Case Qty");
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
        private void Init(CurveCanvas curveCanvas)
        {
            var lockorgValues = (int[])Enum.GetValues(typeof(OriginLockMode));
            var tanTypeValues = (int[])Enum.GetValues(typeof(CurveTangentTypes));
            var loopValues = (int[])Enum.GetValues(typeof(CurveLoopTypes));
            splitContainer1 = new SplitContainer();
            m_curvesListView = new ListView();

            m_curveControl = curveCanvas;

            m_menu = new MenuStrip();
            m_tangentsMenuItem = new ToolStripMenuItem();
            m_InTangentMenuItem = new ToolStripMenuItem();
            m_outTangentMenuItem = new ToolStripMenuItem();
            m_topStrip = new ToolStrip();
            m_PointLabel = new ToolStripLabel();
            m_xTxtBox = new ToolStripTextBox();
            m_yTxtBox = new ToolStripTextBox();
            m_bottomStrip = new ToolStrip();
            m_MousePos = new ToolStripLabel();
            m_helpForm = new HelpForm();
            m_TangentsSep1 = new ToolStripSeparator();
            m_editModeButtons = new ToolStripButton[4];
            for (int i = 0; i < m_editModeButtons.Length; i++)
            {
                m_editModeButtons[i] = new ToolStripButton();
            }

            m_tangentBtns = new ToolStripButton[5];
            for (int i = 0; i < m_tangentBtns.Length; i++)
            {
                m_tangentBtns[i] = new ToolStripButton();
            }

            m_infinityBtns = new ToolStripButton[4];
            for (int i = 0; i < m_infinityBtns.Length; i++)
            {
                m_infinityBtns[i] = new ToolStripButton();
            }

            // help menu items
            m_helpMenuItem = new ToolStripMenuItem();
            var quickHelpMenuItem = new ToolStripMenuItem();


            m_fitBtn = new ToolStripButton();
            m_breakTangent = new ToolStripButton();
            m_unifyTangent = new ToolStripButton();
            var snapToX = new ToolStripButton();
            var snapToY = new ToolStripButton();
            var snapToPoint = new ToolStripButton();
            var snapToCurve = new ToolStripButton();

            m_undoBtn = new ToolStripButton();
            m_redoBtn = new ToolStripButton();
            //m_cutBtn = new ToolStripButton();
            //m_copyBtn = new ToolStripButton();
            //m_pasteBtn = new ToolStripButton();
            m_delBtn = new ToolStripButton();

            // suspendlayouts            
            splitContainer1.Panel1.SuspendLayout();
            splitContainer1.Panel2.SuspendLayout();
            splitContainer1.SuspendLayout();
            SuspendLayout();


            m_preInfinityMenuItem = new ToolStripMenuItem();
            m_preInfinityMenuItem.Name = "PreInfinity";
            m_preInfinityMenuItem.Text = "Pre-Infinity".Localize();
            foreach (int val in loopValues)
            {
                string name = Enum.GetName(typeof(CurveLoopTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "PreInfinity" + name;
                item.Text = name;
                item.Tag = (CurveLoopTypes)val;
                item.Click += curveLoopMenu_Click;
                m_preInfinityMenuItem.DropDownItems.Add(item);
            }

            m_postInfinityMenuItem = new ToolStripMenuItem();
            m_postInfinityMenuItem.Name = "PostInfinity";
            m_postInfinityMenuItem.Text = "Post-Infinity".Localize();
            foreach (int val in loopValues)
            {
                string name = Enum.GetName(typeof(CurveLoopTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "PostInfinity" + name;
                item.Text = name;
                item.Tag = (CurveLoopTypes)val;
                item.Click += curveLoopMenu_Click;
                m_postInfinityMenuItem.DropDownItems.Add(item);
            }

            m_curveMenuItem = new ToolStripMenuItem();
            m_curveMenuItem.DropDownItems.AddRange(new ToolStripItem[] { m_preInfinityMenuItem, m_postInfinityMenuItem });
            m_curveMenuItem.Name = "Curve";
            m_curveMenuItem.Text = "Curve".Localize();

            var editMenuItem = new ToolStripMenuItem("Edit".Localize());
            editMenuItem.DropDown = m_curveControl.ContextMenuStrip;
           
            m_menu.Location = new Point(0, 0);
            m_menu.Name = "m_menu";
            m_menu.RenderMode = ToolStripRenderMode.System;
            m_menu.Size = new Size(898, 31);
            m_menu.TabIndex = 0;
            m_menu.Text = "menuStrip1";
            m_menu.Renderer = new CustomToolStripRenderer();

            foreach (int val in tanTypeValues)
            {
                var tanType = (CurveTangentTypes)val;
                if (!IsImplemented(tanType))
                    continue;
                string name = Enum.GetName(typeof(CurveTangentTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = name;
                item.Text = name;
                item.Tag = tanType;
                item.Click += TanMenuItem_Click;
                m_tangentsMenuItem.DropDownItems.Add(item);
            }

            m_tangentsMenuItem.DropDownItems.AddRange(new ToolStripItem[] {                        
            m_TangentsSep1,
            m_InTangentMenuItem,
            m_outTangentMenuItem});
            m_tangentsMenuItem.Name = "m_tangentsMenuItem";
            m_tangentsMenuItem.Size = new Size(100, 27);
            m_tangentsMenuItem.Text = "Tangents".Localize();

            foreach (int val in tanTypeValues)
            {
                var tanType = (CurveTangentTypes)val;
                if (!IsImplemented(tanType) || tanType == CurveTangentTypes.Stepped
                    || tanType == CurveTangentTypes.SteppedNext)
                    continue;

                string name = Enum.GetName(typeof(CurveTangentTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "InTan" + name;
                item.Text = name;
                item.Tag = tanType;
                item.Click += TanMenuItem_Click;
                m_InTangentMenuItem.DropDownItems.Add(item);
            }
            m_InTangentMenuItem.Name = "m_InTangentMenuItem";
            m_InTangentMenuItem.Size = new Size(205, 28);
            m_InTangentMenuItem.Text = "In Tangent".Localize();

            foreach (int val in tanTypeValues)
            {
                var tanType = (CurveTangentTypes)val;
                if (!IsImplemented(tanType) || tanType == CurveTangentTypes.Stepped
                    || tanType == CurveTangentTypes.SteppedNext)
                    continue;

                string name = Enum.GetName(typeof(CurveTangentTypes), val);
                var item = new ToolStripMenuItem();
                item.Name = "OutTan" + name;
                item.Text = name;
                item.Tag = tanType;
                item.Click += TanMenuItem_Click;
                m_outTangentMenuItem.DropDownItems.Add(item);
            }
            m_outTangentMenuItem.Name = "m_outTangentMenuItem";
            m_outTangentMenuItem.Size = new Size(205, 28);
            m_outTangentMenuItem.Text = "Out Tangent".Localize();

            m_helpMenuItem.Name = "helpMenuItem";
            m_helpMenuItem.Text = "Help".Localize();
            m_helpMenuItem.DropDownItems.Add(quickHelpMenuItem);

            quickHelpMenuItem.Name = "quickHelpMenuItem";
            quickHelpMenuItem.Text = "Quick Help...".Localize();
            quickHelpMenuItem.Click += delegate
            {
                if (m_helpForm.Visible)
                {
                    m_helpForm.Activate();
                    return;
                }
                m_helpForm.Show(this);
            };

            m_optionsMenu = new ToolStripMenuItem("Options".Localize());
            var inputmodeMenu = new ToolStripMenuItem("Input Mode".Localize());
            m_basicMenuItem = new ToolStripMenuItem("Basic".Localize());
            m_basicMenuItem.Name = "basic";
            m_basicMenuItem.Click += delegate
            {
                InputMode = InputModes.Basic;

            };
            m_advancedInputMenuItem = new ToolStripMenuItem("Advanced".Localize());
            m_advancedInputMenuItem.Click += delegate
            {
                InputMode = InputModes.Advanced;
            };
            InputMode = m_curveControl.InputMode;

            m_flipYMenuItem = new ToolStripMenuItem("Flip Y-Axis".Localize());
            m_flipYMenuItem.Click += delegate
            {
                FlipY = !FlipY;
            };

            m_optionsMenu.DropDownOpening += delegate { m_flipYMenuItem.Checked = FlipY; };
                       
            inputmodeMenu.DropDownItems.Add(m_basicMenuItem);
            inputmodeMenu.DropDownItems.Add(m_advancedInputMenuItem);

            var lockmenu = new ToolStripMenuItem("Lock Origin".Localize(
                "This is the name of a command. Lock is a verb. Origin is like the origin of a graph."));
            foreach (int val in lockorgValues)
            {
                string name = Enum.GetName(typeof(OriginLockMode), val);
                var item = new ToolStripMenuItem();
                item.Name = name;
                item.Text = name;
                item.Tag = (OriginLockMode)val;
                item.Click += delegate(object sender, EventArgs e)
                {
                    var menuItem = (ToolStripMenuItem)sender;
                    m_curveControl.LockOrigin = (OriginLockMode)menuItem.Tag;
                };
                lockmenu.DropDownItems.Add(item);
            }
            lockmenu.DropDownOpening += delegate
            {
                foreach (ToolStripMenuItem mitem in lockmenu.DropDownItems)
                {
                    mitem.Checked = m_curveControl.LockOrigin == (OriginLockMode)mitem.Tag;
                }
            };

            m_optionsMenu.DropDownItems.Add(inputmodeMenu);
            m_optionsMenu.DropDownItems.Add(lockmenu);
            m_optionsMenu.DropDownItems.Add(m_flipYMenuItem);
                        
            // Initialize CurveTypeSelector (with items and labels)
            m_curveTypeLabel = new ToolStripLabel();
            m_curveTypeLabel.Name = "CurveTypeLabel";
            m_curveTypeLabel.AutoSize = true;
            m_curveTypeLabel.Text = "Type".Localize("curve types");
            m_curveTypeSelector = new ToolStripDropDownButton();
            m_curveTypeSelector.Name = "CurveTypeSelector";
            m_curveTypeSelector.AutoSize = false;
            m_curveTypeSelector.Width = 70;
            m_curveTypeSelector.ToolTipText = "Type of Selected Curve(s)".Localize();
            m_curveTypeSelector.DisplayStyle = ToolStripItemDisplayStyle.Text;
            var linearItem = new ToolStripMenuItem("Linear".Localize());
            linearItem.Tag = InterpolationTypes.Linear;
            linearItem.Name = linearItem.Text;
            var smoothItem = new ToolStripMenuItem("Smooth".Localize());
            smoothItem.Tag = InterpolationTypes.Hermite;
            smoothItem.Name = smoothItem.Text;
            smoothItem.Checked = true;
            m_curveTypeSelector.DropDownItems.Add(linearItem);
            m_curveTypeSelector.DropDownItems.Add(smoothItem);
            m_curveTypeSelector.Text = smoothItem.Text;
            m_curveTypeSelector.DropDownItemClicked += curveTypeSelector_DropDownItemClicked;

            m_menu.Items.AddRange(new ToolStripItem[] {
                editMenuItem,
                m_curveMenuItem,
            m_tangentsMenuItem,m_optionsMenu,m_helpMenuItem});

            m_topStrip.Items.AddRange(m_editModeButtons);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.AddRange(new ToolStripItem[] {                
            m_PointLabel,
            m_xTxtBox,
            m_yTxtBox,
            m_fitBtn,            
            });
            m_tanSeparator1 = new ToolStripSeparator();
            m_tanSeparator2 = new ToolStripSeparator();
            m_topStrip.Items.Add(m_tanSeparator1);
            m_topStrip.Items.Add(m_curveTypeLabel);
            m_topStrip.Items.Add(m_curveTypeSelector);
            m_topStrip.Items.AddRange(m_tangentBtns);
            m_topStrip.Items.Add(m_tanSeparator2);
            m_topStrip.Items.Add(m_breakTangent);
            m_topStrip.Items.Add(m_unifyTangent);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.Add(snapToX);
            m_topStrip.Items.Add(snapToY);
            m_topStrip.Items.Add(snapToPoint);
            m_topStrip.Items.Add(snapToCurve);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.AddRange(m_infinityBtns);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Items.Add(m_undoBtn);
            m_topStrip.Items.Add(m_redoBtn);
            //m_topStrip.Items.Add(m_cutBtn);
            //m_topStrip.Items.Add(m_copyBtn);
            //m_topStrip.Items.Add(m_pasteBtn);
            m_topStrip.Items.Add(m_delBtn);
            m_topStrip.Items.Add(new ToolStripSeparator());
            m_topStrip.Location = new Point(0, 31);
            m_topStrip.Name = "m_topStrip";
            m_topStrip.RenderMode = ToolStripRenderMode.System;
            m_topStrip.Size = new Size(898, 32);
            m_topStrip.TabIndex = 1;
            m_topStrip.Stretch = true;
            m_topStrip.Text = "topstrip";
            m_topStrip.GripStyle = ToolStripGripStyle.Hidden;
            m_topStrip.MinimumSize = new Size(32, 32);
            m_topStrip.CausesValidation = true;


            for (int i = 0; i < m_editModeButtons.Length; i++)
            {
                m_editModeButtons[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_editModeButtons[i].Click += EditModeClick;
                m_editModeButtons[i].Alignment = ToolStripItemAlignment.Left;
                m_editModeButtons[i].ImageScaling = ToolStripItemImageScaling.None;
            }

            m_editModeButtons[0].Name = "ScalePoint";
            m_editModeButtons[0].Tag = EditModes.Scale;
            m_editModeButtons[0].Image = new Bitmap(typeof(CurveUtils), "Resources.ScaleKeysTool.png");
            m_editModeButtons[0].ToolTipText = "Scale selected control points   " + KeysUtil.KeysToString(CurveCanvas.ShortcutKeys.Scale, true);

            m_editModeButtons[1].Checked = true;
            m_editModeButtons[1].Name = "MovePoint";
            m_editModeButtons[1].Tag = EditModes.Move;
            m_editModeButtons[1].Image = new Bitmap(typeof(CurveUtils), "Resources.MoveKeysTool.png");
            m_editModeButtons[1].ToolTipText = "Move selected control points   " + KeysUtil.KeysToString(CurveCanvas.ShortcutKeys.Move, true);

            m_editModeButtons[2].Name = "InsertPoint";
            m_editModeButtons[2].Tag = EditModes.InsertPoint;
            m_editModeButtons[2].Image = new Bitmap(typeof(CurveUtils), "Resources.InsertKeysTool.png");
            m_editModeButtons[2].ToolTipText = "Insert control point";

            m_editModeButtons[3].Name = "AddPoint";
            m_editModeButtons[3].Tag = EditModes.AddPoint;
            m_editModeButtons[3].Image = new Bitmap(typeof(CurveUtils), "Resources.AddKeysTool.png");
            m_editModeButtons[3].ToolTipText = "Add control point";


            m_PointLabel.Name = "m_PointLabel";
            m_PointLabel.AutoSize = true;
            m_PointLabel.Text = "Stats".Localize();

            m_xTxtBox.Name = "m_XtxtBox";
            m_xTxtBox.Size = new Size(100, 30);
            m_xTxtBox.Validating += InputBoxValidating;
            m_xTxtBox.KeyUp += m_TxtBox_KeyUp;
            m_xTxtBox.ReadOnly = true;


            m_yTxtBox.Name = "m_yTxtBox";
            m_yTxtBox.Size = new Size(100, 30);
            m_yTxtBox.Validating += InputBoxValidating;
            m_yTxtBox.KeyUp += m_TxtBox_KeyUp;
            m_yTxtBox.ReadOnly = true;


            // fit all
            m_fitBtn.Name = "m_fitBtn";
            m_fitBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_fitBtn.Alignment = ToolStripItemAlignment.Left;
            m_fitBtn.Tag = null;
            m_fitBtn.Image = new Bitmap(typeof(CurveUtils), "Resources.FrameAll.png");
            m_fitBtn.ToolTipText = "Fit " + KeysUtil.KeysToString(CurveCanvas.ShortcutKeys.Fit, true);
            m_fitBtn.Click += delegate { m_curveControl.Fit(); };
            m_fitBtn.ImageScaling = ToolStripItemImageScaling.None;
            



            // tangent buttons
            for (int i = 0; i < m_tangentBtns.Length; i++)
            {
                m_tangentBtns[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_tangentBtns[i].Alignment = ToolStripItemAlignment.Left;
                m_tangentBtns[i].Name = "m_tangentBtns" + i;
                m_tangentBtns[i].ImageScaling = ToolStripItemImageScaling.None;
                m_tangentBtns[i].Click += delegate(object sender, EventArgs e)
                {
                    var btn = sender as ToolStripButton;
                    m_curveControl.SetTangent(TangentSelection.TangentInOut, (CurveTangentTypes)btn.Tag);
                };
            }
            m_tangentBtns[0].Tag = CurveTangentTypes.Spline;
            m_tangentBtns[0].Image = new Bitmap(typeof(CurveUtils), "Resources.SplineTangents.png");
            m_tangentBtns[0].ToolTipText = "Spline";

            m_tangentBtns[1].Tag = CurveTangentTypes.Clamped;
            m_tangentBtns[1].Image = new Bitmap(typeof(CurveUtils), "Resources.ClampedTangents.png");
            m_tangentBtns[1].ToolTipText = "Clamped";

            m_tangentBtns[2].Tag = CurveTangentTypes.Linear;
            m_tangentBtns[2].Image = new Bitmap(typeof(CurveUtils), "Resources.LinearTangents.png");
            m_tangentBtns[2].ToolTipText = "Linear";

            m_tangentBtns[3].Tag = CurveTangentTypes.Flat;
            m_tangentBtns[3].Image = new Bitmap(typeof(CurveUtils), "Resources.FlatTangents.png");
            m_tangentBtns[3].ToolTipText = "Flat";

            m_tangentBtns[4].Tag = CurveTangentTypes.Stepped;
            m_tangentBtns[4].Image = new Bitmap(typeof(CurveUtils), "Resources.StepTangents.png");
            m_tangentBtns[4].ToolTipText = "Step";


            // break tangents
            m_breakTangent.Name = "m_breakTangent";
            m_breakTangent.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_breakTangent.Alignment = ToolStripItemAlignment.Left;
            m_breakTangent.Image = new Bitmap(typeof(CurveUtils), "Resources.BreakTangents.png");
            m_breakTangent.ImageScaling = ToolStripItemImageScaling.None;
            m_breakTangent.ToolTipText = "Break Tangents";
            m_breakTangent.Click += delegate { m_curveControl.BreakTangents(true); };

            m_unifyTangent.Name = "m_unifyTangent";
            m_unifyTangent.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_unifyTangent.Alignment = ToolStripItemAlignment.Left;
            m_unifyTangent.Image = new Bitmap(typeof(CurveUtils), "Resources.UnifyTangents.png");
            m_unifyTangent.ImageScaling = ToolStripItemImageScaling.None;
            m_unifyTangent.ToolTipText = "Unify Tangents";
            m_unifyTangent.Click += delegate { m_curveControl.BreakTangents(false); };


            snapToX.Checked = m_curveControl.AutoSnapToX;
            snapToX.Name = "snapToX";
            snapToX.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToX.Alignment = ToolStripItemAlignment.Left;
            snapToX.Image = new Bitmap(typeof(CurveUtils), "Resources.TimeSnap.png");
            snapToX.ImageScaling = ToolStripItemImageScaling.None;
            snapToX.ToolTipText = "Auto snap to major X tick";
            snapToX.Click += delegate
            {
                snapToX.Checked = !snapToX.Checked;
                m_curveControl.AutoSnapToX = snapToX.Checked;
            };


            snapToY.Checked = m_curveControl.AutoSnapToY;
            snapToY.Name = "snapToY";
            snapToY.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToY.Alignment = ToolStripItemAlignment.Left;
            snapToY.Image = new Bitmap(typeof(CurveUtils), "Resources.ValueSnap.png");
            snapToY.ImageScaling = ToolStripItemImageScaling.None;
            snapToY.ToolTipText = "Auto snap to major Y tick";
            snapToY.Click += delegate
            {
                snapToY.Checked = !snapToY.Checked;
                m_curveControl.AutoSnapToY = snapToY.Checked;
            };

            snapToPoint.Checked = m_curveControl.AutoPointSnap;
            snapToPoint.Name = "snapToPoint";
            snapToPoint.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToPoint.Alignment = ToolStripItemAlignment.Left;
            snapToPoint.Image = new Bitmap(typeof(CurveUtils), "Resources.PointSnap.png");
            snapToPoint.ImageScaling = ToolStripItemImageScaling.None;
            snapToPoint.ToolTipText = "Auto snap to point";
            snapToPoint.Click += delegate
            {
                snapToPoint.Checked = !snapToPoint.Checked;
                m_curveControl.AutoPointSnap = snapToPoint.Checked;
            };

            snapToCurve.Checked = m_curveControl.AutoCurveSnap;
            snapToCurve.Name = "snapToCurve";
            snapToCurve.DisplayStyle = ToolStripItemDisplayStyle.Image;
            snapToCurve.Alignment = ToolStripItemAlignment.Left;
            snapToCurve.Image = new Bitmap(typeof(CurveUtils), "Resources.CurveSnap.png");
            snapToCurve.ImageScaling = ToolStripItemImageScaling.None;
            snapToCurve.ToolTipText = "Auto snap to curve";
            snapToCurve.Click += delegate
            {
                snapToCurve.Checked = !snapToCurve.Checked;
                m_curveControl.AutoCurveSnap = snapToCurve.Checked;
            };

            for (int i = 0; i <= 1; i++)
            {
                m_infinityBtns[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_infinityBtns[i].Alignment = ToolStripItemAlignment.Left;
                m_infinityBtns[i].Name = "m_infinityBtns" + i;
                m_infinityBtns[i].ImageScaling = ToolStripItemImageScaling.None;
                m_infinityBtns[i].Click += delegate(object sender, EventArgs e)
                {
                    var btn = sender as ToolStripButton;
                    m_curveControl.SetPreInfinity((CurveLoopTypes)btn.Tag);
                };
            }

            for (int i = 2; i <= 3; i++)
            {
                m_infinityBtns[i].DisplayStyle = ToolStripItemDisplayStyle.Image;
                m_infinityBtns[i].Alignment = ToolStripItemAlignment.Left;
                m_infinityBtns[i].Name = "m_infinityBtns" + i;
                m_infinityBtns[i].ImageScaling = ToolStripItemImageScaling.None;
                m_infinityBtns[i].Click += delegate(object sender, EventArgs e)
                {
                    var btn = sender as ToolStripButton;
                    m_curveControl.SetPostInfinity((CurveLoopTypes)btn.Tag);
                };
            }


            m_infinityBtns[0].Tag = CurveLoopTypes.Cycle;
            m_infinityBtns[0].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleBefore.png");
            m_infinityBtns[0].ToolTipText = "Cycle Before";

            m_infinityBtns[1].Tag = CurveLoopTypes.CycleWithOffset;
            m_infinityBtns[1].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleBeforewithOffset.png");
            m_infinityBtns[1].ToolTipText = "Cycle Before with Offset";

            m_infinityBtns[2].Tag = CurveLoopTypes.Cycle;
            m_infinityBtns[2].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleAfter.png");
            m_infinityBtns[2].ToolTipText = "Cycle After";

            m_infinityBtns[3].Tag = CurveLoopTypes.CycleWithOffset;
            m_infinityBtns[3].Image = new Bitmap(typeof(CurveUtils), "Resources.CycleAfterwithOffset.png");
            m_infinityBtns[3].ToolTipText = "Cycle After with Offset";

            // udo/redo/cut/copy/paste/delete  buttons            
            m_undoBtn.Name = "m_undoBtn";
            m_undoBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_undoBtn.Alignment = ToolStripItemAlignment.Left;
            m_undoBtn.Image = ResourceUtil.GetImage24(Resources.UndoImage);
            m_undoBtn.ImageScaling = ToolStripItemImageScaling.None;
            m_undoBtn.ToolTipText = "Undo";
            m_undoBtn.Click += delegate { m_curveControl.Undo(); };

            m_redoBtn.Name = "m_redoBtn";
            m_redoBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_redoBtn.Alignment = ToolStripItemAlignment.Left;
            m_redoBtn.Image = ResourceUtil.GetImage24(Resources.RedoImage);
            m_redoBtn.ImageScaling = ToolStripItemImageScaling.None;
            m_redoBtn.ToolTipText = "Redo";
            m_redoBtn.Click += delegate { m_curveControl.Redo(); };

            //m_cutBtn.Name = "cutBtn";
            //m_cutBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //m_cutBtn.Alignment = ToolStripItemAlignment.Left;
            //m_cutBtn.Image = ResourceUtil.GetImage24(Resources.CutImage);
            //m_cutBtn.ImageScaling = ToolStripItemImageScaling.None;
            //m_cutBtn.ToolTipText = "Cut selected points";
            //m_cutBtn.Click += delegate { m_curveControl.Cut(); };

            //m_copyBtn.Name = "copyBtn";
            //m_copyBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //m_copyBtn.Alignment = ToolStripItemAlignment.Left;
            //m_copyBtn.Image = ResourceUtil.GetImage24(Resources.CopyImage);
            //m_copyBtn.ImageScaling = ToolStripItemImageScaling.None;
            //m_copyBtn.ToolTipText = "Copy selected points";
            //m_copyBtn.Click += delegate { m_curveControl.Copy(); };

            //m_pasteBtn.Name = "pasteBtn";
            //m_pasteBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            //m_pasteBtn.Alignment = ToolStripItemAlignment.Left;
            //m_pasteBtn.Image = ResourceUtil.GetImage24(Resources.PasteImage);
            //m_pasteBtn.ImageScaling = ToolStripItemImageScaling.None;
            //m_pasteBtn.ToolTipText = "Paste selected points";
            //m_pasteBtn.Click += delegate { m_curveControl.Paste(); };

            m_delBtn.Name = "delBtn";
            m_delBtn.DisplayStyle = ToolStripItemDisplayStyle.Image;
            m_delBtn.Alignment = ToolStripItemAlignment.Left;
            m_delBtn.Image = ResourceUtil.GetImage24(Resources.DeleteImage);
            m_delBtn.ImageScaling = ToolStripItemImageScaling.None;
            m_delBtn.ToolTipText = "Delete selected points";
            m_delBtn.Click += delegate { m_curveControl.Delete(); };

            m_bottomStrip.Dock = DockStyle.Bottom;
            m_bottomStrip.Items.AddRange(new ToolStripItem[] { m_MousePos });
            m_bottomStrip.Location = new Point(0, 549);
            m_bottomStrip.Name = "m_bottomStrip";
            m_bottomStrip.RenderMode = ToolStripRenderMode.System;
            m_bottomStrip.Size = new Size(898, 26);
            m_bottomStrip.TabIndex = 2;
            m_bottomStrip.Text = "toolStrip2";
            m_bottomStrip.GripStyle = ToolStripGripStyle.Hidden;

            m_MousePos.Alignment = ToolStripItemAlignment.Left;
            m_MousePos.AutoSize = true;
            m_MousePos.Name = "m_MousePos";
            m_MousePos.Size = new Size(250, 27);
            m_MousePos.Text = "Mouse Position".Localize();

            m_curveControl.Dock = DockStyle.Fill;
            m_curveControl.Location = new Point(24, 61);
            m_curveControl.Name = "m_curveControl";
            m_curveControl.Size = new Size(900, 600);
            m_curveControl.TabIndex = 0;
            m_curveControl.TabStop = false;
            m_curveControl.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                PointD gp = m_curveControl.ClientToGraph_d(e.X, e.Y);
                m_MousePos.Text = string.Format("{0}, {1}", Math.Round(gp.X, 4), Math.Round(gp.Y, 4));
            };
            m_curveControl.MouseLeave += delegate { m_MousePos.Text = ""; };
            m_curveControl.MouseUp += delegate { UpdateInputBoxes(); };
            m_curveControl.EditMode = EditModes.Move;
            m_curveControl.EditModeChanged += delegate
            {
                foreach (ToolStripButton btn in m_editModeButtons)
                {
                    btn.Checked = (EditModes)btn.Tag == m_curveControl.EditMode;
                }
            };
            m_curveControl.SelectionChanged += SelectionChanged;

            m_TangentsSep1.Name = "m_TangentsSep1";
            m_TangentsSep1.Size = new Size(202, 6);

            splitContainer1.Dock = DockStyle.Fill;
            splitContainer1.ForeColor = SystemColors.Control;
            splitContainer1.Location = new Point(0, 48);
            splitContainer1.Name = "splitContainer1";
            splitContainer1.Panel1MinSize = 30;
            splitContainer1.Panel2MinSize = 30;
            splitContainer1.Panel1.Controls.Add(m_curvesListView);
            splitContainer1.Panel2.Controls.Add(m_curveControl);
            splitContainer1.Size = new Size(898, 520);
            splitContainer1.SplitterDistance = 180;
            splitContainer1.SplitterIncrement = 5;
            splitContainer1.TabIndex = 0;
            splitContainer1.TabStop = false;
            splitContainer1.Text = "splitContainer1";
            splitContainer1.BorderStyle = BorderStyle.None;
            splitContainer1.SplitterWidth = 4;
            splitContainer1.FixedPanel = FixedPanel.Panel1;
            splitContainer1.SplitterMoved += splitContainer1_SplitterMoved;
            splitContainer1.SplitterMoving += splitContainer1_SplitterMoving;

            // list view                  
            m_curvesListView.CheckBoxes = true;
            m_curvesListView.Dock = DockStyle.Fill;
            m_curvesListView.HideSelection = false;
            m_curvesListView.LabelEdit = false;
            m_curvesListView.Location = new Point(0, 0);
            m_curvesListView.Name = "m_curvesListView";
            m_curvesListView.Size = new Size(300, 300);
            m_curvesListView.TabIndex = 0;
            m_curvesListView.TabStop = false;
            m_curvesListView.TileSize = new Size(250, 24);
            m_curvesListView.UseCompatibleStateImageBehavior = false;
            m_curvesListView.View = View.Details;
            m_curvesListView.Sorting = SortOrder.Ascending;
            m_curvesListView.ItemChecked += m_curvesListView_ItemChecked;            
            m_curvesListView.Scrollable = true;
            m_curvesListView.Columns.Add("Curves", 250);
            m_curvesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
            m_curvesListView.AllowColumnReorder = false;
            m_curvesListView.BackColor = m_curveControl.BackColor;

            var addMenuItem = new ToolStripMenuItem("Add Point".Localize());
            var listMenuStrip = new ContextMenuStrip();
            m_curvesListView.ContextMenuStrip = listMenuStrip;
            listMenuStrip.Opening += delegate
            {
                addMenuItem.Enabled = m_curvesListView.SelectedItems.Count > 0;
            };
            listMenuStrip.Items.Add(addMenuItem);
            addMenuItem.Click += delegate
            {
                if (m_curvesListView.SelectedItems.Count == 0)
                    return;
                var dlg = new AddPointDialog();
                dlg.Location = new Point(MousePosition.X, MousePosition.Y);
                dlg.ShowDialog(this);
                if (dlg.DialogResult != DialogResult.OK)
                    return;

                PointF pt = dlg.PointPosition;
                m_curveControl.TransactionContext.DoTransaction(delegate
                {
                    foreach (ListViewItem item in m_curvesListView.SelectedItems)
                    {
                        var curve = (ICurve)item.Tag;
                        IControlPoint cpt = curve.CreateControlPoint();
                        float x = pt.X;

                        int index = CurveUtils.GetValidInsertionIndex(curve, x);
                        while (index == -1)
                        {
                            x += CurveUtils.Epsilone;
                            index = CurveUtils.GetValidInsertionIndex(curve, x);
                        }

                        cpt.X = x;
                        cpt.Y = pt.Y;
                        curve.InsertControlPoint(index, cpt);
                        CurveUtils.ComputeTangent(curve);
                    }
                }, "Add Point".Localize());

                m_curveControl.Invalidate();
            };

            ClientSize = new Size(898, 575);
            Dock = DockStyle.Fill;
            Controls.Add(splitContainer1);
            Controls.Add(m_bottomStrip);
            Controls.Add(m_topStrip);
            Controls.Add(m_menu);

            // resume layouts.                        
            splitContainer1.Panel1.ResumeLayout(false);
            splitContainer1.Panel2.ResumeLayout(false);
            splitContainer1.ResumeLayout(false);
            ResumeLayout(false);
            PerformLayout();
            Invalidated += CurveEditorControl_Invalidated;
            SetUI(false);
            Application.Idle += Application_Idle;
        }
        /// <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)
                {
                    SystemManager.ExceptionDeal(ex);
                }
            }
            lstSvr.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
Example #25
0
 //Populates a list view.
 private void PopulateTermListView(ListView lv, List<ShippingTerm> termList)
 {
     _myTermManager.ShippingTerms = termList;
     lv.Items.Clear();
     lv.Columns.Clear();
     foreach (var term in termList)
     {
         var item = new ListViewItem();
         item.Text = term.Id.ToString();
         //item.SubItems.Add(term.ShippingVendorId.ToString());
         item.SubItems.Add(term.ShippingVendorName);
         if (term.Description.Length > 25)
         {
             item.SubItems.Add(term.Description.Substring(0, 25));
         }
         else
         {
             item.SubItems.Add(term.Description);
         }
         item.SubItems.Add(term.Active.ToString());
         lv.Items.Add(item);
     }
     lv.Columns.Add("Term ID");
     //lv.Columns.Add("Vendor ID");
     lv.Columns.Add("Vendor Name");
     lv.Columns.Add("Description");
     lv.Columns.Add("Active");
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
        private void InitialDisplay()
        {
            GetConfig(this);
            int primaryW = Screen.PrimaryScreen.Bounds.Width;
            int primaryH = Screen.PrimaryScreen.Bounds.Height;
            this.Icon = Properties.Resources._1445534907_Hat;
            this.Size = new Size(900, 600);
            int clientW = this.FormBorderStyle == FormBorderStyle.None ? this.ClientSize.Width : this.ClientSize.Width;
            int clientH = this.FormBorderStyle == FormBorderStyle.None ? this.ClientSize.Height : this.ClientSize.Height;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.BackColor = Color.LightBlue;
            this.Layout += Form1_Layout;

            noti.Icon = Properties.Resources._1445534907_Hat;
            noti.BalloonTipText = this.Text;
            noti.BalloonTipTitle = "JL";
            noti.Text = "JL_Tester";
            noti.Visible = false;
            noti.MouseUp += Noti_MouseUp;

            ///Form Size Setting///
            this.MouseClick += Form1_MouseClick;

            ///Virtical Position Numbers///
            int topH = 30;
            int gap = 5;
            int topLabelH = clientH * 15 / 100;
            int top1stPoint = topLabelH * 30 / 100;
            int top2ndPoint = (topLabelH * 70 / 100) - (gap * 2);
            int bottomLabelH = clientH * 6 / 100;
            int section = clientH * 80 / 100;
            int sec1stH = section * 50 / 100;
            int sec2ndH = section * 50 / 100 - (gap * 2);
            int sec1stPoint = topLabelH;
            int sec2ndPoint = topLabelH + sec1stH + gap;
            ///Virtical Position Numbers///

            //Top Panel
            Panel topP = new Panel();
            PictureBox topPb = new PictureBox();
            Label topPLbl = new Label();
            Button btnMin = new Button();
            Button btnExit = new Button();
            //Top Panel

            topP.Size = new Size(clientW, topH);
            if (this.FormBorderStyle != FormBorderStyle.None) topP.Height = 0;
            topP.Location = new Point(0, 0);
            topP.BorderStyle = BorderStyle.FixedSingle;
            topP.BackColor = Color.Navy;
            topP.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            topP.MouseDown += MoveForm;
            topP.Parent = this;

            topPb.Size = new Size(topH - 5, topH - 5);
            topPb.Location = new Point(2, 2);
            topPb.BorderStyle = BorderStyle.None;
            topPb.SizeMode = PictureBoxSizeMode.StretchImage;
            topPb.Image = Properties.Resources._1445562055_Hat;
            topPb.Parent = topP;

            topPLbl.Size = new Size(200, topH - 10);
            topPLbl.Location = new Point(topPb.Right, (topH - topPLbl.Height) / 2);
            topPLbl.Text = this.Text;
            topPLbl.Font = new Font("arial", 11, FontStyle.Regular);
            topPLbl.TextAlign = ContentAlignment.MiddleLeft;
            topPLbl.ForeColor = Color.White;
            topPLbl.BorderStyle = BorderStyle.None;
            topPLbl.Anchor = AnchorStyles.Left;
            topPLbl.MouseDown += MoveForm;
            topPLbl.Parent = topP;

            btnExit.Size = new Size(25, 25);
            btnExit.Location = new Point(topP.Width - btnExit.Width - 2, 2);
            btnExit.BackgroundImage = Properties.Resources._1445543925_close_red;
            btnExit.BackgroundImageLayout = ImageLayout.Stretch;
            btnExit.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            btnExit.FlatStyle = FlatStyle.Flat;
            btnExit.FlatAppearance.BorderSize = 0;
            btnExit.Name = "btnExit";
            btnExit.MouseClick += BtnExit_MouseUp;
            btnExit.Parent = topP;

            btnMin.Size = new Size(25, 25);
            btnMin.Location = new Point(btnExit.Left - btnMin.Width - 2, 2);
            btnMin.BackgroundImage = Properties.Resources._1445548524_minimize_window;
            btnMin.BackgroundImageLayout = ImageLayout.Stretch;
            btnMin.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            btnMin.FlatStyle = FlatStyle.Flat;
            btnMin.FlatAppearance.BorderSize = 0;
            btnMin.Name = "btnMin";
            btnMin.MouseClick += BtnExit_MouseUp;
            btnMin.Parent = topP;

            Label lbl2 = new Label();
            lbl2.Size = new Size(150, 18);
            lbl2.Location = new Point(gap, topP.Bottom);
            lbl2.BorderStyle = BorderStyle.None;
            Assembly assem = Assembly.GetEntryAssembly();
            AssemblyName assemName = assem.GetName();
            Version ver = assemName.Version;
            lbl2.Text = "ver." + ver.ToString();
            lbl2.Font = new Font("arial", 11, FontStyle.Regular);
            lbl2.TextAlign = ContentAlignment.MiddleLeft;
            lbl2.ForeColor = Color.Black;
            lbl2.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            lbl2.Parent = this;

            GroupBox gb = new GroupBox();
            gb.Text = "Serial Port List";
            gb.Font = new Font("arial", 14, FontStyle.Regular);
            gb.Size = new Size(200, clientH - 60);
            gb.Location = new Point(gap, lbl2.Bottom + 5);
            gb.BackColor = Color.LightBlue;
            gb.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
            gb.Name = "gb";
            this.Controls.Add(gb);

            PortList.Reverse();
            PortList.ForEach(x =>
            {
                int i = PortList.IndexOf(x) + 1;
                RadioButton port = new RadioButton();
                port.Text = i + " : " + x;
                port.Name = x;
                port.Font = new Font("arial", 14, FontStyle.Regular);
                port.CheckedChanged += Radiobutton_CheckedChanged;
                port.Size = new Size(120, 30);
                port.Location = new Point(0, 30 * i); //(-13, 30);
                port.Checked = false;
                port.FlatStyle = FlatStyle.Flat;
                port.FlatAppearance.BorderSize = 5;
                gb.Controls.Add(port);

                SerialP.Add(new SerialPort(x));
                SerialP[i - 1].ReadTimeout = 500;
                SerialP[i - 1].WriteTimeout = 500;
                SerialP[i - 1].Open();
                SerialP[i - 1].DataReceived += new SerialDataReceivedEventHandler(SerialP_DataReceived);
                i++;

                port.MouseClick += Port_MouseClick;
            });

            Label lblPort = new Label();
            lblPort.Size = new Size(80, 25);
            lblPort.Location = new Point(gb.Right + gap, gb.Top);
            lblPort.Text = "PORT";
            lblPort.Font = new Font("arial", 18, FontStyle.Regular);
            lblPort.TextAlign = ContentAlignment.MiddleLeft;
            lblPort.ForeColor = Color.Black;
            lblPort.BorderStyle = BorderStyle.None;
            lblPort.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            lblPort.Parent = this;

            TextBox tb1 = new TextBox();
            tb1.Name = "MainTb";
            tb1.Size = new Size(clientW - lblPort.Right - gap * 2, lblPort.Height);
            tb1.Location = new Point(lblPort.Right + gap, gb.Top);
            tb1.Font = new Font("arial", 18, FontStyle.Regular);
            tb1.ForeColor = Color.Black;
            tb1.BorderStyle = BorderStyle.FixedSingle;
            tb1.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            tb1.KeyDown += KeyDown;
            tb1.Parent = this;

            RichTextBox Main = new RichTextBox();
            Main.Size = new Size(clientW - gb.Right - gap * 2, gb.Height - tb1.Height - gap);
            Main.Location = new Point(gb.Right + gap, tb1.Bottom + gap);
            Main.BackColor = Color.LightBlue;
            Main.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            Main.BorderStyle = BorderStyle.Fixed3D;
            Main.Font = new Font("arial", 12, FontStyle.Regular);
            Main.Text = (PortList.Count != 0) ? PortList.Count + " port(s) found. Ready to scan or print." : "Connected port not found, please check the port connection";
            Main.Name = "Main";
            Main.SelectionFont = new Font("tahoma", 12);
            Main.ReadOnly = true;
            this.Controls.Add(Main);

            Panel Main_Print = new Panel();
            Main_Print.Size = new Size(clientW - gb.Right - gap * 2, gb.Height - tb1.Height - gap);
            Main_Print.Location = new Point(gb.Right + gap, tb1.Bottom + gap);
            Main_Print.BackColor = Color.FromArgb(215, 198, 121);
            Main_Print.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            Main_Print.BorderStyle = BorderStyle.Fixed3D;
            Main_Print.Name = "Main_Print";
            this.Controls.Add(Main_Print);

            {//Start Main_Print Elements//
                GroupBox gb3 = new GroupBox();
                gb3.Text = "Input Type";
                gb3.Font = new Font("arial", 10, FontStyle.Regular);
                gb3.Size = new Size(152, 45);
                gb3.Location = new Point(gap, gap);
                gb3.Anchor = AnchorStyles.Top | AnchorStyles.Left;
                gb3.Tag = "";
                gb3.Name = "gb3";
                Main_Print.Controls.Add(gb3);
                {//Start Input Type GroupBox
                    RadioButton rbText = new RadioButton();
                    rbText.Size = new Size(60, 23);
                    rbText.Location = new Point(gap, (gb3.Height - rbText.Height) / 2 + 5);
                    rbText.Font = new Font("arial", 12, FontStyle.Regular);
                    rbText.Text = "Text";
                    rbText.Name = "TypeText";
                    rbText.Checked = true;
                    rbText.CheckedChanged += Radiobutton_CheckedChanged;
                    rbText.Parent = gb3;

                    RadioButton rbBarcode = new RadioButton();
                    rbBarcode.Size = new Size(86, 23);
                    rbBarcode.Location = new Point(rbText.Right, rbText.Top);
                    rbBarcode.Font = new Font("arial", 12, FontStyle.Regular);
                    rbBarcode.Text = "Barcode";
                    rbBarcode.Name = "TypeBarcode";
                    rbBarcode.CheckedChanged += Radiobutton_CheckedChanged;
                    rbBarcode.Checked = false;
                    rbBarcode.Parent = gb3;
                }//End Input Type GroupBox

                int i = 0;
                zplElements.ForEach(x =>
                {
                    Panel zplElementsPanel = new Panel();
                    zplElementsPanel.Size = new Size(62, 30);
                    zplElementsPanel.Location = new Point(gb3.Right + gap * (i + 1) + (zplElementsPanel.Width * i), gb3.Controls["TypeText"].Top + 3);
                    zplElementsPanel.Anchor = AnchorStyles.Top | AnchorStyles.Left;
                    zplElementsPanel.BorderStyle = BorderStyle.None;
                    zplElementsPanel.Name = x;
                    Main_Print.Controls.Add(zplElementsPanel);
                    {
                        Label lblzpl = new Label();
                        lblzpl.Size = new Size(32, 25);
                        lblzpl.Location = new Point(0, 0);
                        lblzpl.Text = x + ":";
                        lblzpl.Name = x + "lbl";
                        lblzpl.Font = new Font("Tahoma", 13, FontStyle.Regular);
                        lblzpl.TextAlign = ContentAlignment.MiddleLeft;
                        lblzpl.ForeColor = Color.Black;
                        lblzpl.BorderStyle = BorderStyle.None;
                        lblzpl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
                        lblzpl.Parent = zplElementsPanel;

                        TextBox tbzpl = new TextBox();
                        tbzpl.Size = new Size(30, 25);
                        tbzpl.Location = new Point(lblzpl.Right, 0);
                        tbzpl.Font = new Font("Tahoma", 11, FontStyle.Regular);
                        tbzpl.Name = x + "Value";
                        tbzpl.ForeColor = Color.Black;
                        tbzpl.BorderStyle = BorderStyle.FixedSingle;
                        tbzpl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
                        tbzpl.Parent = zplElementsPanel;
                        tbzpl.KeyDown += KeyDown;
                    }
                    i++;
                });//End Foreach
                Main_Print.Controls["Font-Size"].Width = 120;
                Main_Print.Controls["Font-Size"].Location = new Point(Main_Print.Controls["Y"].Right + gap, Main_Print.Controls["Y"].Top);
                Main_Print.Controls["Font-Size"].Controls["Font-Sizelbl"].Width = 89;
                Main_Print.Controls["Font-Size"].Controls["Font-SizeValue"].Location = new Point(89, 0);
                Main_Print.Controls["Font-Size"].Controls["Font-SizeValue"].Text = "11";
                Main_Print.Controls["Font-Size"].Visible = true;
                Main_Print.Controls["X"].Controls["XValue"].Text = "20";
                Main_Print.Controls["Y"].Controls["YValue"].Text = "20";
                Main_Print.Controls["H"].Controls["HValue"].Text = "30";
                Main_Print.Controls["W"].Controls["WValue"].Text = "30";
                Main_Print.Controls["H"].Visible = false;
                Main_Print.Controls["W"].Visible = false;

                NumericUpDown NumPrint = new NumericUpDown();
                NumPrint.Size = new Size(88, 10);
                NumPrint.Location = new Point(Main_Print.Controls["W"].Right + gap, Main_Print.Controls["W"].Top - 1);
                NumPrint.Font = new Font("Tahoma", 30, FontStyle.Regular);
                NumPrint.ForeColor = Color.Black;
                NumPrint.BorderStyle = BorderStyle.FixedSingle;
                NumPrint.Minimum = 1;
                NumPrint.Maximum = 200;
                NumPrint.Value = 1;
                NumPrint.Name = "NumPrint";
                NumPrint.Parent = Main_Print;

                Button btnPrintOut = new Button();
                btnPrintOut.Size = new Size(NumPrint.Height, NumPrint.Height);
                btnPrintOut.Location = new Point(NumPrint.Right + gap, NumPrint.Top);
                btnPrintOut.BackColor = Color.LightGray;
                btnPrintOut.Font = new Font("tahoma", 12, FontStyle.Regular);
                //btnPrintOut.FlatStyle = FlatStyle.Flat;
                //btnPrintOut.FlatAppearance.BorderSize = 0;
                btnPrintOut.Text = "Print";
                btnPrintOut.Name = "btnPrintOut";
                btnPrintOut.MouseClick += Button_MouseClick;
                Main_Print.Controls.Add(btnPrintOut);

                TextBox input = new TextBox();
                input.Size = new Size(Main_Print.Controls["Y"].Right - gap, 20);
                input.Location = new Point(gap, Main_Print.Controls["gb3"].Height + gap * 2);
                input.Font = new Font("arial", 14, FontStyle.Regular);
                input.ForeColor = Color.Black;
                input.BorderStyle = BorderStyle.FixedSingle;
                input.Anchor = AnchorStyles.Left | AnchorStyles.Top;
                input.Name = "Input";
                input.KeyDown += KeyDown;
                input.Parent = Main_Print;

                Button addText = new Button();
                addText.Size = new Size(Main_Print.Controls["W"].Right - input.Right - gap, 30);
                addText.Location = new Point(input.Right + gap, input.Top);
                addText.BackColor = Color.LightGray;
                addText.Font = new Font("tahoma", 11, FontStyle.Regular);
                //btnPrintOut.FlatStyle = FlatStyle.Flat;
                //btnPrintOut.FlatAppearance.BorderSize = 0;
                addText.Text = "Add Input";
                addText.Name = "addInput";
                addText.MouseClick += Button_MouseClick;
                Main_Print.Controls.Add(addText);

                //DataGridView dg1 = new DataGridView();
                //dg1.Size = new Size(400, 150);
                //dg1.Location = new Point(gap, input.Bottom + gap);
                //dg1.BackColor = Color.White;
                //dg1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
                //dg1.BorderStyle = BorderStyle.Fixed3D;
                //dg1.Font = new Font("arial", 9, FontStyle.Regular);
                //dg1.Name = "dg1";
                //gridviewColumns.ForEach(x => dg1.Columns.Add(x, x));
                //dg1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
                //dg1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
                //dg1.Rows.Add("dfl");
                //dg1.RowHeadersVisible = false;
                //dg1.ReadOnly = true;
                //Main_Print.Controls.Add(dg1);

                ListView dg1 = new ListView();
                dg1.Size = new Size(400, 150);
                dg1.Location = new Point(gap, input.Bottom + gap);
                dg1.BackColor = Color.White;
                dg1.Anchor = AnchorStyles.Top | AnchorStyles.Left;
                dg1.BorderStyle = BorderStyle.Fixed3D;
                dg1.Font = new Font("arial", 9, FontStyle.Regular);
                dg1.Name = "dg1";
                dg1.View = View.Details;
                gridviewColumns.ForEach(x => dg1.Columns.Add(x));
                dg1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                dg1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                dg1.HeaderStyle = ColumnHeaderStyle.Nonclickable;
                Main_Print.Controls.Add(dg1);

                RichTextBox ZPLText = new RichTextBox();
                ZPLText.Size = new Size(250,150);
                ZPLText.Location = new Point(dg1.Right + gap, dg1.Top);
                ZPLText.BackColor = Color.White;
                ZPLText.Anchor = AnchorStyles.Top | AnchorStyles.Left;
                ZPLText.BorderStyle = BorderStyle.FixedSingle;
                ZPLText.Font = new Font("arial", 12, FontStyle.Regular);
                ZPLText.Name = "ZPLText";
                Main_Print.Controls.Add(ZPLText);

                Button shiftLabel = new Button();
                shiftLabel.Size = new Size(120 ,30);
                shiftLabel.Location = new Point(gap, dg1.Bottom + gap);
                shiftLabel.BackColor = Color.LightGray;
                shiftLabel.Font = new Font("tahoma", 11, FontStyle.Regular);
                shiftLabel.Text = "Shift Label Print";
                shiftLabel.Name = "btn_ShiftLabel";
                shiftLabel.MouseClick += Button_MouseClick;
                Main_Print.Controls.Add(shiftLabel);

                GroupBox gb_preview = new GroupBox();
                gb_preview.Text = "Output may vary";
                gb_preview.Font = new Font("arial", 11, FontStyle.Regular);
                gb_preview.Size = new Size(input.Width, 100);
                gb_preview.Location = new Point(gap, shiftLabel.Bottom + gap);
                gb_preview.BackColor = Color.White;
                gb_preview.Anchor = AnchorStyles.Top | AnchorStyles.Left;
                gb_preview.Name = "gb_preview";
                Main_Print.Controls.Add(gb_preview);

            }//End Main_Print Elements//

            CheckBox sound = new CheckBox();
            sound.Size = new Size(100, 30);
            sound.Location = new Point(gap, gb.Bottom);
            sound.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            sound.Font = new Font("arial", 12, FontStyle.Regular);
            sound.Text = "Sound On";
            sound.Name = "Sound";
            this.Controls.Add(sound);

            CheckBox Linecolor = new CheckBox();
            Linecolor.Size = new Size(100, 30);
            Linecolor.Location = new Point(Main.Left, Main.Bottom);
            Linecolor.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            Linecolor.Font = new Font("arial", 12, FontStyle.Regular);
            Linecolor.Text = "Line Color";
            Linecolor.Name = "Linecolor";
            this.Controls.Add(Linecolor);

            CheckBox checkPrint = new CheckBox();
            checkPrint.Size = new Size(100, 30);
            checkPrint.Location = new Point(Linecolor.Right, Main.Bottom);
            checkPrint.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            checkPrint.Font = new Font("arial", 12, FontStyle.Regular);
            checkPrint.Text = "Test Print";
            checkPrint.Name = "checkPrint";
            checkPrint.MouseClick += CheckBox_MouseClick;
            this.Controls.Add(checkPrint);

            Panel gb1 = new Panel();
            gb1.Size = new Size(180, 27);
            gb1.Location = new Point(checkPrint.Right, Main.Bottom);
            gb1.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
            gb1.BorderStyle = BorderStyle.FixedSingle;
            gb1.Name = "gb1";
            gb1.Visible = false;
            this.Controls.Add(gb1);

            Label lblgb = new Label();
            lblgb.Size = new Size(90, 25);
            lblgb.Location = new Point(0, (gb1.Height - lblgb.Height) / 2);
            lblgb.Text = "Label Size";
            lblgb.Font = new Font("arial", 12, FontStyle.Regular);
            lblgb.TextAlign = ContentAlignment.MiddleLeft;
            lblgb.ForeColor = Color.Black;
            lblgb.BorderStyle = BorderStyle.None;
            lblgb.Parent = gb1;

            RadioButton rb1 = new RadioButton();
            rb1.Size = new Size(50, 30);
            rb1.Location = new Point(lblgb.Right, (gb1.Height - rb1.Height) / 2);
            rb1.Font = new Font("arial", 12, FontStyle.Regular);
            rb1.Text = "S";
            rb1.Name = "S";
            rb1.Checked = true;
            rb1.CheckedChanged += Radiobutton_CheckedChanged;
            rb1.Parent = gb1;

            RadioButton rb2 = new RadioButton();
            rb2.Size = new Size(50, 30);
            rb2.Location = new Point(rb1.Right, rb1.Top);
            rb2.Font = new Font("arial", 12, FontStyle.Regular);
            rb2.Text = "L";
            rb2.Name = "L";
            rb2.Checked = false;
            rb2.CheckedChanged += Radiobutton_CheckedChanged;
            rb2.Parent = gb1;

            Panel gb2 = new Panel();
            gb2.Size = new Size(230, 27);
            gb2.Location = new Point(clientW - gb2.Width - gap, Main.Bottom);
            gb2.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            gb2.BorderStyle = BorderStyle.None;
            gb2.Name = "gb2";
            this.Controls.Add(gb2);

            Button btnPrint = new Button();
            btnPrint.Size = new Size(110, 25);
            btnPrint.Location = new Point(0, 0);
            btnPrint.BackColor = Color.Silver;
            btnPrint.Font = new Font("arial", 12, FontStyle.Regular);
            btnPrint.FlatStyle = FlatStyle.Popup;
            btnPrint.FlatAppearance.BorderSize = 1;
            btnPrint.Text = "Manual Print";
            btnPrint.Name = "btnPrint";
            btnPrint.MouseClick += Button_MouseClick;
            gb2.Controls.Add(btnPrint);
            btnPrint.Visible = false;

            Label lblFontSize = new Label();
            lblFontSize.Size = new Size(70, 25);
            lblFontSize.Location = new Point(btnPrint.Right + 2, btnPrint.Top);
            lblFontSize.Text = "Font Size";
            lblFontSize.Font = new Font("arial", 10, FontStyle.Regular);
            lblFontSize.TextAlign = ContentAlignment.MiddleLeft;
            lblFontSize.ForeColor = Color.Black;
            lblFontSize.BorderStyle = BorderStyle.None;
            lblFontSize.Parent = gb2;

            NumericUpDown lb = new NumericUpDown();
            lb.Size = new Size(gb2.Width - lblFontSize.Right - gap, 24);
            lb.Location = new Point(gb2.Width - lb.Width, 0);
            lb.Font = new Font("arial", 11, FontStyle.Regular);
            lb.ForeColor = Color.Black;
            lb.BorderStyle = BorderStyle.FixedSingle;
            lb.Minimum = 8;
            lb.Maximum = 100;
            lb.Value = int.Parse(Controls["Main"].Font.Size.ToString());
            lb.ValueChanged += Lb_ValueChanged;
            lb.Name = "FontSize";
            lb.Parent = gb2;

            GetConfig2(this);
        }
        private void Update(ListView list)
        {
            list.BeginUpdate();
            list.Items.Clear();
            if (_targetNode != null)
                foreach (RSARFileNode file in _targetNode.Files)
                    list.Items.Add(new SoundPackItem(file));

            list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            list.EndUpdate();
        }
Example #28
0
        private void CreateMyListView()
        {
            listView1        = new System.Windows.Forms.ListView();
            listView1.Bounds = new Rectangle(new Point(10, 10), new Size(500, 400));

            // Set the view to show details.
            listView1.View = View.Details;
            // Allow the user to edit item text.
            listView1.LabelEdit = true;
            // Allow the user to rearrange columns.
            listView1.AllowColumnReorder = true;
            // Display check boxes.
            listView1.CheckBoxes = true;
            // Select the item and subitems when selection is made.
            listView1.FullRowSelect = true;
            // Display grid lines.
            listView1.GridLines = true;
            // Sort the items in the list in ascending order.
            //listView1.Sorting = SortOrder.Ascending;


            // Width of -2 indicates auto-size.
            listView1.Columns.Add("Column 1", 100, HorizontalAlignment.Left);
            listView1.Columns.Add("Column 2", 100, HorizontalAlignment.Center);
            listView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left);
            listView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center);

            listView1.Items.Clear();
            // Create three items and three sets of subitems for each item.
            ListViewItem item1 = new ListViewItem("item1", 0);

            item1.Checked = true;
            item1.SubItems.Add("1");
            item1.SubItems.Add("2");
            item1.SubItems.Add("3");
            ListViewItem item2 = new ListViewItem("item2", 1);

            item2.SubItems.Add("4");
            item2.SubItems.Add("5");
            item2.SubItems.Add("6");
            ListViewItem item3 = new ListViewItem("item3", 0);

            item3.Checked = true;
            item3.SubItems.Add("7");
            item3.SubItems.Add("8");
            item3.SubItems.Add("9");
            ListViewItem item4 = new ListViewItem("item4", 0);

            item4.Checked = true;
            item4.SubItems.Add("10");
            item4.SubItems.Add("11");
            item4.SubItems.Add("12");

            listView1.Items.AddRange(new ListViewItem[] { item1, item4, item3, item2 });


            // Create two ImageList objects.
            ImageList imageListSmall = new ImageList();
            ImageList imageListLarge = new ImageList();

            // Initialize the ImageList objects with bitmaps.
            imageListSmall.Images.Add(Bitmap.FromFile("F:\\Test\\001.jpg"));
            imageListSmall.Images.Add(Bitmap.FromFile("F:\\Test\\002.jpg"));
            imageListLarge.Images.Add(Bitmap.FromFile("F:\\Test\\003.jpg"));
            imageListLarge.Images.Add(Bitmap.FromFile("F:\\Test\\004.jpg"));

            //Assign the ImageList objects to the ListView.
            listView1.LargeImageList = imageListLarge;
            listView1.SmallImageList = imageListSmall;

            listView1.ColumnClick += new ColumnClickEventHandler(ListView_ColumnClick);

            listView1.ItemChecked += new ItemCheckedEventHandler(listView1_ItemChecked);

            // listview根据列名自动调整列宽
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            listView1.ListViewItemSorter = listViewItemSort;

            this.Controls.Add(listView1);
        }
        /// <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)
                        {
                            SystemManager.ExceptionDeal(ex);
                        }
                    }
                }
                catch (Exception ex)
                {
                    SystemManager.ExceptionDeal(ex);
                }
            }
            lstSrvOpr.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
 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 PopulateVendorListView(ListView lv, List<ShippingVendor> vendorList)
 {
     _myVendorManager.ShippingVendors = vendorList;
     lv.Items.Clear();
     lv.Columns.Clear();
     foreach (var vendor in vendorList)
     {
         var item = new ListViewItem();
         item.Text = vendor.Id.ToString();
         item.SubItems.Add(vendor.Name);
         item.SubItems.Add(vendor.Address);
         item.SubItems.Add(vendor.City);
         item.SubItems.Add(vendor.State);
         item.SubItems.Add(vendor.Zip);
         item.SubItems.Add(vendor.Country);
         item.SubItems.Add(vendor.Phone);
         item.SubItems.Add(vendor.Contact);
         item.SubItems.Add(vendor.ContactEmail);
         item.SubItems.Add(vendor.Active.ToString());
         lv.Items.Add(item);
     }
     lv.Columns.Add("Vendor ID");
     lv.Columns.Add("Name");
     lv.Columns.Add("Address");
     lv.Columns.Add("City");
     lv.Columns.Add("State");
     lv.Columns.Add("Zip");
     lv.Columns.Add("Country");
     lv.Columns.Add("Phone");
     lv.Columns.Add("Contact");
     lv.Columns.Add("Email");
     lv.Columns.Add("Active");
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
Example #32
0
        private void listView1_DragDrop(object sender, DragEventArgs e)
        {
            List <string> files = ((string[])e.Data.GetData(DataFormats.FileDrop, false)).ToList();

            try
            {
                // Perform drag-and-drop, depending upon the effect.
                if (e.Effect != DragDropEffects.Copy)
                {
                    this.listView1.Items.Clear();
                }


                this.listView1.BeginUpdate();

                //remove duplicates bevore add
                foreach (ListViewItem lvi in this.listView1.Items)
                {
                    if (files.Contains(lvi.Text))
                    {
                        files.Remove(lvi.Text);
                    }
                }

                foreach (var filepath in files)
                {
                    var file = new FileInfo(filepath);
                    if (IsValidTarget(file))
                    {
                        // Set a default icon for the file.
                        Icon iconForFile = SystemIcons.WinLogo;

                        ListViewItem lvi = new ListViewItem();
                        //lvi.Text = file.Name;
                        lvi.Text       = file.FullName;
                        lvi.ImageIndex = 1;
                        lvi.Tag        = file;

                        ListViewItem.ListViewSubItem lvsi1 = new ListViewItem.ListViewSubItem();
                        lvsi1.Text = file.Length.ToString();
                        lvi.SubItems.Add(lvsi1);

                        ListViewItem.ListViewSubItem lvsi2 = new ListViewItem.ListViewSubItem();
                        lvsi2.Text = file.LastAccessTime.ToString();
                        lvi.SubItems.Add(lvsi2);

                        // Check to see if the image collection contains an image
                        // for this extension, using the extension as a key.
                        if (!ilSmall.Images.ContainsKey(file.Extension))
                        {
                            // If not, add the image to the image list.
                            iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(file.FullName);
                            ilSmall.Images.Add(file.Extension, iconForFile);
                        }

                        lvi.ImageKey    = file.Extension;
                        lvi.ToolTipText = "Unsaved";
                        this.listView1.Items.Add(lvi);
                    }
                }

                listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

                this.listView1.EndUpdate();
            }
            catch (System.Exception err)
            {
                MessageBox.Show("Error: " + err.Message);
            }

            this.listView1.View = View.Details;
        }
Example #33
0
 /// <summary>
 /// Automatically adjusts the size of list view columns to best fit.
 /// </summary>
 /// <param name="view">The <see cref="ListView"/> to be adjusted..</param>
 internal static void AutoAdjustListViewColumns(ListView view)
 {
     view.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
 /// <summary>
 /// リストビューの列幅を項目に応じて調整する
 /// </summary>
 /// <param name="listView">列幅を調整する ListView コントロール</param>
 private static void AdjustListViewColumnWidth(ListView listView)
 {
     if (listView.Items.Count > 0)
     {
         listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
     }
 }
        /// <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);
                    }
                    lstData.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    break;
            }
        }
        public static void LoadDividends(ListView lv, string active, DataTable dtXmlCache, DataTable dtXml, Label lblAnnualDividends)
        {
            try
            {
                lv.Clear();
                lv.View = View.Details;
                lv.Columns.Add("");
                lv.Columns.Add("Symbol");
                lv.Columns.Add("Name");
                lv.Columns.Add("Industry");
                lv.Columns.Add("Ex-Dividend");
                lv.Columns.Add("Pay Date");
                lv.Columns.Add("Pay Interval");
                lv.Columns.Add("Payout Ratio");
                lv.Columns.Add("Weight");
                lv.Columns.Add("Shares");
                lv.Columns.Add("Cost");
                lv.Columns.Add("Cost Basis");
                lv.Columns.Add("Quarterly Dividend");
                lv.Columns.Add("Yearly Dividend");

                //lv.Columns.Add("");
                    decimal[] eachWeight = new decimal[lv.Items.Count];
                    string[] stocks = new string[lv.Items.Count];

                    if (lv.Name == "lvCurrentDividends")
                    {
                        eachWeight = GetCalculateWeight();
                        stocks = uti.SplitCommaDelStockData(uti.GetStockSymbols(dtXml, ",", false, true));
                    }
                    else
                    {
                        stocks = uti.SplitCommaDelStockData(uti.GetStockSymbols(dtXml, ",", false, false));
                    }
                    string[] eachCost = GetEachStockCost(dtXml, stocks);
                    int count = 1;
                    int weightCnt = 0;
                    decimal totalAnnualDiv = 0;
                    bool isStockNameEmpty = false;
                    for (int i = 0; i < dtXml.Rows.Count; i++)
                    {
                        if (dtXml.Rows[i]["active"].ToString() == active)
                        {
                            string symbol = dtXml.Rows[i]["symbol"].ToString();
                            ListViewItem lvItem = new ListViewItem(count++.ToString());
                            lvItem.SubItems.Add(symbol);
                            lvItem.Tag = dtXml.Rows[i]["id"].ToString();
                            lvItem.SubItems.Add(dtXmlCache.Rows[i]["stockname"].ToString().Length == 1 ? "" : dtXmlCache.Rows[i]["stockname"].ToString());
                            lvItem.SubItems.Add(dtXml.Rows[i]["industry"].ToString());
                            lvItem.SubItems.Add(dtXmlCache.Rows[i]["exDividend"].ToString().Length == 1 ? "" : dtXmlCache.Rows[i]["exDividend"].ToString());
                            lvItem.SubItems.Add(dtXmlCache.Rows[i]["payDates"].ToString().Length == 1 ? "" : dtXmlCache.Rows[i]["payDates"].ToString());
                            decimal payoutRatio = 0;
                            if (dtXmlCache.Rows[i]["eps"].ToString() != "" && dtXmlCache.Rows[i]["eps"].ToString() != "N/A" && dtXmlCache.Rows[i]["annualDiv"].ToString() != "" && dtXmlCache.Rows[i]["annualDiv"].ToString() != "N/A")
                            {
                                payoutRatio = Math.Round(Convert.ToDecimal(dtXmlCache.Rows[i]["annualDiv"].ToString()) / Convert.ToDecimal(dtXmlCache.Rows[i]["eps"].ToString()) * 100, 2);
                            }
                            lvItem.SubItems.Add(dtXml.Rows[i]["interval"].ToString());
                            lvItem.SubItems.Add(dtXmlCache.Rows[i]["eps"].ToString().Length == 1 ? "" : payoutRatio.ToString() + "%");
                            lvItem.SubItems.Add(eachWeight.Length > 1 ? eachWeight[weightCnt] + "%" : "-");
                            lvItem.SubItems.Add(dtXml.Rows[i]["shares"].ToString());
                            lvItem.SubItems.Add(dtXml.Rows[i]["cost"].ToString());
                            if (dtXml.Rows[i]["active"].ToString() == "true")
                            {
                                lvItem.SubItems.Add(eachCost[weightCnt] != "" ? "$" + Convert.ToDecimal(eachCost[weightCnt]).ToString() : "$0");
                                weightCnt++;
                            }
                            else
                            {
                                lvItem.SubItems.Add(eachCost[weightCnt] != "" ? "$" + Convert.ToDecimal(eachCost[weightCnt]).ToString() : "$0");
                                weightCnt++;
                            }
                            lvItem.SubItems.Add(dtXmlCache.Rows[i]["annualDiv"].ToString() != "" && dtXmlCache.Rows[i]["annualDiv"].ToString() != "N/A" ? "$" + Math.Round(Convert.ToDecimal(dtXmlCache.Rows[i]["annualDiv"]) * Convert.ToDecimal(dtXml.Rows[i]["shares"]) / 4, 2).ToString() : "$0");
                            lvItem.SubItems.Add(dtXmlCache.Rows[i]["annualDiv"].ToString() != "" && dtXmlCache.Rows[i]["annualDiv"].ToString() != "N/A" ? "$" + Math.Round(Convert.ToDecimal(dtXmlCache.Rows[i]["annualDiv"]) * Convert.ToDecimal(dtXml.Rows[i]["shares"]), 2).ToString() : "$0");
                            totalAnnualDiv += dtXmlCache.Rows[i]["annualDiv"].ToString() != "" && dtXmlCache.Rows[i]["annualDiv"].ToString() != "N/A" ? (Convert.ToDecimal(dtXmlCache.Rows[i]["annualDiv"]) * Convert.ToDecimal(dtXml.Rows[i]["shares"])) : 0;

                            lvItem.ForeColor = Color.White;
                            lvItem.Font = new Font(lv.Font, FontStyle.Bold);
                            lv.Items.Add(lvItem);
                        }
                        else
                        {

                        }
                    }
                    isStockNameEmpty = dtXmlCache.Rows[0]["stockname"].ToString() == "" ? true : false;
                    lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                    lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                    for (int a = 0; a < lv.Columns.Count; a++)
                    {
                        lv.Columns[a].TextAlign = HorizontalAlignment.Center;
                        if (a == 2)
                        {
                            if (isStockNameEmpty)
                            {
                                lv.Columns[a].Width = 180;
                            }
                        }
                        if (a == 6 || a == 7 || a == 8 || a == 9 || a == 10 || a == 11 || a == 12 || a == 13)
                        {
                            //lv.Columns[a].AutoResize(ColumnHeaderAutoResizeStyle.None);
                            lv.Columns[a].Width = 95;
                            //lv.Columns[a].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                            //lv.Columns[a].Width = 1000;
                        }
                    }
                    if (active == "true")
                    {
                        lblAnnualDividends.Text = "$" + Math.Round(totalAnnualDiv, 2).ToString();
                    }
                    for (int b = 0; b < lv.Items.Count; b++)
                    {
                        uti.ChangedListViewItemBold(lv, b, false, true);
                        lv.Items[b].ForeColor = uti.ForeColorUnSelected;
                    }
            }
            catch (Exception e)
            {

            }
        }
 private void PopulatePackListView(ListView lv, List<ShippingOrder> orderList)
 {
     btnPackComplete.Enabled = false;
     _myOrderManager.Orders = orderList;
     lv.Items.Clear();
     lv.Columns.Clear();
     foreach (var order in _myOrderManager.Orders)
     {
         if (order.UserId.HasValue)
         {
         }
         else
         {
             var item = new ListViewItem();
             item.Text = order.ID.ToString();
             item.SubItems.Add(order.ShippingVendorName);
             item.SubItems.Add(order.ShippingTermDesc);
             item.SubItems.Add(order.ShipToName);
             item.SubItems.Add(order.ShipToAddress);
             item.SubItems.Add(order.ShipToCity);
             item.SubItems.Add(order.ShipToState);
             item.SubItems.Add(order.ShipToZip);
             item.SubItems.Add(order.Picked.ToString());
             lv.Items.Add(item);
         }
     }
     lv.Columns.Add("OrderID");
     lv.Columns.Add("Vendor");
     lv.Columns.Add("ShipTerm");
     lv.Columns.Add("CustomerName");
     lv.Columns.Add("Address");
     lv.Columns.Add("City");
     lv.Columns.Add("State");
     lv.Columns.Add("ZipCode");
     lv.Columns.Add("Picked");
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
        /// <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);
            }
            lstData.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
            // 用新的排序方法对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>
 /// 用户列表
 /// </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);
 }
Example #40
0
 private void fillListView(ListView lv, List<VendorSourceItem> lista)
 {
     lv.Items.Clear();
        lv.View = View.Details;
        lv.GridLines = true;
        foreach (var vsr in lista)
        {
        var item = new ListViewItem {Text = vsr.ProductID.ToString()};
       // item.SubItems.Add(vsr.Name);
        item.SubItems.Add(vsr.VendorID.ToString());
        item.SubItems.Add(vsr.MinQtyToOrder.ToString());
        item.SubItems.Add(vsr.UnitCost.ToString());
        lv.Items.Add(item);
        }
        lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
		/**
		 * Parses summaries into a list view using the network stream for name lookup.
		 * 
		 * @param	NetworkStream	Network stream used for name lookup
		 * @param	Summaries		Summaries to parse into listview
		 * @param	ListView		List view to parse data into
		 */
		public static void ParseStreamIntoListView( NetworkStream NetworkStream, Dictionary<int,TypeSummary> Summaries, ListView ListView )
		{
			ListView.BeginUpdate();
			ListView.Items.Clear();

			// Columns are total size KByte, count, avg size in bytes, avg size in bits and associated name.
			var Columns = new string[6];
			foreach( var SummaryEntry in Summaries )
			{
				Columns[0] = ((float)SummaryEntry.Value.SizeBits / 8 / 1024).ToString("0.0");
				Columns[1] = SummaryEntry.Value.Count.ToString();
                Columns[2] = ((float)SummaryEntry.Value.SizeBits / 8 / SummaryEntry.Value.Count).ToString("0.0");
				Columns[3] = ((float)SummaryEntry.Value.SizeBits / SummaryEntry.Value.Count).ToString("0.0");
                Columns[4] = SummaryEntry.Value.TimeInMS.ToString("0.00");
                Columns[5] = NetworkStream.GetName(SummaryEntry.Key);
                ListView.Items.Add(new ListViewItem(Columns));
			}

			ListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
			ListView.EndUpdate();
		}
        /// <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());
                                //https://jira.mongodb.org/browse/CSHARP-665
                                try
                                {
                                    //注意:这个MaxDocuments只是在CappedCollection时候有效
                                    lst.SubItems.Add(CollectionStatus.MaxDocuments.ToString());
                                }
                                catch (Exception ex)
                                {
                                    //溢出
                                    lst.SubItems.Add(Int32.MaxValue.ToString());
                                    SystemManager.ExceptionLog(ex);
                                }

                                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 ex)
                            {
                                //throw;
                                //TODO:排序时候会发生错误,所以暂时不对应
                                //lstData.Items.Add(new ListViewItem(strColName + "[Exception]"));
                                SystemManager.ExceptionDeal(ex);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    SystemManager.ExceptionDeal(ex);
                }
            }
            lstData.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
        }
        void MoveItem (ListView srcView, ListView destView)
        {
            if (srcView.SelectedIndices.Count == 0)
                return;

            int selectedIndex = srcView.SelectedIndices [0];
            var item = srcView.Items [selectedIndex];

            srcView.Items.RemoveAt (selectedIndex);
            destView.Items.Add (item);
			destView.AutoResizeColumns (ColumnHeaderAutoResizeStyle.HeaderSize);
        }
 private void PopulatePickListView(ListView lv, List<ShippingOrder> orderList)
 {
     btnStartPick.Enabled = false;
     _myOrderManager.Orders = orderList;
     lv.Items.Clear();
     lv.Columns.Clear();
     foreach (var order in _myOrderManager.Orders)
     {
         var item = new ListViewItem();
         item.Text = order.ID.ToString();
         item.SubItems.Add(order.ShippingVendorName);
         if (order.UserId.HasValue)
         {
             item.SubItems.Add(order.UserId.ToString());
             item.SubItems.Add(order.UserFirstName.ToString());
             item.SubItems.Add(order.UserLastName.ToString());
         }
         else
         {
             item.SubItems.Add(" ");
             item.SubItems.Add(" ");
             item.SubItems.Add(" ");
         }
         item.SubItems.Add(order.Picked.ToString());
         lv.Items.Add(item);
     }
     lv.Columns.Add("OrderID");
     lv.Columns.Add("Vendor");
     lv.Columns.Add("UserID");
     lv.Columns.Add("FirstName");
     lv.Columns.Add("LastName");
     lv.Columns.Add("Picked");
     lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
 }
Example #45
-1
        // This subroutine is a shortcut that changes the detail-list data on-screen if dropdown selectors are changed
        // It also plays a part in initialisation
        private void changeHardwareDetails(object hardwareInstance, ListView list)
        {
            // Clear the list
            list.Items.Clear();

            if (hardwareInstance != null)
            {
                // Get the properties of the given hardware class
                FieldInfo[] classFields = hardwareInstance.GetType().GetFields();
                string name, value;
                // Loop through each field in the class
                foreach (FieldInfo field in classFields)
                {
                    // Extract the field name (format it)
                    name = fieldToString(field.Name);
                    // Extract the value
                    value = Convert.ToString(field.GetValue(hardwareInstance));
                    // If the value is zero or blank, output N/A
                    if (value == "0" || value == "") value = "N/A";
                    // Add the value to the list
                    list.Items.Add(new ListViewItem(new string[] {
                        name,
                        value
                    }));
                }
                // Resize columns
                list.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                // Make last column fill the remaining width
                list.Columns[list.Columns.Count - 1].Width = -2;
            }
        }
 void PopulateListView(ListView lv, List<KeyValuePair<string, Type>> map, Predicate<KeyValuePair<string, Type>> match)
 {
     lv.Visible = false;
     lv.BeginUpdate();
     lv.Items.Clear();
     string fmt = "{0:D" + (map.Count.ToString().Length) + "}";
     int order = 0;
     foreach (var kvp in map)
     {
         order++;
         if (!match(kvp)) continue;
         string tag = getTag(kvp.Key);
         string wrapper = kvp.Value.Name;
         string file = System.IO.Path.GetFileName(kvp.Value.Assembly.Location);
         string title = GetAttrValue(kvp.Value.Assembly, typeof(System.Reflection.AssemblyTitleAttribute), "Title");
         string description = GetAttrValue(kvp.Value.Assembly, typeof(System.Reflection.AssemblyDescriptionAttribute), "Description");
         string company = GetAttrValue(kvp.Value.Assembly, typeof(System.Reflection.AssemblyCompanyAttribute), "Company");
         string product = GetAttrValue(kvp.Value.Assembly, typeof(System.Reflection.AssemblyProductAttribute), "Product");
         ListViewItem lvi = new ListViewItem(new string[] { String.Format(fmt, order), tag, kvp.Key, wrapper, file, title, description, company, product, });
         lvi.Tag = kvp;
         lv.Items.Add(lvi);
     }
     if (lv.Items.Count > 0)
         lv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
     lv.EndUpdate();
     lv.Visible = true;
 }