Beispiel #1
0
        protected override void OnCreateForm(Form form)
        {
            form.Spacing = 5;

            form.Add(new Headline("Create Subfolders"));

            LinearLayout lyButton = LinearLayout.Horizontal();
            Button       button   = new Button("Ok", ButtonClicked);

            button.Width = 100;
            lyButton.Add(new View()).Add(button);

            Label lblSubfolders = new Label("Subfolders:");

            lblSubfolders.Width = 150;

            GridLayout lyCheckboxes = new GridLayout(3, GridLayout.EOrientation.Vertical);

            foreach (string folder in new string[] { "Scripts", "Scenes", "Prefabs", "Resources", "Textures", "Materials", "Meshes" })
            {
                Toggle toggle = new Toggle(false, folder);
                subfolders.Add(toggle);
                lyCheckboxes.Add(toggle);
            }

            form.Add(lyCheckboxes);
            form.Add(new View());
            form.Add(lyButton);
        }
        public void it_suggests_a_class_for_an_undefined_step_with_a_form()
        {
            var form = new Form();

            form.Add("A", "a");
            form.Add("B", "b");
            form.Add("C", "c");

            var undefinedSteps = new List <Step>
            {
                new Step
                {
                    Type   = StepType.Given,
                    Text   = "Given this form",
                    Block  = form,
                    Result = StepResult.Undefined
                }
            };

            ReportUndefinedStepsOutputShouldBe(undefinedSteps,
                                               "Your undefined steps can be defined with the following code:",
                                               "",
                                               "public void given_this_form(Foo foo)",
                                               "{",
                                               "    throw new NotImplementedException();",
                                               "}",
                                               "",
                                               "public class Foo",
                                               "{",
                                               "    public string A { get; set; }",
                                               "    public string B { get; set; }",
                                               "    public string C { get; set; }",
                                               "}"
                                               );
        }
Beispiel #3
0
 private Form GetForm()
 {
     if (form == null)
     {
         form             = new Form();
         form.Add(txtText = new TextField());
         form.Add(new Button("Say", Say));
     }
     return(form);
 }
Beispiel #4
0
        protected override void OnCreateForm(Form form)
        {
            form.Spacing = 5;

            form.Add(new Headline("Create Folder"));

            //Label lblNamespace = new Label("Namespace:");
            //lblNamespace.Width = 150;
            //txtNamespace = new TextField(transitiveSourceInfo.@namespace);
            //Linear lyNamespace = Linear.Horizontal().Add(lblNamespace).Add(txtNamespace);
            //lyNamespace.Height = 30;

            Label lblFolder = new Label("Folder:");

            lblFolder.Width = 150;
            txtFolderName   = new TextField();
            Linear lyFolder = Linear.Horizontal().Add(lblFolder).Add(txtFolderName);

            lyFolder.Height          = 30;
            lblError                 = new Label("");
            lblError.style.fontStyle = FontStyle.Bold;

            Linear lyButton = Linear.Horizontal();
            Button button   = new Button("Ok", ButtonClicked);

            button.Width = 100;
            lyButton.Add(new View()).Add(button);

            Label lblSubfolders = new Label("Create subfolders:");

            lblSubfolders.Width = 150;

            EMP.Forms.Grid lyCheckboxes = new EMP.Forms.Grid(3, EMP.Forms.Grid.EOrientation.Vertical);

            foreach (string folder in new string[] { "Scripts", "Scenes", "Prefabs", "Resources", "Textures", "Materials", "Meshes", "Editor" })
            {
                Toggle toggle = new Toggle(false, folder);
                subfolders.Add(toggle);
                lyCheckboxes.Add(toggle);
            }

            Linear lySubfolders = Linear.Horizontal().Add(lblSubfolders).Add(lyCheckboxes);

            //form.Add(lyNamespace);
            form.Add(lyFolder);
            form.Add(lblError);
            form.Add(lySubfolders);
            form.Add(lyButton);

            form.RequestFocusForView = txtFolderName;
        }
Beispiel #5
0
        public MvcErrorLog(string application, ExceptionContext exceptionContext) : base(application, exceptionContext.Exception)
        {
            var context = exceptionContext.HttpContext;

            if (context == null)
            {
                return;
            }

            Host = Host ?? TryGetMachineName(context);

            var user = context.User;

            if (!(user == null || string.IsNullOrWhiteSpace(user.Identity.Name)))
            {
                User = user.Identity.Name;
            }

            var request = context.Request;

            ServerVariables.Add(request.ServerVariables);
            QueryString.Add(request.QueryString);
            Form.Add(request.Form);
            Cookies.Add(request.Cookies);
        }
