Beispiel #1
0
        private void btnNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            FlowMap canvas = new FlowMap();

            canvas.MdiParent = this;
            canvas.Show();
            canvas.WindowState = FormWindowState.Maximized;
            canvas.View.UpdateFormInfo();
            FlowDocument doc = canvas.View.Doc;

            doc.UndoManager.Clear();
            doc.IsModified = false;

            frmInfo dlg = new frmInfo();

            dlg.Doc = doc;
            dlg.ShowDialog();
        }
Beispiel #2
0
        private VarInfo HandleOutputblock(FlowBlock CurrentBlock, out string ErrorReport)
        {
            FlowMap map = form.ActiveMdiChild as FlowMap;

            ErrorReport = "";

            string  expression = CurrentBlock.Text;
            VarInfo varRes     = FlowData.HandleExpression(expression, out ErrorReport);

            if (ErrorReport != "")
            {
                return(null);
            }

            MainInterface.Instance.UserLog("Output: " + CurrentBlock.Text + " = " + varRes.value, LogType.Normal);
            MainInterface.Instance.UserOutput(varRes.value, LogType.Normal);
            return(varRes);
        }
Beispiel #3
0
        private VarInfo HandleInputBlock(FlowBlock CurrentBlock, out string ErrorReport)
        {
            FlowMap map = form.ActiveMdiChild as FlowMap;

            ErrorReport = "";

            string varAndType = CurrentBlock.Text;
            string varName;

            FlowData.HandleDeclaration(varAndType, out varName, out ErrorReport);
            if (ErrorReport != "")
            {
                return(null);
            }

            DataType varType = FlowData.GetVarInfo(varName, out ErrorReport).type;

            if (ErrorReport != "")
            {
                return(null);
            }

            frmScan      InputForm    = new frmScan(varName, varType);
            DialogResult dialogResult = InputForm.ShowDialog();

            if (dialogResult == DialogResult.Cancel)
            {
                ErrorReport = "Error: User input was canceled";
                return(null);
            }

            VarInfo InputVarInfo = InputForm.VarInfoResult;

            FlowData.AssignVariable(varName, InputVarInfo, out ErrorReport);
            if (ErrorReport != "")
            {
                return(null);
            }

            MainInterface.Instance.UserLog("Input: " + varName + " = " + InputVarInfo.value, LogType.Normal);
            return(null);
        }
Beispiel #4
0
        public virtual bool Reload()
        {
            String loc = this.Doc.Location;

            if (loc != "")
            {
                FileStream   file   = File.Open(loc, FileMode.Open);
                FlowDocument olddoc = this.View.Doc;
                FlowDocument newdoc = null;
                try
                {
                    newdoc = FlowDocument.Load(file, loc);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error reading design from a file");
                    return(false);
                }
                finally
                {
                    file.Close();
                }
                if (newdoc != null)
                {
                    IList windows = FlowMap.FindWindows(this.MdiParent, olddoc);
                    foreach (Object obj in windows)
                    {
                        FlowMap w = obj as FlowMap;
                        if (w != null)
                        {
                            w.View.Document = newdoc;
                        }
                    }
                }
            }
            return(true);
        }
Beispiel #5
0
 private void btnOpen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     FlowMap.Open(this);
 }
Beispiel #6
0
        /// return false if the flow is terminated due to error or end-block
        private bool ExecuteNextBlock()
        {
            string   ErrorReport = "";
            FlowView view        = form.GetCurrentGoView() as FlowView;
            FlowMap  map         = form.ActiveMdiChild as FlowMap;

            if (view == null)
            {
                MainInterface.Instance.UserLog("Error: No flow is found", LogType.Error);
                MainInterface.Instance.UserLog("Please create a new Flow art or open your old project", LogType.Normal);
                ResetFlow();
                RaiseError?.Invoke(this, new EventArgs());
                return(false);
            }
            if (map == null)
            {
                return(false);
            }

            FlowBlock OldBlock = CurrentBlock;

            CurrentBlock = view.GetNextBlock(CurrentBlock, LastBlockResult, out ErrorReport);
            // remember to check if this view is the same as the previous view

            // reset flow when there is link error
            if (CurrentBlock == null)
            {
                MainInterface.Instance.UserLog(ErrorReport, LogType.Error);
                ResetFlow();
                RaiseError?.Invoke(this, new EventArgs());
                return(false);
            }

            // unhighlight old block
            if (PlayFadingEffect)
            {
                OldBlock?.FxPlayer.FadeToNormalColor();
            }
            else
            {
                OldBlock?.FxPlayer.NormalizeColor();
            }

            // highlight new block
            CurrentBlock?.FxPlayer.DarkenColor();

            EnterNextBlock?.Invoke(this, new EventArgs());

            // reset flow if there is expression error
            LastBlockResult = HandleBlock(CurrentBlock, out ErrorReport);
            if (ErrorReport != "")
            {
                MainInterface.Instance.UserLog(ErrorReport, LogType.Error);
                ResetFlow();
                RaiseError?.Invoke(this, new EventArgs());
                return(false);
            }

            // reset flow if this is then End-block
            if (CurrentBlock.Kind == BlockType.End)
            {
                ResetFlow();
                ReachEndBlock?.Invoke(this, new EventArgs());
                return(false);
            }

            // blank space because it's beautiful :)
            MainInterface.Instance.UserLog("", LogType.Normal);

            return(true);
        }