示例#1
0
 public GLoader()
 {
     _url = string.Empty;
     _align = AlignType.Left;
     _verticalAlign = VertAlignType.Top;
     showErrorSign = true;
 }
示例#2
0
        public GTextField()
            : base()
        {
            underConstruct = true;

            _textFormat = new TextFormat();
            _textFormat.font = UIConfig.defaultFont;
            _textFormat.size = 12;
            _textFormat.color = Color.black;
            _textFormat.lineSpacing = 3;
            _textFormat.letterSpacing = 0;
            _strokeColor = new Color(0, 0, 0, 1);
            UpdateTextFormat();

            _text = string.Empty;
            _align = AlignType.Left;
            _verticalAlign = VertAlignType.Top;

            this.autoSize = AutoSizeType.Both;

            underConstruct = false;

            gearColor = new GearColor(this);

            onFocusIn = new EventListener(this, "onFocusIn");
            onFocusOut = new EventListener(this, "onFocusOut");
            onChanged = new EventListener(this, "onChanged");
        }
示例#3
0
 internal ElementState(ElementState copy)
 {
     alignment = copy.alignment;
     verticalAlignment = copy.verticalAlignment;
     pointSize = copy.pointSize;
     // not part of the ongoing state
     //heightPercent = copy.heightPercent;
 }
        public GLoader()
        {
            _playing = true;
            _url = string.Empty;
            _align = AlignType.Left;
            _verticalAlign = VertAlignType.Top;
            showErrorSign = true;

            gearAnimation = new GearAnimation(this);
            gearColor = new GearColor(this);
        }
示例#5
0
 public Text(string text, FontSize size)
 {
     this.text = text;
     this.alignType = AlignType.Left;
     ChangeFont(size);
     this.origin = new Vector2();
     this.scale = new Vector2(1, 1);
     this.angle = 0;
     this.flipping = SpriteEffects.None;
     this.tintColor = Color.White;
 }
示例#6
0
	void Realign(float referenceAspectRatio, AlignType alignment) 
	{			
		Vector3 newPos;
		xForm.position = initialPos;
		
//		float viewRatio = 1f;
//		HorizontalFOVCamera viewChanger = renderCamera.GetComponent<HorizontalFOVCamera>();
//		if (viewChanger != null) {
//			if (renderCamera.orthographic) {
//				viewRatio = renderCamera.orthographicSize / viewChanger.InitialOrtoSize;
//			}
//			else {
//				viewRatio = renderCamera.fov / viewChanger.InitialFOV;
//			}
//		}
		
		if (alignment == AlignType.Left || alignment == AlignType.BottomLeft || alignment == AlignType.TopLeft ||
			alignment == AlignType.Right || alignment == AlignType.BottomRight || alignment == AlignType.TopRight) 
		{
			float originalX = Screen.height * referenceAspectRatio / Screen.width;
			Vector3 offset = renderCamera.ViewportToWorldPoint(new Vector3(1f, 0f, 0f)) - renderCamera.ViewportToWorldPoint(new Vector3(originalX, 0f, 0f));
			newPos = xForm.position;
			if (alignment == AlignType.Left || alignment == AlignType.BottomLeft || alignment == AlignType.TopLeft) {
				newPos.x = initialPos.x - offset.x / 2f;
			} else {
				newPos.x = initialPos.x + offset.x / 2f;
			}
			xForm.position = newPos;
		}
		
		if (alignment == AlignType.Top || alignment == AlignType.BottomLeft || alignment == AlignType.TopLeft ||
			alignment == AlignType.Bottom || alignment == AlignType.BottomRight || alignment == AlignType.TopRight) 
		{
			float originalY = Screen.width / referenceAspectRatio / Screen.height;
			Vector3 offset = renderCamera.ViewportToWorldPoint(new Vector3(0f, 1f, 0f)) - renderCamera.ViewportToWorldPoint(new Vector3(0f, originalY, 0f));
//			Debug.Log(offset);
			newPos = xForm.position;
			if (alignH == AlignType.Top || alignH == AlignType.TopLeft || alignH == AlignType.TopRight) {
				newPos.y = initialPos.y + offset.y / 2f;
			} else {
				newPos.y = initialPos.y - offset.y / 2f;
			}
			xForm.position = newPos;
		}
	}
        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            str = xml.GetAttribute("url");
            if (str != null)
                _url = str;

            str = xml.GetAttribute("align");
            if (str != null)
                _align = FieldTypes.ParseAlign(str);

            str = xml.GetAttribute("vAlign");
            if (str != null)
                _verticalAlign = FieldTypes.ParseVerticalAlign(str);

            str = xml.GetAttribute("fill");
            if (str != null)
                _fill = FieldTypes.ParseFillType(str);

            _autoSize = xml.GetAttributeBool("autoSize", false);

            str = xml.GetAttribute("errorSign");
            if (str != null)
                showErrorSign = str == "true";

            _playing = xml.GetAttributeBool("playing", true);

            str = xml.GetAttribute("color");
            if (str != null)
                this.color = ToolSet.ConvertFromHtmlColor(str);

            str = xml.GetAttribute("fillMethod");
            if (str != null)
                _content.fillMethod = FieldTypes.ParseFillMethod(str);

            if (_content.fillMethod != FillMethod.None)
            {
                _content.fillOrigin = xml.GetAttributeInt("fillOrigin");
                _content.fillClockwise = xml.GetAttributeBool("fillClockwise", true);
                _content.fillAmount = (float)xml.GetAttributeInt("fillAmount", 100) / 100;
            }

            if (_url != null)
                LoadContent();
        }