Beispiel #6
0
        private void AddToCategory(string category, string field, string label, NameValueCollection value)
        {
            var labelValue = Tuple.Create(label, value.Cast <string>()
                                          .Select(key => new KeyValuePair <string, string>(key, value[key]))
                                          );

            switch (category)
            {
            case "form":
                Form.Add(field, labelValue);
                break;

            case "support.metrics.system":
                System.Add(field, labelValue);
                break;

            case "support.metrics.environment":
                Environment.Add(field, labelValue);
                break;

            case "support.metrics.counters":
                Counters.Add(field, labelValue);
                break;

            case "support.metrics.tasks":
                Tasks.Add(field, labelValue);
                break;

            case "support.metrics.eventlog":
                EventLog.Add(field, labelValue);
                break;
            }
        }
Beispiel #7
0
        private void DisplayAuthenticated(bool viaCookie, string UID)
        {
            //This will display to the user a few pieces of information about the session data stored
            Document doc = new Document();

            doc.Head = new DocumentHead("OpenNETCF Padarn Web Server", new StyleInfo("css/SampleSite.css"));

            Utility.AddPadarnHeaderToDocument(doc, true, "Execute");

            Div  containerDiv = new Div("container");
            Form form         = new Form("CookieWork.aspx", FormMethod.Post);

            if (viaCookie)
            {
                form.Add(new RawText(String.Format("Your are authenticated via cookie")));
            }
            else
            {
                form.Add(new RawText(String.Format("Your are authenticated via normal credentials")));
            }
            form.Add(new LineBreak());
            form.Add(new RawText(String.Format("Cookie last visit on {0}", Request.Cookies[COOKIENAME][COOKIEVAL_LAST_VISIT] == null ?
                                               "NEVER" : DateTime.Parse(Request.Cookies[COOKIENAME][COOKIEVAL_LAST_VISIT]).ToString())));
            form.Add(new LineBreak());
            form.Add(new RawText(String.Format("Cookie GUID is {0}", Request.Cookies[COOKIENAME][COOKIEVAL_GUID])));

            //Let the user log out at any point
            form.Add(new LineBreak());
            form.Add(new LineBreak());
            form.Add(new Button(new ButtonInfo(ButtonType.Submit, "Log Out")));
            form.Add(new Hidden("LogOut", UID));

            containerDiv.Add(form);
            doc.Body.Add(containerDiv);

            if (Request.Cookies.Count > 0 && Request.Cookies[COOKIENAME] != null)
            {
                //Modify cookie to show we've been here before
                OpenNETCF.Web.HttpCookie myCookie = Request.Cookies[0];
                myCookie.Values[COOKIEVAL_LAST_VISIT] = DateTime.Now.ToString();
                Response.SetCookie(myCookie);
            }

            //Write out the response
            Response.Write(doc.OuterHtml);
            Response.Flush();
        }
Beispiel #8
0
        static void testForm()
        {
            Separate();
            Console.WriteLine("                      Test From");
            Separate();
            var root = UINode.CreateRootNode(1000, 1000, "default style", "root");
            var form = new Form("form");

            root.Add(form);
            form.Add(new CheckButton());
            form.Add(new TextInput());
            form.Add(new TextInput());
            form.Add(new TextInput());
            form.Add(new CheckButton());

            foreach (UINode node in form)
            {
                Console.WriteLine(node);
            }
        }
    private void FillForm()
    {
        Form = new Form();
        var select = new Select();

        select.Add("Price", "Price");
        select.Add("Calories", "Calories");
        select.Add("Fat", "Fat");
        select.Add("Sugar", "Sugar");
        select.Add("Salt", "Salt");
        Form.Add(select, "PropertySelect");
    }
    public void CreatF(string id, string name, List <Vector3[]> faces)
    {
        Form form = new Form();

        foreach (var item in faces)
        {
            Polygon pg = new Polygon(item);
            form.Add(pg);
        }

        tobeUpdatedForm.Add(id, form);
        tobeUpdatedForm[id].name = name;
    }
Beispiel #11
0
        public HttpRequest(HttpListenerContext context)
        {
            this.Request        = context.Request;
            this.HttpMethod     = this.Request.HttpMethod;
            this.Context        = context;
            this.Url            = this.Request.Url;
            this.RawUrl         = this.Request.RawUrl;
            this.RemoteEndPoint = this.Request.RemoteEndPoint;
            this.Form           = new NameValueCollection();
            this.QueryString    = new NameValueCollection();
            StreamReader sr      = new StreamReader(this.Request.InputStream);
            var          formStr = sr.ReadToEnd();

            if (!string.IsNullOrEmpty(formStr))
            {
                formStr.Split('&').Select(p =>
                {
                    var ps = p.Split('=');
                    return(new
                    {
                        key = ps[0],
                        value = ps[1]
                    });
                }).ForEach(p =>
                {
                    Form.Add(p.key, p.value);
                });
            }
            if (!string.IsNullOrEmpty(this.Request.Url.Query))
            {
                var query = this.Request.Url.Query.Substring(1, this.Request.Url.Query.Length - 1);
                query.Split('&').Select(p =>
                {
                    var ps = p.Split('=');
                    return(new
                    {
                        key = ps[0],
                        value = ps[1].UrlDecode()//解密
                    });
                }).ForEach(p =>
                {
                    QueryString.Add(p.key, p.value);
                });
            }
        }
