Beispiel #1
0
 /// <summary>
 /// Creates a setup object for a standard numeric-text control.
 /// </summary>
 /// <param name="displaySetup"></param>
 /// <param name="classes">The classes on the control.</param>
 /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param>
 /// <param name="autoFillTokens">A list of auto-fill detail tokens (see
 /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill
 /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param>
 /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action.</param>
 /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param>
 /// <param name="pageModificationValue"></param>
 /// <param name="numericPageModificationValue"></param>
 /// <param name="validationPredicate"></param>
 /// <param name="validationErrorNotifier"></param>
 public static NumericTextControlSetup Create(
     DisplaySetup displaySetup          = null, ElementClassSet classes = null, string placeholder = "", string autoFillTokens = "",
     SpecifiedValue <FormAction> action = null, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue           = null,
     PageModificationValue <long?> numericPageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null)
 {
     return(new NumericTextControlSetup(
                new TextControlSetup(
                    displaySetup,
                    "text",
                    null,
                    null,
                    false,
                    classes,
                    false,
                    true,
                    placeholder,
                    autoFillTokens,
                    null,
                    null,
                    action,
                    null,
                    valueChangedAction,
                    pageModificationValue,
                    numericPageModificationValue,
                    validationPredicate,
                    validationErrorNotifier),
                validationErrorNotifier));
 }
        private ElementActivationBehavior(ResourceInfo resource = null, FormAction action = null, string script = "")
        {
            if (action == null && !script.Any())
            {
                HyperlinkBehavior hyperlinkBehavior = resource;

                Classes               = hyperlinkBehavior.HasDestination ? ActivatableClass : ElementClassSet.Empty;
                AttributeGetter       = () => hyperlinkBehavior.AttributeGetter(true);
                IncludesIdAttribute   = () => hyperlinkBehavior.IncludesIdAttribute(true);
                EtherealChildren      = hyperlinkBehavior.EtherealChildren;
                JsInitStatementGetter = id => hyperlinkBehavior.JsInitStatementGetter(id, true);
                IsFocusable           = hyperlinkBehavior.IsFocusable;
                PostBackAdder         = hyperlinkBehavior.PostBackAdder;
            }
            else
            {
                var buttonBehavior = action != null ? (ButtonBehavior) new FormActionBehavior(action) : new CustomButtonBehavior(() => script + ";");

                Classes               = ActivatableClass;
                AttributeGetter       = () => buttonBehavior.GetAttributes().Materialize();
                IncludesIdAttribute   = buttonBehavior.IncludesIdAttribute;
                EtherealChildren      = buttonBehavior.GetEtherealChildren();
                JsInitStatementGetter = buttonBehavior.GetJsInitStatements;
                IsFocusable           = true;
                PostBackAdder         = buttonBehavior.AddPostBack;
            }
        }
Beispiel #3
0
 public MenuItem(string name, string description, FormAction action, MenuForm parent)
 {
     ItemName        = name;
     ItemDescription = description;
     ItemAction      = action;
     ItemParent      = parent;
 }
 private bool AnyValues()
 {
     return(BaseUri.Any() || DefaultSrc.Any() || ScriptSrc.Any() || ObjectSrc.Any() ||
            StyleSrc.Any() || ImgSrc.Any() || MediaSrc.Any() || FrameSrc.Any() ||
            ChildSrc.Any() || FrameAncestors.Any() || FontSrc.Any() || ConnectSrc.Any() ||
            ManifestSrc.Any() || FormAction.Any());
 }
