Example #1
0
        public Select2Editor(jQueryObject hidden, TOptions opt)
            : base(hidden, opt)
        {
            items    = new List <Select2Item>();
            itemById = new JsDictionary <string, Select2Item>();

            var emptyItemText = EmptyItemText();

            if (emptyItemText != null)
            {
                hidden.Attribute("placeholder", emptyItemText);
            }

            var select2Options = GetSelect2Options();

            multiple = Q.IsTrue(select2Options.Multiple);
            hidden.Select2(select2Options);

            hidden.Attribute("type", "text"); // jquery validate to work
            hidden.Bind2("change." + this.uniqueName, (e, x) =>
            {
                if (e.HasOriginalEvent() || Q.IsFalse(x))
                {
                    if (hidden.GetValidator() != null)
                    {
                        hidden.Valid();
                    }
                }
            });
        }
Example #2
0
        public Select2AjaxEditor(jQueryObject hidden, TOptions opt)
            : base(hidden, opt)
        {
            var emptyItemText = EmptyItemText();

            if (emptyItemText != null)
            {
                hidden.Attribute("placeholder", emptyItemText);
            }

            hidden.Select2(GetSelect2Options());

            hidden.Attribute("type", "text"); // jquery validate to work

            hidden.Bind2("change." + this.uniqueName, (e, x) =>
            {
                if (e.HasOriginalEvent() || Q.IsFalse(x))
                {
                    if (hidden.GetValidator() != null)
                    {
                        hidden.Valid();
                    }
                }
            });
        }
Example #3
0
        public TextAreaEditor(jQueryObject input, TextAreaEditorOptions opt)
            : base(input, opt)
        {
            if (options.Cols != null)
                input.Attribute("cols", options.Cols.Value.ToString());

            if (options.Rows != null)
                input.Attribute("rows", options.Rows.Value.ToString());
        }
Example #4
0
        public TextAreaEditor(jQueryObject input, TextAreaEditorOptions opt)
            : base(input, opt)
        {
            if (options.Cols != 0)
            {
                input.Attribute("cols", (options.Cols ?? 80).ToString());
            }

            if (options.Rows != 0)
            {
                input.Attribute("rows", (options.Rows ?? 6).ToString());
            }
        }
Example #5
0
        public void HandleMouseEnter(EventData e, object item)
        {
            OnCellChangedEventData cell = (OnCellChangedEventData)(object)_grid.GetCellFromEvent(e);

            if (cell != null)
            {
                _mouseOut = false;
                Entity entityRow = (Entity)_grid.GetDataItem(cell.Row);
                if (entityRow != null)
                {
                    Script.Literal("{0}.getGridPosition()", _grid);
                    int viewPortRight = _grid.GetViewport().RightPx;
                    int viewPortLeft  = _grid.GetViewport().LeftPx;

                    jQueryObject node         = jQuery.Select((string)Script.Literal("{0}.getCellNode({1},{2})", _grid, cell.Row, cell.Cell));
                    int          buttonsWidth = _hoverButtons.GetWidth();
                    int          x            = node.Parent().GetWidth();
                    if (viewPortRight < x + buttonsWidth)
                    {
                        x = viewPortRight - buttonsWidth;
                    }
                    int y = 0;

                    node.Parent().Append(_hoverButtons);
                    _hoverButtons.CSS("left", x.ToString() + "px");
                    _hoverButtons.CSS("top", y.ToString() + "px");
                    _hoverButtons.CSS("display", "block");
                    _hoverButtons.Attribute("rowId", entityRow.Id.ToString());
                }
            }
        }
Example #6
0
        public static void DoCreateMatch(jQueryObject obj, string datetime, object ids, string courtData, string comments, object opponentId, Callback callback)
        {
            JsonObject parameters = new JsonObject("date", datetime, "locations", ids, "courtData", courtData, "comments", comments, "opponentId", opponentId);

            obj.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/CreateOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback<object>)delegate(object data, string textStatus, jQueryXmlHttpRequest<object> request)
            {
                obj.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                Utility.ProcessResponse((Dictionary)data);

                if (null != callback)
                {
                    callback();
                }
            }
            );
        }
Example #7
0
        public static void DoCreateMatch(jQueryObject obj, string datetime, object ids, string courtData, string comments, object opponentId, Callback callback)
        {
            JsonObject parameters = new JsonObject("date", datetime, "locations", ids, "courtData", courtData, "comments", comments, "opponentId", opponentId);

            obj.Attribute("disabled", "disabled").AddClass("ui-state-disabled");
            jQuery.Post("/services/CreateOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(parameters), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
            {
                obj.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                Utility.ProcessResponse((Dictionary)data);

                if (null != callback)
                {
                    callback();
                }
            }
                        );
        }
        public HtmlContentEditor(jQueryObject textArea, HtmlContentEditorOptions opt)
            : base(textArea, opt)
        {
            IncludeCKEditor();

            string id = textArea.GetAttribute("id");

            if (id.IsTrimmedEmpty())
            {
                textArea.Attribute("id", this.uniqueName);
                id = this.uniqueName;
            }

            if (options.Cols != null)
            {
                textArea.Attribute("cols", options.Cols.Value.ToString());
            }

            if (options.Rows != null)
            {
                textArea.Attribute("rows", options.Rows.Value.ToString());
            }

            var self = this;

            this.AddValidationRule(this.uniqueName, e =>
            {
                if (e.HasClass("required"))
                {
                    var value = self.Value.TrimToNull();
                    if (value == null)
                    {
                        return(Q.Text("Validation.Required"));
                    }
                }

                return(null);
            });

            LazyLoadHelper.ExecuteOnceWhenShown(this.element, () =>
            {
                var config = GetConfig();
                CKEditor.Replace(id, config);
            });
        }
Example #9
0
        private void AcceptMatch(jQueryEvent e)
        {
            jQueryObject button  = jQuery.FromElement(e.CurrentTarget);
            string       offerId = button.Siblings("input").GetValue();

            jQueryObject parentRow = button.Parents(".offer");

            parentRow.Attribute("disabled", "disabled").AddClass("ui-state-disabled");

            jQuery.Post("/services/AcceptOffer?signed_request=" + Utility.GetSignedRequest(), Json.Stringify(new JsonObject("id", offerId)), (AjaxRequestCallback <object>) delegate(object data, string textStatus, jQueryXmlHttpRequest <object> request)
            {
                parentRow.Attribute("disabled", "").RemoveClass("ui-state-disabled");
                button.Parent().Children("a").FadeOut(EffectDuration.Slow);
                button.Parent().Children(".pending").FadeIn(EffectDuration.Fast);

                Utility.ProcessResponse((Dictionary)data);
            });
        }
Example #10
0
        public QuickSearchInput(jQueryObject input, QuickSearchInputOptions opt)
            : base(input, opt)
        {
            input.Attribute("title", Texts.Controls.QuickSearch.Hint)
            .Attribute("placeholder", Texts.Controls.QuickSearch.Placeholder);

            lastValue = Q.Trim(input.GetValue() ?? "");

            var self = this;

            this.element.Bind("keyup." + this.uniqueName, delegate
            {
                self.CheckIfValueChanged();
            });

            this.element.Bind("change." + this.uniqueName, delegate
            {
                self.CheckIfValueChanged();
            });

            J("<span><i></i></span>").AddClass("quick-search-icon")
            .InsertBefore(input);

            if (options.Fields != null && options.Fields.Count > 0)
            {
                var a = J("<a/>").AddClass("quick-search-field")
                        .Attribute("title", Texts.Controls.QuickSearch.FieldSelection)
                        .InsertBefore(input);

                var menu = J("<ul></ul>").CSS("width", "120px");
                foreach (var item in options.Fields)
                {
                    var field = item;
                    J("<li><a/></li>").AppendTo(menu)
                    .Children().Attribute("href", "#")
                    .Text(item.Title ?? "")
                    .Click(delegate(jQueryEvent e) {
                        e.PreventDefault();
                        fieldChanged = self.field != field;
                        self.field   = field;
                        UpdateInputPlaceHolder();
                        CheckIfValueChanged();
                    });
                }

                new PopupMenuButton(a, new PopupMenuButtonOptions
                {
                    PositionMy = "right top",
                    PositionAt = "right bottom",
                    Menu       = menu
                });

                this.field = options.Fields[0];
                UpdateInputPlaceHolder();
            }
        }
