Ejemplo n.º 1
0
    void Update()
    {
        accelerrateTime += Time.deltaTime;

        //----
        if (accelerrateTime > timeInterval)
        {
            bossMoveSpeed += accelerrate;
            if (bossMoveSpeed > bossSpeedLimit)
            {
                bossMoveSpeed = bossSpeedLimit;
            }
            accelerrateTime -= timeInterval;
        }
        //-----
        gameTime += Time.deltaTime;
        if (gameTime < DelayEnterTime || isFinishGame)
        {
            return;
        }
        var currentPlayer = players[CurrentBallIndex];
        var cheatPoint    = ballPoint[CurrentBallIndex].position;

        ballSprite.sortingOrder = currentPlayer.As <SpriteRenderer>().sortingOrder + 1;

        ball.transform.position = Vector3.MoveTowards(ball.transform.position, cheatPoint, Time.deltaTime * ballMoveSpeed);

        patrolTime += Time.deltaTime;

        var bossPos = boss.transform.position;
        var ballPos = ball.transform.position;

        holdTime += Time.deltaTime;

        if (holdTime > 2 && isHighScore == false)
        {
            if (currentPlayer.animator.GetBool("isHurry"))
            {
                Score            += 5;
                fadeOutLabel.text = "+5";
                currentPlayer.animator.SetBool("isHurry", false);
                AudioManager.Inst.PlayLaugh3();
            }
            else
            {
                Score            += 3;
                fadeOutLabel.text = "+3";

                var rand = Random.Range(0, 2);
                if (rand == 0)
                {
                    AudioManager.Inst.PlayLaugh1();
                }
                else
                {
                    AudioManager.Inst.PlayLaugh2();
                }
            }

            holdTime = 0;
            var position = currentPlayer.transform.position;
            var uiPos    = mainCamera.WorldToScreenPoint(position);
            uiPos.z = 1;
            fadeOutLabel.transform.position = uiPos;
            var locaPosY = fadeOutLabel.transform.localPosition.y;
            fadeOutLabel.color = fadeOutLabel.color.SetAlpha(1);
            fadeOutLabel.transform.DOMoveY(uiPos.y + 100, 0.8f);
            fadeOutLabel.DOFade(0, 0.8f);
            isHighScore = true;
        }
        else if (holdTime > 1 && isHighScore == true)
        {
            Score   += 2;
            holdTime = 0;
            var position = currentPlayer.transform.position;
            var uiPos    = mainCamera.WorldToScreenPoint(position);
            uiPos.z = 1;
            fadeOutLabel.transform.position = uiPos;
            fadeOutLabel.color = fadeOutLabel.color.SetAlpha(1);
            fadeOutLabel.transform.DOMoveY(uiPos.y + 100, 0.8f);
            fadeOutLabel.text = "+2";
            fadeOutLabel.DOFade(0, 0.8f);
        }

        if (patrolTime > patrolLimitTime)
        {
            boss.isAngry = true;
            AudioManager.Inst.PlayAngry();
            boss.transform.position =
                Vector3.Lerp(bossPos, ballPos, Time.deltaTime * bossMoveSpeed);
            boss.SetTarget(ballPos);
            bool isFilp = bossPos.x < ballPos.x;
            boss.isFilpX = isFilp;
        }
        else
        {
            boss.isAngry = false;
//			XLogger.Log( currentPlayer.neighborPoint[ bossMoveableIndex ].name, currentPlayer.neighborPoint[ bossMoveableIndex ].gameObject );
            var movePoint = currentPlayer.neighborPoint[bossMoveableIndex].position;
            boss.transform.position =
                Vector3.Lerp(bossPos, movePoint, Time.deltaTime * bossMoveSpeed);
            boss.SetTarget(movePoint);
            var manguite = (bossPos - movePoint).magnitude;
//			XLogger.Log( manguite );

            if (manguite < 1f)
            {
                bossMoveableIndex = Random.Range(0, 3);
            }


            bool isFilp = bossPos.x < movePoint.x;
            boss.isFilpX = isFilp;
        }
        if (boss.isInSector(ball.transform.position))
        {
            XLogger.LogError("FinishGame");
            isFinishGame = true;
            boss.SetCatch();
            bool isFilp = bossPos.x < ballPos.x;
            boss.isFilpX = isFilp;
            AudioManager.Inst.PlayCatch();

            AudioManager.Inst.StopPlaying();
            AudioManager.Inst.PlayFail();
            AudioManager.Inst.PlayTeacherLaugh();

            StopAllCoroutines();
            ball.transform.position = boss.catchPoint(isFilp);
            ballSprite.sortingOrder = 1000;
            for (int i = 0; i < players.Length; i++)
            {
                var c = players[i];
                if (c == lastPlayer)
                {
                    c.Cry();
                }
                else
                {
                    c.Win();
                }
            }
            lastPlayer.Cry();
            Invoke("DelayFinish", 4);
        }

//		var buttonUp = Input.GetMouseButtonUp( 0 );
//		if( buttonUp )
//		{
//			var mousePos = Input.mousePosition;
//			var mainCamera = Camera.main;
//			for( int i = 0; i < players.Length; i++ )
//			{
//				var rect = players[ i ].As<SpriteRenderer>();
//				var spriteRect = new Rect(players[i].transform.position, rect.size);
////				if( rect.bounds.Contains( mousePos ) )
////				{
////					XLogger.Log( i );
////					FireBall( i );
////					break;
////				}
//////				if( RectTransformUtility.RectangleContainsScreenPoint( rect, mousePos ) )
//////				{
//////					XLogger.Log( i );
//////					FireBall( i );
//////					break;
//////
//////				}
//////				if( rect.rect.Contains( mousePos ) )
//////				{
//////					XLogger.Log( i.ToString() );
//////					FireBall( i );
//////					break;
//////
//////				}
//
//			}
//		}
    }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="command"></param>
        /// <param name="commandOutput"></param>
        /// <param name="commandParams"></param>
        /// <returns></returns>
        public static bool ExecuteCommand(string command, string workingDir, string commandArguments, out string commandOutput) //, params string[] commandParams
        {
            commandOutput = "";

            try
            {
                int exitCode;
                ProcessStartInfo processInfo;
                Process          process;

                processInfo = new ProcessStartInfo("cmd", String.Concat("/c ", command));

                /*
                 * //another way
                 * processInfo = new ProcessStartInfo();
                 * processInfo.FileName = command;
                 * //processInfo.WorkingDirectory = Path.GetDirectoryName(command);
                 */

                //StringBuilder finalArgs = new StringBuilder();
                //if (commandParams != null && commandParams.Length > 0)
                //    processInfo.Arguments = String.Join(" ", commandParams);
                //processInfo.Arguments = commandArguments;
                processInfo.WorkingDirectory = workingDir;
                //processInfo.CreateNoWindow = true;        //using this will break the GPG command!!
                processInfo.UseShellExecute = false;
                //processInfo.WindowStyle = ProcessWindowStyle.Hidden;


                // *** Redirect the output ***
                processInfo.RedirectStandardError  = true;
                processInfo.RedirectStandardOutput = true;

                StringBuilder sb = new StringBuilder();
                sb.AppendLine("before StartInfo!!");
                sb.AppendLine("processInfo.WorkingDirectory " + processInfo.WorkingDirectory);
                sb.AppendLine("processInfo.FileName " + processInfo.FileName);
                sb.AppendLine("processInfo.Arguments " + processInfo.Arguments);
                //XLogger.Info(sb.ToString());
                process = Process.Start(processInfo);
                process.WaitForExit();

                // *** Read the streams ***
                //string output = process.StandardOutput.ReadToEnd();
                //string error = process.StandardError.ReadToEnd();

                exitCode = process.ExitCode;

                /*
                 * Console.WriteLine("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
                 * Console.WriteLine("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
                 * Console.WriteLine("ExitCode: " + exitCode.ToString(), "ExecuteCommand");
                 */

                commandOutput = String.Concat(process.StandardOutput.ReadToEnd(), Environment.NewLine, process.StandardError.ReadToEnd());
                process.Close();

                //not always valid
                //if (!String.IsNullOrWhiteSpace(error))
                //    throw new ApplicationException("Commnad returned an error:  " + error);

                return(true);
            }
            catch (Exception x)
            {
                x.Data.Add("command", command);
                XLogger.Error(x);

                return(false);
            }
        }