Beispiel #5
0
        /// <summary>
        /// Creates a text box.
        /// </summary>
        /// <param name="value">Do not pass null.</param>
        /// <param name="rows">The number of rows in the text box.</param>
        /// <param name="masksCharacters">Pass true to mask characters entered in the text box. Has no effect when there is more than one row in the text box.
        /// </param>
        /// <param name="maxLength">The maximum number of characters that can be entered in this text box.</param>
        /// <param name="readOnly">Pass true to prevent the contents of the text box from being changed.</param>
        /// <param name="disableBrowserAutoComplete">If true, prevents the browser from displaying values the user previously entered. Keep in mind that there is
        /// currently an "arms race" taking place over forms auto-complete. Banks and other "high-security" organizations keep looking for ways to disable
        /// auto-complete on their login forms while browsers and password managers are always trying to preserve this functionality for their users. Because of
        /// this war, it's possible that your request to disable auto-complete will be ignored. See http://stackoverflow.com/a/23234498/35349 for more information.
        /// </param>
        /// <param name="suggestSpellCheck">By default, Firefox does not spell check single-line text boxes. By default, Firefox does spell check multi-line text
        /// boxes. Setting this parameter to a value will set the spellcheck attribute on the text box to enable/disable spell checking, if the user agent supports
        /// it.</param>
        /// <param name="action">The action that will be performed when the user hits Enter on the text box or selects an auto-complete item.</param>
        /// <param name="autoPostBack">Pass true to cause an action when the text box loses focus.</param>
        public EwfTextBox(
            string value, int rows = 1, bool masksCharacters = false, int?maxLength    = null, bool readOnly = false, bool disableBrowserAutoComplete = false,
            bool?suggestSpellCheck = null, FormAction action = null, bool autoPostBack = false)
        {
            this.rows                       = rows;
            this.masksCharacters            = masksCharacters;
            this.maxLength                  = maxLength;
            this.readOnly                   = readOnly;
            this.disableBrowserAutoComplete = disableBrowserAutoComplete;
            this.suggestSpellCheck          = suggestSpellCheck;

            if (value == null)
            {
                throw new ApplicationException("You cannot create a text box with a null value. Please use the empty string instead.");
            }
            formValue = new FormValue <string>(
                () => value,
                () => this.IsOnPage() ? UniqueID : "",
                v => v,
                rawValue =>
                rawValue != null && (!readOnly || rawValue == formValue.GetDurableValue())
                                        ? PostBackValueValidationResult <string> .CreateValid(rawValue)
                                        : PostBackValueValidationResult <string> .CreateInvalid());

            this.action       = action ?? FormState.Current.DefaultAction;
            this.autoPostBack = autoPostBack;
        }
Beispiel #6
0
        /// <summary>
        /// Creates an in-line radio button that is part of the group.
        /// </summary>
        public EwfCheckBox CreateInlineRadioButton(
            bool isSelected, string label = "", FormAction action = null, bool autoPostBack = false, PageModificationValue <bool> pageModificationValue = null)
        {
            EwfCheckBox checkBox = null;

            checkBox = new EwfCheckBox(
                formValue,
                label,
                action,
                () =>
                checkBoxesAndSelectionStatesAndPageModificationValues.Where(i => i.Item3 != null)
                .Select(i => i.Item3.GetJsModificationStatements(i.Item1 == checkBox ? "true" : "false")))
            {
                AutoPostBack = autoPostBack
            };
            checkBoxesAndSelectionStatesAndPageModificationValues.Add(
                Tuple.Create <CommonCheckBox, bool, PageModificationValue <bool> >(checkBox, isSelected, pageModificationValue));

            if (pageModificationValue != null)
            {
                formValue.AddPageModificationValue(pageModificationValue, value => value == checkBox);
            }

            return(checkBox);
        }
        internal static void AddCheckBoxAttributes(
            WebControl checkBoxElement, Control checkBox, FormValue <bool> checkBoxFormValue, FormValue <CommonCheckBox> radioButtonFormValue, string radioButtonListItemId,
            FormAction action, bool autoPostBack, IEnumerable <string> onClickJsMethods)
        {
            checkBoxElement.Attributes.Add("type", checkBoxFormValue != null ? "checkbox" : "radio");
            checkBoxElement.Attributes.Add("name", checkBoxFormValue != null ? checkBox.UniqueID : ((FormValue)radioButtonFormValue).GetPostBackValueKey());
            if (radioButtonFormValue != null)
            {
                checkBoxElement.Attributes.Add("value", radioButtonListItemId ?? checkBox.UniqueID);
            }
            if (checkBoxFormValue != null
                                    ? checkBoxFormValue.GetValue(AppRequestState.Instance.EwfPageRequestState.PostBackValues)
                                    : radioButtonFormValue.GetValue(AppRequestState.Instance.EwfPageRequestState.PostBackValues) == checkBox)
            {
                checkBoxElement.Attributes.Add("checked", "checked");
            }

            SubmitButton.EnsureImplicitSubmissionAction(checkBoxElement, action, false);
            var isSelectedRadioButton = radioButtonFormValue != null &&
                                        radioButtonFormValue.GetValue(AppRequestState.Instance.EwfPageRequestState.PostBackValues) == checkBox;
            var postBackScript = autoPostBack && !isSelectedRadioButton?action.GetJsStatements() : "";

            var customScript = StringTools.ConcatenateWithDelimiter("; ", onClickJsMethods.ToArray());

            checkBoxElement.AddJavaScriptEventScript(JsWritingMethods.onclick, StringTools.ConcatenateWithDelimiter("; ", postBackScript, customScript));
        }
        /// <summary>
        /// Creates a date picker.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="action">The action that will be performed when the user hits Enter on the date picker.</param>
        public DatePicker(DateTime?value, FormAction action = null)
        {
            this.value  = value.HasValue ? value.Value.Date as DateTime? : null;
            this.action = action;

            dataModifications = FormState.Current.DataModifications;
        }
