Exemplo n.º 1
0
        public bool InitializeOauth()
        {
            var tokens = System.IO.File.ReadAllLines(@Server.MapPath("~/state.txt"));

            var refresh_token = "";
            var token_type    = "";
            var access_token  = "";

            if (tokens != null && tokens.Count() == 3)
            {
                string domain           = ConfigurationManager.AppSettings["Domain"];
                string oauth_path       = ConfigurationManager.AppSettings["OauthPath"];
                string client_id        = ConfigurationManager.AppSettings["ClientID"];
                var    client_secret    = ConfigurationManager.AppSettings["ClientSecret"];
                var    redirect_uri_str = ConfigurationManager.AppSettings["RedirectUri"];
                var    redirect_uri     = (Uri)null;
                if (string.IsNullOrEmpty(redirect_uri_str) == false)
                {
                    redirect_uri = new Uri(redirect_uri_str);
                }



                access_token    = tokens[0];
                refresh_token   = tokens[1];
                token_type      = tokens[2];
                _Config         = new CanvasConfig(domain, client_id, client_secret, redirect_uri);
                _Session        = new OAuth2Session(access_token, refresh_token, 1, token_type);
                _AuthRepository = new AuthRepository(_Config, new RequestService(new HttpRequestHandler()), new JsonConverter(), _Session);
                _Client         = new Client(_Config, _AuthRepository);
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        private void AddCanvas(GameObject uiGameobject)
        {
            CanvasConfig canvasConfig = uiGameobject.GetComponent <CanvasConfig>();

            if (canvasConfig == null)
            {
                return;
            }
            GameObject parentGameobject = m_allLayers[canvasConfig.CanvasName];
            int        sortingOrder     = parentGameobject.GetComponent <Canvas>().sortingOrder + (parentGameobject.transform.childCount - 1) * 100;
            Canvas     _canvas          = uiGameobject.GetComponent <Canvas>();

            if (_canvas == null)
            {
                _canvas = uiGameobject.AddComponent <Canvas>();
            }
            _canvas.overrideSorting          = true;
            _canvas.sortingOrder             = sortingOrder;
            _canvas.additionalShaderChannels = (AdditionalCanvasShaderChannels)(1 | 1 << 3 | 1 << 4);
            GraphicRaycaster _graphic = uiGameobject.GetComponent <GraphicRaycaster>();

            if (_graphic == null)
            {
                _graphic = uiGameobject.AddComponent <GraphicRaycaster>();
            }

            ChangeOrderRender(uiGameobject.transform, sortingOrder);
        }
Exemplo n.º 3
0
    public DumpWrapper Dump()
    {
        var ret = new DumpWrapper();

        ret.name           = Name;
        ret.minimalPLMDump = minimalPlayablePLM;
        ret.canvasDump     = CanvasConfig.StaticSerialize(canvasConfig);
        ret.matchRuleDumps = matchRules.SchemeStyleMap <RuleMatchBasic, string>((r) => {
            return(RuleMatchBasic.StaticSerialize(r));
        });
        ret.operationRuleDumps = operationRules.SchemeStyleMap <RuleOperation, string>((r) => {
            return(RuleOperation.StaticSerialize(r));
        });
        ret.extensionRuleDumps = extensionRules.SchemeStyleMap <RuleMatchExtension, string>((r) => {
            return(RuleMatchExtension.StaticSerialize(r));
        });
        ret.scoreRuleDumps = scoreRules.SchemeStyleMap <RuleScore, string>((r) => {
            return(RuleScore.StaticSerialize(r));
        });
        ret.refillRuleDump = RuleRefill.StaticSerialize(refillRule);
        ret.traitDumps     = slotConfig.Traits.SchemeStyleMap <SlotTrait, string>((t) => {
            return(SlotTrait.StaticSerialize(t));
        });
        ret.specialDumps = new List <string>();
        foreach (var kvp in slotConfig.Specials)
        {
            ret.specialDumps.Add(SlotSpecialty.StaticSerialize(kvp.Value));
        }
        return(ret);
    }
Exemplo n.º 4
0
    void Awake()
    {
        canvas = gameObject.GetComponent <CanvasController>();
        Rect camRect = new Rect(screenOffset.left,
                                screenOffset.bottom, Screen.width - screenOffset.horizontal, Screen.height - screenOffset.vertical);

        canvasConfig = canvas.config;



        if (texture == null)
        {
            canvasConfig.canvasSize = new IntVector2(1024, 768);
        }
        else
        {
            canvasConfig.canvasSize = new IntVector2(texture.width, texture.height);
        }

        CanvasCameraConfig camConfig = new CanvasCameraConfig();

        camConfig.camMinSize      = 10;
        camConfig.screenPixelRect = camRect;
        canvas.initialize(canvasConfig, camConfig, texture);

        testDrawing();
        oldWidth  = Screen.width;
        oldHeight = Screen.height;
    }
Exemplo n.º 5
0
        public async static Task DoStuff(string[] tokens, string domain, string client_id)
        {
            var access_token     = tokens[0];
            var refresh_token    = tokens[1];
            var token_type       = tokens[2];
            var client_secret    = ConfigurationManager.AppSettings["ClientSecret"];
            var redirect_uri_str = ConfigurationManager.AppSettings["RedirectUri"];
            var redirect_uri     = (Uri)null;

            if (string.IsNullOrEmpty(redirect_uri_str) == false)
            {
                redirect_uri = new Uri(redirect_uri_str);
            }

            var canvas_config = new CanvasConfig(domain, client_id, client_secret, redirect_uri);

            var oauth2session = new OAuth2Session("", refresh_token, 0, token_type);

            var client = new Client(canvas_config, new AuthRepository(canvas_config, new RequestService(new HttpRequestHandler()), new JsonConverter(), oauth2session));

            var self_account = await client.AccountsManager.GetSelf().ConfigureAwait(false);

            var courses = await client.CoursesManager.GetAll().ConfigureAwait(false);

            return;
        }
 public static void Initialize()
 {
     service = new RequestService(HANDLER);
     config  = new CanvasConfig(DOMAIN, "", "", REDIRECT);
     //auth = new AuthRepository(config, service, CONVERTER, new OAuth2Session("7~DHwAbT82Vj4LujkiK5f0sHxvIjuAJMC5lg23G54R0qARwckBzBOttvI3WjDxBQa9", "", -1, "Bearer"));
     auth   = new AuthRepository(config, service, CONVERTER, new OAuth2Session("13185~Et9gDdkpi4iYyFs3QlmoE9OKV7UaHgZ5w2VSLq6ZDG8zmKhX9jAsEho78DCsia7S", "", -1, "Bearer"));
     client = new Client(config, auth);
 }
 void createCanvas()
 {
     if (canvas.config == null)
         canvasConfig = new CanvasConfig();
     else
         canvasConfig = canvas.config;
     canvasConfig.layersShader = layerShader;
     canvasConfig.canvasSize = new IntVector2(props.width, props.height);
     canvasConfig.bufferSize = bufferSize;
 }
Exemplo n.º 8
0
        public async Task AuthenticateLive_InvalidAuthCode_Exception()
        {
            // Arrange
            IRequestHandler handler = new HttpRequestHandler();
            IRequestService service = new RequestService(handler);
            ICanvasConfig   config  = new CanvasConfig("domain", null, null, null);

            IAuthRepository authRepository = new AuthRepository(config, service, _converter);

            // Act
            OAuth2Session response = await authRepository.AuthenticateAsync("fakeAuthorizationCode");
        }
Exemplo n.º 9
0
 void createCanvas()
 {
     if (canvas.config == null)
     {
         canvasConfig = new CanvasConfig();
     }
     else
     {
         canvasConfig = canvas.config;
     }
     canvasConfig.layersShader = layerShader;
     canvasConfig.canvasSize   = new IntVector2(props.width, props.height);
     canvasConfig.bufferSize   = bufferSize;
 }
Exemplo n.º 10
0
        public static void DoSomeOauth2()
        {
            var request_factory = new OAuth2.Infrastructure.RequestFactory();

            request_factory.CreateRequest();
            request_factory.CreateClient();



            var config = new OAuth2.Configuration.RuntimeClientConfiguration();

            config.ClientId     = CLIENT_ID;
            config.ClientSecret = CLIENT_SECRET;
            config.RedirectUri  = REDIRECT.ToString();



            var oauthin = new OAuth2.Client.Impl.GoogleClient(request_factory, config);

            oauthin.GetCurrentToken();



            service        = new RequestService(HANDLER);
            Program.config = new CanvasConfig(DOMAIN, CLIENT_ID, CLIENT_SECRET, REDIRECT);

            var request = new ApiRequest(new Uri("https://instantadmin.instructure.com/login/oauth2/auth"))
                          .Param("client_id", CLIENT_ID)
                          .Param("response_type", "code")
                          .Param("redirect_uri", REDIRECT.ToString())
            ;

            //var basic = await HANDLER.ExecuteAsync<OAuth2Session>(request).ConfigureAwait(false);

            //session = new OAuth2Session(access_token, refresh_token, expires_in, token_type);
            auth = new AuthRepository(Program.config, service, CONVERTER);

            client = new Client(Program.config, auth);

            //var courses = await client.CoursesManager.GetAll();

            //foreach(var course in courses)
            //{
            //    Console.WriteLine(course.ToString());
            //}


            //return;
        }
Exemplo n.º 11
0
    public void initialize(CanvasConfig config, CanvasCameraConfig canvasCameraConfig, Texture2D texture = null)
    {
        canvasBuffer   = new CanvasBuffer(config.canvasSize, config.bufferSize);
        this.config    = config;
        canvasCamera   = new CanvasCamera(canvasCameraConfig, config.canvasSize, gameObject);
        backLayer      = new CanvasLayer(config.canvasSize, 100, config.layersShader, canvasCamera);
        frontLayer     = new CanvasLayer(config.canvasSize, 20, config.layersShader, canvasCamera);
        radialLayer    = new CanvasRadialLayer(config.canvasSize, 25, config.radialFillShader, config.radialFillTexture, canvasCamera);
        canvasCollider = CanvasCollider.createCanvasCollider(config.canvasSize, 10, gameObject, canvasCamera);

        setNewPicture(texture);
        initialized = true;

        handleInnerEvents();
    }
Exemplo n.º 12
0
 public LineStrategyImpl(CanvasTool tool, InterpoalateStrategyInterface interpolateStrategy)
 {
     this.tool = tool;
     this.interpolateStrategy  = interpolateStrategy  ;
     canvasConfig = PropertiesSingleton.instance.canvasWorkspaceController.canvas.config;
     canvas = PropertiesSingleton.instance.canvasWorkspaceController.canvas;
     canvasCam = canvas.canvasCamera.camera;
     switch (tool.meshType){
     case LineMeshType.SQUARE_SIDES:
         lineRendererMeshType = new SquareSideLineMeshTypeImpl();
         break;
     case LineMeshType.TRIANGLE_SIDES:
         lineRendererMeshType = new TriangleSideLineMeshTypeImpl();
         break;
     }
 }
Exemplo n.º 13
0
    public LineStrategyImpl(CanvasTool tool, InterpoalateStrategyInterface interpolateStrategy)
    {
        this.tool = tool;
        this.interpolateStrategy = interpolateStrategy;
        canvasConfig             = PropertiesSingleton.instance.canvasWorkspaceController.canvas.config;
        canvas    = PropertiesSingleton.instance.canvasWorkspaceController.canvas;
        canvasCam = canvas.canvasCamera.camera;
        switch (tool.meshType)
        {
        case LineMeshType.SQUARE_SIDES:
            lineRendererMeshType = new SquareSideLineMeshTypeImpl();
            break;

        case LineMeshType.TRIANGLE_SIDES:
            lineRendererMeshType = new TriangleSideLineMeshTypeImpl();
            break;
        }
    }
Exemplo n.º 14
0
        public CanvasInitializer(CanvasConfig config, ISelectedCharacterData selectedCharacterData)
        {
            // Initialize Hud GameObject
            GameObject canvasGameObject = UnityEngine.Object.FindObjectOfType <CanvasView>()?.gameObject;

            if (canvasGameObject == null)
            {
                canvasGameObject = UnityEngine.Object.Instantiate(config.CanvasPrefab);
            }

            // Initialize models and views from factories
            var hudCharacterView = new ViewFactory.HudCharacterViewFactory().View;
            var hudStatViews     = new ViewFactory.HudStatViewFactory().Views;
            // Initialize controllers from factory
            var hudControllers =
                new ControllerFactory.HudCharacterControllerFactory(selectedCharacterData, hudCharacterView, hudStatViews)
                .Controllers;
        }
Exemplo n.º 15
0
	private static bool CheckCanvas(CanvasConfig canvas, out string reason)
	{
		reason = "";
		var c1 = canvas as CanvasConfig2DR;
		if (null != c1)
		{
			if (c1.mapWidth <= 2
			    || c1.mapWidth >= 30
			    || c1.mapHeight <= 2
			    || c1.mapHeight >= 30)
			{
				reason = "Illegal Canvas Config!";
				return false;
			}
			
			return true;
		}
		throw new NotImplementedException();
	}
Exemplo n.º 16
0
        /// <summary>
        /// 隐藏ui
        /// </summary>
        /// <param name="type"></param>
        public void Hide(string type)
        {
            UI ui = Get(type);

            if (ui == null)
            {
                return;
            }
            uis[type].UiComponent.Hide();
            SetViewParent(uis[type], UILayerType.Hide);
            string       canvasName   = "";
            CanvasConfig canvasConfig = ui.GameObject.GetComponent <CanvasConfig>();

            if (canvasConfig != null)
            {
                canvasName = canvasConfig.CanvasName;
            }
            ChangeOrderOnRemove(canvasName);
            BgMaskmanager.UpdateUI();
        }
Exemplo n.º 17
0
    private static bool CheckCanvas(CanvasConfig canvas, out string reason)
    {
        reason = "";
        var c1 = canvas as CanvasConfig2DR;

        if (null != c1)
        {
            if (c1.mapWidth <= 2 ||
                c1.mapWidth >= 30 ||
                c1.mapHeight <= 2 ||
                c1.mapHeight >= 30)
            {
                reason = "Illegal Canvas Config!";
                return(false);
            }

            return(true);
        }
        throw new NotImplementedException();
    }
Exemplo n.º 18
0
 private void InitFrom(DumpWrapper dump)
 {
     Name = dump.name;
     minimalPlayablePLM = dump.minimalPLMDump;
     canvasConfig       = CanvasConfig.StaticDeserialize(dump.canvasDump);
     slotConfig         = new SlotConfig();
     slotConfig.Init(dump.traitDumps, dump.specialDumps);
     matchRules = dump.matchRuleDumps.SchemeStyleMap <string, RuleMatchBasic>((str) => {
         return(RuleMatchBasic.StaticDeserialize(str));
     });
     operationRules = dump.operationRuleDumps.SchemeStyleMap <string, RuleOperation>((str) => {
         return(RuleOperation.StaticDeserialize(str));
     });
     extensionRules = dump.extensionRuleDumps.SchemeStyleMap <string, RuleMatchExtension>((str) => {
         return(RuleMatchExtension.StaticDeserialize(str));
     });
     scoreRules = dump.scoreRuleDumps.SchemeStyleMap <string, RuleScore>((str) => {
         return(RuleScore.StaticDeserialize(str));
     });
     refillRule = RuleRefill.StaticDeserialize(dump.refillRuleDump);
 }
Exemplo n.º 19
0
    void Awake()
    {
        canvas = gameObject.GetComponent<CanvasController>();
        Rect camRect = new Rect(screenOffset.left,
                                screenOffset.bottom, Screen.width - screenOffset.horizontal, Screen.height - screenOffset.vertical);

        canvasConfig = canvas.config;

        if (texture == null)
            canvasConfig.canvasSize = new IntVector2(1024,768);
        else
            canvasConfig.canvasSize = new IntVector2(texture.width, texture.height);

        CanvasCameraConfig camConfig = new CanvasCameraConfig();
        camConfig.camMinSize = 10;
        camConfig.screenPixelRect = camRect;
        canvas.initialize(canvasConfig, camConfig, texture);

        testDrawing();
        oldWidth = Screen.width;
        oldHeight = Screen.height;
    }
Exemplo n.º 20
0
        public void Remove(string type)
        {
            UI ui;

            if (!uis.TryGetValue(type, out ui))
            {
                return;
            }
            //UiTypes[type].Remove(type);
            uiFactory.Remove(type);
            uis.Remove(type);
            string canvasName = "";

            if (ui.GameObject != null)
            {
                CanvasConfig canvasConfig = ui.GameObject.GetComponent <CanvasConfig>();
                if (canvasConfig != null)
                {
                    canvasName = canvasConfig.CanvasName;
                }
            }
            ui.Dispose();
            ChangeOrderOnRemove(canvasName);
        }
Exemplo n.º 21
0
	public static string StaticSerialize(CanvasConfig c)
	{
		return JsonHelper.Serialize(new Tuple<string, string>(c.SerializeUID, c.Serialize()));
	}
Exemplo n.º 22
0
 public static string StaticSerialize(CanvasConfig c)
 {
     return(JsonHelper.Serialize(new Tuple <string, string>(c.SerializeUID, c.Serialize())));
 }
Exemplo n.º 23
0
    public void initialize(CanvasConfig config, CanvasCameraConfig canvasCameraConfig, Texture2D texture=null)
    {
        canvasBuffer = new CanvasBuffer(config.canvasSize, config.bufferSize);
        this.config = config;
        canvasCamera = new CanvasCamera(canvasCameraConfig, config.canvasSize, gameObject);
        backLayer = new CanvasLayer(config.canvasSize, 100, config.layersShader, canvasCamera);
        frontLayer = new CanvasLayer(config.canvasSize, 20, config.layersShader, canvasCamera);
        radialLayer = new CanvasRadialLayer(config.canvasSize, 25, config.radialFillShader, config.radialFillTexture, canvasCamera);
        canvasCollider = CanvasCollider.createCanvasCollider (config.canvasSize, 10, gameObject, canvasCamera);

        setNewPicture(texture);
        initialized = true;

        handleInnerEvents();
    }
 public ToolBucketStrategyImpl()
 {
     canvas       = PropertiesSingleton.instance.canvasWorkspaceController.canvas;
     canvasConfig = canvas.config;
     props        = PropertiesSingleton.instance;
 }
Exemplo n.º 25
0
 public ToolBucketStrategyImpl()
 {
     canvas = PropertiesSingleton.instance.canvasWorkspaceController.canvas;
     canvasConfig = canvas.config;
     props = PropertiesSingleton.instance;
 }