Esempio n. 1
0
 static Int32Rect GetImageRect(GroupPosition gp)
 {
     return(new Int32Rect((int)(gp.Left + gp.BorderThickness.Left + gp.Margin.Left),
                          (int)(gp.Top + gp.BorderThickness.Top + gp.Margin.Top),
                          (int)(gp.Width - gp.BorderThickness.Left - gp.BorderThickness.Right - gp.Margin.Left - gp.Margin.Right),
                          (int)(gp.Height - gp.BorderThickness.Top - gp.BorderThickness.Bottom - gp.Margin.Top - gp.Margin.Bottom)));
 }
Esempio n. 2
0
        void SetSize(Size size)
        {
            // 计算居中的 x y 偏移
            Point offset = GetOffset(size, out Size picture_size);

            // 遍历 ContentControl 对象
            foreach (Button button in this.canvas.Children)
            {
                if (button == null)
                {
                    continue;
                }
                GroupPosition gp = button.Tag as GroupPosition;
                if (gp == null)
                {
                    continue;
                }

                button.SetValue(Canvas.LeftProperty, offset.X + (picture_size.Width * gp.Left));
                button.SetValue(Canvas.TopProperty, offset.Y + (picture_size.Height * gp.Top));
                button.Width  = picture_size.Width * gp.Width;
                button.Height = picture_size.Height * gp.Height;
                var door_item = button.DataContext as DoorItem;
                if (door_item != null)
                {
                    door_item.Padding         = Multiple(gp.Padding, picture_size.Width, picture_size.Height);
                    door_item.Margin          = Multiple(gp.Margin, picture_size.Width, picture_size.Height);
                    door_item.BorderThickness = Multiple(gp.BorderThickness, picture_size.Width, picture_size.Height);
                    door_item.CornerRadius    = Multiple(gp.CornerRadius, picture_size.Width, picture_size.Height);
                }
            }
        }
    // Token: 0x06000AD2 RID: 2770 RVA: 0x00045C28 File Offset: 0x00043E28
    private string ConvertClanPosition(GroupPosition gp)
    {
        string result = string.Empty;

        switch (gp)
        {
        case GroupPosition.Leader:
            result = LocalizedStrings.Leader;
            break;

        default:
            if (gp != GroupPosition.Officer)
            {
                result = LocalizedStrings.Unknown;
            }
            else
            {
                result = LocalizedStrings.Officer;
            }
            break;

        case GroupPosition.Member:
            result = LocalizedStrings.Member;
            break;
        }
        return(result);
    }
Esempio n. 4
0
 public override void OnOpen()
 {
     focused          = false;
     currentGroupName = defaultGroupName;
     groupPosition    = GameObjectGroupingTool.lastGroupPosition;
     base.OnOpen();
 }
Esempio n. 5
0
        /// <summary>
        /// Groups the currently selected gameObjects under a new parent gameObject with the given name.
        /// </summary>
        /// <param name="groupName">Name of the new parent.</param>
        public static void GroupSelection(GroupPosition groupPosition, string groupName)
        {
            GameObject[] selectedObjects = Selection.gameObjects;

            if (selectedObjects.Length == 0)
            {
                return;
            }

            // Create Parent.
            GameObject parentObject = CreateParentObject(selectedObjects, groupPosition, groupName);
            string     parentingUndoDisplayMessage = selectedObjects.Length > 1 ?
                                                     "Parent GameObjects" : "Parent GameObject";

            // Parent selection.
            for (int i = 0; i < selectedObjects.Length; i++)
            {
                GameObject current = selectedObjects[i];
                Undo.SetTransformParent(current.transform, parentObject.transform, parentingUndoDisplayMessage);
            }

            Selection.activeGameObject = parentObject;

            // Save the changed group position.
            lastGroupPosition = groupPosition;
            GameObjectGroupingToolPreferences.SaveGroupingToolSettings();
        }
