예제 #1
0
        private static Inline BuildFont(ElementToken token, Hint hint)
        {
            var span = new Span();

            string size;
            if (token.Attributes.TryGetValue("size", out size))
            {
                var fc = new FontSizeConverter();
                var sz = (double)fc.ConvertFromString(size);
                span.FontSize = sz;
            }

            string face;
            if (token.Attributes.TryGetValue("face", out face))
            {
                span.FontFamily = new FontFamily(face);
            }

            string color;
            if (token.Attributes.TryGetValue("color", out color))
            {
                var bc = new BrushConverter();
                var br = (Brush)bc.ConvertFromString(color);
                span.Foreground = br;
            }
            return span.Fill(token, hint);
        }
        void IIntrinsicSupport.EmitJcc(InstructionCode code, Label label, Hint hint)
        {
            Contract.Requires(label != null);
            Contract.Requires(hint == Hint.None || hint == Hint.NotTaken || hint == Hint.Taken);

            throw new NotImplementedException();
        }
예제 #3
0
	// Update is called once per frame
	void Update ()
    {
        fIdleTimer      += Time.deltaTime;

        if(iWrongAttemps >= iWrongAttempsCap || fIdleTimer > iIdleTimerCap)
        {
            iWrongAttemps = 0;
            fIdleTimer = 0.0f;

            CalcSquare calcSquare = Playboard.getCalcSquare();
            Hint newHint = calcSquare.getHint_new();
            if (calcSquare != null && newHint != null)
            {
               
                int hintValueMin = Mathf.Clamp(int.Parse(newHint.getValue()) - Random.Range(2, 5), 1, 9);
                int hintValueMax = Mathf.Clamp(int.Parse(newHint.getValue()) + Random.Range(2, 5), 1, 9);
                //newHint.setMessage("Probier doch mal an der Gelb markierten Stelle eine Zahl zwischen " + hintValueMin.ToString() + " und " + hintValueMax.ToString());
                Image btnNewImage = Playboard.instance.transform.GetChild(newHint.getY() * (int)calcSquare.uiFieldSize_Y + newHint.getX()).GetChild(0).GetChild(0).GetComponent<Image>();
                btnNewImage.color = Color.yellow;
                hintText.text = "Probier doch mal an der Gelb markierten Stelle eine Zahl zwischen " + hintValueMin.ToString() + " und " + hintValueMax.ToString();// newHint.getMessage();

                if(lastHint != null)
                {
                    Image btnLastImage = Playboard.instance.transform.GetChild(lastHint.getY() * (int)calcSquare.uiFieldSize_Y + lastHint.getX()).GetChild(0).GetChild(0).GetComponent<Image>();
                    btnLastImage.color = Color.white;
                }
                
                lastHint = newHint;
            }
            else
            {
                Debug.Log("NO HINT!");
            }
        }
    }
예제 #4
0
 private HintDialog(Window parent, Hint hint)
     : base("Hint", parent, DialogFlags.Modal)
 {
     this.Build();
     this.hintAlignment.Remove(textviewHint);
     this.textviewHint.Buffer.Text = HintList.Hints[hint];
     this.hintAlignment.Add(textviewHint);
 }
예제 #5
0
 public Question(int nyQuestion_id, char nyOperationType, string nyQuestion, string nyAnswer, string[] hints)
 {
     question_id = nyQuestion_id;
     operationType = nyOperationType;
     question = nyQuestion;
     answer = nyAnswer;
     hint = new Hint(hints, nyQuestion_id);
 }
예제 #6
0
 public static HintReadDto MapToReadDto(this Hint hint)
 {
     return(new HintReadDto
     {
         Id = hint.Id,
         Content = hint.Content,
         QuestionId = hint.QuestionId
     });
 }
예제 #7
0
        public void create_hint(string errorMessage, int lineNumber)
        {
            Range range = new Range(fctb, lineNumber);

            fctb.Hints.Clear();
            Hint hint = new Hint(range, errorMessage, true, true);

            fctb.Hints.Add(hint);
        }
