Esempio n. 1
0
        public LookupModel(string key, SectorModel sector, LookupRules rules, PlayerModel player, bool readOnly)
            : base(key)
        {
            this.Cards = new ModelCollection(this);

              this.Player = player;
              this.ReadOnly = readOnly;
              this.Sector = sector;
              this.Rules = rules;
              if(rules == null)
            this.Rules = new LookupRules(LookupStyle.All, -1, new List<string>());

              int i = 0;
              switch(rules.Style)
              {
            case LookupStyle.All:
            case LookupStyle.KeepVisibleTop:
            case LookupStyle.Top:
              this.Sector.Cards.CollectionChanged += new CollectionChangedEventHandler(Cards_CollectionChanged);
              for(i = 0; i < sector.Cards.Count(); i++)
              {
            if(this.Rules.Style == LookupStyle.Top && i < Rules.Amount)
              visibleCards.Add(sector.Cards.ElementAt(i).Key);
            InsertCard(sector.Cards.ElementAt(i).Key, i);
              }
              break;
              }
        }
Esempio n. 2
0
        public LookupView(LookupRules rules, bool readOnly, SectorItem sectorItem, string sectorKey, string playerKey)
        {
            InitializeComponent();

              this.rules = rules;
              this.readOnly = readOnly;
              this.sectorItem = sectorItem;
              this.sectorKey = sectorKey;
              this.playerKey = playerKey;

              cardList.MouseDown += new MouseEventHandler(list_MouseDown);
              cardList.MouseMove += new MouseEventHandler(list_MouseMove);
              cardList.MouseUp += new MouseEventHandler(list_MouseUp);
              cardList.SelectedIndexChanged += new EventHandler(cardList_SelectedIndexChanged);
              cardList.DragOver += new DragEventHandler(cardList_DragOver);
              cardList.DragDrop += new DragEventHandler(cardList_DragDrop);
              sortedCardList.MouseDown += new MouseEventHandler(list_MouseDown);
              sortedCardList.MouseMove += new MouseEventHandler(list_MouseMove);
              sortedCardList.MouseUp += new MouseEventHandler(list_MouseUp);
              sortedCardList.OrderList(0);

              btnUp.Enabled = !readOnly;
              btnDown.Enabled = !readOnly;
              btnBottom.Enabled = !readOnly;
              btnSort.Enabled = rules.Style == LookupStyle.All;

              btnSort.Click += new EventHandler(btnSort_Click);
              btnUp.Click += new EventHandler(btnUp_Click);
              btnDown.Click += new EventHandler(btnDown_Click);
              btnBottom.Click += new EventHandler(btnBottom_Click);

              txtQuickSearch.TextChanged += new EventHandler(txtQuickSearch_TextChanged);

              string title = string.Empty;
              switch(rules.Style)
              {
            case LookupStyle.KeepVisibleTop:
            case LookupStyle.Top:
              title = string.Concat(sectorItem.Name, " (" , rules.Amount, ")");
              break;
            case LookupStyle.All:
              title = sectorItem.Name;
              break;
              }
              this.Text = title;

              Localize();
        }
 void Log(SectorModel sector, LookupRules rules)
 {
     string playerName = Receiver.GetPlayerByKey(Invoker).Info.NickName;
       string destinationPlayerName = Receiver.GetPlayerByKey(Arguments.DestinationPlayerKey).Info.NickName;
       bool show = Invoker != Arguments.DestinationPlayerKey;
       string commandName = string.Empty;
       switch(Arguments.Mode)
       {
     case LookupOpenMode.All:
       commandName = Receiver.GetCommandByKey(show ? COMMANDCODE_SHOW_ALL : COMMANDCODE_WATCH_ALL).Data.Name;
       break;
     case LookupOpenMode.KeepVisibleTop:
       commandName = Receiver.GetCommandByKey(COMMANDCODE_KEEP_VISIBLE_TOP).Data.Name;
       break;
     case LookupOpenMode.Top:
       commandName = Receiver.GetCommandByKey(show ? COMMANDCODE_SHOW_TOP : COMMANDCODE_WATCH_TOP).Data.Name;
       break;
       }
       commandName = commandName.Replace("#amount#", Arguments.Amount.ToString());
       string message = string.Concat("[", playerName, "] ", commandName, " (");
       if(!show && sector.Parent.Key != Invoker)
     message += string.Concat(Receiver.GetPlayerByKey(sector.Parent.Key).Info.NickName, "-");
       message += string.Concat(sector.Data.Name, ")");
       if(show)
     message += string.Concat(">", destinationPlayerName);
       Receiver.Console.WriteLog(message);
 }
        public override void Execute()
        {
            SectorModel sector = Receiver.GetSectorByKey(Arguments.SectorKey);
              PlayerModel player = Receiver.GetPlayerByKey(Arguments.DestinationPlayerKey);
              LookupRules rules = null;
              LookupStyle style = LookupStyle.All;
              switch(Arguments.Mode)
              {
            case LookupOpenMode.All: style = LookupStyle.All; break;
            case LookupOpenMode.KeepVisibleTop: style = LookupStyle.KeepVisibleTop; break;
            case LookupOpenMode.Top: style = LookupStyle.Top; break;
              }
              rules = new LookupRules(style, Arguments.Amount, Arguments.CardKeys);
              bool readOnly = sector.Parent.Key != Receiver.ActivePlayer.Key;
              LookupModel lookup = new LookupModel(lookupKey, sector, rules, player, readOnly);
              Receiver.Lookups.Add(lookup);

              Log(sector, rules);
        }
Esempio n. 5
0
 public void OpenSectorLookup(string key, LookupRules rules, string playerKey, bool readOnly, string sectorKey)
 {
     AddLookupArgs args = new AddLookupArgs() { LookupKey = key, Rules = rules, PlayerKey = playerKey, ReadOnly = readOnly, SectorKey = sectorKey };
       if(InvokeRequired)
     Invoke(new Action<AddLookupArgs>(OpenSectorLookup), args);
       else
       {
     try
     {
       OpenSectorLookup(args);
     }
     catch(Exception ex)
     {
       HandleException(ex);
     }
       }
 }