Beispiel #1
0
 public GameBoard()
 {
     this.gameBoard     = new ITile[NumberOfRows, NumberOfColumn];
     this.tileGenerator = new TileGenerator();
     this.hint          = new Hint();
     this.score         = new Score();
 }
Beispiel #2
0
        private Adorner CreateAdornerTooltip(IHint hint, UIElement adornedElement)
        {
            var adorner = _adornerTooltipGenerator.GetAdornerTooltip(hint, adornedElement);

            adorner.Visibility = !IsEnabled ? Visibility.Collapsed : Visibility.Visible;

            return(adorner);
        }
        private Adorner CreateAdornerTooltip(IHint hint, UIElement adornedElement)
        {
            var adorner = _adornerTooltipGenerator.GetAdornerTooltip(hint, adornedElement);

            adorner.SetCurrentValue(UIElement.VisibilityProperty, !IsEnabled ? Visibility.Collapsed : Visibility.Visible);

            return(adorner);
        }
Beispiel #4
0
        private UIElement FindElement(FrameworkElement element, IHint hint)
        {
            Argument.IsNotNull(() => element);
            Argument.IsNotNull(() => hint);

            var dependencyObject = (DependencyObject)element;

            return(dependencyObject.FindVisualDescendant(o => (o is FrameworkElement) && string.Equals(((FrameworkElement)o).Name, hint.ControlName)) as UIElement);
        }
Beispiel #5
0
        public void AddHint <TControlType>(IHint hint)
        {
            Argument.IsNotNull(() => hint);

            var type = typeof(TControlType);

            if (!_hints.ContainsKey(type))
            {
                _hints.Add(type, new List <IHint>());
            }

            _hints[type].Add(hint);
        }
        private string HintToSql(IHint hint, MySqlCommand command)
        {
            if (hint is TimestampRange)
            {
                var range = (TimestampRange)hint;
                var sb    = new StringBuilder();

                if (range.From.HasValue)
                {
                    sb.Append(" created_at >= @TimestampFrom ");
                    command.Parameters.AddWithValue("@TimestampFrom", range.From.Value.Ticks);
                }
                if (range.From.HasValue && range.To.HasValue)
                {
                    sb.Append("AND");
                }
                if (range.To.HasValue)
                {
                    sb.Append(" created_at < @TimestampTo ");
                    command.Parameters.AddWithValue("@TimestampTo", range.To.Value.Ticks);
                }

                return(sb.ToString());
            }
            if (hint is PersistenceIdRange)
            {
                var range = (PersistenceIdRange)hint;
                var sb    = new StringBuilder(" persistence_id IN (");
                var i     = 0;
                foreach (var persistenceId in range.PersistenceIds)
                {
                    var paramName = "@persistence_id" + (i++);
                    sb.Append(paramName).Append(',');
                    command.Parameters.AddWithValue(paramName, persistenceId);
                }
                return(range.PersistenceIds.Count == 0
                    ? string.Empty
                    : sb.Remove(sb.Length - 1, 1).Append(')').ToString());
            }
            else if (hint is WithManifest)
            {
                var manifest = (WithManifest)hint;
                command.Parameters.AddWithValue("@manifest", manifest.Manifest);
                return(" manifest = @manifest");
            }
            else
            {
                throw new NotSupportedException(string.Format("MySql journal doesn't support query with hint [{0}]", hint.GetType()));
            }
        }
Beispiel #7
0
        private void AddAdorneredTooltip(FrameworkElement element, IHint hint)
        {
            var elementWithHint = FindElement(element, hint);

            if (!CanAddAdorner(elementWithHint))
            {
                return;
            }

            var adornerTooltip = CreateAdornerTooltip(hint, elementWithHint);

            _adornerLayer.Add(adornerTooltip);
            _adorneredTooltipsCollection.Add(element, adornerTooltip, IsEnabled);
        }
