Inheritance: IGroupAction
コード例 #1
0
ファイル: GameSerializer.cs プロジェクト: rexperalta/OCTGN
 internal IEnumerable<IGroupAction> DeserializeGroupActionGroup(actionSubmenu actiongroup, bool isGroup)
 {
     var ret = new List<IGroupAction>();
     foreach (var item in actiongroup.Items)
     {
         if (item is action)
         {
             var i = item as action;
             var add = new GroupAction
             {
                 Name = i.menu,
                 Shortcut = i.shortcut,
                 Execute = i.execute,
                 BatchExecute = i.batchExecute,
                 ShowIf = i.showIf,
                 DefaultAction = bool.Parse([email protected]())
             };
             add.IsGroup = isGroup;
             ret.Add(add);
         }
         if (item is actionSubmenu)
         {
             var i = item as actionSubmenu;
             var addgroup = new GroupActionGroup { Children = new List<IGroupAction>(), Name = i.menu };
             addgroup.IsGroup = isGroup;
             addgroup.Children = this.DeserializeGroupActionGroup(i, isGroup);
             ret.Add(addgroup);
         }
     }
     return ret;
 }
コード例 #2
0
ファイル: GameSerializer.cs プロジェクト: rexperalta/OCTGN
 internal Group DeserialiseGroup(group grp, int id)
 {
     if (grp == null)
         return null;
     var ret = new Group
     {
         Id = (byte)id,
         Name = grp.name,
         Background = grp.background == null ? null : Path.Combine(directory, grp.background),
         BackgroundStyle = grp.backgroundStyle.ToString(),
         Collapsed = bool.Parse(grp.collapsed.ToString()),
         Height = Int32.Parse(grp.height),
         Width = Int32.Parse(grp.width),
         Icon = grp.icon == null ? null : Path.Combine(directory, grp.icon),
         Ordered = bool.Parse(grp.ordered.ToString()),
         Shortcut = grp.shortcut,
         MoveTo = bool.Parse(grp.moveto.ToString()),
         CardActions = new List<IGroupAction>(),
         GroupActions = new List<IGroupAction>()
     };
     if (ret.Width == 0)
     {
         ret.Width = 1;
     }
     if (ret.Height == 0)
     {
         ret.Height = 1;
     }
     if (grp.Items != null)
     {
         foreach (var item in grp.Items)
         {
             if (item is action)
             {
                 var i = item as action;
                 var to = new GroupAction
                              {
                                  Name = i.menu,
                                  Shortcut = i.shortcut,
                                  ShowIf = i.showIf,
                                  BatchExecute = i.batchExecute,
                                  Execute = i.execute,
                                  DefaultAction = bool.Parse([email protected]())
                              };
                 if (item is cardAction)
                 {
                     to.IsGroup = false;
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupAction)
                 {
                     to.IsGroup = true;
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
             else if (item is actionSubmenu)
             {
                 var i = item as actionSubmenu;
                 var to = new GroupActionGroup
                 {
                     Children = new List<IGroupAction>(),
                     Name = i.menu,
                     ShowIf = i.showIf,
                 };
                 if (item is cardActionSubmenu)
                 {
                     to.IsGroup = false;
                     to.Children = this.DeserializeGroupActionGroup(i, false);
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupActionSubmenu)
                 {
                     to.IsGroup = true;
                     to.Children = this.DeserializeGroupActionGroup(i, true);
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
             else if (item is actionSeparator)
             {
                 var separator = new GroupActionSeparator {
                     ShowIf = item.showIf,
                 };
                 if (item is groupActionSeparator)
                 {
                     separator.IsGroup = true;
                     (ret.GroupActions as List<IGroupAction>).Add(separator);
                 }
                 else if (item is cardActionSeparator)
                 {
                     separator.IsGroup = false;
                     (ret.CardActions as List<IGroupAction>).Add(separator);
                 }
             }
         }
     }
     switch (grp.visibility)
     {
         case groupVisibility.none:
             ret.Visibility = GroupVisibility.Nobody;
             break;
         case groupVisibility.me:
             ret.Visibility = GroupVisibility.Owner;
             break;
         case groupVisibility.all:
             ret.Visibility = GroupVisibility.Everybody;
             break;
         case groupVisibility.undefined:
             ret.Visibility = GroupVisibility.Undefined;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return ret;
 }
コード例 #3
0
ファイル: GroupControl.cs プロジェクト: karlnp/OCTGN
        private void CreateContextMenus()
        {
            _cardHeader = null;
            _defaultGroupAction = _defaultCardAction = null;

            var def = group.Definition;

            // Create the card actions
            List<Control> cardItems = CreateCardMenuItems(def);
            _cardMenu.Collection = cardItems;

            // Create the group actions
            List<Control> groupItems = CreateGroupMenuItems(def);
            _groupMenu.Collection = groupItems;
        }
コード例 #4
0
ファイル: GroupControl.cs プロジェクト: karlnp/OCTGN
        private MenuItem CreateCardMenuItem(IGroupAction baseAction)
        {
            var item = new MenuItem {Header = baseAction.Name};

            var actionGroupDef = baseAction as GroupActionGroup;
            if (actionGroupDef != null)
            {
                foreach (MenuItem subItem in actionGroupDef.Children.Select(CreateCardMenuItem))
                    item.Items.Add(subItem);
                return item;
            }

            var action = baseAction as GroupAction;
            item.Tag = action;
            if (action != null)
            {
                item.InputGestureText = action.Shortcut;
                if (action.DefaultAction)
                {
                    item.FontWeight = FontWeights.Bold;
                    _defaultCardAction = action;
                }
            }
            item.Click += CardActionClicked;
            return item;
        }
コード例 #5
0
ファイル: GameSerializer.cs プロジェクト: sbarnabas/OCTGN
 internal Group DeserialiseGroup(group grp, int id)
 {
     var ret = new Group
     {
         Id = (byte)id,
         Name = grp.name,
         Background = grp.background == null ? null : Path.Combine(directory, grp.background),
         BackgroundStyle = grp.backgroundStyle.ToString(),
         Board = grp.board == null ? null : Path.Combine(directory, grp.board),
         BoardPosition = grp.boardPosition == null ? new DataRectangle { X = 0, Y = 0, Height = 0, Width = 0 } :
             new DataRectangle
             {
                 X = double.Parse(grp.boardPosition.Split(',')[0]),
                 Y = double.Parse(grp.boardPosition.Split(',')[1]),
                 Width = double.Parse(grp.boardPosition.Split(',')[2]),
                 Height = double.Parse(grp.boardPosition.Split(',')[3])
             },
         Collapsed = bool.Parse(grp.collapsed.ToString()),
         Height = Int32.Parse(grp.height),
         Width = Int32.Parse(grp.width),
         Icon = grp.icon == null ? null : Path.Combine(directory, grp.icon),
         Ordered = bool.Parse(grp.ordered.ToString()),
         Shortcut = grp.shortcut,
         CardActions = new List<IGroupAction>(),
         GroupActions = new List<IGroupAction>()
     };
     if (grp.Items != null)
     {
         foreach (var item in grp.Items)
         {
             if (item is action)
             {
                 var i = item as action;
                 var to = new GroupAction
                              {
                                  Name = i.menu,
                                  Shortcut = i.shortcut,
                                  BatchExecute = i.batchExecute,
                                  Execute = i.execute,
                                  DefaultAction = bool.Parse([email protected]())
                              };
                 if (item is cardAction)
                 {
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupAction)
                 {
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
             else if (item is actionSubmenu)
             {
                 var i = item as actionSubmenu;
                 var to = new GroupActionGroup { Children = new List<IGroupAction>(), Name = i.menu };
                 to.Children = this.DeserializeGroupActionGroup(i);
                 if (item is cardActionSubmenu)
                 {
                     (ret.CardActions as List<IGroupAction>).Add(to);
                 }
                 else if (item is groupActionSubmenu)
                 {
                     (ret.GroupActions as List<IGroupAction>).Add(to);
                 }
             }
         }
     }
     switch (grp.visibility)
     {
         case groupVisibility.none:
             ret.Visibility = GroupVisibility.Nobody;
             break;
         case groupVisibility.me:
             ret.Visibility = GroupVisibility.Owner;
             break;
         case groupVisibility.all:
             ret.Visibility = GroupVisibility.Everybody;
             break;
         case groupVisibility.undefined:
             ret.Visibility = GroupVisibility.Undefined;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return ret;
 }