Beispiel #9
0
        /// <summary>
        /// Creates a form item with a change based check box list, which is a check box list that is based on changes to the selections rather than the absolute
        /// set of selected items.
        /// </summary>
        /// <typeparam name="ItemIdType"></typeparam>
        /// <param name="label"></param>
        /// <param name="items"></param>
        /// <param name="selectedItemIds"></param>
        /// <param name="modificationMethod">A method that executes the change handlers of the items that were selected or deselected on this post back.</param>
        /// <param name="caption"></param>
        /// <param name="includeSelectAndDeselectAllButtons"></param>
        /// <param name="numberOfColumns"></param>
        /// <param name="uiSelectedItemIds"></param>
        /// <param name="action"></param>
        /// <param name="cellSpan"></param>
        /// <param name="textAlignment"></param>
        /// <param name="validationPredicate"></param>
        /// <returns></returns>
        public static FormItem GetFormItem <ItemIdType>(
            FormItemLabel label, IEnumerable <ChangeBasedListItem <ItemIdType> > items, IEnumerable <ItemIdType> selectedItemIds, out Action modificationMethod,
            string caption    = "", bool includeSelectAndDeselectAllButtons = false, byte numberOfColumns = 1, IEnumerable <ItemIdType> uiSelectedItemIds = null,
            FormAction action = null, int?cellSpan = null, TextAlignment textAlignment = TextAlignment.NotSpecified, Func <bool> validationPredicate      = null)
        {
            var checkBoxList = new ChangeBasedCheckBoxList <ItemIdType>(
                items,
                selectedItemIds,
                caption,
                includeSelectAndDeselectAllButtons,
                numberOfColumns,
                uiSelectedItemIds ?? selectedItemIds,
                action);

            modificationMethod = checkBoxList.ModifyData;
            return(FormItem.Create(
                       label,
                       checkBoxList,
                       cellSpan: cellSpan,
                       textAlignment: textAlignment,
                       validationGetter: control => new EwfValidation(
                           (pbv, validator) => {
                if (validationPredicate != null && !validationPredicate())
                {
                    return;
                }
                control.Validate(pbv);
            })));
        }
