public static Sizer MyDialogFunc( Window parent, bool call_fit, bool set_sizer )
    {
        BoxSizer item0 = new BoxSizer( Orientation.wxVERTICAL );

        StaticBox item2 = new StaticBox( parent, -1, "Copyright" );
        item2.Font = new wx.Font( 16, wx.FontFamily.wxROMAN, wx.FontStyle.wxNORMAL, wx.FontWeight.wxNORMAL );
        StaticBoxSizer item1 = new StaticBoxSizer( item2, Orientation.wxVERTICAL );

        StaticText item3 = new StaticText( parent, ID_TEXT, "Copyright 2002 T. Coon. 1000,- ¤.", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item3.ForegroundColour = Colour.wxBLUE;
        item3.Font = new wx.Font( 16, wx.FontFamily.wxROMAN, wx.FontStyle.wxNORMAL, wx.FontWeight.wxNORMAL );
        item1.Add( item3, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        item0.Add( item1, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        StaticLine item4 = new StaticLine( parent, ID_LINE, Window.wxDefaultPosition, new Size(20,-1), StaticLine.wxLI_HORIZONTAL );
        item0.Add( item4, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        Button item5 = new Button( parent, Window.wxID_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item0.Add( item5, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        if (set_sizer)
        {
            parent.SetSizer( item0 );
            if (call_fit)
                item0.SetSizeHints( parent );
        }

        return item0;
    }
        public HttpResponseMessage add(StaticText post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null");
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist");
            }

            // Make sure that the data is valid
            post.id = AnnytabDataValidation.TruncateString(post.id, 100);
            post.value = AnnytabDataValidation.TruncateString(post.value, 200);

            // Check if the id exists
            if(StaticText.MasterPostExists(post.id) == true)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The id already exists");
            }

            // Make sure that the id contains valid characters
            if (AnnytabDataValidation.CheckPageNameCharacters(post.id) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The id contains characters that not are allowed");
            }

            // Add the post
            StaticText.Add(post, languageId);

            // Return the success response
            return Request.CreateResponse<string>(HttpStatusCode.OK, "The post has been added");

        } // End of the add method
Exemple #3
0
        public static int MessageBoxRect(Rect R, string Msg, MessageBoxFlags AOptions, params object[] Params)
        {
            string[] ButtonName = new string[4] {
                "~Y~es", "~N~o", "O~K~", "Cancel"
            };
            int[] Commands = new int[4] {
                View.cmYes, View.cmNo, View.cmOk, View.cmCancel
            };
            string[] Titles = new string[4] {
                "Warning", "Error", "Information", "Confirm"
            };

            int    X, ButtonCount;
            Dialog Dialog;
            View   Control;

            View[] ButtonList = new View[4];
            string S;

            Dialog  = new Dialog(R, Titles[(int)AOptions & 0x03]);
            R       = new Rect(3, 2, Dialog.Size.X - 2, Dialog.Size.Y - 3);
            S       = string.Format(Msg, Params);
            Control = new StaticText(R, S);
            Dialog.Insert(Control);
            X           = -2;
            ButtonCount = 0;
            for (int i = 0; i < 4; i++)
            {
                if (((int)AOptions & (0x0100 << i)) != 0)
                {
                    R       = new Rect(0, 0, 12, 2);
                    Control = new Button(R, ButtonName[i], Commands[i], Button.ButtonFlags.Normal);
                    X      += Control.Size.X + 2;
                    ButtonList[ButtonCount] = Control;
                    ButtonCount++;
                }
            }
            X = (Dialog.Size.X - X) >> 1;
            for (int i = 0; i < ButtonCount; i++)
            {
                Control = ButtonList[i];
                Dialog.Insert(Control);
                Control.MoveTo(X, Dialog.Size.Y - 3);
                X += Control.Size.X + 2;
            }
            Dialog.SelectNext(false);
            if ((AOptions & MessageBoxFlags.mfCentered) != 0)
            {
                Dialog.Options |= View.OptionFlags.ofCentered;
            }
            if ((AOptions & MessageBoxFlags.mfInsertInApp) == 0)
            {
                return(Program.Desktop.ExecView(Dialog));
            }
            else
            {
                return(Program.Application.ExecView(Dialog));
            }
        }
        public ActionResult translate(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();

            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor", "Translator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession    = true;
                ViewBag.AdminErrorCode  = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return(View("index"));
            }
            else
            {
                // Redirect the user to the start page
                return(RedirectToAction("index", "admin_login"));
            }

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get the language id
            int languageId = 0;

            if (Request.Params["lang"] != null)
            {
                Int32.TryParse(Request.Params["lang"], out languageId);
            }

            // Add data to the form
            ViewBag.LanguageId           = languageId;
            ViewBag.Languages            = Language.GetAll(adminLanguageId, "name", "ASC");
            ViewBag.StandardOptionType   = OptionType.GetOneById(id, adminLanguageId);
            ViewBag.StandardOptions      = Option.GetByOptionTypeId(id, adminLanguageId);
            ViewBag.TranslatedOptionType = OptionType.GetOneById(id, languageId);
            ViewBag.TranslatedOptions    = Option.GetByOptionTypeId(id, languageId);
            ViewBag.TranslatedTexts      = StaticText.GetAll(adminLanguageId, "id", "ASC");
            ViewBag.ReturnUrl            = returnUrl;

            // Return the view
            if (ViewBag.StandardOptionType != null)
            {
                return(View("translate"));
            }
            else
            {
                return(Redirect("/admin_options" + returnUrl));
            }
        } // End of the translate method
        public IControl this[string id]
        {
            get
            {
                Control ret = null;
                VirindiViewService.Controls.HudControl iret = myView[id];
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudButton))
                {
                    ret = new Button();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudCheckBox))
                {
                    ret = new CheckBox();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudTextBox))
                {
                    ret = new TextBox();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudCombo))
                {
                    ret = new Combo();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudHSlider))
                {
                    ret = new Slider();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudList))
                {
                    ret = new List();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudStaticText))
                {
                    ret = new StaticText();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudTabView))
                {
                    ret = new Notebook();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudProgressBar))
                {
                    ret = new ProgressBar();
                }
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudImageButton))
                {
                    ret = new ImageButton();
                }

                if (ret == null)
                {
                    return(null);
                }

                ret.myControl = iret;
                ret.myName    = id;
                ret.Initialize();
                allocatedcontrols.Add(ret);
                return(ret);
            }
        }
Exemple #6
0
        /// <summary>
        /// Creates the controls for use in the dialog
        /// </summary>
        private void CreateControls()
        {
            // Right justify static controls
            Element e = dialog.GetDefaultElement(ControlType.StaticText, 0);

            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Left;

            // Title
            int        y     = 5;
            StaticText title = dialog.AddStatic((int)AircraftDialogControlIds.Static, "Aircraft", 10, 5, 400, 30);

            e            = title[0];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.Top | DrawTextFormat.Left;

            ReadAircraftList();

            aircraftCombo = dialog.AddComboBox((int)AircraftDialogControlIds.ComboAircraft, 10, y += 30, 200, 24);
            foreach (AircraftInfo aircraft in aircraftList)
            {
                aircraftCombo.AddItem(aircraft.Name, aircraft);
            }
            //aircraftCombo.SetSelected("BMI Allegro 1500");
            aircraftCombo.SetSelected("El Trainer");

            /*
             * aircraftCombo.AddItem("Cessna", "aircraft\\cessna\\cessna.par");
             * aircraftCombo.AddItem("Extra", "aircraft\\extra\\extra.par");
             * aircraftCombo.AddItem("Thermal sailplane", "aircraft\\glider\\glider.par");
             * aircraftCombo.AddItem("BMKDesigns P-51", "aircraft\\BMK_P-51\\BMK_P-51.par");
             * aircraftCombo.AddItem("Eurocopter Tiger", "aircraft\\tiger\\tiger.par");
             */
            aircraftCombo.Changed += new EventHandler(aircraftCombo_Changed);

            //aircraftPicture = dialog.AddPicture((int)AircraftDialogControlIds.PictureAircraft, "aircraft\\BMI Allegro 1500\\allegro_icon.png", 340, 30, 256, 256);
            aircraftPicture = dialog.AddPicture((int)AircraftDialogControlIds.PictureAircraft, "aircraft\\cessna\\icon.png", 340, 30, 256, 256);
            aircraftPicture.SourceRectangle = new System.Drawing.Rectangle(0, 0, 256, 256);

            aircraftText = dialog.AddStatic((int)AircraftDialogControlIds.TextAircraft, "", 10, y += 30, 320, 240);
            e            = aircraftText[0];
            e.FontIndex  = 0;
            e.textFormat = DrawTextFormat.Top | DrawTextFormat.Left | DrawTextFormat.WordBreak;
            UpdateText();

            checkboxStartOnWater           = dialog.AddCheckBox((int)AircraftDialogControlIds.CheckStartOnWater, "Start on water", 10, 320, 200, 24, true);
            checkboxStartOnWater.Changed  += new EventHandler(checkboxStartOnWater_Changed);
            checkboxStartOnWater.IsVisible = false;

            buttonBuy           = dialog.AddButton((int)AircraftDialogControlIds.Buy, "buy/more info", 370, 300, 196, 32);
            buttonBuy.Click    += new EventHandler(buttonBuy_Click);
            buttonBuy.IsVisible = false;
            //buttonBuy.IsVisible = true;

            buttonBack        = dialog.AddButton((int)AircraftDialogControlIds.Back, "back to menu", 190, 435, 100, 31);
            buttonBack.Click += new EventHandler(buttonBack_Click);

            buttonOk        = dialog.AddButton((int)AircraftDialogControlIds.OK, "back to sim", 350, 435, 100, 31);
            buttonOk.Click += new EventHandler(buttonOk_Click);
        }