Beispiel #12
0
    void Start()
    {
        form         = new Form();
        form.Spacing = 5;

        Label labelNamespace = new Label("Component Namespace:");

        labelNamespace.Width = 150;
        TextField    txtNamespace       = new TextField();
        LinearLayout componentNamespace = LinearLayout.Horizontal().Add(labelNamespace).Add(txtNamespace);

        componentNamespace.Height = 30;
        form.Add(componentNamespace);

        Label labelComponentName = new Label("Name of Component:");

        labelComponentName.Width = 150;
        TextField    txtComponentName = new TextField();
        LinearLayout componentName    = LinearLayout.Horizontal().Add(labelComponentName).Add(txtComponentName);

        componentName.Height = 30;
        form.Add(componentName);

        form.Add(new Label("Generate following folders in component:"));

        LinearLayout toggles = LinearLayout.Horizontal();
        LinearLayout left    = LinearLayout.Vertical();

        left.Width = 100;
        left.Add(new Toggle(true, "Scripts"));
        left.Add(new Toggle(true, "Meshes"));
        left.Add(new Toggle(true, "Materials"));

        LinearLayout right = LinearLayout.Vertical();

        right.Width = 100;
        right.Add(new Toggle(true, "Prefabs"));
        right.Add(new Toggle(true, "Ressoures"));

        toggles.Add(left).Add(right);
        form.Add(toggles);

        LinearLayout buttonContainer = LinearLayout.Horizontal();

        form.Add(buttonContainer);

        Button button = new Button("Ok", _ => { });

        button.Width = 100;
        buttonContainer.Add(new View()).Add(button);
        form.Add(buttonContainer);
    }
Beispiel #13
0
        /// <summary>
        /// Method that creates an HTML page with text input, radio group, checkbox, and submit button
        /// </summary>
        private void CreateHTMLInput()
        {
            //1. Create a simple input form with textbox, radio buttons, and sumbit button
            Document page = new Document();

            page.Head = new DocumentHead("OpenNETCF Padarn Web Server - Form Test Input", new StyleInfo("css/SampleSite.css"));
            page.Head.MetaTags.Add(new ContentType(CharSet.UTF8));

            Utility.AddPadarnHeaderToDocument(page, true, "Default");

            //2. Create a form object and set the method to POST
            Form form = new Form("FormExample.aspx", FormMethod.Post);

            //3.  Add text input and buttons
            form.Add(new Input(TEXT_INPUT));
            form.Add(new Button(new ButtonInfo(ButtonType.Submit, "Submit")));
            form.Add(new Button(new ButtonInfo(ButtonType.Reset, "Reset")));

            form.Add(new LineBreak());

            //4. Add RadioButtons
            RadioGroup rg = new RadioGroup(RADIO_INPUT);

            rg.Items.Add(new RadioItem("Value 1", "Val1", true, RADIO_CLASS));
            rg.Items.Add(new RadioItem("Value 2", "Val2", false, RADIO_CLASS));
            form.Add(rg);

            form.Add(new LineBreak());

            //5. Add checkboxes
            form.Add(new RawText("Choice selected?:" +
                                 "<input type=\"checkbox\" name=\"CheckSelected\" value=\"Selected\"" +
                                 "/>" +
                                 "<br />"));

            //6. Complete writing page
            page.Body.Elements.Add(form);
            Response.Write(page.OuterHtml);
            Response.Flush();
        }
        protected override void OnCreateForm(Form form)
        {
            form.Spacing = 5;

            form.Add(new Headline("Create C# Class"));

            Label lblNamespace = new Label("Namespace:");

            lblNamespace.Width = 150;
            txtNamespace       = new TextField(sourcesInfo.@namespace);
            LinearLayout lyNamespace = LinearLayout.Horizontal().Add(lblNamespace).Add(txtNamespace);

            lyNamespace.Height = 30;

            Label lblClassName = new Label("Class name:");

            lblClassName.Width = 150;
            txtClassName       = new TextField();
            LinearLayout lyClassName = LinearLayout.Horizontal().Add(lblClassName).Add(txtClassName);

            lyClassName.Height = 30;

            form.Add(lyNamespace);
            form.Add(lyClassName);
            form.Add(lblError        = new Label(""));
            lblError.style.fontStyle = FontStyle.Bold;

            form.Add(tglHeaderComment = new Toggle(true, "Generate source code header comment"));
            form.Add(tglLogger        = new Toggle(true, "Generate logger"));

            LinearLayout lyButton = LinearLayout.Horizontal();
            Button       button   = new Button("Ok", ButtonClicked);

            button.Width = 100;
            lyButton.Add(new View()).Add(button);
            form.Add(lyButton);

            form.RequestFocusForView = txtClassName;
        }