示例#8
0
        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            string[] arr;

            str = xml.GetAttribute("layout");
            if (str != null)
                _layout = FieldTypes.ParseListLayoutType(str);
            else
                _layout = ListLayoutType.SingleColumn;

            str = xml.GetAttribute("selectionMode");
            if (str != null)
                selectionMode = FieldTypes.ParseListSelectionMode(str);
            else
                selectionMode = ListSelectionMode.Single;

            OverflowType overflow;
            str = xml.GetAttribute("overflow");
            if (str != null)
                overflow = FieldTypes.ParseOverflowType(str);
            else
                overflow = OverflowType.Visible;

            str = xml.GetAttribute("margin");
            if (str != null)
                _margin.Parse(str);

            str = xml.GetAttribute("align");
            if (str != null)
                _align = FieldTypes.ParseAlign(str);

            str = xml.GetAttribute("vAlign");
            if (str != null)
                _verticalAlign = FieldTypes.ParseVerticalAlign(str);

            if (overflow == OverflowType.Scroll)
            {
                ScrollType scroll;
                str = xml.GetAttribute("scroll");
                if (str != null)
                    scroll = FieldTypes.ParseScrollType(str);
                else
                    scroll = ScrollType.Vertical;

                ScrollBarDisplayType scrollBarDisplay;
                str = xml.GetAttribute("scrollBar");
                if (str != null)
                    scrollBarDisplay = FieldTypes.ParseScrollBarDisplayType(str);
                else
                    scrollBarDisplay = ScrollBarDisplayType.Default;

                int scrollBarFlags = xml.GetAttributeInt("scrollBarFlags");

                Margin scrollBarMargin = new Margin();
                str = xml.GetAttribute("scrollBarMargin");
                if (str != null)
                    scrollBarMargin.Parse(str);

                string vtScrollBarRes = null;
                string hzScrollBarRes = null;
                arr = xml.GetAttributeArray("scrollBarRes");
                if (arr != null)
                {
                    vtScrollBarRes = arr[0];
                    hzScrollBarRes = arr[1];
                }

                SetupScroll(scrollBarMargin, scroll, scrollBarDisplay, scrollBarFlags, vtScrollBarRes, hzScrollBarRes);
            }
            else
            {
                SetupOverflow(overflow);
            }

            arr = xml.GetAttributeArray("clipSoftness");
            if (arr != null)
                this.clipSoftness = new Vector2(int.Parse(arr[0]), int.Parse(arr[1]));

            _lineGap = xml.GetAttributeInt("lineGap");
            _columnGap = xml.GetAttributeInt("colGap");
            _lineItemCount = xml.GetAttributeInt("lineItemCount");
            defaultItem = xml.GetAttribute("defaultItem");

            autoResizeItem = xml.GetAttributeBool("autoItemSize", true);

            XMLList.Enumerator et = xml.GetEnumerator("item");
            while (et.MoveNext())
            {
                XML ix = et.Current;
                string url = ix.GetAttribute("url");
                if (string.IsNullOrEmpty(url))
                {
                    url = defaultItem;
                    if (string.IsNullOrEmpty(url))
                        continue;
                }

                GObject obj = GetFromPool(url);
                if (obj != null)
                {
                    AddChild(obj);
                    str = ix.GetAttribute("title");
                    if (str != null)
                        obj.text = str;
                    str = ix.GetAttribute("icon");
                    if (str != null)
                        obj.icon = str;
                    str = ix.GetAttribute("name");
                    if (str != null)
                        obj.name = str;
                }
            }
        }