Example #11
0
        public string GetFetchXmlForQuery(FetchQuerySettings config, string searchTerm)
        {
            jQueryObject fetchElement = config.FetchXml.Find("fetch");

            fetchElement.Attribute("count", "{0}");
            fetchElement.Attribute("paging-cookie", "{1}");
            fetchElement.Attribute("page", "{2}");
            fetchElement.Attribute("returntotalrecordcount", "true");
            fetchElement.Attribute("distinct", "true");
            fetchElement.Attribute("no-lock", "true");

            jQueryObject orderByElement = fetchElement.Find("order");

            orderByElement.Remove();

            // Add the search string and adjust any lookup columns
            jQueryObject conditions = fetchElement.Find("filter[isquickfindfields='1']");

            conditions.First().Children().Each(delegate(int index, Element element)
            {
                // Is this a lookup column?
                string logicalName = element.GetAttribute("attribute").ToString();
                if (LookupAttributes.ContainsKey(logicalName))
                {
                    element.SetAttribute("attribute", logicalName + "name");
                }
            });
            // Add the sort order placeholder
            string fetchXml = config.FetchXml.GetHtml().Replace("</entity>", "{3}</entity>");

            // Add the Query term
            fetchXml = fetchXml.Replace("#Query#", XmlHelper.Encode(searchTerm));
            return(fetchXml);
        }
        public string GetFetchXmlForQuery(string entityLogicalName, string queryName, string searchTerm)
        {
            FetchQuerySettings config;

            if (queryName == "QuickFind")
            {
                config = EntityLookup[entityLogicalName].QuickFindQuery;
            }
            else
            {
                config = EntityLookup[entityLogicalName].Views[queryName];
            }
            jQueryObject fetchElement = config.FetchXml.Find("fetch");

            fetchElement.Attribute("distinct", "true");
            fetchElement.Attribute("no-lock", "true");

            jQueryObject orderByElement = fetchElement.Find("order");

            orderByElement.Remove();

            // Add the search string and adjust any lookup columns
            jQueryObject conditions = fetchElement.Find("filter[isquickfindfields='1']");

            conditions.First().Children().Each(delegate(int index, Element element)
            {
                // Is this a lookup column?
                string logicalName = element.GetAttribute("attribute").ToString();
                if (LookupAttributes.ContainsKey(logicalName))
                {
                    element.SetAttribute("attribute", logicalName + "name");
                }
            });
            // Add the sort order placeholder
            string fetchXml = config.FetchXml.GetHtml();//.Replace("</entity>", "{3}</entity>");

            // Add the Query term
            fetchXml = fetchXml.Replace("#Query#", XmlHelper.Encode(searchTerm));
            return(fetchXml);
        }
        private void linkFn(IScope scope, jQueryObject element, object attrs)
        {

            forCounter++;

            var next = element.Next();
            string id = next.GetAttribute("id");
            if (id == null)
            {
                id = "forLink" + forCounter;
                next.Attribute("id", id);
            }

            element.Attribute("for", id);
        }
Example #14
0
        private void linkFn(IScope scope, jQueryObject element, object attrs)
        {
            forCounter++;

            var    next = element.Next();
            string id   = next.GetAttribute("id");

            if (id == null)
            {
                id = "forLink" + forCounter;
                next.Attribute("id", id);
            }

            element.Attribute("for", id);
        }
Example #15
0
        public PhoneEditor(jQueryObject input, PhoneEditorOptions opt)
            : base(input, opt)
        {
            var self = this;

            this.AddValidationRule(this.uniqueName, (e) =>
            {
                string value = this.Value.TrimToNull();
                if (value == null)
                {
                    return(null);
                }

                return(Validate(value, options.Multiple, options.Internal, options.Mobile));
            });

            string hint = options.Internal ?
                          "Dahili telefon numarası '456, 8930, 12345' formatlarında" :
                          (options.Mobile ? "Cep telefonu numarası '(533) 342 01 89' formatında" :
                           "Telefon numarası '(216) 432 10 98' formatında");

            if (options.Multiple)
            {
                hint = hint.Replace("numarası", "numaraları") + " ve birden fazlaysa virgülle ayrılarak ";
            }

            hint += " girilmelidir.";

            input.Attribute("title", hint);

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                {
                    return;
                }

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });
        }
        /// <summary>Constructor.</summary>
        public Textbox() 
        {
            // Setup initial conditions.
            Container.AddClass(ClassTextbox);

            // Create INPUT.
            input = Html.CreateElement("input");
            input.Attribute(Html.Type, "text");
            input.AppendTo(Container);
            input.AddClass(ClassTextbox);

            // Set initial size.
            Height = 40;

            // Assign focus control to the input element.
            ChangeFocusElement(input);
            Focus.BrowserHighlighting = false;
            Focus.CanFocus = true;

            // Setup padding.
            padding = new Spacing().Sync(input, OnBeforePaddingSync);
            padding.Change(10, 5);

            // Create child objects.
            eventDelay = new DelayedAction(0.3, OnDelayElapsed);

            // Wire up events.
            Container.MouseDown(delegate { FocusOnClick(); });
            input.Keyup(delegate(jQueryEvent e)
                                    {
                                        if (previousText != Text) FireTextChanged();
                                        if (Int32.Parse(e.Which) == (int)Key.Enter) FireEnterPress();
                                    });
            input.MouseDown(delegate { OnInputMouseDown(); });
            input.MouseUp(delegate { OnInputMouseUp(); });
            Focus.GotFocus += OnGotFocus;
            Focus.LostFocus += OnLostFocus;
            IsEnabledChanged += delegate { SyncEnabled(); };
            SizeChanged += delegate { UpdateLayout(); };

            // Sync size and shape.
            SyncCornerRadius();

            // Finish up.
            previousText = Text;
            FireSizeChanged();
        }
        public static string GetFetchXmlParentFilter(FetchQuerySettings query, string parentAttribute)
        {
            jQueryObject fetchElement = query.FetchXml.Find("fetch");

            fetchElement.Attribute("count", "{0}");
            fetchElement.Attribute("paging-cookie", "{1}");
            fetchElement.Attribute("page", "{2}");
            fetchElement.Attribute("returntotalrecordcount", "true");
            fetchElement.Attribute("distinct", "true");
            fetchElement.Attribute("no-lock", "true");
            jQueryObject orderByElement = fetchElement.Find("order");

            // Get the default order by field - currently only supports a single sort by column
            query.OrderByAttribute = orderByElement.GetAttribute("attribute");
            query.OrderByDesending = orderByElement.GetAttribute("descending") == "true";

            orderByElement.Remove();

            // Get the root filter (if there is one)
            jQueryObject filter = fetchElement.Find("entity>filter");

            if (filter != null)
            {
                // Check that it is an 'and' filter
                string filterType = filter.GetAttribute("type");
                if (filterType == "or")
                {
                    // wrap up in an and filter
                    jQueryObject andFilter = jQuery.FromHtml("<filter type='and'>" + filter.GetHtml() + "</filter>");

                    // remove existing filter
                    filter.Remove();

                    filter = andFilter;
                    // Add in the existing filter
                    fetchElement.Find("entity").Append(andFilter);
                }
            }

            // Add in the parent query filter
            jQueryObject parentFilter = jQuery.FromHtml("<condition attribute='" + parentAttribute + "' operator='eq' value='" + ParentRecordPlaceholder + "'/>");

            filter.Append(parentFilter);

            // Add the order by placeholder for the EntityDataViewModel
            return(query.FetchXml.GetHtml().Replace("</entity>", "{3}</entity>"));
        }
