Exemplo n.º 1
0
        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);
 }
Exemplo n.º 3
0
 private void Delete_Click(object sender, EventArgs e)
 {
     if (ActiveChild != VoucherForm.Empty)
     {
         ActiveChild.Close();
     }
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 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);
 }
Exemplo n.º 7
0
 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();
     }
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
        /// <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
        }
Exemplo n.º 11
0
        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();
        }
Exemplo n.º 12
0
 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();
     }
 }
Exemplo n.º 13
0
 protected override void TouchGestureMessage(object sender, TouchType type, float force, ref bool handled)
 {
     if (ActiveChild != null)
     {
         handled = true;
         ActiveChild.SendTouchGesture(sender, type, force);
     }
 }
Exemplo n.º 14
0
 void MainFormBase_Deactivate(object sender, EventArgs e)
 {
     // active child formbase
     if (ActiveChild != null)
     {
         ActiveChild.PerformDeactivated();
     }
 }
Exemplo n.º 15
0
 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);
 }
Exemplo n.º 16
0
 /// <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);
     }
 }
Exemplo n.º 17
0
 public override void SelectAll()
 {
     DeSelect();
     ActiveChild.SelectAll();
     if (!IsSelecting)
     {
         IsSelecting = true;
     }
 }
Exemplo n.º 18
0
        public void AdjustCarets()
        {
            vCaret.Location    = ActiveChild.GetVerticalCaretLocation();
            vCaret.CaretLength = ActiveChild.GetVerticalCaretLength();
            EquationContainer innerMost = ((RowContainer)ActiveChild).GetInnerMostEquationContainer();

            hCaret.Location    = innerMost.GetHorizontalCaretLocation();
            hCaret.CaretLength = innerMost.GetHorizontalCaretLength();
        }
Exemplo n.º 19
0
        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");
            }
        }
Exemplo n.º 20
0
 /// <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);
 }
Exemplo n.º 21
0
 public override void RemoveSelection(bool registerUndo)
 {
     if (IsSelecting)
     {
         ActiveChild.RemoveSelection(registerUndo);
         CalculateSize();
         AdjustCarets();
         DeSelect();
     }
 }
Exemplo n.º 22
0
 public override void HandleMouseDrag(Point mousePoint)
 {
     if (!IsSelecting)
     {
         ActiveChild.StartSelection();
         IsSelecting = true;
     }
     ActiveChild.HandleMouseDrag(mousePoint);
     AdjustCarets();
 }
Exemplo n.º 23
0
 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();
     }
 }
Exemplo n.º 24
0
 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));
     }
 }
Exemplo n.º 25
0
		public void Update()
		{
			if (ActiveChild != null)
			{
				ActiveChild.Update();
			}

			if (_updateAction != null)
			{
				_updateAction();
			}
		}
Exemplo n.º 26
0
 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));
 }
Exemplo n.º 27
0
 public override bool ConsumeMouseClick(System.Windows.Point mousePoint)
 {
     if (bottomEquation.Bounds.Contains(mousePoint))
     {
         ActiveChild = bottomEquation;
     }
     else
     {
         ActiveChild = mainEquation;
     }
     return(ActiveChild.ConsumeMouseClick(mousePoint));
 }
Exemplo n.º 28
0
            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);
            }
Exemplo n.º 29
0
        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);
        }
Exemplo n.º 30
0
        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);
        }