Beispiel #15
0
        private void DisplayLoginForm(bool badPW)
        {
            Document doc = new Document();

            doc.Head = new DocumentHead("OpenNETCF Padarn Web Server", new StyleInfo("css/SampleSite.css"));

            Utility.AddPadarnHeaderToDocument(doc, true, "Execute");

            Div containerDiv = new Div("container");

            //We need to prompt user for credentials
            Div  div  = new Div("UserName");
            Form form = new Form("CookieWork.aspx", FormMethod.Post);

            if (badPW)
            {
                form.Add(new RawText(string.Format("<label>{0}</label>", "! Invalid Credentials !")));
                form.Add(new LineBreak());
                form.Add(new LineBreak());
            }

            form.Add(new RawText(string.Format("<label>{0}</label>", "User Name ")));
            form.Add(new Input("UserName"));

            form.Add(new LineBreak());

            //Create a standard password input box
            form.Add(new RawText(string.Format("<label>{0}</label>", "Password ")));
            form.Add(new RawText("<input name=\"PW\" type=\"password\">"));

            form.Add(new LineBreak());
            form.Add(new LineBreak());

            //Create a submit and reset button
            form.Add(new Button(new ButtonInfo(ButtonType.Submit, "Submit")));
            form.Add(new Hidden("Submit", "UserName"));

            form.Add(new Button(new ButtonInfo(ButtonType.Reset, "Reset")));

            div.Add(form);
            containerDiv.Add(div);
            doc.Body.Add(containerDiv);

            //Write out the response
            Response.Write(doc.OuterHtml);
            Response.Flush();
        }
Beispiel #16
0
 private void FillForm()
 {
     Form = new Form();
     Form.Add(new FormEntry(FormEntryType.Checkbox, "Milk"), "Milk");
     Form.Add(new FormEntry(FormEntryType.Checkbox, "Nuts"), "Nuts");
 }
Beispiel #17
0
        static void Main(string[] args)
        {
            Console.Title = "Extended Console Class Test";
            ConsoleBase.Init();
            ConsoleBase.SetHotkeyHandler(HotKeyPressed);
            frm      = new Form();
            frm.Text = "[Form]";
            frm.SetBounds(0, 0, 25, 20);
            //
            lb = new Label();
            lb.SetBounds(0, 0, 10, 1);
            lb.Text = "3Chars";
            frm.Add(lb);
            //
            tb        = new TextBox();
            tb.MaxLen = 3;
            tb.SetBounds(10, 0, 10, 1);
            frm.Add(tb);
            //
            lb = new Label();
            lb.SetBounds(0, 2, 10, 1);
            lb.Text = "Text";
            frm.Add(lb);
            //
            tb = new TextBox();
            tb.SetBounds(10, 2, 10, 1);
            tb.Text = "123";
            frm.Add(tb);
            //
            bt      = new Button();
            bt.Text = "Plus";
            bt.SetBounds(0, 4, 10, 1);
            bt.KeyHandler += ButtonKeyPressed;
            frm.Add(bt);
            //
            bt2      = new Button();
            bt2.Text = "Minus";
            bt2.SetBounds(10, 4, 10, 1);
            bt2.KeyHandler += ButtonKeyPressed;
            frm.Add(bt2);
            //
            pb = new ProgressBar();
            pb.SetBounds(0, 6, 10, 1);
            pb.Val = 50;
            frm.Add(pb);
            //
            cb = new CheckBox();
            cb.SetBounds(0, 8, 13, 1);
            cb.Text = "IsChecked";
            frm.Add(cb);
            //
            lbx = new ListBox();
            lbx.SetBounds(0, 10, 15, 4);
            lbx.Items.Add("ABC");
            lbx.Items.Add("DEF");
            lbx.Items.Add("GHI");
            lbx.Items.Add("JKL");
            lbx.Items.Add("MNO");
            lbx.Items.Add("PQR");
            lbx.Items.Add("STU");
            lbx.Items.Add("VWX");
            lbx.Items.Add("YZA");
            lbx.Idx = 4;
            frm.Add(lbx);
            //
            nm = new NumericUpDown();
            nm.SetBounds(0, 16, 7, 1);
            nm.Format = "00.00";
            nm.Min    = 1;
            nm.Max    = 15;
            frm.Add(nm);
            //
            frm.Draw();
            ConsoleMouse.SetMouseKeyHandler(MouseKeyPressed);
            uint retval = MessageBox.Show("Test", "Test Message12345678901234567\nNew Line", new string[] { "Yes", "No", "Maybe" });

            if (retval == 0)
            {
                tb.Focus();
            }
            else if (retval == 1)
            {
                bt.Focus();
            }
            else
            {
                nm.Focus();
            }
            ConsoleBase.ClearScreen();
            frm.Draw();
        }
Beispiel #18
0
 protected virtual void RegisterAsFormComponent()
 {
     Form?.Add(this);
 }