Beispiel #10
0
        /// <summary>
        /// Creates a submit button.
        /// </summary>
        /// <param name="style">The style.</param>
        /// <param name="displaySetup"></param>
        /// <param name="classes">The classes on the button.</param>
        /// <param name="postBack">Pass null to use the post-back corresponding to the first of the current data modifications.</param>
        public SubmitButton(ButtonStyle style, DisplaySetup displaySetup = null, ElementClassSet classes = null, PostBack postBack = null)
        {
            var elementChildren = style.GetChildren();
            var postBackAction  = new PostBackFormAction(postBack ?? FormState.Current.PostBack);

            children = new DisplayableElement(
                context => {
                FormAction action = postBackAction;
                action.AddToPageIfNecessary();

                if (EwfPage.Instance.SubmitButtonPostBack != null)
                {
                    throw new ApplicationException("A submit button already exists on the page.");
                }
                EwfPage.Instance.SubmitButtonPostBack = postBackAction.PostBack;

                return(new DisplayableElementData(
                           displaySetup,
                           () =>
                           new DisplayableElementLocalData(
                               "button",
                               attributes: new[] { Tuple.Create("name", EwfPage.ButtonElementName), Tuple.Create("value", "v") },
                               jsInitStatements: style.GetJsInitStatements(context.Id)),
                           classes: style.GetClasses().Add(classes ?? ElementClassSet.Empty),
                           children: elementChildren));
            }).ToCollection();
        }
        private void EnableForm(bool flag, FormAction action)
        {
            switch (action)
            {
            default:
            case FormAction.Editing:
                editProgressBar.Visible     = !flag;
                labelProgressStatus.Visible = !flag;
                break;

            case FormAction.Logging:
                logProgressLabel.Visible   = !flag;
                loggingProgressBar.Visible = !flag;
                break;
            }
            editButton.Enabled         = flag;
            inputTextBox.Enabled       = flag;
            outputTextBox.Enabled      = flag;
            inputBrowseButton.Enabled  = flag;
            outputBrowseButton.Enabled = flag;
            IDoffsetTextBox.Enabled    = flag;
            XtextBox.Enabled           = flag;
            YtextBox.Enabled           = flag;
            ZtextBox.Enabled           = flag;
            patchIdeCheckBox.Enabled   = flag;
            ignoreLOD_checkBox.Enabled = flag;
            comboBoxLoadedMap.Enabled  = flag;
        }
Beispiel #12
0
        private void mesBtnCreateRmaOnly_Click(object sender, EventArgs e)
        {
            _messageDialogResult.Message = "Do you want to place these serials on hold?";
            DialogResult dr = _messageDialogResult.ShowDialog();

            _action = (dr == DialogResult.No) ? FormAction.RmaOnly : FormAction.RmaOnlyOnHold;
        }
