private void btAdd_Click(object sender, EventArgs e) { string factQuery; FormActions fa = new FormActions(); factQuery = "(`name`, `text`) VALUES('" + tbNameAction.Text + "', '" + tbTextAction.Text + "');"; db.Add("actions", factQuery, fa.dataGridView1); Hide(); }
public string BeginForm(string action, string controller, FormActions verb) { var form = new StringBuilder(); var url = String.Format("~/{0}/{1}", controller, action); form.AppendFormat("<form action='{0}' method='{1}'>", VirtualPathUtility.ToAbsolute(url), verb.ToString()); return(form.ToString()); }
public string Form <T>(Expression <Func <T, ActionResult> > action, FormActions verb) { var expression = (MethodCallExpression)action.Body; var function = action.Compile(); //string value = function(this.Model); var form = new StringBuilder(); var url = String.Format("~/{0}/{1}", expression.Method.ReflectedType.Name.Replace("Controller", ""), expression.Method.Name); form.AppendFormat("<form action='{0}' method='{1}'>", VirtualPathUtility.ToAbsolute(url), verb.ToString()); return(form.ToString()); }
/// <summary> /// Выполнить заданное действие /// </summary> public void PerformAction(FormActions formAction) { ExecuteAction(() => { BringToFront(); switch (formAction) { case FormActions.New: miFileNew_Click(null, null); break; case FormActions.Open: miFileOpen_Click(null, null); break; case FormActions.Save: miFileSave_Click(null, null); break; case FormActions.Cut: miEditCut_Click(null, null); break; case FormActions.Copy: miEditCopy_Click(null, null); break; case FormActions.Paste: miEditPaste_Click(null, null); break; case FormActions.Undo: miEditUndo_Click(null, null); break; case FormActions.Redo: miEditRedo_Click(null, null); break; case FormActions.Pointer: miEditPointer_Click(null, null); break; case FormActions.Delete: miEditDelete_Click(null, null); break; } }); }
// Funkce pro najiti vsech ListView na formu. iAction=0 Save, iAction=1 Load. private static void IterateControl(Control.ControlCollection ctrControls, FormActions iAction, string sFormPrefix) { foreach (Control ctrControl in ctrControls) { if (ctrControl.Controls.Count > 0) { IterateControl(ctrControl.Controls, iAction, sFormPrefix); } // Pokud je to listviw, prolezeme jeho columny a ulozime if (ctrControl.GetType().ToString() == "System.Windows.Forms.ListView") { ListView lsvListView = (ListView)ctrControl; foreach (ColumnHeader colColumn in lsvListView.Columns) { // Pokud se jedna o Load, tak nacteme, jinak ulozime if (iAction == FormActions.FormActionLoad) { //MessageBox.Show(sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString() + " = " + regKeySize.GetValue(sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString(), "80")); //MessageBox.Show(Convert.ToString(Convert.ToInt32(regKeySize.GetValue(sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString(), "80")))); //colColumn.Width = Convert.ToInt32(regKeySize.GetValue(sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString(), "80")); colColumn.Width = Convert.ToInt32(INIFiles.INI_GetSetting("Size", sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString(), "80")); } else { // Ukladame //regKeySize.SetValue(sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString(), colColumn.Width.ToString()); INIFiles.INI_SetSetting("Size", sFormPrefix + "_" + lsvListView.Name + "_column" + colColumn.Index.ToString(), colColumn.Width.ToString()); } } } else if (ctrControl.GetType().ToString() == "System.Windows.Forms.SplitContainer") { // Pretypujeme objekt na spravny SplitContainer scSplit = (SplitContainer)ctrControl; if (iAction == FormActions.FormActionLoad) { scSplit.SplitterDistance = Convert.ToInt32(INIFiles.INI_GetSetting("Size", sFormPrefix + "_" + scSplit.Name + "_distance", "20")); } else { INIFiles.INI_SetSetting("Size", sFormPrefix + "_" + scSplit.Name + "_distance", scSplit.SplitterDistance.ToString()); } } } }
/// <summary> /// Updates a control property on the UI thread. /// </summary> /// <param name="actionToTake">FormActions. Enumerates the action to take on the form UI control.</param> /// <param name="actionObject">object. The form UI control whose property is to be updated.</param> /// <param name="actionData">object. The new property value of the control to be updated.</param> private void TakeFormAction(FormActions actionToTake, object actionObject, object actionData) { try { System.Windows.Window thisForm; switch (actionToTake) { case FormActions.CloseForm: //Close conversation window thisForm = (System.Windows.Window)actionObject; thisForm.Close(); break; case FormActions.DisplayDefaultCursor: //Display the default cursor this.Cursor = Cursors.Arrow; break; case FormActions.DisplayWaitCursor: //Display the wait cursor this.Cursor = Cursors.Wait; break; case FormActions.EnableButton: //Enable the specified button ((Button)actionObject).IsEnabled = true; //((Button)actionObject).FocusVisualStyle = FocusVisualStyle. break; case FormActions.DisableButton: //Disable the specified button ((Button)actionObject).IsEnabled = false; break; case FormActions.UpdateLabel: //Update the text property of the specified label Label labelToUpdate = (Label)actionObject; labelToUpdate.Content = (string)actionData; break; case FormActions.UpdateWindowTitle: thisForm = (System.Windows.Window)actionObject; thisForm.Title = (string)actionData; break; case FormActions.ClearText: //Clear the text property of the specified text box System.Windows.Controls.TextBox textBoxToUpdate = (System.Windows.Controls.TextBox)actionObject; textBoxToUpdate.Text = string.Empty; break; case FormActions.StartTimer: _DispatcherTimer_DisplayComposing.Start(); break; case FormActions.StopTimer: _DispatcherTimer_DisplayComposing.Stop(); break; case FormActions.DisplayTypingStatus: ActivityText_Label.Content = ""; _DispatcherTimer_DisplayComposing.Start(); break; case FormActions.SetListContents: //clear and update the contents of the conversation history WebBrowser //*************************************************** //cast action data to array of object. //*************************************************** object[] actionDataArray = (object[])actionData; //*************************************************** //Get the arraylist of conversation history out of the action data array //*************************************************** ArrayList historyArray = (ArrayList)actionDataArray[1]; //*************************************************** //Get the name of the message sender out of first element of action data //*************************************************** string sender = (string)actionDataArray[0]; //*************************************************** //Get the newest message text out of the conversation history array //*************************************************** string receivedMessage = historyArray[historyArray.Count - 1].ToString(); //*************************************************** //Cast the object of action to the control type to be updated //*************************************************** WebBrowser webBrowserToUpdate = (WebBrowser)actionObject; //*************************************************** //Concatenate the previous history to the new message //*************************************************** _ConversationHistoryHtml.Insert(0, sender + receivedMessage); webBrowserToUpdate.NavigateToString(_ConversationHistoryHtml.ToString()); //*************************************************** //Update the history array to replace the newest message with //the message sender name + the newest message text. //*************************************************** string recMessage = sender + ": " + receivedMessage; historyArray.RemoveAt(historyArray.Count - 1); historyArray.Add(recMessage); break; case FormActions.SetFormBackColor: //Set the background color of the form. System.Windows.Window formToUpdate = (System.Windows.Window)actionObject; formToUpdate.Background = (Brush)actionData; break; } } catch (InvalidCastException ex) { MessageBox.Show("Invalid cast exception: " + ex.Message, "ConversationForm.TakeFormAction"); } }
/// <summary> /// Performs various application-specific functions that /// involve accessing the application's form. /// </summary> /// /// <param name="action"> a FormActions member that names the action to perform on the form</param> /// <param name="formText"> text that the form displays or the code uses for /// another purpose. Actions that don't use text ignore this parameter. </param> private void AccessForm(FormActions action, String formText) { try { // Select an action to perform on the form: switch (action) { case FormActions.AddItemToListBox: LstResults.Items.Add(formText); break; case FormActions.DisableInputReportBufferSize: cmdInputReportBufferSize.Enabled = false; break; case FormActions.EnableGetInputReportInterruptTransfer: cmdGetInputReportInterrupt.Enabled = true; break; case FormActions.EnableInputReportBufferSize: cmdInputReportBufferSize.Enabled = true; break; case FormActions.EnableSendOutputReportInterrupt: cmdSendOutputReportInterrupt.Enabled = true; break; case FormActions.ScrollToBottomOfListBox: LstResults.SelectedIndex = LstResults.Items.Count - 1; break; case FormActions.SetInputReportBufferSize: txtInputReportBufferSize.Text = formText; break; } } catch (Exception ex) { DisplayException(Name, ex); throw; } }
/// <summary> /// Enables accessing a form's controls from another thread /// </summary> /// /// <param name="action"> a FormActions member that names the action to perform on the form </param> /// <param name="textToDisplay"> text that the form displays or the code uses for /// another purpose. Actions that don't use text ignore this parameter. </param> private void MyMarshalDataToForm(FormActions action, String textToDisplay) { try { object[] args = { action, textToDisplay }; // The AccessForm routine contains the code that accesses the form. MarshalDataToForm marshalDataToFormDelegate = AccessForm; // Execute AccessForm, passing the parameters in args. Invoke(marshalDataToFormDelegate, args); } catch (Exception ex) { DisplayException(Name, ex); throw; } }
internal FormActionsBuilder(HtmlHelper <TModel> htmlHelper, FormActions formActions) : base(htmlHelper, formActions) { }
private bool CheckPermissions2(DataRow row, FormActions actionType) { if (row.GetSourceMethodNew() == SourceMethods.None) return true; var permission = row.GetLocType() == LocTypes.S ? UserStoreList[row.GetLoc()] : UserWhList[row.GetLoc()]; switch (permission) { case LocPermissionTypes.Full: { return true; } case LocPermissionTypes.Supplier: { switch (actionType) { case FormActions.Add: { return true; } case FormActions.Modify: { if (row.GetSourceMethodNew() == SourceMethods.S) return true; break; } case FormActions.Delete: { if (row.GetSourceMethodNew() == SourceMethods.S) return true; break; } case FormActions.ModifyCancel: { return true; } case FormActions.Restore: { return true; } } break; } case LocPermissionTypes.WarehouseTransit: { switch (actionType) { case FormActions.Add: { return true; } case FormActions.Modify: { return true; } case FormActions.Delete: { if (row.GetSourceMethodNew() == SourceMethods.W || row.GetSourceMethodNew() == SourceMethods.T) return true; break; } case FormActions.ModifyCancel: { return true; } case FormActions.Restore: { return true; } } break; } } return false; }
public bool DataTableSecSourceUpdateStatus(FormActions actionType, SortedSet<IL> setIL, ref SortedSet<IL> lockedIL) { var source = DataTableGet(Table.TableSecSource.Name); if (source == null) return false; var rows = new List<DataRow>(); var stateRows = new StateRows(); foreach (var il in setIL) { var row = source.Rows.Find(new[] { (object)il.Item, (object)il.Loc }); //if (row.GetLocType() == LocTypes.W && row.GetItemType() != ItemTypes.ExpendMaterial) continue; if (!CheckPermissions2(row, actionType)) { if (!lockedIL.Contains(il)) lockedIL.Add(il); continue; } var action = row.GetAction(); var measureStatus = row.GetMeasureStatus(); var measureStatusNew = row.GetMeasureStatusNew(); object actionWrite = null; object measureStatusNewWrite = null; switch (actionType) { case FormActions.Add: { measureStatusNewWrite = MeasureStatuses.InAssortment; if (measureStatus == MeasureStatuses.NotInAssortment) { if (measureStatusNew == MeasureStatuses.NotInAssortment && action == Actions.Delete) actionWrite = Actions.NoAction; else actionWrite = Actions.Leave; } else { if (measureStatusNew == MeasureStatuses.NotInAssortment) actionWrite = action == Actions.NoAction ? Actions.Leave : Actions.NoAction; else actionWrite = action; } break; } case FormActions.Delete: { measureStatusNewWrite = MeasureStatuses.NotInAssortment; if (row["DIM_ITEMLOC_SUPPLIER"] != DBNull.Value) row["DIM_ITEMLOC_SUPPLIER_NEW"] = row["DIM_ITEMLOC_SUPPLIER"]; if (row["DIM_ITEMLOC_SUPPLIER_DESC_NEW"] != DBNull.Value) row["DIM_ITEMLOC_SUPPLIER_DESC_NEW"] = row["DIM_ITEMLOC_SUPPLIER_DESC"]; if (row.GetOrderPlaceNew() != OrderPlaces.None) row["DIM_ITEMLOC_ORDERPLACE_NEW"] = row["DIM_ITEMLOC_ORDERPLACE"]; else row["DIM_ITEMLOC_ORDERPLACE_NEW"] = 3; if (row.GetSourceMethodNew() != SourceMethods.None && row.GetSourceMethodNew() == SourceMethods.T) row["DIM_ITEMLOC_SOURCEWH_NEW"] = DBNull.Value; row["DIM_ITEMLOC_SOURCEMETHOD_NEW"] = (char)SourceMethods.S; if (row["DIM_ITEMLOC_SOURCEWH"] != DBNull.Value) row["DIM_ITEMLOC_SOURCEWH_NEW"] = row["DIM_ITEMLOC_SOURCEWH"]; if (measureStatus == MeasureStatuses.InAssortment) actionWrite = Actions.Delete; else { if (measureStatusNew == MeasureStatuses.InAssortment) actionWrite = action == Actions.NoAction ? Actions.Delete : Actions.NoAction; else actionWrite = action; } break; } case FormActions.Modify: { measureStatusNewWrite = measureStatusNew; actionWrite = (action == Actions.NoAction && measureStatusNew == MeasureStatuses.InAssortment) ? Actions.Modify : action; // Cleanup SourceMethodNew if permission type is 'W' if (UserStoreList.ContainsKey(Convert.ToInt32(il.Loc))) if (UserStoreList[Convert.ToInt32(il.Loc)] == LocPermissionTypes.WarehouseTransit) if (row.GetSourceMethod() == SourceMethods.S && row.GetSourceMethodNew() == SourceMethods.S) row["DIM_ITEMLOC_SOURCEMETHOD_NEW"] = DBNull.Value; break; } case FormActions.ModifyCancel: { measureStatusNewWrite = measureStatusNew; actionWrite = action == Actions.Modify ? Actions.NoAction : action; break; } case FormActions.Restore: { measureStatusNewWrite = measureStatus; actionWrite = Actions.NoAction; row["DIM_ITEMLOC_SUPPLIER_NEW"] = row["DIM_ITEMLOC_SUPPLIER"]; row["DIM_ITEMLOC_SUPPLIER_DESC_NEW"] = row["DIM_ITEMLOC_SUPPLIER_DESC"]; row["DIM_ITEMLOC_ORDERPLACE_NEW"] = row["DIM_ITEMLOC_ORDERPLACE"]; row["DIM_ITEMLOC_SOURCEMETHOD_NEW"] = row["DIM_ITEMLOC_SOURCEMETHOD"]; row["DIM_ITEMLOC_SOURCEWH_NEW"] = row["DIM_ITEMLOC_SOURCEWH"]; break; } } // Save row state stateRows.Rows.Add(new StateRow { Item = row.GetItem(), Loc = row.GetLoc(), FieldsValuesPrevious = new List<FieldValue> { new FieldValue { Field = "ACTION", Value = (int)action }, new FieldValue { Field = "MEASURE_STATUS_NEW", Value = (int)measureStatusNew } }, FieldsValuesNext = new List<FieldValue> { new FieldValue { Field = "ACTION", Value = (int)actionWrite }, new FieldValue { Field = "MEASURE_STATUS_NEW", Value = (int)measureStatusNewWrite } } }); row["ACTION"] = (int)actionWrite; row["MEASURE_STATUS_NEW"] = (int)measureStatusNewWrite; rows.Add(row); } Steps.CreateNewState(stateRows); try { if (rows.Count > 0) { ((OracleDataAdapter)_adapters[Table.TableSecSource.Name]).Update(rows.ToArray()); DocChanged(this, new EventArgs()); } } catch (Exception ex) { Error = ex.Message; return false; } return true; }
public void ActualizarControl() { if (FormActions == null) { PanelPrimario.Controls.Clear(); PanelSecundario.Controls.Clear(); return; } this.SuspendLayout(); PanelPrimario.SuspendLayout(); PanelSecundario.SuspendLayout(); // Primero elimino los botones que ya no están en la lista foreach (Control btn in PanelPrimario.Controls) { if (btn is Lui.Forms.Button) { if (FormActions.ContainsKey(btn.Name) == false) { // No existe... lo elimino PanelPrimario.Controls.Remove(btn); btn.Dispose(); } else if (FormActions[btn.Name].Visibility != Lazaro.Pres.Forms.FormActionVisibility.Main) { // Existe... pero no en el panel primario PanelPrimario.Controls.Remove(btn); btn.Dispose(); } } } foreach (Control btn in PanelSecundario.Controls) { if (btn is Lui.Forms.Button) { if (FormActions.ContainsKey(btn.Name) == false) { // No existe... lo elimino PanelSecundario.Controls.Remove(btn); btn.Dispose(); } else if (FormActions[btn.Name].Visibility != Lazaro.Pres.Forms.FormActionVisibility.Secondary) { // Existe... pero no en el panel secundario PanelSecundario.Controls.Remove(btn); btn.Dispose(); } } } int PrimaryWidth = 0, SecondaryWidth = 0; // Ordeno por TabIndex this.FormActions.Sort(delegate(Lazaro.Pres.Forms.FormAction itm, Lazaro.Pres.Forms.FormAction itm2) { return(itm.TabIndex.CompareTo(itm2.TabIndex)); }); int IdxPri = 0, IdxSec = 0; // Ahora agrego o actualizo los botones existentes foreach (Lazaro.Pres.Forms.FormAction act in this.FormActions) { // Me fijo en que panel va FlowLayoutPanel Panel; if (act.Visibility == Lazaro.Pres.Forms.FormActionVisibility.Main) { Panel = this.PanelPrimario; } else if (act.Visibility == Lazaro.Pres.Forms.FormActionVisibility.Secondary) { Panel = this.PanelSecundario; } else { Panel = null; } if (Panel != null) { Lui.Forms.Button Btn; if (Panel.Controls.ContainsKey(act.Name)) { // Existe, lo actualizo Btn = Panel.Controls[act.Name] as Lui.Forms.Button; } else { // No existe, lo agrego Btn = new Lui.Forms.Button(); Btn.Margin = new System.Windows.Forms.Padding(6, 0, 0, 0); Btn.Name = act.Name; Btn.Size = new System.Drawing.Size(116, Panel.ClientRectangle.Height); Btn.Visible = true; Btn.Click += new EventHandler(this.Btn_Click); Panel.Controls.Add(Btn); } Btn.Text = act.Text; Btn.Subtext = act.SubText; if (act.SubText == null) { Btn.SubLabelPos = SubLabelPositions.None; } else { Btn.SubLabelPos = SubLabelPositions.Bottom; } Btn.Enabled = act.Enabled; Btn.TabIndex = act.TabIndex; if (Panel == this.PanelPrimario) { Panel.Controls.SetChildIndex(Btn, IdxPri++); } else { Panel.Controls.SetChildIndex(Btn, IdxSec++); } if (act.Visibility == Lazaro.Pres.Forms.FormActionVisibility.Main) { PrimaryWidth += Btn.Width + Btn.Margin.Left + Btn.Margin.Right; } else if (act.Visibility == Lazaro.Pres.Forms.FormActionVisibility.Secondary) { SecondaryWidth += Btn.Width + Btn.Margin.Left + Btn.Margin.Right; } } } PanelPrimario.Width = PrimaryWidth + 8; PanelSecundario.Width = SecondaryWidth + 8; PanelSecundario.ResumeLayout(true); PanelPrimario.ResumeLayout(true); this.ResumeLayout(true); }
private void pictureBox1_Click(object sender, EventArgs e) { FormActions.ExitApplication(); }
public FormActionEventArgs(FormActions action, string textToDisplay) { Action = action; TextToDisplay = textToDisplay; }
public void ActualizarControl() { if (FormActions == null) { PanelPrimario.Controls.Clear(); return; } this.SuspendLayout(); PanelPrimario.SuspendLayout(); // Primero elimino los botones que ya no están en la lista foreach (System.Windows.Forms.Control btn in PanelPrimario.Controls) { if (btn is Lui.Forms.LinkLabel) { if (FormActions.ContainsKey(btn.Name) == false) { // No existe... lo elimino PanelPrimario.Controls.Remove(btn); btn.Dispose(); } else if (FormActions[btn.Name].Visibility != Lazaro.Pres.Forms.FormActionVisibility.Tertiary) { // Existe... pero no en el panel terciario PanelPrimario.Controls.Remove(btn); btn.Dispose(); } } } // Ahora agrego o actualizo los botones existentes foreach (Lazaro.Pres.Forms.FormAction act in this.FormActions) { if (act.Visibility == Lazaro.Pres.Forms.FormActionVisibility.Tertiary) { if (PanelPrimario.Controls.ContainsKey(act.Name)) { // Existe, lo actualizo Lui.Forms.LinkLabel Btn = PanelPrimario.Controls[act.Name] as Lui.Forms.LinkLabel; Btn.Text = act.Text; Btn.Enabled = act.Enabled; } else { // No existe, lo agrego Lui.Forms.LinkLabel Btn = new Lui.Forms.LinkLabel(); Btn.Margin = new System.Windows.Forms.Padding(4, 0, 0, 0); Btn.Name = act.Name; Btn.Text = act.Text; Btn.Enabled = act.Enabled; Btn.TabIndex = act.TabIndex; Btn.AutoSize = true; //Btn.Size = new System.Drawing.Size(96, PanelPrimario.ClientRectangle.Height); Btn.Visible = true; Btn.LinkClicked += new LinkLabelLinkClickedEventHandler(this.Btn_LinkClicked); PanelPrimario.Controls.Add(Btn); } } } PanelPrimario.ResumeLayout(true); this.ResumeLayout(true); }
public FormActionsBuilder <TModel> Begin(FormActions formActions) { return(new FormActionsBuilder <TModel>(Html, formActions)); }
private void btActions_Click(object sender, EventArgs e) { FormActions fa = new FormActions(); fa.ShowDialog(); }