Beispiel #8
0
        protected virtual string HintToSql(IHint hint, DbCommand command)
        {
            if (hint is TimestampRange)
            {
                var range = (TimestampRange)hint;
                var sb    = new StringBuilder();

                if (range.From.HasValue)
                {
                    sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" >= @TimestampFrom ");
                    AddParameter(command, "@TimestampFrom", DbType.Int64, range.From.Value);
                }
                if (range.From.HasValue && range.To.HasValue)
                {
                    sb.Append("AND");
                }
                if (range.To.HasValue)
                {
                    sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" < @TimestampTo ");
                    AddParameter(command, "@TimestampTo", DbType.Int64, range.To.Value);
                }

                return(sb.ToString());
            }
            if (hint is PersistenceIdRange)
            {
                var range = (PersistenceIdRange)hint;
                var sb    = new StringBuilder(" e.").Append(Configuration.PersistenceIdColumnName).Append(" IN (");
                var i     = 0;
                foreach (var persistenceId in range.PersistenceIds)
                {
                    var paramName = "@Pid" + (i++);
                    sb.Append(paramName).Append(',');
                    AddParameter(command, paramName, DbType.String, persistenceId);
                }
                return(range.PersistenceIds.Count == 0
                    ? string.Empty
                    : sb.Remove(sb.Length - 1, 1).Append(')').ToString());
            }
            else if (hint is WithManifest)
            {
                var manifest = (WithManifest)hint;
                AddParameter(command, "@Manifest", DbType.String, manifest.Manifest);
                return($" e.{Configuration.ManifestColumnName} = @Manifest");
            }
            else
            {
                throw new NotSupportedException($"Sqlite journal doesn't support query with hint [{hint.GetType()}]");
            }
        }
        /*
         *
         * The GetHintString method takes the correct hints supplied by the PickHint method as a parameter
         * and calculates the index of the string according to the GameKnowledgeLevel. As you can see in
         * the DefaultHints.cs, the structure of the list is sorted as follows. For each GameKnowledgeLevel
         * for each class there are three hints depending on the players performance. Therefore we have to
         * add 3 * gameKnowledgeEnum to determine the hint's index.
         *
         */

        private string GetHintString(List <IHint> hints)
        {
            IHint resultHint  = hints[0 + 3 * (int)this.GameKnowledgeLevel];
            IHint checkedHint = hints[1 + 3 * (int)this.GameKnowledgeLevel];
            int   i           = 1;

            while ((i < 3) && this.HintAttributesCheck(checkedHint))
            {
                checkedHint = hints[i + 1 + 3 * (int)this.GameKnowledgeLevel];
                resultHint  = hints[i + 3 * (int)this.GameKnowledgeLevel];
                i          += 1;
            }

            return(resultHint.HintString);
        }
        private string HintToSql(IHint hint, SQLiteCommand command)
        {
            if (hint is TimestampRange)
            {
                var range = (TimestampRange)hint;
                var sb = new StringBuilder();
                
                if (range.From.HasValue)
                {
                    sb.Append(" timestamp >= @TimestampFrom ");
                    command.Parameters.AddWithValue("@TimestampFrom", range.From.Value);
                }
                if (range.From.HasValue && range.To.HasValue) sb.Append("AND");
                if (range.To.HasValue)
                {
                    sb.Append(" timestamp < @TimestampTo ");
                    command.Parameters.AddWithValue("@TimestampTo", range.To.Value);
                }

                return sb.ToString();
            }
            if (hint is PersistenceIdRange)
            {
                var range = (PersistenceIdRange)hint;
                var sb = new StringBuilder(" persistence_id IN (");
                var i = 0;
                foreach (var persistenceId in range.PersistenceIds)
                {
                    var paramName = "@Pid" + (i++);
                    sb.Append(paramName).Append(',');
                    command.Parameters.AddWithValue(paramName, persistenceId);
                }
                return range.PersistenceIds.Count == 0
                    ? string.Empty
                    : sb.Remove(sb.Length - 1, 1).Append(')').ToString();
            }
            else if (hint is WithManifest)
            {
                var manifest = (WithManifest)hint;
                command.Parameters.AddWithValue("@Manifest", manifest.Manifest);
                return " manifest = @Manifest";
            }
            else throw new NotSupportedException(string.Format("Sqlite journal doesn't support query with hint [{0}]", hint.GetType()));
        }
        /*
         *
         * The HintAttributesCheck method takes the checkedHint from GetHintString and compares it with the
         * this.GameResult by calling methods specific to the class type. If the results fit with all the
         * parameters important to the character type then the method return True, otherwise it returns
         * False.
         *
         */

        private bool HintAttributesCheck(IHint checkedHint)
        {
            switch (checkedHint.ClassType)
            {
            case ClassTypeEnum.Duelist:
                return(this.DuelistsHintAtributesCheck((DuelistsHint)checkedHint));

            case ClassTypeEnum.Controller:
                return(this.ControllersHintAtributesCheck((ControllersHint)checkedHint));

            case ClassTypeEnum.Initiator:
                return(this.InitiatorsHintAtributesCheck((InitiatorsHint)checkedHint));

            case ClassTypeEnum.Sentinel:
                return(this.SentinelsHintAtributesCheck((SentinelsHint)checkedHint));
            }

            throw new ArgumentException("Invalid class type.");
        }
        private Adorner CreateAdornerTooltip(IHint hint, UIElement adornedElement)
        {
            var adorner = _adornerTooltipGenerator.GetAdornerTooltip(hint, adornedElement);
            adorner.Visibility = !IsEnabled ? Visibility.Collapsed : Visibility.Visible;

            return adorner;
        }
