public void DependencyPropertyGetterSetterTest()
        {
            var control = new GenericControl <DateTime>();
            var now     = DateTime.Now;

            control.SetValue(GenericControl <DateTime> .GenericProperty, now);

            Assert.AreEqual(now, control.GetValue(GenericControl <DateTime> .GenericProperty));
        }
        public void ClrGetterSetterTest()
        {
            var control = new GenericControl <DateTime>();
            var now     = DateTime.Now;

            control.Generic = now;

            Assert.AreEqual(now, control.Generic);
        }
Пример #3
0
        public void clickBtn(object sender, RoutedEventArgs e)
        {
            var m = ((Button)sender).DataContext as TestViewModel;

            m.CreateModel.HeaderText = "tripathi";
            viewModel = m;
            var s = new GenericControl {
                DataContext = viewModel
            };
        }
Пример #4
0
        public ResourceManager(ClientControl clientControl)
        {
            ClientControl = clientControl;

            _personControl           = new PersonControl(ClientControl);
            _groupControl            = new GroupControl(ClientControl);
            _ocgSSoDControl          = new OcgSSoDControl(clientControl);
            _ocgOrgUnitControl       = new OcgOrgUnitControl(clientControl);
            _ocgOrgAssignmentControl = new OcgOrgAssignmentControl(clientControl);
            _ocgRoleControl          = new OcgRoleControl(clientControl);
            _approvalControl         = new ApprovalControl(clientControl);
            _genericControl          = new GenericControl(clientControl);
        }
Пример #5
0
        private Control AddControl(string name, int count, float[] distances, object[] userData)
        {
            var control = new GenericControl(name)
            {
                count    = () => { return(count); },
                distance = (guiState, i) => { return(distances[i]); },
                userData = (i) => { return(userData[i]); }
            };

            m_GUISystem.AddControl(control);

            return(control);
        }
Пример #6
0
        public ActionResult Create(GenericControlViewModel model, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                                  .Select(v => v.ErrorMessage + " " + v.Exception));
                    base.ModelState.AddModelError("", messages);
                    return(base.View(model));
                }
                else
                {
                    GenericControl modelMap = Mapper.Map <GenericControlViewModel, App.Domain.Entities.GenericControl.GenericControl>(model);
                    this._genericControlService.Create(modelMap);

                    //Update Localized
                    foreach (var localized in model.Locales)
                    {
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Name, localized.Name, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                    }

                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.GenericControl)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ExtentionUtils.Log(string.Concat("GenericControl.Create: ", exception.Message));
                return(base.View(model));
            }
            return(action);
        }
Пример #7
0
        public String  PerformLogin(String UsernameValue, String PasssworValue, String ExpectedResult)
        {
            try
            {
                GenericControl obj      = new GenericControl(browser);
                UITestControl  Username = obj.FindControl <HtmlEdit>(UsernNameLocatorType, UsernNameLocatorValue);
                KeyboardActions.SendKeys(Username, UsernameValue, browser);
                UITestControl Submit = obj.FindControl <HtmlInputButton>(SubmitLocatordType, SubmitLocatorValue);
                MouseActions.MouseClick(Submit, browser);
                UITestControl Password = obj.FindControl <HtmlEdit>(PassworLocatordType, PassworLocatordValue);
                KeyboardActions.SendKeys(Password, PasssworValue, browser);
                UITestControl Login = obj.FindControl <HtmlInputButton>(SubmitLocatordType, SubmitLocatorValue);
                MouseActions.MouseClick(Login, browser);

                return(ActualResult = ExpectedResult);
            }

            catch (Exception e)
            {
                return(ActualResult = e.Message);
            }
        }