예제 #8
0
        /// <summary>
        /// Set Error marker on code for Java. returns True on success False otherwise.
        /// </summary>
        public static bool SetJavaCodeError(FastColoredTextBox code, Range message, bool focus = false)
        {
            try
            {
                //split data in parts separated by ':'
                string   data = message.Text;
                string[] part = data.Split(new char[] { ':' });

                //usually row and col is on first two parts
                int row = int.Parse(part[0]) - 1; // <-- throws exception on failure

                //check if rest of the data is not empty
                string rest = string.Join(" ", part, 1, part.Length - 1);
                if (rest.Trim().Length == 0)
                {
                    return(false);
                }

                //get line by row number
                string line = code.Lines[row].TrimEnd();
                //get last of the message
                Place stop = new Place(line.Length, row);
                //we need to move start point where first  non-space character found
                int col = 0; while (col < line.Length && line[col] == ' ')
                {
                    ++col;
                }
                Place start = new Place(col, row);
                //get range from start to stop
                Range range = code.GetRange(start, stop);

                //show zigzag lines under the errors
                range.SetStyle(HighlightSyntax.LineErrorStyle);

                //focus current and exit
                if (focus)
                {
                    code.ExpandBlock(row);
                    code.Selection = range;
                    code.DoRangeVisible(range, true);
                }

                // add hints
                if (Properties.Settings.Default.EditorShowHints)
                {
                    Hint hdat = code.AddHint(range, data, focus, true, true);
                    hdat.Tag         = message;
                    hdat.BorderColor = Color.LightBlue;
                    hdat.BackColor   = Color.AliceBlue;
                    hdat.BackColor2  = Color.PowderBlue;
                }

                return(true);
            }
            catch { return(false); }
        }
예제 #9
0
        private IEnumerable <Hint> GetHints(IEnumerable <Rectangle> hintsBoundaries)
        {
            List <Rectangle> boundariesList        = hintsBoundaries.ToList();
            int maxHintBoxWidth                    = boundariesList.Max(h => h.Width);
            int approximateMaxDistanceBetweenHints = maxHintBoxWidth / 2;
            IEnumerable <MatrixRow> hintRows       = SplitBoxesToRows(boundariesList, 4);
            List <MatrixRow>        hintRowsList   = hintRows.ToList();

            List <Hint> hints = new List <Hint>();

            foreach (MatrixRow hintRow in hintRowsList)
            {
                List <Rectangle> rowList = hintRow.Row
                                           .OrderBy(r => r.X)
                                           .ToList();

                List <Rectangle> maxCurrentCandidate = new List <Rectangle>();
                int limit = hintRow.Row.Count();

                for (int i = 0; i < limit; i++)
                {
                    Rectangle currentRectangle = rowList[i];
                    maxCurrentCandidate.Add(currentRectangle);

                    if (i == limit - 1)
                    {
                        Hint hint = new Hint()
                        {
                            HintSize      = maxCurrentCandidate.Count,
                            BoundingBoxes = maxCurrentCandidate
                        };

                        hints.Add(hint);
                        break;
                    }

                    Rectangle nextRectangle = rowList[i + 1];
                    int       distanceBetweenPreviousXEndPointAndCurrentStartingPoint = nextRectangle.X - (currentRectangle.X + currentRectangle.Width);
                    int       widthDifference = Math.Abs(nextRectangle.Width - currentRectangle.Width);

                    if (distanceBetweenPreviousXEndPointAndCurrentStartingPoint >= widthDifference + approximateMaxDistanceBetweenHints)
                    {
                        Hint hint = new Hint
                        {
                            HintSize      = maxCurrentCandidate.Count,
                            BoundingBoxes = maxCurrentCandidate
                        };

                        hints.Add(hint);
                        maxCurrentCandidate = new List <Rectangle>();
                    }
                }
            }

            return(hints);
        }
예제 #10
0
 // game3.js: override this on your class
 public override void StartGame3js()
 {
     switch (GameStateManager.GameState)
     {
     case GameState.Intro:
         GameStateManager.GameState = GameState.Game3jsReady;
         Hint.SetActive(true);
         break;
     }
 }
 public FProgressBar()
 {
     ValueChanged += delegate
     {
         if (Hint == null || Hint.EndsWith(" %"))
         {
             Hint = ((int)(Value / Maximum * 100)).ToString() + " %";
         }
     };
 }
