Exemplo n.º 1
0
        private void ResourceGetsCreated(object sender, EventArgs args)
        {
            if (_mode == EditingMode.UserEditsExistingResource)
            {
                _view.ShowMessageToUser("Bitte erst die Änderungen speichern oder verwerfen!");
                return;
            }

            TeachingResource newResource = new TeachingResource("Neue Ressource", "bitte ausfüllen");

            _activeResource = newResource;
            _allResources.Add(newResource);

            if (_mode == EditingMode.EmptyDatabase)
            {
                _mode = EditingMode.UserEditsFirstNewResource;
            }
            else
            {
                _mode = EditingMode.UserEditsNewResource;
                _view.UpdateResourceCollectionView(_allResources);
                _view.HighlightLatestResource();
            }

            _view.EnterEditNewMode(newResource);
        }
Exemplo n.º 2
0
 public static void Initialize()
 {
     // Initial whole fields in window.
     _symbolName         = string.Empty;
     _symbolAbbreviation = string.Empty;
     _symbolDescription  = string.Empty;
     _symbolOutlineColor = Color.black;
     _symbolFilledColor  = Color.white;
     _symbolTextColor    = Color.black;
     _symbolTerminal     = NodeTerminalType.Terminal;
     // Set the first values.
     _currentTab               = AlphabetWindowTab.Nodes;
     _isInitTabButton          = true;
     _editingMode              = EditingMode.None;
     _scrollPosition           = Vector2.zero;
     _messageHint              = string.Empty;
     _messageType              = MessageType.Info;
     _node                     = new GraphGrammarNode(NodeTerminalType.Terminal);
     _connection               = new GraphGrammarConnection();
     _symbolListCanvas         = new Rect(0, 0, Screen.width, Screen.height);
     _symbolListCanvasInWindow = _symbolListCanvas;
     _symbolListArea           = new Rect(0, 0, Screen.width, Screen.height);
     _centerPosition           = new Vector2(Screen.width / 2, 75);
     _connectionType           = ConnectionType.WeakRequirement;
     _connectionArrowType      = ConnectionArrowType.Normal;
     // Revoke all.
     Alphabet.RevokeAllSelected();
 }
Exemplo n.º 3
0
        /// <summary>
        /// A keydown event handler
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="keyEventArgs">event args</param>
        private void keyboardActuator_EvtKeyDown(object sender, KeyEventArgs keyEventArgs)
        {
            if (AgentUtils.IsKeyDown(Keys.LMenu) ||
                AgentUtils.IsKeyDown(Keys.RMenu) ||
                AgentUtils.IsKeyDown(Keys.LControlKey) ||
                AgentUtils.IsKeyDown(Keys.RControlKey))
            {
                _currentEditingMode = EditingMode.Edit;
            }
            else if (AgentUtils.IsPrintable(keyEventArgs.KeyCode))
            {
                _currentEditingMode = EditingMode.TextEntry;
            }
            else
            {
                _currentEditingMode = EditingMode.Edit;
            }

            Log.Debug("_currentEditingMode: " + _currentEditingMode);

            if (_currentAgent != null && _currentAgent.TextControlAgent != null)
            {
                _currentAgent.TextControlAgent.OnKeyDown(keyEventArgs);
            }
        }
Exemplo n.º 4
0
			public void SetPoint(EditingMode mode, Point pt)
			{
				if (mode.HasFlag(EditingMode.TopLeft))
					TopLeft = pt;
				if (mode.HasFlag(EditingMode.BottomRight))
					BottomRight = pt;
			}
Exemplo n.º 5
0
        public void ChangeTextdrawMode(string name, EditingMode mode)
        {
            switch (mode)
            {
            case EditingMode.Unselected:
            {
                textdrawList[name].BackColor = textdrawList[name].backColor;
                textdrawList[name].Text      = textdrawList[name].text;
                break;
            }

            case EditingMode.Position:
            {
                textdrawList[name].BackColor = editingColor;
                textdrawList[name].Text      = "Position";
                break;
            }

            case EditingMode.WidthHeight:
            {
                textdrawList[name].BackColor = editingColor;
                textdrawList[name].Text      = "Width/Height";
                break;
            }
            }
            textdrawEditMode[name] = mode;
        }
Exemplo n.º 6
0
        public MainController(MainForm view)
        {
            _view         = view;
            _allResources = new List <TeachingResource>();
            _db           = new FileDatabase("file-database.csv");

            _allResources.AddRange(_db.LoadAllEntries());

            _view.SetupUI();

            if (_allResources.Count == 0)
            {
                _mode = EditingMode.EmptyDatabase;
                _view.EnterNoResourcesMode();
            }
            else
            {
                EnterInitMode();
                _view.UpdateResourceCollectionView(_allResources);
            }

            _view.ResourceEdited            += new EventHandler(ResourceGetsEdited);
            _view.ResourceEditCompleted     += new EventHandler(ResourceGetsUpdated);
            _view.ResourceCreationRequested += new EventHandler(ResourceGetsCreated);
            _view.ResourceDeletionRequested += new EventHandler(ResourceGetsDeleted);
            _view.ResourceSelected          += new MainForm.TeachingResourceHandler(ResourceGetsSelected);
            _view.Canceled += new EventHandler(CurrentActivityCanceled);
            _view.ValidationStateChanged += new MainForm.ValidationChangedHandler(ResourceValidationChanged);
            _view.FormCloseRequested     += new MainForm.CloseFormHandler(FormGetsClosed);
        }
Exemplo n.º 7
0
 private void ResourceGetsEdited(object sender, EventArgs args)
 {
     // editing a new Resource is different than editing an existing Resource
     if (IsUserEditing())
     {
         // editing allowed without further intervention
         return;
     }
     else if (_mode == EditingMode.UserSelectedExistingResource)
     {
         if (_activeResource == null)
         {
             _view.ShowMessageToUser("Es wurde noch kein Eintrag zum Ändern ausgewählt!");
             EnterInitMode();
         }
         else
         {
             _mode = EditingMode.UserEditsExistingResource;
             _view.EnterEditExistingMode();
         }
     }
     else
     {
         throw new InvalidOperationException($"UI ist im {_mode} Modus in dem Editieren nicht erlaubt ist!");
     }
 }
Exemplo n.º 8
0
        private void CurrentActivityCanceled(object sender, EventArgs args)
        {
            if (_mode == EditingMode.UserEditsNewResource)
            {
                // TODO: JS, should we ask user whether he is sure to delete the input?
                _allResources.RemoveAt(_allResources.Count - 1);
                _view.UpdateResourceCollectionView(_allResources);

                EnterInitMode();
            }
            else if (_mode == EditingMode.UserEditsFirstNewResource)
            {
                // TODO: JS, should we ask user whether he is sure to delete the input?
                _allResources.RemoveAt(_allResources.Count - 1);

                _mode = EditingMode.EmptyDatabase;
                _view.EnterNoResourcesMode();
            }
            else if (_mode == EditingMode.UserEditsExistingResource)
            {
                EnterInitMode();
            }
            else
            {
                throw new InvalidOperationException($"UI ist im {_mode} Modus. Darin kann nicht abgebrochen werden!");
            }
        }
Exemplo n.º 9
0
        // Content of submition.
        void LayoutSubmitionButton()
        {
            // When click apply button.
            switch (_editingMode)
            {
            case EditingMode.Create:
                GUI.enabled = (_messageType != MessageType.Error && _messageType != MessageType.Warning);
                if (GUILayout.Button(Languages.GetText("MissionAlphabet-AddSymbol"), SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Regular, SampleStyle.ButtonColor.Green), SampleStyle.SubmitButtonHeight))
                {
                    // When click the button, revoke all selected symbols and add the symbon in list.
                    switch (_currentTab)
                    {
                    case AlphabetWindowTab.Nodes:
                        Alphabet.RevokeAllSelected();
                        Alphabet.AddNode(new GraphGrammarNode(_node));
                        Alphabet.Nodes.Last().Selected = true;
                        break;

                    case AlphabetWindowTab.Connections:
                        Alphabet.RevokeAllSelected();
                        Alphabet.AddConnection(new GraphGrammarConnection(_connection));
                        Alphabet.Connections.Last().Selected = true;
                        break;
                    }
                    // Make the scroll position in list to bottom, and switch to modify mode.
                    _scrollPosition.y = Mathf.Infinity;
                    _editingMode      = EditingMode.Modify;
                    // Unfocus from the field.
                    GUI.FocusControl("FocusToNothing");
                }
                GUI.enabled = true;
                break;

            case EditingMode.Modify:
                GUI.enabled = (_messageType != MessageType.Error && _messageType != MessageType.Warning);
                if (GUILayout.Button(Languages.GetText("MissionAlphabet-UpdateChanges"), SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Regular, SampleStyle.ButtonColor.Green), SampleStyle.SubmitButtonHeight))
                {
                    // When click the button, update the symbol informations.
                    switch (_currentTab)
                    {
                    case AlphabetWindowTab.Nodes:
                        // Update in alphabet and mission grammar.
                        UpdateNode(Alphabet.SelectedNode);
                        MissionGrammar.OnAlphabetUpdated(Alphabet.SelectedNode);
                        break;

                    case AlphabetWindowTab.Connections:
                        // Update in alphabet and mission grammar.
                        UpdateConnection(Alphabet.SelectedConnection);
                        MissionGrammar.OnAlphabetUpdated(Alphabet.SelectedConnection);
                        break;
                    }
                    // Unfocus from the field.
                    GUI.FocusControl("FocusToNothing");
                }
                GUI.enabled = true;
                break;
            }
        }
Exemplo n.º 10
0
 public void PutStart(Vector3 position)
 {
     editingMode     = EditingMode.Checkpoints;
     checkpointIndex = 0;
     editingRace.checkpoints[0].Position = position;
     UpdatePlayerCheckpoint();
     hud.SetSelectedIdx("S", editingMode);
 }