Exemple #7
0
 public OrderInputEditingPage()
 {
     LabelDirectory = new StaticText(By.CssSelector("legend"));
     PickupStatus   = new Select(By.Name("pickup_status"));
     PickupDate     = new StaticText(By.Name("pickup_date"));
     TransferCDDate = new StaticText(By.Name("transfer_date"));
     ProcessDate    = new StaticText(By.Name("process_date"));
 }
Exemple #8
0
 public СalculatorRowControl(int index, string locator)
     : base(By.XPath(string.Format(locator)))
 {
     Company       = new StaticText(By.XPath(string.Format("{1}/tbody/tr[{0}]/td[1]", index, locator)));
     TimeDelivery  = new StaticText(By.XPath(string.Format("{1}/tbody/tr[{0}]/td[2]", index, locator)));
     PriceDelivery = new StaticText(By.XPath(string.Format("{1}/tbody/tr[{0}]/td[3]", index, locator)));
     PricePickup   = new StaticText(By.XPath(string.Format("{1}/tbody/tr[{0}]/td[5]", index, locator)));
 }
Exemple #9
0
        public StaticText get_by_id(string id = "", Int32 languageId = 0)
        {
            // Create the post to return
            StaticText post = StaticText.GetOneById(id, languageId);

            // Return the post
            return(post);
        } // End of the get_by_id method
Exemple #10
0
        public Dictionary <string, string> get_all(Int32 languageId = 0, string sortField = "", string sortOrder = "")
        {
            // Create the list to return
            KeyStringList posts = StaticText.GetAll(languageId, sortField, sortOrder);

            // Return the list
            return(posts.dictionary);
        } // End of the get_all method
 public SupportFreshDeskPage()
 {
     LabelDirectory = new StaticText(By.CssSelector("body > div > header > div > div > h1"));
     HomeLink       = new Link(By.LinkText("Главная"));
     SolutionsLink  = new Link(By.LinkText("Решения"));
     TicketsLink    = new Link(By.LinkText("Заявки"));
     LogOut         = new Link(By.XPath("//header/div/nav/b[2]/a"));
 }
Exemple #12
0
    } // End of the UnprotectCookieValue method

    /// <summary>
    /// Get a 404 not found page
    /// </summary>
    /// <returns>A string with html</returns>
    public static string GetHttpNotFoundPage()
    {
        // Create the string to return
        string htmlString = "";

        // Get the current domain
        Domain currentDomain = Tools.GetCurrentDomain();

        // Get the error page
        StaticPage staticPage = StaticPage.GetOneByConnectionId(5, currentDomain.front_end_language);
        staticPage = staticPage != null ? staticPage : new StaticPage();

        // Get the translated texts
        KeyStringList tt = StaticText.GetAll(currentDomain.front_end_language, "id", "ASC");

        // Create the Route data
        System.Web.Routing.RouteData routeData = new System.Web.Routing.RouteData();
        routeData.Values.Add("controller", "home");

        // Create the controller context
        System.Web.Mvc.ControllerContext context = new System.Web.Mvc.ControllerContext(new System.Web.Routing.RequestContext(new HttpContextWrapper(HttpContext.Current), routeData), new Annytab.Webshop.Controllers.homeController());

        // Create the bread crumb list
        List<BreadCrumb> breadCrumbs = new List<BreadCrumb>(2);
        breadCrumbs.Add(new BreadCrumb(tt.Get("start_page"), "/"));
        breadCrumbs.Add(new BreadCrumb(staticPage.link_name, "/home/error/404"));

        // Set form values
        context.Controller.ViewBag.BreadCrumbs = breadCrumbs;
        context.Controller.ViewBag.CurrentCategory = new Category();
        context.Controller.ViewBag.TranslatedTexts = tt;
        context.Controller.ViewBag.CurrentDomain = currentDomain;
        context.Controller.ViewBag.CurrentLanguage = Language.GetOneById(currentDomain.front_end_language);
        context.Controller.ViewBag.StaticPage = staticPage;
        context.Controller.ViewBag.PricesIncludesVat = HttpContext.Current.Session["PricesIncludesVat"] != null ? Convert.ToBoolean(HttpContext.Current.Session["PricesIncludesVat"]) : currentDomain.prices_includes_vat;

        // Render the view
        using (StringWriter stringWriter = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture))
        {
            string viewPath = currentDomain.custom_theme_id == 0 ? "/Views/home/error.cshtml" : "/Views/theme/error.cshtml";
            System.Web.Mvc.RazorView razor = new System.Web.Mvc.RazorView(context, viewPath, null, false, null);
            razor.Render(new System.Web.Mvc.ViewContext(context, razor, context.Controller.ViewData, context.Controller.TempData, stringWriter), stringWriter);
            htmlString += stringWriter.ToString();
        }

        //// Create the web page
        //notFoundString += "<html><head>";
        //notFoundString += "<meta charset=\"utf-8\">";
        //notFoundString += "<title>" + staticPage.title + "</title></head>";
        //notFoundString += "<body><div style=\"text-align:center;margin:200px auto auto auto;\"><h1>" + staticPage.title + "</h1>";
        //notFoundString += "<p>" + staticPage.main_content + "</p>";
        //notFoundString += "<a href=\"/\">" + tt.Get("start_page") + "</a></div></body>";
        //notFoundString += "</html>";

        // Return the string
        return htmlString;

    } // End of the GetHttpNotFoundPage method
        public DynamicText SaveDynamicText(DynamicText dynamicText,
                                           IfDefaultNotExistAction actionForDefaultCulture = IfDefaultNotExistAction.DoNothing)
        {
            using (var dbContext = m_dbContextFunc.Invoke())
            {
                var dao             = new StaticTextDao(dbContext.StaticText);
                var dictionaryScope = GetDictionaryScope(dbContext, dynamicText.DictionaryScope);
                if (dictionaryScope.Name != dynamicText.DictionaryScope)
                {
                    dictionaryScope = CreateDictionaryScope(dbContext, dynamicText.DictionaryScope);
                }

                var culture         = GetCultureByNameOrGetDefault(dbContext, dynamicText.Culture);
                var existsInCulture = culture.Name == dynamicText.Culture;

                if (!existsInCulture)
                {
                    culture = CreateCulture(dbContext, dynamicText.Culture);
                    CreateCultureHierarchy(dbContext, culture);
                }

                var staticText = dao.FindByNameAndCultureAndScope(
                    dynamicText.Name, culture, dictionaryScope, dbContext.CultureHierarchy
                    );
                if (staticText == null || !existsInCulture || staticText.CultureId != culture.Id)
                {
                    staticText = new StaticText
                    {
                        Format           = dynamicText.Format,
                        ModificationTime = DateTime.UtcNow,
                        ModificationUser = dynamicText.ModificationUser,
                        Name             = dynamicText.Name,
                        Text             = dynamicText.Text,
                        Culture          = culture,
                        DictionaryScope  = dictionaryScope
                    };

                    dao.Create(staticText);
                }
                else
                {
                    staticText.Format           = dynamicText.Format;
                    staticText.ModificationTime = DateTime.UtcNow;
                    staticText.ModificationUser = dynamicText.ModificationUser;
                    staticText.Name             = dynamicText.Name;
                    staticText.Text             = dynamicText.Text;

                    dao.Update(staticText);
                }

                ExecuteDefaultCultureAction(actionForDefaultCulture, dynamicText, culture, dictionaryScope, dbContext,
                                            dao);

                dbContext.SaveChanges();

                return(dynamicText);
            }
        }
        public ActionResult images(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get the return url
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get form values
            Int32 categoryId = Convert.ToInt32(collection["txtId"]);
            Int32 languageId = Convert.ToInt32(collection["selectLanguage"]);

            // Get images
            string[] environmentImageUrls = collection.GetValues("otherImageUrl");
            HttpPostedFileBase mainImage = null;
            List<HttpPostedFileBase> environmentImages = new List<HttpPostedFileBase>(10);

            HttpFileCollectionBase images = Request.Files;
            string[] imageKeys = images.AllKeys;
            for (int i = 0; i < images.Count; i++)
            {
                if (images[i].ContentLength == 0)
                    continue;

                if (imageKeys[i] == "uploadMainImage")
                    mainImage = images[i];
                else
                    environmentImages.Add(images[i]);
            }

            // Update images
            UpdateImages(categoryId, languageId, mainImage, environmentImages, environmentImageUrls);

            // Redirect the user to the list
            return Redirect("/admin_categories" + returnUrl);

        } // End of the images method