Пример #8
0
        public ActionResult Edit(GenericControlViewModel model, string ReturnUrl)
        {
            ActionResult action;

            try
            {
                if (!base.ModelState.IsValid)
                {
                    String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors)
                                                  .Select(v => v.ErrorMessage + " " + v.Exception));
                    base.ModelState.AddModelError("", messages);
                    return(base.View(model));
                }
                else
                {
                    GenericControl objGenericControl = _genericControlService.GetById(model.Id);

                    List <MenuLink> lstMenuLink = new List <MenuLink>();
                    List <int>      lstMenuId   = new List <int>();

                    string menuLink = this.Request["MenuLink"];
                    if (!string.IsNullOrEmpty(menuLink))
                    {
                        foreach (var item in menuLink.Split(new char[] { ',' }).ToList <string>())
                        {
                            int menuId = int.Parse(item);
                            lstMenuId.Add(menuId);

                            lstMenuLink.Add(_menuLinkService.GetById(menuId, isCache: false));
                        }

                        if (lstMenuId.IsAny())
                        {
                            (from x in objGenericControl.MenuLinks
                             where !lstMenuId.Contains(x.Id)
                             select x).ToList <MenuLink>()
                            .ForEach((MenuLink m) =>
                                     objGenericControl.MenuLinks.Remove(m)
                                     );
                        }
                    }
                    objGenericControl.MenuLinks = lstMenuLink;

                    GenericControl modelMap = Mapper.Map <GenericControlViewModel, GenericControl>(model);
                    this._genericControlService.Update(objGenericControl);


                    //Update Localized
                    foreach (var localized in model.Locales)
                    {
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Name, localized.Name, localized.LanguageId);
                        _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId);
                    }

                    base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.GenericControl)));
                    if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\"))
                    {
                        action = base.RedirectToAction("Index");
                    }
                    else
                    {
                        action = this.Redirect(ReturnUrl);
                    }
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                ExtentionUtils.Log(string.Concat("GenericControl.Create: ", exception.Message));
                return(base.View(model));
            }
            return(action);
        }
        private GUISystem CreateSystem(UnityObject target)
        {
            var guiSystem = new GUISystem(new GUIState());

            GUIAction removePointAction = null;

            var pointControl = new GenericControl("Point")
            {
                count = () =>
                {
                    return(GetPointCount(target));
                },
                distance = (guiState, i) =>
                {
                    var position = GetPointWorld(target, i);
                    return(ShapeEditorUtility.DistanceToCircle(position, ShapeEditorUtility.GetHandleSize(position) * 10f));
                },
                position = (i) =>
                {
                    return(GetPointWorld(target, i));
                },
                forward = (i) =>
                {
                    return(GetForward(target));
                },
                up = (i) =>
                {
                    return(GetUp(target));
                },
                right = (i) =>
                {
                    return(GetRight(target));
                },
                onRepaint = (IGUIState guiState, Control control, int index) =>
                {
                    var position = GetPointWorld(target, index);

                    if (guiState.hotControl == control.actionID && control.hotLayoutData.index == index)
                    {
                        m_Drawer.DrawPointSelected(position);
                    }
                    else if (guiState.hotControl == 0 && guiState.nearestControl == control.ID && control.layoutData.index == index)
                    {
                        if (removePointAction.IsEnabled(guiState))
                        {
                            m_Drawer.DrawRemovePointPreview(position);
                        }
                        else
                        {
                            m_Drawer.DrawPointHovered(position);
                        }
                    }
                    else
                    {
                        m_Drawer.DrawPoint(position);
                    }
                }
            };

            var edgeControl = new GenericControl("Edge")
            {
                count = () =>
                {
                    return(GetPointCount(target));
                },
                distance = (IGUIState guiState, int index) =>
                {
                    return(ShapeEditorUtility.DistanceToSegment(GetPointWorld(target, index), NextControlPoint(target, index)));
                },
                position = (i) =>
                {
                    return(GetPointWorld(target, i));
                },
                forward = (i) =>
                {
                    return(GetForward(target));
                },
                up = (i) =>
                {
                    return(GetUp(target));
                },
                right = (i) =>
                {
                    return(GetRight(target));
                },
                onRepaint = (IGUIState guiState, Control control, int index) =>
                {
                    var nextIndex = NextIndex(target, index);
                    var prevIndex = PrevIndex(target, index);

                    var isEndpointHovered =
                        guiState.hotControl == 0 &&
                        guiState.nearestControl == pointControl.ID &&
                        (index == pointControl.layoutData.index || nextIndex == pointControl.layoutData.index);

                    var isPointHovered =
                        guiState.hotControl == 0 &&
                        guiState.nearestControl == pointControl.ID &&
                        index == pointControl.layoutData.index;

                    var color = Color.white;

                    if (guiState.hotControl == 0 && guiState.nearestControl == control.ID && control.layoutData.index == index)
                    {
                        color = Color.yellow;
                    }
                    else if (removePointAction.IsEnabled(guiState) && isEndpointHovered)
                    {
                        if (isPointHovered)
                        {
                            m_Drawer.DrawDottedLine(GetPointWorld(target, prevIndex), GetPointWorld(target, nextIndex), 5f, color);
                        }

                        color = Color.red;
                    }

                    m_Drawer.DrawLine(GetPointWorld(target, index), GetPointWorld(target, nextIndex), 5f, color);
                }
            };

            var createPointAction = new CreatePointAction(pointControl, edgeControl)
            {
                enable = (guiState, action) =>
                {
                    return(guiState.isShiftDown);
                },
                enableRepaint = (IGUIState guiState, GUIAction action) =>
                {
                    return(guiState.nearestControl != pointControl.ID && guiState.hotControl == 0);
                },
                repaintOnMouseMove = (guiState, action) =>
                {
                    return(true);
                },
                guiToWorld = (mousePosition) =>
                {
                    return(GUIToWorld(target, mousePosition));
                },
                onCreatePoint = (int index, Vector3 position) =>
                {
                    InsertPointWorld(target, index + 1, position);
                },
                onPreRepaint = (guiState, action) =>
                {
                    var position = ClosestPointInEdge(target, guiState.mousePosition, edgeControl.layoutData.index);

                    m_Drawer.DrawCreatePointPreview(position);
                }
            };

            removePointAction = new ClickAction(pointControl, 0)
            {
                enable = (guiState, action) =>
                {
                    return(guiState.isActionKeyDown);
                },
                onClick = (GUIState, control) =>
                {
                    if (GetPointCount(target) > 3)
                    {
                        RemovePoint(target, control.layoutData.index);
                    }
                }
            };

            var movePointAction = new SliderAction(pointControl)
            {
                onSliderChanged = (guiState, control, position) =>
                {
                    var index         = control.hotLayoutData.index;
                    var pointPosition = GetPointWorld(target, index);
                    pointPosition = position;
                    SetPointWorld(target, index, pointPosition);
                }
            };

            var moveEdgeAction = new SliderAction(edgeControl)
            {
                onSliderChanged = (guiState, control, position) =>
                {
                    var index         = control.hotLayoutData.index;
                    var pointPosition = GetPointWorld(target, index);
                    var delta         = position - pointPosition;
                    pointPosition += delta;
                    SetPointWorld(target, index, pointPosition);
                    pointPosition  = NextControlPoint(target, index);
                    pointPosition += delta;
                    SetPointWorld(target, NextIndex(target, index), pointPosition);
                }
            };

            guiSystem.AddControl(edgeControl);
            guiSystem.AddControl(pointControl);
            guiSystem.AddAction(createPointAction);
            guiSystem.AddAction(removePointAction);
            guiSystem.AddAction(movePointAction);
            guiSystem.AddAction(moveEdgeAction);

            return(guiSystem);
        }