Example #18
0
 public PasswordEditor(jQueryObject input)
     : base(input)
 {
     input.Attribute("type", "password");
 }
        private void linkFn(EffectTestCardScope scope, jQueryObject element, object attrs)
        {
            element.Attribute("style", "width:71px; height:96px;");
            element.Attribute("class", "card " + string.Format("card{0}-{1}", scope.Card.Type, scope.Card.Value));

            var test = scope.Test;
            GameSpaceModel space = null;
            switch (test)
            {
                case EffectTestType.Card:
                    space = scope.Model.CardTest.Space;
                    break;
                case EffectTestType.Space:
                    space = scope.Model.SpaceTest.Space;
                    break;
            }
            Action redrawCard = () =>
                                {
                                    Point scale;
                                    int cardIndex;
                                    Point spaceScale;
                                    if (test == EffectTestType.Card)
                                    {
                                        scale = scope.Model.Scale;

                                        var cardCount = 1;

                                        spaceScale = new Point(space.Width, space.Height);
                                        cardIndex = cardCount;
                                    }
                                    else
                                    {
                                        scale = scope.Model.Scale;

                                        var cards = scope.Model.SpaceTest.Cards;

                                        spaceScale = new Point(space.Width/(cards.Count - 1),
                                            space.Height/(cards.Count - 1));
                                        cardIndex = cards.IndexOf(scope.Card);
                                    }
                                    var vertical = space.Vertical;


                                    scope.CardStyle = new {};

                                    var xx = 0.0;
                                    var yy = 0.0;


                                    switch (space.LayoutType)
                                    {
                                        case GameSpaceLayoutType.Static:
                                            if (vertical)
                                                yy = ((scope.Card.Value + 1)/13.0)*space.Height*scale.Y;
                                            else
                                                xx = ((scope.Card.Value + 1)/13.0)*space.Width*scale.X;
                                            break;
                                        case GameSpaceLayoutType.Grow:
                                            xx = (!vertical ? (cardIndex*spaceScale.X*scale.X) : 0);
                                            yy = (vertical ? (cardIndex*spaceScale.Y*scale.Y) : 0);
                                            break;
                                        default:
                                            xx = (!vertical ? (cardIndex*spaceScale.X*scale.X) : 0);
                                            yy = (vertical ? (cardIndex*spaceScale.Y*scale.Y) : 0);
                                            break;
                                    }

                                    xx -= 71/2;
                                    yy -= 96/2;

                                    scope.CardStyle.position = "absolute";
                                    scope.CardStyle.zIndex = cardIndex;
                                    scope.CardStyle.borderRadius = "5px";
                                    scope.CardStyle.left = (xx + (vertical ? space.Width*scale.X/2 : 0));
                                    scope.CardStyle.top = (yy + (!vertical ? space.Height*scale.Y/2 : 0));

                                    if (test == EffectTestType.Card)
                                    {
                                        scope.CardStyle.left += space.Left*scale.X;
                                        scope.CardStyle.top += space.Top*scale.Y;
                                    }
                                    //                scope.CardStyle["-webkit-transform"] = "rotate(" + scope.Parent.Space.Appearance.InnerStyle.Rotate + "deg)";
                                    //                element.me().rotate(space.Appearance.InnerStyle.Rotate);
                                    scope.CardStyle.content = "\"\"";
                                };
            JsDictionary<string, string> keys;
            scope.Watch("model.selection.selectedEffect", () =>
                                                          {
                                                              if (test != EffectTestType.Card) return;
                                                              ClientHelpers.PurgeCSS(string.Format("card{0}-{1}::before",
                                                                  scope.Card.Type, scope.Card.Value));

                                                              keys = new JsDictionary<string, string>() {};
                                                              if (scope.Card.Value == -1 && scope.Card.Type == -1)
                                                              {
                                                                  keys["content"] = string.Format("url('{1}assets/cards/{0}.gif')", 155, Constants.ContentAddress);
                                                              }
                                                              else
                                                              {
                                                                  keys["content"] = string.Format("url('{1}assets/cards/{0}.gif')", (100 + (scope.Card.Value + 1) + (scope.Card.Type) * 13), Constants.ContentAddress);
                                                              }

ClientHelpers.ChangeCSS(
                                                                  "card" + scope.Card.Type + "-" + scope.Card.Value +
                                                                  "::before", keys);

                                                              var effect = scope.Model.Selection.SelectedEffect;
                                                              if (effect == null) return;

                                                              switch (effect.Type)
                                                              {
                                                                  case EffectType.Highlight:


                                                                      var color = effect.GetString("color");
                                                                      var radius = effect.GetNumber("radius");
                                                                      var rotate = effect.GetNumber("rotate");
                                                                      var offsetX = effect.GetNumber("offsetx");
                                                                      var offsetY = effect.GetNumber("offsety");
                                                                      var opacity = effect.GetNumber("opacity");


                                                                      var beforeStyle =
                                                                          new JsDictionary<string, string>();
                                                                      beforeStyle["display"] = "block";
                                                                      beforeStyle["position"] = "relative";
                                                                      beforeStyle["z-index"] = "-1";
                                                                      beforeStyle["width"] = "100%";
                                                                      beforeStyle["height"] = "100%";
                                                                      beforeStyle["left"] = (-radius + offsetX) + "px";
                                                                      beforeStyle["top"] = (-radius + offsetY) + "px";
                                                                      beforeStyle["padding"] = (radius) + "px";
                                                                      beforeStyle["border-radius"] = "5px";
                                                                      beforeStyle["box-shadow"] =
                                                                          "rgb(44, 44, 44) 3px 3px 2px";
                                                                      var hexcolor = ClientHelpers.HexToRGB(color);

                                                                      beforeStyle["background-color"] =
                                                                          string.Format("rgba({0}, {1}, {2}, {3})",
                                                                              hexcolor.R, hexcolor.G, hexcolor.B,
                                                                              opacity);
                                                                      beforeStyle["border"] = "2px solid black";

                                                                      ClientHelpers.ChangeCSS("card" + scope.Card.Type + "-" +scope.Card.Value + "::before", beforeStyle);

                                                                      break;
                                                                  case EffectType.Rotate:
                                                                      break;
                                                                  case EffectType.Bend:


                                                                      /*

                                                                                          var bEffect = (new CardGameAppearanceEffectBend(new CardGameEffectBendOptions()
                                                                                          {
                                                                                              Degrees = grabbedEffect.GetPropertyByName<double>("degrees"),
                                                                                          }));


                                                                                          var rotate = element.GetCSS("transform").Replace(" scale(1, 1)", "");

                                                                                          element.me().rotate((((-bEffect.Degrees / 2 + bEffect.Degrees / (space.Pile.Cards.Count - 1) * cardIndex) + NoTransformRotate(rotate))));
                                                                      */

                                                                      break;
                                                                  case EffectType.StyleProperty:
                                                                      break;
                                                                  case EffectType.Animated:
                                                                      break;
                                                              }
                                                          }, true);


            keys = new JsDictionary<string, string>() {};
            if (scope.Card.Value == -1 && scope.Card.Type == -1)
            {
                keys["content"] = string.Format("url('{1}assets/cards/{0}.gif')", 155, Constants.ContentAddress);
            }
            else
            {
                keys["content"] = string.Format("url('{1}assets/cards/{0}.gif')", (100 + (scope.Card.Value + 1) + (scope.Card.Type) * 13), Constants.ContentAddress);
            }

            ClientHelpers.ChangeCSS("card" + scope.Card.Type + "-" + scope.Card.Value + "::before", keys);

            scope.Watch("space", redrawCard, true);

            scope.Watch("model.selection.selectedScenario", redrawCard, true);

//            scope.On("redrawCard", redrawCard);

            //   redrawCard();
            /*
                          
 
            scope.Watch("$parent.space", () =>
            {
                Console.Log("ac");
                redrawCard();
            }, true);
            scope.Watch("card.appearance.effectNames.join()", () =>
            {
                Console.Log("b");
                redrawCard();
            }, true);*/
            /*scope.Watch<CardScope>((_scope) =>
            {

                List<Effect> effects = new List<Effect>();

                foreach (var ef in _scope.Card.Appearance.EffectNames)
                {
                    var _ef = myEffectManager.GetEffectByName(ef);
                    effects.Add(_ef);
                }
                return effects;
            }, () => {
                Console.Log("c");
                   redrawCard();
               }, true);

*/
            redrawCard();
        }
Example #20
0
 /// <summary>Adds or removes the 'disabled' attribute on the given INPUT element.</summary>
 /// <param name="input">The input element to effect.</param>
 /// <param name="isEnabled">The enabled value.</param>
 public static void SetDisabled(jQueryObject input, bool isEnabled)
 {
     if (isEnabled)
     {
         input.Attribute(Disabled, null);
     }
     else
     {
         input.Attribute(Disabled, Disabled);
     }
 }
Example #21
0
 /// <summary>Gets the elements ID, creating a unique ID of the element doesn't already have one.</summary>
 /// <param name="element">The element to get the ID for.</param>
 public static string GetOrCreateId(jQueryObject element)
 {
     string id = element.GetAttribute(Id);
     if (string.IsNullOrEmpty(id))
     {
         id = Helper.CreateId();
         element.Attribute(Id, id);
     }
     return id;
 }