示例#9
0
        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            str = xml.GetAttribute("url");
            if (str != null)
                _url = str;

            str = xml.GetAttribute("align");
            if (str != null)
                _align = FieldTypes.ParseAlign(str);

            str = xml.GetAttribute("vAlign");
            if (str != null)
                _verticalAlign = FieldTypes.ParseVerticalAlign(str);

            str = xml.GetAttribute("fill");
            if (str != null)
                _fill = FieldTypes.ParseFillType(str);

            _autoSize = xml.GetAttributeBool("autoSize", false);

            str = xml.GetAttribute("errorSign");
            if (str != null)
                showErrorSign = str == "true";

            _playing = xml.GetAttributeBool("playing", true);

            str = xml.GetAttribute("color");
            if (str != null)
                this.color = ToolSet.ConvertFromHtmlColor(str);

            if (_url != null)
                LoadContent();
        }
示例#10
0
        public override void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;
            this.displayAsPassword = xml.GetAttributeBool("password", false);
            str = xml.GetAttribute("font");
            if (str != null)
                _textFormat.font = str;

            str = xml.GetAttribute("fontSize");
            if (str != null)
                _textFormat.size = int.Parse(str);

            str = xml.GetAttribute("color");
            if (str != null)
                _textFormat.color = ToolSet.ConvertFromHtmlColor(str);

            str = xml.GetAttribute("align");
            if (str != null)
                _align = FieldTypes.ParseAlign(str);

            str = xml.GetAttribute("vAlign");
            if (str != null)
                _verticalAlign = FieldTypes.ParseVerticalAlign(str);

            str = xml.GetAttribute("leading");
            if (str != null)
                _textFormat.lineSpacing = int.Parse(str);

            str = xml.GetAttribute("letterSpacing");
            if (str != null)
                _textFormat.letterSpacing = int.Parse(str);

            _ubbEnabled = xml.GetAttributeBool("ubb", false);

            str = xml.GetAttribute("autoSize");
            if (str != null)
                this.autoSize = FieldTypes.ParseAutoSizeType(str);

            _textFormat.underline = xml.GetAttributeBool("underline", false);
            _textFormat.italic = xml.GetAttributeBool("italic", false);
            _textFormat.bold = xml.GetAttributeBool("bold", false);
            _singleLine = xml.GetAttributeBool("singleLine", false);
            str = xml.GetAttribute("strokeColor");
            if (str != null)
            {
                _strokeColor = ToolSet.ConvertFromHtmlColor(str);
                _stroke = xml.GetAttributeInt("strokeSize", 1);
            }
        }
示例#11
0
        /// <summary>
        /// make the origin in the center of the image
        /// </summary>
        public void Align(AlignType type)
        {
            alignType = type;

            switch (type)
            {
                case AlignType.Left:
                    OriginX = 0;
                    break;
                case AlignType.Right:
                    OriginX = Width;
                    break;
                case AlignType.Center:
                    OriginX = Width / 2;
                    break;
            }
        }
示例#12
0
 public void Align(AlignType align)
 {
     this.DrawArea.Align(align);
 }
