/// <summary> /// Convert number to alpha numeric system by the requested style (UpperAlpha, LowerRoman, Hebrew, etc.). /// </summary> /// <param name="number">the number to convert</param> /// <param name="style">the css style to convert by</param> /// <returns>converted string</returns> public static string ConvertToAlphaNumber(int number, LayoutFarm.Css.CssListStyleType style) // = string style = CssConstants.UpperAlpha) { if (number == 0) return string.Empty; switch (style) { case Css.CssListStyleType.LowerGreek: return ConvertToGreekNumber(number); case Css.CssListStyleType.LowerRoman: return ConvertToRomanNumbers(number, true); case Css.CssListStyleType.UpperRoman: return ConvertToRomanNumbers(number, false); case Css.CssListStyleType.Armenian: return ConvertToSpecificNumbers(number, _armenianDigitsTable); case Css.CssListStyleType.Georgian: return ConvertToSpecificNumbers(number, _georgianDigitsTable); case Css.CssListStyleType.Hebrew: return ConvertToSpecificNumbers(number, _hebrewDigitsTable); case Css.CssListStyleType.Hiragana: case Css.CssListStyleType.HiraganaIroha: return ConvertToSpecificNumbers2(number, _hiraganaDigitsTable); case Css.CssListStyleType.Katakana: case Css.CssListStyleType.KatakanaIroha: return ConvertToSpecificNumbers2(number, _satakanaDigitsTable); case Css.CssListStyleType.LowerAlpha: case Css.CssListStyleType.LowerLatin: return ConvertToEnglishNumber(number, true); default: return ConvertToEnglishNumber(number, false); } }
internal static LayoutFarm.HtmlBoxes.CssBox CreateCssBox( LayoutFarm.WebDom.IHtmlElement domE, LayoutFarm.HtmlBoxes.CssBox parentBox, LayoutFarm.Css.BoxSpec spec, LayoutFarm.HtmlBoxes.HtmlHost htmlhost) { //create cssbox //test only! var newspec = new BoxSpec(); BoxSpec.InheritStyles(newspec, spec); newspec.BackgroundColor = Color.Blue; newspec.Width = new CssLength(50, CssUnitOrNames.Pixels); newspec.Height = new CssLength(50, CssUnitOrNames.Pixels); newspec.Position = CssPosition.Absolute; newspec.Freeze(); //freeze before use HtmlElement htmlElement = (HtmlElement)domE; var newBox = new CssBox(newspec, parentBox.RootGfx); newBox.SetController(domE); htmlElement.SetPrincipalBox(newBox); //auto set bc of the element parentBox.AppendChild(newBox); htmlhost.UpdateChildBoxes(htmlElement, true); //---------- return newBox; }
public void Connect(LayoutFarm.UI.UISurfaceViewportControl vwport) { #if DEBUG this.vwport = vwport; #endif this.TopMost = true; }
void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; //-------------------------------------------- //move controller here controllerBox1.TargetBox = box; controllerBox1.SetLocation(box.Left - 5, box.Top - 5); controllerBox1.SetSize(box.Width + 10, box.Height + 10); controllerBox1.Visible = true; //-------------------------------------------- //change mouse capture to this, for next drag e.SetMouseCapture(controllerBox1); }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = Color.LightGray; //hide controller controllerBox1.Visible = false; controllerBox1.TargetBox = null; }; }
public SampleViewport(LayoutFarm.UI.UISurfaceViewportControl vw) { this.vw = vw; var workingArea = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea; this.primaryScreenWorkingAreaW = workingArea.Width; this.primaryScreenWorkingAreaH = workingArea.Height; }
public static PixelFarm.Drawing.Color ConvertToActualColor(LayoutFarm.WebDom.CssColor color) { return new PixelFarm.Drawing.Color( color.A, color.R, color.G, color.B); }
public static void MakeFormCanvas(Form form1, LayoutFarm.UI.UISurfaceViewportControl surfaceViewportControl) { form1.FormClosing += (s, e) => { surfaceViewportControl.Close(); }; }
void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox) { //if click on background backgroundBox.MouseDown += (s, e) => { controllerBox1.TargetBox = null;//release target box controllerBox1.Visible = false; }; }
void contentMx_LoadStyleSheet(object sender, LayoutFarm.ContentManagers.TextRequestEventArgs e) { string absolutePath = documentRootPath + "\\" + e.Src; if (!System.IO.File.Exists(absolutePath)) { return; } //if found e.TextContent = System.IO.File.ReadAllText(absolutePath); }
static void ShowFormLayoutInspector(LayoutFarm.UI.UISurfaceViewportControl viewport) { var formLayoutInspector = new LayoutFarm.Dev.FormLayoutInspector(); formLayoutInspector.Show(); formLayoutInspector.FormClosed += (s, e2) => { formLayoutInspector = null; }; formLayoutInspector.Connect(viewport); }
void contentMx_ImageLoadingRequest(object sender, LayoutFarm.ContentManagers.ImageRequestEventArgs e) { //load resource -- sync or async? string absolutePath = documentRootPath + "\\" + e.ImagSource; if (!System.IO.File.Exists(absolutePath)) { return; } //load System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(absolutePath); e.SetResultImage(DemoBitmap.CreateFromGdiPlusBitmap(bmp)); }
void contentMx_ImageLoadingRequest(object sender, LayoutFarm.ContentManagers.ImageRequestEventArgs e) { //load resource -- sync or async? string absolutePath = imgFolderPath + "\\" + e.ImagSource; if (!System.IO.File.Exists(absolutePath)) { return; } //load e.SetResultImage(LoadBitmap(absolutePath)); }
public override LayoutFarm.HtmlBoxes.CssBox CreateCssBox( DomElement domE, LayoutFarm.HtmlBoxes.CssBox parentBox, BoxSpec spec, HtmlHost host) { switch (domE.Name) { case "input": { var inputBox = CreateInputBox(domE, parentBox, spec, myHost.RootGfx, host); if (inputBox != null) { return inputBox; } } break; case "canvas": { //test only //TODO: review here var canvas = new LayoutFarm.CustomWidgets.MiniAggCanvasBox(400, 400); var wrapperBox = CreateWrapper( canvas, canvas.GetPrimaryRenderElement(myHost.RootGfx), spec, true); parentBox.AppendChild(wrapperBox); return wrapperBox; } } //default unknown var simpleBox = new LayoutFarm.CustomWidgets.SimpleBox(100, 20); simpleBox.BackColor = PixelFarm.Drawing.Color.LightGray; var wrapperBox2 = CreateWrapper( simpleBox, simpleBox.GetPrimaryRenderElement(myHost.RootGfx), spec, false); parentBox.AppendChild(wrapperBox2); return wrapperBox2; }
public void StartModule(LayoutFarm.SampleViewport sampleViewport) { this.viewport = sampleViewport; dzBoardModule = new DesignBoardModule(); menuModule = new MenuBoardModule(); menuModule.menuItemClick += new EventHandler<MenuItemClickEventArgs>(menuModule_menuItemClick); var contentMx = new LayoutFarm.ContentManagers.ImageContentManager(); contentMx.ImageLoadingRequest += contentMx_ImageLoadingRequest; //app specific here documentRootPath = System.Windows.Forms.Application.ExecutablePath; this.htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, (s, e) => contentMx.AddRequestImage(e.ImageBinder), contentMx_LoadStyleSheet); //1. design board dzBoardModule.StartModule(htmlHost, this.viewport); ////2. canvas board //drawingBoard.StartModule(htmlHost, this.viewport); //3. menu menuModule.StartModule(htmlHost, this.viewport); //------------------------------------------------------ //context knowledge*** //------------------------------------------------------ }
static void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; box.BackColor = Color.LightGray; }; box.MouseDrag += (s, e) => { box.BackColor = KnownColors.FromKnownColor(KnownColor.GreenYellow); Point pos = box.Position; box.SetLocation(pos.X + e.XDiff, pos.Y + e.YDiff); e.MouseCursorStyle = MouseCursorStyle.Pointer; e.CancelBubbling = true; }; }
public static Form CreateNewFormCanvas( MyRootGraphic myRootGfx, InnerViewportKind internalViewportKind, out LayoutFarm.UI.UISurfaceViewportControl canvasViewport) { Form form1 = new Form(); var innerViewport = canvasViewport = new LayoutFarm.UI.UISurfaceViewportControl(); Rectangle screenClientAreaRect = Conv.ToRect(Screen.PrimaryScreen.WorkingArea); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, internalViewportKind); canvasViewport.Bounds = new System.Drawing.Rectangle(0, 0, screenClientAreaRect.Width, screenClientAreaRect.Height); //---------------------- form1.Controls.Add(canvasViewport); //---------------------- MakeFormCanvas(form1, canvasViewport); form1.SizeChanged += (s, e) => { if (form1.WindowState == FormWindowState.Maximized) { Screen currentScreen = GetScreenFromX(form1.Left); //make full screen ? if (innerViewport != null) { innerViewport.Size = currentScreen.WorkingArea.Size; } } }; //---------------------- return form1; }
public void ReleaseHtmlLayoutVisitor(LayoutFarm.HtmlBoxes.LayoutVisitor lay) { lay.UnBind(); this.htmlLayoutVisitorStock.Enqueue(lay); }
void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox) { }
internal EaseViewport(LayoutFarm.UI.UISurfaceViewportControl viewportControl) { this.viewportControl = viewportControl; this.sampleViewport = new SampleViewport(viewportControl); }
void SetupActiveBoxProperties(LayoutFarm.CustomWidgets.EaseBox box) { //1. mouse down box.MouseDown += (s, e) => { //box.BackColor = KnownColors.FromKnownColor(KnownColor.DeepSkyBlue); e.MouseCursorStyle = MouseCursorStyle.Pointer; //-------------------------------------------- //request user controller for this box if (this.BoxSelectionMode == DzBoardSample.BoxSelectionMode.Single) { RemoveAllControllerBoxes(); } var userControllerBox = GetFreeControllerBox(); userControllerBox.TargetBox = box; //-------- //get position relative to box var loca1 = box.GetGlobalLocation(); userControllerBox.SetLocation(loca1.X - 5, loca1.Y - 5); userControllerBox.SetSize(box.Width + 10, box.Height + 10); userControllerBox.Visible = true; userControllerBox.Focus(); e.SetMouseCapture(userControllerBox); e.StopPropagation(); //-------------------------------------------- }; //2. mouse up box.MouseUp += (s, e) => { e.MouseCursorStyle = MouseCursorStyle.Default; //box.BackColor = Color.LightGray; RemoveAllControllerBoxes(); e.StopPropagation(); }; }
void SetupBackgroundProperties(LayoutFarm.CustomWidgets.EaseBox backgroundBox) { //if click on background backgroundBox.MouseDown += (s, e) => { //remove all controller box RemoveAllControllerBoxes(); }; //when start drag on bg //just show selection box on top most backgroundBox.MouseDrag += (s, e) => { //move to mouse position if (!selectionBoxIsShown) { selectionBox.LandingPoint = new Point(e.X, e.Y); selectionBox.SetLocation(e.X, e.Y); selectionBox.Visible = true; selectionBoxIsShown = true; e.SetMouseCapture(selectionBox); } else { Point pos = selectionBox.LandingPoint; int x = pos.X; int y = pos.Y; int w = e.X - pos.X; int h = e.Y - pos.Y; if (w < 0) { w = -w; x -= w; } if (h < 0) { h = -h; y -= h; } //set width and height selectionBox.SetBounds(x, y, w, h); e.SetMouseCapture(selectionBox); } e.StopPropagation(); }; backgroundBox.MouseUp += (s, e) => { if (selectionBoxIsShown) { FindSelectedUserBoxes(); selectionBox.Visible = false; selectionBox.SetSize(1, 1); selectionBoxIsShown = false; } e.StopPropagation(); }; }
public static void TexEnv(TextureEnvTarget target, TextureEnvParameter pname, LayoutFarm.Drawing.Color color) { Color4 c = new Color4(color.R, color.G, color.B, color.A); unsafe { TexEnv(target, pname, &c.R); } }
public static void Viewport(LayoutFarm.Drawing.Rectangle rectangle) { GL.Viewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); }
public static void Viewport(LayoutFarm.Drawing.Point location, LayoutFarm.Drawing.Size size) { GL.Viewport(location.X, location.Y, size.Width, size.Height); }
public static void BlendColor(LayoutFarm.Drawing.Color color) { GL.BlendColor(color.R / 255.0f, color.G / 255.0f, color.B / 255.0f, color.A / 255.0f); }
CssBox CreateCustomCssBox(CssBox parent, LayoutFarm.WebDom.DomElement tag, LayoutFarm.Css.BoxSpec boxspec) { for (int i = generators.Count - 1; i >= 0; --i) { var newbox = generators[i].CreateCssBox(tag, parent, boxspec, this); if (newbox != null) { return newbox; } } return null; }
public void RegisterCssBoxGenerator(LayoutFarm.Composers.CustomCssBoxGenerator cssBoxGenerator) { this.generators.Add(cssBoxGenerator); }
public static void Rect(ref LayoutFarm.Drawing.Rectangle rect) { GL.Rect(rect.Left, rect.Top, rect.Right, rect.Bottom); }
internal static CssBox CreateBridgeBox(IFonts iFonts, LayoutFarm.RenderElement containerElement, RootGraphic rootgfx) { var spec = new BoxSpec(); spec.CssDisplay = CssDisplay.Block; spec.Freeze(); var box = new RenderElementBridgeCssBox(spec, containerElement, rootgfx); //------------------------------------ box.ReEvaluateFont(iFonts, 10); //------------------------------------ return box; }
public static void Viewport(LayoutFarm.Drawing.Size size) { GL.Viewport(0, 0, size.Width, size.Height); }