Example #22
0
 public PasswordEditor(jQueryObject input)
     : base(input)
 {
     input.Attribute("type", "password");
 }
        private void linkFn(EffectTestAreaScope scope, jQueryObject element, object attrs)
        {
            GameAreaModel area = null;
            area = scope.Model.AreaTest.Area;
            element.Attribute("class", "area " + string.Format("area{0}", area.Name));

            var scale = scope.Model.Scale;
            Action reApplyAreaBind = () =>
                                     {
                                         /*   JsDictionary<string, string> beforeStyle = new JsDictionary<string, string>();
                   if (false)
                   {
                       beforeStyle["display"] = "block";
                       beforeStyle["position"] = "relative";
                       beforeStyle["z-index"] = "-1";
                       beforeStyle["width"] = "100%";
                       beforeStyle["height"] = "100%";
                       beforeStyle["left"] = "-50px";
                       beforeStyle["top"] = "-50px";
                       beforeStyle["padding"] = "50px";
                       beforeStyle["border-radius"] = "15px";
                       beforeStyle["box-shadow"] = "rgb(51, 51, 51) 4px 4px 2px";
                       beforeStyle["content"] = "\"\"";
                       beforeStyle["background"] = "rgba(112, 12, 58, 0.231373)";
                   }
                   ChangeCSS("area" + area.Name + "::before", beforeStyle);*/
                                         scope.AreaStyle = new {};

                                         var l = area.Left;
                                         var t = area.Top;
                                         var w = area.Width;
                                         var h = area.Height;
                                         var sl = scale.X;
                                         var st = scale.Y;

                                         scope.AreaStyle.position = "absolute";
                                         scope.AreaStyle.left = l*sl;
                                         scope.AreaStyle.top = t*st;
                                         scope.AreaStyle.boxShadow = "rgb(51, 51, 51) 4px 4px 2px";
                                         scope.AreaStyle.borderRadius = "15px";


                                         scope.AreaStyle.width = w*sl;
                                         scope.AreaStyle.height = h*st;
                                         scope.AreaStyle.backgroundColor = "blue";
                                     };
            scope.Watch("model.selection.selectedEffect", () =>
                                                          {
                                                              ClientHelpers.PurgeCSS("area" + area.Name + "::before");

                                                              var effect = scope.Model.Selection.SelectedEffect;
                                                              if (effect == null) return;
                                                              switch (effect.Type)
                                                              {
                                                                  case EffectType.Highlight:

                                                                      var color = effect.GetString("color");
                                                                      var radius = effect.GetNumber("radius");
                                                                      var rotate = effect.GetNumber("rotate");
                                                                      var offsetX = effect.GetNumber("offsetx");
                                                                      var offsetY = effect.GetNumber("offsety");
                                                                      var opacity = effect.GetNumber("opacity");

                                                                      var beforeStyle =
                                                                          new JsDictionary<string, string>();

                                                                      beforeStyle["display"] = "block";
                                                                      beforeStyle["position"] = "relative";
                                                                      beforeStyle["z-index"] = "-1";
                                                                      beforeStyle["width"] = "100%";
                                                                      beforeStyle["height"] = "100%";
                                                                      beforeStyle["left"] = (-radius + offsetX) + "px";
                                                                      beforeStyle["top"] = (-radius + offsetY) + "px";
                                                                      beforeStyle["padding"] = (radius) + "px";
                                                                      beforeStyle["border-radius"] = "5px";
                                                                      beforeStyle["box-shadow"] =
                                                                          "rgb(44, 44, 44) 3px 3px 2px";
                                                                      var hexcolor = ClientHelpers.HexToRGB(color);
                                                                      beforeStyle["content"] = "\"\"";

                                                                      beforeStyle["background-color"] =
                                                                          string.Format("rgba({0}, {1}, {2}, {3})",
                                                                              hexcolor.R, hexcolor.G, hexcolor.B,
                                                                              opacity);
                                                                      beforeStyle["border"] = "2px solid black";

                                                                    ClientHelpers.  ChangeCSS("area" + area.Name + "::before",
                                                                          beforeStyle);

                                                                      break;
                                                                  case EffectType.Rotate:
                                                                      break;
                                                                  case EffectType.Bend:
                                                                      break;
                                                                  case EffectType.StyleProperty:
                                                                      break;
                                                                  case EffectType.Animated:
                                                                      break;
                                                              }
                                                          }, true);

            scope.Watch("area", reApplyAreaBind, true);
        }
        private void linkFn(SpaceScope scope, jQueryObject element, object attrs)
        {
            element.Attribute("class", "space " + string.Format("space{0}", scope.Space.Name));
            element.Resizable(new ResizableOptions()
            {
                Grid = new[] { scope.Parent.Scale.X, scope.Parent.Scale.Y },
                MinHeight = -1,
                MinWidth = -1,
                Handles = "n, e, s, w,nw,sw,ne,se",
                OnResize = (ev, ele) =>
                {
                    scope.Space.Width = ele.Size.Width / scope.Parent.Scale.X;
                    scope.Space.Height = ele.Size.Height / scope.Parent.Scale.Y;
                    scope.Apply();

                }
            });
            element.Draggable(new DraggableOptions()
            {
                Cursor = "crosshair",
                Grid = new[] { scope.Parent.Scale.X, scope.Parent.Scale.Y }, 
                OnDrag = (ev, ele) =>
                {
                    scope.Space.X = ele.Position.Left / scope.Parent.Scale.X;
                    scope.Space.Y = ele.Position.Top/ scope.Parent.Scale.Y;
                    scope.Apply();

                }
            });

            JsDictionary<string, string> beforeStyle = new JsDictionary<string, string>();
            beforeStyle["display"] = "block";
            beforeStyle["position"] = "relative";
            beforeStyle["z-index"] = "-1";
            beforeStyle["width"] = "100%";
            beforeStyle["height"] = "100%";
            beforeStyle["left"] = "-50px";
            beforeStyle["top"] = "-50px";
            beforeStyle["padding"] = "50px";
            beforeStyle["border-radius"] = "15px";
            beforeStyle["box-shadow"] = "rgb(51, 51, 51) 4px 4px 2px";
            beforeStyle["content"] = "\"\"";
            beforeStyle["background"] = "rgba(112, 12, 58, 0.231373)";
            ChangeCSS("space" + scope.Space.Name + "::before", beforeStyle);

            scope.SpaceStyle = new { };



            scope.SpaceStyle.position = "absolute";
            scope.SpaceStyle.left = scope.Space.X * scope.Parent.Scale.X;
            scope.SpaceStyle.top = scope.Space.Y * scope.Parent.Scale.Y;

            scope.SpaceStyle.width = scope.Space.Width * scope.Parent.Scale.X;
            scope.SpaceStyle.height = scope.Space.Height * scope.Parent.Scale.Y;
            scope.SpaceStyle.backgroundColor = "red";



            foreach (var effect in scope.Space.Appearance.Effects)
            {
                switch (effect.Type)
                {
                    case EffectType.Highlight:
                        var hEffect = ((CardGameAppearanceEffectHighlight)effect);
                        scope.SpaceStyle.padding = string.Format("{0} {0} {0} {0}", hEffect.Radius);
                        scope.SpaceStyle.backgroundColor = hEffect.Color;
                        scope.SpaceStyle.border = "solid 2px black";
                        scope.SpaceStyle.borderRadius = 15.0;
                        scope.SpaceStyle.boxShadow = "4px 4px 2px #333";
                        break;
                    case EffectType.Rotate:
                        Window.Alert(effect.Type.ToString());
                        break;
                    case EffectType.Bend:
                        var bEffect = (CardGameAppearanceEffectBend)effect;

                        //rotate


                        break;
                    case EffectType.StyleProperty:
                        Window.Alert(effect.Type.ToString());
                        break;
                    case EffectType.Animated:
                        Window.Alert(effect.Type.ToString());
                        break;
                    default:

                        break;
                }
            }

        }
        private void linkFn(TestTextScope scope, jQueryObject element, object attrs)
        {
            element.Attribute("class", "text " + string.Format("text{0}", scope.Text.Name));
            element.MouseDown((e) =>
            {
                scope.Model.Selection.SelectedText = scope.Text;
                scope.Apply();
            });


            var scale = scope.Model.Scale;
            Action reApplyTextBind = () =>
            {
                scope.TextStyle = new { };


                scope.TextStyle.position = "absolute";
                scope.TextStyle.left = scope.Text.Left * scale.X;
                scope.TextStyle.top = scope.Text.Top * scale.Y;
                scope.TextStyle.boxShadow = "rgb(51, 51, 51) 4px 4px 2px";
                scope.TextStyle.borderRadius = "15px";


                element.Text(scope.Text.Text);

                ClientHelpers.PurgeCSS("text" + scope.Text.Name + "::before");

                foreach (var gameLayoutScenarioEffect in scope.Model.Selection.SelectedScenario.Effects)
                {
                    foreach (var textGuid in gameLayoutScenarioEffect.TextGuids)
                    {
                        if (textGuid == scope.Text.Guid)
                        {
                            foreach (var gameEffectModel in scope.Model.Game.Effects)
                            {
                                if (gameEffectModel.Guid == gameLayoutScenarioEffect.EffectGuid)
                                {
                                    var effect = gameEffectModel;
                                    switch (effect.Type)
                                    {
                                        case EffectType.Highlight:

                                            var color = effect.GetString("color");
                                            var radius = effect.GetNumber("radius");
                                            var rotate = effect.GetNumber("rotate");
                                            var offsetX = effect.GetNumber("offsetx");
                                            var offsetY = effect.GetNumber("offsety");
                                            var opacity = effect.GetNumber("opacity");

                                            var beforeStyle =
                                                new JsDictionary<string, string>();

                                            beforeStyle["display"] = "block";
                                            beforeStyle["position"] = "relative";
                                            beforeStyle["z-index"] = "-1";
                                            beforeStyle["width"] = "100%";
                                            beforeStyle["height"] = "100%";
                                            beforeStyle["left"] = (-radius + offsetX) + "px";
                                            beforeStyle["top"] = (-radius + offsetY) + "px";
                                            beforeStyle["padding"] = (radius) + "px";
                                            beforeStyle["border-radius"] = "5px";
                                            beforeStyle["box-shadow"] =
                                                "rgb(44, 44, 44) 3px 3px 2px";
                                            var hexcolor = ClientHelpers.HexToRGB(color);
                                            beforeStyle["content"] = "\"\"";

                                            beforeStyle["background-color"] = string.Format("rgba({0}, {1}, {2}, {3})", hexcolor.R, hexcolor.G, hexcolor.B, opacity);
                                            beforeStyle["border"] = "2px solid black";

                                            ClientHelpers.ChangeCSS("text" + scope.Text.Name + "::before", beforeStyle);

                                            break;

                                        case EffectType.Rotate:
                                            break;
                                        case EffectType.Bend:
                                            break;
                                        case EffectType.StyleProperty:
                                            break;
                                        case EffectType.Animated:
                                            break;
                                    }
                                }
                            }
                        }
                    }
                }
            };
            scope.Watch("model.scale", () =>
            {
                scale = scope.Model.Scale;


                element.Draggable(new DraggableOptions()
                {
                    Cursor = "crosshair",
                    Grid = new[] { scale.X, scale.Y },
                    OnDrag = (ev, ele) =>
                    {
                        scope.Text.Left = (ele.Position.Left /
                                           scale.X);
                        scope.Text.Top = (ele.Position.Top / scale.Y);
                        scope.Apply();
                    }
                });
                reApplyTextBind();
            });


            scope.Watch("text", reApplyTextBind, true);
            scope.Watch("model.selection.selectedEffect", reApplyTextBind, true);
            scope.Watch("model.selection.selectedScenario.effects", reApplyTextBind, true);
        }
        private void linkFn(DebugSpaceScope scope, jQueryObject element, object attrs)
        {
            var scale = scope.GameModel.Scale;

            var debugSpace = scope.Space.GameSpace;

            element.Attribute("class", "space " + string.Format("space{0}", debugSpace.Name));

            var cardLookups = new JsDictionary<Guid, DebugSpaceCard>();


            Console.WriteLine("Smash");
            scope.Space.Cards = debugSpace.Pile.Cards.Map((card, index, cards) => cardLookups[card.Guid] ?? (cardLookups[card.Guid] = new DebugSpaceCard() {GameCard = card, PlaceHolder = false, Index = index}));


            var process = new Action(() =>
                                     {
                                         debugSpace = scope.Space.GameSpace;
                                         Console.WriteLine("space process " + debugSpace.Name);

                                         scope.SpaceStyle = new {};

                                         scope.SpaceStyle.position = "absolute";
                                         scope.SpaceStyle.left = debugSpace.X*scale.X;
                                         scope.SpaceStyle.top = debugSpace.Y*scale.Y;

                                         scope.SpaceStyle.width = debugSpace.Width*scale.X;
                                         scope.SpaceStyle.height = debugSpace.Height*scale.Y;
                                         scope.SpaceStyle.backgroundColor = "red";

                                         scope.SpaceStyle = new {};

                                         var left = debugSpace.X;
                                         var top = debugSpace.Y;
                                         var w = debugSpace.Width;
                                         var h = debugSpace.Height;
                                         var scaleLeft = scale.X;
                                         var scaleTop = scale.Y;

                                         scope.SpaceStyle.position = "absolute";
                                         scope.SpaceStyle.left = left*scaleLeft;
                                         scope.SpaceStyle.top = top*scaleTop;
                                         scope.SpaceStyle.boxShadow = "rgb(51, 51, 51) 4px 4px 2px";
                                         scope.SpaceStyle.borderRadius = "15px";


                                         scope.SpaceStyle.width = w*scaleLeft;
                                         scope.SpaceStyle.height = h*scaleTop;
                                         scope.SpaceStyle.backgroundColor = "red";

                                         scope.Space.Location = new Rectangle(left*scaleLeft, top*scaleTop, w*scaleLeft, h*scaleTop);

                                         ClientHelpers.PurgeCSS("space" + debugSpace.Name + "::before");


                                         var beforeStyle = new JsDictionary<string, string>();

                                         foreach (var effectName in debugSpace.Effects)
                                         {
                                             var effect = scope.GameModel.MainArea.ClientGetEffectByName(effectName);
                                             switch (effect.Type)
                                             {
                                                 case EffectType.Highlight:

                                                     var color = effect.GetString("color");
                                                     var radius = effect.GetNumber("radius");
                                                     var rotate = effect.GetNumber("rotate");
                                                     var offsetX = effect.GetNumber("offsetx");
                                                     var offsetY = effect.GetNumber("offsety");
                                                     var opacity = effect.GetNumber("opacity");

                                                     beforeStyle["display"] = "block";
                                                     beforeStyle["position"] = "relative";
                                                     beforeStyle["z-index"] = "-1";
                                                     beforeStyle["width"] = "100%";
                                                     beforeStyle["height"] = "100%";
                                                     beforeStyle["left"] = (-radius + offsetX) + "px";
                                                     beforeStyle["top"] = (-radius + offsetY) + "px";
                                                     beforeStyle["padding"] = (radius) + "px";
                                                     beforeStyle["border-radius"] = "5px";
                                                     beforeStyle["box-shadow"] =
                                                         "rgb(44, 44, 44) 3px 3px 2px";
                                                     var hexcolor = ClientHelpers.HexToRGB(color);
                                                     beforeStyle["content"] = "\"\"";

                                                     beforeStyle["background-color"] =
                                                         string.Format("rgba({0}, {1}, {2}, {3})",
                                                             hexcolor.R, hexcolor.G, hexcolor.B,
                                                             opacity);
                                                     beforeStyle["border"] = "2px solid black";

                                                     break;
                                                 case EffectType.Rotate:
                                                     break;
                                                 case EffectType.Bend:
                                                     break;
                                                 case EffectType.StyleProperty:
                                                     break;
                                                 case EffectType.Animated:
                                                     break;
                                             }
                                         }


                                         ClientHelpers.ChangeCSS("space" + debugSpace.Name + "::before", beforeStyle);


                                         scope.Broadcast("redrawCard");
                                     });


            scope.On("spaceUpdated", () =>
                                     { 
                                         debugSpace = scope.Space.GameSpace;
                                         scope.Space.Cards = debugSpace.Pile.Cards.Map((card, index, cards) =>
                                                                                       {
                                                                                           var lookup = cardLookups[card.Guid] ?? (cardLookups[card.Guid] = new DebugSpaceCard() {GameCard = card, PlaceHolder = false, Index = index});
                                                                                           lookup.GameCard.Effects = card.Effects;
                                                                                           return lookup;
                                                                                       });
                                         process();
                                     });


            scope.Watch("space", process);
        }
        public string GetFetchXmlForQuery(string entityLogicalName, string queryName, string searchTerm, SearchTermOptions searchOptions)
        {
            FetchQuerySettings config;

            if (queryName == "QuickFind")
            {
                config = EntityLookup[entityLogicalName].QuickFindQuery;
            }
            else
            {
                config = EntityLookup[entityLogicalName].Views[queryName];
            }
            jQueryObject fetchElement = config.FetchXml.Clone().Find("fetch");

            fetchElement.Attribute("distinct", "true");
            fetchElement.Attribute("no-lock", "true");

            jQueryObject orderByElement = fetchElement.Find("order");

            orderByElement.Remove();

            // Add the search string and adjust any lookup columns
            jQueryObject conditions = fetchElement.Find("filter[isquickfindfields='1']");

            conditions.First().Children().Each(delegate(int index, Element element)
            {
                // Is this a lookup column?
                string logicalName = element.GetAttribute("attribute").ToString();
                if (LookupAttributes.ContainsKey(logicalName))
                {
                    element.SetAttribute("attribute", logicalName + "name");
                }
            });

            //See what field types can we use for query and remove those attributes we cannot query using this search term.
            if (Number.IsNaN(Int32.Parse(searchTerm)))
            {
                fetchElement.Find("condition[value='#QueryInt#']").Remove();
            }
            if (Number.IsNaN(Decimal.Parse(searchTerm)))
            {
                fetchElement.Find("condition[value='#QueryCurrency#']").Remove();
            }
            if (Number.IsNaN(Date.Parse(searchTerm).GetDate()))
            {
                fetchElement.Find("condition[value='#QueryDateTime#']").Remove();
            }
            if (Number.IsNaN(Double.Parse(searchTerm)))
            {
                fetchElement.Find("condition[value='#QueryFloat#']").Remove();
            }
            // Add the sort order placeholder
            string fetchXml = fetchElement.Parent().GetHtml();//.Replace("</entity>", "{3}</entity>");

            //Prepare search term based on options
            string textSearchTerm = searchTerm;

            if (searchOptions != null && (searchOptions & SearchTermOptions.PrefixWildcard) == SearchTermOptions.PrefixWildcard)
            {
                //Trimming, in case there are already wildcards with user input
                while (textSearchTerm.StartsWith("*") || textSearchTerm.StartsWith("%"))
                {
                    textSearchTerm = textSearchTerm.Substring(1, textSearchTerm.Length);
                }
                textSearchTerm = "%" + textSearchTerm;
            }
            if (searchOptions != null && (searchOptions & SearchTermOptions.SuffixWildcard) == SearchTermOptions.SuffixWildcard)
            {
                //Trimming, in case there are already wildcards
                while (textSearchTerm.EndsWith("*") || textSearchTerm.EndsWith("%"))
                {
                    textSearchTerm = textSearchTerm.Substring(0, textSearchTerm.Length - 1);
                }
                textSearchTerm = textSearchTerm + "%";
            }

            // Add the Query term
            fetchXml = fetchXml.Replace("#Query#", XmlHelper.Encode(textSearchTerm))
                       .Replace("#QueryInt#", Int32.Parse(searchTerm).ToString())
                       .Replace("#QueryCurrency#", Double.Parse(searchTerm).ToString())
                       .Replace("#QueryDateTime#", XmlHelper.Encode(Date.Parse(searchTerm).Format("MM/dd/yyyy")))
                       .Replace("#QueryFloat#", Double.Parse(searchTerm).ToString());

            return(fetchXml);
        }