Beispiel #13
0
 /// <summary>
 /// Восстановление файла
 /// </summary>
 /// <param name="file">имя src-файла, _recover_dir должна быть установлена</param>
 private void RecoverFile(string file, string _rec_dir)
 {
     try
     {
         string decrypt_name = fileTreeExplorer.GetTrueFileName(Path.GetFileName(file));//надо извлечь имя файла
         if (fileTreeExplorer.IsCryptFile(decrypt_name, _prefix))
         {
             decrypt_name = new FileCrypt().DecryptFName(decrypt_name, _pwd_namefile_enc, _prefix);
             //расшифровываем файл и копируем в _recover_dir
             using (FormAction frm_a = new FormAction(file, _rec_dir, decrypt_name, string.Empty, false, _prefix, _pwd_file_enc, _key_size, _pwd_namefile_enc))
             {
                 frm_a.ShowDialog();
             }
         }
         else
         {
             //оставшиеся файлы копируем в _recover_dir
             File.Copy(file, Path.Combine(_rec_dir, decrypt_name), true);
         }
         ms.write_lview_message("Файл извлечен", Path.Combine(_rec_dir, decrypt_name), Color.GhostWhite, 0, listView_trace);
     }
     catch (Exception ex)
     {
         ms.PrintError(ex, listView_trace);
     }
 }
        internal void SetUpClickableControl(WebControl clickableControl)
        {
            if (resource == null && action == null && script == "")
            {
                return;
            }

            clickableControl.CssClass = clickableControl.CssClass.ConcatenateWithSpace("ewfClickable");

            if (resource != null && EwfPage.Instance.IsAutoDataUpdater)
            {
                action   = HyperlinkBehavior.GetHyperlinkPostBackAction(resource);
                resource = null;
            }

            Func <string> scriptGetter;

            if (resource != null)
            {
                scriptGetter = () => "location.href = '" + EwfPage.Instance.GetClientUrl(resource.GetUrl()) + "'; return false";
            }
            else if (action != null)
            {
                action.AddToPageIfNecessary();
                scriptGetter = () => action.GetJsStatements() + " return false";
            }
            else
            {
                scriptGetter = () => script;
            }

            // Defer script generation until after all controls have IDs.
            EwfPage.Instance.PreRender += delegate { clickableControl.AddJavaScriptEventScript(JsWritingMethods.onclick, scriptGetter()); };
        }
        void ControlTreeDataLoader.LoadData()
        {
            FormState.ExecuteWithDataModificationsAndDefaultAction(
                dataModifications,
                () => {
                if (TagKey == HtmlTextWriterTag.Button)
                {
                    Attributes.Add("name", EwfPage.ButtonElementName);
                    Attributes.Add("value", "v");
                    Attributes.Add("type", usesSubmitBehavior ? "submit" : "button");
                }

                FormAction action = postBackAction;
                action.AddToPageIfNecessary();

                if (ConfirmationWindowContentControl != null)
                {
                    if (usesSubmitBehavior)
                    {
                        throw new ApplicationException("PostBackButton cannot be the submit button and also have a confirmation message.");
                    }
                    confirmationWindow = new ModalWindow(this, ConfirmationWindowContentControl, title: "Confirmation", postBack: postBackAction.PostBack);
                }
                else if (!usesSubmitBehavior)
                {
                    PreRender += delegate { this.AddJavaScriptEventScript(JsWritingMethods.onclick, action.GetJsStatements() + " return false"); }
                }
                ;

                CssClass = CssClass.ConcatenateWithSpace("ewfClickable");
                ActionControlStyle.SetUpControl(this, "");
            });
        }
Beispiel #16
0
        public FormEditOptions(FormOptionsMenu optionsMenu, Options option = null)
        {
            InitializeComponent();

            OptionsMenu = optionsMenu;

            if (option != null)
            {
                FormAction = FormAction.EDIT;
                Option     = option;
                FillCamps(option);
            }
            else
            {
                Text = "New Options";

                FillCamps(new Options {
                    SourcePath        = "C:\\origin...",
                    DestinyPath       = "C:\\destiny...",
                    IncludeSubFolders = true
                });
            }

            KeyDown   += new KeyEventHandler(FormEditOption_KeyDown);
            KeyPreview = true;
        }
 /// <summary>
 /// Creates a setup object for a standard text control.
 /// </summary>
 /// <param name="displaySetup"></param>
 /// <param name="widthOverride">The width of the control. This overrides any value that may be specified via CSS. If no width is specified via CSS and you
 /// pass null for this parameter, the width will be based on the maximum number of characters a user can input.</param>
 /// <param name="numberOfRows">The number of lines in the text control. Must be one or more.</param>
 /// <param name="classes">The classes on the control.</param>
 /// <param name="disableTrimming">Pass true to disable white-space trimming.</param>
 /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param>
 /// <param name="autoFillTokens">A list of auto-fill detail tokens (see
 /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill
 /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param>
 /// <param name="checksSpellingAndGrammar">Pass true to enable spelling and grammar checking, false to disable it, and null for default behavior.</param>
 /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action. Currently has no
 /// effect for multiline controls.</param>
 /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param>
 /// <param name="pageModificationValue"></param>
 /// <param name="validationPredicate"></param>
 /// <param name="validationErrorNotifier"></param>
 public static TextControlSetup Create(
     DisplaySetup displaySetup             = null, ContentBasedLength widthOverride = null, int numberOfRows = 1, ElementClassSet classes = null,
     bool disableTrimming                  = false, string placeholder = "", string autoFillTokens = "", bool?checksSpellingAndGrammar    = null,
     SpecifiedValue <FormAction> action    = null, FormAction valueChangedAction  = null, PageModificationValue <string> pageModificationValue = null,
     Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null)
 {
     return(new TextControlSetup(
                displaySetup,
                numberOfRows == 1 ? "text" : "",
                widthOverride,
                numberOfRows,
                false,
                classes,
                disableTrimming,
                false,
                placeholder,
                autoFillTokens,
                null,
                checksSpellingAndGrammar,
                action,
                null,
                valueChangedAction,
                pageModificationValue,
                null,
                validationPredicate,
                validationErrorNotifier));
 }
