Esempio n. 1
0
        private void OnCellMouseDown(MyDataGridView dataGridViewCharacters, ref Button btnZoom, Font font, TableLayoutPanel ZoomButtonParent,
                                     SendToEditorForms eOutputForm, bool bIsLegacy, DataGridViewCellMouseEventArgs e)
        {
            if ((e.RowIndex >= 0) && (e.ColumnIndex >= 0))
            {
                m_mbButtonDown = e.Button;

                DataGridViewCell aCell = dataGridViewCharacters.Rows[e.RowIndex].Cells[e.ColumnIndex];
                if (m_mbButtonDown == MouseButtons.Right)
                {
                    // simply selecting the cell will trigger the zoom button update
                    //  (but only if it's already activated)
                    if (btnZoom == null)
                    {
                        ShowZoomButton(ref btnZoom, font, ZoomButtonParent, eOutputForm, bIsLegacy, aCell);
                    }
                    else if (!btnZoom.Visible)
                    {
                        btnZoom.Show();
                    }

                    // either way, select the cell
                    aCell.Selected = true;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            components         = new System.ComponentModel.Container();
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            var data = new DataSet("Previous");

            Grid      = new MyDataGridView();
            Grid.Name = "Moves";
            Grid.Size = new Size(Width, Height);
            Grid.AllowUserToAddRows    = false;
            Grid.AllowUserToDeleteRows = false;
            Grid.ColumnCount           = 3;
            int w = (Config.MovesWidth - Config.MoveColumnWidth - 42 /*width of left strip*/) / 2;

            Grid.Columns[0].Name     = Config.MoveColumn;
            Grid.Columns[0].ReadOnly = true;
            Grid.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
            Grid.Columns[0].Width    = Config.MoveColumnWidth;
            Grid.Columns[1].Name     = Config.BlackColumn;
            Grid.Columns[1].Width    = w;
            Grid.Columns[1].ReadOnly = true;
            Grid.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
            Grid.Columns[2].Name     = Config.WhiteColumn;
            Grid.Columns[2].Width    = w;
            Grid.Columns[2].ReadOnly = true;
            Grid.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;

            Controls.Add(Grid);
        }
Esempio n. 3
0
        /// <summary>
        /// 将表格中选择的单元格导出到CSV文件中
        /// </summary>
        /// <param name="view"></param>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static bool ExportDataGridViewToCsv(MyDataGridView view, string filename)
        {
            int startcol = view.ColumnCount;
            int endcol   = -1;
            int startrow = view.RowCount;
            int endrow   = -1;

            foreach (DataGridViewCell cell in view.SelectedCells)
            {
                if (cell.ColumnIndex < startcol)
                {
                    startcol = cell.ColumnIndex;
                }
                if (cell.ColumnIndex > endcol)
                {
                    endcol = cell.ColumnIndex;
                }
                if (cell.RowIndex < startrow)
                {
                    startrow = cell.RowIndex;
                }
                if (cell.RowIndex > endrow)
                {
                    endrow = cell.RowIndex;
                }
            }
            if (File.Exists(filename))
            {
                File.SetAttributes(filename, FileAttributes.Normal);
                File.Delete(filename);
            }
            StreamWriter  sw  = new StreamWriter(filename);
            StringBuilder txt = new StringBuilder();

            for (int col = startcol; col <= endcol; col++)
            {
                txt.Append(view.Columns[col].HeaderText + ",");
            }
            txt = txt.Remove(txt.Length - 1, 1);
            sw.WriteLine(txt.ToString());
            for (int row = startrow; row <= endrow; row++)
            {
                txt = new StringBuilder();
                for (int col = startcol; col <= endcol; col++)
                {
                    if (view.Rows[row].Cells[col].Selected)
                    {
                        txt.Append(view.GetGridValue(row, col) + ",");
                    }
                    else
                    {
                        txt.Append(",");
                    }
                }
                txt = txt.Remove(txt.Length - 1, 1);
                sw.WriteLine(txt.ToString());
            }
            sw.Close();
            return(true);
        }
Esempio n. 4
0
        private void OnCbSelectedIndexChanged(ComboBox cbCodePointRange, MyDataGridView dataGridViewCharacters,
                                              ref Button btnZoom, Font font, bool bIsLegacy)
        {
            string strValue = (string)cbCodePointRange.SelectedItem;

            if (String.IsNullOrEmpty(strValue))
            {
                return;
            }

            ResetCharMap(ref btnZoom, dataGridViewCharacters);

            RadioButton   btnToCheck;
            UnicodeSubset aUS;

            if ((m_aUSM != null) && m_aUSM.TryGetValue(strValue, out aUS))
            {
                btnToCheck = radioButtonUnicodeSubsets;
                foreach (KeyValuePair <int, int> aRangeLength in aUS)
                {
                    InitializeCharMap(font, dataGridViewCharacters, aRangeLength.Key, aRangeLength.Value, 0, bIsLegacy);
                }
            }
            else if (radioButtonByCodePoint.Checked)
            {
                btnToCheck = radioButtonByCodePoint;
                int nBeginningIndex = Convert.ToInt32(strValue.Substring(0, 4), 16);
                InitializeCharMap(font, dataGridViewCharacters, nBeginningIndex, 0x80, 0, bIsLegacy);
            }
            else
            {
                return;
            }

            // first see if this range has been added to our list of recently used ranges
            foreach (RadioButton btnUnicodeRange in flowLayoutPanelRecentRanges.Controls)
            {
                if (btnUnicodeRange.Text == strValue)
                {
                    flowLayoutPanelRecentRanges.Controls.SetChildIndex(btnUnicodeRange, 0);
                    btnUnicodeRange.Checked = true;
                    return;                     // found, so just return
                }
            }

            // otherwise, add a radio button for this range so we can more easily go back to it
            RadioButton btn = new RadioButton();

            btn.AutoSize = true;
            btn.Name     = "radioButton" + strValue;
            btn.TabStop  = true;
            btn.Text     = strValue;
            btn.UseVisualStyleBackColor = true;
            btn.Click += new EventHandler(btnUnicodeRange_Click);

            flowLayoutPanelRecentRanges.Controls.Add(btn);
            flowLayoutPanelRecentRanges.Controls.SetChildIndex(btn, 0);
            btn.Checked = true;
            btn.Tag     = btnToCheck;
        }
Esempio n. 5
0
        // Method stores the original Mission before checking
        public void doStoreOriginalMission(MyDataGridView Commands)
        {
            m_takeoff_id = -1;
            m_land_id    = -1;

            defined_mission.Clear();

            foreach (DataGridViewRow Command in Commands.Rows)
            {
                int    cmd_id = get_command_id(Command.Cells[0].Value.ToString());
                double p1     = double.Parse(Command.Cells[1].Value.ToString());
                double p2     = double.Parse(Command.Cells[2].Value.ToString());
                double p3     = double.Parse(Command.Cells[3].Value.ToString());
                double p4     = double.Parse(Command.Cells[4].Value.ToString());

                double x = double.Parse(Command.Cells[5].Value.ToString()); //
                double y = double.Parse(Command.Cells[6].Value.ToString()); //
                double z = double.Parse(Command.Cells[7].Value.ToString()); //

                // check also takeoff and landing points:
                if (cmd_id == (int)MAVLink.MAV_CMD.TAKEOFF)
                {
                    m_takeoff_id = defined_mission.Count();
                }
                if (cmd_id == (int)MAVLink.MAV_CMD.LAND)
                {
                    m_land_id = defined_mission.Count();
                }

                defined_mission.Add(new MissionItem(cmd_id, p1, p2, p3, p4, x, y, z));
            }
        }
Esempio n. 6
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            if (!CanSave())
            {
                return;
            }

            /*
             * if (MyDataGridView.SelectedRows.Count == 0)
             * {
             *  decimal price = PriceTBox.Value;
             *  int.TryParse(BillIdTbox.Text, out int InvoiceId);
             *  var DR = (DataRowView)this.selectInvoices_ItemsBindingSource.AddNew();
             *  DR[InvoiceIdCol.DataPropertyName] = InvoiceId;
             *  DR[itemIdCol.DataPropertyName] = ItemCodeCBox.SelectedValue;
             *  DR[BarCodeCol.DataPropertyName] = ItemCodeCBox.Text;
             *  DR[itemNameCol.DataPropertyName] = ItemNameCBox.Text;
             *  DR[QuantityCol.DataPropertyName] = QtyTBox.Value;
             *  DR[PriceCol.DataPropertyName] = price;
             *  DR[TotalPriceCol.DataPropertyName] = Math.Round(price * QtyTBox.Value, 2);
             * }
             * MyDataGridView.ClearSelection();
             */

            selectInvoices_ItemsBindingSource.EndEdit();
            MyDataGridView.EndEdit();
            AddNewItem();
            SetTotals(true);
        }
Esempio n. 7
0
        private void buttonOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string   name      = openFileDialog1.FileName;
                string   File      = _FileString.MyFileString.ReadF(name);
                string[] arrstring = File.Split(new char[] { ' ', ',', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                Newbase = new Base();
                for (int i = 0; i < arrstring.Length; i += 5)
                {
                    Newbase.Add(new Room(arrstring[i], Convert.ToInt32(arrstring[i + 1]), Convert.ToDouble(arrstring[i + 2]), Convert.ToDouble(arrstring[i + 3]), Convert.ToDouble(arrstring[i + 4])));
                }
                dataGridView231 = MyDataGridView.ClearDataGridView(dataGridView231);

                dataGridView231.Columns.Add("Название района", "Название района");
                dataGridView231.Columns.Add("Количество комнат", "Количество комнат");
                dataGridView231.Columns.Add("Общая площадь", "Общая площадь");
                dataGridView231.Columns.Add("Площадь кухни", "Площадь кухни");
                dataGridView231.Columns.Add("Цена", "Цена");
                for (int i = 0; i < Newbase.MainBase.Count; i++)
                {
                    dataGridView231.Rows.Add(Newbase.MainBase[i].name, Convert.ToString(Newbase.MainBase[i].Nroom), Convert.ToString(Newbase.MainBase[i].Smax), Convert.ToString(Newbase.MainBase[i].Scook), Convert.ToString(Newbase.MainBase[i].Price));
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Инициализация ДатаГрид. Выводится стартовый список клиентов тоже тут.
        /// </summary>
        private void InitDataGridView()
        {
            var dt = DataBaseM.CreatePersonsTable(_personsAll.Values, DataBaseM.GetPersonFieldsShort);

            MyDataGridView.SetSourceDataGridView(dataGridView_Persons, dt);
            MyDataGridView.ImplementStyle(dataGridView_Persons);
        }
Esempio n. 9
0
 /// <summary>
 /// Обновляет таблицу с посещениями на вкладке посещений.
 /// Сейчас только для Гостевого посещения. Костыль
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GuestVisitHappend(object sender, EventArgs e)
 {
     if (_person.Status == StatusPerson.Гостевой)
     {
         MyDataGridView.SetSourceDataGridView(dataGridView_Visits, Visit.GetVisitsTable(_person));
     }
 }
Esempio n. 10
0
        internal unsafe void GetAllPossibleGlyphIndices(MyDataGridView grid, Font font, int nBeginningCharacterIndex, int nNumPossibleChars,
                                                        int nCodePage, bool bIsLegacy, out char[] achFullPossibleChars, out char[] achGlyIdxes)
        {
            IntPtr hWnd      = IntPtr.Zero;
            IntPtr hFont     = IntPtr.Zero;
            IntPtr hDC       = IntPtr.Zero;
            IntPtr hOrigFont = IntPtr.Zero;
            int    nCount    = 0;

            try
            {
                hWnd      = grid.Handle;
                hFont     = font.ToHfont();
                hDC       = GetDC(hWnd);
                hOrigFont = SelectObject(hDC, hFont);

                char *pGlyIdx = stackalloc char[nNumPossibleChars];

                // legacy (but not symbol) fonts behave differently
                if (bIsLegacy && (nCodePage != EncConverters.cnSymbolFontCodePage))
                {
                    // fill a byte array with all possible ansi code points and then turn that into chars via
                    //  the default system code page.
                    byte[] abyCharValues = new byte[nNumPossibleChars];
                    for (int i = 0; i < nNumPossibleChars; i++)
                        abyCharValues[i] = (byte)i;

                    fixed(byte *pTxt = abyCharValues)
                    {
                        nCount = GetGlyphIndicesA(hDC, pTxt, nNumPossibleChars, pGlyIdx, GGI_MARK_NONEXISTING_GLYPHS);
                    }

                    achFullPossibleChars = Encoding.GetEncoding(nCodePage).GetChars(abyCharValues);
                }
                else
                {
                    achFullPossibleChars = new char[nNumPossibleChars];
                    for (int i = 0; i < nNumPossibleChars; i++)
                        achFullPossibleChars[i] = (char)(nBeginningCharacterIndex + i);

                    fixed(char *pTxt = achFullPossibleChars)
                    {
                        nCount = GetGlyphIndicesW(hDC, pTxt, nNumPossibleChars, pGlyIdx, GGI_MARK_NONEXISTING_GLYPHS);
                    }
                }

                achGlyIdxes = new char[nCount];
                for (int i = 0; i < nCount; i++)
                {
                    achGlyIdxes[i] = pGlyIdx[i];
                }
            }
            finally
            {
                // release what we got
                SelectObject(hDC, hOrigFont);
                ReleaseDC(hWnd, hDC);
            }
        }
Esempio n. 11
0
        private void Sort()
        {
            MyDataGridView     myDataGridView = this.gridView;
            DataGridViewColumn sortedColumn   = this.gridView.SortedColumn ?? this.gridView.Columns[1];
            object             sortOrder      = this.gridView.SortOrder;

            object[] objArray = new object[] { SortOrder.Ascending, SortOrder.None };
            myDataGridView.Sort(sortedColumn, (sortOrder.IsAny(objArray) ? ListSortDirection.Ascending : ListSortDirection.Descending));
        }
Esempio n. 12
0
        private void ModsSelector_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button != System.Windows.Forms.MouseButtons.Right)
            {
                return;
            }
            MyDataGridView myDataGridView = sender as MyDataGridView;

            if (myDataGridView == null)
            {
                return;
            }
            this.selectorContextMenu.Tag = myDataGridView.Parent;
            this.selectorContextMenu.Show(myDataGridView, e.Location);
        }
Esempio n. 13
0
 private void SaveInvoiceBtn_Click(object sender, EventArgs e)
 {
     if (!CanSave())
     {
         return;
     }
     else if (MyDataGridView.RowCount < 1)
     {
         MessageBox.Show("Please add at least one item!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     selectInvoicesBindingSource.EndEdit();
     selectInvoices_ItemsBindingSource.EndEdit();
     MyDataGridView.EndEdit();
     selectInvoicesTableAdapter.Update(myDataSet.SelectInvoices);
     selectInvoices_ItemsTableAdapter.Update(myDataSet.SelectInvoices_Items);
 }
Esempio n. 14
0
        public DisplayForm(DataGridViewRow clickedRow = null)
        {
            InitializeComponent();
            CenterToScreen();
            this.clickedRow = clickedRow;
            currentGrid     = null;

            listViewItem1.Tag  = "cimek";
            listViewItem2.Tag  = "szerzodesek";
            listViewItem3.Tag  = "szemelyek";
            listViewItem4.Tag  = "szervezetek";
            listViewItem5.Tag  = "ingatlanok";
            listViewItem6.Tag  = "gepjarmuvek";
            listViewItem7.Tag  = "ingok";
            listViewItem8.Tag  = "teljesitesek";
            listViewItem9.Tag  = "szerzodestargyak";
            listViewItem10.Tag = "reszvetelek";
            createGridViews();
        }
Esempio n. 15
0
        protected void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (TcpClientWrapper.Instance.isConnected() && listView1.SelectedItems.Count > 0)
            {
                splitContainer2.Panel2.Controls.Remove(currentGrid);
                Label = (string)listView1.SelectedItems[0].Tag;
                foreach (var grid in dataGrids)
                {
                    if (listView1.SelectedItems.Count > 0 && Label == grid.Id)
                    {
                        splitContainer2.Panel2.Controls.Add(grid);
                        currentGrid = grid;

                        break;
                    }
                }
                GetRecordMessage msg = new GetRecordMessage($"{Route}/{Label}", new byte[0], false);
                TcpClientWrapper.Instance.send <GetRecordMessage>(msg);
            }
        }
Esempio n. 16
0
        private void RemoveItem(bool force = false)
        {
            int index = MyDataGridView.Items.IndexOf(MyDataGridView.SelectedItem);

            Invoices_Items[] _items = new Invoices_Items[MyDataGridView.Items.Count];
            MyDataGridView.Items.CopyTo(_items, 0);
            foreach (Invoices_Items item in _items)
            {
                if (!force && MyDataGridView.Items.IndexOf(item) == index)
                {
                    continue;
                }

                if (item.Id <= 0 && item.IsNewInvoiceItem)
                {
                    context.Invoices_Items.Remove(item);
                    MyDataGridView.UpdateLayout();
                }
            }
        }
Esempio n. 17
0
        private void requestButton_Click(object sender, EventArgs e)
        {
            const string requestUri =
                "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5/";

            StringBuilder data = new StringBuilder();

            data.AppendFormat("query?text={0}&geometry={1}&geometryType={2}&inSR={3}", string.Empty, string.Empty, "esriGeometryPoint", string.Empty);
            data.AppendFormat("&spatialRel-{0}&relationParam={1}&objectIds={2}", "esriSpatialRelIntersects", string.Empty, string.Empty);
            data.AppendFormat("&where={0}", System.Web.HttpUtility.UrlEncode("POP2000>" + MyNumericUpDown.Value.ToString(CultureInfo.InvariantCulture)));
            data.AppendFormat("&time={0}&returnCountOnly={1}&returnIdsOnly={2}&returnGeometry={3}", string.Empty, "false", "false", "false");
            data.AppendFormat("&maxAllowableOffset={0}&outSR={1}&outFields={2}&f={3}", string.Empty, string.Empty, "*", "json");

            HttpWebRequest request = WebRequest.Create(requestUri + data) as HttpWebRequest;

            using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
            {
                StreamReader reader         = new StreamReader(response.GetResponseStream());
                string       responseString = reader.ReadToEnd();

                // JavaScriptSerializer in System.Web.Extensions.dll
                JavaScriptSerializer jss = new JavaScriptSerializer();

                IDictionary <string, object> results = jss.DeserializeObject(responseString) as IDictionary <string, object>;

                if (results == null || !results.ContainsKey("features"))
                {
                    return;
                }

                IEnumerable <object> features = results["features"] as IEnumerable <object>;
                foreach (IDictionary <string, object> record in from IDictionary <string, object> feature in features select feature["attributes"] as IDictionary <string, object> )
                {
                    MyDataGridView.Rows.Add(new[] { record["ObjectID"], record["STATE_NAME"], record["POP2000"] });
                }

                MyDataGridView.Update();
            }
        }
Esempio n. 18
0
        public static List <DataTable> ImportExcelFile(string filePath, MyDataGridView dgv1, MyDataGridView dgv2, MyDataGridView dgv3, MyDataGridView dgv4, MyDataGridView dgv5)
        {
            List <DataTable> dts = new List <DataTable>();
            HSSFWorkbook     hssfworkbook;

            #region//初始化信息
            try
            {
                using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    hssfworkbook = new HSSFWorkbook(file);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            #endregion

            NPOI.SS.UserModel.ISheet       sheet = hssfworkbook.GetSheetAt(0);
            System.Collections.IEnumerator rows  = sheet.GetRowEnumerator();
            DataTable dt1  = (DataTable)dgv1.DataSource;
            DataTable dt2  = (DataTable)dgv2.DataSource;
            DataTable dt3  = (DataTable)dgv3.DataSource;
            DataTable dt4  = (DataTable)dgv4.DataSource;
            DataTable dt5  = (DataTable)dgv5.DataSource;
            int       cols = sheet.GetRow(0).LastCellNum;
            if (cols != 15 && cols != 13)
            {
                return(dts);
            }
            dt1.Clear();
            dt2.Clear();
            dt3.Clear();
            dt4.Clear();
            dt5.Clear();
            //前两行为标题
            rows.MoveNext();
            rows.MoveNext();

            int count = 0;
            while (rows.MoveNext())
            {
                count++;
                if (count > 10)
                {
                    break;
                }

                HSSFRow row = (HSSFRow)rows.Current;
                DataRow dr1 = dt1.NewRow();
                DataRow dr2 = dt2.NewRow();
                DataRow dr3 = dt3.NewRow();
                DataRow dr4 = dt4.NewRow();
                DataRow dr5 = dt5.NewRow();

                NPOI.SS.UserModel.ICell cell = null;
                createColumn(dt1, cell, row, dr1, 0, 1);  //输入功率标定
                createColumn(dt2, cell, row, dr2, 3, 4);  //输出功率标定
                createColumn(dt3, cell, row, dr3, 6, 7);  //反射功率标定
                createColumn(dt4, cell, row, dr4, 9, 10); //ALC功率标定

                //衰减补偿
                if (count > 3)
                {
                    continue;
                }
                createColumn(dt5, cell, row, dr5, 12, 14);
            }
            dts.Add(dt1);
            dts.Add(dt2);
            dts.Add(dt3);
            dts.Add(dt4);
            dts.Add(dt5);
            return(dts);
        }
Esempio n. 19
0
        private void InitializeComponent()
        {
            ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(ModsSelector));
            DataGridViewCellStyle    dataGridViewCellStyle    = new DataGridViewCellStyle();
            DataGridViewCellStyle    control = new DataGridViewCellStyle();

            this.gridView = new MyDataGridView();
            this.colImage = new DataGridViewImageColumn();
            this.colFile  = new DataGridViewTextBoxColumn();
            this.colDesc  = new DataGridViewTextBoxColumn();
            this.colPlay  = new DataGridViewImageColumn();
            this.colMod   = new DataGridViewComboBoxColumn();
            ((ISupportInitialize)this.gridView).BeginInit();
            base.SuspendLayout();
            componentResourceManager.ApplyResources(this.gridView, "gridView");
            this.gridView.AllowUserToAddRows       = false;
            this.gridView.AllowUserToDeleteRows    = false;
            this.gridView.AllowUserToResizeColumns = false;
            this.gridView.AllowUserToResizeRows    = false;
            this.gridView.BackgroundColor          = SystemColors.ControlLightLight;
            this.gridView.BorderStyle                 = System.Windows.Forms.BorderStyle.None;
            this.gridView.CellBorderStyle             = DataGridViewCellBorderStyle.SingleHorizontal;
            this.gridView.ClipboardCopyMode           = DataGridViewClipboardCopyMode.Disable;
            this.gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            DataGridViewColumnCollection columns = this.gridView.Columns;

            DataGridViewColumn[] dataGridViewColumnArray = new DataGridViewColumn[] { this.colImage, this.colFile, this.colDesc, this.colPlay, this.colMod };
            columns.AddRange(dataGridViewColumnArray);
            dataGridViewCellStyle.Alignment          = DataGridViewContentAlignment.MiddleLeft;
            dataGridViewCellStyle.BackColor          = SystemColors.ControlLightLight;
            dataGridViewCellStyle.Font               = new System.Drawing.Font("Segoe UI", 8.25f);
            dataGridViewCellStyle.ForeColor          = SystemColors.ControlText;
            dataGridViewCellStyle.SelectionBackColor = SystemColors.Highlight;
            dataGridViewCellStyle.SelectionForeColor = SystemColors.HighlightText;
            dataGridViewCellStyle.WrapMode           = DataGridViewTriState.False;
            this.gridView.DefaultCellStyle           = dataGridViewCellStyle;
            this.gridView.EditMode          = DataGridViewEditMode.EditOnEnter;
            this.gridView.Name              = "gridView";
            this.gridView.RowFilter         = null;
            this.gridView.RowHeadersVisible = false;
            this.gridView.SelectionMode     = DataGridViewSelectionMode.FullRowSelect;
            this.gridView.CellClick        += new DataGridViewCellEventHandler(this.gridView_CellClick);
            this.colImage.AutoSizeMode      = DataGridViewAutoSizeColumnMode.AllCells;
            this.colImage.Frozen            = true;
            componentResourceManager.ApplyResources(this.colImage, "colImage");
            this.colImage.Name        = "colImage";
            this.colFile.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.colFile.FillWeight   = 40f;
            componentResourceManager.ApplyResources(this.colFile, "colFile");
            this.colFile.Name         = "colFile";
            this.colFile.ReadOnly     = true;
            this.colFile.Resizable    = DataGridViewTriState.True;
            this.colDesc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.colDesc.FillWeight   = 60f;
            componentResourceManager.ApplyResources(this.colDesc, "colDesc");
            this.colDesc.Name             = "colDesc";
            this.colDesc.ReadOnly         = true;
            this.colDesc.Resizable        = DataGridViewTriState.True;
            this.colPlay.AutoSizeMode     = DataGridViewAutoSizeColumnMode.AllCells;
            control.Alignment             = DataGridViewContentAlignment.MiddleCenter;
            control.BackColor             = SystemColors.Control;
            control.NullValue             = componentResourceManager.GetObject("dataGridViewCellStyle1.NullValue");
            this.colPlay.DefaultCellStyle = control;
            componentResourceManager.ApplyResources(this.colPlay, "colPlay");
            this.colPlay.Image       = (Image)componentResourceManager.GetObject("colPlay.Image");
            this.colPlay.Name        = "colPlay";
            this.colMod.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.colMod.FillWeight   = 40f;
            componentResourceManager.ApplyResources(this.colMod, "colMod");
            this.colMod.Name     = "colMod";
            this.colMod.SortMode = DataGridViewColumnSortMode.Automatic;
            componentResourceManager.ApplyResources(this, "$this");
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.Controls.Add(this.gridView);
            base.Name = "ModsSelector";
            ((ISupportInitialize)this.gridView).EndInit();
            base.ResumeLayout(false);
        }
Esempio n. 20
0
        /// <summary>
        /// Выводит в DataGrid всех Клиентов из коллекции которую подавать на вход надо
        /// </summary>
        /// <param name="personsToShow"></param>
        private async void ShowPersons(IEnumerable <Person> personsToShow)
        {
            var dt = await Task.Run(() => DataBaseM.CreatePersonsTable(personsToShow, DataBaseM.GetPersonFieldsShort));

            MyDataGridView.SetSourceDataGridView(dataGridView_Persons, dt);
        }
Esempio n. 21
0
        /// <summary>
        /// 根据Control返回IMyControl接口
        /// </summary>
        /// <param name="ctl">控件</param>
        /// <returns></returns>
        private MyControls.IMyControl GetIMyControl(Control ctl)
        {
            MyControls.IMyControl ICtl = null;
            if (dictIMyControls.ContainsKey(ctl))
            {
                //如果已经存在Hash表中
                ICtl = dictIMyControls[ctl] as MyControls.IMyControl;
            }
            else
            {
                //如果不存在Hash表中

                if (ctl is Form)
                {
                    //如果是窗体
                    ICtl = new MyControls.MyForm(ctl as Form);
                }
                else if (ctl is Button)
                {
                    //如果是按钮

                    //如果是StartButton
                    //if (ctl.Tag != null && ctl.Tag is string && ctl.Tag.ToString().Equals("StartButton"))
                    //ICtl = new MyControls.MyStartButton(ctl as Button, this);
                    //else
                    ICtl = new MyControls.MyButton(ctl as Button);
                }
                else if (ctl is StatusStrip)
                {
                    //如果是状态条
                    ICtl = new MyStatusStrip(ctl as StatusStrip);
                }
                else if (ctl is ToolStrip)
                {
                    //如果是工具条
                    ICtl = new MyToolStrip(ctl as ToolStrip);
                }
                else if (ctl is DataGridView)
                {
                    //如果是DataGridView
                    ICtl = new MyDataGridView(ctl as DataGridView);
                }
                else if (ctl is HScrollBar)
                {
                    //如果是水平滚动条
                    ICtl = new MyHScrollBar(ctl as HScrollBar);
                }
                else if (ctl is VScrollBar)
                {
                    //如果是垂直滚动条
                    ICtl = new MyVScrollBar(ctl as VScrollBar);
                }

                /*
                 * else if (ctl is ProgressBar)
                 * {
                 *  //如果是进度条
                 *  ICtl = new MyControls.MyProgressBar(ctl as ProgressBar, this);
                 * }
                 * else if (ctl is ListView)
                 * {
                 *  //如果是列表
                 *  ICtl = new MyControls.MyListView(ctl as ListView, this);
                 * }
                 * else if (ctl is Label)
                 * {
                 *  //如果是Label标签
                 *  ICtl = new MyControls.MyLabel(ctl as Label, this);
                 * }
                 * else if (ctl is GroupBox)
                 * {
                 *  //如果是GroupBox
                 *  ICtl = new MyControls.MyGroupBox(ctl as GroupBox, this);
                 * }
                 * else if (ctl is TabControl)
                 * {
                 *  //如果是TabControl
                 *  ICtl = new MyControls.MyTabControl(ctl as TabControl, this);
                 * }
                 * else if (ctl is TrackBar)
                 * {
                 *  //如果是TrackBar
                 *  ICtl = new MyControls.MyTrackBar(ctl as TrackBar, this);
                 * }
                 * else if (ctl is Panel)
                 * {
                 *  //如果是面板
                 *  ICtl = new MyControls.MyPanel(ctl as Panel, this);
                 * }
                 * else if (ctl is CheckBox)
                 * {
                 *  //如果是勾选项
                 *  ICtl = new MyControls.MyCheckBox(ctl as CheckBox, this);
                 * }
                 */

                //添加到Hash表中
                if (ICtl != null)
                {
                    dictIMyControls.Add(ctl, ICtl);
                }
            }
            return(ICtl);
        }
Esempio n. 22
0
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(ModEditor));
            DataGridViewCellStyle    dataGridViewCellStyle    = new DataGridViewCellStyle();
            DataGridViewCellStyle    control = new DataGridViewCellStyle();

            this.gridViewContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.tsmiDeleteFile      = new ToolStripMenuItem();
            this.gridView            = new MyDataGridView();
            this.colEnabled          = new DataGridViewCheckBoxColumn();
            this.colSelect           = new DataGridViewButtonColumn();
            this.colFile             = new DataGridViewTextBoxColumn();
            this.colDesc             = new DataGridViewTextBoxColumn();
            this.colOpen             = new DataGridViewImageColumn();
            this.gridViewContextMenu.SuspendLayout();
            ((ISupportInitialize)this.gridView).BeginInit();
            base.SuspendLayout();
            componentResourceManager.ApplyResources(this.gridViewContextMenu, "gridViewContextMenu");
            this.gridViewContextMenu.Items.AddRange(new ToolStripItem[] { this.tsmiDeleteFile });
            this.gridViewContextMenu.Name = "gridViewContextMenu";
            componentResourceManager.ApplyResources(this.tsmiDeleteFile, "tsmiDeleteFile");
            this.tsmiDeleteFile.Image  = Images16px.Cross;
            this.tsmiDeleteFile.Name   = "tsmiDeleteFile";
            this.tsmiDeleteFile.Click += new EventHandler(this.tsmi_DeleteFile_Click);
            componentResourceManager.ApplyResources(this.gridView, "gridView");
            this.gridView.AllowUserToAddRows       = false;
            this.gridView.AllowUserToDeleteRows    = false;
            this.gridView.AllowUserToResizeColumns = false;
            this.gridView.AllowUserToResizeRows    = false;
            this.gridView.BackgroundColor          = SystemColors.ControlLightLight;
            this.gridView.BorderStyle                 = System.Windows.Forms.BorderStyle.None;
            this.gridView.CellBorderStyle             = DataGridViewCellBorderStyle.SingleHorizontal;
            this.gridView.ClipboardCopyMode           = DataGridViewClipboardCopyMode.Disable;
            this.gridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            DataGridViewColumnCollection columns = this.gridView.Columns;

            DataGridViewColumn[] dataGridViewColumnArray = new DataGridViewColumn[] { this.colEnabled, this.colSelect, this.colFile, this.colDesc, this.colOpen };
            columns.AddRange(dataGridViewColumnArray);
            this.gridView.ContextMenuStrip           = this.gridViewContextMenu;
            dataGridViewCellStyle.Alignment          = DataGridViewContentAlignment.MiddleLeft;
            dataGridViewCellStyle.BackColor          = SystemColors.ControlLightLight;
            dataGridViewCellStyle.Font               = new System.Drawing.Font("Segoe UI", 8.25f);
            dataGridViewCellStyle.ForeColor          = SystemColors.ControlText;
            dataGridViewCellStyle.SelectionBackColor = SystemColors.Highlight;
            dataGridViewCellStyle.SelectionForeColor = SystemColors.HighlightText;
            dataGridViewCellStyle.WrapMode           = DataGridViewTriState.False;
            this.gridView.DefaultCellStyle           = dataGridViewCellStyle;
            this.gridView.EditMode          = DataGridViewEditMode.EditOnEnter;
            this.gridView.Name              = "gridView";
            this.gridView.RowFilter         = null;
            this.gridView.RowHeadersVisible = false;
            this.gridView.SelectionMode     = DataGridViewSelectionMode.FullRowSelect;
            this.gridView.CellClick        += new DataGridViewCellEventHandler(this.gridView_CellClick);
            this.gridView.KeyDown          += new KeyEventHandler(this.gridView_KeyDown);
            this.colEnabled.AutoSizeMode    = DataGridViewAutoSizeColumnMode.AllCells;
            componentResourceManager.ApplyResources(this.colEnabled, "colEnabled");
            this.colEnabled.Name        = "colEnabled";
            this.colEnabled.ReadOnly    = true;
            this.colEnabled.SortMode    = DataGridViewColumnSortMode.Automatic;
            this.colSelect.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            this.colSelect.DividerWidth = 1;
            componentResourceManager.ApplyResources(this.colSelect, "colSelect");
            this.colSelect.Name = "colSelect";
            this.colSelect.Text = "...";
            this.colSelect.UseColumnTextForButtonValue = true;
            this.colFile.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.colFile.FillWeight   = 40f;
            componentResourceManager.ApplyResources(this.colFile, "colFile");
            this.colFile.Name         = "colFile";
            this.colFile.ReadOnly     = true;
            this.colFile.Resizable    = DataGridViewTriState.True;
            this.colDesc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            this.colDesc.DividerWidth = 1;
            this.colDesc.FillWeight   = 60f;
            componentResourceManager.ApplyResources(this.colDesc, "colDesc");
            this.colDesc.Name             = "colDesc";
            this.colDesc.ReadOnly         = true;
            this.colDesc.Resizable        = DataGridViewTriState.True;
            this.colOpen.AutoSizeMode     = DataGridViewAutoSizeColumnMode.AllCells;
            control.Alignment             = DataGridViewContentAlignment.MiddleCenter;
            control.BackColor             = SystemColors.Control;
            control.NullValue             = componentResourceManager.GetObject("dataGridViewCellStyle1.NullValue");
            this.colOpen.DefaultCellStyle = control;
            componentResourceManager.ApplyResources(this.colOpen, "colOpen");
            this.colOpen.Name      = "colOpen";
            this.colOpen.Resizable = DataGridViewTriState.False;
            componentResourceManager.ApplyResources(this, "$this");
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.Controls.Add(this.gridView);
            base.Name = "ModEditor";
            this.gridViewContextMenu.ResumeLayout(false);
            ((ISupportInitialize)this.gridView).EndInit();
            base.ResumeLayout(false);
        }
Esempio n. 23
0
 private void QtyPriceTBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     SetTotals(true, false);
     MyDataGridView.UpdateLayout();
 }