Beispiel #19
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            Document doc = new Document(new DocumentHead("OpenNETCF File Upload Example"));

            if (Request.HttpMethod == "POST")
            {
                // We will save this file to the Virtual Directory folder
                if (this.Request.ContentLength > 0 && this.Request.Files.Count > 0 && this.Request.Files[0] != null)
                {
                    try
                    {
                        //Request FileName includes full path from client
                        string remoteName = Path.GetFileName(this.Request.Files[0].FileName);
                        string fullPath   = VIRTUAL_DIRECTORY_LOCAL + remoteName;

                        int uploadSize = this.Request.ContentLength;

                        //We'll need to create the directory if it doesn't exist
                        if (!Directory.Exists(VIRTUAL_DIRECTORY_LOCAL))
                        {
                            Directory.CreateDirectory(VIRTUAL_DIRECTORY_LOCAL);
                        }
                        else if (File.Exists(fullPath))
                        {
                            //Overwrite file
                            File.Delete(fullPath);
                        }

                        //Verify there's enough disk space
                        DiskFreeSpace folderSpace = new DiskFreeSpace();

                        //Use our P/Invoke below to determine free space
                        if (!GetDiskFreeSpaceEx(VIRTUAL_DIRECTORY_LOCAL, ref folderSpace.FreeBytesAvailable,
                                                ref folderSpace.TotalBytes, ref folderSpace.TotalFreeBytes))
                        {
                            throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Error retrieving free disk space");
                        }
                        else if (uploadSize > folderSpace.FreeBytesAvailable)
                        {
                            doc.Body.Elements.Add(new RawText("Insufficient disk space on server"));
                        }
                        else
                        {
                            //Save file locally
                            this.Request.Files[0].SaveAs(fullPath);

                            FileInfo fiUploaded = new FileInfo(fullPath);

                            //Indicate success to user
                            doc.Body.Elements.Add(new RawText("Upload success"));
                            doc.Body.Elements.Add(new LineBreak());
                            doc.Body.Elements.Add(new RawText(String.Format("File upload completed at {0}",
                                                                            fiUploaded.CreationTime.ToLongTimeString())));
                        }
                    }
                    catch
                    {
                        //Indicate failure to user
                        doc.Body.Elements.Add(new RawText("Upload failure"));
                    }
                }
            }
            else
            {
                //Utilitarian browse/upload form
                Form form = new Form("FileReceiver.aspx", FormMethod.Post, "upload", "upload");
                form.ContentType = "multipart/form-data";
                form.Add(new RawText("File to upload:"));
                form.Add(new Upload("upfile"));
                form.Add(new Button(new ButtonInfo(ButtonType.Submit, "Upload")));
                doc.Body.Elements.Add(form);
            }

            //Send the document html to the Response object
            Response.Write(doc.OuterHtml);
            //Flush the response
            Response.Flush();
        }