예제 #12
0
 public static void StaticListCleanup()
 {
     SymbolList.Clear ();
     ConnectionList.Clear ();
     HintList.Clear ();
     HintMap.Clear ();
     SelectedHint = null;
     FieldManager.lineConnectionList.Clear ();
     FieldManager.symbolPositionList.Clear ();
 }
예제 #13
0
    /// <summary>
    /// Removes the specified hint from the current task without raising any events.
    /// Saves treasure hunt after removing the hint.
    /// </summary>
    /// <param name="hint"></param>
    public void SilentlyRemoveHint(Hint hint)
    {
        CurrentTask.AllHints.Remove(hint);
        CurrentTask.RevealedHints.Remove(hint);
        CurrentTask.UnrevealedHints.Remove(hint);

        CurrentHint = null;

        SaveTreasureHunt();
    }
예제 #14
0
        public void UpdateHint(Hint entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            _dbContext.Update(entity);
            _dbContext.Entry(entity).State = EntityState.Modified;
        }
예제 #15
0
        //
        // Generate a puzzle of a specific difficulty
        //
        public void OnGeneratePuzzle(EDifficulty difficulty)
        {
            puzzle = creator.GeneratePuzzle(difficulty);

            Check.SetCanExecute(true);
            Hint.SetCanExecute(true);
            Query.SetCanExecute(true);

            OnReset();
        }
예제 #16
0
        private static Inline BuildSymbol(ElementToken token, Hint hint)
        {
            string spanClass = token.Attributes["span-class"];
            string value     = token.Text;

            return(new Run(value)
            {
                Foreground = hint.MapBrush(spanClass)
            });
        }
예제 #17
0
    public void HideHint(string hint_name)
    {
        Hint hint = this.FindHint(hint_name);

        if (hint == null)
        {
            return;
        }
        this.m_HUDHint.HideHint(hint);
    }
 public static void SetDefaultVal()
 {
     setDefault();
     Storage.SetDefaultValue();
     Score.SetDefaultRecord();
     MessageSystemGameBlock.SetDefaultValue();
     Hint.SetDefaultValue();
     TapToGo.SetDefaulValue();
     OpenMenu.NumberOperation = 0;
 }
        public void ImportFile(FileInfo file, Main db)
        {
            using (StreamReader sr = file.OpenText())
            {
                string s;
                var count = 0;
                QuizQuestion question = null;
                while ((s = sr.ReadLine()) != null)
                {
                    s = s.Trim();
                    ++count;

                    // Skip Header
                    if (count < 4) { continue; }

                    if (count % 3 == 1)
                    {
                        question = new QuizQuestion();
                        db.QuizQuestions.InsertOnSubmit(question);

                        // Line 1: Question
                        question.Question = s;
                        if (Language != null)
                        {
                            question.Language = Language;
                        }
                        if (Author != null)
                        {
                            question.Author = Author;
                        }
                    }

                    if (count % 3 == 2 && question != null)
                    {
                        // Line 2: Answer (manual work needed)
                        question.Answer = s;
                        db.SubmitChanges();
                    }

                    if (count % 3 == 0 && question != null && question.ID.HasValue && !s.IsNullOrEmpty())
                    {
                        // Line 3: A Hint
                        var hint = new Hint();
                        db.Hints.InsertOnSubmit(hint);

                        hint.Message = s;
                        hint.QuizQuestionID = question.ID.Value;

                        db.SubmitChanges();
                    }
                }

                db.SubmitChanges();
            }
        }
예제 #20
0
 public MiProgressBar()
 {
     ControlUtility.Refresh(this);
     ValueChanged += delegate
     {
         if (Hint == null || Hint.EndsWith(" %"))
         {
             Hint = ((int)(Value / Maximum * 100)).ToString() + " %";
         }
     };
 }
예제 #21
0
 void Start()
 {
     isColumnBomb = false;
     isRowBomb    = false;
     isColorBomb  = false;
     isBigBomb    = false;
     board        = FindObjectOfType <Board>();
     find         = FindObjectOfType <FindMatches>();
     hint         = FindObjectOfType <Hint>();
     end          = FindObjectOfType <EndGameManager>();
 }
예제 #22
0
    void ReplaceHint(Vector3 pos)
    {
        if (FindObjectOfType <Hint>() != null)
        {
            Hint oldHint = FindObjectOfType <Hint>();
            Destroy(oldHint.gameObject);
        }


        GameObject hintObject = Instantiate(hint, pos, Quaternion.identity, hintParent.transform);
    }