Exemplo n.º 11
0
        private void PressKey(Keys key)
        {
            var t = String.Empty;

            switch (_editMode)
            {
            case EditingMode.FrameName:
                t = _charDef.Frames[_selFrame].Name;
                break;

            case EditingMode.AnimationName:
                t = _charDef.Animations[_selAnim].Name;
                break;

            case EditingMode.PathName:
                t = _charDef.Path;
                break;

            case EditingMode.Script:
                t = _charDef.Animations[_selAnim].KeyFrames[_selKeyFrame].Scripts[_selScriptLine];
                break;
            }

            if (key == Keys.Back)
            {
                if (t.Length > 0)
                {
                    t = t.Substring(0, t.Length - 1);
                }
            }
            else if (key == Keys.Enter)
            {
                _editMode = EditingMode.None;
            }
            else
            {
                t = (t + (char)key).ToLower();
            }

            switch (_editMode)
            {
            case EditingMode.FrameName:
                _charDef.Frames[_selFrame].Name = t;
                break;

            case EditingMode.AnimationName:
                _charDef.Animations[_selAnim].Name = t;
                break;

            case EditingMode.PathName:
                _charDef.Path = t;
                break;

            case EditingMode.Script:
                _charDef.Animations[_selAnim].KeyFrames[_selKeyFrame].Scripts[_selScriptLine] = t;
                break;
            }
        }
Exemplo n.º 12
0
    public override void OnInspectorGUI()
    {
        RoomData data = (RoomData)target;

        mode = (EditingMode)EditorGUILayout.EnumPopup("EditingMode: ", mode);
        EditorGUILayout.LabelField("Transparency: ");
        data.debugTransparency = EditorGUILayout.Slider(data.debugTransparency, 0f, 0.25f);
        base.OnInspectorGUI();
    }
Exemplo n.º 13
0
        internal IStudioDocument OpenFile(EditingMode mode)
        {
            var selectedFiles = _controllers.TranscreateController.GetSelectedProjectFiles();

            if (selectedFiles.Count != 1)
            {
                Enabled = false;
                return(null);
            }

            var project = _controllers.ProjectsController.GetAllProjects().FirstOrDefault(
                a => a.GetProjectInfo().Id.ToString() == selectedFiles[0].ProjectId);

            if (project == null)
            {
                return(null);
            }

            var documents = _controllers.EditorController.GetDocuments();
            var document  =
                documents?.FirstOrDefault(a => a.Files.FirstOrDefault()?.Id.ToString() == selectedFiles[0].FileId);

            if (document != null)
            {
                _controllers.EditorController.Activate();
                _controllers.EditorController.Activate(document);
                return(document);
            }

            if (selectedFiles[0].Action == Enumerators.Action.Export || selectedFiles[0].Action == Enumerators.Action.ExportBackTranslation)
            {
                var activityfile = selectedFiles[0].ProjectFileActivities.OrderByDescending(a => a.Date)
                                   .FirstOrDefault(a => a.Action == Enumerators.Action.Export);

                var message1 = string.Format(PluginResources.Message_FileWasExportedOn, activityfile?.DateToString);
                var message2 =
                    string.Format(PluginResources.Message_WarningTranslationsCanBeOverwrittenDuringImport,
                                  activityfile?.DateToString);
                var message3 = PluginResources.Message_DoYouWantToProceed;

                var dr = MessageBox.Show(message1 + Environment.NewLine + Environment.NewLine + message2 +
                                         Environment.NewLine + Environment.NewLine + message3,
                                         PluginResources.TranscreateManager_Name, MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Question);

                if (dr != DialogResult.Yes)
                {
                    return(null);
                }

                _controllers.TranscreateController.OverrideEditorWarningMessage = true;
            }

            var projectFile = project.GetFile(Guid.Parse(selectedFiles[0].FileId));

            return(_controllers.EditorController.Open(projectFile, mode));
        }
Exemplo n.º 14
0
 public void SetPoint(EditingMode mode, Point pt)
 {
     if (mode.HasFlag(EditingMode.TopLeft))
     {
         TopLeft = pt;
     }
     if (mode.HasFlag(EditingMode.BottomRight))
     {
         BottomRight = pt;
     }
 }
Exemplo n.º 15
0
 public void SetSelectedIdx(string idx, EditingMode editingMode)
 {
     selectedIdx = idx;
     if (editingMode == EditingMode.Checkpoints)
     {
         layer.SetTextdrawText("selectedidx", "Selected CP: " + idx);
     }
     else if (editingMode == EditingMode.SpawnPos)
     {
         layer.SetTextdrawText("selectedidx", "Selected Spawn: " + idx);
     }
 }
Exemplo n.º 16
0
 public void SetEditingMode(EditingMode editingMode)
 {
     layer.SetTextdrawText("editingmode", editingMode.ToString());
     if (editingMode == EditingMode.Checkpoints)
     {
         layer.SetTextdrawText("selectedidx", "Selected CP: " + selectedIdx);
     }
     else if (editingMode == EditingMode.SpawnPos)
     {
         layer.SetTextdrawText("selectedidx", "Selected Spawn: " + selectedIdx);
     }
 }
        /// <summary>
        /// Loads the view model state.
        /// </summary>
        /// <param name="uploadViewModelEditPhotoArgs">The arguments.</param>
        public async Task LoadState(UploadViewModelEditPhotoArgs uploadViewModelEditPhotoArgs)
        {
            await base.LoadState();

            _editingMode = EditingMode.Update;

            Category = uploadViewModelEditPhotoArgs.Category;
            Photo    = uploadViewModelEditPhotoArgs.Photo;
            Comment  = Photo.Caption;

            BitmapImage = new BitmapImage(new Uri(Photo.ImageUrl));
        }
Exemplo n.º 18
0
        private void LoadingRace_Loaded(object sender, RaceLoadedEventArgs e)
        {
            hud.SetRaceName(e.race.Name);
            hud.SetSelectedIdx("S", editingMode);
            hud.SetTotalCP(e.race.checkpoints.Count - 1);

            checkpointIndex = 0;
            editingRace     = e.race;
            UpdatePlayerCheckpoint();
            isEditing   = true;
            editingMode = EditingMode.Checkpoints;
            player.SendClientMessage(Color.Green, "Race #" + e.race.Id + " loaded successfully in creation mode");
        }