Exemple #15
0
 public SupportRowControl(int index)
     : base(By.XPath(string.Format("//tbody")))
 {
     TicketId   = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[1]", index)));
     Time       = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[2]/strong", index)));
     TicketText = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[3]", index)));
     Content    = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[4]", index)));
     Status     = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[5]", index)));
 }
        public ActionResult images(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query paramaters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get the language id
            int languageId = 0;
            if (Request.Params["lang"] != null)
            {
                Int32.TryParse(Request.Params["lang"], out languageId);
            }

            // Add data to the view
            ViewBag.LanguageId = languageId;
            ViewBag.Languages = Language.GetAll(adminLanguageId, "name", "ASC");
            ViewBag.Category = Category.GetOneById(id, adminLanguageId);
            ViewBag.MainImageUrl = GetMainImageUrl(id, languageId);
            ViewBag.EnvironmentImages = Tools.GetEnvironmentImageUrls(id, languageId, true);
            ViewBag.TranslatedTexts = StaticText.GetAll(adminLanguageId, "id", "ASC");
            ViewBag.ReturnUrl = returnUrl;

            // Return the view
            if (ViewBag.Category != null)
            {
                return View("images");
            }
            else
            {
                return Redirect("/admin_categories" + returnUrl);
            }

        } // End of the images method
        public ActionResult edit(Int32 id = 0, Int32 administratorId = 0, Int32 languageId = 0, string returnUrl = "/admin_ratings")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Get the signed in administrator
            Administrator administrator = Administrator.GetSignedInAdministrator();

            // Get the post rating
            PostRating postRating = PostRating.GetOneById(id, administratorId, languageId);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (administrator != null && administrator.admin_role == "Author" && 
                (postRating == null || postRating.administrator_id == administrator.id))
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the default admin language
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Add data to the view
            ViewBag.TranslatedTexts = StaticText.GetAll(adminLanguageId, "id", "ASC");
            ViewBag.PostRating = postRating;
            ViewBag.ReturnUrl = returnUrl;

            // Return the user to the index page if the rating does not exist
            if (ViewBag.PostRating == null)
            {
                // Return the user to the index page
                return Redirect(returnUrl);
            }

            // Return the edit view
            return View("edit");

        } // End of the edit method
        public ActionResult delete(Int32 id = 0, string returnUrl = "/admin_comments")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Get the signed in administrator
            Administrator administrator = Administrator.GetSignedInAdministrator();

            // Get the comment
            PostComment comment = PostComment.GetOneById(id);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (administrator != null && administrator.admin_role == "Author" && 
                (comment == null || comment.administrator_id == administrator.id))
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Create an error code variable
            Int32 errorCode = 0;

            // Delete the comment post and all the connected posts (CASCADE)
            errorCode = PostComment.DeleteOnId(id);

            // Check if there is an error
            if (errorCode != 0)
            {
                ViewBag.AdminErrorCode = errorCode;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }

            // Redirect the user to the list
            return Redirect(returnUrl);

        } // End of the delete method
        public ActionResult edit(Int32 id = 0, string returnUrl = "/admin_posts")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query paramaters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Get the administrator
            Administrator administrator = Administrator.GetSignedInAdministrator();

            // Get the post
            Post post = Post.GetOneById(id, currentDomain.back_end_language);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (administrator != null && administrator.admin_role == "Author" &&
            (post == null || post.administrator_id == administrator.id))
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Add data to the view
            ViewBag.Keywords = "";
            ViewBag.CurrentPage = 1;
            ViewBag.Post = post;
            ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
            ViewBag.ReturnUrl = returnUrl;

            // Make sure that post not is null
            if (ViewBag.Post == null)
            {
                // Create a new empty post
                ViewBag.Post = new Post();
            }

            // Return the edit view
            return View("edit");

        } // End of the edit method
Exemple #20
0
 public WarehousesRowControl(int index)
     : base(By.XPath(string.Format("//tbody")))
 {
     Name      = new Link(By.XPath(string.Format("//tbody/tr[{0}]/td[1]/a", index)));
     Documents = new Link(By.XPath(string.Format("//tbody/tr[{0}]/td[2]/a", index)));
     City      = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[3]", index)));
     Address   = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[4]", index)));
     Contact   = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[5]", index)));
     TimeWork  = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[6]", index)));
 }
Exemple #21
0
 public UsersRowControl(int index)
     : base(index)
 {
     UserEmail     = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[2]", index)));
     OfficialName  = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[3]", index)));
     Logins        = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[4]", index)));
     UserLastLogin = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[5]", index)));
     UserActive    = new StaticText(By.XPath(string.Format("//tbody/tr[{0}]/td[6]", index)));
     ActionsAuth   = new Link(By.XPath(string.Format("//tbody/tr[{0}]/td[7]/a[3]", index)));
 }
Exemple #22
0
 public WdlControl()
 {
     mIndexDraw = new StaticText
     {
         FontFamily = "Segoe UI",
         FontSize   = 18.0f,
         Weight     = SharpDX.DirectWrite.FontWeight.Bold,
         Text       = "Selected ADT: 0/0"
     };
 }
Exemple #23
0
        public DocumentsPreparedPage()
        {
            WarehouseSelect = new Select(By.ClassName("check_warehouse"));

            InstructionsForUse = new Link(By.LinkText("Инструкция по использованию"));
            Stickers           = new Link(By.LinkText("Наклейки"));
            Acts      = new Link(By.LinkText("Акты для компании забора"));
            ActsTC    = new Link(By.LinkText("Акты для самостоятельной передачи заказов на склады ТК"));
            TextAlert = new StaticText(By.XPath("//div/div[@class='alert']"));
        }
Exemple #24
0
        public Checkbox()
        {
            mTextDraw = new StaticText
            {
                Weight            = SharpDX.DirectWrite.FontWeight.Bold,
                VerticalAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center
            };

            Text = "";
        }
Exemple #25
0
        public Checkbox()
        {
            mTextDraw = new StaticText
            {
                Weight = SharpDX.DirectWrite.FontWeight.Bold,
                VerticalAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center
            };

            Text = "";
        }
Exemple #26
0
 public WdlControl()
 {
     mIndexDraw = new StaticText
     {
         FontFamily = "Segoe UI",
         FontSize = 18.0f,
         Weight = SharpDX.DirectWrite.FontWeight.Bold,
         Text = "Selected ADT: 0/0"
     };
 }