예제 #23
0
 public void HideHint(Hint hint)
 {
     foreach (Hint hint2 in this.m_HintsQueue)
     {
         if (hint2.m_Name == hint.m_Name)
         {
             this.m_HintsQueue.Remove(hint2);
             break;
         }
     }
 }
예제 #24
0
 private void OnMouseDown()
 {
     Hint.PlayClip();
     DisableButtons();
     isPause = true;
     MessageSystemGameBlock.SaveSpeed();
     MessageSystemGameBlock.StopGame();
     MessageSystemPlayingScene.Player.GetComponent <Animator>().speed = 0;
     Go.SetActive(true);
     gameObject.SetActive(false);
 }
예제 #25
0
        public void Hints_Employees(Hint hint)
        {
            //Переход на страницу Сотрудники
            //не требуется для админа
            //  app.hintHelper.moveToHint("Employees.MoreFilters");

            Hint testHint = app.hintHelper.getHint("Employees.MoreFilters");

            //Проверка соответствия двух отпусков.
            Assert.IsTrue(app.hintHelper.CompareHints(hint, testHint));
        }
예제 #26
0
        public void SceneLoader_HintStructure_Class_Create_and_Add_to_ListTest()
        {
            var hint = new Hint();

            hint.duration = 2.0f;
            hint.text     = "TestHint";
            var hints = new Hints();

            hints.items.Add(hint);

            Assert.IsNotEmpty(hints.items);
        }
예제 #27
0
        private static Inline GetInline(ParseToken token, Hint hint)
        {
            if (token is TextToken)
            {
                var tt = (TextToken)token;
                return(new Run(tt.Text));
            }
            if (token is ElementToken)
            {
                var et = (ElementToken)token;
                switch (et.Name)
                {
                case "b":
                    return(new Bold().Fill(et, hint));

                case "u":
                    return(new Underline().Fill(et, hint));

                case "i":
                    return(new Italic().Fill(et, hint));

                case "lb":
                    return(new LineBreak());

                case "code":
                    return(new Span {
                        FontFamily = new FontFamily("Consolas"), FontSize = 12.0d * (96d / 72d)
                    }.Fill(et, hint));

                case "font":
                    return(BuildFont(et, hint));

                case "keyword":
                    return(new Span {
                        Foreground = Brushes.Blue
                    }.Fill(et, hint));

                //case "span":
                case "hint":
                    return(BuildHint(et, hint));

                case "ref":
                    return(BuildRef(et, hint));

                case "params":
                    return(BuildParam(et, hint));

                default:
                    throw new NotSupportedException(et.Name);
                }
            }
            throw new NotSupportedException();
        }
예제 #28
0
        // GENERATE VALUES
        //
        public void generateValues(DataElement obj)
        {
            // 1. Get filename in hint
            // 2. Run function to add values in filename to list

            Hint h = null;

            if (obj.Hints.TryGetValue("WordList", out h))
            {
                AddListToValues(h.Value);
            }
        }
예제 #29
0
 public IActionResult Modify([FromBody] Hint item)
 {
     try
     {
         hintRepository.Add(item);
     }
     catch (Exception)
     {
         return(BadRequest("Error while creating"));
     }
     return(Ok(item));
 }
예제 #30
0
 public void TriggerHint()
 {
     if (!wasActivated && !NetGame.isClient)
     {
         if (activeHint != null)
         {
             activeHint.StopHint();
         }
         activeHint     = this;
         timerCoroutine = StartCoroutine(HintCoroutine());
     }
 }
예제 #31
0
 public void Setup()
 {
     for (int i = 0; i < ELSingleton <XmlSettings> .Instance.hintsConfig.Count; i++)
     {
         Hint hint = new Hint();
         hint.type        = ELSingleton <XmlSettings> .Instance.hintsConfig[i].type;
         hint.coins       = ELSingleton <XmlSettings> .Instance.hintsConfig[i].coins;
         hint.amount      = ELSingleton <XmlSettings> .Instance.hintsConfig[i].initial;
         hint.isAvailable = false;
         hints.Add(hint);
     }
 }
