示例#1
0
文件: EForm.cs 项目: windrobin/kumpro
        void c_MouseDown(object sender, MouseEventArgs e)
        {
            Label  label = (Label)sender;
            string text  = label.Text;
            int    i     = int.Parse(text);

            if (i < 0)
            {
                return;
            }

            if (startTabIndex < 0)
            {
                if (selec != null)
                {
                    int tiSrc = Convert.ToInt32(COMUtil.GetProperty(selec.Tag, "TabIndex"));
                    int tiDst = Convert.ToInt32(COMUtil.GetProperty(label.Tag, "TabIndex"));

                    int tiMin = Math.Min(tiSrc, tiDst);
                    int tiMax = Math.Max(tiSrc, tiDst);

                    SortedDictionary <int, Control> tab2ctrl = new SortedDictionary <int, Control>();

                    foreach (Control ctrl in panelMain.Controls)
                    {
                        if (ctrl.TabIndex > 9999)
                        {
                            continue;
                        }
                        tab2ctrl[Convert.ToInt32(COMUtil.GetProperty(ctrl.Tag, "TabIndex"))] = ctrl;
                    }

                    COMUtil.SetProperty(tab2ctrl[tiMax].Tag, "TabIndex", tiMin);
                    COMUtil.SetProperty(tab2ctrl[tiMin].Tag, "TabIndex", tiMax);

                    selec.BackColor = clrAvail;
                    selec           = null;

                    refreshTabIndex();
                }
                else
                {
                    label.BackColor = clrSel;
                    selec           = label;
                }
            }
            else
            {
                COMUtil.SetProperty(label.Tag, "TabIndex", startTabIndex);
                startTabIndex++;
                toolStripButtonIndexIndic.Text = "次インデックス=" + startTabIndex;
                refreshTabIndex();
            }
        }
示例#2
0
文件: EForm.cs 项目: windrobin/kumpro
 void refreshTabIndex()
 {
     foreach (Control ctrl in panelMain.Controls)
     {
         int tabIndex = Convert.ToInt32(COMUtil.GetProperty(ctrl.Tag, "TabIndex", -1));
         if (tabIndex < 0)
         {
             continue;
         }
         ctrl.Text     = "" + tabIndex;
         ctrl.TabIndex = tabIndex;
     }
 }
示例#3
0
文件: EForm.cs 项目: windrobin/kumpro
        void selectForm(Microsoft.Office.Interop.Access.Form form)
        {
            panelMain.Controls.Clear();
            selec = null;

            if (form.CurrentView != 0)
            {
                if (MessageBox.Show("選択されたフォームは、現在デザインビューの為に起動されていません。デザインビューに切り替えないと、変更は保存されません。\n\nいますぐ切り替えますか。", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    string name = form.Name;
                    form.Application.DoCmd.OpenForm(
                        form.Name,
                        Microsoft.Office.Interop.Access.AcFormView.acDesign,
                        null,
                        null,
                        Microsoft.Office.Interop.Access.AcFormOpenDataMode.acFormPropertySettings,
                        Microsoft.Office.Interop.Access.AcWindowMode.acWindowNormal,
                        null
                        );
                    form = form.Application.Forms[name];
                }
            }

            List <Control> box = new List <Control>();
            SortedDictionary <int, Point> sec2pos = new SortedDictionary <int, Point>();

            if (true)
            {
                Microsoft.Office.Interop.Access._Section sec;
                int si, y = 0;

                try {
                    sec         = form.get_Section(si = (int)Microsoft.Office.Interop.Access.AcSection.acHeader);
                    sec2pos[si] = new Point(0, y);
                    y          += sec.Height;
                }
                catch (COMException err) {
                    if (err.ErrorCode == -2146825826)   // {"セクション番号の指定が正しくありません。"}
                    {
                    }
                    else
                    {
                        throw;
                    }
                }

                sec         = form.get_Section(si = (int)Microsoft.Office.Interop.Access.AcSection.acDetail);
                sec2pos[si] = new Point(0, y);
                y          += sec.Height;

                try {
                    sec         = form.get_Section(si = (int)Microsoft.Office.Interop.Access.AcSection.acFooter);
                    sec2pos[si] = new Point(0, y);
                    y          += sec.Height;
                }
                catch (COMException err) {
                    if (err.ErrorCode == -2146825826)   // {"セクション番号の指定が正しくありません。"}
                    {
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            int cz = form.Controls.Count;

            for (int z = 0; z < cz; z++)
            {
                Microsoft.Office.Interop.Access.Control src = (Microsoft.Office.Interop.Access.Control)form.Controls[z];
                Point pos      = sec2pos[Convert.ToInt32(COMUtil.GetProperty(src, "Section"))];
                int   x        = Convert.ToInt32(COMUtil.GetProperty(src, "Left")) + pos.X;
                int   y        = Convert.ToInt32(COMUtil.GetProperty(src, "Top")) + pos.Y;
                int   cx       = Convert.ToInt32(COMUtil.GetProperty(src, "Width"));
                int   cy       = Convert.ToInt32(COMUtil.GetProperty(src, "Height"));
                int   tabIndex = Convert.ToInt32(COMUtil.GetProperty(src, "TabIndex", -1));
                Label c        = new Label();
                c.Location    = new Point(MeasureUtil.PosToPix(x), MeasureUtil.PosToPix(y));
                c.Size        = new Size(MeasureUtil.PosToPix(cx), MeasureUtil.PosToPix(cy));
                c.Text        = "" + tabIndex;
                c.TextAlign   = ContentAlignment.MiddleCenter;
                c.Visible     = true;
                c.BorderStyle = BorderStyle.FixedSingle;
                c.Tag         = src;
                c.TabIndex    = (tabIndex < 0) ? 10000 : tabIndex;
                c.MouseDown  += new MouseEventHandler(c_MouseDown);
                if (tabIndex >= 0)
                {
                    c.BackColor = clrAvail;
                }
                box.Insert(0, c);
            }
            panelMain.Controls.AddRange(box.ToArray());
        }