Ejemplo n.º 3
0
 public virtual void OnCopy()
 {
     XLogger.Log("Copy");
 }
Ejemplo n.º 4
0
 public virtual void OnDelete()
 {
     XLogger.Log("Delete");
 }
        void MatchPara()
        {
            var functions = command.RegexCutString("(", ")");

            for (int i = 0; i < functions.Length; i++)
            {
                var objs = paserPara(functions[i]);
            }
            List <object[]> paras = new List <object[]>();

            var clear = command.RegexCutStringReverse("(", ")");

            string[] commandPara = clear.Split('.');
            if (commandPara.Length > 0 && type == null && currValue == null)
            {
                type = XReflectionUtils.TryGetClass(commandPara[0]);
            }

            currValue = draggedObject;

            int allLenght = commandPara.Length;
            int funCount  = functions.Length;

            int startIndex = 1;

            if (currValue != null)
            {
                startIndex = 0;
            }
            for (int i = startIndex; i < startIndex + funCount; i++)
            {
                //  TODO loop in funCount
                if (currValue == null)
                {
                    currValue = type.TryInvokeGlobalMethod(commandPara[i]);
                }
                else
                {
                    currValue = currValue.GetType().TryInvokeMethod(currValue, commandPara[i]);
                }
            }
            int fieldCount = commandPara.Length - funCount;

            int fieldIndex = 1;

            if (currValue != null)
            {
                fieldIndex = 0;
            }
            for (int pos = fieldIndex; pos < fieldCount; pos++)
            {
                //  TODO loop in Length
                if (currValue == null)
                {
                    currValue = type.TrySearchGlobalMemberValue(commandPara[pos + startIndex]);
                }
                else
                {
                    currValue = currValue.TryGetFieldValue(commandPara[pos + startIndex]);
                }
            }
            XLogger.Log("currValue is : " + currValue.ToString());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// The main routine of the handler. Creates a request message and sends it to the server. 
        /// </summary>
        /// <param name="context">The current http context<guer/param>
        public void ProcessRequest(HttpContext context)
        {
            string requestMsg;
            bool ok = false;
            string responseMsg;
            HttpRequest request = context.Request;
            log = new XWindowsLogger();
            config = new XConfig(request, log);
            srv = new XServerConnection(log, config);

            if (buildRequestMessage(out requestMsg, request))
            {
                if (srv.connect())
                {
                    if (srv.sendMessage(requestMsg))
                    {
                        if (srv.receiveMessage(out responseMsg))
                        {
                            if (processResponse(ref responseMsg, context))
                            {
                                context.Response.Write(responseMsg);
                                ok = true;
                            }
                        }
                    }
                }
            }

            if (!ok)
            {
                context.Response.Write(ERRORMSG);
            }
        }
Ejemplo n.º 7
0
 static public void LogErrorChannel(UnityEngine.Object context, string channel, string message, params object[] paramsObject)
 {
     XLogger.Log(context, LogLevel.Error, channel, message, paramsObject);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="log">A logger to write debug and error messages</param>     
 /// <param name="config">A configuration</param>
 public XServerConnection(XLogger log, XConfig config)
 {
     this.config = config;
     this.log = log;
 }
Ejemplo n.º 9
0
 static public void LogError(string message, params object[] paramsObject)
 {
     XLogger.Log(null, LogLevel.Error, "", message, paramsObject);
 }
Ejemplo n.º 10
0
 static public void Log(UnityEngine.Object context, string message, params object[] paramsObject)
 {
     XLogger.Log(context, LogLevel.Message, "", message, paramsObject);
 }
Ejemplo n.º 11
0
 static public void LogWarning(string message, params object[] paramsObject)
 {
     XLogger.Log(null, LogLevel.Warning, "", message, paramsObject);
 }
 // Awake is called when the script instance is being loaded.
 void Awake()
 {
     m_renderer = this.GetComponent <MeshRenderer>();
     XLogger.LogValidObject(m_renderer, "DbgSys:GetComponent<MeshRenderer>", gameObject);
 }
Ejemplo n.º 13
0
 void Awake()
 {
     XLogger.LogValidObject(m_pivot == null, LibConstants.ErrorMsg.GetMsgNotBoundComponent("Pivot"), gameObject);
     XLogger.LogValidObject(m_targetUser == null, LibConstants.ErrorMsg.GetMsgNotBoundComponent("Target"), gameObject);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// <see cref="https://wurstkoffer.wordpress.com/2013/05/18/c-printing-to-word-programmatically-in-3-way/"/>
        /// </summary>
        /// <param name="documents"></param>
        public static void PrintAll(List <string> documents)
        {
            try
            {
                var paperSize = PrinterUtils.PaperSizes["A4"];
                var filename  = string.Empty;
                for (int i = 0; i < documents.Count; i++)
                {
                    filename = documents[i];
                    CallUpdateStatus($"Sending document {i + 1} of {documents.Count} to the printer");

                    bool    isLandscape = false;
                    Margins margins     = null;
                    var     isEnvelop   = REF.Constants.envelopIDs.Any(t => filename.ContainsString(t));
                    var     isPostcard  = REF.Constants.postcardIDs.Any(t => filename.ContainsString(t));

                    if (isEnvelop)
                    {
                        paperSize = !Config.UI.EnvelopSize.Equals("CUSTOM") ? PrinterUtils.PaperSizes[Config.UI.EnvelopSize] :
                                    new System.Drawing.Printing.PaperSize("CUSTOM", Config.UI.EnvelopWidth, Config.UI.EnvelopHeight);
                        margins = new Margins(Config.UI.EnvelopMarginLeft, Config.UI.EnvelopMarginRight, Config.UI.EnvelopMarginTop, Config.UI.EnvelopMarginBottom);
                    }

                    /*
                     * else if (isPostcard)
                     * {
                     *  paperSize = !Config.UI.PostcardSize.Equals("CUSTOM") ? PrinterUtils.PaperSizes[Config.UI.EnvelopSize] :
                     *     new System.Drawing.Printing.PaperSize("CUSTOM", Config.UI.EnvelopWidth, Config.UI.EnvelopHeight);
                     *  margins = new Margins(Config.UI.PostcardMarginLeft, Config.UI.PostcardMarginRight, Config.UI.PostcardMarginTop, Config.UI.PostcardMarginBottom);
                     *  isLandscape = true;
                     * }
                     */

                    switch (Config.UI.PrintMethod)
                    {
                    case REF.PrintMethod.PrintWithNoDialog:
                        PrinterUtils.PrintWithNoDialog(filename, Config.UI.Printer);
                        break;

                    case REF.PrintMethod.PrintWithInterop:
                        PrinterUtils.PrintWithInterop2(filename, Config.UI.Printer);
                        break;

                    case REF.PrintMethod.PrintWithAspose:
                        PrinterUtils.PrintWithAspose(filename, Config.UI.Printer);
                        break;

                    case REF.PrintMethod.PrintWithGnostice:
                        PrinterUtils.PrintWithGnostice(filename, Config.UI.Printer);
                        break;

                    case REF.PrintMethod.PrintWithSpire:
                        PrinterUtils.PrintWithSpire(filename, Config.UI.Printer, isLandscape, paperSize, margins);
                        break;

                    default:
                        break;
                    }

                    Thread.Sleep(Config.UI.PrintBuffer * 1000);
                }

                CallUpdateStatus("Operation passed and all documents have been sent to the printer");
            }
            catch (Exception x)
            {
                if (x is ApplicationException)
                {
                    CallMarkCompleted(x.Message);
                }
                else
                {
                    CallMarkCompleted("Something went wrong while printing. Please check the logs.txt file.");
                }

                XLogger.Error(x);
            }
        }
Ejemplo n.º 15
0
 static public void LogErrorChannel(string channel, string message, params object[] paramsObject)
 {
     XLogger.Log(null, LogLevel.Error, channel, message, paramsObject);
 }
    public override void OnXGUI()
    {
        //TODO List
        if (Selection.objects != null && Selection.objects.Length > 0)
        {
            selectedObject = Selection.objects[0];
        }

        if (CreateSpaceButton("Packing Selected Objects"))
        {
            Object[] objects = Selection.objects;

            string path = EditorUtility.SaveFilePanel("Create A Bundle", AssetDatabase.GetAssetPath(objects[0]), "newbundle.assetbundle", "assetbundle");
            if (path == "")
            {
                return;
            }


            CreateXMLWithDependencies(objects, path);

            BuildPipeline.BuildAssetBundle(
                null, objects,
                path,
                BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.UncompressedAssetBundle
                | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.Android);
        }

        if (CreateSpaceButton("GetObject"))
        {
            string path = EditorUtility.OpenFilePanel("Open A Bundle", Application.streamingAssetsPath, "");
            if (path == "")
            {
                return;
            }
            _bundlepath   = "file://" + path;
            LoadingConfig = true;
            asset         = null;
//			AssetDatabase.Refresh();
            if (currBundle != null)
            {
                currBundle.Unload(true);
            }
        }

        if (CreateSpaceButton("Clean Cache"))
        {
            currentBundleObjects = null;
            Caching.CleanCache();
        }

        if (LoadingConfig)
        {
            XLogger.Log("start loading");
            if (null == asset)
            {
                asset = new WWW(_bundlepath);
            }
            LoadingConfig = false;
        }
//		Logger.Log(string.Format("asset == null is {0}" , asset == null));
        if (asset != null)
        {
//			Logger.Log("asset.isDone is " + asset.isDone);
//			if(asset.isDone){

            XLogger.Log("end loading");
            currBundle = asset.assetBundle;
            if (currBundle == null)
            {
                CreateNotification("Selected the asset bundle 's format is error.");
                LoadingConfig = false;
                asset         = null;
                return;
            }
                        #if UNITY_5_0
            currentBundleObjects = currBundle.LoadAllAssets();
                        #endif
                        #if UNITY_4_6
            currentBundleObjects = currBundle.LoadAll();
                        #endif
            LoadingConfig = false;
            asset         = null;
//			}
        }



        if (null != currentBundleObjects)
        {
            for (int pos = 0; pos < currentBundleObjects.Length; pos++)
            {
                CreateObjectField(currentBundleObjects[pos].GetType().ToString(), currentBundleObjects[pos]);
            }
        }

        if (CreateSpaceButton("Add A AssetBundle"))
        {
            allAssets.Add(new AssetBundleModel());
        }
        if (CreateSpaceButton("Clean All AssetBundle"))
        {
            allAssets.Clear();
        }
        if (CreateSpaceButton("Collect") && allAssets.Count > 0)
        {
            List <AssetBundleModel> AllChilds = new List <AssetBundleModel>();
            sortAssets.Clear();

            BundlePath = EditorUtility.SaveFolderPanel("Save Bundles", Application.streamingAssetsPath, "");
            if (BundlePath == null)
            {
                return;
            }
            BundlePath += "/";
            XmlDocument xmlDoc = new XmlDocument();
            XmlElement  root   = xmlDoc.CreateElement("root");
            for (int pos = 0; pos < allAssets.Count; pos++)
            {
                if (allAssets[pos].ParentName.Equals(""))
                {
                    sortAssets.Add(allAssets[pos].ModelName, allAssets[pos]);
                    XmlElement child = xmlDoc.CreateElement(allAssets[pos].ModelName);
                    root.AppendChild(child);
                }
                else
                {
                    AllChilds.Add(allAssets[pos]);
                }
//				allAssets.Remove(allAssets[pos]);
            }
            for (int pos = 0; pos < AllChilds.Count; pos++)
            {
                sortAssets[AllChilds[pos].ParentName].Childs.Add(AllChilds[pos]);
                XmlElement child = xmlDoc.CreateElement(AllChilds[pos].ModelName);
                root.SelectSingleNode(AllChilds[pos].ParentName).AppendChild(child);
//				allAssets.Remove(allAssets[pos]);
            }
            xmlDoc.AppendChild(root);
            xmlDoc.Save(BundlePath + "bundle.xml");
            foreach (var bundle in sortAssets)
            {
                bundle.Value.PackingSelf();
            }
//			allAssets.Clear();
            AssetDatabase.Refresh();
            CreateNotification("Create asset bundle success!");
        }

        for (int pos = 0; pos < allAssets.Count; pos++)
        {
            AssetBundleModel Item = allAssets[pos];
            BeginHorizontal();
            Item.ModelName  = CreateStringField("Name", allAssets[pos].ModelName);
            Item.ParentName = CreateStringField("Dependencies", allAssets[pos].ParentName);
            if (CreateSpaceButton("Add Asset") && null != selectedObject)
            {
                Item.Assets.AddRange(Selection.objects);
            }
            if (CreateSpaceButton("Remove Bundle"))
            {
                allAssets.RemoveAt(pos);
            }
            EndHorizontal();
            CreateSpaceBox();

            for (int idx = 0; idx < Item.Assets.Count; idx++)
            {
                BeginHorizontal();
                CreateObjectField("child_" + idx, Item.Assets[idx]);
                if (CreateSpaceButton("Remove"))
                {
                    Item.Assets.RemoveAt(idx);
                }
                EndHorizontal();
            }

            CreateSpaceBox();
        }
    }
Ejemplo n.º 17
0
        private void DoCustom()
        {
            try
            {
                if (string.IsNullOrEmpty(myUI.ContactsFile))
                {
                    MessageBox.Show("Please select an input csv file first!");
                    return;
                }
                if (string.IsNullOrEmpty(myUI.OutputFolder))
                {
                    MessageBox.Show("Please set the output folder first!");
                    return;
                }

                Engine.Config = myUI.BuildConfig();
                Engine.ReadContacts();
                if (Engine.Variables.Contacts.Count == 0)
                {
                    MessageBox.Show("The selected input csv has no contacts, or it is currently open in Excel, or it doesn't follow the correct format. Please check.");
                    return;
                }

                Custom sc = new Custom();
                sc.ShowDialog();
                if (sc.DialogResult == DialogResult.OK)
                {
                    var contacts = new List <Contact>();
                    if (sc.SelectedContact == REF.Constants.AllContacts)
                    {
                        contacts.AddRange(Engine.Variables.Contacts);
                    }
                    else
                    {
                        var matchingContact = Engine.Variables.Contacts.FirstOrDefault(c => c.ContactName.MatchesString(sc.SelectedContact));
                        if (matchingContact == null)
                        {
                            MessageBox.Show("Something went wrong.");
                            return;
                        }
                        else
                        {
                            contacts.Add(matchingContact);
                        }
                    }

                    var templateFile = Path.Combine(REF.templatesPath, $"{sc.SelectedTemplate}.docx");
                    Engine.DoCustom(Engine.Config.UI.OutputFolder, contacts, sc.GeneratePerContact, templateFile);

                    ////--> use DoCustom here
                    //foreach (var contact in contacts)
                    //    Engine.ExecutionStatus.Result = Engine.GenerateContact(Engine.Config.UI.OutputFolder, contact, sc.GeneratePerContact, templateFile);
                }
            }
            catch (Exception x)
            {
                Engine.ExecutionStatus.Result = Engine.ExecutionResult.ErrorOccured;
                if (x is ApplicationException)
                {
                    Engine.ExecutionStatus.Message = x.Message;
                }
                else
                {
                    Engine.ExecutionStatus.Message = MSG.UnknownError;
                }

                XLogger.Error(x);
            }
        }
Ejemplo n.º 18
0
    public override void OnCreate()
    {
        base.OnCreate();

        XLogger.LogFormat(Fsm, "OnCreate at {0}====={1}", Fsm, Owner.Name);
    }
Ejemplo n.º 19
0
        private bool LoadSettings(out string exeVersion)
        {
            int tempInt = 0;

            exeVersion = "";
            try
            {
                List <String> missingKeys = new List <string>();
                Configuration config      = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);
                exeVersion = ConfigurationManager.AppSettings[ConfigKeys.Config.ExeVersion];

                //------------------------------------------------------------------------------------------
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.ContactsFile))
                {
                    myUI.ContactsFile = config.AppSettings.Settings[ConfigKeys.UI.ContactsFile].Value;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.ContactsFile);
                }
                //------------------------------------------------------------------------------------------
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.OutputFolder))
                {
                    myUI.OutputFolder = config.AppSettings.Settings[ConfigKeys.UI.OutputFolder].Value;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.OutputFolder);
                }
                //------------------------------------------------------------------------------------------
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.GeneratePerContact))
                {
                    myUI.GeneratePerContact = (REF.Scope)Enum.Parse(typeof(REF.Scope), config.AppSettings.Settings[ConfigKeys.UI.GeneratePerContact].Value);
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.GeneratePerContact);
                }
                //------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopSize))
                {
                    myUI.EnvelopSize = config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopSize].Value;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopSize);
                }
                //------------------------------------------------------------------------------------------
                int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopWidth].Value, out tempInt);
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopWidth))
                {
                    myUI.EnvelopWidth = tempInt;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopWidth);
                }
                //------------------------------------------------------------------------------------------
                int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopHeight].Value, out tempInt);
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopHeight))
                {
                    myUI.EnvelopHeight = tempInt;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopHeight);
                }
                //------------------------------------------------------------------------------------------
                int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginLeft].Value, out tempInt);
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginLeft))
                {
                    myUI.EnvelopMarginLeft = tempInt;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopMarginLeft);
                }
                //------------------------------------------------------------------------------------------
                int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginRight].Value, out tempInt);
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginRight))
                {
                    myUI.EnvelopMarginRight = tempInt;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopMarginRight);
                }
                //------------------------------------------------------------------------------------------
                int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginTop].Value, out tempInt);
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginTop))
                {
                    myUI.EnvelopMarginTop = tempInt;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopMarginTop);
                }
                //------------------------------------------------------------------------------------------
                int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginBottom].Value, out tempInt);
                if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginBottom))
                {
                    myUI.EnvelopMarginBottom = tempInt;
                }
                else
                {
                    missingKeys.Add(ConfigKeys.UI.Print.EnvelopMarginBottom);
                }
                //------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------

                /*
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardSize))
                 *  myUI.PostcardSize = config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardSize].Value;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardSize);
                 * //------------------------------------------------------------------------------------------
                 * int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardWidth].Value, out tempInt);
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardWidth))
                 *  myUI.PostcardWidth = tempInt;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardWidth);
                 * //------------------------------------------------------------------------------------------
                 * int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardHeight].Value, out tempInt);
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardHeight))
                 *  myUI.PostcardHeight = tempInt;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardHeight);
                 * //------------------------------------------------------------------------------------------
                 * int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginLeft].Value, out tempInt);
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginLeft))
                 *  myUI.PostcardMarginLeft = tempInt;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardMarginLeft);
                 * //------------------------------------------------------------------------------------------
                 * int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginRight].Value, out tempInt);
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginRight))
                 *  myUI.PostcardMarginRight = tempInt;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardMarginRight);
                 * //------------------------------------------------------------------------------------------
                 * int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginTop].Value, out tempInt);
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginTop))
                 *  myUI.PostcardMarginTop = tempInt;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardMarginTop);
                 * //------------------------------------------------------------------------------------------
                 * int.TryParse(config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginBottom].Value, out tempInt);
                 * if (config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginBottom))
                 *  myUI.PostcardMarginBottom = tempInt;
                 * else
                 *  missingKeys.Add(ConfigKeys.UI.Print.PostcardMarginBottom);
                 * //------------------------------------------------------------------------------------------
                 */

                if (missingKeys.Count > 0)
                {
                    throw new ApplicationException("the following config keys are missing, they will be inserted on application exit: " + String.Join(", ", missingKeys));
                }
                return(true);
            }
            catch (Exception x)
            {
                XLogger.Error(x);
                return(false);
            }
        }
