Example #1
0
        /// <summary>
        /// Refresh Button OnClick Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RefreshClick(object sender, EventArgs e)
        {
            ToolStripButton  button = sender as ToolStripButton;
            ComponentToolbar tool   = null;

            if (button == null)
            {
                tool = sender as ComponentToolbar;
            }
            else
            {
                tool = button.GetCurrentParent() as ComponentToolbar;
            }

            string    sql       = (tool.DataGrid.DataSource as DataTable).Namespace;
            string    tablename = (tool.DataGrid.DataSource as DataTable).TableName;
            DataTable dt        = DBHelper.GetDataTable(sql);

            dt.Namespace             = sql;
            dt.TableName             = tablename;
            tool.DataGrid.DataSource = dt;

            if (dt != null && dt.Rows.Count > 0)
            {
                tool.DataGrid.Rows[0].Cells[0].Selected = true;
                CommonCellClick(tool.DataGrid, new DataGridViewCellEventArgs(0, 0));
            }
        }
Example #2
0
        /// <summary>
        /// Edit Button OnClick Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditClick(object sender, EventArgs e)
        {
            ToolStripButton button = sender as ToolStripButton;

            ComponentToolbar  tool = null;
            ComponentDataGrid grid = null;

            if (button != null)
            {
                tool = button.GetCurrentParent() as ComponentToolbar;
                grid = tool.DataGrid;
            }
            else
            {
                grid = sender as ComponentDataGrid;
            }

            var rows = grid.SelectedRows;

            if (rows == null || rows.Count == 0)
            {
                MessageBox.Show("当前没有可以编辑的数据!", "title", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            frmModule form = new frmModule(grid, true);

            form.atRefresh = RefreshClick;
            form.InitializeData();
            form.ShowDialog();
        }
Example #3
0
        public void LoadAssembly(ToolStripButton Button, Action <object, EventArgs> Refresh, string FullName)
        {
            Assembly assembly = Assembly.LoadFrom(_msfileName);

            Type type = assembly.GetType(FullName);

            if (type == null)
            {
                return;
            }

            object obj = Activator.CreateInstance(type);

            if (obj == null)
            {
                return;
            }

            if (obj is ComponentToolBarPlugins)
            {
                ComponentToolbar toolbar = Button.GetCurrentParent() as ComponentToolbar;

                ComponentToolBarPlugins abPlugin = obj as ComponentToolBarPlugins;
                abPlugin.DataGrid        = toolbar.DataGrid;
                abPlugin.User            = GlobalInvariant.User;
                abPlugin.RefreshDataGrid = Refresh;

                abPlugin.OnActivated();
            }
        }
Example #4
0
        private void filterFormaNazadKlik(object sender, EventArgs e)
        {
            ToolStripButton button = (ToolStripButton)sender;
            Form            f      = (Form)button.GetCurrentParent().Parent;

            f.Hide();
            BringToFront();
        }
Example #5
0
        /// <summary>
        /// Add Button OnClick Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddClick(object sender, EventArgs e)
        {
            ToolStripButton  button = sender as ToolStripButton;
            ComponentToolbar tool   = button.GetCurrentParent() as ComponentToolbar;
            var grid = tool.DataGrid;

            frmModule form = new frmModule(grid);

            form.atRefresh = RefreshClick;
            form.InitializeData();
            form.ShowDialog();
        }
Example #6
0
        public static void RadioCheck(this ToolStripButton tsb)
        {
            ToolStrip parent = tsb.GetCurrentParent();

            foreach (ToolStripButton tsbParent in parent.Items.OfType <ToolStripButton>())
            {
                if (tsbParent != tsb)
                {
                    tsbParent.Checked = false;
                }
            }

            tsb.Checked = true;
        }
        /// <summary>
        /// ToolStripButton 有設定 CheckOnClick 屬性為 true 的按鈕們,當 任一按鈕 Checked 時,其他按鈕 unChecked
        /// </summary>
        /// <param name="sender"></param>
        private void setSingleToolStripButtonOn(ToolStripButton button, ToolStripButton[] excludeButtons)
        {
            if (button.Checked)
            {
                var checkOnClickItems = button.GetCurrentParent().Items.OfType <ToolStripButton>()
                                        .Where(p => p.CheckOnClick == true && !p.Equals(button));
                if (excludeButtons != null)
                {
                    checkOnClickItems = checkOnClickItems.Where(p => !excludeButtons.Contains(p));
                }

                foreach (ToolStripButton checkOnClickToolStrip in checkOnClickItems)
                {
                    checkOnClickToolStrip.Checked = false;
                }
            }
        }
Example #8
0
        public void EndInit()
        {
            if (!this.DesignMode)
            {
                IEnumerator iter = m_ComandsTable.Keys.GetEnumerator();
                while (iter.MoveNext() && iter.Current != null)
                {
                    if (iter.Current is ToolStripMenuItem)
                    {
                        ToolStripMenuItem item = (ToolStripMenuItem)(iter.Current);
                        item.Paint += new PaintEventHandler(item_Paint);
                        switch ((MfcCommand)m_ComandsTable[iter.Current])
                        {
                        case MfcCommand.APP_EXIT:
                        case MfcCommand.FILE_CLOSE:
                        case MfcCommand.WINDOW_ARRANGE:
                        case MfcCommand.WINDOW_CASCADE:
                        case MfcCommand.WINDOW_TILE_HORZ:
                        case MfcCommand.WINDOW_TILE_VERT:
                        case MfcCommand.VIEW_TOOLBAR:
                        case MfcCommand.FILE_PRINT_PREVIEW:
                            item.Click += new EventHandler(InternalCmdHandler);
                            break;

                        default:
                            item.Click += new EventHandler(OnClick);
                            break;
                        }
                    }
                    else if (iter.Current is ToolStripButton)
                    {
                        ToolStripButton button = (ToolStripButton)iter.Current;

                        if (m_ToolStrip == null)
                        {
                            // init UpdateUI event for ToolStrip
                            Application.Idle += new EventHandler(OnUpdateUI);

                            m_ToolStrip = button.GetCurrentParent();
                        }
                        button.Click += new EventHandler(OnClick);
                    }
                }
            }
        }
Example #9
0
 private void  除DToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     {
         FavSiteurl siteurl = (FavSiteurl)contextMenuStrip1.Tag;
         Mdb.DeleteSiteurl(siteurl.id);
         if ((siteurl.tag as ToolStripMenuItem) == null)
         {
             ToolStripButton button = (ToolStripButton)siteurl.tag;
             button.GetCurrentParent().Items.Remove(button);
         }
         else
         {
             ToolStripMenuItem item = (ToolStripMenuItem)siteurl.tag;
             item.GetCurrentParent().Items.Remove(item);
         }
     }
 }
Example #10
0
        private void tsBtn_Click(object sender, MouseEventArgs e)
        {
            ToolStripButton tsBtn = sender as ToolStripButton;

            tsBtn.Checked = true;

            foreach (ToolStripButton abtn in tsBtn.GetCurrentParent().Items)
            {
                if (!abtn.Equals(tsBtn))
                {
                    abtn.Checked = false;
                }
            }

            if (tsBtn.Equals(this.mTsBtnSqlWindow))
            {
                frmSQLWindow window = new frmSQLWindow();
                window.Tag = Common.Definition.ConstValue.DBViewerFormType.SqlWindow;

                this.ShowFormORClose(window);
            }
            else if (tsBtn.Equals(this.mTsBtnSchemaBrowser))
            {
                frmSchemaBrowser browser = new frmSchemaBrowser();
                browser.Tag = Common.Definition.ConstValue.DBViewerFormType.SchemaBrowser;

                this.ShowFormORClose(browser);
            }
            else if (tsBtn.Equals(this.mTsBtnSessionView))
            {
                frmSessionView sessionView = new frmSessionView();
                sessionView.Tag = Common.Definition.ConstValue.DBViewerFormType.SessionViewer;

                this.ShowFormORClose(sessionView);
            }
            else if (tsBtn.Equals(this.mTsBtnTableSpaceView))
            {
                frmTableSpaceView tableSpaceView = new frmTableSpaceView();
                tableSpaceView.Tag = Common.Definition.ConstValue.DBViewerFormType.TableSpaceViewer;

                this.ShowFormORClose(tableSpaceView);
            }
        }
Example #11
0
        private void SaveRaw(object sender, EventArgs e)
        {
            ToolStripButton toolStripButton = (ToolStripButton)sender;
            Form            form            = toolStripButton.GetCurrentParent().FindForm();
            // Call the save file dialog to enter the file name of the image
            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter           = "XML files(*.xml) | *.xml";
            saveFileDialog1.FilterIndex      = 1;
            saveFileDialog1.RestoreDirectory = true;

            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                using (Mat mat = new Mat()) {
                    switch (form.Text)
                    {
                    case "CamView2":                             //rawData.Save(saveFileDialog1.FileName);
                        rawData.CopyTo(mat);
                        break;

                    case "PhaseView":                             //phFo.Save(saveFileDialog1.FileName);
                        phFo.CopyTo(mat);
                        break;

                    case "FTView1":                             //magT.Save(saveFileDialog1.FileName);
                        magT.CopyTo(mat);
                        break;

                    case "IntensityView":                             //magFo.Save(saveFileDialog1.FileName);
                        magFo.CopyTo(mat);
                        break;

                    default:
                        MessageBox.Show("A Error has occur");
                        break;
                    }
                    //XML saving supported only by this
                    using (FileStorage fs = new FileStorage(saveFileDialog1.FileName, FileStorage.Mode.Write)) {
                        fs.Write(mat, "top");
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        /// Delete Button OnClick Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteClick(object sender, EventArgs e)
        {
            ToolStripButton  button = sender as ToolStripButton;
            ComponentToolbar tool   = button.GetCurrentParent() as ComponentToolbar;
            var grid = tool.DataGrid;

            var rows = grid.SelectedRows;

            if (rows == null || rows.Count == 0)
            {
                MessageBox.Show("当前没有可以删除的数据!", "title", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DialogResult dr = MessageBox.Show($"是否删除选中的{rows.Count}行", "title", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                int iIndex = rows[0].Index;

                // List<DataGridViewRow> lisRow = new List<DataGridViewRow>();

                List <string> lisStr = new List <string>(rows.Count);

                foreach (DataGridViewRow row in rows)
                {
                    var rowDelete = row.DataBoundItem as DataRowView;
                    rowDelete.Delete();
                    lisStr.Add($@"delete from {(grid.DataSource as DataTable).TableName} where fid ={(int)rowDelete["fid"]}");
                }

                DBHelper.RunSql(lisStr, CommandType.Text, null);

                //删除后自动点击
                if (grid.RowCount == iIndex && grid.RowCount != 0)
                {
                    int rowIndex = iIndex - 1;
                    grid.Rows[rowIndex].Selected = true;
                    CommonCellClick(grid, new DataGridViewCellEventArgs(0, rowIndex));
                }
            }
        }
        /// <summary>
        /// Отжимание всех кнопок кроме заданной
        /// </summary>
        /// <param name="strip">Панель, на которой нужно отжать кнопки</param>
        /// <param name="button">Кнопка, которую оставить нажатой</param>
        /// <remarks>Если кнопка задана, то отжимаются все кнопки на панели кроме неё. Если не задана, то все кнопки панели</remarks>
        public static void UncheckButtons(this ToolStrip strip, ToolStripButton button = null)
        {
            //Кнопка не на панели
            if (button != null && !strip.Items.Contains(button))
            {
                throw new ArgumentException("Кнопка должна находиться на панели!");
            }
            var toolStripButtons = button != null
                ? button.GetCurrentParent()
                                   .Items.OfType <ToolStripButton>()
                                   .Where(b => b.CheckOnClick && !b.Equals(button))
                : strip.Items
                                   .OfType <ToolStripButton>()
                                   .Where(b => b.CheckOnClick);

            foreach (var btn in toolStripButtons)
            {
                btn.Checked = false;
            }
        }
Example #14
0
            protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
            {
                ToolStripButton tsBtn = e.Item as ToolStripButton;

                if (tsBtn != null && tsBtn.Checked)
                {
                    foreach (ToolStripButton btn in tsBtn.GetCurrentParent().Items)
                    {
                        if (!btn.Equals(tsBtn))
                        {
                            btn.Invalidate();
                        }
                    }

                    e.Graphics.DrawRectangle(Pens.Black, 0, 0, e.Item.Size.Width - 1, e.Item.Size.Height - 1);
                }
                else
                {
                    base.OnRenderButtonBackground(e);
                }
            }
        private static PropertyGrid getPropertyGridParent(object sender)
        {
            PropertyGrid    propertyGrid    = null;
            ToolStripButton toolStripButton = sender as ToolStripButton;

            // ToolStripButton -> ToolStrip -> PropertyGrid
            if (toolStripButton != null)
            {
                ToolStrip toolStrip = toolStripButton.GetCurrentParent() as ToolStrip;

                if (toolStrip != null)
                {
                    propertyGrid = toolStrip.Parent as PropertyGrid;

                    if (propertyGrid != null)
                    {
                        propertyGrid.CollapseAllGridItems();
                    }
                }
            }
            return(propertyGrid);
        }
Example #16
0
        public static Point GetControlLocation(ToolStripButton toolStripButton)
        {
            var point = new Point(toolStripButton.Bounds.X + toolStripButton.Width, toolStripButton.Bounds.Y);

            return(toolStripButton.GetCurrentParent().PointToScreen(point));
        }
 private Form GetParentForm(ToolStripButton thisToolStripButton)
 {
     return(GetParentForm(thisToolStripButton.GetCurrentParent()));
 }
 private Form GetParentForm(ToolStripButton thisToolStripButton)
 {
   return GetParentForm(thisToolStripButton.GetCurrentParent());
 }