Exemplo n.º 19
0
        // Buttons about adding new symbol, modifying and deleting.
        void LayoutEditingModeButtonGroup()
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(Languages.GetText("MissionAlphabet-AddNew"), SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Left, SampleStyle.ButtonColor.Blue), SampleStyle.ButtonHeight))
            {
                // Switch the mode.
                _editingMode = EditingMode.Create;
                // Initial the preview node and connection.
                _node       = new GraphGrammarNode();
                _connection = new GraphGrammarConnection();
                // Initial all fields and repaint.
                Alphabet.RevokeAllSelected();
                InitFields();
                Repaint();
            }
            switch (_currentTab)
            {
            case AlphabetWindowTab.Nodes:
                EditorGUI.BeginDisabledGroup(Alphabet.SelectedNode == null || Alphabet.IsAnyNode(Alphabet.SelectedNode.AlphabetID));
                break;

            case AlphabetWindowTab.Connections:
                EditorGUI.BeginDisabledGroup(Alphabet.SelectedConnection == null);
                break;
            }
            if (GUILayout.Button(Languages.GetText("MissionAlphabet-Modify"), SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Mid, SampleStyle.ButtonColor.Blue), SampleStyle.ButtonHeight))
            {
                // Switch the mode.
                _editingMode = EditingMode.Modify;
            }
            if (GUILayout.Button(Languages.GetText("MissionAlphabet-Delete"), SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Right, SampleStyle.ButtonColor.Blue), SampleStyle.ButtonHeight))
            {
                // Switch the mode.
                _editingMode = EditingMode.Delete;
                // Remove the node or connection from alphabet and repaint.
                switch (_currentTab)
                {
                case AlphabetWindowTab.Nodes:
                    Alphabet.RemoveNode(Alphabet.SelectedNode);
                    break;

                case AlphabetWindowTab.Connections:
                    Alphabet.RemoveConnection(Alphabet.SelectedConnection);
                    break;
                }
                Repaint();
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 20
0
        private void OnMouseLeftButtonClick(MouseState mouseState)
        {
            mouseClick = true;

            if (Text.DrawClickText(5, 5, "Layer: " + layerName, mouseState.X, mouseState.Y, mouseClick))
            {
                currentLayer = (currentLayer + 1) % 3;
            }

            if (Text.DrawClickText(5, 25, "draw: " + layerName, mouseX, mouseY, mouseClick))
            {
                drawingMode = (DrawingMode)((int)(drawingMode + 1) % 3);
            }

            if (drawingMode == DrawingMode.Ledges)
            {
                for (int i = 0; i < 16; i++)
                {
                    var y = (int)ledgePaletteLocation[i].Y;

                    if (Text.DrawClickText(paletteOffsetX, y, "ledge " + i.ToString(), mouseX, mouseY, mouseClick))
                    {
                        currentLedge = i;
                    }

                    if (Text.DrawClickText(768, y, "f" + map.Ledges[i].Flags.ToString(), mouseX, mouseY, mouseClick))
                    {
                        map.Ledges[i].Flags = (map.Ledges[i].Flags + 1) % 2;
                    }
                }
            }

            if (Text.DrawClickText(5, 45, map.Path, mouseX, mouseY, mouseClick))
            {
                editingMode = EditingMode.Path;
            }

            if (DrawButton(5, 65, 3, mouseX, mouseY, mouseClick))
            {
                map.Save();
            }

            if (DrawButton(40, 65, 4, mouseX, mouseY, mouseClick))
            {
                map.Load();
            }

            Console.WriteLine("X = {0}, Y = {1}", mouseState.X, mouseState.Y);
        }
Exemplo n.º 21
0
 public void PutFinish(Vector3 position)
 {
     editingMode     = EditingMode.Checkpoints;
     checkpointIndex = editingRace.checkpoints.Count - 1;
     if (editingRace.checkpoints[checkpointIndex].Type == CheckpointType.Finish || editingRace.checkpoints[checkpointIndex].Type == CheckpointType.AirFinish)
     {
         editingRace.checkpoints[checkpointIndex].Position = position + new Vector3(0.0, 5.0, 0.0);
     }
     else
     {
         editingRace.checkpoints.Add(editingRace.checkpoints.Count, new Checkpoint(position + new Vector3(0.0, 5.0, 0.0), CheckpointType.Finish));
     }
     UpdatePlayerCheckpoint();
     hud.SetSelectedIdx("F", editingMode);
 }
Exemplo n.º 22
0
        public void AddCheckpoint(Vector3 position)
        {
            editingMode = EditingMode.Checkpoints;
            int idx = editingRace.checkpoints.Count;

            while (editingRace.checkpoints.ContainsKey(idx))
            {
                editingRace.checkpoints[idx] = editingRace.checkpoints[idx - 1];
                idx--;
            }

            checkpointIndex++;
            editingRace.checkpoints.Add(checkpointIndex, new Checkpoint(position, CheckpointType.Normal));
            UpdatePlayerCheckpoint();
            hud.SetSelectedIdx(checkpointIndex.ToString(), editingMode);
        }
Exemplo n.º 23
0
        //protected override bool IsInputKey(Keys keyData)
        //{
        //    // Make sure we get arrow keys
        //    switch(keyData)
        //    {
        //        case Keys.Up:
        //        case Keys.Left:
        //        case Keys.Down:
        //        case Keys.Right:
        //            return true;
        //    }

        //    // The rest can be determined by the base class
        //    return base.IsInputKey(keyData);
        //}

        //protected override void OnKeyUp(KeyEventArgs e)
        //{
        //    base.OnKeyDown(e);

        //    //MessageBox.Show("raw key:" + e.KeyCode.ToString(), "debug");
        //    //MessageBox.Show("Keys.KeyCode:" + Keys.KeyCode.ToString(), "debug");
        //    //MessageBox.Show("e.KeyCode:" + e.KeyCode.ToString(), "debug");

        //    switch(Keys.KeyCode & e.KeyCode)
        //    {
        //        case Keys.Up:
        //            if(iScrnRow > 0)
        //                iScrnRow--;
        //            break;

        //        case Keys.Down:
        //            if(iScrnRow < 28)
        //                iScrnRow++;
        //            break;

        //        case Keys.Left:
        //            if(iScrnCol > 0)
        //                iScrnCol--;
        //            break;

        //        case Keys.Right:
        //            if(iScrnCol < 39)
        //                iScrnCol++;
        //            break;
        //    }

        //    NewDrawTextPreview();
        //    pictureBox1.Image = screenImage;
        //}

        public TextScreenEditorForm()
        {
            InitializeComponent();

            m_ui16DataLength   = 0;
            m_ui16StartAddress = 0;

            scrnCol = 0;
            scrnRow = 0;

            cScrnPaper = 0;
            cScrnInk   = 7;

            bScrnUpdated = false;

            // Load the standard character set
            BuildCharSet();

            labelSelectedPaperColour.BackColor = Color.Black;
            labelSelectedPaperColour.Tag       = 0;

            labelSelectedInkColour.BackColor = Color.White;
            labelSelectedInkColour.Tag       = 7;

            radioButtonSingle.Checked = true;
            radioButtonSteady.Checked = true;

            screenImage = new Bitmap(pictureBoxEditor.Width, pictureBoxEditor.Height);

            fileInfo = new OricFileInfo();
            oricDisk = new OricDisk();
            oricTape = new OricTape();

            loadedProgram = new OricProgram();

            bShowGrid          = true;
            bShowAttrIndicator = true;

            m_bFlash = true;

            _ZoomFactor = 2;

            radioButtonColourMode.Checked = true;
            editMode = EditingMode.COLOUR_MODE;
        }
Exemplo n.º 24
0
        // Native function for Editor Window.
        void OnGUI()
        {
            if (_isInitTabButton)
            {
                NodeTabButtonStyle       = new GUIStyle(SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Left, SampleStyle.ButtonColor.Blue));
                ConnectionTabButtonStyle = new GUIStyle(SampleStyle.GetButtonStyle(SampleStyle.ButtonType.Right, SampleStyle.ButtonColor.Blue));
                _isInitTabButton         = false;
            }
            SampleStyle.DrawWindowBackground(SampleStyle.ColorGrey);
            // Buttons - Nodes or Connections.
            GUILayout.BeginVertical(SampleStyle.Frame(SampleStyle.ColorLightestGrey));
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Toggle(_currentTab == AlphabetWindowTab.Nodes, Languages.GetText("MissionAlphabet-Tab-Nodes"), NodeTabButtonStyle, SampleStyle.TabButtonHeight))
            {
                _editingMode = (_currentTab != AlphabetWindowTab.Nodes) ? EditingMode.None : _editingMode;
                _currentTab  = AlphabetWindowTab.Nodes;
            }
            if (GUILayout.Toggle(_currentTab == AlphabetWindowTab.Connections, Languages.GetText("MissionAlphabet-Tab-Connections"), ConnectionTabButtonStyle, SampleStyle.TabButtonHeight))
            {
                _editingMode = (_currentTab != AlphabetWindowTab.Connections) ? EditingMode.None : _editingMode;
                _currentTab  = AlphabetWindowTab.Connections;
            }
            EditorGUILayout.EndHorizontal();
            // Toggle for nodes interface and connection interface.
            switch (_currentTab)
            {
            case AlphabetWindowTab.Nodes:
                // Header.
                GUILayout.Label(Languages.GetText("MissionAlphabet-List-Nodes"), SampleStyle.HeaderTwo, SampleStyle.HeaderTwoHeightLayout);
                // Content of nodes.
                LayoutNodesInterface();
                break;

            case AlphabetWindowTab.Connections:
                // Header.
                GUILayout.Label(Languages.GetText("MissionAlphabet-List-Connections"), SampleStyle.HeaderTwo, SampleStyle.HeaderTwoHeightLayout);
                // Content of connections.
                LayoutConnectionsInterface();
                break;
            }

            // Event controller.
            EventController();
            GUILayout.EndVertical();
        }
Exemplo n.º 25
0
        void picPreview_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu || e.KeyCode == Keys.ControlKey)
            {
                return;
            }
            else if (e.KeyCode == Keys.Enter)
            {
                if (mode == EditingMode.TopLeft)
                {
                    mode = EditingMode.BottomRight;
                }
                else
                {
                    mode = EditingMode.TopLeft;
                }
                return;
            }
            Point loc = rectangle.GetPoint(mode);
            int   dif = e.Control ? 10 : 1;

            if (e.KeyCode == Keys.Left)
            {
                key |= KeyMode.Left;
            }
            else if (e.KeyCode == Keys.Right)
            {
                key |= KeyMode.Right;
            }
            else if (e.KeyCode == Keys.Up)
            {
                key |= KeyMode.Up;
            }
            else if (e.KeyCode == Keys.Down)
            {
                key |= KeyMode.Down;
            }
            loc.Offset(
                (key & KeyMode.Horizontal) != 0 ? (key.HasFlag(KeyMode.Left) ? -dif : dif) : 0,
                (key & KeyMode.Vertical) != 0 ? (key.HasFlag(KeyMode.Up) ? -dif : dif) : 0);
            loc = GetVerifiedLocation(loc);
            rectangle.SetPoint(e.Shift ? EditingMode.TopLeft | EditingMode.BottomRight : mode, loc);
            picPreview.Invalidate();
        }
        void InitializeMessageAndParameterData()
        {
            ModelItem        parameterModelItem;
            ModelTreeManager modelTreeManager = (this.ModelItem as IModelTreeItem).ModelTreeManager;

            ModelItem contentModelItem = this.ModelItem.Properties["Content"].Value;

            if (contentModelItem == null)
            {
                this.messageExpression   = modelTreeManager.WrapAsModelItem(new TMessage()).Properties["Message"].Value;
                this.declaredMessageType = null;
                parameterModelItem       = modelTreeManager.WrapAsModelItem(new TParameter()).Properties["Parameters"].Value;
            }
            else
            {
                if (contentModelItem.ItemType == typeof(TMessage))
                {
                    this.editingMode         = EditingMode.Message;
                    this.messageExpression   = contentModelItem.Properties["Message"].Value;
                    this.declaredMessageType = (Type)contentModelItem.Properties["DeclaredMessageType"].ComputedValue;
                    parameterModelItem       = modelTreeManager.WrapAsModelItem(new TParameter()).Properties["Parameters"].Value;
                }
                else
                {
                    this.editingMode         = EditingMode.Parameter;
                    this.messageExpression   = modelTreeManager.WrapAsModelItem(new TMessage()).Properties["Message"].Value;
                    this.declaredMessageType = null;
                    parameterModelItem       = contentModelItem.Properties["Parameters"].Value;
                }
            }

            bool isDictionary;
            Type underlyingArgumentType;

            this.DynamicArguments = DynamicArgumentDesigner.ModelItemToWrapperCollection(
                parameterModelItem,
                out isDictionary,
                out underlyingArgumentType);

            this.IsDictionary           = isDictionary;
            this.UnderlyingArgumentType = underlyingArgumentType;
        }
Exemplo n.º 27
0
        void blogPostHtmlEditor_DocumentComplete(object sender, EventArgs e)
        {
            _documentComplete = true;

            if (_editMode != null && _editMode.HasValue)
            {
                EditingMode mode = _editMode.Value;
                _editMode = null;
                ChangeView(mode);
                return;
            }

            while (delayedInsertOperations.Count > 0)
            {
                DelayedInsert insert = delayedInsertOperations.Dequeue();
                InsertHtml(insert.Content, insert.Options);
            }

            _contentEditorSite.OnDocumentComplete();
        }