Ejemplo n.º 20
0
        public void FlushAutoAlwaysReturnsFalse()
        {
            var myLogger = new XLogger();

            Assert.False(myLogger.FlushAuto);
        }
Ejemplo n.º 21
0
        private void SaveSettings()
        {
            try
            {
                Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath);

                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.ContactsFile))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.ContactsFile, myUI.ContactsFile);
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.ContactsFile].Value = myUI.ContactsFile;
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.OutputFolder))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.OutputFolder, myUI.OutputFolder);
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.OutputFolder].Value = myUI.OutputFolder;
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.GeneratePerContact))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.GeneratePerContact, myUI.GeneratePerContact.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.GeneratePerContact].Value = myUI.GeneratePerContact.ToString();
                }
                //------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopSize))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopSize, myUI.EnvelopSize.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopSize].Value = myUI.EnvelopSize.ToString();
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopWidth))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopWidth, myUI.EnvelopWidth.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopWidth].Value = myUI.EnvelopWidth.ToString();
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopHeight))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopHeight, myUI.EnvelopHeight.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopHeight].Value = myUI.EnvelopHeight.ToString();
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginLeft))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopMarginLeft, myUI.EnvelopMarginLeft.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginLeft].Value = myUI.EnvelopMarginLeft.ToString();
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginRight))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopMarginRight, myUI.EnvelopMarginRight.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginRight].Value = myUI.EnvelopMarginRight.ToString();
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginTop))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopMarginTop, myUI.EnvelopMarginTop.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginTop].Value = myUI.EnvelopMarginTop.ToString();
                }
                //------------------------------------------------------------------------------------------
                if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.EnvelopMarginBottom))
                {
                    config.AppSettings.Settings.Add(ConfigKeys.UI.Print.EnvelopMarginBottom, myUI.EnvelopMarginBottom.ToString());
                }
                else
                {
                    config.AppSettings.Settings[ConfigKeys.UI.Print.EnvelopMarginBottom].Value = myUI.EnvelopMarginBottom.ToString();
                }
                //------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------

                /*
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardSize))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardSize, myUI.PostcardSize.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardSize].Value = myUI.PostcardSize.ToString();
                 * //------------------------------------------------------------------------------------------
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardWidth))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardWidth, myUI.PostcardWidth.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardWidth].Value = myUI.PostcardWidth.ToString();
                 * //------------------------------------------------------------------------------------------
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardHeight))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardHeight, myUI.PostcardHeight.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardHeight].Value = myUI.PostcardHeight.ToString();
                 * //------------------------------------------------------------------------------------------
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginLeft))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardMarginLeft, myUI.PostcardMarginLeft.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginLeft].Value = myUI.PostcardMarginLeft.ToString();
                 * //------------------------------------------------------------------------------------------
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginRight))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardMarginRight, myUI.PostcardMarginRight.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginRight].Value = myUI.PostcardMarginRight.ToString();
                 * //------------------------------------------------------------------------------------------
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginTop))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardMarginTop, myUI.PostcardMarginTop.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginTop].Value = myUI.PostcardMarginTop.ToString();
                 * //------------------------------------------------------------------------------------------
                 * if (!config.AppSettings.Settings.AllKeys.Contains(ConfigKeys.UI.Print.PostcardMarginBottom))
                 *  config.AppSettings.Settings.Add(ConfigKeys.UI.Print.PostcardMarginBottom, myUI.PostcardMarginBottom.ToString());
                 * else
                 *  config.AppSettings.Settings[ConfigKeys.UI.Print.PostcardMarginBottom].Value = myUI.PostcardMarginBottom.ToString();
                 * //------------------------------------------------------------------------------------------
                 * //------------------------------------------------------------------------------------------
                 */

                config.Save(ConfigurationSaveMode.Modified);
            }
            catch (Exception x)
            {
                XLogger.Error(x);
                MessageBox.Show(MSG.UnableToSaveConfig);
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="log">A logger to write debug and error messages</param>
 /// <param name="config">A configuration</param>
 public XServerConnection(XLogger log, XConfig config)
 {
     this.config = config;
     this.log    = log;
 }
Ejemplo n.º 23
0
 public static void InitTexture()
 {
     XLogger.Log("Resources Init with wuxingogo");
 }
Ejemplo n.º 24
0
 public virtual void OnPaste()
 {
     XLogger.Log("Paste");
 }
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Загрузка изображения по полному пути
            /// </summary>
            /// <param name="file_name">Имя файла</param>
            //---------------------------------------------------------------------------------------------------------
            public void Load(String file_name)
            {
                if (!mFreeImageBitmap.IsNull)
                {
                    mFreeImageBitmap.SetNull();
                }

                // Try loading the file
                mFreeImageFormat = FREE_IMAGE_FORMAT.FIF_UNKNOWN;
                mFreeImageBitmap = FreeImage.LoadEx(file_name, ref mFreeImageFormat);

                try
                {
                    // Error handling
                    if (mFreeImageBitmap.IsNull)
                    {
                        // Chech whether FreeImage generated an error messe
                        if (mCurrentMessage != null)
                        {
                            XLogger.LogErrorFormatModule(MODULE_NAME, "File could not be loaded!\nError:{0}", mCurrentMessage);
                        }
                        else
                        {
                            XLogger.LogErrorModule(MODULE_NAME, "File could not be loaded!");
                        }
                        return;
                    }


                    mFileName = file_name;

                    //
                    // РАЗМЕР ИЗОБРАЖЕНИЯ
                    //

                    // Read width
                    textWidth.Text = String.Format("Width: {0}", FreeImage.GetWidth(mFreeImageBitmap));

                    // Read height
                    textHeight.Text = String.Format("Height: {0}", FreeImage.GetHeight(mFreeImageBitmap));

                    // Read x-axis dpi
                    textDPI.Text = String.Format("DPI: x={0}, y={1}", FreeImage.GetResolutionX(mFreeImageBitmap),
                                                 FreeImage.GetResolutionY(mFreeImageBitmap));

                    //
                    // ПАРАМЕТРЫ ИЗОБРАЖЕНИЯ
                    //

                    // Read file format
                    textFileFormat.Text = String.Format("File Format: {0}", mFreeImageFormat);

                    // Read image type (FI_BITMAP, FIT_RGB16, FIT_COMPLEX ect)
                    textImageType.Text = String.Format("Image Type: {0}", FreeImage.GetImageType(mFreeImageBitmap));

                    // Read color type
                    textColorType.Text = String.Format("Color Depth: {0}", FreeImage.GetColorType(mFreeImageBitmap));

                    //
                    // ПАРАМЕТРЫ ЦВЕТА
                    //

                    // Read file format
                    textColorDepth.Text = String.Format("ColorDepth: {0}", FreeImage.GetBPP(mFreeImageBitmap));

                    // Read file format
                    textPixelFormat.Text = String.Format("PixelFormat: {0}", FreeImage.GetPixelFormat(mFreeImageBitmap));

                    // Read file format
                    textIsTransparent.Text = String.Format("IsTransparent: {0}", FreeImage.IsTransparent(mFreeImageBitmap));

                    //
                    // ПАРАМЕТРЫ МАСКИ
                    //

                    // Read red bitmask (16 - 32 bpp)
                    textRedMask.Text = String.Format("Red Mask: 0x{0:X8}", FreeImage.GetRedMask(mFreeImageBitmap));

                    // Read green bitmask (16 - 32 bpp)
                    textBlueMask.Text = String.Format("Green Mask: 0x{0:X8}", FreeImage.GetGreenMask(mFreeImageBitmap));

                    // Read blue bitmask (16 - 32 bpp)
                    textGreenMask.Text = String.Format("Blue Mask: 0x{0:X8}", FreeImage.GetBlueMask(mFreeImageBitmap));

                    // Получаем презентатор
                    if (mImagePresentator == null)
                    {
                        mImagePresentator = contentViewer.Content as Image;
                    }

                    // Основной режим
                    //mBitmapOriginal = FreeImage.GetBitmap(mFreeImageBitmap).ToBitmapSource();
                    mBitmapOriginal = null;                     // CreateFromHBitmap(FreeImage.GetHbitmap(mFreeImageBitmap, IntPtr.Zero, false));

                    // Если есть прозрачность
                    if (FreeImage.IsTransparent(mFreeImageBitmap) && FreeImage.GetBPP(mFreeImageBitmap) > 24)
                    {
                        // Получаем альфа-канал
                        FIBITMAP bitmap_alpha = FreeImage.GetChannel(mFreeImageBitmap, FREE_IMAGE_COLOR_CHANNEL.FICC_ALPHA);
                        if (!bitmap_alpha.IsNull)
                        {
                            mBitmapAlpha = null;                             // CreateFromHBitmap(FreeImage.GetHbitmap(bitmap_alpha, IntPtr.Zero, false));
                            FreeImage.UnloadEx(ref bitmap_alpha);
                        }

                        // Преобразуем
                        FIBITMAP bitmap_no_transparent = FreeImage.ConvertTo24Bits(mFreeImageBitmap);
                        if (!bitmap_no_transparent.IsNull)
                        {
                            mBitmapNoTransparent = null;                             // CreateFromHBitmap(FreeImage.GetHbitmap(bitmap_no_transparent, IntPtr.Zero, false));
                            FreeImage.UnloadEx(ref bitmap_no_transparent);
                        }

                        radioChannelAlpha.IsEnabled         = true;
                        radioChannelNoTransparent.IsEnabled = true;
                        if (radioChannelOriginal.IsChecked.Value)
                        {
                            mImagePresentator.Source = mBitmapOriginal;
                        }
                        else
                        {
                            radioChannelOriginal.IsChecked = true;
                        }
                    }
                    else
                    {
                        radioChannelAlpha.IsEnabled         = false;
                        radioChannelNoTransparent.IsEnabled = false;
                        if (radioChannelOriginal.IsChecked.Value)
                        {
                            mImagePresentator.Source = mBitmapOriginal;
                        }
                        else
                        {
                            radioChannelOriginal.IsChecked = true;
                        }
                    }

                    mImagePresentator.Width  = FreeImage.GetWidth(mFreeImageBitmap);
                    mImagePresentator.Height = FreeImage.GetHeight(mFreeImageBitmap);

                    if (mImagePresentator.Width > contentViewer.ViewportWidth - 30)
                    {
                        contentViewer.ContentScale = (contentViewer.ViewportWidth - 30) / mImagePresentator.Width;
                    }
                    else
                    {
                        contentViewer.ContentScale = 1.0;
                    }
                }
                catch (Exception exc)
                {
                    XLogger.LogExceptionModule(MODULE_NAME, exc);
                }

                // Always unload bitmap
                FreeImage.UnloadEx(ref mFreeImageBitmap);
            }
Ejemplo n.º 26
0
 protected virtual void OnAwake()
 {
     XLogger.Log(name + " OnAwake");
 }
Ejemplo n.º 27
0
        private static void DrawHierarchyItem(int instanceId, Rect selectionRect)
        {
            try
            {
                rectCount = 0;
                QuickToggle.selectionRect = selectionRect;

                BuildStyles();

                GameObject target = EditorUtility.InstanceIDToObject(instanceId) as GameObject;
                if (target == null)
                {
                    return;
                }

                Rect lockRect = GetNextRect();
                // Draw lock toggle
                bool isLocked = (target.hideFlags & HideFlags.NotEditable) > 0;
                // Decide which GUIStyle to use for the button
                // If this item is currently selected, show the visible lock style, if not, invisible lock style
                GUIStyle lockStyle = (Selection.activeInstanceID == instanceId) ? styleLock : styleLockUnselected;
                if (isLocked != GUI.Toggle(lockRect, isLocked, GUIContent.none, lockStyle))
                {
                    SetLockObject(target, !isLocked);
                    EditorApplication.RepaintHierarchyWindow();
                }


                // Reserve the draw rects
                Rect visRect = GetNextRect(2.1f);
                visRect.xMax = selectionRect.xMax - selectionRect.height;


                // Draw the visibility toggle
                bool isActive = target.activeSelf;
                if (isActive != GUI.Toggle(visRect, isActive, GUIContent.none, styleVisible))
                {
                    SetVisible(target, !isActive);
                    EditorApplication.RepaintHierarchyWindow();
                }


                var monos      = target.GetComponents <Behaviour> ();
                int startIndex = 0;
                for (int i = 0; i < monos.Length; i++)
                {
                    if (monos [i] == null)
                    {
                        continue;
                    }
                    var e = monos [i].enabled;


                    if ((monos [i].hideFlags & HideFlags.HideInInspector) != 0 || showHideComponents)
                    {
                        continue;
                    }
                    else
                    {
                        startIndex++;
                    }
                    Rect monoRect   = GetNextRect();
                    var  guiContent = EditorGUIUtility.ObjectContent(monos [i], monos [i].GetType());
                    if (guiContent != null && guiContent.image != null && e != GUI.Toggle(monoRect, e, guiContent.image, skin.toggle))
                    {
                        SetVisible(monos [i], !e);
                        EditorApplication.RepaintHierarchyWindow();
                        var window = InspectorUtilites.GetInspectorWindow();
                        window.Repaint();
                    }
                }


                for (int i = 0; i < hierchyTypes.Length; i++)
                {
                    var t = hierchyTypes[i];
                    t.TryInvokeMethod(hierchyObjects[i], "OnGUI", instanceId);
                }
            }catch (Exception e) {
                XLogger.Log(e.ToString());
                var          lineNumber = 0;
                const string lineSearch = ":line ";
                var          index      = e.StackTrace.LastIndexOf(lineSearch);
                if (index != -1)
                {
                    var lineNumberText = e.StackTrace.Substring(index + lineSearch.Length);
                    if (int.TryParse(lineNumberText, out lineNumber))
                    {
                    }
                }
                XLogger.Log(lineNumber);
            }
        }
Ejemplo n.º 28
0
    public override void OnXGUI()
    {
        //TODO List
        CreateSpaceBox();


        for (int pos = 0; pos < anims.Count; pos++)
        {
            EditorCurveBinding[] edicurves = AnimationUtility.GetCurveBindings(anims[pos]);

            // AnimationEvent[] events = AnimationUtility.GetAnimationEvents(anims[pos]);
            for (int foot = 0; foot < edicurves.Length; foot++)
            {
                AnimationCurve curve = AnimationUtility.GetEditorCurve(anims[pos], edicurves[foot]);
                EditorGUILayout.BeginHorizontal();
                CreateLabel(edicurves[foot].path);

                CreateLabel(edicurves[foot].type.ToString());
                if (CreateSpaceButton("change"))
                {
                    Undo.RecordObject(anims[pos], "change curves");
                }

                if (CreateSpaceButton("copy"))
                {
                    ShowNotification(new GUIContent("selected key has " + curve.keys.Length + " frames"));
                    // anims[pos].
                    AnimationUtility.SetObjectReferenceCurve(anims[pos], edicurves[0], null);
                }
                if (CreateSpaceButton("paste"))
                {
                    Undo.RecordObject(anims[pos], "clear curves");
                    anims[pos].ClearCurves();
                }

                EditorGUILayout.EndHorizontal();
            }
        }

        if (CreateSpaceButton("Copy"))
        {
            //AnimationUtility.GetAnimatedObject(Selection.objects[0],

            for (int i = 0; i < anims.Count; i++)
            {
                ShowNotification(new GUIContent("wuxingogo"));

                EditorCurveBinding[] edicurves = AnimationUtility.GetCurveBindings(anims[i]);
                //AnimationEvent[] events = AnimationUtility.GetAnimationEvents(anims[i]);
                //AnimationCurve curves = AnimationUtility.GetEditorCurve(anims[i], edicurves[i]);
                //AnimationUtility.GetObjectReferenceCurveBindings (anims[i])
                //AnimationClipSettings setting = AnimationUtility.GetAnimationClipSettings(anims[i]);
                for (int pos = 0; pos < edicurves.Length; pos++)
                {
                    XLogger.Log("pos is : " + edicurves[i].propertyName);
                }
                // AnimationUtility.
                foreach (var binding in AnimationUtility.GetObjectReferenceCurveBindings(anims[i]))
                {
                    ObjectReferenceKeyframe[] keyframes = AnimationUtility.GetObjectReferenceCurve(anims[i], edicurves[i]);
                    XLogger.Log(binding.path + "/" + binding.propertyName + ", Keys: " + keyframes.Length);
                }
            }
        }
    }
        static void ShowXMethods <T>(object target)
        {
            if (target == null)
            {
                return;
            }

            var  methods     = target.GetType().GetMethods(bindFlags);
            bool noAttribute = true;

            foreach (var info in methods)
            {
                foreach (var att in info.GetCustomAttributes(typeof(T), true))
                {
                    noAttribute = false;
                    break;
                }
            }
            if (noAttribute)
            {
                return;
            }

            bool toggle = DrawHeader("Method", "Method", false, false);

            if (!toggle)
            {
                return;
            }

            List <object> nextShow = new List <object>();



            foreach (var info in methods)
            {
                foreach (var att in info.GetCustomAttributes(typeof(T), true))
                {
                    DrawFieldHeader(info.ReturnType, info.Name);
                    ParameterInfo[] paras = info.GetParameters();

                    if (!methodParameters.ContainsKey(info))
                    {
                        object[] o = new object[paras.Length];
                        methodParameters.Add(info, o);
                    }
                    object[] objects = methodParameters [info];

                    if (paras.Length != 0)
                    {
                        using (new GUILayout.HorizontalScope(Skin.textArea, GUILayout.MaxWidth(ForcusWindow.position.width - 40))) {
                            for (int pos = 0; pos < paras.Length; pos++)
                            {
                                if ((paras [pos].Attributes & ParameterAttributes.HasDefault) != ParameterAttributes.None && objects [pos] == null)
                                {
                                    objects [pos] = paras [pos].DefaultValue;
                                }

                                DrawFieldHeader(paras [pos].ParameterType, paras [pos].Name);
                                objects [pos] = GetTypeGUI(objects [pos], paras [pos].ParameterType, paras [pos].Name, nextShow);
                            }
                        }
                    }

                    if (CreateSpaceButton(info.Name))
                    {
                        var invokeValue = info.Invoke(target, objects);
                        if (invokeValue != null)
                        {
                            XLogger.Log(info.Name + " return : " + invokeValue.ToString());
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        public static ExecutionResult DoCustom(string outputFolder, List <Contact> contacts, REF.Scope generatePerContact, string templateFile)
        {
            var successfulContacts = new List <Contact>();
            var failedContacts     = new List <Contact>();

            Contact contact = new Contact();

            for (int i = 0; i < contacts.Count; i++)
            {
                try
                {
                    contact = contacts[i];
                    CallUpdateStatus($"Processing contact {i + 1} of {contacts.Count} contacts");

                    GenerateContactCore(outputFolder, generatePerContact, contact, templateFile);

                    if (!File.Exists(templateFile))
                    {
                        throw new ApplicationException($"Missing template file: {templateFile}");
                    }
                    successfulContacts.Add(contact);
                }
                catch (Exception x)
                {
                    if (!x.Data.Contains("outputFolder"))
                    {
                        x.Data.Add("outputFolder", outputFolder);
                    }
                    if (!x.Data.Contains("generatePerContact"))
                    {
                        x.Data.Add("generatePerContact", generatePerContact);
                    }
                    if (!x.Data.Contains("templateFile"))
                    {
                        x.Data.Add("templateFile", templateFile);
                    }
                    if (!x.Data.Contains("contact.OppName"))
                    {
                        x.Data.Add("contact.OppName", contact.OppName);
                    }
                    XLogger.Error(x);
                    failedContacts.Add(contact);
                }
            }

            if (successfulContacts.Count == contacts.Count())
            {
                CallUpdateStatus("Operation passed and filled templates are generated in the Output folder");
                return(ExecutionResult.Successful);
            }
            else if (failedContacts.Count == contacts.Count())
            {
                CallUpdateStatus("There was a problem in generating all the contacts files");
                return(ExecutionResult.ErrorOccured);
            }
            else
            {
                CallUpdateStatus($"There was a problem generating some of the contact files. Successfully generated {successfulContacts.Count} contact files and failed to generate {failedContacts.Count} files. \nBelow are the failed contacts:\n\n{String.Join("\n", failedContacts)}");
                return(ExecutionResult.PartialPass);
            }
        }
        protected static object GetTypeGUIOpt(object t, Type type, string valueName, List <object> nextShow)
        {
            var controlRect = EditorGUILayout.GetControlRect();

            if (t == null)
            {
                t = GetDefaultValue(type);
            }
            if (t is int || t is System.Int32 || type == typeof(int))
            {
                t = EditorGUI.IntField(controlRect, valueName, Convert.ToInt32(t));
            }
            else if (t is System.Int16)
            {
                t = (short)EditorGUI.IntField(controlRect, valueName, Convert.ToInt16(t));
            }
            else if (t is System.Int64)
            {
                t = EditorGUI.IntField(controlRect, valueName, (int)Convert.ToInt64(t));
            }
            else if (t is uint || type == typeof(UInt32))
            {
                t = (uint)EditorGUI.IntField(controlRect, valueName, Convert.ToInt32(t));
            }
            else if (t is byte)
            {
                int value = Convert.ToInt32(t);
                t = Convert.ToByte(EditorGUI.IntField(controlRect, valueName, value));
            }
            else if (type == typeof(String))
            {
                t = EditorGUI.TextField(controlRect, valueName, (string)t);
            }
            else if (type == typeof(Single))
            {
                t = EditorGUI.FloatField(controlRect, valueName, Convert.ToSingle(t));
            }
            else if (type == typeof(Boolean))
            {
                t = EditorGUI.Toggle(controlRect, valueName, Convert.ToBoolean(t));
            }
            else if (type.BaseType == typeof(Enum))
            {
                t = EditorGUI.EnumPopup(controlRect, valueName, (Enum)t ?? (Enum)Enum.ToObject(type, 0));
            }
            else if (type.IsSubclassOf(typeof(Object)))
            {
                t = EditorGUI.ObjectField(controlRect, valueName, (Object)t, type);
            }
            else if (t is Color || t is Color32)
            {
                t = EditorGUI.ColorField(controlRect, valueName, (Color)t);
            }
            else if (t is Rect)
            {
                t = EditorGUI.RectField(controlRect, valueName, (Rect)t);
            }
            else if (t is Vector2)
            {
                Vector2 v = (Vector2)t;
                t = EditorGUI.Vector2Field(controlRect, valueName, v);
            }
            else if (t is Vector3)
            {
                Vector3 v = (Vector3)t;
                t = EditorGUI.Vector3Field(controlRect, valueName, v);
            }
            else if (t is Vector4)
            {
                Vector4 v = (Vector4)t;
                t = EditorGUI.Vector4Field(controlRect, valueName, v);
            }
            else if (t is Quaternion)
            {
                Quaternion q = (Quaternion)t;
                Vector4    v = new Vector4(q.x, q.y, q.z, q.w);
                v   = EditorGUI.Vector4Field(controlRect, valueName, v);
                q.x = v.x;
                q.y = v.y;
                q.z = v.z;
                q.w = v.w;
                t   = q;
            }
            else if (t is Matrix4x4)
            {
                Matrix4x4 m = (Matrix4x4)t;
                CreateLabel(valueName);
                for (int i = 0; i < 4; i++)
                {
                    //BeginVertical ();
                    EditorGUI.Vector2Field(controlRect, "", m.GetRow(i));
                    //EndVertical ();
                }
            }
            else if (t is DateTime)
            {
                DateTime dateTime = ( DateTime )t;

//				string toString = CreateStringField( dateTime.ToString(XEditorSetting.CultureInfo));
//				t = DateTime.Parse(toString, XEditorSetting.CultureInfo);
            }
            else if (typeof(IList).IsAssignableFrom(type))
            {
                IList list = t as IList;
                if (list == null)
                {
                    XLogger.Log(t.GetType().ToString());
                }
                var  name   = valueName;
                bool toggle = DrawHeader(name + " : " + list.Count, name, false, false);
                if (list == null || !toggle)
                {
                    return(t);
                }
                DoButton("Clear", () => list.Clear());

                var newList = new List <object>();

                BeginVertical();
                for (int pos = 0; pos < list.Count; pos++)
                {
                    //  TODO loop in list.Count
                    var o = list[pos];
                    using (new EditorGUILayout.HorizontalScope())
                    {
                        GetTypeGUIOpt(o, o.GetType(), valueName + "_" + pos, newList);
                        DoButton("Delete", () =>
                        {
                            list.Remove(o);
                        });
                    }
                }
                //bool isShow = DrawHeader( type.Name, type.Name, false, false );
                EndVertical();

                DrawListType(newList);
            }
//			else if( typeof(Queue<>).IsAssignableFrom( type ) )
//			{
//				Queue<> queue = ( Queue<> )t;
//
//				var name = valueName;
//				bool toggle = DrawHeader(name + " : " + queue.Count , name, false, false );
//				if( queue == null || !toggle)
//					return t;
//
//				using( new EditorGUILayout.HorizontalScope() )
//				{
//					DoButton ("Clear", () => queue.Clear());
//					DoButton( "Dequeue",()=>queue.Dequeue() );
//				}
//
//				var newList = new List<object>();
//
//				BeginVertical();
//
//				var array = queue.ToArray();
//				for( int pos = 0; pos < array.Length; pos++ )
//				{
//					//  TODO loop in list.Count
//					var o = array[pos];
//					GetTypeGUIOpt( o, o.GetType(), valueName + "_" + pos, newList );
//				}
//				//bool isShow = DrawHeader( type.Name, type.Name, false, false );
//				EndVertical();
//
//				DrawListType( newList );
//
//			}
//			else if( typeof(Stack<>).IsAssignableFrom( type )  )
//			{
//				var stack = ( Stack<> )t;
//
//				var name = valueName;
//				bool toggle = DrawHeader(name + " : " + stack.Count , name, false, false );
//				if( stack == null || !toggle)
//					return t;
//
//				using( new EditorGUILayout.HorizontalScope() )
//				{
//					DoButton ("Clear", () => stack.Clear());
//					DoButton( "Pop",()=>stack.Pop() );
//				}
//
//				var newList = new List<object>();
//
//				BeginVertical();
//
//				var array = stack.ToArray();
//				for( int pos = 0; pos < array.Length; pos++ )
//				{
//					//  TODO loop in list.Count
//					var o = array[pos];
//					GetTypeGUIOpt( o, o.GetType(), valueName + "_" + pos, newList );
//				}
//				//bool isShow = DrawHeader( type.Name, type.Name, false, false );
//				EndVertical();
//
//				DrawListType( newList );
//
//			}
            else if (typeof(IDictionary).IsAssignableFrom(type))
            {
                IDictionary dictionary    = ( IDictionary )t;
                IEnumerator iteratorKey   = dictionary.Keys.GetEnumerator();
                IEnumerator iteratorValue = dictionary.Values.GetEnumerator();
                ICollection collection    = dictionary.Values;
                var         name          = valueName;
                bool        toggle        = DrawHeader(name + " : " + dictionary.Count, name, false, false);
                if (!toggle)
                {
                    return(t);
                }
                DoButton("Clear", () => dictionary.Clear());
                while (iteratorKey.MoveNext() && iteratorValue.MoveNext())
                {
                    var newList = new List <object>();
                    //BeginHorizontal();
                    var keyType   = iteratorKey.Current.GetType();
                    var valueType = dictionary [iteratorKey.Current].GetType();
                    GetTypeGUI(iteratorKey.Current, keyType, keyType.Name, newList);
                    GetTypeGUI(dictionary[iteratorKey.Current], valueType, valueType.Name, newList);
                    //EndHorizontal();
                    DrawListType(newList);
                }
            }

//            else if( typeof( IEnumerable ).IsAssignableFrom( type ) )
//            {
//				bool toggle = DrawHeader( valueName, valueName, false, false );
//				if(!toggle)
//					return t;
//
//                IEnumerable collection = ( IEnumerable )t;
//				IEnumerator iteratorValue = collection.GetEnumerator();
//
//                int index = 0;
//                var newList = new List<object>();
//                while( iteratorValue.MoveNext() )
//                {
//					var valueType = iteratorValue.Current.GetType();
//                    if( iteratorValue.Current != null )
//						GetTypeGUI( iteratorValue.Current, valueType, valueType.Name + "_" + index, newList );
//                    index++;
//                }
//            }
            else if (t != null)
            {
                if (!nextShow.Contains(t))
                {
                    nextShow.Add(t);
                }

//                EditorGUILayout.Space();
//                DrawHeader( type.Name, type.Name, false, false );
            }
            else
            {
                CreateLabel("NULL");
            }

            return(t);
        }
Ejemplo n.º 32
0
        public XConfig(HttpRequest request, XLogger log)
        {
            System.Configuration.Configuration confg =
                           System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(request.ApplicationPath);
            if (confg.AppSettings.Settings.Count > 0)
            {
                System.Configuration.KeyValueConfigurationElement portPair =
                    confg.AppSettings.Settings["XebraServerPort"];

                if (null != portPair)
                {
                    this.port = int.Parse(portPair.Value);
                }
                else
                {
                    log.Error("Missing property in web.config: XebraServerPort");
                }

                System.Configuration.KeyValueConfigurationElement hostPair =
                    confg.AppSettings.Settings["XebraServerHost"];

                if (null != hostPair)
                {
                    this.host = hostPair.Value;
                }
                else
                {
                    log.Error("Missing property in web.config: XebraServerHost");
                }

                System.Configuration.KeyValueConfigurationElement maxUploadSizePair =
                    confg.AppSettings.Settings["MaxUploadSize"];

                if (null != maxUploadSizePair)
                {
                    this.maxUploadSize = int.Parse(maxUploadSizePair.Value);
                }
                else
                {
                    log.Error("Missing property in web.config: MaxUploadSize");
                }

                System.Configuration.KeyValueConfigurationElement uploadSavePathPair =
                    confg.AppSettings.Settings["UploadSavePath"];

                if (null != uploadSavePathPair)
                {
                    this.uploadSavePath = uploadSavePathPair.Value;
                    if (!this.uploadSavePath.EndsWith("\\"))
                    {
                        this.uploadSavePath += "\\";
                    }
                }
                else
                {
                    log.Error("Missing property in web.config: UploadSavePath");
                }
            }
            else
            {
                log.Error("No properties found in web.config");
            }
        }
Ejemplo n.º 33
0
 public void Log()
 {
     XLogger.Log("Tranvers " + name, gameObject);
 }