Example #1
0
        public override void UpdateLayout()
        {
            //Log.Message($"Layout Update: {NamePrefix()}");

            needsUpdateLayout = false;

            //UpdateLayoutConstraintsIfNeeded();

            base.UpdateLayout();
            try
            {
                Solver.Solve();
                InErrorState = false;
            }
            catch (Exception e)
            {
                InErrorState = true;
                var sb = new StringBuilder();
                sb.AppendLine($"{e.GetType().Name} thrown during constraints solving: {e.Message}");
                sb.AppendLine($"{e.StackTrace}");
                sb.AppendLine();
                sb.AppendLine($"solver's constraints:\n{string.Join("\n", Solver.AllConstraints().Select(x => x.ToString()))}");
                Log.Error(sb.ToString());

                if (solver == Solver)
                {
                    var copy = solver.AllConstraints().ToArray();
                    solver = null;
                    Solver.AddConstraints(copy);
                    Log.Warning("solver reseted");
                }

                if (!retry)
                {
                    retry = true;
                    UpdateLayout();
                    retry = false;
                }
            }
        }
Example #2
0
 public string AllConstraintsString()
 {
     return(string.Join("\n", Solver.AllConstraints().Select(x => x.ToString())));
 }
Example #3
0
 public ClConstraint[] AllConstraintsDebug()
 {
     return(Solver.AllConstraints());
 }