Example #28
0
        public PhoneEditor(jQueryObject input, PhoneEditorOptions opt)
            : base(input, opt)
        {
            var self = this;

            this.AddValidationRule(this.uniqueName, (e) =>
            {
                string value = this.Value.TrimToNull();
                if (value == null)
                {
                    return(null);
                }

                return(Validate(value));
            });

            string hint = options.Internal ?
                          "Dahili telefon numarası '456, 8930, 12345' formatlarında" :
                          (options.Mobile ? "Cep telefonu numarası '(533) 342 01 89' formatında" :
                           "Telefon numarası '(216) 432 10 98' formatında");

            if (options.Multiple)
            {
                hint = hint.Replace("numarası", "numaraları") + " ve birden fazlaysa virgülle ayrılarak ";
            }

            hint += " girilmelidir.";

            input.Attribute("title", hint);

            input.Bind("change", delegate(jQueryEvent e)
            {
                if (!e.HasOriginalEvent())
                {
                    return;
                }

                FormatValue();
            });

            input.Bind("blur", delegate(jQueryEvent e)
            {
                if (this.element.HasClass("valid"))
                {
                    FormatValue();
                }
            });

            input.Bind("keyup", delegate(jQueryEvent e)
            {
                if (options.Internal)
                {
                    return;
                }

                var val = (input.GetValue() ?? "");
                if (val.Length > 0 && ((dynamic)input[0]).selectionEnd == val.Length &&
                    ((e.Which >= 48 && e.Which <= 57) || (e.Which >= 96 && e.Which <= 105)) &&
                    val[val.Length - 1] >= '0' && val[val.Length - 1] <= '9' && !val.StartsWith("+") && val.IndexOf('/') < 0)
                {
                    if (Validate(val) == null)
                    {
                        FormatValue();
                    }
                    else
                    {
                        for (var i = 1; i <= 7; i++)
                        {
                            val += "9";
                            if (Validate(val) == null)
                            {
                                this.Value = val;
                                FormatValue();
                                val = this.Value;
                                for (var j = 1; j <= i; j++)
                                {
                                    val = val.Trim();
                                    val = val.Substr(0, val.Length - 1);
                                }
                                this.Value = val;
                                break;
                            }
                        }
                    }
                }
            });
        }
        private void linkFn(CardScope scope, jQueryObject element, object attrs)
        {
            element.Attribute("style", "width:71px; height:96px;");
            element.Attribute("class", "card "+string.Format("card{0}-{1}", scope.Card.Type, scope.Card.Value));


            scope.watch("$parent.$parent.selectedCard",
                        () =>
                        {
                            if (scope.Parent.Parent.SelectedCard == null || scope.Parent.Parent.SelectedCard != scope.Card)
                            {
                                scope.CardStyle.border = Script.Undefined;

                            }
                            else
                            {

                                scope.CardStyle.border = "solid 4px green";
                            }
                        });

            scope.CardClick = () =>
            {
                if (scope.Parent.Parent.SelectedCard == scope.Card)
                {
                    scope.Parent.Parent.SelectedCard = null;
                }
                else
                {
                    scope.Parent.Parent.SelectedCard = scope.Card;

                }
            };
            Action redrawCard = () =>
            {

                var spaceScale = new { width = scope.Parent.Space.Width / scope.Parent.Space.Pile.Cards.Count, height = scope.Parent.Space.Height / scope.Parent.Space.Pile.Cards.Count };
                var vertical = scope.Parent.Space.Vertical;
                var cardIndex = scope.Parent.Space.Pile.Cards.IndexOf(scope.Card);

                scope.CardStyle = new { };

                var xx = 0.0;
                var yy = 0.0;

                switch (scope.Parent.Space.ResizeType)
                {
                    case TableSpaceResizeType.Static:
                        if (vertical)
                            yy = ((scope.Card.Value + 1) / 13.0) * scope.Parent.Space.Height * scope.Parent.Parent.Scale.Y;
                        else
                            xx = ((scope.Card.Value + 1) / 13.0) * scope.Parent.Space.Width * scope.Parent.Parent.Scale.X;
                        break;
                    case TableSpaceResizeType.Grow:
                        xx = (!vertical ? (cardIndex * spaceScale.width * scope.Parent.Parent.Scale.X) : 0);
                        yy = (vertical ? (cardIndex * spaceScale.height * scope.Parent.Parent.Scale.Y) : 0);
                        break;
                    default:
                        xx = (!vertical ? (cardIndex * spaceScale.width * scope.Parent.Parent.Scale.X) : 0);
                        yy = (vertical ? (cardIndex * spaceScale.height * scope.Parent.Parent.Scale.Y) : 0);
                        break;
                }

                xx -= 71 / 2;
                yy -= 96 / 2;

                scope.CardStyle.position = "absolute";
                scope.CardStyle.zIndex = cardIndex;
                scope.CardStyle.borderRadius = "5px";
                scope.CardStyle.left = (xx + (vertical ? scope.Parent.Space.Width * scope.Parent.Parent.Scale.X / 2 : 0));
                scope.CardStyle.top = (yy + (!vertical ? scope.Parent.Space.Height * scope.Parent.Parent.Scale.Y / 2 : 0));
//                scope.CardStyle["-webkit-transform"] = "rotate(" + scope.Parent.Space.Appearance.InnerStyle.Rotate + "deg)";
                element.Me().rotate(scope.Parent.Space.Appearance.InnerStyle.Rotate + "deg");
                scope.CardStyle.content = "\"\"";


                if (scope.Parent.Space.Name.StartsWith("User"))
                {

                    if (scope.Card.Appearance.Effects.Count == 0)
                        scope.Card.Appearance.Effects.Add(new CardGameAppearanceEffectBend(new CardGameEffectBendOptions() { Degrees = 15 }));

                }
                else
                {
                    for (var index = scope.Card.Appearance.Effects.Count - 1; index >= 0; index--)
                    {
                        var cardGameAppearanceEffect = scope.Card.Appearance.Effects[index];
                        if (cardGameAppearanceEffect.Type == EffectType.Bend)
                            scope.Card.Appearance.Effects.Remove(cardGameAppearanceEffect);
                    }
                }


                foreach (var effect in scope.Card.Appearance.EffectNames)
                {
                    Effect grabbedEffect = myEffectManager.GetEffectByName(effect);
                    if (grabbedEffect == null)
                    {
                        continue;
                    }
                    switch (grabbedEffect.Type)
                    {
                        case EffectType2.Highlight:

                            var _effect = new CardGameAppearanceEffectHighlight(new CardGameEffectHighlightOptions()
                            {
                                Color = grabbedEffect.GetPropertyByName<string>("color"),
                                Radius = grabbedEffect.GetPropertyByName<double>("radius"),
                                Rotate = grabbedEffect.GetPropertyByName<double>("rotate"),
                                OffsetX = grabbedEffect.GetPropertyByName<double>("offsetx"),
                                OffsetY = grabbedEffect.GetPropertyByName<double>("offsety"),
                                Opacity = grabbedEffect.GetPropertyByName<double>("opacity"),
                            });

                            JsDictionary<string, string> beforeStyle = new JsDictionary<string, string>();
                            beforeStyle["display"] = "block";
                            beforeStyle["position"] = "relative";
                            beforeStyle["z-index"] = "-1";
                            beforeStyle["width"] = "100%";
                            beforeStyle["height"] = "100%";
                            beforeStyle["left"] = (-_effect.Radius + _effect.OffsetX) + "px";
                            beforeStyle["top"] = (-_effect.Radius + _effect.OffsetY) + "px";
                            beforeStyle["padding"] = (_effect.Radius) + "px";
                            beforeStyle["border-radius"] = "5px";
                            beforeStyle["box-shadow"] = "rgb(44, 44, 44) 3px 3px 2px";
                            var color = hextorgb(_effect.Color);

                            beforeStyle["background-color"] = string.Format("rgba({0}, {1}, {2}, {3})", color.R, color.G, color.B, _effect.Opacity);
                            beforeStyle["border"] = "2px solid black";

                            ChangeCSS("card" + scope.Card.Type + "-" + scope.Card.Value + "::before", beforeStyle);




                            break;
                        case EffectType2.Rotate:
                            break;
                        case EffectType2.Bend:




                            var bEffect = (new CardGameAppearanceEffectBend(new CardGameEffectBendOptions()
                            {
                                Degrees = grabbedEffect.GetPropertyByName<double>("degrees"),
                            }));

                            element.Me().rotate((((-bEffect.Degrees / 2 + bEffect.Degrees / (scope.Parent.Space.Pile.Cards.Count - 1) * cardIndex) + NoTransformRotate(element.Me().rotate()))) + "deg");

                            break;
                        case EffectType2.StyleProperty:
                            break;
                        case EffectType2.Animated:
                            break;
                    }
                }




 

           
            };
            JsDictionary<string, string> keys = new JsDictionary<string, string>() { };
            keys["content"] = "url('assets/cards/" + (100 + (scope.Card.Value + 1) + (scope.Card.Type) * 13) + ".gif')";
            ChangeCSS("card" + scope.Card.Type + "-" + scope.Card.Value + "::before", keys);


 
            scope.watch("$parent.space", () =>
            {
                Console.Log("ac");
                redrawCard();
            }, true);
            scope.watch("card.appearance.effectNames", () =>
            {
                Console.Log("b");
                redrawCard();
            }, true);
            scope.watch<CardScope>((_scope) =>
            {

                List<Effect> effects = new List<Effect>();

                foreach (var ef in _scope.Card.Appearance.EffectNames)
                {
                    var _ef = myEffectManager.GetEffectByName(ef);
                    effects.Add(_ef);
                }
                return effects;
            }, () => {
                Console.Log("c");
                   redrawCard();
               }, true);


            redrawCard();
        }
        private void linkFn(DebugCardScope scope, jQueryObject element, object attrs)
        {
            var card = scope.Card.GameCard;
            scope.Classes = new List<string>();
            
            element.Attribute("style", "width:71px; height:96px;");
            var beforeStyle = new JsDictionary<string, string>() { };
            var lastStyle = new JsDictionary<string, string>() { };
            element.Draggable(new DraggableOptions()
            {
                OnStart = (@event, uiEvent) =>
                          {
                              scope.Card.Dragging = true;
                              scope.CardStyle.zIndex = 1000;
                              rootScope.Broadcast("redrawCard");
                              scope.Apply();
                          },
                OnDrag = (@event, uiEvent) =>
                         {
                             scope.Card.Location.X = @event.ClientX ;
                             scope.Card.Location.Y = @event.ClientY ;
                             bool updated = false;
                             foreach (var debugSpace in scope.GameModel.Spaces)
                             {
                                 for (int index = debugSpace.Cards.Count - 1; index >= 0; index--)
                                 {
                                     if (debugSpace.Cards[index].PlaceHolder)
                                     {
                                         updated = true;
                                         debugSpace.Cards.RemoveAt(index);

                                     }
                                 }
                             }


                             foreach (var debugSpace in scope.GameModel.Spaces)
                             {
                                 if (debugSpace.Location.Expand(30).Contains(scope.Card.Location))
                                 {
                                     foreach (var debugSpaceCard in debugSpace.Cards)
                                     {
                                         Rectangle rectangle = debugSpaceCard.Location.Offset(debugSpace.Location.X, debugSpace.Location.Y);
                                         Console.WriteLine(string.Format("{0},{1}   {2} {3}", debugSpace.Location.X, debugSpace.Location.Y, debugSpaceCard, rectangle.Expand(10).ToString(), scope.Card.Location.ToString()));
                                         if (rectangle.Expand(10).Contains(scope.Card.Location))
                                         {
                                             debugSpace.Cards.Insert(debugSpace.Cards.IndexOf(debugSpaceCard), new DebugSpaceCard() { PlaceHolder = true, GameCard = null });

/*
                                             if (rectangle.X + rectangle.Width/2 < scope.Card.Location.X)
                                             {
                                                 debugSpace.Cards.Insert(debugSpace.Cards.IndexOf(debugSpaceCard), new DebugSpaceCard() { PlaceHolder = true, GameCard = null });
                                             }
                                             else
                                             {
                                                 debugSpace.Cards.Insert(debugSpace.Cards.IndexOf(debugSpaceCard)+1, new DebugSpaceCard() { PlaceHolder = true, GameCard = null });
                                             }
*/


                                             Console.WriteLine("Took");
                                             updated = true;
                                             break;
                                         }
                                     }
                                 }
                             }
                             if (updated)
                             {
                                 rootScope.Broadcast("redrawCard");
                                 scope.Apply();
                             }
                         },
                OnStop = (@event, uiEvent) =>
                {
                    foreach (var debugSpace in scope.GameModel.Spaces)
                    {
                        for (int index = debugSpace.Cards.Count - 1; index >= 0; index--)
                        {
                            if (debugSpace.Cards[index].PlaceHolder)
                            {
                                debugSpace.Cards.RemoveAt(index);
                                scope.Space.Cards.Remove(scope.Card);

                                foreach (var debugSpaceCard in scope.Space.Cards)
                                {
                                    if (debugSpaceCard.Index > scope.Card.Index)
                                    {
                                        debugSpaceCard.Index--;
                                    }
                                }

                                scope.Card.Index = index;

                                foreach (var debugSpaceCard in debugSpace.Cards)
                                {
                                    if (debugSpaceCard.Index >= scope.Card.Index)
                                    {
                                        debugSpaceCard.Index++;
                                    }
                                }

                                debugSpace.Cards.Insert(index,scope.Card);
                                break;
                            }
                        }
                    }
                    ExtensionMethods.Delete(scope.CardStyle.zIndex);
                    scope.Card.Dragging = false;
                    rootScope.Broadcast("redrawCard");
                    scope.Apply();
                }
            });

            Action redrawCard = () =>
            {

                Console.WriteLine(string.Format("card{0}-{1} being called ", card.Type, card.Value));
                if (scope.Card.Dragging)
                {
                    return;
                }
                scope.CardStyle = new { };
                card = scope.Card.GameCard;
                var scale = scope.GameModel.Scale;


                var goodCards = scope.Space.Cards.Where(a => !a.Dragging);
                int spaceCardLength = goodCards.Count - 1;
                var debugSpace = scope.Space.GameSpace;

                var spaceScale =
                    new
                    {
                        width = debugSpace.Width / spaceCardLength,
                        height = debugSpace.Height / spaceCardLength
                    };
                var vertical = debugSpace.Vertical;
                var cardIndex = goodCards.IndexOf(scope.Card);


                var xx = 0.0;
                var yy = 0.0;


                switch (debugSpace.ResizeType)
                {
                    case TableSpaceResizeType.Static:
                        if (vertical)
                            yy = ((card.Value + 1) / 13.0) * debugSpace.Height * scale.Y;
                        else
                            xx = ((card.Value + 1) / 13.0) * debugSpace.Width * scale.X;
                        break;
                    case TableSpaceResizeType.Grow:
                        xx = (!vertical ? (cardIndex * spaceScale.width * scale.X) : 0);
                        yy = (vertical ? (cardIndex * spaceScale.height * scale.Y) : 0);
                        break;
                    default:
                        xx = (!vertical ? (cardIndex * spaceScale.width * scale.X) : 0);
                        yy = (vertical ? (cardIndex * spaceScale.height * scale.Y) : 0);
                        break;
                }

                xx -= 71 / 2;
                yy -= 96 / 2;


                scope.CardStyle.position = "absolute";
                scope.CardStyle.zIndex = cardIndex;
                scope.CardStyle.borderRadius = 5.ToPx();
                xx = (xx + (vertical ? debugSpace.Width * scale.X / 2 : 0));
                element.CSS("left", xx.ToPx());
                yy = (yy + (!vertical ? debugSpace.Height * scale.Y / 2 : 0));
                element.CSS("top", yy.ToPx());

                scope.Card.Location = new Rectangle(xx, yy, 71, 96);
                //                scope.CardStyle["-webkit-transform"] = "rotate(" + scope.Parent.Space.Appearance.InnerStyle.Rotate + "deg)";
                //                element.me().rotate(scope.Parent.Space.Appearance.InnerStyle.Rotate);
                scope.CardStyle.content = "\"\"";



                if (card == null)
                {
                    scope.CardStyle.border = "solid 2px blue";
                    scope.CardStyle.width = "71px";
                    scope.CardStyle.height = "96px";
                }

                else
                {


                    beforeStyle = new JsDictionary<string, string>() { };
                    if (card.Value == -1 && card.Type == -1)
                    {
                        beforeStyle["content"] = string.Format("url('{1}assets/cards/{0}.gif')", 155, Constants.ContentAddress);
                    }
                    else
                    {
                        beforeStyle["content"] = string.Format("url('{1}assets/cards/{0}.gif')", (100 + (card.Value + 1) + (card.Type) * 13), Constants.ContentAddress);
                    }
                     

                    foreach (var effectName in card.Effects)
                    {
                        var effect = scope.GameModel.MainArea.ClientGetEffectByName(effectName);

                        switch (effect.Type)
                        {
                            case EffectType.Highlight:
                                {
                                    var color = effect.GetString("color");
                                    var radius = effect.GetNumber("radius");
                                    var rotate = effect.GetNumber("rotate");
                                    var offsetX = effect.GetNumber("offsetx");
                                    var offsetY = effect.GetNumber("offsety");
                                    var opacity = effect.GetNumber("opacity");

                                     
                                    beforeStyle["display"] = "block";
                                    beforeStyle["position"] = "relative";
                                    beforeStyle["z-index"] = "-1";
                                    beforeStyle["width"] = "100%";
                                    beforeStyle["height"] = "100%";
                                    beforeStyle["left"] = (-radius + offsetX) + "px";
                                    beforeStyle["top"] = (-radius + offsetY) + "px";
                                    beforeStyle["padding"] = (radius) + "px";
                                    beforeStyle["border-radius"] = "5px";
                                    beforeStyle["box-shadow"] = "rgb(44, 44, 44) 3px 3px 2px";
                                    beforeStyle["content"] = string.Format("url('{1}assets/cards/{0}.gif')", (100 + (card.Value + 1) + (card.Type) * 13), Constants.ContentAddress);
                                    var hexcolor = ClientHelpers.HexToRGB(color);
                                    beforeStyle["background-color"] = string.Format("rgba({0}, {1}, {2}, {3})", hexcolor.R, hexcolor.G, hexcolor.B, opacity);
                                    beforeStyle["border"] = "2px solid black";



                                }
                                break;
                            case EffectType.Rotate:
                                {
                                    var rotate = effect.GetNumber("degrees");
                                    scope.CardStyle["-webkit-transform"] = "rotate(" + rotate + "deg)";
                                    scope.CardStyle.transform = "rotate(" + rotate + "deg)";



                                }

                                break;
                            case EffectType.Bend:

                                /*


                              var bEffect = (new CardGameAppearanceEffectBend(new CardGameEffectBendOptions()
                              {
                                  Degrees = grabbedEffect.GetPropertyByName<double>("degrees"),
                              }));


                              var rotate = element.GetCSS("transform").Replace(" scale(1, 1)", "");

                              element.me().rotate((((-bEffect.Degrees / 2 + bEffect.Degrees / (scope.Space.Pile.Cards.Count - 1) * cardIndex) + NoTransformRotate(rotate))));
                 
  */

                                break;
                            case EffectType.StyleProperty:
                                break;
                            case EffectType.Animated:
                                break;
                        }

                    }


                    if (!lastStyle.SameAs(beforeStyle))
                    {
                        Console.WriteLine(string.Format("card{0}-{1} being updated ", card.Type, card.Value));
                        ClientHelpers.PurgeCSS(string.Format("card{0}-{1}", card.Type, card.Value) + "::before");
                        ClientHelpers.ChangeCSS(string.Format("card{0}-{1}::before", card.Type, card.Value), beforeStyle);
                    }
                    lastStyle = beforeStyle;

                }





                /*
                                foreach (var effect in scope.Card.Appearance.EffectNames)
                                {
                                    GameEffectModel grabbedEffect = myEffectManager.GetEffectByName(effect);
                                    if (grabbedEffect == null)
                                    {
                                        continue;
                                    }
                                    switch (grabbedEffect.Type)
                                    {
                                        case EffectType.Highlight:

                                            var _effect = new CardGameAppearanceEffectHighlight(new CardGameEffectHighlightOptions()
                                            {
                                                Color = grabbedEffect.GetPropertyByName<string>("color"),
                                                Radius = grabbedEffect.GetPropertyByName<double>("radius"),
                                                Rotate = grabbedEffect.GetPropertyByName<double>("rotate"),
                                                OffsetX = grabbedEffect.GetPropertyByName<double>("offsetx"),
                                                OffsetY = grabbedEffect.GetPropertyByName<double>("offsety"),
                                                Opacity = grabbedEffect.GetPropertyByName<double>("opacity"),
                                            });

                                            JsDictionary<string, string> beforeStyle = new JsDictionary<string, string>();
                                            beforeStyle["display"] = "block";
                                            beforeStyle["position"] = "relative";
                                            beforeStyle["z-index"] = "-1";
                                            beforeStyle["width"] = "100%";
                                            beforeStyle["height"] = "100%";
                                            beforeStyle["left"] = (-_effect.Radius + _effect.OffsetX) + "px";
                                            beforeStyle["top"] = (-_effect.Radius + _effect.OffsetY) + "px";
                                            beforeStyle["padding"] = (_effect.Radius) + "px";
                                            beforeStyle["border-radius"] = "5px";
                                            beforeStyle["box-shadow"] = "rgb(44, 44, 44) 3px 3px 2px";
                                            var color = hextorgb(_effect.Color);

                                            beforeStyle["background-color"] = string.Format("rgba({0}, {1}, {2}, {3})", color.R, color.G, color.B, _effect.Opacity);
                                            beforeStyle["border"] = "2px solid black";

                                            ChangeCSS("card" + scope.Card.Type + "-" + scope.Card.Value + "::before", beforeStyle);




                                            break;
                                        case EffectType.Rotate:
                                            break;
                                        case EffectType.Bend:




                                            var bEffect = (new CardGameAppearanceEffectBend(new CardGameEffectBendOptions()
                                            {
                                                Degrees = grabbedEffect.GetPropertyByName<double>("degrees"),
                                            }));


                                            var rotate = element.GetCSS("transform").Replace(" scale(1, 1)", "");

                                            element.me().rotate((((-bEffect.Degrees / 2 + bEffect.Degrees / (scope.Space.Pile.Cards.Count - 1) * cardIndex) + NoTransformRotate(rotate))) );

                                            break;
                                        case EffectType.StyleProperty:
                                            break;
                                        case EffectType.Animated:
                                            break;
                                    }
                                }
                */
            };
            if (card != null)
            {
                if (card.Value == -1 && card.Type == -1)
                {
                    beforeStyle["content"] = string.Format("url('{1}assets/cards/{0}.gif')", 155, Constants.ContentAddress);
                }
                else
                {
                    beforeStyle["content"] = string.Format("url('{1}assets/cards/{0}.gif')", (100 + (card.Value + 1) + (card.Type) * 13), Constants.ContentAddress);
                }

                scope.Classes.Add(string.Format("card{0}-{1}", card.Type, card.Value));

                ClientHelpers.ChangeCSS("card" + card.Type + "-" + card.Value + "::before", beforeStyle);
            }

            scope.On("redrawCard", redrawCard);

            //   redrawCard();
            /*
                          
 
            scope.Watch("$parent.space", () =>
            {
                Console.Log("ac");
                redrawCard();
            }, true);
            scope.Watch("card.appearance.effectNames.join()", () =>
            {
                Console.Log("b");
                redrawCard();
            }, true);*/
            /*scope.Watch<CardScope>((_scope) =>
            {

                List<Effect> effects = new List<Effect>();

                foreach (var ef in _scope.Card.Appearance.EffectNames)
                {
                    var _ef = myEffectManager.GetEffectByName(ef);
                    effects.Add(_ef);
                }
                return effects;
            }, () => {
                Console.Log("c");
                   redrawCard();
               }, true);

*/
            redrawCard();
        }
        private void linkFn(CardScope scope, jQueryObject element, object attrs)
        {
            element.Attribute("style", "width:71px; height:96px;");
            element.Attribute("class", "card " + string.Format("card{0}-{1}", scope.Card.Type, scope.Card.Value));
            element.Draggable(new DraggableOptions()
                              {
                                  OnDrag = (@event, uiEvent) =>
                                           {


                                           }
                              });

            Action redrawCard = () =>
                                {
                                    var scale = ((Point)((dynamic)scope.Parent.Parent)["$parent"].scale);


                                    var spaceScale =
                                        new
                                        {
                                            width = scope.Space.Width / (scope.Space.Pile.Cards.Count - 1),
                                            height = scope.Space.Height / (scope.Space.Pile.Cards.Count - 1)
                                        };
                                    var vertical = scope.Space.Vertical;
                                    var cardIndex = scope.Space.Pile.Cards.IndexOf(scope.Card);

                                    scope.CardStyle = new { };

                                    var xx = 0.0;
                                    var yy = 0.0;


                                    switch (scope.Space.ResizeType)
                                    {
                                        case TableSpaceResizeType.Static:
                                            if (vertical)
                                                yy = ((scope.Card.Value + 1) / 13.0) * scope.Space.Height * scale.Y;
                                            else
                                                xx = ((scope.Card.Value + 1) / 13.0) * scope.Space.Width * scale.X;
                                            break;
                                        case TableSpaceResizeType.Grow:
                                            xx = (!vertical ? (cardIndex * spaceScale.width * scale.X) : 0);
                                            yy = (vertical ? (cardIndex * spaceScale.height * scale.Y) : 0);
                                            break;
                                        default:
                                            xx = (!vertical ? (cardIndex * spaceScale.width * scale.X) : 0);
                                            yy = (vertical ? (cardIndex * spaceScale.height * scale.Y) : 0);
                                            break;
                                    }

                                    xx -= 71 / 2;
                                    yy -= 96 / 2;

                                    scope.CardStyle.position = "absolute";
                                    scope.CardStyle.zIndex = cardIndex;
                                    scope.CardStyle.borderRadius = "5px";
                                    scope.CardStyle.left = (xx + (vertical ? scope.Space.Width * scale.X / 2 : 0));
                                    scope.CardStyle.top = (yy + (!vertical ? scope.Space.Height * scale.Y / 2 : 0));
                                    //                scope.CardStyle["-webkit-transform"] = "rotate(" + scope.Parent.Space.Appearance.InnerStyle.Rotate + "deg)";
                                    //                element.me().rotate(scope.Parent.Space.Appearance.InnerStyle.Rotate);
                                    scope.CardStyle.content = "\"\"";

                                     
                                    /*
                                                    foreach (var effect in scope.Card.Appearance.EffectNames)
                                                    {
                                                        GameEffectModel grabbedEffect = myEffectManager.GetEffectByName(effect);
                                                        if (grabbedEffect == null)
                                                        {
                                                            continue;
                                                        }
                                                        switch (grabbedEffect.Type)
                                                        {
                                                            case EffectType.Highlight:

                                                                var _effect = new CardGameAppearanceEffectHighlight(new CardGameEffectHighlightOptions()
                                                                {
                                                                    Color = grabbedEffect.GetPropertyByName<string>("color"),
                                                                    Radius = grabbedEffect.GetPropertyByName<double>("radius"),
                                                                    Rotate = grabbedEffect.GetPropertyByName<double>("rotate"),
                                                                    OffsetX = grabbedEffect.GetPropertyByName<double>("offsetx"),
                                                                    OffsetY = grabbedEffect.GetPropertyByName<double>("offsety"),
                                                                    Opacity = grabbedEffect.GetPropertyByName<double>("opacity"),
                                                                });

                                                                JsDictionary<string, string> beforeStyle = new JsDictionary<string, string>();
                                                                beforeStyle["display"] = "block";
                                                                beforeStyle["position"] = "relative";
                                                                beforeStyle["z-index"] = "-1";
                                                                beforeStyle["width"] = "100%";
                                                                beforeStyle["height"] = "100%";
                                                                beforeStyle["left"] = (-_effect.Radius + _effect.OffsetX) + "px";
                                                                beforeStyle["top"] = (-_effect.Radius + _effect.OffsetY) + "px";
                                                                beforeStyle["padding"] = (_effect.Radius) + "px";
                                                                beforeStyle["border-radius"] = "5px";
                                                                beforeStyle["box-shadow"] = "rgb(44, 44, 44) 3px 3px 2px";
                                                                var color = hextorgb(_effect.Color);

                                                                beforeStyle["background-color"] = string.Format("rgba({0}, {1}, {2}, {3})", color.R, color.G, color.B, _effect.Opacity);
                                                                beforeStyle["border"] = "2px solid black";

                                                                ChangeCSS("card" + scope.Card.Type + "-" + scope.Card.Value + "::before", beforeStyle);




                                                                break;
                                                            case EffectType.Rotate:
                                                                break;
                                                            case EffectType.Bend:




                                                                var bEffect = (new CardGameAppearanceEffectBend(new CardGameEffectBendOptions()
                                                                {
                                                                    Degrees = grabbedEffect.GetPropertyByName<double>("degrees"),
                                                                }));


                                                                var rotate = element.GetCSS("transform").Replace(" scale(1, 1)", "");

                                                                element.me().rotate((((-bEffect.Degrees / 2 + bEffect.Degrees / (scope.Space.Pile.Cards.Count - 1) * cardIndex) + NoTransformRotate(rotate))) );

                                                                break;
                                                            case EffectType.StyleProperty:
                                                                break;
                                                            case EffectType.Animated:
                                                                break;
                                                        }
                                                    }
                                    */
                                };
            var keys = new JsDictionary<string, string>() { };
            if (scope.Card.Value == -1 && scope.Card.Type == -1)
            {
                keys["content"] = string.Format("url('{1}assets/cards/{0}.gif')", 155, Constants.ContentAddress);
            }
            else
            {
                keys["content"] = string.Format("url('{1}assets/cards/{0}.gif')", (100 + (scope.Card.Value + 1) + (scope.Card.Type) * 13), Constants.ContentAddress);
            }
            ClientHelpers.ChangeCSS("card" + scope.Card.Type + "-" + scope.Card.Value + "::before", keys);


            scope.On("redrawCard", redrawCard);

            //   redrawCard();
            /*
                          
 
            scope.Watch("$parent.space", () =>
            {
                Console.Log("ac");
                redrawCard();
            }, true);
            scope.Watch("card.appearance.effectNames.join()", () =>
            {
                Console.Log("b");
                redrawCard();
            }, true);*/
            /*scope.Watch<CardScope>((_scope) =>
            {

                List<Effect> effects = new List<Effect>();

                foreach (var ef in _scope.Card.Appearance.EffectNames)
                {
                    var _ef = myEffectManager.GetEffectByName(ef);
                    effects.Add(_ef);
                }
                return effects;
            }, () => {
                Console.Log("c");
                   redrawCard();
               }, true);

*/
            redrawCard();
        }