Beispiel #20
0
        private void InitializeUI()
        {
            Form mainForm = new Form(
                new Vector2(50, 50),
                new Vector2(200, 200),
                s_mainMenuTitle,
                Color.DarkGray,
                Color.Black,
                "Verdana",
                0.7f,
                false,
                false,
                false,
                false,
                Form.BorderStyle.FixedSingle,
                Form.Style.Default
                );

            TextButton startGameButton = new TextButton(
                s_mainMenuStartGame,
                new Vector2(20, 50),
                s_mainMenuStartGame,
                160,
                Color.White,
                m_resourceManager.GetFont(GameFontKey.Verdana),
                Form.Style.Default
                );

            startGameButton.OnPress += startGameButton_OnPress;
            mainForm.Add(startGameButton);

            TextButton optionsButton = new TextButton(
                s_mainMenuOptions,
                new Vector2(20, 80),
                s_mainMenuOptions,
                160,
                Color.White,
                m_resourceManager.GetFont(GameFontKey.Verdana),
                Form.Style.Default
                );

            optionsButton.OnPress += optionsButton_OnPress;
            mainForm.Add(optionsButton);

            TextButton exitButton = new TextButton(
                s_mainMenuExit,
                new Vector2(20, 110),
                s_mainMenuExit,
                160,
                Color.White,
                m_resourceManager.GetFont(GameFontKey.Verdana),
                Form.Style.Default
                );

            exitButton.OnPress += exitButton_OnPress;
            mainForm.Add(exitButton);

            Form optionsForm = new Form(
                new Vector2(270, 50),
                new Vector2(400, 500),
                s_mainMenuOptions,
                Color.DarkGray,
                Color.Black,
                "Verdana",
                0.7f,
                false,
                false,
                false,
                false,
                Form.BorderStyle.FixedSingle,
                Form.Style.Default
                );

            Label musicLabel = new Label(
                s_optionsMenuMusic + "Label",
                new Vector2(45, 50),
                s_optionsMenuMusic + ":",
                Label.Alignment.Left,
                300,
                Color.Black,
                m_resourceManager.GetFont(GameFontKey.Verdana)
                );

            optionsForm.Add(musicLabel);

            Slider musicVolumeSlider = new Slider(
                s_optionsMenuMusic,
                new Vector2(50, 70),
                300,
                0,
                100,
                (int)(m_audioManager.MusicVolume * 100),
                Form.Style.Default
                );

            optionsForm.Add(musicVolumeSlider);

            Label soundLabel = new Label(
                s_optionsMenuSounds + "Label",
                new Vector2(45, 90),
                s_optionsMenuSounds + ":",
                Label.Alignment.Left,
                300,
                Color.Black,
                m_resourceManager.GetFont(GameFontKey.Verdana)
                );

            optionsForm.Add(soundLabel);

            Slider soundVolumeSlider = new Slider(
                s_optionsMenuSounds,
                new Vector2(50, 110),
                300,
                0,
                100,
                (int)(m_audioManager.SoundVolume * 100),
                Form.Style.Default
                );

            optionsForm.Add(soundVolumeSlider);

            Label resolutionLabel = new Label(
                s_optionsResolution + "Label",
                new Vector2(45, 130),
                s_optionsResolution + ":",
                Label.Alignment.Left,
                50,
                Color.Black,
                m_resourceManager.GetFont(GameFontKey.Verdana)
                );

            optionsForm.Add(resolutionLabel);

            Combo resolutionComboBox = new Combo(
                s_optionsResolution,
                new Vector2(145, 130),
                200,
                m_resourceManager.GetFont(GameFontKey.Verdana),
                Form.Style.Default
                );

            resolutionComboBox.AddItem(s_optionsResolution800x600);
            resolutionComboBox.AddItem(s_optionsResolution1024x768);
            resolutionComboBox.AddItem(s_optionsResolution1280x960);

            if (m_graphicsManager.ViewportSize == ViewportSizePreset.Size800x600)
            {
                resolutionComboBox.SelectedItem = s_optionsResolution800x600;
            }
            if (m_graphicsManager.ViewportSize == ViewportSizePreset.Size1024x768)
            {
                resolutionComboBox.SelectedItem = s_optionsResolution1024x768;
            }
            if (m_graphicsManager.ViewportSize == ViewportSizePreset.Size1280x960)
            {
                resolutionComboBox.SelectedItem = s_optionsResolution1280x960;
            }

            optionsForm.Add(resolutionComboBox);

            m_forms.Add(mainForm);
            m_forms.Add(optionsForm);
        }
 private void FillForm()
 {
     Form = new Form();
     Form.Add(new FormEntry(FormEntryType.TextField), "Search");
 }