예제 #32
0
 public void LoginResult(int code)
 {
     if (code == 0)
     {
         Hint.GetInstance().Show("不错嘛,跟我来!", "Not bad, follow me!");
         LoginSuccess();
     }
     else
     {
         Hint.GetInstance().Show("用户名不存在啊!", "User is not exist!");
     }
 }
예제 #33
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (this.hintCollection != null)
     {
         Hint                = new Hint();
         Hint.Text           = textTbx.Text;
         Hint.HintCollection = hintCollection;
         Hint                = (Hint)modelService.SaveDomainObject(Hint);
         hintCollection.Hints.Add(this.Hint);
     }
     Close();
 }
예제 #34
0
 public void InitializeHints()
 {
     hintCoffeText.text = Order.GetCoffeeName(orderedCoffe.CoffeeType.ToString());
     foreach (var ingredient in orderedCoffe.IngredientsToMakeCoffee)
     {
         GameObject hintGO = Instantiate(hintPrefab, hintSpawnTransfom);
         Hint       hint   = hintGO.GetComponent <Hint>();
         hint.InitializeHint(ingredient.IngredientAmount.ToString(), ingredient.Sprite);
         hints.Add(hint);
     }
     OnShowHint.Invoke(null);
 }
예제 #35
0
	void Start() {
		Debug.Log (filename);
		GetWords ();
		SpawnObjects ();
		showedTutorial = false;
		currentHint = null;
		InputField field = unscramble.transform.GetChild (0).GetComponent<InputField> ();
		Text par = field.transform.parent.parent.GetComponent<Text> ();
		par.gameObject.SetActive (false);
		cageDoorText.transform.parent.gameObject.SetActive (false);
		transitionText.gameObject.SetActive (false);
	}
예제 #36
0
        public async Task <IActionResult> Create([Bind("Content", "CorrectAnswer")] Hint hint, int qid)
        {
            if (ModelState.IsValid)
            {
                hint.QuestionID = qid;
                _context.Add(hint);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", new { questionid = qid }));
            }
            return(View(hint));
        }
예제 #37
0
 public Hint FindHint(string hint_name)
 {
     for (int i = 0; i < this.m_Hints.Count; i++)
     {
         Hint hint = this.m_Hints[i];
         if (hint.m_Name == hint_name)
         {
             return(hint);
         }
     }
     return(null);
 }
예제 #38
0
        private void button2_Click(object sender, EventArgs e)
        {
            fctb.Hints.Clear();
            foreach (var r in fctb.GetRanges(tbFind.Text))
            {
                Hint hint;
                if (cbSimple.Checked)
                    hint = new Hint(r, "This is hint " + fctb.Hints.Count, cbInline.Checked, cbDock.Checked);
                else
                    hint = new Hint(r, new CustomHint(), cbInline.Checked, cbDock.Checked);

                fctb.Hints.Add(hint);
            }
        }
예제 #39
0
        public static void ShowHint(Window parent,
            Hint hint,
            bool forceShowHint = false)
        {
            if (!HintList.Hints.ShouldShowHint(hint) &&
                !forceShowHint)
                return;

            if (!AppSettings.Main.EnableHints)
                return;

            HintDialog dialog = new HintDialog(parent, hint);
            dialog.Response += (o, args) => dialog.Destroy();
            dialog.Run();
            HintList.Hints.SetShowHint(hint, !dialog.DontShowAgain);
        }
예제 #40
0
        private static Inline BuildHint(ElementToken token, Hint hint)
        {
            Trace.Assert(token.Name == "hint");

            string handler;
            token.Attributes.TryGetValue("handler", out handler);

            string key;
            token.Attributes.TryGetValue("key", out key);

            string value = token.Attributes["value"];

            var hc = key == null ? new HintControl(token.ToString(), handler)
                                                     : new HintControl(key, hint.RaiseGetHintContent, handler);
            //Fill(hc.Inlines, token);
            hc.Inlines.Add(new Run(value));
            return new InlineUIContainer { Child = hc };
        }