示例#13
0
		public void ParseStyleContent(string styleContent)
		{
			string[] splitOnSemi = styleContent.Split(';');
			for (int i = 0; i < splitOnSemi.Length; i++)
			{
				if (splitOnSemi[i].Length > 0)
				{
					string[] splitOnColon = splitOnSemi[i].Split(':');
					string attribute = splitOnColon[0];
					string value = splitOnColon[1];
					switch (attribute)
					{
						case "margin-right":
						case "margin-left":
							break;

						case "width":
							if (value.Contains("%"))
							{
								this.sizePercent = new Point2D(GetFirstInt(value), this.SizePercent.y);
							}
							else
							{
								this.sizeFixed = new Point2D(GetFirstInt(value), this.SizePercent.y);
							}
							break;

						case "float":
							Console.WriteLine("Not Implemented");
							break;

						case "height":
							if (value.Contains("%"))
							{
								this.sizePercent = new Point2D(this.SizePercent.x, GetFirstInt(value));
							}
							else
							{
								this.sizeFixed = new Point2D(this.SizeFixed.x, GetFirstInt(value));
							}
							break;

						case "text-align":
							this.alignment = (ElementState.AlignType)Enum.Parse(typeof(ElementState.AlignType), value);
							break;

						case "font-size":
							this.pointSize = GetFirstInt(value);
							break;

						case "vertical-align":
							this.verticalAlignment = (ElementState.VerticalAlignType)Enum.Parse(typeof(ElementState.VerticalAlignType), value);
							break;

						case "'": // the ending single quote
							break;

						default:
							throw new NotImplementedException();
					}
				}
			}
		}
