Esempio n. 1
0
 /// <summary>
 /// Occurs when the Start button is pressed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BStart_Click(object sender, EventArgs e)
 {
     //necessary to update the NumericUpDown in text mode
     this.bStart.Focus();
     //The radio communication with the channel and address specified by the user is opened
     if (this.radio.StartRadio((byte)this.nudChannel.Value, (byte)this.nudDirection.Value))
     {
         //If opens correctly are enabled/disabled controls radio
         this.nudChannel.Enabled      = false;
         this.nudDirection.Enabled    = false;
         this.bStart.Enabled          = false;
         this.bStop.Enabled           = true;
         this.lReceptorDir.Enabled    = true;
         this.nudReceptorDir.Enabled  = true;
         this.l0.Enabled              = true;
         this.l7.Enabled              = true;
         this.tbData0.Enabled         = true;
         this.tbData1.Enabled         = true;
         this.tbData2.Enabled         = true;
         this.tbData3.Enabled         = true;
         this.tbData4.Enabled         = true;
         this.tbData5.Enabled         = true;
         this.tbData6.Enabled         = true;
         this.tbData7.Enabled         = true;
         this.bSend.Enabled           = true;
         this.lTransmiterData.Enabled = true;
         this.lbMessages.Enabled      = true;
     }
     else
     {
         //if it is not opened correctly a message of explanatory error appears
         MowayMessageBox.Show(CommunicationMessages.START_ERROR, CommunicationMessages.COMMUNICATIONS, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Update the list of detected cameras
        /// </summary>
        private void RefreshDevices()
        {
            this.cbDevice.Items.Clear();
            detectedDevices = this.camera.GetDevices();

            //The cameras registered in the system are loaded into the CbCameras
            if (detectedDevices != null)
            {
                foreach (FilterInfo device in detectedDevices)
                {
                    this.cbDevice.Items.Add(device.Name);
                }
            }
            else
            {
                MowayMessageBox.Show(CameraMessages.CAMERA_NOT_FOUND + "\r\n", CameraMessages.SHORT_TITTLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            if (this.cbDevice.Items.Count != 0)
            {
                this.cbDevice.SelectedItem = this.cbDevice.Items[0];
                this.bPlay.Enabled         = true;
            }
            else
            {
                this.bPlay.Enabled = false;
            }
        }
 private void BUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.cbSize.SelectedIndex == 0)
         {
             if (this.rbVertical.Checked)
             {
                 graphDiagram.ChangeSize(AreaFormat.A3_Vertical);
             }
             else
             {
                 graphDiagram.ChangeSize(AreaFormat.A3_Horizontal);
             }
         }
         else
         if (this.rbVertical.Checked)
         {
             graphDiagram.ChangeSize(AreaFormat.A4_Vertical);
         }
         else
         {
             graphDiagram.ChangeSize(AreaFormat.A4_Horizontal);
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     catch
     {
         MowayMessageBox.Show(AreaSizeMessages.ERROR_AREA_SIZE, AreaSizeMessages.TITTLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Creating a new project
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BCreate_Click(object sender, EventArgs e)
 {
     //It is valid that the name of the project is not empty
     if (this.tbName.Text == "")
     {
         MowayMessageBox.Show(NewProjectMessages.MISSING_PATH, NewProjectMessages.TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     //Project Path validated
     if (this.tbLocation.Text == "")
     {
         MowayMessageBox.Show(NewProjectMessages.MISSING_NAME, NewProjectMessages.TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     //It checks if the project already exists, it is consulted and the old one is deleted if yes
     if (File.Exists(this.tbLocation.Text + "\\" + this.tbName.Text + ".mpj"))
     {
         if (DialogResult.No == MowayMessageBox.Show(NewProjectMessages.PROJECT_EXISTS_1 + " " + this.tbName.Text + NewProjectMessages.PROJECT_EXISTS_2 + "\r\n" + NewProjectMessages.REPLACE_PROJECT, NewProjectMessages.TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
         {
             return;
         }
         else
         {
             File.Delete(this.tbLocation.Text + "\\" + this.tbName.Text + ".mpj");
             Directory.Delete(this.tbLocation.Text + "\\" + this.tbName.Text + "-files", true);
         }
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
        private void BCreate_Click(object sender, EventArgs e)
        {
            //***ADDED: Added start-by-number check
            string strTemp = this.tbName.Text.Substring(0, 1);

            if (System.Text.RegularExpressions.Regex.IsMatch(strTemp, @"^([0-9\d_])$"))
            {
                MowayMessageBox.Show(FunctionsMessages.NAME_ERROR + "\r\n" + FunctionsMessages.NAME_CONDITIONS, FunctionsMessages.NEW_FUNCTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if (!DiagramLayout.Diagram.Validate(this.tbName.Text))
            {
                MowayMessageBox.Show(FunctionsMessages.NAME_ERROR + "\r\n" + FunctionsMessages.NAME_CONDITIONS, FunctionsMessages.NEW_FUNCTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (Diagram.IsKeyword(this.tbName.Text))
            {
                MowayMessageBox.Show(FunctionsMessages.NAME_KEYWORD, FunctionsMessages.NEW_FUNCTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (GraphManager.ConstainFunction(this.tbName.Text))
            {
                MowayMessageBox.Show(FunctionsMessages.FUNCTION_EXISTS, FunctionsMessages.NEW_FUNCTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                this.diagram      = new Diagram(this.tbName.Text, this.tbDescription.Text, new StartAction(), true);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// This method executes the insert operation after the insertion position has been set
        /// </summary>
        public void Do()
        {
            if (!GraphDiagram.ValidateCopy(this.selectLayer.Elements))
            {
                MowayMessageBox.Show(CutMessages.CUT_START, CutMessages.CUT, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cancel();
                return;
            }
            //The items to be copied are loaded
            List <GraphElement> elementsToCut = GraphDiagram.GetElementsToCopy(this.selectLayer);
            List <GraphElement> cloneElements = GraphDiagram.CloneElements(elementsToCut);

            GraphManager.Clipboard.SetElements(cloneElements);

            this.elementsToDelete = GraphDiagram.GetElementsToDelete(this.selectLayer);
            GraphDiagram.DeleteElements(this.diagramLayer, this.diagram, this.elementsToDelete);
            //Cleans and hides the selection layer
            this.selectLayer.ClearAndHide();
            //Updates the diagram layer
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.ElementSelectedChanged != null)
            {
                this.ElementSelectedChanged(this, new EventArgs());
            }
            //Launch Event of operation completed
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Cut));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Starts capturing the selected camera
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BPlay_Click(object sender, EventArgs e)
        {
            if (this.StartCameraPanel())
            {
                this.camera.PlayCamera("");
                this.bPlay.Enabled             = false;
                this.bStop.Enabled             = true;
                this.bRefresh.Enabled          = false;
                this.cbDevice.Enabled          = false;
                this.bCapture.Enabled          = true;
                this.bBrowser.Enabled          = true;
                this.tbName.Enabled            = true;
                this.cbAutoincremental.Enabled = true;

                this.pbCamera.Visible           = false;
                this.videoSourcePlayer1.Visible = true;
            }
            else
            {
                MowayMessageBox.Show(CameraMessages.ERROR_PLAY_CAMERA, CameraMessages.CAMERA, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            return;
        }
Esempio n. 8
0
 public void Do()
 {
     //If you are modifying the next of an item...
     if (this.nextEnable)
     {
         if (this.presentConnector.Parent is GraphConditional)
         {
             this.conditionalOut = ((GraphConditional)this.presentConnector.Parent).GetPredefOut(this.presentConnector);
             if ((conditionalOut == ConditionalOut.True) && (((GraphConditional)this.presentConnector.Parent).NextTrue != null))
             {
                 if (DialogResult.Yes != MowayMessageBox.Show(InsertArrowMessages.REPLACE_TRUE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                 {
                     this.Cancel();
                     return;
                 }
                 else if ((conditionalOut == ConditionalOut.False) && (((GraphConditional)this.presentConnector.Parent).NextFalse != null))
                 {
                     if (DialogResult.Yes != MowayMessageBox.Show(InsertArrowMessages.REPLACE_FALSE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                     {
                         this.Cancel();
                         return;
                     }
                 }
             }
         }
         GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
         this.graphArrow = GraphDiagram.InsertArrow(this.diagram, this.diagramLayer, this.presentConnector, this.fixedConnector, this.conditionalOut, this.gridStatus);
     }
     else        //If you are modifying an item's prev
     {
         if (fixedConnector.Parent is GraphConditional)
         {
             if (((GraphConditional)fixedConnector.Parent).NextTrue == this.graphArrowToDelete)
             {
                 this.conditionalOut = ConditionalOut.True;
             }
             else
             {
                 this.conditionalOut = ConditionalOut.False;
             }
         }
         GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
         this.graphArrow = GraphDiagram.InsertArrow(this.diagram, this.diagramLayer, this.fixedConnector, this.presentConnector, this.conditionalOut, this.gridStatus);
     }
     foreach (GraphElement element in this.tempLayer.Elements)
     {
         element.DisableConnectors();
     }
     this.tempLayer.ClearAndHide();
     this.diagramLayer.UpdateSurface();
     if (this.OperationFinished != null)
     {
         this.OperationFinished(this, new OperationEventArgs(Operation.Reconnect));
     }
 }
 /// <summary>
 /// This method executes the insert operation after the insertion position has been set
 /// </summary>
 public void Do()
 {
     //If the operation is not precanceled and the mouse is within the workspace (when the temporary layer is visible)
     if ((!this.opPrecanceled) && (this.tempLayer.Visible))
     {
         //It is checked if the position is valid for insertion
         if (this.ValidateLocation())
         {
             //It checks if the action needs Inicilización
             if (this.graphElement.NeedInit)
             {
                 ActionForm actionForm = ActionFactory.GetActionForm(this.graphElement.Element);
                 if (DialogResult.OK != actionForm.ShowDialog())
                 {
                     this.Cancel();
                     return;
                 }
             }
             //The GraphElement is added to the diagram layer, and to the logical diagram
             this.diagramLayer.AddElement(this.graphElement);
             this.diagram.AddElement(this.graphElement.Element);
             //The temporary layer is cleaned and hidden
             this.tempLayer.ClearAndHide();
             //The diagram layer is updated
             this.diagramLayer.UpdateSurface();
             //It is indicated that the diagram has changed
             if (this.DiagramChanged != null)
             {
                 this.DiagramChanged(this, new EventArgs());
             }
             //The operation is terminated
             if (this.OperationFinished != null)
             {
                 this.OperationFinished(this, new OperationEventArgs(Operation.Insert));
             }
         }
         else
         {
             //If the position is invalid, it is precanceled to show notice to the user
             this.PreCancel();
             if (GraphSettings.Default.InsertWarning == true)
             {
                 bool showAgain = true;
                 MowayMessageBox.Show(InsertElementMessages.DRAG_OBJECT, InsertElementMessages.INSERT_ELEMENT, MessageBoxButtons.OK, MessageBoxIcon.Error, ref showAgain);
                 GraphSettings.Default.InsertWarning = showAgain;
                 GraphSettings.Default.Save();
             }
             this.Cancel();
         }
     }
     else
     {
         this.Cancel();
     }
 }
Esempio n. 10
0
 /// <summary>
 /// Launches to Default Web server with Moway server IP
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BLaunchWeb_Click(object sender, EventArgs e)
 {
     try
     {
         System.Diagnostics.Process.Start("http://169.254.3." + nudIp.Value.ToString());
     }
     catch
     {
         MowayMessageBox.Show(ServerMessages.BROWSER_ERROR, ServerMessages.TITTLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Saves the current image captured with the camera
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BCapture_Click(object sender, EventArgs e)
 {
     if (this.CaptureImage(this.tbLocation.Text, this.tbName.Text))
     {
         if (this.cbAutoincremental.Checked)
         {
             this.capture_cont++;
             tbName.Text = "Capture" + this.capture_cont.ToString() + ".jpg";
         }
     }
     else
     {
         MowayMessageBox.Show(CameraMessages.ERROR_CAPTURE, CameraMessages.CAMERA, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 12
0
 private void BRemove_Click(object sender, EventArgs e)
 {
     if (GraphManager.RemoveVariable(this.itemSelected.Text))
     {
         this.pItems.Controls.Remove(itemSelected);
         this.variables.Remove(itemSelected.Text);
         this.UpdateItems();
         this.itemSelected    = null;
         this.bEdit.Enabled   = false;
         this.bRemove.Enabled = false;
     }
     else
     {
         MowayMessageBox.Show(VariablesMessages.VARIABLE_IN_USE, VariablesMessages.DELETE_VARIABLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Close panel warning before the communication is open
 /// </summary>
 /// <returns></returns>
 public override bool CloseBox()
 {
     if (this.radio.RadioIsRunning())
     {
         if (DialogResult.Yes == MowayMessageBox.Show(CommunicationMessages.WARNING_CLOSE + "\r\n" + CommunicationMessages.CONTINUE, CommunicationMessages.COMMUNICATIONS, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
         {
             this.Stop();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 14
0
 /// <summary>
 /// This method executes the paste operation once the paste position is set
 /// </summary>
 public void Do()
 {
     //If the operation is not precanceled and the mouse is within the workspace (when the temporary layer is visible)
     if (this.tempLayer.Visible)
     {
         //It is checked if the position is valid for insertion
         if (this.ValidateLocation())
         {
             foreach (GraphElement element in this.tempLayer.Elements)
             {
                 //The GraphElement is added to the diagram layer, and to the logical diagram
                 this.diagramLayer.AddElement(element);
                 this.diagram.AddElement(element.Element);
             }
             //The temporary layer is cleaned and hidden
             this.tempLayer.ClearAndHide();
             //The diagram layer is updated
             this.diagramLayer.UpdateSurface();
             if (this.DiagramChanged != null)
             {
                 this.DiagramChanged(this, new EventArgs());
             }
             //The operation is terminated
             if (this.OperationFinished != null)
             {
                 this.OperationFinished(this, new OperationEventArgs(Operation.Paste));
             }
         }
         else
         {
             if (GraphSettings.Default.InsertWarning == true)
             {
                 bool showAgain = true;
                 MowayMessageBox.Show(PasteMessages.PASTE_WARNING, PasteMessages.PASTE, MessageBoxButtons.OK, MessageBoxIcon.Error, ref showAgain);
                 GraphSettings.Default.InsertWarning = showAgain;
                 GraphSettings.Default.Save();
             }
             this.Cancel();
         }
     }
     else
     {
         this.Cancel();
     }
 }
Esempio n. 15
0
        /// <summary>
        /// This method executes the insert operation after the insertion position has been set
        /// </summary>
        public void Do()
        {
            if (!GraphDiagram.ValidateCopy(this.selectLayer.Elements))
            {
                MowayMessageBox.Show(CopyMessages.COPY_START, CopyMessages.COPY, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cancel();
                return;
            }
            //The items to be copied are loaded
            List <GraphElement> elementsToCopy = GraphDiagram.GetElementsToCopy(this.selectLayer);
            List <GraphElement> cloneElements  = GraphDiagram.CloneElements(elementsToCopy);

            GraphManager.Clipboard.SetElements(cloneElements);
            //Launch Event of operation completed
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Copy));
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Load the code file in the window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ViewCodeForm_Load(object sender, EventArgs e)
 {
     //The file is loaded in the window
     try
     {
         StreamReader reader = new StreamReader(this.asmFile);
         do
         {
             string line = reader.ReadLine();
             this.tbCode.Text += line + "\r\n";
         }while (!reader.EndOfStream);
         reader.Close();
     }
     catch
     {
         MowayMessageBox.Show("Can't load source code file.\r\nYou must generate the program code before clicking on Program mOway.", "Code Display", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
Esempio n. 17
0
        public void Do()
        {
            if (!this.ValidateDelete())
            {
                MowayMessageBox.Show(DeleteMessages.DELETE_START, DeleteMessages.DELETE_OBJECT, MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Cancel();
                return;
            }

            if (GraphSettings.Default.DeleteWarning == true)
            {
                bool showAgain = true;
                if (DialogResult.No == MowayMessageBox.Show(DeleteMessages.WARNING_DELETE + "\r\n" + DeleteMessages.CONTINUE, DeleteMessages.DELETE_OBJECT, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, ref showAgain))
                {
                    this.Cancel();
                    GraphSettings.Default.DeleteWarning = showAgain;
                    GraphSettings.Default.Save();
                    return;
                }
                GraphSettings.Default.DeleteWarning = showAgain;
                GraphSettings.Default.Save();
            }
            this.elementsToDelete = GraphDiagram.GetElementsToDelete(this.selectLayer);
            GraphDiagram.DeleteElements(this.diagramLayer, this.diagram, this.elementsToDelete);
            //Cleans and hides the selection layer
            this.selectLayer.ClearAndHide();
            //Updates the diagram layer
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.ElementSelectedChanged != null)
            {
                this.ElementSelectedChanged(this, new EventArgs());
            }
            //Launch Event of operation completed
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Delete));
            }
        }
Esempio n. 18
0
 private void BUpdate_Click(object sender, EventArgs e)
 {
     if (!Variable.Validate(this.tbVariable.Text))
     {
         MowayMessageBox.Show(VariablesMessages.NAME_ERROR + "\r\n" + VariablesMessages.NAME_CONDITIONS, VariablesMessages.EDIT_VARIABLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (Variable.IsKeyword(this.tbVariable.Text))
     {
         MowayMessageBox.Show(VariablesMessages.NAME_KEYWORD, VariablesMessages.EDIT_VARIABLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if ((this.variable.Name != this.tbVariable.Text) && (GraphManager.ConstainVariable(this.tbVariable.Text)))
     {
         MowayMessageBox.Show(VariablesMessages.VARIABLE_EXISTS, VariablesMessages.EDIT_VARIABLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         GraphManager.UpdateVariable(this.variable, this.tbVariable.Text, (byte)this.nudValue.Value);
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
        /// <summary>
        /// Timer of launching operations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpTimer_Tick(object sender, EventArgs e)
        {
            //According to the operation to run
            switch (operation)
            {
            case ProcessOperation.Program:
                //launches the process of recording
                this.opTimer.Enabled = false;
                //the driver of the mOway events are logged
                Controller.Controller mController = Controller.Controller.GetController();
                mController.ProgrammingProgress  += new ProgressEventHandler(MController_ProgrammingProgress);
                mController.ProgrammingCompleted += new EventHandler(MController_ProgrammingCompleted);
                mController.ProgrammingCanceled  += new EventHandler(MController_ProgrammingCanceled);
                try
                {
                    //checks the memory of the micro...
                    int response = mController.CheckPicMemory(this.hexFile);
                    if (response == 1)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_201 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    else if (response == 2)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_202 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    //It enables the timer which is limited to 15 seconds the recording process
                    this.tProgramLimited.Enabled = true;
                    //the mOway recording is released
                    mController.ProgramMoway(this.hexFile);
                }
                //error in the launch of the recording process
                catch (ControllerException ex)
                {
                    //The Close button is enabled
                    this.bClose.Enabled = true;
                    //The error is displayed
                    this.bClose.Enabled          = true;
                    this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                    this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                    switch (ex.Message)
                    {
                    case "File not found":
                        this.lProgramMoway.Text = ProcessMessages.FILE_NOT_FOUND;
                        break;

                    case "Moway disconnected":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_DISCONNECTED;
                        break;

                    case "Moway busy":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_BUSY;
                        break;

                    default:
                        this.lProgramMoway.Text = ProcessMessages.PROGRAMMOWAY_ERROR;
                        break;
                    }
                }
                break;

            case ProcessOperation.Close:
                //close the form
                this.DialogResult = DialogResult.OK;
                this.Close();
                break;
            }
        }
Esempio n. 20
0
        public void Do()
        {
            GraphElement initialElement = initialConnector.Parent;
            GraphElement finalElement   = finalConnector.Parent;

            this.graphArrow = new GraphArrow(initialConnector, finalConnector, gridStatus);
            if (initialElement is GraphConditional)
            {
                if ((conditionalOut == ConditionalOut.True) && (((GraphConditional)initialElement).NextTrue != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_TRUE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextTrue;
                        GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                else if ((conditionalOut == ConditionalOut.False) && (((GraphConditional)initialElement).NextFalse != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_FALSE + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextFalse;
                        GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                ((GraphConditional)initialElement).AddNext(initialConnector, this.graphArrow, conditionalOut);
            }
            else
            {
                if (initialElement.Next != null)
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_OUT + "\r\n" + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)initialElement.Next;
                        GraphDiagram.DeleteElement(diagramLayer, diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                initialElement.AddNext(initialConnector, this.graphArrow);
            }
            finalElement.AddPrevious(finalConnector, this.graphArrow);
            diagramLayer.AddElement(this.graphArrow);
            this.diagram.AddElement(this.graphArrow.Element);
            //Elements in the context of the operation are deleted
            this.PreCancel();
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.InsertArrow));
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Execution of the operation
        /// </summary>
        public void Do()
        {
            GraphElement initialElement = this.initialConnector.Parent;
            GraphElement finalElement   = this.finalConnector.Parent;

            graphArrow = new GraphArrow(initialConnector, finalConnector, this.diagramLayer.GetGridPoints());
            if (initialElement is GraphConditional)
            {
                if ((this.conditionalOut == ConditionalOut.True) && (((GraphConditional)initialElement).NextTrue != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_TRUE + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextTrue;
                        GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                else if ((this.conditionalOut == ConditionalOut.False) && (((GraphConditional)initialElement).NextFalse != null))
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_FALSE + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)((GraphConditional)initialElement).NextFalse;
                        GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                ((GraphConditional)initialElement).AddNext(initialConnector, graphArrow, this.conditionalOut);
            }
            else
            {
                if (initialElement.Next != null)
                {
                    if (DialogResult.Yes == MowayMessageBox.Show(InsertArrowMessages.REPLACE_OUT + InsertArrowMessages.CONTINUE, InsertArrowMessages.INSERT_ARROW, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        this.graphArrowToDelete = (GraphArrow)initialElement.Next;
                        GraphDiagram.DeleteElement(this.diagramLayer, this.diagram, this.graphArrowToDelete);
                    }
                    else
                    {
                        this.Cancel();
                        return;
                    }
                }
                initialElement.AddNext(initialConnector, graphArrow);
            }
            finalElement.AddPrevious(finalConnector, graphArrow);
            this.diagramLayer.AddElement(graphArrow);
            //Elements in the context of the operation are deleted
            foreach (GraphElement element in this.tempLayer.Elements)
            {
                element.DisableConnectors();
            }
            this.tempLayer.ClearAndHide();
            this.diagramLayer.UpdateSurface();
            if (this.DiagramChanged != null)
            {
                this.DiagramChanged(this, new EventArgs());
            }
            if (this.OperationFinished != null)
            {
                this.OperationFinished(this, new OperationEventArgs(Operation.Connect));
            }
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            // Detect operating system language
            if (MowayWorld.Default.ConfigLanguage == false)
            {
                try
                {
                    Thread.CurrentThread.CurrentCulture   = new CultureInfo(CultureInfo.InstalledUICulture.Name);
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo(CultureInfo.InstalledUICulture.Name);
                }
                catch
                {
                    Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-GB");
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
                }
                finally
                {
                    MowayWorld.Default.ConfigLanguage = true;
                }
            }
            else
            {
                //The application language is set
                Thread.CurrentThread.CurrentCulture   = new CultureInfo(MowayWorld.Default.Language);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(MowayWorld.Default.Language);
            }

            //Alerts if another instance of the application is running
            bool  mutexCreado = false;
            Mutex miMutex     = new Mutex(true, "MowayWorld", out mutexCreado);

            if (!mutexCreado)
            {
                if (DialogResult.No == MessageBox.Show(ProgramMessages.WARNING_OPEN + "\r\n" + ProgramMessages.CONTINUE, "mOwayWorld", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                {
                    return;
                }
            }

            //Alerts if an instance of MOwayScratch is running
            // Get all processes running on the local computer.
            System.Diagnostics.Process[] localAll = System.Diagnostics.Process.GetProcesses();

            foreach (System.Diagnostics.Process process in localAll)
            {
                if (process.ProcessName == "mOwayScratch")
                {
                    if (DialogResult.No == MessageBox.Show(ProgramMessages.WARNING_OPEN + "\r\n" + ProgramMessages.CONTINUE, "mOwayWorld", MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                    {
                        return;
                    }
                }
            }


            //It ensures the existence of the necessary directories for the MOwayWorld
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mOwayWorld"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mOwayWorld");
            }
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\mOproj"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\mOproj");
            }
            //necessary because the library is not properly initialized
            SdlDotNet.Graphics.Video.Initialize();
            //The main form is launched
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            try
            {
                if (args.Length == 0)
                {
                    //The application opens with an empty project
                    Application.Run(new MainForm());
                }
                else
                {
                    //The application is opened from a project file
                    Application.Run(new MainForm(args[0]));
                }
            }
            catch
            {
                //Generic error message
                MowayMessageBox.Show(ProgramMessages.GENERAL_ERROR, "mOwayWorld", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Timer of launching operations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpTimer_Tick(object sender, EventArgs e)
        {
            //according to the operation to be executed
            switch (operation)
            {
            case ProcessOperation.Check:
                //The errors of all the diagrams are checked
                List <DiagramError> errors = new List <DiagramError>();
                foreach (Diagram diagram in this.project.Functions)
                {
                    Generator.CheckDiagram(diagram, errors);
                }
                //If there are errors, it is reported
                if (errors.Count != 0)
                {
                    bool onlyWarnings = false;
                    //the errors are checked
                    foreach (DiagramError error in errors)
                    {
                        //If any of the errors is not a warning
                        if (error.Type == ErrorType.Error)
                        {
                            onlyWarnings         = true;
                            this.opTimer.Enabled = false;
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbCheckDiagram.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lCheckDiagram.Text      = ProcessMessages.CHECKDIAGRAM_ERROR;
                            this.lCheckDiagram.ForeColor = Color.FromArgb(208, 0, 0);
                            break;
                        }
                    }
                    //If they are only warnings
                    if (!onlyWarnings)
                    {
                        //The warning message is displayed
                        this.pbCheckDiagram.Image    = this.icons.Images[(int)OperationState.Warning];
                        this.lCheckDiagram.Text      = ProcessMessages.CHECKDIAGRAM_WARNING;
                        this.lCheckDiagram.ForeColor = Color.FromArgb(200, 140, 0);
                        //it passes to the following operation
                        this.operation            = ProcessOperation.Generate;
                        this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running];
                    }
                    //The error event is launched
                    if (this.DiagramErrors != null)
                    {
                        this.DiagramErrors(this, new ProcessEventArgs(errors));
                    }
                }
                else
                {
                    this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Finish];
                    this.lCheckDiagram.Text   = ProcessMessages.CHECKDIAGRAM_OK;
                    //it passes to the following operation
                    this.operation            = ProcessOperation.Generate;
                    this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running];
                }
                break;

            case ProcessOperation.Generate:
                //Generates the source code for the diagrams
                try
                {
                    // The code is generated
                    AsmGenerator.GenerateCode(this.project.MainFunction, this.project.Subfunctions, this.project.Variables, this.project.AsmFile);
                    this.lGenerateCode.Text   = ProcessMessages.GENERATECODE_OK;
                    this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Finish];
                    //it passes to the following operation
                    this.operation           = ProcessOperation.Compile;
                    this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Running];
                }
                catch { }
                break;

            case ProcessOperation.Compile:
                //The generated source code is compiled
                try
                {
                    //The project is compiled
                    if (AsmCompiler.Compile(this.project.AsmFile))
                    {
                        this.lCompileCode.Text   = ProcessMessages.COMPILECODE_OK;
                        this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Finish];
                        //it passes to the following operation
                        this.operation            = ProcessOperation.Program;
                        this.opTimer.Interval     = 50;
                        this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Running];
                    }
                    else
                    {
                        this.opTimer.Enabled = false;
                        //The Close button is enabled
                        this.bClose.Enabled = true;
                        //The error is displayed
                        this.pbCompileCode.Image    = this.icons.Images[(int)OperationState.Error];
                        this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0);
                        this.lCompileCode.Text      = ProcessMessages.COMPILECODE_ERROR;
                    }
                }
                //Code compilation failed
                catch (CompilerException ex)
                {
                    this.opTimer.Enabled = false;
                    //The Close button is enabled
                    this.bClose.Enabled = true;
                    //The error is displayed
                    this.pbCompileCode.Image    = this.icons.Images[(int)OperationState.Error];
                    this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0);
                    switch (ex.Message)
                    {
                    case "File not found":
                        this.lCompileCode.Text = ProcessMessages.FILE_NOT_FOUND;
                        break;

                    case "Access denied":
                        this.lCompileCode.Text = ProcessMessages.ACCES_DENIED;
                        break;

                    default:
                        this.lCompileCode.Text = ProcessMessages.COMPILECODE_ERROR;
                        break;
                    }
                }
                break;

            case ProcessOperation.Program:
                //Launches the recording process
                this.opTimer.Enabled = false;
                //MOway Driver events are logged
                Controller.Controller mController = Controller.Controller.GetController();
                mController.ProgrammingProgress  += new ProgressEventHandler(MController_ProgrammingProgress);
                mController.ProgrammingCompleted += new EventHandler(MController_ProgrammingCompleted);
                mController.ProgrammingCanceled  += new EventHandler(MController_ProgrammingCanceled);
                try
                {
                    //It checks the memory of the micro...
                    int response = mController.CheckPicMemory(this.project.HexFile);
                    if (response == 1)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_201 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    else if (response == 2)
                    {
                        //A confirmation is requested
                        if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_202 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning))
                        {
                            //The Close button is enabled
                            this.bClose.Enabled = true;
                            //The error is displayed
                            this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                            this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                            this.lProgramMoway.Text      = ProcessMessages.MEMORY_ERROR;
                            return;
                        }
                    }
                    //Timer is enabled to limit the recording process to 15 seconds
                    this.tProgramLimited.Enabled = true;
                    //It launches the recording of the mOway
                    mController.ProgramMoway(this.project.HexFile);
                }
                //Timer is enabled to limit the recording process to 15 seconds
                catch (ControllerException ex)
                {
                    //The Close button is enabled
                    this.bClose.Enabled = true;
                    //The error is displayed
                    this.pbProgramMoway.Image    = this.icons.Images[(int)OperationState.Error];
                    this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0);
                    switch (ex.Message)
                    {
                    case "File not found":
                        this.lProgramMoway.Text = ProcessMessages.FILE_NOT_FOUND;
                        break;

                    case "Moway disconnected":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_DISCONNECTED;
                        break;

                    case "Moway busy":
                        this.lProgramMoway.Text = ProcessMessages.MOWAY_BUSY;
                        break;

                    default:
                        this.lProgramMoway.Text = ProcessMessages.PROGRAMMOWAY_ERROR;
                        break;
                    }
                }
                break;

            case ProcessOperation.Close:
                //Close the form
                this.DialogResult = DialogResult.OK;
                this.Close();
                break;
            }
        }