Esempio n. 24
0
		public void TestDisposeWhenInEditMode_Xamarin19567 ()
		{
			var dgv = new MyDataGridView ();
			dgv.EditMode = DataGridViewEditMode.EditOnEnter;
			dgv.Columns.Add ("TestColumn", "Test column");
			dgv.Columns.Add ("Column2", "Second column");
			dgv.Rows.Add ();
			dgv.Rows.Add ();
			dgv.SetCurrentCell ();

			// The Dispose() call will fail if #19567 is not fixed
			dgv.Dispose ();
		}
        /// <summary>
        /// 生成查询SQL
        /// </summary>
        /// <returns></returns>
        private string MakeSql(MyDataGridView view)
        {
            string sql = "";

            view.DataSource = null;
            view.Columns.Clear();
            DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn();

            c.DataPropertyName = "layerid";
            c.Visible          = false;
            view.Columns.Add(c);
            c = new DataGridViewTextBoxColumn();
            c.DataPropertyName = "objectid";
            c.Visible          = false;
            view.Columns.Add(c);
            c = new DataGridViewTextBoxColumn();
            c.DataPropertyName = "区域名称";
            c.HeaderText       = "区域名称";
            view.Columns.Add(c);
            foreach (TreeNode node in geomTree.Nodes)
            {
                ILayer layer = node.Tag as ILayer;
                int    row   = view.Rows.Add();
                foreach (TreeNode subnode in node.Nodes)
                {
                    if (subnode.Checked)
                    {
                        int col = -1;
                        for (int i = 0; i < view.RowCount; i++)
                        {
                            for (int j = 0; j < view.ColumnCount; j++)
                            {
                                if (view.GetGridValue(i, j).ToString() == subnode.Text)
                                {
                                    col = j;
                                    break;
                                }
                            }
                            if (col >= 0)
                            {
                                break;
                            }
                        }
                        if (col < 0)
                        {
                            DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
                            column.DataPropertyName = subnode.Text;
                            column.Tag        = "[" + subnode.Text + "]";
                            column.HeaderText = subnode.Text;
                            col = view.Columns.Add(column);
                        }
                        view.Rows[row].Cells[col].Value = subnode.Text;
                        view.Rows[row].Cells[col].Tag   = "[" + GetTableName(layer) + "].[" + subnode.Text + "]";
                    }
                }
            }
            int index = 0;

            foreach (TreeNode node in geomTree.Nodes)
            {
                bool find = false;
                foreach (TreeNode subnode in node.Nodes)
                {
                    if (subnode.Checked)
                    {
                        find = true;
                        break;
                    }
                }
                if (find)
                {
                    string      subsql = "";
                    VectorLayer layer  = node.Tag as VectorLayer;
                    for (int i = 3; i < view.ColumnCount; i++)
                    {
                        if (subsql != "")
                        {
                            subsql += ",";
                        }
                        if (view.Rows[index].Cells[i].Tag != null)
                        {
                            subsql += view.Rows[index].Cells[i].Tag.ToString() + " as " + view.Columns[i].Tag.ToString();
                        }
                        else
                        {
                            subsql += "NULL as " + view.Columns[i].Tag.ToString();
                        }
                    }
                    if (subsql != "")
                    {
                        string tablename = GetTableName(layer);
                        subsql = "select " + tablename + ".layerid," + tablename + ".objectid,isnull(t_object.name,'') as 区域名称," + subsql + " from " + tablename;
                        //subsql += " and propertydate='" + dateTimePicker1.Value.ToShortDateString() + "'";
                        GeometryProvider datasource = layer.DataSource as GeometryProvider;
                        string           values     = "";
                        foreach (Geometry geom in _ObjectsId)
                        {
                            if (datasource.Geometries.Contains(geom))
                            {
                                if (values != "")
                                {
                                    values += ",";
                                }
                                values += geom.ID;
                            }
                        }
                        if (radioButton2.Checked)
                        {
                            subsql += " left join t_object on ";
                            subsql += tablename + ".mapid=t_object.mapid ";
                            subsql += " and " + tablename + ".layerid=t_object.layerid ";
                            subsql += " and " + tablename + ".objectid=t_object.objectid ";
                            subsql += " where " + tablename + ".mapid=" + _MapId;
                            subsql += " and " + tablename + ".layerid=" + layer.ID;
                            string sdate = Common.ConvertDateToString(dateTimePicker1.Value);
                            subsql += " and " + tablename + ".propertydate='" + sdate + "'";
                            if (values != "")
                            {
                                subsql += " and " + tablename + ".objectid in (" + values + ")";
                            }
                            else
                            {
                                subsql = "";
                            }
                        }
                        else
                        {
                            subsql += " left join t_object on ";
                            subsql += tablename + ".mapid=t_object.mapid ";
                            subsql += " and " + tablename + ".layerid=t_object.layerid ";
                            subsql += " and " + tablename + ".objectid=t_object.objectid ";
                            subsql += " inner join (select mapid,layerid,objectid,max(propertydate) as propertydate from " + tablename;
                            subsql += " where " + tablename + ".mapid=" + _MapId;
                            subsql += " and " + tablename + ".layerid=" + layer.ID;
                            if (values != "")
                            {
                                subsql += " and " + tablename + ".objectid in (" + values + ")";
                                subsql += " group by mapid,layerid,objectid) t";
                                subsql += " on " + tablename + ".mapid=t.mapid";
                                subsql += " and " + tablename + ".layerid=t.layerid";
                                subsql += " and " + tablename + ".objectid=t.objectid";
                                subsql += " and " + tablename + ".propertydate=t.propertydate";
                            }
                            else
                            {
                                subsql = "";
                            }
                        }
                    }
                    if (subsql != "")
                    {
                        if (sql != "")
                        {
                            sql += "union all\r\n";
                        }
                        sql += subsql + "\r\n";
                    }
                }
                index++;
            }
            return(sql);
        }