Exemple #27
0
        private StaticText AddStaticText(int y)
        {
            StaticText text = dialog.AddStatic((int)CenterHudControlIds.Static, "", 10, y, dialog.Width, 20);
            Element    e    = text[0];

            e.FontIndex    = 0;
            e.textFormat   = DrawTextFormat.Left;
            text.IsVisible = false;
            return(text);
        }
        public ActionResult delete(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the review
            ProductReview review = ProductReview.GetOneById(id);

            // Create an error code variable
            Int32 errorCode = 0;

            // Make sure that the review not is null
            if(review != null)
            {
                // Delete the review
                errorCode = ProductReview.DeleteOnId(id);

                // Check if there is an error
                if (errorCode != 0)
                {
                    ViewBag.AdminErrorCode = errorCode;
                    ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                    return View("index");
                }

                // Update the product rating
                Product.UpdateRating(review.product_id, review.language_id);
            }
            
            // Redirect the user to the list
            return Redirect("/admin_product_reviews" + returnUrl);

        } // End of the delete method
Exemple #29
0
    } // End of the MasterPostExists method

    /// <summary>
    /// Get one static text based on id
    /// </summary>
    /// <param name="id">A static text id</param>
    /// <param name="languageId">The language id</param>
    /// <returns>A reference to a static text post</returns>
    public static StaticText GetOneById(string id, Int32 languageId)
    {
        // Create the post to return
        StaticText post = null;

        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "SELECT * FROM dbo.static_texts WHERE id = @id AND language_id = @language_id;";

        // The using block is used to call dispose automatically even if there are an exception
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there are an exception
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@id", id);
                cmd.Parameters.AddWithValue("@language_id", languageId);

                // Create a MySqlDataReader
                SqlDataReader reader = null;

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases
                try
                {
                    // Open the connection.
                    cn.Open();

                    // Fill the reader with one row of data
                    reader = cmd.ExecuteReader();

                    // Loop through the reader as long as there is something to read and add values
                    while (reader.Read())
                    {
                        post = new StaticText(reader);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                finally
                {
                    // Call Close when done reading to avoid memory leakage
                    if (reader != null)
                        reader.Close();
                }
            }
        }

        // Return the post
        return post;

    } // End of the GetOneById method
Exemple #30
0
        public ActionResult delete(Int32 id = 0, string returnUrl = "")
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the image map
            InspirationImageMap imageMap = InspirationImageMap.GetOneById(id);

            // Create an error code variable
            Int32 errorCode = 0;

            // Delete the image map post and all the connected posts (CASCADE)
            errorCode = InspirationImageMap.DeleteOnId(id);

            // Check if there is an error
            if (errorCode != 0)
            {
                ViewBag.AdminErrorCode = errorCode;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }

            // Delete the image
            if (imageMap != null)
            {
                DeleteInspirationImage(imageMap.id);
            }

            // Redirect the user to the list
            return Redirect("/admin_inspiration" + returnUrl);

        } // End of the delete method
Exemple #31
0
        public MapSelectQuad()
        {
            mTextDraw = new StaticText
            {
                FontFamily = "Segoe UI",
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold
            };

            Size = new Vector2(96, 96);
        }
        public ActionResult edit_comment(FormCollection collection)
        {
            // Get the signed in user
            Administrator user = Administrator.GetSignedInAdministrator();

            // Check if the user is signed in
            if (user == null)
            {
                return RedirectToAction("login", "user");
            }

            // Get the current domain
            Domain domain = Tools.GetCurrentDomain();

            // Get the translated texts
            KeyStringList tt = StaticText.GetAll(domain.front_end_language, "id", "ASC");

            // Get form values
            Int32 commentId = Convert.ToInt32(collection["hiddenId"]);
            Int32 languageId = Convert.ToInt32(collection["hiddenLanguageId"]);
            string commentText = collection["txtCommentText"];

            // Modify the comment text
            commentText = commentText.Replace(Environment.NewLine, "<br />");

            // Get the comment
            PostComment comment = PostComment.GetOneById(commentId);

            // Get the post
            Post post = Post.GetOneById(comment.post_id, languageId);

            // Update the comment
            if(comment != null && comment.administrator_id == user.id)
            {
                // Update values
                comment.comment_date = DateTime.UtcNow;
                comment.comment_text = commentText;

                // Update the comment
                PostComment.Update(comment);

                // Send a email to the administrator of the website
                string subject = tt.Get("comment") + " - " + domain.website_name;
                string message = tt.Get("post") + ": " + comment.post_id.ToString() + "<br />"
                    + tt.Get("language") + ": " + comment.language_id.ToString() + "<br />"
                    + tt.Get("user_name") + ": " + user.admin_user_name + "<br /><br />" 
                    + comment.comment_text;
                Tools.SendEmailToHost("", subject, message);
            }

            // Redirect the user to the post
            return Redirect("/home/post/" + post.page_name + "#comments");

        } // End of the edit_comment method
        public void Initialize()
        {
            dialog = new Dialog(Framework.Instance);
            dialog.SetFont(0, "Arial", 14, FontWeight.Normal);
            dialog.SetFont(1, "Arial", 20, FontWeight.Bold);
            dialog.SetSize(600, 400);
            dialog.SetBackgroundColors(
                new ColorValue(0.5f, 0.5f, 0.5f, 128f),
                new ColorValue(0.5f, 0.5f, 0.5f, 128f),
                new ColorValue(0, 0, 0, 128f),
                new ColorValue(0, 0, 0, 128f));

            text = dialog.AddStatic((int)WelcomeDialogControlIds.Static,
                                    "Hi, and welcome to R/C Desk Pilot.\nDownloading news, please wait...",
                                    dialog.Width / 2 - 290, 10, 580, 265);
            Element e = text[0];

            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.Top | DrawTextFormat.Center | DrawTextFormat.WordBreak;

            infoButton        = dialog.AddButton((int)WelcomeDialogControlIds.InfoButton, "website", dialog.Width / 2 - 70, dialog.Height - 120, 140, 30);
            infoButton.Click += new EventHandler(infoButton_Click);
            e            = infoButton[0];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Center | DrawTextFormat.WordBreak;
            e            = infoButton[1];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Center | DrawTextFormat.WordBreak;

            startText = dialog.AddStatic((int)WelcomeDialogControlIds.Static,
                                         "Click one of the buttons below to start flying or watch the demo.",
                                         dialog.Width / 2 - 290, dialog.Height - 80, 580, 30);
            e            = startText[0];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.Top | DrawTextFormat.Center | DrawTextFormat.WordBreak;

            startButton        = dialog.AddButton((int)WelcomeDialogControlIds.StartButton, "Start", dialog.Width / 4 - 60, dialog.Height - 40, 120, 30);
            startButton.Click += new EventHandler(startButton_Click);
            e            = startButton[0];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Center | DrawTextFormat.WordBreak;
            e            = startButton[1];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Center | DrawTextFormat.WordBreak;

            demoButton        = dialog.AddButton((int)WelcomeDialogControlIds.DemoButton, "Demo", 3 * dialog.Width / 4 - 60, dialog.Height - 40, 120, 30);
            demoButton.Click += new EventHandler(demoButton_Click);
            e            = demoButton[0];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Center | DrawTextFormat.WordBreak;
            e            = demoButton[1];
            e.FontIndex  = 1;
            e.textFormat = DrawTextFormat.VerticalCenter | DrawTextFormat.Center | DrawTextFormat.WordBreak;
        }