Пример #10
0
        public PathEditor(GUISystem guiSystem)
        {
            m_GUISystem = guiSystem;

            var m_PointControl = new GenericControl("Point")
            {
                count    = GetPointCount,
                distance = (guiState, i) =>
                {
                    var position = GetPoint(i).position;
                    return(guiState.DistanceToCircle(position, guiState.GetHandleSize(position) * 10f));
                },
                position  = (i) => { return(GetPoint(i).position); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = DrawPoint
            };

            var m_EdgeControl = new GenericControl("Edge")
            {
                count     = GetEdgeCount,
                distance  = DistanceToEdge,
                position  = (i) => { return(GetPoint(i).position); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = DrawEdge
            };

            m_EdgeControl.onEndLayout = (guiState) => { controller.AddClosestPath(m_EdgeControl.layoutData.distance); };

            var m_LeftTangentControl = new GenericControl("LeftTangent")
            {
                count = () =>
                {
                    if (GetShapeType() != ShapeType.Spline)
                    {
                        return(0);
                    }

                    return(GetPointCount());
                },
                distance = (guiState, i) =>
                {
                    if (linearTangentIsZero && GetPoint(i).tangentMode == TangentMode.Linear)
                    {
                        return(float.MaxValue);
                    }

                    if (!IsSelected(i) || IsOpenEnded() && i == 0)
                    {
                        return(float.MaxValue);
                    }

                    var position = GetLeftTangent(i);
                    return(guiState.DistanceToCircle(position, guiState.GetHandleSize(position) * 10f));
                },
                position  = (i) => { return(GetLeftTangent(i)); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = (guiState, control, i) =>
                {
                    if (!IsSelected(i) || IsOpenEnded() && i == 0)
                    {
                        return;
                    }

                    var point = GetPoint(i);

                    if (linearTangentIsZero && point.tangentMode == TangentMode.Linear)
                    {
                        return;
                    }

                    var position    = point.position;
                    var leftTangent = GetLeftTangent(i);

                    drawer.DrawTangent(position, leftTangent);
                }
            };

            var m_RightTangentControl = new GenericControl("RightTangent")
            {
                count = () =>
                {
                    if (GetShapeType() != ShapeType.Spline)
                    {
                        return(0);
                    }

                    return(GetPointCount());
                },
                distance = (guiState, i) =>
                {
                    if (linearTangentIsZero && GetPoint(i).tangentMode == TangentMode.Linear)
                    {
                        return(float.MaxValue);
                    }

                    if (!IsSelected(i) || IsOpenEnded() && i == GetPointCount() - 1)
                    {
                        return(float.MaxValue);
                    }

                    var position = GetRightTangent(i);
                    return(guiState.DistanceToCircle(position, guiState.GetHandleSize(position) * 10f));
                },
                position  = (i) => { return(GetRightTangent(i)); },
                forward   = (i) => { return(GetForward()); },
                up        = (i) => { return(GetUp()); },
                right     = (i) => { return(GetRight()); },
                onRepaint = (guiState, control, i) =>
                {
                    if (!IsSelected(i) || IsOpenEnded() && i == GetPointCount() - 1)
                    {
                        return;
                    }

                    var point = GetPoint(i);

                    if (linearTangentIsZero && point.tangentMode == TangentMode.Linear)
                    {
                        return;
                    }

                    var position     = point.position;
                    var rightTangent = GetRightTangent(i);

                    drawer.DrawTangent(position, rightTangent);
                }
            };

            var m_CreatePointAction = new CreatePointAction(m_PointControl, m_EdgeControl)
            {
                enable             = (guiState, action) => !IsAltDown(guiState) && !guiState.isActionKeyDown && controller.closestEditablePath == controller.editablePath,
                enableRepaint      = (guiState, action) => EnableCreatePointRepaint(guiState, m_PointControl, m_LeftTangentControl, m_RightTangentControl),
                repaintOnMouseMove = (guiState, action) => true,
                guiToWorld         = GUIToWorld,
                onCreatePoint      = (index, position) =>
                {
                    controller.RegisterUndo("Create Point");
                    controller.CreatePoint(index, position);
                },
                onPreRepaint = (guiState, action) =>
                {
                    if (GetPointCount() > 0)
                    {
                        var position = ClosestPointInEdge(guiState, guiState.mousePosition, m_EdgeControl.layoutData.index);
                        drawer.DrawCreatePointPreview(position);
                    }
                }
            };

            Action <IGUIState> removePoints = (guiState) =>
            {
                controller.RegisterUndo("Remove Point");
                controller.RemoveSelectedPoints();
                guiState.changed = true;
            };

            var m_RemovePointAction1 = new CommandAction(kDeleteCommandName)
            {
                enable    = (guiState, action) => { return(GetSelectedPointCount() > 0); },
                onCommand = removePoints
            };

            var m_RemovePointAction2 = new CommandAction(kSoftDeleteCommandName)
            {
                enable    = (guiState, action) => { return(GetSelectedPointCount() > 0); },
                onCommand = removePoints
            };

            var dragged           = false;
            var m_MovePointAction = new SliderAction(m_PointControl)
            {
                enable  = (guiState, action) => !IsAltDown(guiState),
                onClick = (guiState, control) =>
                {
                    dragged = false;
                    var index = control.layoutData.index;

                    if (!IsSelected(index))
                    {
                        controller.RegisterUndo("Selection");

                        if (!guiState.isActionKeyDown)
                        {
                            controller.ClearSelection();
                        }

                        controller.SelectPoint(index, true);
                        guiState.changed = true;
                    }
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index = control.hotLayoutData.index;
                    var delta = SnapIfNeeded(position) - GetPoint(index).position;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Point");
                        dragged = true;
                    }

                    controller.MoveSelectedPoints(delta);
                }
            };

            var m_MoveEdgeAction = new SliderAction(m_EdgeControl)
            {
                enable        = (guiState, action) => !IsAltDown(guiState) && guiState.isActionKeyDown,
                onSliderBegin = (guiState, control, position) =>
                {
                    dragged = false;
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index = control.hotLayoutData.index;
                    var delta = position - GetPoint(index).position;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Edge");
                        dragged = true;
                    }

                    controller.MoveEdge(index, delta);
                }
            };

            var cachedRightTangent = Vector3.zero;
            var cachedLeftTangent  = Vector3.zero;
            var cachedTangentMode  = TangentMode.Linear;

            var m_MoveLeftTangentAction = new SliderAction(m_LeftTangentControl)
            {
                enable        = (guiState, action) => !IsAltDown(guiState),
                onSliderBegin = (guiState, control, position) =>
                {
                    dragged = false;
                    var point = GetPoint(control.hotLayoutData.index);
                    cachedRightTangent = point.rightTangent;
                    cachedTangentMode  = point.tangentMode;
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index       = control.hotLayoutData.index;
                    var setToLinear = m_PointControl.distance(guiState, index) <= DefaultControl.kPickDistance;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Tangent");
                        dragged = true;
                    }

                    position = SnapIfNeeded(position);
                    controller.SetLeftTangent(index, position, setToLinear, guiState.isShiftDown, cachedRightTangent, cachedTangentMode);
                }
            };

            var m_MoveRightTangentAction = new SliderAction(m_RightTangentControl)
            {
                enable        = (guiState, action) => !IsAltDown(guiState),
                onSliderBegin = (guiState, control, position) =>
                {
                    dragged = false;
                    var point = GetPoint(control.hotLayoutData.index);
                    cachedLeftTangent = point.leftTangent;
                    cachedTangentMode = point.tangentMode;
                },
                onSliderChanged = (guiState, control, position) =>
                {
                    var index       = control.hotLayoutData.index;
                    var setToLinear = m_PointControl.distance(guiState, index) <= DefaultControl.kPickDistance;

                    if (!dragged)
                    {
                        controller.RegisterUndo("Move Tangent");
                        dragged = true;
                    }

                    position = SnapIfNeeded(position);
                    controller.SetRightTangent(index, position, setToLinear, guiState.isShiftDown, cachedLeftTangent, cachedTangentMode);
                }
            };

            m_GUISystem.AddControl(m_EdgeControl);
            m_GUISystem.AddControl(m_PointControl);
            m_GUISystem.AddControl(m_LeftTangentControl);
            m_GUISystem.AddControl(m_RightTangentControl);
            m_GUISystem.AddAction(m_CreatePointAction);
            m_GUISystem.AddAction(m_RemovePointAction1);
            m_GUISystem.AddAction(m_RemovePointAction2);
            m_GUISystem.AddAction(m_MovePointAction);
            m_GUISystem.AddAction(m_MoveEdgeAction);
            m_GUISystem.AddAction(m_MoveLeftTangentAction);
            m_GUISystem.AddAction(m_MoveRightTangentAction);
        }