Beispiel #22
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            //User-selected time comes in here
            string time = Request.Form["data"];

            if (time == null)
            {
                //Page version 1 - User views admin page for first time; display buttons to launch calendar and submit

                Document doc = new Document();
                doc.Head = new DocumentHead("OpenNETCF Padarn Web Server", new StyleInfo("css/SampleSite.css"));

                //Add the calendar scripts
                doc.Head.Scripts.Add(new Script("script/calendar.js"));
                doc.Head.Scripts.Add(new Script("script/calendar-en.js"));
                doc.Head.Scripts.Add(new Script("script/calendar-setup.js"));

                Utility.AddPadarnHeaderToDocument(doc, true, "AdminLogView");

                Div timeDiv = new Div();

                //Add the calendar elements
                Form calendarForm = new Form("AdminLogView.aspx", FormMethod.Post);
                calendarForm.Add(new RawText("<input type=\"text\" id=\"data\" name=\"data\" />"));
                calendarForm.Add(new RawText("<button id=\"trigger\">...</button>"));
                calendarForm.Add(new Button(new ButtonInfo(ButtonType.Submit, "Search")));
                timeDiv.Add(calendarForm);

                timeDiv.Add(new RawText("<script type=\"text/javascript\">\r\n" +
                                        "Calendar.setup(\r\n" +
                                        "{\r\n" +
                                        "  inputField : \"data\",\r\n" +
                                        "  ifFormat : \"%m-%d-%y %H:%M\",\r\n" +
                                        "  button : \"trigger\",\r\n" +
                                        "  showsTime : \"true\"\r\n" +
                                        "}\r\n" +
                                        ");\r\n" +
                                        "</script>\r\n"
                                        ));

                doc.Body.Add(timeDiv);

                //Send the document html to the Response object
                Response.Write(doc.OuterHtml);

                //Flush the response
                Response.Flush();
            }

            else
            {
                //Page version 2 - User selected a valid date from the JavaScript calendar control

                //What Date was passed in?
                DateTime selectedDate = DateTime.Parse(time).Date;

                //Create the document
                Document doc = new Document();

                //Add a header to the document
                doc.Head = new DocumentHead("OpenNETCF LogProvider Sample Output", new StyleInfo("css/SampleSite.css"));

                Div menuContainer = new Div();
                menuContainer.ClassName = "centeredContainer";

                Div menuItemContainer = new Div();
                menuItemContainer.ClassName = "siteMenu";

                Paragraph paragraph = new Paragraph();
                paragraph.Elements.Add(new FormattedText("Listing of Event Log for "
                                                         + selectedDate.ToShortDateString() + " :", TextFormat.Bold, "6"));
                paragraph.Elements.Add(new LineBreak());

                Table table = new Table(CLASS_NAME, "1000", Align.Center);

                //Create header row corresponding to file details
                Row row = new Row();
                row.Cells.Add(new RawText("Num #"));
                row.Cells.Add(new RawText("Page"));
                row.Cells.Add(new RawText("Client IP"));
                row.Cells.Add(new RawText("Cookies"));
                row.Cells.Add(new RawText("SSL"));
                row.Cells.Add(new RawText("Browser"));
                row.Cells.Add(new RawText("Event ID"));
                row.Cells.Add(new RawText("Event Time"));
                table.Headers.Add(row);

                //Retrieve records for selected day
                List <DataItemHelper.ClientRequestInfo> listEntries = DataItemHelper.FindRecordsOnDay(selectedDate);

                int recordCount = 0;

                foreach (DataItemHelper.ClientRequestInfo data in listEntries)
                {
                    //For each record, show page (or error), client IP, cookie enablement, SSL enablement, eventID, and time
                    row = new Row();
                    row.Cells.Add(new FormattedText((++recordCount).ToString(), TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.PageRequested, TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.ClientIP, TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.ClientBringsCookies ? "YES" : "NO", TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.UsingSsl ? "ON" : "OFF", TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.Browser.ToString(), TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.EventID.ToString(), TextFormat.None, "2"));
                    row.Cells.Add(new FormattedText(data.RequestDate.ToLongTimeString(), TextFormat.None, "2"));
                    table.Rows.Add(row);
                }

                if (listEntries.Count == 0)
                {
                    //If no records can be found, display some boilerplate
                    paragraph.Elements.Add(new LineBreak());
                    paragraph.Elements.Add(new FormattedText("- No records found for " + selectedDate.ToShortDateString() + " -", TextFormat.None, "6"));
                    paragraph.Elements.Add(new LineBreak());
                }

                menuItemContainer.Elements.Add(paragraph);
                menuContainer.Elements.Add(menuItemContainer);
                doc.Body.Elements.Add(menuContainer);

                if (recordCount != 0)
                {
                    //Add content table if there were files encountered
                    menuContainer.Add(table);
                }

                //Send the document html to the Response object
                Response.Write(doc.OuterHtml);

                //Flush the response
                Response.Flush();
            }
        }
		public void ShowAddUI (UIBarButtonItem addButton, bool dup, bool folder)
		{
			if (DismissSheetsAndPopovers ()) {
				return;
			}

			var directory = CurrentDocumentListController.Directory;

			if (!ActiveFileSystem.IsWritable)
				return;

			var form = new Form {
				new FormAction (
					"New " + App.DocumentBaseName,
					async () => await AddAndOpenNewDocument ()),
			};

			var pbtext = GetPasteboardText ();
			if (ShowAddFromClipboard && !string.IsNullOrWhiteSpace (pbtext) && lastClipboard != pbtext) {
				lastClipboard = pbtext;
				form.Add (new FormAction (
					"From Clipboard",
					async () => await AddAndOpenDocRef (await DocumentReference.New (
						directory, 
						App.DocumentBaseName, 
						App.DefaultExtension,
						ActiveFileSystem, 
						App.CreateDocument, 
						GetNewDocumentText () + pbtext))));
			}

			var odi = OpenedDocIndex;
			var source = (dup && 0 <= odi && odi < Docs.Count) ?
			             Docs [odi] :
			             null;
			if (source != null) {
				form.Add (new FormAction (
					"Duplicate",
					async () => await AddAndOpenDocRef (await source.Duplicate (ActiveFileSystem))));
			}

			if (folder && GetDirectoryDepth (directory) < ActiveFileSystem.MaxDirectoryDepth) {
				form.Add (new FormAction (
					"Folder",
					AddFolder));
			}

			if (form.Count > 1) {
				form.Title = "Add";
				form.Add (new FormAction ("Cancel"));

				ActionSheet = form.ToActionSheet ();
				ActionSheet.ShowFrom (addButton, true);
			} else {
				((FormAction)form [0]).Execute ();
			}
		}
 void UploadFrame(WriteableBitmap bmp, string kind, string fileName, bool replace)
 {
     PlaySound("shutter");
     int W = bmp.PixelWidth;
     int H = bmp.PixelHeight;
     byte[][,] buf = FJ.Image.CreateRaster(W, H, 3);
     int[] pix = bmp.Pixels;
     for (int y = 0; y < H; ++y)
     {
         for (int x = 0, i = y * W; x < W; ++x, ++i)
         {
             int n = pix[i];
             buf[0][x,y] = (byte)((n >> 16) & 255);
             buf[1][x,y] = (byte)((n >> 8) & 255);
             buf[2][x,y] = (byte)(n & 255);
         }
     }
     MemoryStream stream = new MemoryStream();
     FJ.Image img = new FJ.Image(new FJ.ColorModel { colorspace = FJ.ColorSpace.RGB }, buf);
     JpegEncoder enc = new JpegEncoder(img, 80, stream);
     enc.Encode();
     stream.Seek(0, SeekOrigin.Begin);
     Form form = new Form();
     form["name"] = nameTextField.Text;
     form["pin"] = m_verified;
     form["kind"] = kind;
     form["width"] = W.ToString();
     form["height"] = H.ToString();
     if (replace)
     {
         form["replace"] = "replace";
     }
     form.Add(new FileData("file", stream, stream.Length, "image/jpeg", System.IO.Path.GetFileNameWithoutExtension(fileName) + ".jpg"));
     form.Submit(WebRequest.CreateHttp(m_baseUrl + "upload"), (FormSubmissionEventArgs e) =>
     {
         if (!e.Success)
         {
             PlaySound("error");
             SetMode(Mode.Disconnected);
             if (e.Response != null && e.Response.StatusCode == HttpStatusCode.NotFound)
             {
                 SetReason(Reason.Rejected);
             }
             else
             {
                 SetReason(Reason.NoConnection);
             }
         }
     }, Dispatcher);
 }