Exemplo n.º 28
0
        private void DrawAnimationList()
        {
            for (var i = _animScroll; i < _animScroll + 15; i++)
            {
                if (i < _charDef.Animations.Length)
                {
                    var y = (i - _animScroll) * 15 + 5;
                    if (i == _selAnim)
                    {
                        _text.Color = Color.Lime;

                        _text.DrawText(5, y,
                                       i + ": " + _charDef.Animations[i].Name +
                                       ((_editMode == EditingMode.AnimationName) ? "*" : ""));
                    }
                    else
                    {
                        if (_text.DrawClickText(5, y, i + ": " + _charDef.Animations[i].Name, _mouseState.X,
                                                _mouseState.Y, _mouseClick))
                        {
                            _selAnim  = i;
                            _editMode = EditingMode.AnimationName;
                        }
                    }
                }
            }

            if (DrawButton(170, 5, 1, _mouseState.X, _mouseState.Y, (_mouseState.LeftButton == ButtonState.Pressed)) &&
                _animScroll > 0)
            {
                _animScroll--;
            }

            if (
                DrawButton(170, 200, 2, _mouseState.X, _mouseState.Y, (_mouseState.LeftButton == ButtonState.Pressed)) &&
                _animScroll < _charDef.Animations.Length - 15)
            {
                _animScroll++;
            }
        }
Exemplo n.º 29
0
        // [TODO] Temporary. The click event listener for list canvas.
        void OnClickedElementInList(float y)
        {
            if (y > 0 && y < SymbolList.Height)
            {
                // [TODO] This is temporary to assign value, will promote it soon.
                int index = (int)(y + _scrollPosition.y) / 50;
                Alphabet.RevokeAllSelected();
                switch (_currentTab)
                {
                case AlphabetWindowTab.Nodes:
                    if (index < Alphabet.Nodes.Count)
                    {
                        Alphabet.Nodes[index].Selected = true;
                        UpdateFields(Alphabet.Nodes[index]);
                    }
                    else
                    {
                        // Initial the fields.
                        InitFields();
                    }
                    break;

                case AlphabetWindowTab.Connections:
                    if (index < Alphabet.Connections.Count)
                    {
                        Alphabet.Connections[index].Selected = true;
                        UpdateFields(Alphabet.Connections[index]);
                    }
                    else
                    {
                        // Initial the fields.
                        InitFields();
                    }
                    break;
                }
                // Switch to the normal mode.
                _editingMode = EditingMode.None;
            }
        }
Exemplo n.º 30
0
        public RaceCreator(Player _player)
        {
            player = _player;
            player.KeyStateChanged     += Player_KeyStateChanged;
            player.EnterCheckpoint     += Player_EnterCheckpoint;
            player.EnterRaceCheckpoint += Player_EnterRaceCheckpoint;

            if (!player.InAnyVehicle)
            {
                BaseVehicle veh = BaseVehicle.Create(VehicleModelType.Infernus, player.Position + new Vector3(0.0, 5.0, 0.0), 0.0f, 1, 1);
                player.PutInVehicle(veh);
            }

            hud = new HUD(_player);

            editingRace     = null;
            isEditing       = false;
            editingMode     = EditingMode.Checkpoints;
            checkpointIndex = 0;

            spawnVehicles = new BaseVehicle[Race.MAX_PLAYERS_IN_RACE];
        }
