コード例 #1
0
ファイル: TPViewer.cs プロジェクト: alterf/ACT.TPMonitor
 public void Adjust(Widget widget)
 {
     Point pos = widget.Rect.Location;
     if (_controller.IsFixedMode)
     {
         pos = new Point((int)_controller.FixedX, (int)_controller.FixedY);
     }
     else
     {
         pos.Offset((int)_controller.OffsetX, (int)_controller.OffsetY);
     }
     this.Location = pos;
     this.Size = widget.Rect.Size;
 }
コード例 #2
0
ファイル: Util.cs プロジェクト: GB19xx/ACT.TPMonitor
        public static Widget GetPartyListLocation(string path, float scale)
        {
            string textFile = Path.Combine(path, @"ADDON.DAT");
            if (_lastWriteTime != File.GetLastWriteTime(textFile))
            {
                _screenRect = GetWindowSize(path);
                Widget widget = new Widget();
                widget.Rect = new Rectangle(new Point(0, 0), new Size(380, 408));
                widget.Scale = 1.0f;

                _partyListUI = widget;
                _lastWriteTime = File.GetLastWriteTime(textFile);
                return _partyListUI;

                using (System.IO.StreamReader sr = new System.IO.StreamReader(textFile, System.Text.Encoding.GetEncoding("shift_jis")))
                {
                    string s = sr.ReadToEnd();
                    string[] textLine = s.Split('\n');
                    for (int i = 0; i < textLine.Length; i++)
                    {
                        if (textLine[i].Equals("n:_PartyList_a"))
                        {
                            float widthPercent = GetFloat(textLine[i + 2].Substring(2));
                            float heightPercent = GetFloat(textLine[i + 3].Substring(2));
                            int width = int.Parse(textLine[i + 4].Substring(2));
                            int height = int.Parse(textLine[i + 5].Substring(2));
                            float widgetScale = scale == 0f ? GetFloat(textLine[i + 7].Substring(2)) : scale;

                            width = (int)(width * widgetScale);
                            height = (int)(height * widgetScale);

                            int x;
                            if (widthPercent < 30)
                            {
                                x = (int)((_screenRect.Width * widthPercent / 100));
                            }
                            else if (widthPercent < 70)
                            {
                                x = (int)((_screenRect.Width * (widthPercent / 100)) - (width / 2));
                            }
                            else
                            {
                                x = (int)((_screenRect.Width * (widthPercent / 100)) - width);
                            }
                            x += _screenRect.Left;

                            int y;
                            if (heightPercent < 30)
                            {
                                y = (int)((_screenRect.Height * heightPercent / 100));
                            }
                            else if (heightPercent < 80)
                            {
                                y = (int)((_screenRect.Height * (heightPercent / 100)) - (height / 2));
                            }
                            else
                            {
                                y = (int)((_screenRect.Height * (heightPercent / 100)) - height);
                            }
                            y += _screenRect.Top;


                            widget.Rect = new Rectangle(new Point(x, y), new Size(width, height));
                            widget.Scale = widgetScale;
                            break;
                        }
                    }
                }
                _partyListUI = widget;
                _lastWriteTime = File.GetLastWriteTime(textFile);
            }
            return _partyListUI;
        }