/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnIcon_Click(object sender, EventArgs e) { FrmAd_NewButton_Icon fni = new FrmAd_NewButton_Icon(); fni.ShowDialog(); if (!string.IsNullOrEmpty(frmAd_NewButton.iconName)) { btnIcon.Image = OleCreateConverter.PictureDispToImage(Globals.ThisAddIn.Application.CommandBars.GetImageMso(frmAd_NewButton.iconName, frmAd_NewButton.size, frmAd_NewButton.size)); this.btnIcon.Text = ""; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tbButtonName_SelectedIndexChanged(object sender, EventArgs e) { KeyValuePair <string, string> obj = (KeyValuePair <string, string>) this.tbButtonName.SelectedItem; listBox1.Items.Clear(); DataTable dt = new DataTable(); try { dt = ft.GetProcessMacroFromDB(cbTemplateName.SelectedValue.ToString(), obj.Key); } catch { } if (obj.Value == "-1") { #region -1 means 'New Button' btnDelete.Visible = false; btnCNB_Create.Text = "Create New Action"; tbButtonName.Visible = false; tbNewButton.Location = new System.Drawing.Point(106, 59); tbNewButton.Size = new System.Drawing.Size(194, 21); tbNewButton.Name = "TB"; tbNewButton.Visible = true; tbNewButton.Text = ""; this.groupBox3.Controls.Add(tbNewButton); textBox1.Text = "Display in action's SuperTip ,Click here!"; #endregion } else if (obj.Value == "-2") { btnDelete.Visible = false; btnCNB_Create.Text = "Create New Action"; tbButtonName.Visible = true; tbNewButton.Visible = false; textBox1.Text = "Display in action's SuperTip ,Click here!"; } else if (obj.Value != "-1" && obj.Value != "-2") { #region !=-1 and !=-2 means user has choose an exist button btnDelete.Visible = true; btnCNB_Create.Text = "Update Action"; tbButtonName.Visible = true; tbNewButton.Visible = false; if (dt.Rows.Count > 0) { string text = dt.Rows[0]["ButtonText"].ToString(); //ft.GetButtonNameTextFromDB(obj.Key, cbTemplateName.SelectedValue.ToString());//text = text.Substring(text.IndexOf(",,,") + 3, text.Length - text.IndexOf(",,,") - 3); this.textBox1.Text = text; bool?stop = bool.Parse(dt.Rows[0]["StopOnError"].ToString()); //ft.GetButtonStopOnError(obj.Key, cbTemplateName.SelectedValue.ToString()); bool?showmsg = bool.Parse(dt.Rows[0]["ShowMsg"].ToString()); chkStop.Checked = (bool)stop; cbMsg.Checked = (bool)showmsg; string buttonIcon = dt.Rows[0]["ButtonIcon"].ToString();//ft.GetButtonIcon(obj.Key, cbTemplateName.SelectedValue.ToString());//string buttonIcon = buttonIconAndSize.Substring(0, buttonIconAndSize.IndexOf(",,,")); int buttonSize = int.Parse(dt.Rows[0]["ButtonSize"].ToString()); btnIcon.Image = OleCreateConverter.PictureDispToImage(Globals.ThisAddIn.Application.CommandBars.GetImageMso(buttonIcon, buttonSize, buttonSize)); this.btnIcon.Text = ""; frmAd_NewButton.iconName = buttonIcon; frmAd_NewButton.size = buttonSize; this.btnGroup.Text = dt.Rows[0]["ButtonGroup"].ToString(); GroupName = btnGroup.Text; GroupOrder = int.Parse(dt.Rows[0]["GroupOrder"].ToString()); ButtonOrder = int.Parse(dt.Rows[0]["ButtonOrder"].ToString());//ft.GetButtonOrder(obj.Key, cbTemplateName.SelectedValue.ToString()).Value; } #endregion } #region initialize button's process and List <KeyValuePair <string, string> > tbProcessMacros = new List <KeyValuePair <string, string> >(); for (int i = 0; i < dt.Rows.Count; i++) { string processMacroNameType = dt.Rows[i]["Type"].ToString(); string processMacroName = dt.Rows[i]["ProcessID"].ToString(); string[] sArray = System.Text.RegularExpressions.Regex.Split(processMacroName, ","); if (processMacroNameType == "1" || processMacroNameType == "2" || processMacroNameType == "3") { listBox1.Items.Add(new KeyValuePair <string, string>(sArray[1], sArray[2] + ",Output Process")); } else if (processMacroNameType == "6") { listBox1.Items.Add(new KeyValuePair <string, string>("Re-open template", "Output Process")); } else if (processMacroNameType == "4") { processMacroName = "Save"; string Ref = dt.Rows[i]["Reference"].ToString().Replace(" ", ""); listBox1.Items.Add(new KeyValuePair <string, string>(processMacroName, Ref + ",Save")); } else if (processMacroNameType == "7") { processMacroName = "Save PDF"; string Ref = dt.Rows[i]["Reference"].ToString().Replace(" ", ""); listBox1.Items.Add(new KeyValuePair <string, string>(processMacroName, Ref + ",Save PDF")); } else if (processMacroNameType == "5") { processMacroName = dt.Rows[i]["MacroName"].ToString(); listBox1.Items.Add(new KeyValuePair <string, string>(processMacroName, "Output Macro")); } } #endregion BindGroups(obj.Key); }