Exemplo n.º 31
0
        public void ChangeView(EditingMode editingMode)
        {
            if (!_documentComplete)
            {
                _editMode = editingMode;
                return;
            }

            try
            {
                switch (editingMode)
                {
                case EditingMode.Wysiwyg:
                    contentEditor.ChangeToWysiwygMode();
                    return;

                case EditingMode.Source:
                    contentEditor.ChangeToCodeMode();
                    return;

                case EditingMode.Preview:
                    contentEditor.ChangeToPreviewMode();
                    return;

                case EditingMode.PlainText:
                    contentEditor.ChangeToPlainTextMode();
                    return;
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                throw;
            }


            Debug.Fail("Unknown value for editingView: " + editingMode.ToString() + "\r\nAccepted values Wysiwyg, Source, Preview, PlainText");
        }
Exemplo n.º 32
0
        private void ChangeEditor(EditingMode mode, bool editMode)
        {
            // Clean up any items that are associated with this editing mode.
            DisposeItemsOnEditorChange();

            bool isDirty = _currentEditor != null && _currentEditor.IsDirty;

            // Change the editing mode
            _currentEditingMode = mode;

            // Disable or enable any of commands on the ribbon
            ManageCommandsForEditingMode();

            // Lets the user edit the document
            _normalHtmlContentEditor.SetEditable(editMode);
            SetCurrentEditor();

            // Set the orginal dirty state back
            _currentEditor.IsDirty = isDirty;

            // Let everyone the editor just changed (tabs will update)
            FireEditorLoaded();
        }
Exemplo n.º 33
0
        private void DrawScriptRegion()
        {
            spriteBatch.Begin();
            spriteBatch.Draw(nullTexture, new Rectangle(400, 20, 400, 565), new Color(new Vector4(0f, 0f, 0f, .62f)));
            spriteBatch.End();

            for (int i = scriptScroll; i < scriptScroll + 28; i++)
            {
                if (selectedScript == i)
                {
                    text.color = Color.White;
                    text.DrawText(405, 25 + (i - scriptScroll) * 20,
                    i.ToString() + ": " + map.Scripts[i] + "*");
                }
                else
                {
                    if (text.DrawClickText(405, 25 + (i - scriptScroll) * 20,i.ToString() + ": " + map.Scripts[i],mouseX, mouseY, mouseClick))
                    {
                        selectedScript = i;
                        editmode = EditingMode.Script;
                    }
                }

                if (map.Scripts[i].Length > 0)
                {
                    String[] split = map.Scripts[i].Split(' ');
                    int c = GetCommandColor(split[0]);
                    if (c > COLOR_NONE)
                    {
                        switch (c)
                        {
                            case COLOR_GREEN:
                                text.color = Color.Lime;
                                break;
                            case COLOR_YELLOW:
                                text.color = Color.Yellow;
                                break;
                        }
                        text.DrawText(405, 25 + (i - scriptScroll) * 20,
                            i.ToString() + ": " + split[0]);
                    }
                }
                text.color = Color.White;
                text.DrawText(405, 25 + (i - scriptScroll) * 20,
                    i.ToString() + ": ");

            }

            if (DrawButton(770, 20, upArrowTexture, mouseX, mouseY, mouseClick) &&
                   scriptScroll > 0)
                scriptScroll--;

            if (DrawButton(770, 550, downArrowTexture, mouseX, mouseY, mouseClick) &&
                scriptScroll < map.Scripts.Length - 28)
                scriptScroll++;
        }
Exemplo n.º 34
0
        /// <summary>
        /// Draws the frames list in the lower right corner of editor.
        /// Pressing the (a) button next to a frame adds it as KeyFrame to the current Animation
        /// Frames can be renamed
        /// </summary>
        private void DrawFramesList()
        {
            for (int i = frameScroll; i < frameScroll + 20; i++)
            {
                if (i < characterDefinition.Frames.Length)
                {
                    int y = (i - frameScroll) * 15 + 280;
                    if (i == selectedFrame)
                    {
                        text.color = Color.Lime;
                        text.DrawText(600, y, i.ToString() + ": " + characterDefinition.Frames[i].Name + (editmode == EditingMode.FrameName ? "*" : ""));

                        // clicking the (a) will add a reference of this frame to the selected animation
                        if (text.DrawClickText(720,y,"(a)",mouseState.X,mouseState.Y,mouseClick))
                        {
                            Animation animation = characterDefinition.Animations[selectedAnimation];

                            for (int j = 0; j < animation.KeyFrames.Length; j++)
                            {
                                KeyFrame keyFrame = animation.KeyFrames[j];
                                if (keyFrame.FrameReference == -1)
                                {
                                    keyFrame.FrameReference = i;
                                    keyFrame.Duration = 1;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        // clicking a new frame will create a copy of the old frame
                        if (text.DrawClickText(600,y,i.ToString() + ": " + characterDefinition.Frames[i].Name,mouseState.X,mouseState.Y,mouseClick))
                        {
                            if (selectedFrame != i)
                            {
                                if (String.IsNullOrEmpty(characterDefinition.Frames[i].Name))
                                    CopyFrame(selectedFrame, i);

                                selectedFrame = i;
                                editmode = EditingMode.FrameName;
                            }
                        }
                    }
                }
            }
            //draw arrow buttons to scroll up or down the list
            if (DrawScrollButton(770, 280, upArrowTexture, mouseState.X, mouseState.Y, (mouseState.LeftButton == ButtonState.Pressed)) && frameScroll > 0 )
                frameScroll--;
            if (DrawScrollButton(770, 570, downArrowTexture, mouseState.X, mouseState.Y, (mouseState.LeftButton == ButtonState.Pressed)) && frameScroll < characterDefinition.Frames.Length - 20)
                frameScroll++;
        }
Exemplo n.º 35
0
        //private void PressKey(Keys key)
        //{
        //    String t = "";
        //    switch (editmode)
        //    {
        //        case EditingMode.None:
        //            t = map.Path;
        //            break;
        //        case EditingMode.Script:
        //            if (selectedScript < 0)
        //                return;
        //            t = map.Scripts[selectedScript];
        //            break;
        //        default:
        //            return;
        //    }
        //    bool delLine = false;
        //    if (key == Keys.Back)
        //    {
        //        if (t.Length > 0)
        //            t = t.Substring(0, t.Length - 1);
        //        else if (editmode == EditingMode.Script)
        //        {
        //            delLine = ScriptDelLine();
        //        }
        //    }
        //    else if (key == Keys.Enter)
        //    {
        //        if (editmode == EditingMode.Script)
        //        {
        //            if (ScriptEnter())
        //            {
        //                t = "";
        //            }
        //        }
        //        else
        //            editmode = EditingMode.None;
        //    }
        //    else
        //    {
        //        t = (t + (char)key).ToLower();
        //    }
        //    if (!delLine)
        //    {
        //        switch (editmode)
        //        {
        //            case EditingMode.Path:
        //                map.Path = t;
        //                break;
        //            case EditingMode.Script:
        //                map.Scripts[selectedScript] = t;
        //                break;
        //        }
        //    }
        //    else
        //        selectedScript--;
        //}
        // Adds Keypress to string
        // TODO: very crude implementation
        private void PressKey(Keys key)
        {
            string t = String.Empty;
            switch (editmode)
            {
                case EditingMode.None:
                    break;
                case EditingMode.Path:
                    t = map.Path;
                    break;
                default:
                    break;
            }

            if (key == Keys.Back)
            {
                if (t.Length > 0)
                    t = t.Substring(0, t.Length - 1);
            }
            else if (key == Keys.Enter)
            {
                editmode = EditingMode.None;
            }
            else
            {
                t = (t + (char)key).ToLower();
            }

            switch (editmode)
            {
                case EditingMode.None:
                    break;
                case EditingMode.Path:
                    map.Path = t;
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 36
0
        public void ChangeView(EditingMode editingMode)
        {
            if (!_documentComplete)
            {
                _editMode = editingMode;
                return;
            }

            try
            {
                switch (editingMode)
                {
                    case EditingMode.Wysiwyg:
                        contentEditor.ChangeToWysiwygMode();
                        return;
                    case EditingMode.Source:
                        contentEditor.ChangeToCodeMode();
                        return;
                    case EditingMode.Preview:
                        contentEditor.ChangeToPreviewMode();
                        return;
                    case EditingMode.PlainText:
                        contentEditor.ChangeToPlainTextMode();
                        return;

                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                throw;
            }

            Debug.Fail("Unknown value for editingView: " + editingMode.ToString() + "\r\nAccepted values Wysiwyg, Source, Preview, PlainText");

        }
Exemplo n.º 37
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            //draw dark-blue background rectangle for animation and keyframe list
            spriteBatch.Draw(nullTexture, new Rectangle(0, 0, 200, 450), new Color(new
                Vector4(0.0f, 0.0f, 0.0f, 0.5f)));
            //draw dark-blue background rectangle for part and frame list
            spriteBatch.Draw(nullTexture, new Rectangle(590, 0, 300, 600), new Color(new
                Vector4(0.0f, 0.0f, 0.0f, 0.5f)));
            // red bar at the bottom
            spriteBatch.Draw(nullTexture, new Rectangle(300, 450, 200, 5), new Color(new
             Vector4(1.0f, 0.0f, 0.0f, 0.5f)));
            // draw background rectangle for save and load buttons and scripts
            spriteBatch.Draw(nullTexture, new Rectangle(200, 0, 150, 110), new Color(new
                Vector4(0.0f, 0.0f, 0.0f, 0.5f)));

            spriteBatch.End();

            // draw onionskin effect - previews frame next to currently selected frame
            // so we draw our character thrice on the screen (twice with low alpha)
            if (selectedFrame > 0)
                DrawCharacter(new Vector2(400f, 450f), 2f, FACE_RIGHT, selectedFrame - 1, false, 0.2f);
            if (selectedFrame < characterDefinition.Frames.Length - 1)
                DrawCharacter(new Vector2(400f, 450f), 2f, FACE_RIGHT, selectedFrame + 1, false, 0.2f);
            DrawCharacter(new Vector2(400f, 450f), 2f, FACE_RIGHT, selectedFrame, false, 1.0f);

            DrawPalette();
            DrawPartList();
            DrawFramesList();
            DrawAnimationList();
            DrawKeyFrameList();

            int fref = characterDefinition.Animations[selectedAnimation].KeyFrames[currentKeyFrame].FrameReference;
            if (fref < 0)
                fref = 0;

            DrawCharacter(new Vector2(500f, 100f), 0.5f, FACE_LEFT, fref, true, 1.0f);
            if (playing)
            {
                if (text.DrawClickText(480, 100, "stop", mouseState.X, mouseState.Y, mouseClick))
                    playing = false;
            }
            else
            {
                if (text.DrawClickText(480, 100, "play", mouseState.X, mouseState.Y, mouseClick))
                    playing = true;
            }

            if (DrawIconAsButton(245, 5, saveIcon, mouseState.X, mouseState.Y, mouseClick))
                characterDefinition.Write();
            if (DrawIconAsButton(205, 5, openFolderIcon, mouseState.X, mouseState.Y, mouseClick))
                characterDefinition.Read();

            if (editmode == EditingMode.PathName)
            {
                text.color = Color.Lime;

                text.DrawText(270, 15, characterDefinition.Path + "*");
            }
            else
            {
                if (text.DrawClickText(280, 15, characterDefinition.Path, mouseState.X, mouseState.Y, mouseClick))
                    editmode = EditingMode.PathName;
            }

            #region Script
            if (auxMode == AUX_SCRIPT)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (editmode == EditingMode.Script && selectedScriptLine == i)
                    {
                        text.color = Color.Lime;
                        text.DrawText(210, 42 + i * 16, i.ToString() + ": " + characterDefinition.Animations[selectedAnimation].KeyFrames[selectedKeyFrame].Scripts[i] + "*");
                    }
                    else
                    {
                        if (text.DrawClickText(210, 42 + i * 16, i.ToString() + ": " + characterDefinition.Animations[selectedAnimation].KeyFrames[selectedKeyFrame].Scripts[i], mouseState.X, mouseState.Y, mouseClick))
                        {
                            selectedScriptLine = i;
                            editmode = EditingMode.Script;
                        }
                    }
                }
            }
            #endregion

            #region Triggers
            if (auxMode == AUX_TRIGS)
            {
                if (DrawIconAsButton(330, 42, upArrowTexture, mouseState.X, mouseState.Y, mouseClick))
                    if (trigScroll > 0)
                        trigScroll--;
                if (DrawIconAsButton(330, 92, downArrowTexture, mouseState.X, mouseState.Y, mouseClick))
                    if (trigScroll < 100)
                        trigScroll++;

                for (int i = 0; i < 10; i++)
                {
                    int t = i + trigScroll;
                    if (text.DrawClickText(210, 42 + i * 16, GetTrigName(t), mouseState.X, mouseState.Y, mouseClick))
                        characterDefinition.Frames[selectedFrame].Parts[selectedPart].Index = t + 1000;
                }
            }
            #endregion

            #region Script/Trigger Selector
            if (auxMode == AUX_SCRIPT)
            {
                text.color = Color.Lime;
                text.DrawText(210, 110, "script");
            }
            else
            {
                if (text.DrawClickText(210, 110, "script", mouseState.X, mouseState.Y, mouseClick))
                    auxMode = AUX_SCRIPT;
            }

            if (auxMode == AUX_TRIGS)
            {
                text.color = Color.Lime;
                text.DrawText(260, 110, "trigs");
            }
            else
            {
                if (text.DrawClickText(260, 110, "trigs", mouseState.X, mouseState.Y, mouseClick))
                    auxMode = AUX_TRIGS;
            }

            if (auxMode == AUX_TEXTURE)
            {
                text.color = Color.Lime;
                text.DrawText(300, 110, "tex");
            }
            else
            {
                if (text.DrawClickText(300, 110, "tex", mouseState.X, mouseState.Y, mouseClick))
                    auxMode = AUX_TEXTURE;

            }
            #endregion

            #region Texture Switching
            if (auxMode == AUX_TEXTURE)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (DrawIconAsButton(210 + i * 21,40,upArrowTexture,mouseState.X,mouseState.Y,mouseClick))
                    {
                        switch (i)
                        {
                            case 0:
                                if (characterDefinition.HeadIndex > 0)
                                    characterDefinition.HeadIndex--;
                                break;
                            case 1:
                                if (characterDefinition.TorsoIndex > 0)
                                    characterDefinition.TorsoIndex--;
                                break;
                            case 2:
                                if (characterDefinition.LegsIndex > 0)
                                    characterDefinition.LegsIndex--;
                                break;
                            case 3:
                                if (characterDefinition.WeaponIndex > 0)
                                    characterDefinition.WeaponIndex--;
                                break;
                            default:
                                break;
                        }
                    }

                    string t = characterDefinition.HeadIndex.ToString();

                    switch (i)
                    {
                        case 1:
                            t = characterDefinition.TorsoIndex.ToString();
                            break;
                        case 2:
                            t = characterDefinition.LegsIndex.ToString();
                            break;
                        case 3:
                            t = characterDefinition.WeaponIndex.ToString();
                            break;
                        default:
                            break;
                    }

                    text.color = Color.White;
                    text.DrawText(212 + i * 21, 60, t);

                    if (DrawIconAsButton(210 + i * 21, 85, downArrowTexture, mouseState.X,mouseState.Y,mouseClick))
                    {
                        switch (i)
                        {
                            case 0:
                                if (characterDefinition.HeadIndex < headTexture.Length - 1)
                                    characterDefinition.HeadIndex++;
                                break;
                            case 1:
                                if (characterDefinition.TorsoIndex < torsoTexture.Length - 1)
                                    characterDefinition.TorsoIndex++;
                                break;
                            case 2:
                                if (characterDefinition.LegsIndex < legsTexture.Length - 1)
                                    characterDefinition.LegsIndex++;
                                break;
                            case 3:
                                if (characterDefinition.WeaponIndex < weaponTexture.Length - 1)
                                    characterDefinition.WeaponIndex++;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            #endregion

            mouseClick = false;

            base.Draw(gameTime);
        }
Exemplo n.º 38
0
		void picPreview_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.Menu || e.KeyCode == Keys.ControlKey)
				return;
			else if (e.KeyCode == Keys.Enter)
			{
				if (mode == EditingMode.TopLeft)
					mode = EditingMode.BottomRight;
				else
					mode = EditingMode.TopLeft;
				return;
			}
			Point loc = rectangle.GetPoint(mode);
			int dif = e.Control ? 10 : 1;
			if (e.KeyCode == Keys.Left)
				key |= KeyMode.Left;
			else if (e.KeyCode == Keys.Right)
				key |= KeyMode.Right;
			else if (e.KeyCode == Keys.Up)
				key |= KeyMode.Up;
			else if (e.KeyCode == Keys.Down)
				key |= KeyMode.Down;
			loc.Offset(
				(key & KeyMode.Horizontal) != 0 ? (key.HasFlag(KeyMode.Left) ? -dif : dif) : 0,
				(key & KeyMode.Vertical) != 0 ? (key.HasFlag(KeyMode.Up) ? -dif : dif) : 0);
			loc = GetVerifiedLocation(loc);
			rectangle.SetPoint(e.Shift ? EditingMode.TopLeft | EditingMode.BottomRight : mode, loc);
			picPreview.Invalidate();
		}
Exemplo n.º 39
0
        private void PressKey(Keys key)
        {
            var t = String.Empty;

            switch (_editMode)
            {
                case EditingMode.FrameName:
                    t = _charDef.Frames[_selFrame].Name;
                    break;
                case EditingMode.AnimationName:
                    t = _charDef.Animations[_selAnim].Name;
                    break;
                case EditingMode.PathName:
                    t = _charDef.Path;
                    break;
                case EditingMode.Script:
                    t = _charDef.Animations[_selAnim].KeyFrames[_selKeyFrame].Scripts[_selScriptLine];
                    break;
            }

            if (key == Keys.Back)
            {
                if (t.Length > 0) t = t.Substring(0, t.Length - 1);
            }
            else if (key == Keys.Enter)
            {
                _editMode = EditingMode.None;
            }
            else
            {
                t = (t + (char)key).ToLower();
            }

            switch (_editMode)
            {
                case EditingMode.FrameName:
                    _charDef.Frames[_selFrame].Name = t;
                    break;
                case EditingMode.AnimationName:
                    _charDef.Animations[_selAnim].Name = t;
                    break;
                case EditingMode.PathName:
                    _charDef.Path = t;
                    break;
                case EditingMode.Script:
                    _charDef.Animations[_selAnim].KeyFrames[_selKeyFrame].Scripts[_selScriptLine] = t;
                    break;
            }
        }
Exemplo n.º 40
0
 private void StopEditing()
 {
     mode = EditingMode.NotEditing;
     pulseEnabled = false;
     lines = null;
     this.moveNub.Visible = false;
 }
Exemplo n.º 41
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
                case (char)13: // Enter
                    if (tracking)
                    {
                        e.Handled = true;
                    }
                    break;

                case (char)27: // Escape
                    if (tracking)
                    {
                        e.Handled = true;
                    }
                    else
                    {
                        if (mode == EditingMode.Editing)
                        {
                            SaveHistoryMemento();
                        }
                        else if (mode == EditingMode.EmptyEdit)
                        {
                            RedrawText(false);
                        }

                        if (mode != EditingMode.NotEditing)
                        {
                            e.Handled = true;
                            StopEditing();
                        }
                    }

                    break;
            }

            if (!e.Handled && mode != EditingMode.NotEditing && !tracking)
            {
                e.Handled = true;

                if (mode == EditingMode.EmptyEdit)
                {
                    mode = EditingMode.Editing;
                    CompoundHistoryMemento cha = new CompoundHistoryMemento(Name, Image, new List<HistoryMemento>());
                    this.currentHA = cha;
                    HistoryStack.PushNewMemento(cha);
                }

                if (!char.IsControl(e.KeyChar))
                {
                    InsertCharIntoString(e.KeyChar);
                    textPos++;
                    RedrawText(true);
                }
            }

            base.OnKeyPress (e);
        }
Exemplo n.º 42
0
 private void StartEditing()
 {
     this.linePos = 0;
     this.textPos = 0;
     this.lines = new ArrayList();
     this.sizes = null;
     this.lines.Add(string.Empty);
     this.startTime = DateTime.Now;
     this.mode = EditingMode.EmptyEdit;
     this.pulseEnabled = true;
     UpdateStatusText();
 }
Exemplo n.º 43
0
        protected override void OnActivate()
        {
            PdnBaseForm.RegisterFormHotKey(Keys.Back, OnBackspaceTyped);

            base.OnActivate();

            this.textToolCursor = new Cursor(PdnResources.GetResourceStream("Cursors.TextToolCursor.cur"));
            this.Cursor = this.textToolCursor;

            fontChangedDelegate = new EventHandler(FontChangedHandler);
            fontSmoothingChangedDelegate = new EventHandler(FontSmoothingChangedHandler);
            alignmentChangedDelegate = new EventHandler(AlignmentChangedHandler);
            brushChangedDelegate = new EventHandler(BrushChangedHandler);
            antiAliasChangedDelegate = new EventHandler(AntiAliasChangedHandler);
            foreColorChangedDelegate = new EventHandler(ForeColorChangedHandler);

            ra = new RenderArgs(((BitmapLayer)ActiveLayer).Surface);
            mode = EditingMode.NotEditing;

            font = AppEnvironment.FontInfo.CreateFont();
            alignment = AppEnvironment.TextAlignment;

            AppEnvironment.BrushInfoChanged += brushChangedDelegate;
            AppEnvironment.FontInfoChanged += fontChangedDelegate;
            AppEnvironment.FontSmoothingChanged += fontSmoothingChangedDelegate;
            AppEnvironment.TextAlignmentChanged += alignmentChangedDelegate;
            AppEnvironment.AntiAliasingChanged += antiAliasChangedDelegate;
            AppEnvironment.PrimaryColorChanged += foreColorChangedDelegate;
            AppEnvironment.SecondaryColorChanged += new EventHandler(BackColorChangedHandler);
            AppEnvironment.AlphaBlendingChanged += new EventHandler(AlphaBlendingChangedHandler);

            this.threadPool = new PaintDotNet.Threading.ThreadPool();

            this.moveNub = new MoveNubRenderer(this.RendererList);
            this.moveNub.Shape = MoveNubShape.Compass;
            this.moveNub.Size = new SizeF(10, 10);
            this.moveNub.Visible = false;
            this.RendererList.Add(this.moveNub, false);
        }
Exemplo n.º 44
0
			public Point GetPoint(EditingMode mode) { return mode == EditingMode.TopLeft ? TopLeft : BottomRight; }
Exemplo n.º 45
0
        private void DrawAnimationList()
        {
            for (var i = _animScroll; i < _animScroll + 15; i++)
            {
                if (i < _charDef.Animations.Length)
                {
                    var y = (i - _animScroll) * 15 + 5;
                    if (i == _selAnim)
                    {
                        _text.Color = Color.Lime;

                        _text.DrawText(5, y,
                            i + ": " + _charDef.Animations[i].Name +
                            ((_editMode == EditingMode.AnimationName) ? "*" : ""));
                    }
                    else
                    {
                        if (_text.DrawClickText(5, y, i + ": " + _charDef.Animations[i].Name, _mouseState.X,
                            _mouseState.Y, _mouseClick))
                        {
                            _selAnim = i;
                            _editMode = EditingMode.AnimationName;
                        }
                    }
                }
            }

            if (DrawButton(170, 5, 1, _mouseState.X, _mouseState.Y, (_mouseState.LeftButton == ButtonState.Pressed)) &&
                _animScroll > 0)
                _animScroll--;

            if (
                DrawButton(170, 200, 2, _mouseState.X, _mouseState.Y, (_mouseState.LeftButton == ButtonState.Pressed)) &&
                _animScroll < _charDef.Animations.Length - 15)
                _animScroll++;
        }
Exemplo n.º 46
0
        private void PerformControlDelete()
        {
            // where are we?!
            if ((linePos == lines.Count - 1) && (textPos == ((string)lines[lines.Count - 1]).Length)) {
                // If the cursor is at the end of the text block
                return;
            } else if (textPos == ((string)lines[linePos]).Length) {
                // End of a line, must merge strings
                lines[linePos] = ((string)lines[linePos]) + ((string)lines[linePos + 1]);
                lines.RemoveAt (linePos + 1);
            } else {
                // Middle of a line somewhere
                int ntp = textPos;
                string currentLine = (string)lines[linePos];

                if (System.Char.IsLetterOrDigit (currentLine[ntp])) {
                    while (ntp < currentLine.Length && (System.Char.IsLetterOrDigit (currentLine[ntp]))) {
                        currentLine = currentLine.Remove (ntp, 1);
                    }
                } else if (System.Char.IsWhiteSpace (currentLine[ntp])) {
                    while (ntp < currentLine.Length && (System.Char.IsWhiteSpace (currentLine[ntp]))) {
                        currentLine = currentLine.Remove (ntp, 1);
                    }
                } else if (System.Char.IsPunctuation (currentLine[ntp])) {
                    while (ntp < currentLine.Length && (System.Char.IsPunctuation (currentLine[ntp]))) {
                        currentLine = currentLine.Remove (ntp, 1);
                    }
                } else {
                    ntp--;
                }

                lines[linePos] = currentLine;
            }

            // Check for state change
            if (lines.Count == 1 && ((string)lines[0]) == "") {
                mode = EditingMode.EmptyEdit;
            }

            sizes = null;
        }
Exemplo n.º 47
0
        private void DrawFramesList()
        {
            for (var i = _frameScroll; i < _frameScroll + 20; i++)
            {
                if (i < _charDef.Frames.Length)
                {
                    var y = (i - _frameScroll) * 15 + 280;

                    if (i == _selFrame)
                    {
                        _text.Color = Color.Lime;

                        _text.DrawText(600, y,
                            i + ": " + _charDef.Frames[i].Name + ((_editMode == EditingMode.FrameName) ? "*" : ""));

                        if (_text.DrawClickText(720, y, "(a)", _mouseState.X, _mouseState.Y, _mouseClick))
                        {
                            var animation = _charDef.Animations[_selAnim];

                            for (var j = 0; j < animation.KeyFrames.Length; j++)
                            {
                                var keyFrame = animation.KeyFrames[j];

                                if (keyFrame.FrameRef == -1)
                                {
                                    keyFrame.FrameRef = i;
                                    keyFrame.Duration = 1;

                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (_text.DrawClickText(600, y, i + ": " + _charDef.Frames[i].Name, _mouseState.X,
                            _mouseState.Y, _mouseClick))
                        {
                            if (_selFrame != i)
                            {
                                if (String.IsNullOrEmpty(_charDef.Frames[i].Name))
                                    CopyFrame(_selFrame, i);

                                _selFrame = i;
                                _editMode = EditingMode.FrameName;
                            }
                        }
                    }
                }
            }

            if (
                DrawButton(770, 280, 1, _mouseState.X, _mouseState.Y, (_mouseState.LeftButton == ButtonState.Pressed)) &&
                _frameScroll > 0) _frameScroll--;
            if (
                DrawButton(770, 570, 2, _mouseState.X, _mouseState.Y, (_mouseState.LeftButton == ButtonState.Pressed)) &&
                _frameScroll < _charDef.Frames.Length - 20) _frameScroll++;
        }
Exemplo n.º 48
0
 private void scaleToolStripMenuItem_Click(object sender, EventArgs e)
 {
     moveToolStripMenuItem.Checked = false;
     rotateToolStripMenuItem.Checked = false;
     scaleToolStripMenuItem.Checked = true;
     editModeComboBox.SelectedIndex = 2;
     editMode = EditingMode.Scale;
 }
Exemplo n.º 49
0
        protected override void Draw(GameTime gameTime)
        {
            _graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            _spriteBatch.Begin();
            _spriteBatch.Draw(_nullTex, new Rectangle(300, 450, 200, 5), new Color(new Vector4(1.0f, 0.0f, 0.0f, 0.5f)));
            _spriteBatch.Draw(_nullTex, new Rectangle(0, 0, 200, 450), new Color(new Vector4(0.0f, 0.0f, 0.0f, 0.5f)));
            _spriteBatch.Draw(_nullTex, new Rectangle(590, 0, 300, 600), new Color(new Vector4(0.0f, 0.0f, 0.0f, 0.5f)));
            _spriteBatch.Draw(_nullTex, new Rectangle(200, 0, 150, 110), new Color(new Vector4(0.0f, 0.0f, 0.0f, 0.5f)));
            _spriteBatch.End();

            if (_selFrame > 0)
                DrawCharacter(new Vector2(400f, 450f), 2f, FaceRight, _selFrame - 1, false, 0.2f);
            if (_selFrame < _charDef.Frames.Length - 1)
                DrawCharacter(new Vector2(400f, 450f), 2f, FaceRight, _selFrame + 1, false, 0.2f);
            DrawCharacter(new Vector2(400f, 450f), 2f, FaceRight, _selFrame, false, 1.0f);

            DrawPalette();
            DrawPartsList();
            DrawFramesList();
            DrawAnimationList();
            DrawKeyFramesList();

            var fref = _charDef.Animations[_selAnim].KeyFrames[_curKey].FrameRef;
            if (fref < 0)
                fref = 0;

            DrawCharacter(new Vector2(500f, 100f), 0.5f, FaceLeft, fref, true, 1.0f);
            if (_playing)
            {
                if (_text.DrawClickText(480, 100, "stop", _mouseState.X, _mouseState.Y, _mouseClick))
                    _playing = false;
            }
            else
            {
                if (_text.DrawClickText(480, 100, "play", _mouseState.X, _mouseState.Y, _mouseClick))
                    _playing = true;
            }

            if (DrawButton(200, 5, 3, _mouseState.X, _mouseState.Y, _mouseClick))
                _charDef.Write();
            if (DrawButton(230, 5, 4, _mouseState.X, _mouseState.Y, _mouseClick))
                _charDef.Read();

            if (_editMode == EditingMode.PathName)
            {
                _text.Color = Color.Lime;

                _text.DrawText(270, 15, _charDef.Path + "*");
            }
            else
            {
                if (_text.DrawClickText(270, 15, _charDef.Path, _mouseState.X, _mouseState.Y, _mouseClick))
                    _editMode = EditingMode.PathName;
            }

            #region Script/Trigs/Textures Selector

            if (_auxMode == AuxScript)
            {
                _text.Color = Color.Lime;
                _text.DrawText(210, 110, "script");
            }
            else
            {
                if (_text.DrawClickText(210, 110, "script", _mouseState.X, _mouseState.Y, _mouseClick))
                    _auxMode = AuxScript;
            }

            if (_auxMode == AuxTrigs)
            {
                _text.Color = Color.Lime;
                _text.DrawText(260, 110, "trigs");
            }
            else
            {
                if (_text.DrawClickText(260, 110, "trigs", _mouseState.X, _mouseState.Y, _mouseClick))
                    _auxMode = AuxTrigs;
            }

            if (_auxMode == AuxTextures)
            {
                _text.Color = Color.Lime;
                _text.DrawText(300, 110, "tex");
            }
            else
            {
                if (_text.DrawClickText(300, 110, "tex", _mouseState.X, _mouseState.Y, _mouseClick))
                    _auxMode = AuxTextures;
            }

            #endregion

            #region Script

            if (_auxMode == AuxScript)
            {
                for (var i = 0; i < 4; i++)
                {
                    var scriptLineDescription = i + ": " +
                                                _charDef.Animations[_selAnim].KeyFrames[_selKeyFrame].Scripts[i];
                    const int scriptLineX = 210;
                    var scriptLineY = 42 + i * 16;

                    if (_editMode == EditingMode.Script && _selScriptLine == i)
                    {
                        _text.Color = Color.Lime;
                        _text.DrawText(scriptLineX, scriptLineY, scriptLineDescription + "*");
                    }
                    else if (_text.DrawClickText(scriptLineX, scriptLineY, scriptLineDescription, _mouseState.X,
                        _mouseState.Y, _mouseClick))
                    {
                        _selScriptLine = i;
                        _editMode = EditingMode.Script;
                    }
                }
            }

            #endregion

            #region Trigs

            if (_auxMode == AuxTrigs)
            {
                if (DrawButton(330, 42, 1, _mouseState.X, _mouseState.Y, _mouseClick))
                    if (_trigScroll > 0) _trigScroll--;
                if (DrawButton(330, 92, 2, _mouseState.X, _mouseState.Y, _mouseClick))
                    if (_trigScroll < 100) _trigScroll++;
                for (var i = 0; i < 4; i++)
                {
                    var t = i + _trigScroll;
                    if (_text.DrawClickText(210, 42 + i * 16, GetTrigName(t), _mouseState.X, _mouseState.Y, _mouseClick))
                    {
                        _charDef.Frames[_selFrame].Parts[_selPart].Index = t + 1000;
                    }
                }
            }

            #endregion

            #region Texture Switching

            if (_auxMode == AuxTextures)
            {
                for (var i = 0; i < 4; i++)
                {
                    if (DrawButton(210 + i * 21, 40, 1, _mouseState.X, _mouseState.Y, _mouseClick, 0.45f))
                    {
                        switch (i)
                        {
                            case 0:
                                if (_charDef.HeadIndex > 0) _charDef.HeadIndex--;
                                break;
                            case 1:
                                if (_charDef.TorsoIndex > 0) _charDef.TorsoIndex--;
                                break;
                            case 2:
                                if (_charDef.LegsIndex > 0) _charDef.LegsIndex--;
                                break;
                            case 3:
                                if (_charDef.WeaponIndex > 0) _charDef.WeaponIndex--;
                                break;
                        }
                    }
                    var t = _charDef.HeadIndex.ToString(CultureInfo.InvariantCulture);
                    switch (i)
                    {
                        case 1:
                            t = _charDef.TorsoIndex.ToString(CultureInfo.InvariantCulture);
                            break;
                        case 2:
                            t = _charDef.LegsIndex.ToString(CultureInfo.InvariantCulture);
                            break;
                        case 3:
                            t = _charDef.WeaponIndex.ToString(CultureInfo.InvariantCulture);
                            break;
                    }
                    _text.Color = Color.White;
                    _text.DrawText(212 + i * 21, 60, t);
                    if (DrawButton(210 + i * 21, 85, 2, _mouseState.X, _mouseState.Y, _mouseClick, 0.45f))
                    {
                        switch (i)
                        {
                            case 0:
                                if (_charDef.HeadIndex < _headTex.Length - 1) _charDef.HeadIndex++;
                                break;
                            case 1:
                                if (_charDef.TorsoIndex < _torsoTex.Length - 1) _charDef.TorsoIndex++;
                                break;
                            case 2:
                                if (_charDef.LegsIndex < _legsTex.Length - 1) _charDef.LegsIndex++;
                                break;
                            case 3:
                                if (_charDef.WeaponIndex < _weaponTex.Length - 1) _charDef.WeaponIndex++;
                                break;
                        }
                    }
                }
            }

            #endregion

            DrawCursor();

            _mouseClick = false;

            base.Draw(gameTime);
        }
        /// <summary>
        /// Loads the state.
        /// </summary>
        /// <param name="args">The view model arguments.</param>
        public async Task LoadState(UploadViewModelArgs args)
        {
            await base.LoadState();

            _editingMode = EditingMode.New;

            Category = args.Category?.ToCategory();

            try
            {
                // The user needs to be signed-in
                await _authEnforcementHandler.CheckUserAuthentication();

                // When navigating directly from the main window, the user has not
                // selected a category yet, so we need to do this now.
                if (Category == null)
                {
                    Category = await _navigationFacade.ShowCategoryChooserDialog();
                }

                // Here is some synchronization issue going on,
                // when we first set the Photo which propagates to the UI
                // via data binding, and immediately open a ContentDialog via ShowCategoryChooserDialog.
                // We would get random component initialization exceptions from XAML
                // without any further details. This however is only noticeable when
                // the app is launched as share target.
                // As a solution, we assign the selected photo after the chooser dialog 
                // has been awaited.
                WriteableBitmap = args.Image;
            }
            catch (SignInRequiredException)
            {
                await _dialogService.ShowNotification("AuthenticationRequired_Message", "AuthenticationRequired_Title");
                _navigationFacade.GoBack();
            }
        }
Exemplo n.º 51
0
        private void PressKey(Keys key)
        {
            string t = String.Empty;
            switch (editmode)
            {
                case EditingMode.None:
                    break;
                case EditingMode.AnimationName:
                    t = characterDefinition.Animations[selectedAnimation].Name;
                    break;
                case EditingMode.FrameName:
                    t = characterDefinition.Frames[selectedFrame].Name;
                    break;
                case EditingMode.PathName:
                    t = characterDefinition.Path;
                    break;
                case EditingMode.Script:
                    t = characterDefinition.Animations[selectedAnimation].KeyFrames[selectedKeyFrame].Scripts[selectedScriptLine];
                    break;
                default:
                    break;
            }

            if (key == Keys.Back)
            {
                if (t.Length > 0)
                    t = t.Substring(0, t.Length - 1);
            }
            else if (key == Keys.Enter)
            {
                editmode = EditingMode.None;
            }
            else
            {
                t = (t + (char)key).ToLower();
            }

            switch (editmode)
            {
                case EditingMode.None:
                    break;
                case EditingMode.AnimationName:
                    characterDefinition.Animations[selectedAnimation].Name = t;
                    break;
                case EditingMode.FrameName:
                    characterDefinition.Frames[selectedFrame].Name = t;
                    break;
                case EditingMode.PathName:
                    characterDefinition.Path = t;
                    break;
                case EditingMode.Script:
                    characterDefinition.Animations[selectedAnimation].KeyFrames[selectedKeyFrame].Scripts[selectedScriptLine] = t;
                    break;
                default:
                    break;
            }
        }
Exemplo n.º 52
0
        /*
            this.RendererList.Remove(this.moveNub);
            this.moveNub.Dispose();
            this.moveNub = null;

            if (this.textToolCursor != null)
            {
                this.textToolCursor.Dispose();
                this.textToolCursor = null;
            }
            */
        private void StopEditing()
        {
            PintaCore.Layers.ToolLayer.Clear ();
            PintaCore.Layers.ToolLayer.Hidden = true;
            mode = EditingMode.NotEditing;
            pulseEnabled = false;
            lines = null;
            //this.moveNub.Visible = false;
        }
Exemplo n.º 53
0
        // draws the animation list in the upper left corner. is scroll and editable
        private void DrawAnimationList()
        {
            for (int i = animScroll; i < animScroll + 15; i++)
            {
                if (i < characterDefinition.Animations.Length)
                {
                    int y = (i - animScroll) * 15 + 5;
                    if (i == selectedAnimation)
                    {
                        text.color = Color.Lime;
                        text.DrawText(5, y, i.ToString() + ": " + characterDefinition.Animations[i].Name + ((editmode == EditingMode.AnimationName) ? "*" : ""));
                    }
                    else
                    {
                        if (text.DrawClickText(5,y,i.ToString() + ": " + characterDefinition.Animations[i].Name,mouseState.X,mouseState.Y,mouseClick))
                        {
                            selectedAnimation = i;
                            editmode = EditingMode.AnimationName;
                        }
                    }
                }
            }

            //draw scroll buttons (arrows)
            if (DrawScrollButton(170, 5, upArrowTexture, mouseState.X, mouseState.Y, (mouseState.LeftButton == ButtonState.Pressed)) && animScroll > 0)
                animScroll--;
            if (DrawScrollButton(170, 200, downArrowTexture, mouseState.X, mouseState.Y, (mouseState.LeftButton == ButtonState.Pressed)) && animScroll < characterDefinition.Animations.Length - 15)
                animScroll++;
        }
Exemplo n.º 54
0
        /*public override Gdk.Cursor DefaultCursor {
            get {
                return new Gdk.Cursor(;
            }
        }*/
        protected override void OnActivated()
        {
            //PdnBaseForm.RegisterFormHotKey(Gdk.Key.Back, OnBackspaceTyped);

            base.OnActivated ();

            PintaCore.Palette.PrimaryColorChanged += HandlePintaCorePalettePrimaryColorChanged;

            //this.textToolCursor = new Gdk.Cursor (PintaCore.Chrome.DrawingArea.Display, PintaCore.Resources.GetIcon ("Tools.Text.png"), 0, 0);

            //this.Cursor = this.textToolCursor;

            mode = EditingMode.NotEditing;

            //font = AppEnvironment.FontInfo.CreateFont();
            //alignment = AppEnvironment.TextAlignment;
        }
Exemplo n.º 55
0
        // Draws the clickable Text in the upper left corner
        private void DrawText()
        {
            // Layerbutton
            string layerName = "map";

            switch (currentLayer)
            {
                case 0:
                    layerName = "back";
                    break;
                case 1:
                    layerName = "mid";
                    break;
                case 2:
                    layerName = "fore";
                    break;
                default:
                    break;
            }
            if (text.DrawClickText(5, 5, "layer: " + layerName, mouseX, mouseY, mouseClick))
                currentLayer = (currentLayer + 1) % 3;

            // DrawingMode Button
            switch (drawingMode)
            {
                case DrawingMode.SegmentSelection:
                    layerName = "select";
                    break;
                case DrawingMode.CollisionMap:
                    layerName = "collision";
                    break;
                case DrawingMode.Ledges:
                    layerName = "ledges";
                    break;
                case DrawingMode.Script:
                    layerName = "script";
                    break;
                default:
                    break;
            }

            if (text.DrawClickText(5, 25, "draw: " + layerName, mouseX, mouseY, mouseClick))
                drawingMode = (DrawingMode)((int)(drawingMode + 1) % 4);

            text.color = Color.White;
            if (editmode == EditingMode.Path)
                text.DrawText(5, 45, map.Path + "*");
            else
            {
                if (text.DrawClickText(5, 45, map.Path, mouseX, mouseY, mouseClick))
                    editmode = EditingMode.Path;
            }

            mouseClick = false;
        }
Exemplo n.º 56
0
        protected void OnKeyPress(DrawingArea canvas, KeyPressEventArgs args)
        {
            switch (args.Event.Key) {
            case Gdk.Key.KP_Enter:
            case Gdk.Key.Return:
                if (tracking) {
                    args.RetVal = true;
                }
                break;

            case Gdk.Key.Escape:
                if (tracking) {
                    args.RetVal = true;
                } else {
                    if (mode == EditingMode.Editing) {
                        SaveHistoryMemento ();
                    } else if (mode == EditingMode.EmptyEdit) {
                        RedrawText (false);
                    }

                    if (mode != EditingMode.NotEditing) {
                        args.RetVal = true;
                        StopEditing ();
                    }
                }

                break;
            }
            bool handled = false;
            if (args.RetVal != null && args.RetVal is bool)
                handled = (bool)args.RetVal;

            if (!handled && mode != EditingMode.NotEditing && !tracking) {
                args.RetVal = true;

                if (mode == EditingMode.EmptyEdit) {
                    mode = EditingMode.Editing;
                    CompoundHistoryItem cha = new CompoundHistoryItem (Icon, Name);
                    this.currentHA = cha;
                    PintaCore.History.PushNewItem (cha);
                }

                if ((args.Event.State & ModifierType.ControlMask) == 0 && args.Event.Key != Gdk.Key.Control_L && args.Event.Key != Gdk.Key.Control_R) {
                    char ch = (char)args.Event.Key;
                    InsertCharIntoString (ch);
                    textPos++;
                    RedrawText (true);
                }
            }

            //base.OnKeyPress (args.Event.Key, args.Event.State);
        }
Exemplo n.º 57
0
        private void PerformDelete()
        {
            // Where are we?!
            if ((linePos == lines.Count - 1) && (textPos == ((string)lines[lines.Count - 1]).Length)) {
                // If the cursor is at the end of the text block
                return;
            } else if (textPos == ((string)lines[linePos]).Length) {
                // End of a line, must merge strings
                lines[linePos] = ((string)lines[linePos]) + ((string)lines[linePos + 1]);
                lines.RemoveAt (linePos + 1);
            } else {
                // Middle of a line somewhere
                lines[linePos] = ((string)lines[linePos]).Substring (0, textPos) + ((string)lines[linePos]).Substring (textPos + 1);
            }

            // Check for state change
            if (lines.Count == 1 && ((string)lines[0]) == "") {
                mode = EditingMode.EmptyEdit;
            }

            sizes = null;
        }
Exemplo n.º 58
0
        private void editModeComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (editModeComboBox.SelectedItem.ToString())
            {
                case "Location":
                    moveToolStripMenuItem.Checked = true;
                    rotateToolStripMenuItem.Checked = false;
                    scaleToolStripMenuItem.Checked = false;
                    editMode = EditingMode.Location;
                    break;
                case "Rotation":
                    moveToolStripMenuItem.Checked = false;
                    rotateToolStripMenuItem.Checked = true;
                    scaleToolStripMenuItem.Checked = false;
                    editMode = EditingMode.Rotation;
                    break;
                case "Scale":
                    moveToolStripMenuItem.Checked = false;
                    rotateToolStripMenuItem.Checked = false;
                    scaleToolStripMenuItem.Checked = true;
                    editMode = EditingMode.Scale;
                    break;

                default:
                    break;
            }
        }
Exemplo n.º 59
0
 private void StartEditing()
 {
     this.linePos = 0;
     this.textPos = 0;
     this.lines = new List<string> ();
     this.sizes = null;
     this.lines.Add (string.Empty);
     this.startTime = DateTime.Now;
     this.mode = EditingMode.EmptyEdit;
     this.pulseEnabled = true;
     PintaCore.Layers.ToolLayer.Hidden = false;
     //UpdateStatusText();
 }
        /// <summary>
        /// Loads the view model state.
        /// </summary>
        /// <param name="uploadViewModelEditPhotoArgs">The arguments.</param>
        public async Task LoadState(UploadViewModelEditPhotoArgs uploadViewModelEditPhotoArgs)
        {
            await base.LoadState();

            _editingMode = EditingMode.Update;

            Category = uploadViewModelEditPhotoArgs.Category;
            Photo = uploadViewModelEditPhotoArgs.Photo;
            Comment = Photo.Caption;

            BitmapImage = new BitmapImage(new Uri(Photo.ImageUrl));
        }