Esempio n. 26
0
        internal unsafe void InitializeCharMap(Font font, MyDataGridView grid, int nBeginningCharacterIndex, int nRangeLength, int nCodePage, bool bIsLegacy)
        {
            grid.DefaultCellStyle.Font = font;

            // for Legacy fonts, we don't do column and row headers and we do 256 chars
            const int cnGridItems = 16;             // both row and column count
            int       nNumRows    = (nRangeLength + cnGridItems - 1) / cnGridItems;

            if (bIsLegacy)
            {
                grid.ColumnHeadersVisible = grid.RowHeadersVisible = false;
            }

            char[] achCharValues, achGlyIdxes;
            GetAllPossibleGlyphIndices(grid, font, nBeginningCharacterIndex, nRangeLength, nCodePage, bIsLegacy, out achCharValues, out achGlyIdxes);

            int nCharIndex = 0, nMaxIndex = Math.Min(achCharValues.Length, achGlyIdxes.Length);
            int jInit = nBeginningCharacterIndex % cnGridItems;             // first time thru, skip to the correct character

            for (int i = 0; (i < nNumRows) && (nCharIndex < nMaxIndex); i++)
            {
                int             nRowIndex = -1;
                DataGridViewRow theRow    = null;
                if (!bIsLegacy)
                {
                    nRowIndex = grid.Rows.Add();
                    theRow    = grid.Rows[nRowIndex];
                    theRow.HeaderCell.Value = String.Format("{0:X4}", ((nBeginningCharacterIndex / cnGridItems) * cnGridItems) + (i * cnGridItems));
                }

                for (int j = jInit; j < cnGridItems; j++)
                {
                    nCharIndex = (i * cnGridItems) + j - jInit;
                    if (nCharIndex < nMaxIndex)
                    {
                        // don't bother displaying anything if there isn't a real glyph
                        char chGlyphIndex = achGlyIdxes[nCharIndex];
                        if (chGlyphIndex != 0xFFFF)
                        {
                            // delay creating rows until they're needed (so we can skip the first two)
                            //  unless we're displaying Unicode, in which case, we *have* to show all rows
                            if (nRowIndex == -1)
                            {
                                nRowIndex = grid.Rows.Add();
                                theRow    = grid.Rows[nRowIndex];
                            }

                            // the code point for this character/glyph *is* the character index
                            char             ch    = achCharValues[nCharIndex];                 // Convert.ToChar(nCharIndex);
                            DataGridViewCell aCell = theRow.Cells[j];
                            aCell.Value = ch;
                        }
                    }
                    else
                    {
                        break;                          // break out of the loop, because we're done.
                    }
                }

                jInit = 0;                  // start at 0 on subsequent rows
            }
        }