示例#14
0
        /// <summary>
        ///     Creates binarytree using stage1 sequences and
        ///     cut the binary tree at an random edge to get two profiles.
        ///     Create NeedlemanWunschProfileAlignerSerial\Parallel instance
        ///     according to degree of parallelism
        ///     and execute AlignSimple\Align() method using two profiles.
        ///     Validate the IProfileAlignment properties.
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        /// <param name="degreeOfParallelism">if 1 it is serial Profiler else parallel profiler</param>
        /// <param name="edgeIndex">edge index to cut the tree</param>
        /// <param name="overloadType">Execute Align()\AlignSimple()</param>
        private void ValidateProfileAlignerAlign(string nodeName,
                                                 int degreeOfParallelism, int edgeIndex, AlignType overloadType)
        {
            Initialize(Constants.MuscleDnaSequenceNode, Constants.ExpectedScoreNode);
            InitializeStage2Variables(Constants.MuscleDnaSequenceNode);

            // Get Stage2 Binary Tree
            List<ISequence> stage1AlignedSequences = GetStage1AlignedSequence();
            IDistanceMatrix matrix = GetKimuraDistanceMatrix(stage1AlignedSequences);
            IHierarchicalClustering hierarcicalClustering = GetHierarchicalClustering(matrix);
            BinaryGuideTree binaryTree = GetBinaryTree(hierarcicalClustering);

            // Cut Tree at an edge and get sequences.
            List<int>[] leafNodeIndices = binaryTree.SeparateSequencesByCuttingTree(edgeIndex);

            // Extract profiles 
            List<int>[] removedPositions = null;
            IProfileAlignment[] separatedProfileAlignments = ProfileAlignment.ProfileExtraction(
                stage2ExpectedSequences, leafNodeIndices[0], leafNodeIndices[1], out removedPositions);

            // Align it
            IProfileAlignment alignedProfile = null;
            if (1 == degreeOfParallelism)
            {
                var nwprofileAligner =
                    new NeedlemanWunschProfileAlignerSerial(similarityMatrix,
                                                            ProfileScoreFunctionNames.InnerProductFast,
                                                            gapOpenPenalty, gapExtendPenalty, 2);
                switch (overloadType)
                {
                    case AlignType.AlignSimpleAllParams:
                        alignedProfile = nwprofileAligner.AlignSimple(similarityMatrix,
                                                                      gapOpenPenalty, separatedProfileAlignments[0],
                                                                      separatedProfileAlignments[1]);
                        break;
                    case AlignType.AlignSimpleOnlyProfiles:
                        alignedProfile = nwprofileAligner.AlignSimple(separatedProfileAlignments[0],
                                                                      separatedProfileAlignments[1]);
                        break;
                    case AlignType.AlignAllParams:
                        alignedProfile = nwprofileAligner.Align(similarityMatrix, gapOpenPenalty,
                                                                gapExtendPenalty, separatedProfileAlignments[0],
                                                                separatedProfileAlignments[1]);
                        break;
                }
            }
            else
            {
                if (Environment.ProcessorCount >= degreeOfParallelism)
                {
                    var nwprofileAlignerParallel =
                        new NeedlemanWunschProfileAlignerParallel(
                            similarityMatrix,
                            ProfileScoreFunctionNames.InnerProductFast,
                            gapOpenPenalty,
                            gapExtendPenalty, 2);

                    alignedProfile = nwprofileAlignerParallel.AlignSimple(
                        separatedProfileAlignments[0],
                        separatedProfileAlignments[1]);

                    switch (overloadType)
                    {
                        case AlignType.AlignSimpleAllParams:
                            alignedProfile = nwprofileAlignerParallel.AlignSimple(similarityMatrix,
                                                                                  gapOpenPenalty,
                                                                                  separatedProfileAlignments[0],
                                                                                  separatedProfileAlignments[1]);
                            break;
                        case AlignType.AlignSimpleOnlyProfiles:
                            alignedProfile = nwprofileAlignerParallel.AlignSimple(
                                separatedProfileAlignments[0],
                                separatedProfileAlignments[1]);
                            break;
                        case AlignType.AlignAllParams:
                            alignedProfile = nwprofileAlignerParallel.Align(
                                similarityMatrix, gapOpenPenalty,
                                gapExtendPenalty, separatedProfileAlignments[0],
                                separatedProfileAlignments[1]);
                            break;
                    }
                }
                else
                {
                    ApplicationLog.WriteLine(String.Format(null,
                                                           @"PamsamBvtTest: NeedlemanWunschProfileAlignerParallel could not be instantiated
                          as number of processor is {0} and degree of parallelism {1}",
                                                           Environment.ProcessorCount.ToString((IFormatProvider) null),
                                                           degreeOfParallelism));
                }
            }

            if (null != alignedProfile)
            {
                // Validate profile alignement 
                string expectedRowSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.RowSize);
                string expectedColSize = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ColumnSize);
                Assert.AreEqual(expectedColSize,
                                alignedProfile.ProfilesMatrix.ColumnSize.ToString((IFormatProvider) null));
                Assert.AreEqual(expectedRowSize, alignedProfile.ProfilesMatrix.RowSize.ToString((IFormatProvider) null));

                ApplicationLog.WriteLine(String.Format(null,
                                                       @"PamsamBvtTest: {0} {1} method validation completed successfully with
                        number of processor is {2} and degree of parallelism {3}",
                                                       profileAligner,
                                                       overloadType,
                                                       Environment.ProcessorCount.ToString((IFormatProvider) null),
                                                       degreeOfParallelism));
            }
            else
            {
                Assert.Fail("Profile Aligner is not instantiated");
            }
        }
示例#15
0
 private void SetInnerContentPanelAlignment(AlignType alignment)
 {
     switch (alignment)
     {
         case AlignType.TopLeft:
             {
                 innerControlPanel.Left = 0;
                 innerControlPanel.Top = 0;
             }
             break;
         case AlignType.TopCenter:
             {
                 innerControlPanel.Left = (this.Width - innerControlPanel.Width) / 2;
                 innerControlPanel.Top = 0;
             }
             break;
         case AlignType.TopRight:
             {
                 innerControlPanel.Left = this.Width - innerControlPanel.Width;
                 innerControlPanel.Top = 0;
             }
             break;
         case AlignType.MiddleLeft:
             {
                 innerControlPanel.Left = 0;
                 innerControlPanel.Top = (this.Height - innerControlPanel.Height) / 2;
             }
             break;
         case AlignType.MiddleRight:
             {
                 innerControlPanel.Left = this.Width - innerControlPanel.Width;
                 innerControlPanel.Top = (this.Height - innerControlPanel.Height) / 2;
             }
             break;
         case AlignType.BottomLeft:
             {
                 innerControlPanel.Left = 0;
                 innerControlPanel.Top = this.Height - innerControlPanel.Height;
             }
             break;
         case AlignType.BottomCenter:
             {
                 innerControlPanel.Left = (this.Width - innerControlPanel.Width) / 2;
                 innerControlPanel.Top = this.Height - innerControlPanel.Height;
             }
             break;
         case AlignType.BottomRight:
             {
                 innerControlPanel.Left = this.Width - innerControlPanel.Width;
                 innerControlPanel.Top = this.Height - innerControlPanel.Height;
             }
             break;
         default:
         case AlignType.MiddleCenter:
             {
                 innerControlPanel.Left = (this.Width - innerControlPanel.Width) / 2;
                 innerControlPanel.Top = (this.Height - innerControlPanel.Height) / 2;
             }
             break;
     }
 }
