Exemplo n.º 1
0
 public void DeleteSelected()
 {
     if (selectedBoxesIndexes.Count > 0)
     {
         selectedBoxesIndexes.Sort();
         bool   lastRemoved = selectedBoxesIndexes.Last() == displayBoxes.Count - 1;
         double x           = currentBox.Location.X;
         double y           = displayBoxes[selectedBoxesIndexes[0]].Top;
         for (int i = selectedBoxesIndexes.Count - 1; i >= 0; i--)
         {
             displayBoxes.RemoveAt(selectedBoxesIndexes[i]);
         }
         this.MinHeight = (Parent as ScrollViewer).ViewportHeight;
         for (int i = selectedBoxesIndexes[0]; i < displayBoxes.Count; i++)
         {
             displayBoxes[i].AdjustLocations(new Point(x, y));
             y += displayBoxes[i].Height;
             this.MinHeight += displayBoxes[i].Height;
         }
         if (lastRemoved)
         {
             currentBox = new TextDisplayBox(DisplayBoxType.Input, new Point(x, y));
             displayBoxes.Add(currentBox);
             this.MinHeight += currentBox.Height;
             caret.Location  = currentBox.Location;
             currentCommand.Clear();
             caretIndex = 0;
         }
         selectedBoxesIndexes.Clear();
         AdjustCaret();
     }
 }
Exemplo n.º 2
0
        public void OpenFile(XElement root)
        {
            XElement data = root.Element("data");

            Clear();
            displayBoxes.Clear();
            currentCommand.Clear();
            foreach (XElement xe in data.Elements())
            {
                DisplayBoxType dbt = (DisplayBoxType)Enum.Parse(typeof(DisplayBoxType), xe.Attribute("type").Value);
                Point          location;
                if (displayBoxes.Count > 0)
                {
                    location        = new Point(currentBox.Location.X, currentBox.Bottom);
                    this.MinHeight += currentBox.Height;
                }
                else
                {
                    location = caret.Location;
                }
                TextDisplayBox newBox = new TextDisplayBox(dbt, location);
                displayBoxes.Add(newBox);
                newBox.SetText(xe.Value);
                currentBox = newBox;
            }
            if (currentBox.BoxType == DisplayBoxType.Input)
            {
                currentCommand.Append(currentBox.Text);
                caretIndex = currentCommand.Length;
            }
            commandCache.LoadXML(root);
            Calculator.LoadXML(root);
            AdjustCaret();
        }
Exemplo n.º 3
0
        void AddNewBox(DisplayBoxType dbt, string text)
        {
            TextDisplayBox newBox = new TextDisplayBox(dbt, new Point(currentBox.Location.X, currentBox.Bottom));

            newBox.SetText(text);
            displayBoxes.Add(newBox);
            currentBox      = newBox;
            this.MinHeight += currentBox.Height;
        }
Exemplo n.º 4
0
 public CommandControl()
 {
     InitializeComponent();
     mainGrid.Children.Add(caret);
     caret.Location    = new Point(pointer.Width + gap + padding, padding);
     currentBox        = new TextDisplayBox(DisplayBoxType.Input, caret.Location);
     caret.CaretLength = pointer.Height;
     displayBoxes.Add(currentBox);
     this.MinHeight = 800;
     this.MinWidth  = 1200;
     Calculator.IntermediateResultProduced += new IntermediateResult(Calculator_IntermediateResultProduced);
     this.LostFocus += new RoutedEventHandler(CommandControl_LostFocus);
     this.GotFocus  += new RoutedEventHandler(CommandControl_GotFocus);
 }
Exemplo n.º 5
0
        public void Clear()
        {
            displayBoxes.Clear();
            currentBox = new TextDisplayBox(DisplayBoxType.Input, new Point(pointer.Width + gap + padding, padding));
            displayBoxes.Add(currentBox);
            caret.Location = currentBox.Location;
            this.MinHeight = 800;
            this.MinWidth  = 1200;
            ScrollViewer scrollViewer = Parent as ScrollViewer;

            scrollViewer.ScrollToTop();
            scrollViewer.ScrollToLeftEnd();
            //InvalidateVisual();
            GC.Collect();
        }