Beispiel #18
0
        private void FadeForm(int duration, int steps, Form target, bool fadeIn, FormAction action)
        {
            target.Opacity = fadeIn ? 0 : 1;
            Timer timer = new Timer();

            timer.Interval = duration / steps;
            int currentStep = 0;

            timer.Tick += (arg1, arg2) =>
            {
                double magnitude = ((double)currentStep) / steps;
                target.Opacity = fadeIn ? magnitude : 1 - magnitude;

                currentStep++;

                if (currentStep >= steps)
                {
                    if (action != null)
                    {
                        action(target);
                    }
                    timer.Stop();
                    timer.Dispose();
                }
            };
            timer.Start();
        }
Beispiel #19
0
        public NameValueCollection Translate(FormAction formAction, bool isAjaxMode = false)
        {
            const string f    = "yyyy年M月d日";
            string       from = DateTime.Today.AddDays(-1.0).ToString(f);
            string       to   = DateTime.Today.AddDays(-1.0).ToString(f);

            if (null != Date)
            {
                if (this.Date.From.HasValue)
                {
                    from = this.Date.From.Value.ToString(f);
                }

                if (this.Date.To.HasValue)
                {
                    to = this.Date.To.Value.ToString(f);
                }
            }

            var nvc = new NameValueCollection()
            {
                { "form1:execute", "execute" },
                { "form1:action", formAction.DisplayName() },
                { "form1:isAjaxMode", "" },
                { "salesDateFrom", from },
                { "salesDateTo", to },
                { "styleCd", StyleCode },
                { "seasonCd", "" },
                { "brandCd", "" },
                { "catgpCd", "" },            //205
                { "supCd", "" },
                { "destCd:dest", "" },
                { "destCd:destName", "" },
                { "destCd:cust", "" },
                { "destCd:area", "" },
                { "destCd:destClass", "" },
                { "destCd:destType", "" },
                { "destCd:destGroup", "" },
                { "lineCd", "" },
                { "dest_type", "" },
                { "dest_class", "" },
                { "dest_area", "" },
                { "form1:psClass", "2" },
                { "form1:ranking", "0" },
                { "form1:placeUnit", "1" },
                { "form1:sort", "1" },
                { "form1", "form1" },
            };

            if (isAjaxMode)
            {
                nvc["form1:isAjaxMode"] = "1";

                nvc.Add("form1:cons_001", "");
                nvc.Add("form1:cons_002", "");
                nvc.Add("cache", FMWW.Utility.UnixEpochTime.now().ToString());
            }
            return(nvc);
        }
