public Window(Form targetForm, Theme theme, Size maximumSize, Padding margin) { // ... Suspend(); // Properties first TargetForm = targetForm; Theme = theme; Margin = margin; // Throw an exception, if maximum size is less than bitmap if (maximumSize.Width < theme.Width || maximumSize.Height < theme.Height) { throw new Exception($"Maximum size of layered windows must be greater than bitmap size. MaximumSize: {maximumSize}; Bitmap.Size: Width={theme.Width}, Height={theme.Height};"); } // Think about Window class as a single window, it's definetly larger than target form. maximumSize = new Size( maximumSize.Width + theme.Metrics.Left.Width + theme.Metrics.Right.Width + Math.Abs(margin.Horizontal), maximumSize.Height + theme.Metrics.Top.Height + theme.Metrics.Bottom.Height + Math.Abs(margin.Vertical) ); // Creating each side with specific surface sizes depending on how they will be used _left = new WindowSide(this, new Size(theme.Metrics.Left.Width, maximumSize.Height)); _right = new WindowSide(this, new Size(theme.Metrics.Right.Width, maximumSize.Height)); // Horizontal sides _top = new WindowSide(this, new Size(maximumSize.Width, theme.Metrics.Top.Height)); _bottom = new WindowSide(this, new Size(maximumSize.Width, theme.Metrics.Bottom.Height)); // ... Resume(false); }
public List <LevelLamp> lampList = new List <LevelLamp>(); //燈號物件列表 //--------------------------------------------------------------------------------------------------------------------------------------------- //設定位置與尺寸 public void Initialize(WindowSide side, int rowNum, float pos_y, float height) { RectTransform _rt = this.GetComponent <RectTransform>(); columnSide = side; //設定左側or右側 rowNumber = rowNum; //設定列編號 _rt.position = new Vector2(_rt.position.x, pos_y); //設定位置 _rt.sizeDelta = new Vector2(_rt.sizeDelta.x, height); //設定高度 }
//取得窗格位置 //[param] side = 窗格方向, row = 列數編號 public Vector3 GetWindowPosition(WindowSide side, float row) { Vector3 _result = new Vector3(); for (int i = 0; i < lampWindowList.Count; i++) //搜尋符合條件的物件 { if (lampWindowList[i].columnSide == side && lampWindowList[i].rowNumber == row && lampWindowList[i].gameObject.activeSelf) { _result = lampWindowList[i].transform.position; } } return(_result); }
void MenuPosition() { GUILayout.BeginHorizontal(); if (GUILayout.Button(windowSide.ToString())) { switch (windowSide) { case WindowSide.LEFT: windowSide = WindowSide.RIGHT; break; case WindowSide.RIGHT: windowSide = WindowSide.TOP; break; case WindowSide.TOP: windowSide = WindowSide.BOTTOM; break; case WindowSide.BOTTOM: windowSide = WindowSide.LEFT; break; default: windowSide = WindowSide.RIGHT; break; } } if (GUILayout.Button("-", GUILayout.ExpandWidth(false))) { columns--; } GUILayout.Label(columns.ToString(), GUILayout.ExpandWidth(false)); if (GUILayout.Button("+", GUILayout.ExpandWidth(false))) { columns++; } GUILayout.EndHorizontal(); if (columns < 1) { columns = 1; } }