Esempio n. 6
0
 // Token: 0x060000C8 RID: 200 RVA: 0x000026C2 File Offset: 0x000008C2
 public ClanMemberView(string name, int cmid, GroupPosition position, DateTime joiningDate, DateTime lastLogin)
 {
     this.Cmid        = cmid;
     this.Name        = name;
     this.Position    = position;
     this.JoiningDate = joiningDate;
     this.Lastlogin   = lastLogin;
 }
    // Token: 0x06000AD1 RID: 2769 RVA: 0x00045BF0 File Offset: 0x00043DF0
    private bool HasHigherPermissionThan(GroupPosition gp)
    {
        GroupPosition rankInClan = Singleton <PlayerDataManager> .Instance.RankInClan;

        if (rankInClan != GroupPosition.Leader)
        {
            return(rankInClan == GroupPosition.Officer && gp == GroupPosition.Member);
        }
        return(gp != GroupPosition.Leader);
    }
Esempio n. 8
0
 public ItemGroup(T[] items, LockedState lockedState)
 {
     State = lockedState;
     Items = items;
     Level = -1;
     MascotIconContentKey = null;
     LocalizedThemeName   = null;
     ThemeIconContentKey  = null;
     BGImage       = BGImage.Default;
     GroupPosition = GroupPosition.None;
 }
 // Token: 0x060012CB RID: 4811 RVA: 0x0006F258 File Offset: 0x0006D458
 public void UpdateMemberTo(int cmid, GroupPosition position)
 {
     this.IsProcessingWebservice = true;
     ClanWebServiceClient.UpdateMemberPosition(new MemberPositionUpdateView(PlayerDataManager.ClanID, PlayerDataManager.AuthToken, cmid, position), delegate(int ev)
     {
         this.IsProcessingWebservice = false;
         ClanMemberView clanMemberView;
         if (ev == 0 && PlayerDataManager.TryGetClanMember(cmid, out clanMemberView))
         {
             clanMemberView.Position = position;
         }
     }, delegate(Exception ex)
     {
         this.IsProcessingWebservice = false;
     });
 }