Beispiel #20
0
 private void SpyFormHandler_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         FormAction.ReleaseCapture();
         FormAction.SendMessage(this.Handle, FormAction.WM_NCLBUTTONDOWN, FormAction.HT_CAPTION, 0);
     }
 }
        /// <summary>
        /// Creates a time picker. The minute interval allows the user to select values only in the given increments.
        /// Be aware that other values can still be sent from the browser via a crafted request.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="minuteInterval"></param>
        /// <param name="action">The post-back that will be performed when the user hits Enter on the time picker.</param>
        public TimePicker(TimeSpan?value, int minuteInterval = 15, FormAction action = null)
        {
            this.value          = value;
            this.minuteInterval = minuteInterval;
            this.action         = action;

            dataModifications = FormState.Current.DataModifications;
        }
        private void CloseForm(object sender, MouseButtonEventArgs e)
        {
            TitleLabel.Content = "";
            ContentPanel.Children.Clear();
            formAction = null;

            Visibility = Visibility.Hidden;
        }
Beispiel #23
0
 public PublisherForm(LibraryDBContainer dbContext, Publisher editedPublisher)
 {
     InitializeComponent();
     this.dbContext        = dbContext;
     this.editedPublisher  = editedPublisher;
     this.textBoxName.Text = editedPublisher.Name;
     this.formAction       = FormAction.Edit;
 }
Beispiel #24
0
 public GenreForm(LibraryDBContainer dbContext, Genre editedGenre)
 {
     InitializeComponent();
     this.dbContext        = dbContext;
     this.editedGenre      = editedGenre;
     this.textBoxName.Text = editedGenre.Name;
     this.formAction       = FormAction.Edit;
 }
 /// <summary>
 /// Creates a radio button.
 /// </summary>
 internal EwfCheckBox(
     FormValue <CommonCheckBox> formValue, string label, FormAction action, Func <IEnumerable <string> > jsClickHandlerStatementListGetter, string listItemId = null)
 {
     radioButtonFormValue  = formValue;
     radioButtonListItemId = listItemId;
     this.label            = label;
     this.action           = action ?? FormState.Current.DefaultAction;
     jsClickHandlerStatementLists.Add(jsClickHandlerStatementListGetter);
 }
Beispiel #26
0
 public ResourceForm(LibraryDBContainer dbContext, Resource resource)
 {
     this.dbContext = dbContext;
     InitializeComponent();
     this.editedResource = resource;
     txtBoxCategory.Text = GetCategory(resource.Position);
     txtBoxAmount.Text   = editedResource.Amount.ToString();
     formAction          = FormAction.Edit;
 }
Beispiel #27
0
        public (string headerName, string headerValue) ToString(ICspNonceService nonceService)
        {
            string headerName;

            if (ReportOnly)
            {
                headerName = "Content-Security-Policy-Report-Only";
            }
            else
            {
                headerName = "Content-Security-Policy";
            }
            var values = new List <string>
            {
                Default.ToString(nonceService),
                Script.ToString(nonceService),
                Style.ToString(nonceService),
#pragma warning disable CS0618 // Type or member is obsolete
                Child.ToString(nonceService),
#pragma warning restore CS0618 // Type or member is obsolete
                Connect.ToString(nonceService),
                Manifest.ToString(nonceService),
                Font.ToString(nonceService),
                FormAction.ToString(nonceService),
                Img.ToString(nonceService),
                Media.ToString(nonceService),
                Object.ToString(nonceService),
                FrameAncestors.ToString(),
                PluginTypes.ToString(),
                Frame.ToString(nonceService),
                Worker.ToString(nonceService),
                Prefetch.ToString(nonceService),
                BaseUri.ToString(nonceService),
                RequireSri.ToString()
            };

            if (BlockAllMixedContent)
            {
                values.Insert(0, "block-all-mixed-content");
            }
            if (UpgradeInsecureRequests)
            {
                values.Insert(0, "upgrade-insecure-requests");
            }
            if (EnableSandbox)
            {
                values.Add(Sandbox.ToString());
            }
            if (ReportUri != null)
            {
                values.Add("report-uri " + ReportUri);
            }

            string headerValue = string.Join(";", values.Where(s => s.Length > 0));

            return(headerName, headerValue);
        }