예제 #41
0
        private static Inline BuildParam(ElementToken token, Hint hint)
        {
            var pp = new ParamPanel();
            foreach (ParseToken pt in token.Tokens)
            {
                var et = pt as ElementToken;
                if (et != null)
                {
                    var tb = new TextBlock().Fill(et, hint);
                    pp.Children.Add(tb);
                    if (et.Name == "pname")
                        ParamPanel.SetNameColumn(tb, true);

                    continue;
                }

                var tt = pt as TextToken;
                if (tt != null && pp.Children.Count > 0)
                {
                    var elem = pp.Children[pp.Children.Count - 1] as TextBlock;
                    if (elem != null)
                        elem.Inlines.Add(GetInline(tt, hint));

                    continue;
                }
            }

            var span = new Span();
            span.Inlines.Add(new SoftBreak());
            span.Inlines.Add(new InlineUIContainer
                                             {
                                                 Child = pp,
                                                 BaselineAlignment = BaselineAlignment.Bottom
                                             });
            span.Inlines.Add(new SoftBreak());
            return span;
        }
예제 #42
0
 private static Span Fill(this Span span, ElementToken token, Hint hint)
 {
     Fill(span.Inlines, token, hint);
     return span;
 }
 public HintClickEventArgs(Hint hint)
 {
     Hint = hint;
 }
예제 #44
0
 public static FrameworkElement Build(RootToken rootToken, Hint hint)
 {
     var textBlock = new TextBlock().Fill(rootToken, hint);
     textBlock.TextWrapping = TextWrapping.WrapWithOverflow;
     return new HintDecorator { Child = textBlock };
 }
예제 #45
0
        public void SetShowHint(Hint id, bool show)
        {
            if (show)
                disabledHints.Remove(id.ToString());
            else
            {
                if (!disabledHints.Contains(id.ToString()))
                    disabledHints.Add(id.ToString());
            }

            Save();
        }
예제 #46
0
 private static void Fill(InlineCollection inlines, ElementToken token, Hint hint)
 {
     foreach (var t in token.Tokens)
     {
         inlines.Add(GetInline(t, hint));
     }
 }
예제 #47
0
 private static Inline GetInline(ParseToken token, Hint hint)
 {
     if (token is TextToken)
     {
         var tt = (TextToken)token;
         return new Run(tt.Text);
     }
     if (token is ElementToken)
     {
         var et = (ElementToken)token;
         switch (et.Name)
         {
             case "b":
                 return new Bold().Fill(et, hint);
             case "u":
                 return new Underline().Fill(et, hint);
             case "i":
                 return new Italic().Fill(et, hint);
             case "lb":
                 return new LineBreak();
             case "code":
                 return new Span { FontFamily = new FontFamily("Consolas"), FontSize = 12.0d * (96d / 72d) }.Fill(et, hint);
             case "font":
                 return BuildFont(et, hint);
             case "keyword":
                 return new Span { Foreground = Brushes.Blue }.Fill(et, hint);
             //case "span":
             case "hint":
                 return BuildHint(et, hint);
             case "ref":
                 return BuildRef(et, hint);
             case "params":
                 return BuildParam(et, hint);
             default:
                 throw new NotSupportedException(et.Name);
         }
     }
     throw new NotSupportedException();
 }
예제 #48
0
 public void SetHint(Hint Hint)
 {
     this.hint = Hint;
 }