Esempio n. 10
0
        public override void OnGUI(Rect rect)
        {
            // Add window padding
            GUILayout.BeginHorizontal();
            GUILayout.Space(windowPaddingInPixel);
            GUILayout.BeginVertical();
            GUILayout.Space(windowPaddingInPixel);

            // Draw header
            GUILayout.Label("GameObject Group Options", EditorStyles.boldLabel);
            GUILayout.Space(rowPaddingInPixel);

            // Draw name field
            GUILayout.BeginHorizontal();
            GUILayout.Label("Group name");
            GUI.SetNextControlName("Group name");
            currentGroupName = EditorGUILayout.TextField(currentGroupName);
            GUILayout.EndHorizontal();
            GUILayout.Space(rowPaddingInPixel);

            // Draw position selection
            GUILayout.BeginHorizontal();
            GUILayout.Label("Group Position");
            GUI.SetNextControlName("Group Position");
            groupPosition = (GroupPosition)EditorGUILayout.EnumPopup(groupPosition);
            GUILayout.EndHorizontal();
            GUILayout.Space(rowPaddingInPixel);

            // Draw group button and auto group on return.
            if (GUILayout.Button("Group") || (Event.current.isKey && Event.current.keyCode == KeyCode.Return))
            {
                GameObjectGroupingTool.GroupSelection(groupPosition, currentGroupName);
                editorWindow.Close();
            }

            // End window padding
            GUILayout.Space(windowPaddingInPixel);
            GUILayout.EndVertical();
            GUILayout.Space(windowPaddingInPixel);
            GUILayout.EndHorizontal();

            if (focused == false)
            {
                GUI.FocusControl("Group name");
                focused = true;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a parent gameObject for the given gameObjects. The future childs will not be parented.
        /// </summary>
        private static GameObject CreateParentObject(GameObject[] futureChilds, GroupPosition groupPosition, string name = "NewGroup")
        {
            GameObject parentObject = new GameObject(name);
            Transform  groupParent  = CommonParentFinder.FindDeepest(futureChilds);

            if (groupParent != null)
            {
                parentObject.transform.SetParent(groupParent);
            }
            else
            {
                // If it's a root object make sure it's spawned in the correct scene.
                Scene targetScene = futureChilds[0].scene;
                if (parentObject.scene != targetScene)
                {
                    SceneManager.MoveGameObjectToScene(parentObject, targetScene);
                }
            }

            int groupSiblingIndex = CommonParentFinder.GetGroupSiblingIndex(futureChilds, groupParent);

            parentObject.transform.SetSiblingIndex(groupSiblingIndex);

            Vector3 loalPos = groupPosition == GroupPosition.LocalOrigin ? Vector3.zero : GetCenterPosition(futureChilds);

            parentObject.transform.localPosition = loalPos;

            if (useDefaultLable)
            {
                GameObjectLabler.AddLable(
                    parentObject,
                    defaultIconType,
                    defaultIconColor
                    );
            }

            Undo.RegisterCreatedObjectUndo(parentObject, "Create Group GameObject");
            return(parentObject);
        }
Esempio n. 12
0
        void SetSize(Size size)
        {
            // 计算居中的 x y 偏移
            Point offset = GetOffset(size, out Size picture_size);

            // 遍历 Grid 对象
            foreach (Grid grid in this.canvas.Children)
            {
                if (grid == null)
                {
                    continue;
                }
                GroupPosition gp = grid.Tag as GroupPosition;
                if (gp == null)
                {
                    continue;
                }

                grid.SetValue(Canvas.LeftProperty, offset.X + (picture_size.Width * gp.Left));
                grid.SetValue(Canvas.TopProperty, offset.Y + (picture_size.Height * gp.Top));
                grid.Width  = picture_size.Width * gp.Width;
                grid.Height = picture_size.Height * gp.Height;
            }
        }
 public GroupBorders()
 {
     PositionInGroup = GroupPosition.None;
     this.InitializeComponent();
 }
Esempio n. 14
0
        public void InitializeButtons(XmlDocument cfg_dom,
                                      List <DoorItem> door_items)
        {
            // 2019/12/22
            this.canvas.Children.Clear();

            // testing
            // door_items = new List<DoorItem>();

            XmlElement root = cfg_dom.DocumentElement;

            CheckAttributes(root, two_attrs);

            double canvas_width  = GetDouble(root, "width", 0);
            double canvas_height = GetDouble(root, "height", 0);

            XmlNodeList shelfs = cfg_dom.DocumentElement.SelectNodes("shelf");

            bool undefined = false;
            int  index     = 0;

            foreach (XmlElement shelf in shelfs)
            {
                CheckAttributes(shelf, all_attrs);

                GroupPosition gp = new GroupPosition();
                gp.Left   = GetDouble(shelf, "left", -1);
                gp.Top    = GetDouble(shelf, "top", -1);
                gp.Width  = GetDouble(shelf, "width", -1);
                gp.Height = GetDouble(shelf, "height", -1);

                if (gp.Left == -1 || gp.Top == -1 || gp.Width == -1 || gp.Height == -1)
                {
                    undefined = true;
                }

                Grid grid = CreateGroupControls(shelf, door_items, ref index);
                grid.Tag = gp;

                this.canvas.Children.Add(grid);
            }

            // 对 -1 进行调整
            if (undefined)
            {
                double x = 0;
                foreach (Grid grid in this.canvas.Children)
                {
                    GroupPosition gp = grid.Tag as GroupPosition;
                    if (gp.Left == -1)
                    {
                        gp.Left   = x;
                        gp.Top    = 0;
                        gp.Width  = 10;
                        gp.Height = 20;

                        x += 10;
                    }
                }
                canvas_width  = x;
                canvas_height = 20;
            }

            // 变换为比率
            foreach (Grid grid in this.canvas.Children)
            {
                GroupPosition gp = grid.Tag as GroupPosition;
                gp.Left   /= canvas_width;
                gp.Top    /= canvas_height;
                gp.Width  /= canvas_width;
                gp.Height /= canvas_height;
            }

            // 记忆
            _canvas_width  = canvas_width;
            _canvas_height = canvas_height;

            InitialSize();

            SetBackgroundImage();
        }
Esempio n. 15
0
        // 获得一个 door 元素的位置参数。如果 door 元素缺乏参数,则自动找外围的 group 元素中的参数
        GroupPosition GetPosition(XmlElement door)
        {
            GroupPosition gp = new GroupPosition();

            gp.Left            = GetDouble(door, "left", -1);
            gp.Top             = GetDouble(door, "top", -1);
            gp.Width           = GetDouble(door, "width", -1);
            gp.Height          = GetDouble(door, "height", -1);
            gp.Padding         = GetThickness(door, "padding", new Thickness(8));
            gp.Margin          = GetThickness(door, "margin", new Thickness(0));
            gp.BorderBrush     = GetBrush(door, "borderBrush", new System.Windows.Media.SolidColorBrush(Colors.DarkGray));
            gp.BorderThickness = GetThickness(door, "borderThickness", new Thickness(1));
            gp.CornerRadius    = GetCornerRadius(door, "cornerRadius", new CornerRadius(0));
            gp.OpenBrush       = GetBrush(door,
                                          "openBrush",
                                          new System.Windows.Media.SolidColorBrush(DoorItem.DefaultOpenColor),
                                          (filename) =>
            {
                string filepath = System.IO.Path.Combine(WpfClientInfo.UserDir, filename);
                var source      = new BitmapImage(new Uri(filepath));
                // 转换为物理的 pixel 坐标
                return(CutBitmap(source, GetImageRect(gp)));
            });
            gp.CloseBrush = GetBrush(door,
                                     "closeBrush",
                                     new System.Windows.Media.SolidColorBrush(DoorItem.DefaultCloseColor),
                                     (filename) =>
            {
                string filepath = System.IO.Path.Combine(WpfClientInfo.UserDir, filename);
                var source      = new BitmapImage(new Uri(filepath));
                // 转换为物理的 pixel 坐标
                return(CutBitmap(source, GetImageRect(gp)));
            });
            gp.Foreground      = GetBrush(door, "foreground", new System.Windows.Media.SolidColorBrush(DoorItem.DefaultForegroundColor));
            gp.ErrorForeground = GetBrush(door, "errorForeground", new System.Windows.Media.SolidColorBrush(DoorItem.DefaultErrorForegroundColor));

            /*
             * {
             *  string testfilename = System.IO.Path.Combine(WpfClientInfo.UserDir, "daily_wallpaper");
             *  var brush = new ImageBrush(GetBitmapImage(testfilename));
             *  brush.Stretch = Stretch.Uniform;
             *  gp.CloseBrush = brush;
             * }
             */

            if (gp.Left == -1 || gp.Top == -1 || gp.Width == -1 || gp.Height == -1)
            {
                // 找外围的 group 元素
                XmlElement group = FindGroup(door);
                if (group == null)
                {
                    return(gp);
                    // throw new Exception("door 元素没有定义位置参数,也没有从属于任何 group 元素");
                }
                gp.Left            = GetDouble(group, "left", -1);
                gp.Top             = GetDouble(group, "top", -1);
                gp.Width           = GetDouble(group, "width", -1);
                gp.Height          = GetDouble(group, "height", -1);
                gp.Padding         = GetThickness(group, "padding", new Thickness(8));
                gp.Margin          = GetThickness(group, "margin", new Thickness(0));
                gp.BorderBrush     = GetBrush(group, "borderBrush", new System.Windows.Media.SolidColorBrush(Colors.DarkGray));
                gp.BorderThickness = GetThickness(group, "borderThickness", new Thickness(1));
                gp.CornerRadius    = GetCornerRadius(group, "cornerRadius", new CornerRadius(0));
                gp.OpenBrush       = GetBrush(group,
                                              "openBrush",
                                              new System.Windows.Media.SolidColorBrush(DoorItem.DefaultOpenColor),
                                              (filename) =>
                {
                    string filepath = System.IO.Path.Combine(WpfClientInfo.UserDir, filename);
                    var source      = new BitmapImage(new Uri(filepath));
                    // 转换为物理的 pixel 坐标
                    return(CutBitmap(source, GetImageRect(gp)));
                });
                gp.CloseBrush = GetBrush(group,
                                         "closeBrush",
                                         new System.Windows.Media.SolidColorBrush(DoorItem.DefaultCloseColor),
                                         (filename) =>
                {
                    string filepath = System.IO.Path.Combine(WpfClientInfo.UserDir, filename);
                    var source      = new BitmapImage(new Uri(filepath));
                    // 转换为物理的 pixel 坐标
                    return(CutBitmap(source, GetImageRect(gp)));
                });
                gp.Foreground      = GetBrush(group, "foreground", new System.Windows.Media.SolidColorBrush(DoorItem.DefaultForegroundColor));
                gp.ErrorForeground = GetBrush(group, "errorForeground", new System.Windows.Media.SolidColorBrush(DoorItem.DefaultErrorForegroundColor));

                // 看看 door 是 group 的第几个子元素
                var child_nodes = group.SelectNodes("door");
                int index       = IndexOf(child_nodes, door);
                if (index == -1)
                {
                    throw new Exception("door 元素在 group 下级没有找到");
                }
                double per_height = gp.Height / child_nodes.Count;
                gp.Top    = gp.Top + (index * per_height);
                gp.Height = per_height;
            }

            return(gp);
        }
 // Token: 0x0600023D RID: 573 RVA: 0x000032F6 File Offset: 0x000014F6
 public MemberPositionUpdateView(int groupId, string authToken, int memberCmid, GroupPosition position)
 {
     this.GroupId    = groupId;
     this.AuthToken  = authToken;
     this.MemberCmid = memberCmid;
     this.Position   = position;
 }
Esempio n. 17
0
        public void InitializeButtons(XmlDocument cfg_dom,
                                      List <DoorItem> door_items)
        {
            // 2019/12/22
            this.canvas.Children.Clear();

            // testing
            // door_items = new List<DoorItem>();

            XmlElement root = cfg_dom.DocumentElement;

            CheckAttributes(root, two_attrs);

            double canvas_width  = GetDouble(root, "width", 0);
            double canvas_height = GetDouble(root, "height", 0);

            var doors = cfg_dom.DocumentElement.SelectNodes("//door");

            bool undefined = false;
            int  index     = 0;

            foreach (XmlElement door in doors)
            {
                CheckAttributes(door, all_attrs);

                GroupPosition gp = GetPosition(door);

                if (gp.Left == -1 || gp.Top == -1 || gp.Width == -1 || gp.Height == -1)
                {
                    undefined = true;
                }

                DoorItem door_item = null;
                if (index < door_items.Count)
                {
                    door_item = door_items[index++];
                }

                var button = CreateDoorControl(door, door_item);
                button.Tag = gp;

                if (door_item != null)
                {
                    door_item.BorderBrush = gp.BorderBrush;
                    // if (gp.OpenBrush is SolidColorBrush)
                    door_item.OpenBrush = gp.OpenBrush;        // (gp.OpenBrush as SolidColorBrush).Color;
                                                               // if (gp.CloseBrush is SolidColorBrush)
                    door_item.CloseBrush      = gp.CloseBrush; // (gp.CloseBrush as SolidColorBrush).Color;
                    door_item.BorderThickness = gp.BorderThickness;
                    door_item.CornerRadius    = gp.CornerRadius;
                    door_item.Foreground      = gp.Foreground;
                    door_item.ErrorForeground = gp.ErrorForeground;
                }

                this.canvas.Children.Add(button);
            }

            // 对 -1 进行调整
            if (undefined)
            {
                double x = 0;
                double y = 0;
                foreach (Button button in this.canvas.Children)
                {
                    GroupPosition gp = button.Tag as GroupPosition;
                    if (gp.Left == -1)
                    {
                        gp.Left   = 0;
                        gp.Top    = y;
                        gp.Width  = 20;
                        gp.Height = 10;

                        y += 10;
                    }
                }
                canvas_width  = 20;
                canvas_height = y;
            }

            // 变换为比率
            foreach (Button button in this.canvas.Children)
            {
                GroupPosition gp = button.Tag as GroupPosition;
                gp.Left           /= canvas_width;
                gp.Top            /= canvas_height;
                gp.Width          /= canvas_width;
                gp.Height         /= canvas_height;
                gp.Padding         = Divide(gp.Padding, canvas_width, canvas_height);
                gp.Margin          = Divide(gp.Margin, canvas_width, canvas_height);
                gp.BorderThickness = Divide(gp.BorderThickness, canvas_width, canvas_height);
                gp.CornerRadius    = Divide(gp.CornerRadius, canvas_width, canvas_height);
            }

            // 记忆
            _canvas_width  = canvas_width;
            _canvas_height = canvas_height;

            InitialSize();

            SetBackgroundImage();
        }