Exemple #34
0
        public StaticText CreateStaticText(string type, string name)
        {
            IntPtr     cPtr = CeguiBindingsPINVOKE.WindowManager_CreateStaticText(swigCPtr, new CeguiDotNet.String(type).HandleRef, new CeguiDotNet.String(name).HandleRef);
            StaticText ret  = (cPtr == IntPtr.Zero) ? null : new StaticText(cPtr, false);

            if (CeguiBindingsPINVOKE.SWIGPendingException.Pending)
            {
                throw CeguiBindingsPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemple #35
0
        public SizeListControl(By className)
            : base(className)
        {
            locator = className.ToString().Replace("By.XPath: ", "");

            Width  = new StaticText(By.XPath(string.Format("{0}/tbody/tr[1]/td", locator)));
            Height = new StaticText(By.XPath(string.Format("{0}/tbody/tr[2]/td", locator)));
            Length = new StaticText(By.XPath(string.Format("{0}/tbody/tr[3]/td", locator)));
            Weight = new StaticText(By.XPath(string.Format("{0}/tbody/tr[4]/td", locator)));
            Count  = new StaticText(By.XPath(string.Format("{0}/tbody/tr[5]/td", locator)));
        }
Exemple #36
0
        public Button()
        {
            mTextDraw = new StaticText()
            {
                Weight = SharpDX.DirectWrite.FontWeight.Bold,
                FontSize = 14.0f,
                VerticalAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center,
                HorizontalAlignment = SharpDX.DirectWrite.TextAlignment.Center
            };

            Size = new Vector2(115, 25);
        }
Exemple #37
0
 public Label()
 {
     Color = Brushes.White;
     mTextDraw = new StaticText
     {
         FontFamily = "Segoe UI",
         FontSize = 14.0f,
         HorizontalAlignment = TextAlignment.Leading,
         Size = new Size2F(float.MaxValue, 100.0f),
         Text = "",
         VerticalAlignment = ParagraphAlignment.Near,
         Weight = FontWeight.Bold
     };
 }
Exemple #38
0
        public Frame()
        {
            Children = new List<IComponent>();
            HasCaption = false;
            mCaptionText = new StaticText
            {
                FontFamily = "Segoe UI",
                FontSize = 12.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold,
                VerticalAlignment = SharpDX.DirectWrite.ParagraphAlignment.Center
            };

            Position = new Vector2(0, 0);
            Size = new Vector2(2, 2);
        }
        public PerformanceControl()
        {
            mMemorySamples.Add(Environment.WorkingSet);
            mFpsSamples.Add(0.0f);

            mFpsMax = new StaticText
            {
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold
            };

            mFpsMin = new StaticText
            {
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold
            };

            mMemoryMax = new StaticText
            {
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold
            };

            mMemoryMin = new StaticText
            {
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold
            };

            mFpsCaption = new StaticText
            {
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold,
                Text = "FPS",
                HorizontalAlignment = SharpDX.DirectWrite.TextAlignment.Trailing
            };

            mMemoryCaption = new StaticText
            {
                FontSize = 13.0f,
                Weight = SharpDX.DirectWrite.FontWeight.Bold,
                Text = "RAM-Usage",
                HorizontalAlignment = SharpDX.DirectWrite.TextAlignment.Trailing
            };
        }
Exemple #40
0
        public ValueDisplay(Window parent)
            : base(parent, WxDefaultPosition, WxDefaultSize, WindowStyles.BorderSimple)
        {
            BackgroundColour = Colour.WhiteColour;

            var sizer = new FlexGridSizer(2, 5, 5);

            Font displayFont = new Font(30, FontFamily.wxDefault, FontStyle.Normal, FontWeight.Normal);

            _text = new StaticText(this, "10.000", WxDefaultPosition, WxDefaultSize, WindowStyles.AlignRight | WindowStyles.StaticTextNoAutoResize);
            _text.SetFont(displayFont);
            sizer.Add(_text);

            _unit = new StaticText(this, "mV");
            sizer.Add(_unit, 1, SizerFlag.AlignBottom | SizerFlag.AlignRight | SizerFlag.Right | SizerFlag.Bottom, 5);

            SetSizer(sizer);
            sizer.SetSizeHints(this);
        }
Exemple #41
0
        public EditBox()
        {
            mTextDraw = new StaticText
            {
                Size = new Size2F(float.MaxValue, 28.0f),
                VerticalAlignment = ParagraphAlignment.Center,
                FontSize = 15.0f
            };

            mFullTextDraw = new StaticText
            {
                Size = new Size2F(float.MaxValue, 28.0f),
                VerticalAlignment = ParagraphAlignment.Center,
                FontSize = 15.0f
            };

            mCaretOffset = Padding;
            mText = "";
        }
    public static Sizer MyDialogFunc( Window parent, bool call_fit, bool set_sizer )
    {
        BoxSizer item0 = new BoxSizer( Orientation.wxVERTICAL );

        StaticBox item2 = new StaticBox( parent, -1, "Controls will remember their values" );
        StaticBoxSizer item1 = new StaticBoxSizer( item2, Orientation.wxVERTICAL );

        FlexGridSizer item3 = new FlexGridSizer( 0, 2, 0, 0 );
        item3.AddGrowableCol( 0 );
        item3.AddGrowableCol( 1 );

        StaticText item4 = new StaticText( parent, ID_TEXT, "wxSpinCtrl:", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item4.Name = "TestName";
        item3.Add( item4, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        SpinCtrl item5 = new SpinCtrl( parent, ID_MY_NUMBER, "0", Window.wxDefaultPosition, new Size(130,-1), SpinCtrl.wxSP_ARROW_KEYS|SpinCtrl.wxSP_WRAP, 0, 100, 0 );
        item3.Add( item5, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        StaticText item6 = new StaticText( parent, ID_TEXT, "wxTextCtrl:", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item3.Add( item6, 0, Alignment.wxALIGN_RIGHT|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        TextCtrl item7 = new TextCtrl( parent, ID_MY_TEXT, "", Window.wxDefaultPosition, new Size(130,-1), 0 );
        item3.Add( item7, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        item1.Add( item3, 1, Stretch.wxGROW|Direction.wxALL, 5 );

        item0.Add( item1, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        StaticLine item8 = new StaticLine( parent, ID_LINE, Window.wxDefaultPosition, new Size(300,-1), StaticLine.wxLI_HORIZONTAL );
        item0.Add( item8, 0, Stretch.wxGROW|Alignment.wxALIGN_CENTER_VERTICAL|Direction.wxALL, 5 );

        Button item9 = new Button( parent, Window.wxID_OK, "OK", Window.wxDefaultPosition, Window.wxDefaultSize, 0 );
        item0.Add( item9, 0, Alignment.wxALIGN_CENTER|Direction.wxALL, 5 );

        if (set_sizer)
        {
            parent.SetSizer( item0 );
            if (call_fit)
                item0.SetSizeHints( parent );
        }

        return item0;
    }
Exemple #43
0
    } // End of the constructor

    #endregion

    #region Insert methods

    /// <summary>
    /// Add one static text
    /// </summary>
    /// <param name="post">A reference to a static text post</param>
    /// <param name="languageId">A language id</param>
    public static void Add(StaticText post, Int32 languageId)
    {
        // Create the connection and the sql statement
        string connection = Tools.GetConnectionString();
        string sql = "INSERT INTO dbo.static_texts (id, language_id, value) " +
            "VALUES (@id, @language_id, @value);";

        // The using block is used to call dispose automatically even if there is a exception.
        using (SqlConnection cn = new SqlConnection(connection))
        {
            // The using block is used to call dispose automatically even if there is a exception.
            using (SqlCommand cmd = new SqlCommand(sql, cn))
            {
                // Add parameters
                cmd.Parameters.AddWithValue("@id", post.id);
                cmd.Parameters.AddWithValue("@language_id", languageId);
                cmd.Parameters.AddWithValue("@value", post.value);

                // The Try/Catch/Finally statement is used to handle unusual exceptions in the code to
                // avoid having our application crash in such cases
                try
                {
                    // Open the connection
                    cn.Open();

                    // Execute the insert
                    cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }

        // Remove the list from the cache
        Tools.RemoveKeyFromCache("StaticTexts_" + languageId.ToString());

    } // End of the Add method
        public HttpResponseMessage update(StaticText post, Int32 languageId = 0)
        {
            // Check for errors
            if (post == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The post is null");
            }
            else if (Language.MasterPostExists(languageId) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The language does not exist");
            }

            // Make sure that the data is valid
            post.id = AnnytabDataValidation.TruncateString(post.id, 100);
            post.value = AnnytabDataValidation.TruncateString(post.value, 200);

            // Make sure that the id contains valid characters
            if (AnnytabDataValidation.CheckPageNameCharacters(post.id) == false)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The id contains characters that not are allowed");
            }

            // Get the saved post
            StaticText savedPost = StaticText.GetOneById(post.id, languageId);

            // Check if the post exists
            if (savedPost == null)
            {
                return Request.CreateResponse<string>(HttpStatusCode.BadRequest, "The record does not exist");
            }

            // Update the post
            StaticText.Update(post, languageId);

            // Return the success response
            return Request.CreateResponse<string>(HttpStatusCode.OK, "The update was successful");

        } // End of the update method
        public ActionResult edit(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the default admin language id
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get all the form values
            string staticTextId = collection["txtId"];
            string staticTextText = collection["txtText"];

            // Get the static text
            StaticText staticText = StaticText.GetOneById(staticTextId, adminLanguageId);
            bool postExists = true;

            // Check if the static text exists
            if (staticText == null)
            {
                // Create an empty static text
                staticText = new StaticText();
                staticText.id = staticTextId;
                postExists = false;
            }

            // Update values
            staticText.value = staticTextText;

            // Create a error message
            string errorMessage = string.Empty;

            // Check for errors in the static text
            if (AnnytabDataValidation.CheckPageNameCharacters(staticText.id) == false)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_bad_chars"), tt.Get("id")) + "<br/>";
            }
            if (staticText.id.Length == 0 || staticText.id.Length > 100)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_certain_length"), tt.Get("id"), "1", "100") + "<br/>";
            }
            if (staticText.value.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("text"), "200") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Check if we should add or update the static text
                if (postExists == false)
                {
                    // Add the static text
                    StaticText.Add(staticText, adminLanguageId);
                }
                else
                {
                    // Update the static text
                    StaticText.Update(staticText, adminLanguageId);
                }

                // Redirect the user to the list
                return Redirect(returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.StaticText = staticText;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the edit view
                return View("edit");
            }

        } // End of the edit method
        public virtual void Init()
        {
            TestProvider.SetUp();

            using (var tran = RepositoryFactory.StartTransaction())
            {
                _user = new User()
                               {
                                   Id = Guid.NewGuid(),
                                   Name = "user",
                                   Email = "*****@*****.**"
                               };
                var statText1 = new StaticText
                                    {
                                        Id = Guid.NewGuid(),
                                        Title = "text1",
                                        FriendlyUrl = "text1",
                                        CreatedBy = _user,
                                        CreatedDate = DateTime.Now,
                                        ActualVersion = 1,
                                        PublishDate = new DateTime(2002, 1, 1),
                                        Modified = new DateTime(2002, 3, 1),
                                        AreCommentAllowed = true,
                                        StaticTextVersions = new List<StaticTextVersion>
                                                                 {
                                                                     new StaticTextVersion
                                                                         {
                                                                             Id = Guid.NewGuid(),
                                                                             CreatedBy = _user,
                                                                             Text = "version0",
                                                                             Version = 0,
                                                                             CreatedDate = new DateTime(2002, 1, 1)
                                                                         },
                                                                    new StaticTextVersion
                                                                         {
                                                                             Id = Guid.NewGuid(),
                                                                             CreatedBy = _user,
                                                                             Text = "version1",
                                                                             Version = 1,
                                                                             CreatedDate = new DateTime(2002, 2, 1)
                                                                         }
                                                                 }
                                    };
                 statText1.Comments = new List<Comment>
                                         {
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "first_comment",
                                                     Content = statText1,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1),
                                                     ActualVersion = 0,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       Id = Guid.NewGuid(),
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0,
                                                                                   }
                                                                           }
                                                 },
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "first_comment",
                                                     Content = statText1,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1),
                                                     ActualVersion = 1,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       Id = Guid.NewGuid(),
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0
                                                                                   },
                                                                               new CommentVersion
                                                                                   {
                                                                                       Id = Guid.NewGuid(),
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        2, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.2.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen - change",
                                                                                       Version = 1
                                                                                   }
                                                                           }
                                                 }

                                         };
                var statText2 = new StaticText
                {
                    Id = Guid.NewGuid(),
                    Title = "text2",
                    FriendlyUrl = "text2",
                    CreatedBy = _user,
                    CreatedDate = DateTime.Now,
                    ActualVersion = 2,
                    PublishDate = new DateTime(2002, 2, 1),
                    Modified = new DateTime(2002, 3, 1),
                    AreCommentAllowed = true,
                    StaticTextVersions = new List<StaticTextVersion>
                                                                 {
                                                                     new StaticTextVersion
                                                                         {
                                                                             Id = Guid.NewGuid(),
                                                                             CreatedBy = _user,
                                                                             Text = "version0",
                                                                             Version = 0,
                                                                             CreatedDate = new DateTime(2002, 1, 1)
                                                                         },
                                                                    new StaticTextVersion
                                                                         {
                                                                             Id = Guid.NewGuid(),
                                                                             CreatedBy = _user,
                                                                             Text = "version1",
                                                                             Version = 1,
                                                                             CreatedDate = new DateTime(2002, 2, 1)
                                                                         },
                                                                    new StaticTextVersion
                                                                         {
                                                                             Id = Guid.NewGuid(),
                                                                             CreatedBy = _user,
                                                                             Text = "version2",
                                                                             Version = 2,
                                                                             CreatedDate = new DateTime(2002, 3, 1)
                                                                         }
                                                                 }
                };
                var statText3 = new StaticText
                {
                    Id = Guid.NewGuid(),
                    Title = "text3",
                    FriendlyUrl = "text",
                    CreatedBy = _user,
                    CreatedDate = DateTime.Now,
                    ActualVersion = 0,
                    PublishDate = new DateTime(2002, 3, 1),
                    Modified = new DateTime(2002, 3, 1),
                    AreCommentAllowed = true,
                    StaticTextVersions = new List<StaticTextVersion>
                                                                 {
                                                                     new StaticTextVersion
                                                                         {
                                                                             Id = Guid.NewGuid(),
                                                                             CreatedBy = _user,
                                                                             Text = "only one version",
                                                                             Version = 0,
                                                                             CreatedDate = new DateTime(2002, 1, 1)
                                                                         },
                                                                 }
                };

                TestProvider.Create(_user);
                TestProvider.Create(statText1);
                TestProvider.Create(statText2);
                TestProvider.Create(statText3);
                foreach (var comment in statText1.Comments)
                {
                    TestProvider.Create(comment);
                }
                _testData = new[] { statText1, statText2, statText3 };
                tran.Commit();
            }

            TestProvider.WaitForIndexing();
        }