예제 #49
0
		/// <summary>
		/// Creates a flow document of the report data
		/// </summary>
		/// <returns></returns>
		/// <exception cref="ArgumentException">Flow document must have a specified page height</exception>
		/// <exception cref="ArgumentException">Flow document must have a specified page width</exception>
		/// <exception cref="ArgumentException">"Flow document must have only one ReportProperties section, but it has {0}"</exception>
		public FlowDocument CreateFlowDocument(out Hint hints)
		{
			using (var counter = new TimeCounter("\t\t\tReportDocument Total	{0}"))
			{
				FlowDocument res = GetFlowDocument();
				counter.ShowTick("\t\t\t\tReportDocument Load XAML:	{0}");

				if (res.PageHeight == double.NaN)
					throw new ArgumentException("Flow document must have a specified page height");
				if (res.PageWidth == double.NaN)
					throw new ArgumentException("Flow document must have a specified page width");

				// remember original values
				_pageHeight = res.PageHeight;
				_pageWidth = res.PageWidth;

				// search report properties
				DocumentWalker walker = new DocumentWalker();
				List<SectionReportHeader> headers = walker.Walk<SectionReportHeader>(res);
				List<SectionReportFooter> footers = walker.Walk<SectionReportFooter>(res);

				var hintList = walker.Walk<ReportHint>(res);
				hints = Hint.None;
				foreach (var hint in hintList)
				{
					hints |= hint.Hint;
					// remove properties section from FlowDocument
					DependencyObject parent = hint.Parent;
					if (parent is FlowDocument) { ((FlowDocument)parent).Blocks.Remove(hint); parent = null; }
					if (parent is Section) { ((Section)parent).Blocks.Remove(hint); parent = null; }
				}

				List<ReportProperties> properties = walker.Walk<ReportProperties>(res);
				if (properties.Count > 0)
				{
					if (properties.Count > 1)
						throw new ArgumentException(String.Format("Flow document must have only one ReportProperties section, but it has {0}", properties.Count));
					ReportProperties prop = properties[0];
					if (prop.ReportName != null)
						ReportName = prop.ReportName;
					if (prop.ReportTitle != null)
						ReportTitle = prop.ReportTitle;
					if (headers.Count > 0)
						PageHeaderHeight = headers[0].PageHeaderHeight;
					if (footers.Count > 0)
						PageFooterHeight = footers[0].PageFooterHeight;

					// remove properties section from FlowDocument
					DependencyObject parent = prop.Parent;
					if (parent is FlowDocument) { ((FlowDocument)parent).Blocks.Remove(prop); parent = null; }
					if (parent is Section) { ((Section)parent).Blocks.Remove(prop); parent = null; }
				}

				// make height smaller to have enough space for page header and page footer
				res.PageHeight = _pageHeight - _pageHeight * (PageHeaderHeight + PageFooterHeight) / 100d;

				// search image objects
				List<Image> images = new List<Image>();
				walker.Tag = images;
				walker.VisualVisited += new DocumentVisitedEventHandler(walker_VisualVisited);
				walker.Walk(res);

				// load all images
				foreach (Image image in images)
				{
					if (ImageProcessing != null)
						ImageProcessing(this, new ImageEventArgs(this, image));
					try
					{
						if (image.Tag is string)
							image.Source = new BitmapImage(new Uri("file:///" + Path.Combine(_xamlImagePath, image.Tag.ToString())));
					}
					catch (Exception ex)
					{
						// fire event on exception and check for Handled = true after each invoke
						if (ImageError != null)
						{
							bool handled = false;
							lock (ImageError)
							{
								ImageErrorEventArgs eventArgs = new ImageErrorEventArgs(ex, this, image);
								foreach (var ed in ImageError.GetInvocationList())
								{
									ed.DynamicInvoke(this, eventArgs);
									if (eventArgs.Handled) { handled = true; break; }
								}
							}
							if (!handled)
								throw;
						}
						else
							throw;
					}
					if (ImageProcessed != null)
						ImageProcessed(this, new ImageEventArgs(this, image));
					// TODO: find a better way to specify file names
				}

				return res;
			}
		}
예제 #50
0
        private static Inline BuildRef(ElementToken token, Hint hint)
        {
            string handler;
            token.Attributes.TryGetValue("handler", out handler);

            string hintStr;
            token.Attributes.TryGetValue("hint", out hintStr);
            if (hintStr != null)
            {
                hintStr = "<code>" + hintStr + "</code>";
            }
            var hc = new HintControl(hintStr, handler);
            Fill(hc.Inlines, token, hint);
            return new InlineUIContainer { Child = hc };
        }
예제 #51
0
 private static Inline BuildSymbol(ElementToken token, Hint hint)
 {
     string spanClass = token.Attributes["SpanClass"];
       string value     = token.Text;
       return new Run(value) { Foreground = hint.MapBrush(spanClass) };
 }
예제 #52
0
        private int DeriveScalarSerialization(Type thatType, FieldInfo scalarField)
        {
            string s = scalarField.Name;
            isEnum = XmlTools.IsEnum(scalarField);
            xmlHint = XmlTools.SimplHint(scalarField);
            if (isEnum)
                ScalarType = TypeRegistry.ScalarTypes[typeof(Enum)];
            else
                ScalarType = TypeRegistry.ScalarTypes[thatType];

            if (ScalarType == null)
            {
                String msg = "Can't find ScalarType to serialize field: \t\t" + thatType.Name
                             + "\t" + scalarField.Name + ";";

                Debug.WriteLine(msg);
                return (xmlHint == Hint.XmlAttribute) ? FieldTypes.IgnoredAttribute : FieldTypes.IgnoredElement;
            }

            dataFormat = XmlTools.GetFormatAnnotation(field);

            if (xmlHint != Hint.XmlAttribute)
            {
                needsEscaping = ScalarType.NeedsEscaping;
                isCDATA = xmlHint == Hint.XmlLeafCdata || xmlHint == Hint.XmlTextCdata;
            }
            return FieldTypes.Scalar;
        }
