Ejemplo n.º 1
0
        private void Item_Redo_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (HistoryRedo.Count > 0)
                {
                    int last = HistoryRedo.Count - 1;

                    if (HistoryRedo[last] is His_RemovedControl)
                    {
                        SpecialRemoved = true;
                    }

                    HistoryRedo[last].DoRedoAction(DesignCanvas, data);
                    HistoryCommand historyCommand = HistoryRedo[last];
                    HistoryRedo.RemoveAt(last);
                    HistoryUndo.Add(historyCommand);
                    Undo_MI.IsEnabled = true;

                    if (HistoryRedo.Count == 0)
                    {
                        Redo_MI.IsEnabled = false;
                    }
                }
                else
                {
                    Redo_MI.IsEnabled = false;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Redo Error: " + ex);
            }
        }
Ejemplo n.º 2
0
        /*
         * string GetPageTypeName(TestTypeID.Test_Type type)
         * {
         *  switch (type)
         *  {
         *      case TestTypeID.Test_Type.Classic:
         *          return Strings.ResStrings.Answers;
         *      case TestTypeID.Test_Type.Form:
         *          return Strings.ResStrings.Page;
         *      default:
         *          return "";
         *  }
         * }*/


        private void TestTypeCall_OnClick(int Pos, object sender)
        {
            SaveCanvas();

            Debug.WriteLine("POS:  " + Pos + "    Sender:" + ((TestType_ControlN)sender).test_type);

            FrameEditor.NavigationService.LoadCompleted -= NavigationService_LoadCompleted;
            FrameEditor.NavigationService.LoadCompleted += NavigationService_LoadCompleted;

            FrameEditor.Content = new Page_Form();
            FrameEditor.NavigationService.RemoveBackEntry();

            if (LastSelected != null)
            {
                LastSelected.Select(false);
            }

            ((TestType_ControlN)sender).Select(true);
            LastSelected = (TestType_ControlN)sender;

            SelectedPosition = Pos;

            ValueEditor.Content = "";

            HistoryRedo.Clear();
            HistoryUndo.Clear();

            Undo_MI.IsEnabled = false;
            Redo_MI.IsEnabled = false;

            LoadCanvas();
        }
Ejemplo n.º 3
0
        private void Control_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Dragging = false;
            ((UIElement)sender).ReleaseMouseCapture();

            if (!double.IsNaN(StartX) && StartX != Canvas.GetLeft(((UIElement)sender)) && !MovedByMoveButton)
            {
                //Debug.WriteLine("Added to History Undo: "+HistoryUndo.Count);
                HistoryUndo.AddRaise(new His_PositionChanged(DesignCanvas.Children.IndexOf(((UIElement)sender)), Canvas.GetLeft(((UIElement)sender)), Canvas.GetTop(((UIElement)sender)), StartX, StartY));
            }

            if (!MovedByMoveButton)
            {
                StartX = double.NaN;
                StartY = double.NaN;
            }

            if (BMoveOnGrid)
            {
                FrameworkElement element = ((FrameworkElement)sender);
                Canvas.SetLeft(element, ((int)Canvas.GetLeft(element) / GridSize) * GridSize);
                Canvas.SetTop(element, ((int)Canvas.GetTop(element) / GridSize) * GridSize);

                if (IsSelectedControl)
                {
                    DrawSelectedItem((FrameworkElement)SelectedControl);
                }
            }

            IsSelectedControl = false;
        }
Ejemplo n.º 4
0
        private void HistoryUndo_OnAdd(object sender, EventArgs e)
        {
            HistoryRedo.Clear();
            Redo_MI.IsEnabled = false;
            Undo_MI.IsEnabled = true;

            MainWindow.IsChanged = true;

            if (HistoryUndo.Count >= HistoryLimit)
            {
                HistoryUndo.RemoveAt(0);
            }
        }
Ejemplo n.º 5
0
        private void Control_Unloaded(object sender, RoutedEventArgs e)
        {
            if (!SpecialRemoved && SelectedControl != null && !(sender is Gallery))
            {
                try
                {
                    //Debug.WriteLine("Add Removed ID: " + SelectedControlID + "    Type: " + SelectedControl);
                    HistoryUndo.AddRaise(new His_RemovedControl(CreateCopyObject(SelectedControl, 0), SelectedControlID));
                }catch (Exception ex)
                {
                    Debug.WriteLine("Cant create copy: " + ex);
                }
            }

            SpecialRemoved = false;
        }
Ejemplo n.º 6
0
        private void Move_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (!double.IsNaN(StartX) && StartX != Canvas.GetLeft(((UIElement)SelectedControl)))
            {
                //Debug.WriteLine("Added: "+DesignCanvas.Children[SelectedControlID]);
                HistoryUndo.AddRaise(new His_PositionChanged(SelectedControlID, Canvas.GetLeft((UIElement)SelectedControl), Canvas.GetTop((UIElement)SelectedControl), StartX, StartY));
            }

            StartX            = double.NaN;
            StartY            = double.NaN;
            MovedByMoveButton = false;

            if (BMoveOnGrid)
            {
                FrameworkElement element = ((FrameworkElement)SelectedControl);
                Canvas.SetLeft(element, ((int)Canvas.GetLeft(element) / GridSize) * GridSize);
                Canvas.SetTop(element, ((int)Canvas.GetTop(element) / GridSize) * GridSize);
                UpdateSelectedEffect();
            }
        }
Ejemplo n.º 7
0
        private void DesignCanvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ButtonState == e.RightButton)
            {
                Mouse.OverrideCursor = null;
                ControlSelect        = false;
            }

            if (ControlSelect)
            {
                Point p = Mouse.GetPosition(DesignCanvas);

                int CID = 0;

                string textCT = "" + ControlTag;

                int.TryParse("" + textCT[0], out CID);


                switch (CID)
                {
                case 1:
                    AddLevel1Control(p);     //main
                    break;

                case 2:
                    AddLevel2Control(p);     //shapes
                    break;

                case 3:
                    AddLevel3Control(p);     //charts
                    break;

                case 4:
                    AddLevel4Control(p);     //controls (buttons, textbox...)
                    break;

                case 5:
                    AddLevel5Control(p);     //special
                    break;
                }

                if (DesignCanvas.Children.Count > 0)
                {
                    HistoryUndo.AddRaise(new His_AddControl(DesignCanvas.Children[DesignCanvas.Children.Count - 1], DesignCanvas.Children.Count - 1));
                }
            }
            else if (e.OriginalSource is Canvas)
            {
                /*
                 * if (SelectedControl != null && SelectedControl is Control)
                 * {
                 *  if (ChangeColor(SelectedControl))
                 *      ((Control)SelectedControl).Background = selbackground;
                 * }
                 */

                //Keyboard.ClearFocus();

                UnselectControl();
            }
        }