Exemple #47
0
        public IControl this[string id]
        {
            get
            {
                if (CreatedControlsByName.ContainsKey(id)) return CreatedControlsByName[id];

                Control ret = null;
                VirindiViewService.Controls.HudControl iret = myView[id];
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudButton))
                    ret = new Button();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudCheckBox))
                    ret = new CheckBox();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudTextBox))
                    ret = new TextBox();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudCombo))
                    ret = new Combo();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudHSlider))
                    ret = new Slider();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudList))
                    ret = new List();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudStaticText))
                    ret = new StaticText();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudTabView))
                    ret = new Notebook();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudProgressBar))
                    ret = new ProgressBar();
                if (iret.GetType() == typeof(VirindiViewService.Controls.HudImageButton))
                    ret = new ImageButton();

                if (ret == null) return null;

                ret.myControl = iret;
                ret.myName = id;
                ret.Initialize();
                allocatedcontrols.Add(ret);
                CreatedControlsByName[id] = ret;
                return ret;
            }
        }
Exemple #48
0
        public void Init()
        {
            IoC.InitializeWith(new WindsorContainer());
            ApplicationInit.InitializeRepositories();
            base.SetUp();
            DBInit.RegisterDocumentStore(Store);
            DBInit.RegisterIndexes(Store);

            using (var tran = RepositoryFactory.StartTransaction())
            {
                _user = new User()
                            {
                                Id = Guid.NewGuid(),
                                Name = "user",
                                Email = "*****@*****.**"
                            };
                _testText = new StaticText
                                {
                                    Id = Guid.NewGuid(),
                                    Title = "text3",
                                    CreatedBy = _user,
                                    CreatedDate = DateTime.Now,
                                    ActualVersion = 0,
                                    PublishDate = DateTime.Now,
                                    Modified = DateTime.Now,
                                    AreCommentAllowed = true,
                                    StaticTextVersions = new List<StaticTextVersion>
                                                             {
                                                                 new StaticTextVersion
                                                                     {
                                                                         CreatedBy = _user,
                                                                         Text = "only one version",
                                                                         Version = 0,
                                                                         CreatedDate = new DateTime(2002, 1, 1)
                                                                     },
                                                             }
                                };
                _testText.Comments = new List<Comment>
                                         {
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "first_comment",
                                                     Content = _testText,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1),
                                                     ActualVersion = 0,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0
                                                                                   }
                                                                           }
                                                 },
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "second_comment",
                                                     Content = _testText,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1).AddMinutes(1),
                                                     ActualVersion = 1,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0
                                                                                   },
                                                                               new CommentVersion
                                                                                   {
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        2, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.2.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen - change",
                                                                                       Version = 1
                                                                                   }
                                                                           }
                                                 }

                                         };

                _testText.Comments[0].TopComment = _testText.Comments[0];
                _testText.Comments[1].TopComment = _testText.Comments[1];
                SessionFactory<User>.Store(_user);
                SessionFactory<StaticText>.Store(_testText);
                foreach (var comment in _testText.Comments)
                {
                    SessionFactory<Comment>.Store(comment);
                }
                tran.Commit();
            }

            WaitForIndexing();
        }