示例#16
0
 public AutoAlignLine(double x1, double y1, double x2, double y2, AlignType alignType)
 {
     _x1 = x1;
     _y1 = y1;
     _x2 = x2;
     _y2 = y2;
     _alignType = alignType;
     _isEmpty = false;
 }
示例#17
0
    /*
    /// <summary>
    /// ͳһ��λ����ѡ�еĶ���
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <param name="z"></param>
    */
    void PositionSelectionObjects(AlignType alignType)
    {
        GameObject[] gameObjects = this.getSortedGameObjects();

        /* ���뿪ʼ */
        if (gameObjects.Length > 0)
        {
            /* ��ȡ��һ��Ԫ�أ�����Ԫ�ظ�������λ */
            if (alignType == AlignType.TopAlign)
            {
                float firstY = gameObjects[0].transform.localPosition.y;  /*ͳһy, ������ */

                foreach (GameObject obj in gameObjects)
                {
                    float selfX = obj.transform.localPosition.x;
                    float selfZ = obj.transform.localPosition.z;

                    obj.transform.localPosition = new Vector3(selfX, firstY, selfZ);
                }
            }
            else if (alignType == AlignType.LeftAlign)  /*�����*/
            {
                float fisrtX = gameObjects[0].transform.localPosition.x;

                foreach (GameObject obj in gameObjects)
                {
                    float selfY = obj.transform.localPosition.y;
                    float selfZ = obj.transform.localPosition.z;

                    obj.transform.localPosition = new Vector3(fisrtX, selfY, selfZ);
                }
            }

        }
    }
	/// <summary>
	/// 设置位置
	/// </summary>
	/// <param name="alignType"></param>
	/// <param name="fromSmallToLarge"></param>
	void AlignSelection(AlignType alignType, bool fromSmallToLarge)
	{
		var gameObjects = getSortedGameObjects();
		if (gameObjects.Count <= 0)
		{
			Debug.Log("select gameobject null");
			return;
		}

		if (alignType == AlignType.XAlign)
		{
			//按从小到大排序
			gameObjects.Sort((ls, rs) =>
			{
				return ls.transform.localPosition.x.CompareTo(rs.transform.localPosition.x);

			});
			float alignX = 0f;

			if (fromSmallToLarge) alignX = gameObjects.LastOrDefault().transform.localPosition.x;
			else alignX = gameObjects.FirstOrDefault().transform.localPosition.x;

			foreach (GameObject obj in gameObjects)
			{
				float selfY = obj.transform.localPosition.y;
				float selfZ = obj.transform.localPosition.z;
				//注册操作记录
				Undo.RecordObject(obj,string.Concat("SetPosX",obj.name));
				obj.transform.localPosition = new Vector3(alignX, selfY, selfZ);
				
			}
		}
		else if (alignType == AlignType.YAlign)
		{
			//按从小到大排序
			gameObjects.Sort((ls, rs) =>
			{
				return ls.transform.localPosition.y.CompareTo(rs.transform.localPosition.y);

			});
			float alignY = 0f;

			if (fromSmallToLarge) alignY = gameObjects.LastOrDefault().transform.localPosition.y;
			else alignY = gameObjects.FirstOrDefault().transform.localPosition.y;

			foreach (GameObject obj in gameObjects)
			{
				float selfX = obj.transform.localPosition.x;
				float selfZ = obj.transform.localPosition.z;

				obj.transform.localPosition = new Vector3(selfX, alignY, selfZ);
			}
		}
	}