protected override void TouchDownMessage(object sender, point point, ref bool handled) { // Check Controls if (Children != null) { lock (Children) { int i; for (i = Children.Length - 1; i >= 0; i--) { if (Children[i].Visible && Children[i].HitTest(point)) { ActiveChild = Children[i]; Children[i].SendTouchDown(this, point); handled = true; return; } } } } if (ActiveChild != null) { ActiveChild.Blur(); Render(ActiveChild.ScreenBounds, true); ActiveChild = null; } _touch = true; }
public override bool ConsumeKey(Key key) { if (ActiveChild.ConsumeKey(key)) { CalculateSize(); return(true); } if (key == Key.Down) { if (ActiveChild == mainRowContainer) { Point point = ActiveChild.GetVerticalCaretLocation(); ActiveChild = bottomRowContainer; point.Y = ActiveChild.Top + 1; ActiveChild.SetCursorOnKeyUpDown(key, point); return(true); } } else if (key == Key.Up) { if (ActiveChild == bottomRowContainer) { Point point = ActiveChild.GetVerticalCaretLocation(); ActiveChild = mainRowContainer; point.Y = ActiveChild.Bottom - 1; ActiveChild.SetCursorOnKeyUpDown(key, point); return(true); } } return(false); }
private void Delete_Click(object sender, EventArgs e) { if (ActiveChild != VoucherForm.Empty) { ActiveChild.Close(); } }
public override bool ConsumeKey(Key key) { if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) && (new[] { Key.Right, Key.Left, Key.Up, Key.Down, Key.Home, Key.End }).Contains(key)) { if (!IsSelecting) { IsSelecting = true; ((RowContainer)ActiveChild).StartSelection(); } ActiveChild.Select(key); AdjustCarets(); return(true); } Key[] handledKeys = { Key.Left, Key.Right, Key.Delete, Key.Up, Key.Down, Key.Enter, Key.Escape, Key.Back, Key.Home, Key.End }; bool result = false; if (handledKeys.Contains(key)) { result = true; if (IsSelecting && (new[] { Key.Delete, Key.Enter, Key.Back }).Contains(key)) { ActiveChild.RemoveSelection(true); } else { ActiveChild.ConsumeKey(key); } CalculateSize(); AdjustCarets(); DeSelect(); } return(result); }
protected override void TouchGestureMessage(object sender, TouchType type, float force, ref bool handled) { if (Children == null) { return; } if (type == TouchType.GestureRight) { int newSel = _selIndex - 1; if (newSel < 0) { newSel = Children.Length - 1; } SelectedIndex = newSel; } else if (type == TouchType.GestureLeft) { int newSel = _selIndex + 1; if (newSel > Children.Length - 1) { newSel = 0; } SelectedIndex = newSel; } if (ActiveChild != null) { handled = true; ActiveChild.SendTouchGesture(sender, type, force); } }
public override bool ConsumeKey(Key key) { if (ActiveChild.ConsumeKey(key)) { CalculateSize(); return(true); } if (key == Key.Right) { if (ActiveChild == topEquation) { ActiveChild = bottomEquation; return(true); } } else if (key == Key.Left) { if (ActiveChild == bottomEquation) { ActiveChild = topEquation; return(true); } } return(false); }
private void FileButton_Click(object sender, EventArgs e) { if (sender == btnOpen) { ActiveChild.Open(); } else if (sender == btnSave) { ActiveChild.Save(); } else if (sender == btnSaveAs) { ActiveChild.SaveAs(); } else if (sender == btnPrint) { ActiveChild.Print(); } else if (sender == btnPrintPreview) { ActiveChild.PrintPreview(); } else { throw new NotImplementedException(); } }
public override bool ConsumeKey(Key key) { if (ActiveChild.ConsumeKey(key)) { CalculateSize(); return(true); } if (key == Key.Down) { if (ActiveChild == mainEquation) { ActiveChild = bottomEquation; return(true); } } else if (key == Key.Up) { if (ActiveChild == bottomEquation) { ActiveChild = mainEquation; return(true); } } return(false); }
public override bool ConsumeKey(Key key) { if (ActiveChild.ConsumeKey(key)) { CalculateSize(); return(true); } if (key == Key.Down) { if (ActiveChild == topRowContainer) { ActiveChild = mainRowContainer; return(true); } } else if (key == Key.Up) { if (ActiveChild == mainRowContainer) { ActiveChild = topRowContainer; return(true); } } return(false); }
/// <summary> /// Override this message to handle touch events internally. /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="point">Point on screen touch event is occurring</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// Forwards the message to the top most child under the point. /// The hit child is made the active child. /// </remarks> protected override void TouchDownMessage(object sender, point point, ref bool handled) { //TODO: check if this code shouldn't go to Container // Check Controls if (Children != null) { lock (Children) { for (var i = Children.Length - 1; i >= 0; i--) { if (Children[i].Visible && Children[i].HitTest(point)) { ActiveChild = Children[i]; Children[i].SendTouchDown(this, point); handled = true; return; } } } } if (ActiveChild != null) { ActiveChild.Blur(); Render(ActiveChild.ScreenBounds, true); ActiveChild = null; } //TODO: check if _touch shouldn't be set to true here }
public void LoadFile(Stream stream) { UndoManager.ClearAll(); DeSelect(); XDocument xDoc = XDocument.Load(stream, LoadOptions.PreserveWhitespace); XElement root = xDoc.Root; XAttribute fileVersionAttribute; XAttribute appVersionAttribute; if (root.Name == GetType().Name) { XElement formattingElement = root.Element("TextManager"); textManager.DeSerialize(formattingElement); fileVersionAttribute = root.Attributes("fileVersion").FirstOrDefault(); appVersionAttribute = root.Attributes("appVersion").FirstOrDefault(); root = root.Element("RowContainer"); } else { fileVersionAttribute = root.Attributes("fileVersion").FirstOrDefault(); appVersionAttribute = root.Attributes("appVersion").FirstOrDefault(); } string appVersion = appVersionAttribute != null ? appVersionAttribute.Value : "Unknown"; if (fileVersionAttribute == null || fileVersionAttribute.Value != fileVersion) { MessageBox.Show("The file was created by a different version (v." + appVersion + ") of Math Editor and uses a different format." + Environment.NewLine + Environment.NewLine + "Math Editor will still try to open and convert the file to the current version. The operation may fail. " + Environment.NewLine + Environment.NewLine + "Please create a backup if you want to keep the original file intact.", "Message"); } ActiveChild.DeSerialize(root); CalculateSize(); AdjustCarets(); }
private void FontProp_Click(object sender, EventArgs e) { if (sender == btnBold) { ActiveChild.SetFontStyle(FontStyle.Bold); } else if (sender == btnItalic) { ActiveChild.SetFontStyle(FontStyle.Italic); } else if (sender == btnUnderLined) { ActiveChild.SetFontStyle(FontStyle.Underline); } else if (sender == btnStrikeLined) { ActiveChild.SetFontStyle(FontStyle.Strikeout); } else if (sender == btnFondSizeIncrease) { ShowFontSize(ActiveChild.SetFontSize(true).ToString()); } else if (sender == btnFindSizeDecrease) { ShowFontSize(ActiveChild.SetFontSize(false).ToString()); } else { throw new NotImplementedException(); } }
protected override void TouchGestureMessage(object sender, TouchType type, float force, ref bool handled) { if (ActiveChild != null) { handled = true; ActiveChild.SendTouchGesture(sender, type, force); } }
void MainFormBase_Deactivate(object sender, EventArgs e) { // active child formbase if (ActiveChild != null) { ActiveChild.PerformDeactivated(); } }
protected override void KeyboardKeyMessage(char key, bool pressed, ref bool handled) { if (ActiveChild != null) { handled = true; ActiveChild.SendKeyboardKeyEvent(key, pressed); } base.KeyboardKeyMessage(key, pressed, ref handled); }
/// <summary> /// Override this message to handle touch events internally. /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="type">Type of touch gesture</param> /// <param name="force">Force associated with gesture (0.0 to 1.0)</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// Forwards the message to <see cref="Container.ActiveChild"/> /// </remarks> protected override void TouchGestureMessage(object sender, TouchType type, float force, ref bool handled) { //TODO: check if this code shouldn't go to Container if (ActiveChild != null) { handled = true; ActiveChild.SendTouchGesture(sender, type, force); } }
public override void SelectAll() { DeSelect(); ActiveChild.SelectAll(); if (!IsSelecting) { IsSelecting = true; } }
public void AdjustCarets() { vCaret.Location = ActiveChild.GetVerticalCaretLocation(); vCaret.CaretLength = ActiveChild.GetVerticalCaretLength(); EquationContainer innerMost = ((RowContainer)ActiveChild).GetInnerMostEquationContainer(); hCaret.Location = innerMost.GetHorizontalCaretLocation(); hCaret.CaretLength = innerMost.GetHorizontalCaretLength(); }
public void SaveImageToFile(string path) { string extension = Path.GetExtension(path).ToLower(); DrawingVisual dv = new DrawingVisual(); using (DrawingContext dc = dv.RenderOpen()) { if (extension == ".bmp" || extension == "jpg") { dc.DrawRectangle(Brushes.White, null, new Rect(0, 0, Math.Ceiling(Width + Location.X * 2), Math.Ceiling(Width + Location.Y * 2))); } ActiveChild.DrawEquation(dc); } RenderTargetBitmap bitmap = new RenderTargetBitmap((int)(Math.Ceiling(Width + Location.X * 2)), (int)(Math.Ceiling(Height + Location.Y * 2)), 96, 96, PixelFormats.Default); bitmap.Render(dv); BitmapEncoder encoder = null; switch (extension) { case ".jpg": encoder = new JpegBitmapEncoder(); break; case ".gif": encoder = new GifBitmapEncoder(); break; case ".bmp": encoder = new BmpBitmapEncoder(); break; case ".png": encoder = new PngBitmapEncoder(); break; case ".wdp": encoder = new WmpBitmapEncoder(); break; case ".tif": encoder = new TiffBitmapEncoder(); break; } try { encoder.Frames.Add(BitmapFrame.Create(bitmap)); using (Stream s = File.Create(path)) { encoder.Save(s); } } catch { MessageBox.Show("File could not be saved. Please make sure the path you entered is correct", "Error"); } }
/// <summary> /// Override this message to handle key events internally. /// </summary> /// <param name="key">Integer value of the key affected</param> /// <param name="pressed">True if the key is currently being pressed; false if released</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// Forwards the message to <see cref="Container.ActiveChild"/> /// </remarks> protected override void KeyboardKeyMessage(char key, bool pressed, ref bool handled) { //TODO: check if this code shouldn't go to Container if (ActiveChild != null) { ActiveChild.SendKeyboardKeyEvent(key, pressed); } base.KeyboardKeyMessage(key, pressed, ref handled); }
public override void RemoveSelection(bool registerUndo) { if (IsSelecting) { ActiveChild.RemoveSelection(registerUndo); CalculateSize(); AdjustCarets(); DeSelect(); } }
public override void HandleMouseDrag(Point mousePoint) { if (!IsSelecting) { ActiveChild.StartSelection(); IsSelecting = true; } ActiveChild.HandleMouseDrag(mousePoint); AdjustCarets(); }
private void Group3_Click(object sender, EventArgs e) { if (sender == btnNew3) { New(); } else if (sender == btnOpen3) { ActiveChild.Open(); } else if (sender == btnSave3) { ActiveChild.Save(); } else if (sender == btnSaveAs3) { ActiveChild.SaveAs(); } else if (sender == btnPrepare3) { new AppInfoException("Prepare not completed yet").ThrowAndForget(); } else if (sender == btnPublish3) { new AppInfoException("Publish not completed yet").ThrowAndForget(); } else if (sender == btnSend3) { string to = SettingsTable.Get <string>(Strings.VScan_Email_To, "*****@*****.**"); string subject = SettingsTable.Get <string>(Strings.VScan_Email_Subject, "VScan issue"); string body = SettingsTable.Get <string>(Strings.VScan_Email_Body, "Dear Support"); Process.Start(new ProcessStartInfo(string.Format("mailto:{0}?subject={1}&body={2}", to, subject, body))); } else if (sender == btnClose3) { Close(); } else if (sender == btnQuickPrint3)//print { ActiveChild.Print(); } else if (sender == btnAdvancePrint3)// set printer { ActiveChild.SetupAndPrint(); } else if (sender == btnPrintPreview3)//preview { ActiveChild.PrintPreview(); } else { throw new NotImplementedException(); } }
public IParsingTreeActiveNode <T> ExitChild(bool keep) { if (keep) { var recreatedCurrent = new ActiveChild(this.Info, this.RecreateChildrenAsFinal(), this.Parent.LastChild); return(new ActiveNode(this.Parent.Info, this.Parent.Parent, recreatedCurrent)); } else { return(new ActiveNode(this.Parent.Info, this.Parent.Parent, this.Parent.LastChild)); } }
public void Update() { if (ActiveChild != null) { ActiveChild.Update(); } if (_updateAction != null) { _updateAction(); } }
public override bool ConsumeMouseClick(System.Windows.Point mousePoint) { if (nthRootEquation.Bounds.Contains(mousePoint)) { ActiveChild = nthRootEquation; } else if (insideEquation.Bounds.Contains(mousePoint)) { ActiveChild = insideEquation; } return(ActiveChild.ConsumeMouseClick(mousePoint)); }
public override bool ConsumeMouseClick(System.Windows.Point mousePoint) { if (bottomEquation.Bounds.Contains(mousePoint)) { ActiveChild = bottomEquation; } else { ActiveChild = mainEquation; } return(ActiveChild.ConsumeMouseClick(mousePoint)); }
public FinalNode RecreateChildrenAsFinal() { ActiveChild curr = this.LastChild; FinalNode newCurr = null; while (curr != null) { newCurr = new FinalNode(curr.Info, curr.Child, newCurr); curr = curr.PrevChild; } return(newCurr); }
public void SaveFile(Stream stream) { XDocument xDoc = new XDocument(); XElement root = new XElement(GetType().Name); //ActiveChild.Serialize(); root.Add(new XAttribute("fileVersion", fileVersion)); root.Add(new XAttribute("appVersion", Assembly.GetEntryAssembly().GetName().Version)); textManager.OptimizeForSave(this); root.Add(textManager.Serialize()); root.Add(ActiveChild.Serialize()); xDoc.Add(root); xDoc.Save(stream); textManager.RestoreAfterSave(this); }
public override bool ConsumeKey(Key key) { if (ActiveChild.ConsumeKey(key)) { CalculateSize(); return(true); } int currentIndex = childEquations.IndexOf(ActiveChild); if (key == Key.Right) { if (currentIndex % columns < columns - 1)//not last column? { ActiveChild = childEquations[currentIndex + 1]; return(true); } } else if (key == Key.Left) { if (currentIndex % columns > 0)//not last column? { ActiveChild = childEquations[currentIndex - 1]; return(true); } } else if (key == Key.Up) { if (currentIndex / columns > 0)//not in first row? { Point point = ActiveChild.GetVerticalCaretLocation(); ActiveChild = childEquations[currentIndex - columns];; point.Y = ActiveChild.Top + 1; ActiveChild.SetCursorOnKeyUpDown(key, point); return(true); } } else if (key == Key.Down) { if (currentIndex / columns < rows - 1)//not in last row? { Point point = ActiveChild.GetVerticalCaretLocation(); ActiveChild = childEquations[currentIndex + columns];; point.Y = ActiveChild.Top + 1; ActiveChild.SetCursorOnKeyUpDown(key, point); return(true); } } return(false); }