Exemple #49
0
 /// <summary>
 /// Клонировать объект
 /// </summary>
 public override object Clone()
 {
     StaticText staticText = new StaticText();
     staticText.CopyFrom(this);
     return staticText;
 }
Exemple #50
0
        public virtual void Init()
        {
            TestProvider.SetUp();

            using (var tran = RepositoryFactory.StartTransaction())
            {
                _user = new User()
                            {
                                Id = Guid.NewGuid(),
                                Name = "user",
                                Email = "*****@*****.**"
                            };
                _testText = new StaticText
                                {
                                    Id = Guid.NewGuid(),
                                    Title = "text3",
                                    CreatedBy = _user,
                                    CreatedDate = DateTime.Now,
                                    ActualVersion = 0,
                                    PublishDate = DateTime.Now,
                                    Modified = DateTime.Now,
                                    AreCommentAllowed = true,
                                    StaticTextVersions = new List<StaticTextVersion>
                                                             {
                                                                 new StaticTextVersion
                                                                     {
                                                                         Id = Guid.NewGuid(),
                                                                         CreatedBy = _user,
                                                                         Text = "only one version",
                                                                         Version = 0,
                                                                         CreatedDate = new DateTime(2002, 1, 1)
                                                                     },
                                                             }
                                };
                _testText.Comments = new List<Comment>
                                         {
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "first_comment",
                                                     Content = _testText,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1),
                                                     ActualVersion = 0,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       Id = Guid.NewGuid(),
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0
                                                                                   }
                                                                           }
                                                 },
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "second_comment",
                                                     Content = _testText,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1).AddMinutes(1),
                                                     ActualVersion = 1,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       Id = Guid.NewGuid(),
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0
                                                                                   },
                                                                               new CommentVersion
                                                                                   {
                                                                                       Id = Guid.NewGuid(),
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        2, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.2.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen - change",
                                                                                       Version = 1
                                                                                   }
                                                                           }
                                                 }

                                         };

                _testText.Comments[0].TopComment = _testText.Comments[0];
                _testText.Comments[1].TopComment = _testText.Comments[1];
                TestProvider.Create<User>(_user);
                TestProvider.Create<StaticText>(_testText);
                foreach (var comment in _testText.Comments)
                {
                    TestProvider.Create<Comment>(comment);
                }
                tran.Commit();
            }

            TestProvider.WaitForIndexing();
        }
Exemple #51
0
        public void Init()
        {
            IoC.InitializeWith(new WindsorContainer());
            IoC.InitializeWith(new WindsorContainer());
            ApplicationInit.InitializeRepositories();
            base.SetUp();
            DBInit.RegisterDocumentStore(Store);
            DBInit.RegisterIndexes(Store);

            using (var tran = RepositoryFactory.StartTransaction())
            {
                _user = new User()
                               {
                                   Id = Guid.NewGuid(),
                                   Name = "user",
                                   Email = "*****@*****.**"
                               };
                var statText1 = new StaticText
                                    {
                                        Id = Guid.NewGuid(),
                                        Title = "text1",
                                        FriendlyUrl = "text1",
                                        CreatedBy = _user,
                                        CreatedDate = DateTime.Now,
                                        ActualVersion = 1,
                                        PublishDate = new DateTime(2002, 1, 1),
                                        Modified = new DateTime(2002, 3, 1),
                                        AreCommentAllowed = true,
                                        StaticTextVersions = new List<StaticTextVersion>
                                                                 {
                                                                     new StaticTextVersion
                                                                         {
                                                                             CreatedBy = _user,
                                                                             Text = "version0",
                                                                             Version = 0,
                                                                             CreatedDate = new DateTime(2002, 1, 1)
                                                                         },
                                                                    new StaticTextVersion
                                                                         {
                                                                             CreatedBy = _user,
                                                                             Text = "version1",
                                                                             Version = 1,
                                                                             CreatedDate = new DateTime(2002, 2, 1)
                                                                         }
                                                                 }
                                    };
                 statText1.Comments = new List<Comment>
                                         {
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "first_comment",
                                                     Content = statText1,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1),
                                                     ActualVersion = 0,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0,
                                                                                   }
                                                                           }
                                                 },
                                             new Comment
                                                 {
                                                     Id = Guid.NewGuid(),
                                                     Name = "first_comment",
                                                     Content = statText1,
                                                     Owner = _user,
                                                     AnonymousName = null,
                                                     CreatedDate = new DateTime(2002, 1, 1),
                                                     ActualVersion = 1,
                                                     CommentVersions = new List<CommentVersion>()
                                                                           {
                                                                               new CommentVersion
                                                                                   {
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        1, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.1.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen",
                                                                                       Version = 0
                                                                                   },
                                                                               new CommentVersion
                                                                                   {
                                                                                       CreatedDate =
                                                                                           new DateTime(2002,
                                                                                                        2, 1),
                                                                                       CreatedBy = _user,
                                                                                       ClientIp =
                                                                                           "192.168.2.1",
                                                                                       UserAgent = "mozilla",
                                                                                       Text =
                                                                                           "this is unique commen - change",
                                                                                       Version = 1
                                                                                   }
                                                                           }
                                                 }

                                         };
                var statText2 = new StaticText
                {
                    Id = Guid.NewGuid(),
                    Title = "text2",
                    FriendlyUrl = "text2",
                    CreatedBy = _user,
                    CreatedDate = DateTime.Now,
                    ActualVersion = 2,
                    PublishDate = new DateTime(2002, 2, 1),
                    Modified = new DateTime(2002, 3, 1),
                    AreCommentAllowed = true,
                    StaticTextVersions = new List<StaticTextVersion>
                                                                 {
                                                                     new StaticTextVersion
                                                                         {
                                                                             CreatedBy = _user,
                                                                             Text = "version0",
                                                                             Version = 0,
                                                                             CreatedDate = new DateTime(2002, 1, 1)
                                                                         },
                                                                    new StaticTextVersion
                                                                         {
                                                                             CreatedBy = _user,
                                                                             Text = "version1",
                                                                             Version = 1,
                                                                             CreatedDate = new DateTime(2002, 2, 1)
                                                                         },
                                                                    new StaticTextVersion
                                                                         {
                                                                             CreatedBy = _user,
                                                                             Text = "version2",
                                                                             Version = 2,
                                                                             CreatedDate = new DateTime(2002, 3, 1)
                                                                         }
                                                                 }
                };
                var statText3 = new StaticText
                {
                    Id = Guid.NewGuid(),
                    Title = "text3",
                    FriendlyUrl = "text",
                    CreatedBy = _user,
                    CreatedDate = DateTime.Now,
                    ActualVersion = 0,
                    PublishDate = new DateTime(2002, 3, 1),
                    Modified = new DateTime(2002, 3, 1),
                    AreCommentAllowed = true,
                    StaticTextVersions = new List<StaticTextVersion>
                                                                 {
                                                                     new StaticTextVersion
                                                                         {
                                                                             CreatedBy = _user,
                                                                             Text = "only one version",
                                                                             Version = 0,
                                                                             CreatedDate = new DateTime(2002, 1, 1)
                                                                         },
                                                                 }
                };

                SessionFactory<User>.Store(_user);
                SessionFactory<StaticText>.Store(statText1);
                SessionFactory<StaticText>.Store(statText2);
                SessionFactory<StaticText>.Store(statText3);
                foreach (var comment in statText1.Comments)
                {
                    SessionFactory<Comment>.Store(comment);
                }
                _testData = new[] { statText1, statText2, statText3 };
                tran.Commit();
            }

            WaitForIndexing();
        }