Beispiel #25
0
        /// <summary>
        /// Client
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            #region Adapter

            Console.WriteLine("Adapter initialize ");

            Target target  = new Target();
            Target target2 = new Adaptee();

            Target target3 = new Adapter.Adapter();
            target.Request();
            Console.ReadKey();

            Console.WriteLine("Adapter Finalize " + Environment.NewLine);

            #endregion

            #region Bridge

            Console.WriteLine("Bridge initialize ");

            //Step 1
            ExportationBridge exp = new ExportationDOC();
            exp.Export();

            //Apply Brige Pattern
            Exportation exportacao = new ExportationEx();

            //Inject object
            exportacao.Implementor = new ExportationPDF();
            exportacao.Export();

            Console.WriteLine("Bridge finalize" + Environment.NewLine);
            Console.ReadKey();

            #endregion

            #region Composite

            Console.WriteLine("Composite initialize");

            var form = new Form("Cadastro Clientes");
            form.Add(new Button("Incluir"));
            form.Add(new Button("Consultar"));
            form.Add(new TextBox("Nome"));
            form.Add(new TextBox("Fone"));
            form.Display();

            Console.WriteLine("Composite finalize" + Environment.NewLine);
            Console.ReadKey();

            #endregion

            #region Decorator

            Console.WriteLine("Decorator initialize");

            //Step 1
            var dec = new DataSet();
            dec.Write();

            //Apply Decorator
            DataSet c = new DataSet();
            DataSetConcreteDecorator d = new DataSetConcreteDecorator();

            //Setando objeto a ser decorado
            d.setDatasetbase(c);
            d.Write();
            d.WriteXML();

            Console.WriteLine("Decorator finalize" + Environment.NewLine);
            Console.ReadKey();

            #endregion

            #region Facade

            Console.WriteLine("Facade initialize");

            //Step 1
            var email = new Mail(new SMTPSettings());
            var msg   = new MailMessage(new MailFormatTXT());
            msg.Message = "Hello world";
            email.Send(msg);
            Console.ReadKey();

            //Apply Facade pattern
            var emailFachada = new Email();
            emailFachada.Send("Hello world");

            Console.WriteLine("Facade finalize");
            Console.ReadKey();

            #endregion

            #region Flyweight

            Console.WriteLine("Flyweight initialize");

            int ext = 10;

            FlyweightFactory  factory = new FlyweightFactory();
            FlyweightAbstract f1      = factory.GetFlyweight("A");
            f1.Operation(ext++);
            FlyweightAbstract f2 = factory.GetFlyweight("B");
            f2.Operation(ext++);
            FlyweightAbstract f3 = factory.GetFlyweight("C");
            f3.Operation(ext++);
            FlyweightAbstract f4 = new UnsharedConcreteFlyweight();
            f4.Operation(ext++);

            Console.WriteLine("Flyweight finalize" + Environment.NewLine);
            Console.ReadKey();

            #endregion

            #region Proxy

            Console.WriteLine("Proxy initialize");

            //Step 1
            var calc = new Calc();
            var r    = calc.Somar(3, 5);
            Console.WriteLine(r.ToString());
            Console.ReadLine();

            //Aplly Proxy Pattern
            var calcProxy = new CalcProxy();
            var r2        = calcProxy.Somar(3, 5);
            Console.WriteLine(r2.ToString());

            Console.WriteLine("Proxy finalize" + Environment.NewLine);
            Console.ReadLine();

            #endregion
        }
Beispiel #26
0
 [Given(@"Add control to form with name (.*)")] public void GivenAddAControlInputToForm(string name)
 {
     _componentForm.Add <Input>(name);
 }