Beispiel #28
0
 public PublisherForm(LibraryDBContainer dbContext, bool searchPublisher = false)
 {
     InitializeComponent();
     if (searchPublisher)
     {
         buttonSave.Text = "Wyszukaj";
     }
     this.dbContext  = dbContext;
     this.formAction = searchPublisher ? FormAction.Search : FormAction.Add;
 }
Beispiel #29
0
 /// <summary>
 /// Returns the JavaScript statements that should be executed on keypress to ensure that a form control will trigger the specified action when the enter key
 /// is pressed while the control has focus. If you specify the submit-button post-back, this method relies on HTML’s built-in implicit submission behavior,
 /// which will simulate a click on the submit button.
 /// </summary>
 internal static string GetImplicitSubmissionKeyPressStatements(FormAction action, bool forceJsHandling)
 {
     // EWF does not allow form controls to use HTML’s built-in implicit submission on a page with no submit button. There are two reasons for this. First, the
     // behavior of HTML’s implicit submission appears to be somewhat arbitrary when there is no submit button; see
     // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission. Second, we don’t want the implicit submission behavior of
     // form controls to unpredictably change if a submit button is added or removed.
     return(action is PostBackFormAction postBackAction && postBackAction.PostBack == PageBase.Current.SubmitButtonPostBack && !forceJsHandling
                                ? ""
                                : "if( e.which == 13 ) {{ {0} }}".FormatWith("e.preventDefault();".ConcatenateWithSpace(action?.GetJsStatements() ?? "")));
 }
Beispiel #30
0
 public AuthorForm(LibraryDBContainer dbContext, Author editedAuthor)
 {
     InitializeComponent();
     this.dbContext             = dbContext;
     this.editedAuthor          = editedAuthor;
     this.textBoxName.Text      = editedAuthor.Name;
     this.textBoxSurname.Text   = editedAuthor.Surname;
     this.dateTimePicker1.Value = (DateTime)editedAuthor.BirthDate;
     this.formAction            = FormAction.Edit;
 }
        public RedirectToRouteResult UpdateProfile(FormAction formAction)
        {
            if (!ModelState.IsValid)
            {
                return RedirectToAction("Index");
            }

            if (!string.IsNullOrEmpty(Request.Form["Email"]) &&
                Account.Email != Request.Form["Email"] &&
                Account.Confirmation.Confirmed)
            {
                var confirmationKey = CommandExecutor.ExecuteCommand(new GenerateUniqueConfirmationKeyCommand(Session));
                var url = Url.Action("Confirm", "Profile", new
                {
                    Account.Confirmation.Key
                },
                                     "http");

                //set confirmation to defaults
                Account.ResetConfirmation(confirmationKey);
                //send email
                CommandExecutor.ExecuteCommand(new SendConfirmationEmailCommand(Account, url));
            }

            TryUpdateModel(Account, new[]
            {
                "Email", "FirstName", "LastName", "Company", "JobCategory", "JobTitle", "CodingExperience",
                "ContactRoute"
            });
            App.ResetOutputCache();

            switch (formAction)
            {
                case FormAction.Update:
                    Message =
                        string.Format(
                            "You profile was updated. You probably want to go to the <a href='{0}'>Dashboard</a> to manage your API keys.",
                            Url.Action("Index", "Home"));
                    return RedirectToAction("Index");
                case FormAction.UpdateAndGo:
                    return RedirectToAction("Index", "Home", new
                    {
                        Area = "Secure"
                    });
                default:
                    throw new ArgumentOutOfRangeException("formAction");
            }
        }
Beispiel #32
0
 /// <summary>
 /// Gets from form action.
 /// </summary>
 /// <returns>The from form action.</returns>
 /// <param name="formAction">Form action.</param>
 public Visibility GetFromFormAction(FormAction formAction)
 {
     switch (formAction)
     {
         case FormAction.Create:
             return Create;
         case FormAction.Delete:
             return Delete;
         case FormAction.Read:
             return Read;
         case FormAction.Update:
             return Update;
     }
     return Visibility.None;
 }