Exemple #52
0
        private void WriteStaticText(StaticText text)
        {
            int cid = characterMarshal.GetIDFor(text);

            bool hasAlpha = text.HasAlpha;

            WriteBuffer textTag = this.OpenTag(hasAlpha ? Tag.DefineText2 : Tag.DefineText, "; id=" + cid);

            /* Tag.DefineText(2) */
            {
                textTag.WriteUI16((uint)cid);

                textTag.WriteRect(text.Bounds);
                textTag.Align8();

                textTag.WriteMatrix(text.Position);
                textTag.Align8();

                /* ISSUE 49: We're lazy here. We max out the bits for text and advances coz we can't
                 * yet calculate them. Fix this attrocity. */

                int glyphBits = 16;
                int advanceBits = 16;

                textTag.WriteUI8((uint)glyphBits);
                textTag.WriteUI8((uint)advanceBits);

                foreach (TextRecord tr in text.Records)
                {
                    Dictionary<char, int> glyphIDX = null;

                    uint flags = 0x80;

                    if (tr.HasFont)
                    {
                        flags |= 0x08;
                    }

                    if (tr.HasColour)
                    {
                        flags |= 0x04;
                    }

                    if (tr.HasYOffset)
                    {
                        flags |= 0x02;
                    }

                    if (tr.HasXOffset)
                    {
                        flags |= 0x01;
                    }

                    textTag.WriteUI8(flags);

                    if (tr.HasFont)
                    {
                        textTag.WriteUI16((uint)this.characterMarshal.GetExistingIDFor(tr.Font));
                    }

                    if (tr.HasColour)
                    {
                        if (hasAlpha)
                        {
                            textTag.WriteRGBA(tr.Colour.ToArgb());
                        }
                        else
                        {
                            textTag.WriteRGB(tr.Colour.ToArgb());
                        }
                    }

                    if (tr.HasXOffset)
                    {
                        textTag.WriteSI16(tr.XOffset);
                    }

                    if (tr.HasYOffset)
                    {
                        textTag.WriteSI16(tr.YOffset);
                    }

                    if (tr.HasFont)
                    {
                        textTag.WriteUI16((uint)tr.FontHeight);

                        glyphIDX = tr.Font.IndexMap;
                    }

                    char[] chars = tr.Text.ToCharArray();
                    if (chars.Length > 255)
                    {
                        throw new SWFModellerException(SWFModellerError.Internal, "String too long. This should be split across text records.");
                    }

                    textTag.WriteUI8((uint)chars.Length);
                    for (int i = 0; i < tr.Advances.Length; i++)
                    {
                        textTag.WriteUBits((uint)glyphIDX[chars[i]], glyphBits);
                        textTag.WriteSBits(tr.Advances[i], advanceBits);
                    }

                    textTag.Align8();
                }

                textTag.WriteUI8(0); /* End record */

            } /* End of tag code. */

            this.CloseTag();
        }
        public ActionResult translate(FormCollection collection)
        {
            // Get the current domain
            Domain currentDomain = Tools.GetCurrentDomain();
            ViewBag.CurrentDomain = currentDomain;

            // Get query parameters
            string returnUrl = collection["returnUrl"];
            ViewBag.QueryParams = new QueryParams(returnUrl);

            // Check if the administrator is authorized
            if (Administrator.IsAuthorized(new string[] { "Administrator", "Editor", "Translator" }) == true)
            {
                ViewBag.AdminSession = true;
            }
            else if (Administrator.IsAuthorized(Administrator.GetAllAdminRoles()) == true)
            {
                ViewBag.AdminSession = true;
                ViewBag.AdminErrorCode = 1;
                ViewBag.TranslatedTexts = StaticText.GetAll(currentDomain.back_end_language, "id", "ASC");
                return View("index");
            }
            else
            {
                // Redirect the user to the start page
                return RedirectToAction("index", "admin_login");
            }

            // Get the admin default language
            Int32 adminLanguageId = currentDomain.back_end_language;

            // Get translated texts
            KeyStringList tt = StaticText.GetAll(adminLanguageId, "id", "ASC");

            // Get all the form values
            Int32 translationLanguageId = Convert.ToInt32(collection["selectLanguage"]);
            string staticTextId = collection["hiddenStaticTextId"];
            string staticTextText = collection["txtTranslatedText"];

            // Create the translated static text
            StaticText translatedStaticText = new StaticText();
            translatedStaticText.id = staticTextId;
            translatedStaticText.value = staticTextText;

            // Create a error message
            string errorMessage = string.Empty;

            // Check for errors in the static text
            if (translatedStaticText.value.Length > 200)
            {
                errorMessage += "&#149; " + String.Format(tt.Get("error_field_length"), tt.Get("text"), "200") + "<br/>";
            }

            // Check if there is errors
            if (errorMessage == string.Empty)
            {
                // Get the static text
                StaticText staticText = StaticText.GetOneById(staticTextId, translationLanguageId);

                if (staticText == null)
                {
                    // Add a new translated static text
                    StaticText.Add(translatedStaticText, translationLanguageId);
                }
                else
                {
                    // Update the translated static text
                    staticText.value = translatedStaticText.value;
                    StaticText.Update(staticText, translationLanguageId);
                }

                // Redirect the user to the list
                return Redirect(returnUrl);
            }
            else
            {
                // Set form values
                ViewBag.LanguageId = translationLanguageId;
                ViewBag.Languages = Language.GetAll(adminLanguageId, "name", "ASC");
                ViewBag.StandardStaticText = StaticText.GetOneById(staticTextId, adminLanguageId);
                ViewBag.TranslatedStaticText = translatedStaticText;
                ViewBag.ErrorMessage = errorMessage;
                ViewBag.TranslatedTexts = tt;
                ViewBag.ReturnUrl = returnUrl;

                // Return the translate view
                return View("translate");
            }

        } // End of the translate method
Exemple #54
0
        public IControl this[string id]
        {
            get
            {
                if (CreatedControlsByName.ContainsKey(id)) return CreatedControlsByName[id];

                Control ret = null;
                Decal.Adapter.Wrappers.IControlWrapper iret = myView.Controls[id];
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.PushButtonWrapper))
                    ret = new Button();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.CheckBoxWrapper))
                    ret = new CheckBox();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.TextBoxWrapper))
                    ret = new TextBox();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ChoiceWrapper))
                    ret = new Combo();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.SliderWrapper))
                    ret = new Slider();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ListWrapper))
                    ret = new List();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.StaticWrapper))
                    ret = new StaticText();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.NotebookWrapper))
                    ret = new Notebook();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ProgressWrapper))
                    ret = new ProgressBar();
                if (iret.GetType() == typeof(Decal.Adapter.Wrappers.ButtonWrapper))
                    ret = new ImageButton();

                if (ret == null) return null;

                ret.myControl = iret;
                ret.myName = id;
                ret.Initialize();
                allocatedcontrols.Add(ret);
                CreatedControlsByName[id] = ret;
                return ret;
            }
        }
Exemple #55
0
        /// <summary>
        /// Creates a new StaticText field in the SWF.
        /// </summary>
        /// <param name="id">The id (library name).</param>
        /// <returns>The new static text object</returns>
        public StaticText NewStaticText(string id)
        {
            if (this.dictionary.ContainsKey(id))
            {
                throw new SWFModellerException(SWFModellerError.Internal, @"Duplicate character ID (StaticText)");
            }

            StaticText newText = new StaticText(this);
            this.dictionary[id] = newText;

            return newText;
        }