예제 #53
0
 public bool ShouldShowHint(Hint id)
 {
     return !disabledHints.Contains(id.ToString());
 }
예제 #54
0
 public string this[Hint id]
 {
     get
     {
         switch (id)
         {
         default:
             if (hintDict.ContainsKey(id.ToString()))
                 return hintDict[id.ToString()];
             else
                 return id.ToString();
         }
     }
 }
예제 #55
0
 private static TextBlock Fill(this TextBlock tb, ElementToken token, Hint hint)
 {
     Fill(tb.Inlines, token, hint);
     return tb;
 }
        public void ImportFile(FileInfo file, Main db)
        {
            using (StreamReader sr = file.OpenText())
            {
                string s;
                QuizQuestion question = null;
                bool category = false;
                while ((s = sr.ReadLine()) != null)
                {
                    s = s.Trim();
                    if (s.StartsWith("#") || s.IsNullOrEmpty()) { continue; }

                    if (s.StartsWith("Category:"))
                    {
                        question = new QuizQuestion();
                        db.QuizQuestions.InsertOnSubmit(question);

                        question.Category = s.Substring(9);
                        category = true;
                    }

                    if (s.StartsWith("Question:") && question != null)
                    {
                        if (!category)
                        {
                            question = new QuizQuestion();
                            db.QuizQuestions.InsertOnSubmit(question);
                        }
                        category = false;
                        question.Question = s.Substring(9).Trim();
                    }

                    if (s.StartsWith("Answer:") && question != null)
                    {
                        question.Answer = s.Substring(7).Trim();
                        db.SubmitChanges();
                    }

                    if (s.StartsWith("Regexp:") && question != null)
                    {
                        question.AnswerRegExp = s.Substring(7).Trim();
                    }

                    if (s.StartsWith("Author:") && question != null)
                    {
                        question.Author = s.Substring(7).Trim();
                    }

                    if (s.StartsWith("Level:") && question != null)
                    {
                        switch (s.Substring(6).Trim())
                        {
                            case "baby":
                                question.Difficulty = 0;
                                break;
                            case "easy":
                                question.Difficulty = 3;
                                break;
                            case "normal":
                                question.Difficulty = 5;
                                break;
                            case "hard":
                                question.Difficulty = 8;
                                break;
                            case "extreme":
                                question.Difficulty = 10;
                                break;

                        }
                    }

                    if (s.StartsWith("Comment:") && question != null)
                    {
                        question.Comment = s.Substring(8).Trim();
                    }

                    if (s.StartsWith("Score:") && question != null)
                    {
                        question.Score = int.Parse(s.Substring(6).Trim());
                    }

                    if (s.StartsWith("Tip:") && question != null && question.ID.HasValue && !s.IsNullOrEmpty())
                    {
                        var hint = new Hint();
                        db.Hints.InsertOnSubmit(hint);

                        hint.Message = s.Substring(4).Trim();
                        hint.QuizQuestionID = question.ID.Value;

                        db.SubmitChanges();
                    }
                }
            }
        }
예제 #57
0
        private static Inline BuildSymbolHint(ElementToken token, Hint hint)
        {
            Trace.Assert(token.Name == "Symbol");

              string handler;
              token.Attributes.TryGetValue("handler", out handler);

              string key       = token.Attributes["id"];
              string spanClass = token.Attributes["SpanClass"];

              string value = token.Text;

              var hc = new HintControl(key, hint.RaiseGetHintContent, handler);
              hc.Inlines.Add(new Run(value) { Foreground = hint.MapBrush(spanClass) });
              return new InlineUIContainer { Child = hc };
        }
예제 #58
0
 void Awake()
 {
     hint = this.GetComponent<Hint>();
 }