Beispiel #13
0
        private void ShowHint(int type)
        {
            IHint iHint;
            switch (type)
            {
                case CGtd.TYPE_DATES:
                    if (_UhAlert == null)
                    {
                        _UhAlert = new UhTips();
                        _UhAlert.Dock = DockStyle.Fill;
                    }
                    iHint = _UhAlert;
                    break;
                case CGtd.TYPE_EVENT:
                    if (_UhApps == null)
                    {
                        _UhApps = new UhApps();
                        _UhApps.Dock = DockStyle.Fill;
                    }
                    iHint = _UhApps;
                    break;
                case CGtd.TYPE_MATHS:
                    if (_UhEmail == null)
                    {
                        _UhEmail = new UhMail();
                        _UhEmail.Dock = DockStyle.Fill;
                    }
                    iHint = _UhEmail;
                    break;
                default:
                    return;
            }

            if (_IHint != null)
            {
                NpHint.Controls.Remove(_IHint.Control);
            }
            _IHint = iHint;
            NpHint.Controls.Add(_IHint.Control);
        }
Beispiel #14
0
 public TextBlockAdorner(UIElement uiElement, IHint hint)
     : this(uiElement, hint.Text)
 {
 }
 public Adorner GetAdornerTooltip(IHint hint, UIElement adornedElement)
 {
     return(new TextBlockAdorner(adornedElement, hint));
 }
Beispiel #16
0
    } // Ende des Konstruktor's.

    /// <summary>
    /// Dies ist der Copy-Konstruktor.
    /// </summary>
    /// <param name="hint">Der zu kopierende Hint.</param>
    public Hint(IHint hint)
    {
        this.l_iX = hint.getX();
        this.l_iY = hint.getY();
        this.l_sValue = hint.getValue();
        this.setMessage(hint.getMessage());
    } // Ende des Konstruktor's.
Beispiel #17
0
 public TextBlockAdorner(UIElement uiElement, IHint hint)
     : this(uiElement, hint.Text)
 {
 }
        private void AddAdorneredTooltip(FrameworkElement element, IHint hint)
        {
            var elementWithHint = FindElement(element, hint);
            if (!CanAddAdorner(elementWithHint))
            {
                return;
            }

            var adornerTooltip = CreateAdornerTooltip(hint, elementWithHint);
            _adornerLayer.Add(adornerTooltip);
            _adorneredTooltipsCollection.Add(element, adornerTooltip, IsEnabled);
        }
        private UIElement FindElement(FrameworkElement element, IHint hint)
        {
            Argument.IsNotNull(() => element);
            Argument.IsNotNull(() => hint);

            var dependencyObject = (DependencyObject) element;

            return dependencyObject.FindVisualDescendant(o => (o is FrameworkElement) && string.Equals(((FrameworkElement)o).Name, hint.ControlName)) as UIElement;
        }
Beispiel #20
0
 public virtual int CompareTo(IHint hint)
 {
     return(this.Uid.CompareTo(hint.Uid));
 }
 public Adorner GetAdornerTooltip(IHint hint, UIElement adornedElement)
 {
     return new TextBlockAdorner(adornedElement, hint);
 }
Beispiel #22
0
 public virtual RetCode AddHint(IHint hint, bool makeCopy = false)
 {
     return(AddRecord(HintTable, hint, makeCopy));
 }
Beispiel #23
0
        protected virtual string HintToSql(IHint hint, DbCommand command)
        {
            if (hint is TimestampRange)
            {
                var range = (TimestampRange)hint;
                var sb = new StringBuilder();

                if (range.From.HasValue)
                {
                    sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" >= @TimestampFrom ");
                    AddParameter(command, "@TimestampFrom", DbType.Int64, range.From.Value);
                }
                if (range.From.HasValue && range.To.HasValue) sb.Append("AND");
                if (range.To.HasValue)
                {
                    sb.Append(" e.").Append(Configuration.TimestampColumnName).Append(" < @TimestampTo ");
                    AddParameter(command, "@TimestampTo", DbType.Int64, range.To.Value);
                }

                return sb.ToString();
            }
            if (hint is PersistenceIdRange)
            {
                var range = (PersistenceIdRange)hint;
                var sb = new StringBuilder(" e.").Append(Configuration.PersistenceIdColumnName).Append(" IN (");
                var i = 0;
                foreach (var persistenceId in range.PersistenceIds)
                {
                    var paramName = "@Pid" + (i++);
                    sb.Append(paramName).Append(',');
                    AddParameter(command, paramName, DbType.String, persistenceId);
                }
                return range.PersistenceIds.Count == 0
                    ? string.Empty
                    : sb.Remove(sb.Length - 1, 1).Append(')').ToString();
            }
            else if (hint is WithManifest)
            {
                var manifest = (WithManifest)hint;
                AddParameter(command, "@Manifest", DbType.String, manifest.Manifest);
                return $" e.{Configuration.ManifestColumnName} = @Manifest";
            }
            else throw new NotSupportedException($"Sqlite journal doesn't support query with hint [{hint.GetType()}]");
        }