Example #1
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            ITabbedDocument document = PluginBase.MainForm.CurrentDocument;

            if (document == null || !document.IsEditable)
            {
                return;
            }
            switch (e.Type)
            {
            case EventType.Keys:
            {
                Keys keys = (e as KeyEvent).Value;
                if (this.IsSupported(document) && keys == (Keys.Control | Keys.Space))
                {
                    String lang = document.SciControl.ConfigurationLanguage;
                    List <ICompletionListItem> items = this.GetCompletionListItems(lang, document.FileName);
                    if (items != null && items.Count > 0)
                    {
                        items.Sort();
                        Int32  curPos  = document.SciControl.CurrentPos - 1;
                        String curWord = document.SciControl.GetWordLeft(curPos, false);
                        if (curWord == null)
                        {
                            curWord = String.Empty;
                        }
                        CompletionList.Show(items, false, curWord);
                        e.Handled = true;
                    }
                }
                else if (this.IsSupported(document) && keys == (Keys.Control | Keys.Alt | Keys.Space))
                {
                    PluginBase.MainForm.CallCommand("InsertSnippet", "null");
                    e.Handled = true;
                }
                break;
            }

            case EventType.FileSwitch:
            case EventType.SyntaxChange:
            case EventType.ApplySettings:
            {
                if (this.IsSupported(document))
                {
                    String language = document.SciControl.ConfigurationLanguage;
                    if (!this.baseTable.ContainsKey(language))
                    {
                        this.AddBaseKeywords(language);
                    }
                    if (!this.fileTable.ContainsKey(document.FileName))
                    {
                        this.AddDocumentKeywords(document);
                    }
                    if (this.updateTable.ContainsKey(document.FileName))     // Need to update after save?
                    {
                        this.updateTable.Remove(document.FileName);
                        this.AddDocumentKeywords(document);
                    }
                    this.updateTimer.Stop();
                }
                break;
            }

            case EventType.FileSave:
            {
                TextEvent te = e as TextEvent;
                if (te.Value == document.FileName && this.IsSupported(document))
                {
                    this.AddDocumentKeywords(document);
                }
                else
                {
                    ITabbedDocument saveDoc = DocumentManager.FindDocument(te.Value);
                    if (saveDoc != null && saveDoc.IsEditable && this.IsSupported(saveDoc))
                    {
                        this.updateTable[te.Value] = true;
                    }
                }
                break;
            }

            case EventType.Command:
            {
                DataEvent de = e as DataEvent;
                if (de.Action == "ProjectManager.Project")
                {
                    IProject project = de.Data as IProject;
                    if (project != null)
                    {
                        this.LoadProjectKeywords(project);
                    }
                }
                break;
            }
            }
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: @Override public void dataOccurred(final jpos.events.DataEvent e)
		public override void dataOccurred(DataEvent e)
		{
			Activity.runOnUiThread(() =>
			{

				try
				{
					refreshFields();

					track1DataLengthTextView.Text = Convert.ToString(e.Status & 0xff);
					track2DataLengthTextView.Text = Convert.ToString((e.Status & 0xff00) >> 8);
					track3DataLengthTextView.Text = Convert.ToString((e.Status & 0xff0000) >> 16);

					deviceEnabledCheckBox.Checked = msr.DeviceEnabled;
					dataEventEnabledCheckBox.Checked = msr.DataEventEnabled;
					autoDisableCheckBox.Checked = msr.AutoDisable;
				}
				catch (JposException e)
				{
					e.printStackTrace();
					MessageDialogFragment.showDialog(FragmentManager, "Excepction", e.Message);
				}
			});
		}
 private static void native_yTimedReportCallback(YFUN_DESCR fundesc, double timestamp, IntPtr rawdata, u32 len)
 {
     for (int i = 0; i < YFunction._TimedReportCallbackList.Count; i++)
     {
         if (YFunction._TimedReportCallbackList[i].get_functionDescriptor() == fundesc)
         {
             byte[] data = new byte[len];
             Marshal.Copy(rawdata, data, 0, (int)len);
             if ((data[0]&0xff) <= 2)
             {
                 List<int> report = new List<int>((int)len);
                 int p = 0;
                 while (p < len)
                 {
                     report.Add(data[p++] & 0xff);
                 }
                 DataEvent ev = new DataEvent(YFunction._TimedReportCallbackList[i], timestamp, report);
                 _DataEvents.Add(ev);
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// Saves an editable document
        /// </summary>
        public void Save(String file)
        {
            if (!this.IsEditable)
            {
                return;
            }
            if (!this.IsUntitled && FileHelper.FileIsReadOnly(this.FileName))
            {
                String dlgTitle = TextHelper.GetString("Title.ConfirmDialog");
                String message  = TextHelper.GetString("Info.MakeReadOnlyWritable");
                if (MessageBox.Show(Globals.MainForm, message, dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ScintillaManager.MakeFileWritable(this.SciControl);
                }
                else
                {
                    return;
                }
            }
            String  oldFile   = this.SciControl.FileName;
            Boolean otherFile = (this.SciControl.FileName != file);

            if (otherFile)
            {
                String args = this.FileName + ";" + file;
                RecoveryManager.RemoveTemporaryFile(this.FileName);
                TextEvent renaming = new TextEvent(EventType.FileRenaming, args);
                EventManager.DispatchEvent(this, renaming);
                TextEvent close = new TextEvent(EventType.FileClose, this.FileName);
                EventManager.DispatchEvent(this, close);
            }
            TextEvent saving = new TextEvent(EventType.FileSaving, file);

            EventManager.DispatchEvent(this, saving);
            if (!saving.Handled)
            {
                this.UpdateDocumentIcon(file);
                this.SciControl.FileName = file;
                ScintillaManager.CleanUpCode(this.SciControl);
                DataEvent de = new DataEvent(EventType.FileEncode, file, this.SciControl.Text);
                EventManager.DispatchEvent(this, de); // Lets ask if a plugin wants to encode and save the data..
                if (!de.Handled)
                {
                    FileHelper.WriteFile(file, this.SciControl.Text, this.SciControl.Encoding, this.SciControl.SaveBOM);
                }
                this.IsModified = false;
                this.SciControl.SetSavePoint();
                RecoveryManager.RemoveTemporaryFile(this.FileName);
                this.fileInfo = new FileInfo(this.FileName);
                if (otherFile)
                {
                    ScintillaManager.UpdateControlSyntax(this.SciControl);
                    Globals.MainForm.OnFileSave(this, oldFile);
                }
                else
                {
                    Globals.MainForm.OnFileSave(this, null);
                }
            }
            this.RefreshTexts();
        }
Example #5
0
 static void onData(DataEvent <BitmexSocketEvent <BitmexOrderBookEntry> > data)
 {
     Console.WriteLine(JsonConvert.SerializeObject(data));
 }
Example #6
0
 public void SetData(DataEvent evt)
 {
     this.evt = evt;
     PuApp.Instance.GetImage(evt.image,(texture)=>GetComponent<UITexture>().mainTexture = texture);
 }
Example #7
0
 /// <summary>
 /// Конструктор
 /// </summary>
 public ViewModel()
 {
     Event     = new DataEvent();
     Alarm     = new DataAlarm();
     Exception = new DataExcept();
 }
Example #8
0
        private void NotifyDisposed(String file)
        {
            DataEvent de = new DataEvent(EventType.Command, "FlashViewer.Closed", file);

            EventManager.DispatchEvent(this, de);
        }
Example #9
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            TextEvent       te       = e as TextEvent;
            DataEvent       de       = e as DataEvent;
            ITabbedDocument document = PluginBase.MainForm.CurrentDocument;

            //BxmlDesigner designer = document != null && designers.ContainsKey(document) ? designers[document] : null;

            // TODO: we need to handle these too:
            //ProjectManagerEvents.BuildComplete;
            //ProjectManagerEvents.BuildFailed;
            //ProjectManagerEvents.BuildProject;
            //ProjectManagerEvents.CreateProject;
            //ProjectManagerEvents.FileMoved;
            //ProjectManagerEvents.FilePasted;
            //ProjectManagerEvents.OpenVirtualFile;
            //ProjectManagerEvents.ProjectCreated;
            if (e.Type == EventType.Command && de.Action == ProjectManagerEvents.FileMapping)
            {
                ProjectFileMapper.Map((FileMappingRequest)de.Data);
                return;
            }

            // our first priority is getting a non-null Project, otherwise
            // we can't do anything

            if (e.Type == EventType.Command && de.Action == ProjectManagerEvents.Project)
            {
                // the projectexplorer plugin is telling us what project we're working with
                this.asproject = de.Data as ProjectManager.Projects.Project;
                Console.WriteLine("We found a project " + this.asproject + " : " + de.Data + " : " + (de.Data is ProjectManager.Projects.Project));
                //return;
            }

            // we need a project and context to handle these events
            if (e.Type == EventType.FileOpen)
            {
                if (this.IsNfxMxml(document))
                {
                    Console.WriteLine("MXML file opened");
                    PluginBase.MainForm.CallCommand("ChangeSyntax", "xml");

                    //    var timer = new Timer { Interval = 1, Enabled = true };
                    //    timer.Tick += (o, evt) =>
                    //    {
                    //        timer.Enabled = false;

                    // create the design surface
                    //if (GetProjectAndContext())
                    //{
                    //    if (project.AbsoluteClasspaths.GetClosestParent(document.FileName) != null)
                    //    {
                    //        designer = new BxmlDesigner(document, project, GetDesignerSwfPath());
                    //        designers.Add(document, designer);
                    //        //Compile(document, designer);
                    //    }
                    //    else
                    //        SendErrorToResults(document.FileName, "Cannot design this file because the classpath could not be determined.");
                    //}
                    //else SendErrorToResults(document.FileName, "Could not start up the Bent Designer - no project loaded or AS3 completion plugin not loaded.");
                    //    };
                }
            }
            else if (e.Type == EventType.FileClose)
            {
                Console.WriteLine("MXML file closed");
                // TODO: Recompile code behind here
                //if (designers.ContainsKey(document))
                //    designers.Remove(document);
            }
            else if (e.Type == EventType.Command)
            {
                switch (de.Action)
                {
                case ProjectManagerEvents.BuildComplete:

                    // TODO: Not sure we need this
                    //if (!GetProjectAndContext()) return;
                    //if (!File.Exists(project.OutputPathAbsolute)) return;
                    //if (!CheckIsBentApplication()) return;

                    //BuildDesignerSwf();

                    //foreach (BxmlDesigner d in designers.Values)
                    //    d.SwfOutdated = true;

                    //if (designer != null)
                    //    designer.ReloadSwf();

                    break;

                case "XMLCompletion.Element":

                    // TODO: Not yet...
                    //if (!IsBxml(document) || !GetProjectAndContext()) return;
                    //if (designer == null) return;

                    ////DateTime started = DateTime.Now;
                    //completion.HandleElement(designer, (XMLContextTag)de.Data);
                    //TraceManager.Add("Took " + (DateTime.Now - started).TotalMilliseconds + "ms.");
                    //e.Handled = true;
                    break;

                case "XMLCompletion.CloseElement":

                    // TODO: We would try to rely on FD own autocompletion better...
                    //if (!IsBxml(document) || !GetProjectAndContext()) return;
                    //if (designer == null) return;

                    //string ending = completion.HandleCloseElement(designer, (XMLContextTag)de.Data);
                    //if (ending != null)
                    //{
                    //    if (ending != ">")
                    //    {
                    //        ScintillaNet.ScintillaControl sci = document.SciControl;
                    //        int position = sci.CurrentPos;
                    //        sci.SetSel(position - 1, position);
                    //        sci.ReplaceSel(ending);
                    //        sci.SetSel(position + 1, position + 1);
                    //    }
                    //    e.Handled = true;
                    //}

                    break;

                case "XMLCompletion.Attribute":

                    // TODO: We would try to rely on FD own autocompletion better...
                    //if (!IsBxml(document) || !GetProjectAndContext()) return;
                    //if (designer == null) return;

                    //object[] o = de.Data as object[];
                    ////started = DateTime.Now;
                    //completion.HandleAttribute(designer, (XMLContextTag)o[0], o[1] as string);
                    ////TraceManager.Add("Took " + (DateTime.Now - started).TotalMilliseconds + "ms.");
                    //e.Handled = true;
                    break;
                }
            }
            else if (e.Type == EventType.FileSave && this.IsNfxMxml(document))
            {
                Console.WriteLine("MXML file saved " + document.FileName);
                if (String.IsNullOrEmpty(this.preprocessorLocation))
                {
                    OpenFileDialog dialog = new OpenFileDialog();
                    dialog.CheckFileExists = true;
                    dialog.Filter          = "JAR files (*.jar)|*.jar";
                    DialogResult dr = dialog.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        this.preprocessorLocation         =
                            this.settingObject.ParserPath = dialog.FileNames[0];
                    }
                    else
                    {
                        return;
                    }
                }

                this.context = ASCompletion.Context.ASContext.GetLanguageContext("as3");
                string classpath = this.asproject.AbsoluteClasspaths.GetClosestParent(document.FileName);
                Console.WriteLine("Our classpath: " + classpath);
                ASCompletion.Model.PathModel pathModel =
                    context.Classpath.Find(pm => pm.Path == classpath);
                Hashtable ht = new Hashtable();
                ht.Add("-source", document.FileName);
                ht.Add("-source-dir", classpath);
                NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);
                EventManager.DispatchEvent(this, ne);
                PluginCore.Managers.EventManager.DispatchEvent(
                    this, new DataEvent(EventType.Command, "ResultsPanel.ClearResults", null));

                // TEST: trying to remove sci from our generated AS file so we won't get an update message
                ITabbedDocument[] documents    = FlashDevelop.Globals.MainForm.Documents;
                ITabbedDocument   current      = FlashDevelop.Globals.MainForm.CurrentDocument;
                Boolean           designerOpen = false;
                Char[]            splitter     = new Char[] { '.' };
                foreach (ITabbedDocument doc in documents)
                {
                    Console.WriteLine("doc.FileName " + doc.FileName + " document " + document.FileName);
                    if (doc.FileName.Split(splitter)[0] ==
                        document.FileName.Split(splitter)[0])
                    {
                        // Our designer AS file is open now
                        designerOpen = true;
                        this.lastDesignerFileName = doc.FileName;
                        this.tempRemovedSci       = doc.SciControl;
                        //((Form)doc).Controls.Remove(doc.SciControl);
                        break;
                    }
                }
                if (designerOpen)
                {
                    if (this.restoreDesigner == null)
                    {
                        this.restoreDesigner          = new Timer();
                        this.restoreDesigner.Interval = 50;
                        this.restoreDesigner.Tick    += new EventHandler(restoreDesigner_Tick);
                    }
                    this.restoreDesigner.Enabled = true;
                }
                NFXShell.Run(new FileInfo(document.FileName), this.preprocessorLocation, null, ht);
                // TODO: we should only handle our projects
                // TODO: not really sure this will be needed as those files should be picked up by ASCompletion anyway.
                //string classpath = this.project.AbsoluteClasspaths.GetClosestParent(document.FileName);

                this.TellASCompletionAbout(document.FileName, pathModel);
            }
            else if (e.Type == EventType.FileSwitch)
            {
                // TODO: think we don't need this
                //if (!GetProjectAndContext()) return;

                //// if this flash is marked as "dirty" we'll need to reload it
                //if (designer != null && designer.SwfOutdated)
                //    designer.ReloadSwf();
            }
            else if (e.Type == EventType.UIStarted)
            {
                // TODO: Not sure what this does... we'll see later
                this.projectManager =
                    (ProjectManager.PluginMain)PluginBase.MainForm.FindPlugin(
                        "30018864-fadd-1122-b2a5-779832cbbf23");
                //ProjectManager.Controls.TreeView.FileNode.FileAssociations.Add(".nxml", NFXNode.Create);
                //Timer timer = new Timer();
                //timer.Interval = 100;
                //timer.Tick += delegate { GetProjectAndContext(); timer.Stop(); };
                //timer.Start();
            }
        }
Example #10
0
 public GameDataManager()
 {
     DataDitionary = new Dictionary <DataType, GameData>();
     dataEvent     = new DataEvent();
 }
Example #11
0
        /// <summary>
        /// Handles the Command event and displays the movie
        /// </summary>
        public void HandleCommand(DataEvent evnt)
        {
            try
            {
                if (evnt.Action.StartsWith("FlashViewer."))
                {
                    String   action = evnt.Action;
                    String[] args   = evnt.Data != null?evnt.Data.ToString().Split(',') : null;

                    if (action == "FlashViewer.Default")
                    {
                        switch (this.settingObject.DisplayStyle)
                        {
                        case ViewStyle.Popup:
                            action = "FlashViewer.Popup";
                            break;

                        case ViewStyle.Document:
                            action = "FlashViewer.Document";
                            break;

                        case ViewStyle.External:
                            action = "FlashViewer.External";
                            break;
                        }
                    }
                    switch (action)
                    {
                    case "FlashViewer.Popup":
                        Int32 width  = args.Length > 0 ? Convert.ToInt32(args[1]) : 800;
                        Int32 height = args.Length > 1 ? Convert.ToInt32(args[2]) : 600;
                        this.CreatePopup(args[0], new Size(width, height));
                        break;

                    case "FlashViewer.Document":
                        this.CreateDocument(args[0]);
                        break;

                    case "FlashViewer.External":
                        this.LaunchExternal(args[0]);
                        break;

                    case "FlashViewer.GetDisplayStyle":
                        evnt.Data = this.settingObject.DisplayStyle.ToString();
                        break;

                    case "FlashViewer.SetDisplayStyle":
                        ViewStyle vs = (ViewStyle)Enum.Parse(typeof(ViewStyle), evnt.Data.ToString());
                        this.settingObject.DisplayStyle = vs;
                        break;

                    case "FlashViewer.GetFlashPlayer":
                        evnt.Data = PathHelper.ResolvePath(this.settingObject.PlayerPath);
                        break;
                    }
                    evnt.Handled = true;
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
Example #12
0
        private void DisplayClassWizard(String inDirectory, String templateFile, String className, String constructorArgs, List <String> constructorArgTypes)
        {
            Project project   = PluginBase.CurrentProject as Project;
            String  classpath = project.AbsoluteClasspaths.GetClosestParent(inDirectory) ?? inDirectory;
            String  package;

            try
            {
                package = GetPackage(classpath, inDirectory);
                if (package == "")
                {
                    // search in Global classpath
                    Hashtable info = new Hashtable();
                    info["language"] = project.Language;
                    DataEvent de = new DataEvent(EventType.Command, "ASCompletion.GetUserClasspath", info);
                    EventManager.DispatchEvent(this, de);
                    if (de.Handled && info.ContainsKey("cp"))
                    {
                        List <string> cps = info["cp"] as List <string>;
                        if (cps != null)
                        {
                            foreach (string cp in cps)
                            {
                                package = GetPackage(cp, inDirectory);
                                if (package != "")
                                {
                                    classpath = cp;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (System.NullReferenceException)
            {
                package = "";
            }
            AS3ClassWizard dialog = new AS3ClassWizard();
            bool           isHaxe = project.Language == "haxe";

            dialog.Project          = project;
            dialog.Directory        = inDirectory;
            dialog.StartupClassName = className;
            if (package != null)
            {
                package = package.Replace(Path.DirectorySeparatorChar, '.');
                dialog.StartupPackage = package;
            }
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string cPackage    = dialog.getPackage();
                string path        = Path.Combine(classpath, dialog.getPackage().Replace('.', Path.DirectorySeparatorChar));
                string newFilePath = Path.ChangeExtension(Path.Combine(path, dialog.getClassName()), isHaxe ? ".hx" : ".as");
                if (File.Exists(newFilePath))
                {
                    string       title   = " " + TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                    string       message = TextHelper.GetString("ProjectManager.Info.FolderAlreadyContainsFile");
                    DialogResult result  = MessageBox.Show(PluginBase.MainForm, string.Format(message, newFilePath, "\n"), title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }
                string templatePath = templateFile + ".wizard";
                this.lastFileFromTemplate = newFilePath;
                this.constructorArgs      = constructorArgs;
                this.constructorArgTypes  = constructorArgTypes;
                lastFileOptions           = new AS3ClassOptions(
                    project.Language,
                    dialog.getPackage(),
                    dialog.getSuperClass(),
                    dialog.hasInterfaces() ? dialog.getInterfaces() : null,
                    dialog.isPublic(),
                    dialog.isDynamic(),
                    dialog.isFinal(),
                    dialog.getGenerateInheritedMethods(),
                    dialog.getGenerateConstructor()
                    );

                try
                {
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    MainForm.FileFromTemplate(templatePath, newFilePath);
                }
                catch (Exception ex)
                {
                    ErrorManager.ShowError(ex);
                }
            }
        }
Example #13
0
        public bool Build(Project project, bool runOutput, bool noTrace)
        {
            // save modified files
            mainForm.CallCommand("SaveAllModified", null);
            string compiler = null;

            project.TraceEnabled = !noTrace;
            if (project.NoOutput)
            {
                // get the compiler for as3 projects, or else the FDBuildCommand pre/post command in FDBuild will fail on "No Output" projects
                if (project.Language == "as3")
                {
                    compiler = GetCompilerPath(project);
                }

                if (project.PreBuildEvent.Trim().Length == 0 && project.PostBuildEvent.Trim().Length == 0)
                {
                    // no output and no build commands
                    if (project is AS2Project || project is AS3Project)
                    {
                        RunFlashIDE(runOutput, noTrace);
                    }
                    else
                    {
                        String info = TextHelper.GetString("Info.NoOutputAndNoBuild");
                        ErrorManager.ShowInfo(info);
                    }
                    return(false);
                }
            }
            else
            {
                // Ask the project to validate itself
                string error;
                project.ValidateBuild(out error);

                if (error != null)
                {
                    ErrorManager.ShowInfo(TextHelper.GetString(error));
                    return(false);
                }

                if (project.OutputPath.Length < 1)
                {
                    String info = TextHelper.GetString("Info.SpecifyValidOutputSWF");
                    ErrorManager.ShowInfo(info);
                    return(false);
                }
                compiler = GetCompilerPath(project);
                if (compiler == null || (!Directory.Exists(compiler) && !File.Exists(compiler)))
                {
                    if (usingProjectDefinedCompiler)
                    {
                        string info = TextHelper.GetString("Info.InvalidCustomCompiler");
                        MessageBox.Show(info, TextHelper.GetString("Title.ConfigurationRequired"), MessageBoxButtons.OK);
                    }
                    else
                    {
                        string       info   = String.Format(TextHelper.GetString("Info.SpecifyCompilerPath"), project.Language.ToUpper());
                        DialogResult result = MessageBox.Show(info, TextHelper.GetString("Title.ConfigurationRequired"), MessageBoxButtons.OKCancel);
                        if (result == DialogResult.OK)
                        {
                            DataEvent de = new DataEvent(EventType.Command, "ASCompletion.ShowSettings", project.Language);
                            EventManager.DispatchEvent(this, de);
                        }
                    }
                    return(false);
                }
            }
            return(FDBuild(project, runOutput, noTrace, compiler));
        }
Example #14
0
 protected string GetImpactedRecordsStorageKey(DynamicView dynamicView, DataEvent dataEvent, TransactionState transactionState)
 {
     return($"{dynamicView.Id} {dataEvent.id} {transactionState}");
 }
Example #15
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.FileSwitch:
                this.GenerateSurroundMenuItems();
                UpdateMenuItems();
                break;

            case EventType.UIStarted:
                // Expose plugin's refactor main menu & context menu...
                EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "CodeRefactor.Menu", this.refactorMainMenu));
                EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "CodeRefactor.ContextMenu", this.refactorContextMenu));
                // Watch resolved context for menu item updating...
                ASComplete.OnResolvedContextChanged  += OnResolvedContextChanged;
                DirectoryNode.OnDirectoryNodeRefresh += OnDirectoryNodeRefresh;
                this.UpdateMenuItems();
                break;

            case EventType.Command:
                DataEvent de = (DataEvent)e;
                string[]  args;
                string    oldPath;
                string    newPath;
                switch (de.Action)
                {
                case ProjectFileActionsEvents.FileRename:
                    if (settingObject.DisableMoveRefactoring)
                    {
                        break;
                    }
                    args    = de.Data as string[];
                    oldPath = args[0];
                    newPath = args[1];
                    if (Directory.Exists(oldPath) && IsValidForMove(oldPath, newPath))
                    {
                        MovingHelper.AddToQueue(new Dictionary <string, string> {
                            { oldPath, newPath }
                        }, true, true);
                        e.Handled = true;
                    }
                    else if (IsValidForRename(oldPath, newPath))
                    {
                        MoveFile(oldPath, newPath);
                        e.Handled = true;
                    }
                    break;

                case ProjectFileActionsEvents.FileMove:
                    if (settingObject.DisableMoveRefactoring)
                    {
                        break;
                    }
                    args    = de.Data as string[];
                    oldPath = args[0];
                    newPath = args[1];
                    if (IsValidForMove(oldPath, newPath))
                    {
                        MovingHelper.AddToQueue(new Dictionary <string, string> {
                            { oldPath, newPath }
                        }, true);
                        e.Handled = true;
                    }
                    break;

                case "ASCompletion.ContextualGenerator.AddOptions":
                    OnAddRefactorOptions(de.Data as List <ICompletionListItem>);
                    break;

                case ProjectManagerEvents.TreeSelectionChanged:
                    OnTreeSelectionChanged();
                    break;
                }
                break;
            }
        }
Example #16
0
            /// <summary>
            /// Called from webpage to show New Project Dialog
            /// </summary>
            public void NewProject()
            {
                DataEvent de = new DataEvent(EventType.Command, ProjectManagerCommands.NewProject, null);

                EventManager.DispatchEvent(this, de);
            }
Example #17
0
 internal void RemoveEvent(DataEvent dataEvent)
 {
     DataEvents.Remove(dataEvent);
     Items.Remove(dataEvent);
 }
Example #18
0
            /// <summary>
            /// Called from webpage to open project dialog
            /// </summary>
            public void OpenProjectDialog()
            {
                DataEvent de = new DataEvent(EventType.Command, ProjectManagerCommands.OpenProject, null);

                EventManager.DispatchEvent(this, de);
            }
        /// <summary>
        /// Inserts text from the snippets class
        /// </summary>
        public static Boolean InsertTextByWord(String word, Boolean emptyUndoBuffer)
        {
            ScintillaControl sci = Globals.SciControl;

            if (sci == null)
            {
                return(false);
            }
            Boolean canShowList = false;
            String  snippet     = null;

            if (word == null)
            {
                canShowList = true;
                word        = sci.GetWordFromPosition(sci.CurrentPos);
            }
            if (word != null && word.Length > 0)
            {
                snippet = GetSnippet(word, sci.ConfigurationLanguage, sci.Encoding);
            }
            // let plugins handle the snippet
            Hashtable data = new Hashtable();

            data["word"]    = word;
            data["snippet"] = snippet;
            DataEvent de = new DataEvent(EventType.Command, "SnippetManager.Expand", data);

            EventManager.DispatchEvent(Globals.MainForm, de);
            if (de.Handled)
            {
                return(true);
            }
            snippet = (string)data["snippet"];
            if (!String.IsNullOrEmpty(sci.SelText))
            {
                // Remember the previous selection
                ArgsProcessor.PrevSelText = sci.SelText;
            }
            if (snippet != null)
            {
                Int32  endPos   = sci.SelectionEnd;
                Int32  startPos = sci.SelectionStart;
                String curWord  = sci.GetWordFromPosition(endPos);
                if (startPos == endPos)
                {
                    endPos   = sci.WordEndPosition(sci.CurrentPos, true);
                    startPos = sci.WordStartPosition(sci.CurrentPos, true);
                    sci.SetSel(startPos, endPos);
                }
                if (!String.IsNullOrEmpty(curWord))
                {
                    // Remember the current word
                    ArgsProcessor.PrevSelWord = curWord;
                }
                SnippetHelper.InsertSnippetText(sci, endPos, snippet);
                return(true);
            }
            else if (canShowList)
            {
                ICompletionListItem        item;
                List <ICompletionListItem> items = new List <ICompletionListItem>();
                PathWalker    walker             = new PathWalker(PathHelper.SnippetDir, "*.fds", false);
                List <String> files = walker.GetFiles();
                foreach (String file in files)
                {
                    item = new SnippetItem(Path.GetFileNameWithoutExtension(file), file);
                    items.Add(item);
                }
                String path = Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage);
                if (Directory.Exists(path))
                {
                    walker = new PathWalker(path, "*.fds", false);
                    files  = walker.GetFiles();
                    foreach (String file in files)
                    {
                        item = new SnippetItem(Path.GetFileNameWithoutExtension(file), file);
                        items.Add(item);
                    }
                }
                if (items.Count > 0)
                {
                    items.Sort();
                    if (!String.IsNullOrEmpty(sci.SelText))
                    {
                        word = sci.SelText;
                    }
                    else
                    {
                        word = sci.GetWordFromPosition(sci.CurrentPos);
                        if (word == null)
                        {
                            word = String.Empty;
                        }
                    }
                    CompletionList.OnInsert += new InsertedTextHandler(HandleListInsert);
                    CompletionList.OnCancel += new InsertedTextHandler(HandleListInsert);
                    CompletionList.Show(items, false, word);
                    return(true);
                }
            }
            return(false);
        }
Example #20
0
        public async Task Normal(CompressType compressType)
        {
            var random        = new Random();
            var minionLocator = new TestMinionLocator();

            using var host = QuickSetupTestHelper.BuildHost(
                      DatabaseType.SQLite,
                      RelationLocatorStrategy.SharedTable,
                      AppsettingsFilenames.Concat(new[]
                                                  { $"configs/rabbitmq/appsettings.{compressType.ToString("G").ToLower()}.json" }),
                      builder =>
            {
                builder.RegisterInstance(minionLocator)
                .As <IMinionLocator>()
                .SingleInstance();
            }, builder =>
                      builder.UseRabbitMQ(rabbitmq => rabbitmq.AsEventCenter())
                      );

            var container         = host.Services;
            var subscriberManager = container.GetRequiredService <IMQSubscriberManager>();
            await subscriberManager.StartAsync();

            var claptrapFactory = (ClaptrapFactory)container.GetRequiredService <IClaptrapFactory>();
            var id1             = new ClaptrapIdentity("1", Codes.Account);

            await using var scope = claptrapFactory.BuildClaptrapLifetimeScope(id1);
            var eventCenter = scope.Resolve <IEventCenter>();
            var eventData   = new AccountBalanceChangeEvent
            {
                Diff = random.Next(0, 1000)
            };
            var evt = new DataEvent(id1, Codes.AccountBalanceChangeEvent, eventData)
            {
                Version = 1
            };
            await eventCenter.SendToMinionsAsync(id1, evt);

            await Task.Delay(TimeSpan.FromSeconds(3));

            minionLocator.Queue.Count.Should().Be(2);
            var dic               = minionLocator.Queue.ToDictionary(x => x.Identity);
            var balanceMinionId   = new ClaptrapIdentity(id1.Id, Codes.AccountBalanceMinion);
            var balanceMinionItem = dic[balanceMinionId];

            AssertEvent(balanceMinionId, balanceMinionItem);

            var balanceHistoryMinionId   = new ClaptrapIdentity(id1.Id, Codes.AccountBalanceMinion);
            var balanceHistoryMinionItem = dic[balanceHistoryMinionId];

            AssertEvent(balanceHistoryMinionId, balanceHistoryMinionItem);

            await subscriberManager.CloseAsync();

            await container.GetRequiredService <IMQSenderManager>().CloseAsync();

            await host.StopAsync();

            void AssertEvent(ClaptrapIdentity minionId, ReceivedItem item)
            {
                var(id, e) = item;
                id.Should().BeEquivalentTo(minionId);
                e.Version.Should().Be(evt.Version);
                e.EventTypeCode.Should().Be(evt.EventTypeCode);
                e.Data.Should().BeOfType <AccountBalanceChangeEvent>();
                var data = (AccountBalanceChangeEvent)e.Data;

                data.Diff.Should().Be(eventData.Diff);
            }
        }
Example #21
0
        private UnsubscribeAction ConnectToSink <TSaga, TMessage>(ISubscriberContext context, ISagaWorker <TSaga> worker, DataEvent <TSaga, TMessage> eevent, IEnumerable <State> states)
            where TSaga : SagaStateMachine <TSaga>, ISaga
            where TMessage : class
        {
            var factory = new SagaStateMachineMessageSinkFactory <TSaga, TMessage>(context, _policyFactory);
            IPipelineSink <TMessage> sink = factory.Create(eevent, states);

            var workerSink = new SagaWorkerMessageSink <TSaga, TMessage>(worker, sink);

            return(context.Pipeline.ConnectToRouter(workerSink, () => context.SubscribedTo <Distributed <TMessage> >()));
        }
Example #22
0
        public void AddFileFromTemplate(Project project, string inDirectory, string templatePath)
        {
            try
            {
                // the template could be named something like "MXML.fdt", or maybe "Class.as.fdt"
                string fileName  = Path.GetFileNameWithoutExtension(templatePath);
                string extension = "";
                string caption   = TextHelper.GetString("Label.AddNew") + " ";

                if (fileName.IndexOf('.') > -1)
                {
                    // it's something like Class.as.fdt
                    extension = Path.GetExtension(fileName);                                                                     // .as
                    caption  += Path.GetFileNameWithoutExtension(fileName);
                    fileName  = TextHelper.GetString("Label.New") + Path.GetFileNameWithoutExtension(fileName).Replace(" ", ""); // just Class
                }
                else
                {
                    // something like MXML.fdt
                    extension = "." + fileName.ToLower();
                    caption  += fileName + " " + TextHelper.GetString("Label.File");
                    fileName  = TextHelper.GetString("Label.NewFile");
                }

                // let plugins handle the file creation
                Hashtable info = new Hashtable();
                info["templatePath"] = templatePath;
                info["inDirectory"]  = inDirectory;
                DataEvent de = new DataEvent(EventType.Command, "ProjectManager.CreateNewFile", info);
                EventManager.DispatchEvent(this, de);
                if (de.Handled)
                {
                    return;
                }

                LineEntryDialog dialog = new LineEntryDialog(caption, TextHelper.GetString("Label.FileName"), fileName + extension);
                dialog.SelectRange(0, fileName.Length);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    FlashDevelopActions.CheckAuthorName();

                    string newFilePath = Path.Combine(inDirectory, dialog.Line);
                    if (!Path.HasExtension(newFilePath) && extension != ".ext")
                    {
                        newFilePath = Path.ChangeExtension(newFilePath, extension);
                    }

                    if (!ConfirmOverwrite(newFilePath))
                    {
                        return;
                    }

                    // save this so when we are asked to process args, we know what file it's talking about
                    lastFileFromTemplate = newFilePath;

                    mainForm.FileFromTemplate(templatePath, newFilePath);
                }
            }
            catch (UserCancelException) { }
            catch (Exception exception)
            {
                ErrorManager.ShowError(exception);
            }
        }
Example #23
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            if (debugManager == null)
            {
                return;
            }
            switch (e.Type)
            {
            case EventType.FileOpen:
                TextEvent evnt = (TextEvent)e;
                ScintillaHelper.AddSciEvent(evnt.Value);
                breakPointManager.SetBreakPointsToEditor(evnt.Value);
                break;

            case EventType.UIStarted:
                menusHelper.AddToolStripItems();
                menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                debugManager.RestoreOldLayout();
                break;

            case EventType.UIClosing:
                if (debugManager.FlashInterface.isDebuggerStarted)
                {
                    debugManager.FlashInterface.Detach();
                }
                break;

            case EventType.ApplySettings:
                menusHelper.UpdateMenuState(this);
                break;

            case EventType.FileSwitch:
                menusHelper.UpdateMenuState(this);
                break;

            case EventType.Command:
                DataEvent buildevnt = (DataEvent)e;
                if (buildevnt.Action == "AS3Context.StartDebugger")
                {
                    if (settingObject.StartDebuggerOnTestMovie)
                    {
                        if (debugManager.Start(buildevnt.Data != null))
                        {
                            buildevnt.Handled = true;
                        }
                    }
                    return;
                }
                if (!buildevnt.Action.StartsWithOrdinal("ProjectManager"))
                {
                    return;
                }
                if (buildevnt.Action == ProjectManagerEvents.Project)
                {
                    IProject project = PluginBase.CurrentProject;
                    if (project != null && project.EnableInteractiveDebugger)
                    {
                        disableDebugger = false;
                        if (breakPointManager.Project != null && breakPointManager.Project != project)
                        {
                            breakPointManager.Save();
                            watchManager.Save();
                        }
                        PanelsHelper.breakPointUI.Clear();
                        PanelsHelper.watchUI.Clear();
                        breakPointManager.Project = project;
                        breakPointManager.Load();
                        breakPointManager.SetBreakPointsToEditor(PluginBase.MainForm.Documents);

                        watchManager.Project = project;
                        watchManager.Load();
                    }
                    else
                    {
                        disableDebugger = true;
                        if (breakPointManager.Project != null)
                        {
                            breakPointManager.Save();
                            watchManager.Save();
                        }
                        PanelsHelper.breakPointUI.Clear();
                        PanelsHelper.watchUI.Clear();
                    }
                }
                else if (disableDebugger)
                {
                    return;
                }
                if (buildevnt.Action == ProjectManagerCommands.HotBuild || buildevnt.Action == ProjectManagerCommands.BuildProject)
                {
                    if (debugManager.FlashInterface.isDebuggerStarted)
                    {
                        if (debugManager.FlashInterface.isDebuggerSuspended)
                        {
                            debugManager.Continue_Click(null, null);
                        }
                        debugManager.Stop_Click(null, null);
                    }
                }
                if (buildevnt.Action == ProjectManagerEvents.TestProject)
                {
                    if (debugManager.FlashInterface.isDebuggerStarted)
                    {
                        if (debugManager.FlashInterface.isDebuggerSuspended)
                        {
                            debugManager.Continue_Click(null, null);
                            e.Handled = true;
                            return;
                        }
                    }
                }
                if (buildevnt.Action == ProjectManagerEvents.TestProject)
                {
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }
                break;
            }
        }
        /**
         * Handles the incoming events
         */
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            try
            {
                // ignore all events when leaving
                if (PluginBase.MainForm.ClosingEntirely)
                {
                    return;
                }
                // current active document
                ITabbedDocument doc = PluginBase.MainForm.CurrentDocument;

                // application start
                if (!started && e.Type == EventType.UIStarted)
                {
                    started = true;
                    PathExplorer.OnUIStarted();
                    // associate context to initial document
                    e = new NotifyEvent(EventType.SyntaxChange);
                }

                // editor ready?
                if (doc == null)
                {
                    return;
                }
                ScintillaNet.ScintillaControl sci = doc.IsEditable ? doc.SciControl : null;

                //
                //  Events always handled
                //
                bool isValid;
                switch (e.Type)
                {
                // caret position in editor
                case EventType.UIRefresh:
                    if (!doc.IsEditable)
                    {
                        return;
                    }
                    timerPosition.Enabled = false;
                    timerPosition.Enabled = true;
                    return;

                // key combinations
                case EventType.Keys:
                    Keys key = (e as KeyEvent).Value;
                    if (ModelsExplorer.HasFocus)
                    {
                        e.Handled = ModelsExplorer.Instance.OnShortcut(key);
                        return;
                    }
                    if (!doc.IsEditable)
                    {
                        return;
                    }
                    e.Handled = ASComplete.OnShortcut(key, sci);
                    return;

                //
                // File management
                //
                case EventType.FileSave:
                    if (!doc.IsEditable)
                    {
                        return;
                    }
                    ASContext.Context.CheckModel(false);
                    // toolbar
                    isValid = ASContext.Context.IsFileValid;
                    if (isValid && !PluginBase.MainForm.SavingMultiple)
                    {
                        if (ASContext.Context.Settings.CheckSyntaxOnSave)
                        {
                            CheckSyntax(null, null);
                        }
                        ASContext.Context.RemoveClassCompilerCache();
                    }
                    return;

                case EventType.SyntaxDetect:
                    // detect Actionscript language version
                    if (!doc.IsEditable)
                    {
                        return;
                    }
                    if (doc.FileName.ToLower().EndsWith(".as"))
                    {
                        settingObject.LastASVersion = DetectActionscriptVersion(doc);
                        (e as TextEvent).Value      = settingObject.LastASVersion;
                        e.Handled = true;
                    }
                    break;

                case EventType.ApplySettings:
                case EventType.SyntaxChange:
                case EventType.FileSwitch:
                    if (!doc.IsEditable)
                    {
                        ASContext.SetCurrentFile(null, true);
                        ContextChanged();
                        return;
                    }
                    currentDoc = doc.FileName;
                    currentPos = sci.CurrentPos;
                    // check file
                    bool ignoreFile = !doc.IsEditable;
                    ASContext.SetCurrentFile(doc, ignoreFile);
                    // UI
                    ContextChanged();
                    return;

                // some commands work all the time
                case EventType.Command:
                    DataEvent de      = e as DataEvent;
                    string    command = de.Action ?? "";

                    if (command.StartsWith("ASCompletion."))
                    {
                        string cmdData = (de.Data is string) ? (string)de.Data : null;

                        // add a custom classpath
                        if (command == "ASCompletion.ClassPath")
                        {
                            Hashtable info = de.Data as Hashtable;
                            if (info != null)
                            {
                                ContextSetupInfos setup = new ContextSetupInfos();
                                setup.Platform    = (string)info["platform"];
                                setup.Lang        = (string)info["lang"];
                                setup.Version     = (string)info["version"];
                                setup.TargetBuild = (string)info["targetBuild"];
                                setup.Classpath   = (string[])info["classpath"];
                                setup.HiddenPaths = (string[])info["hidden"];
                                ASContext.SetLanguageClassPath(setup);
                                if (setup.AdditionalPaths != null)     // report custom classpath
                                {
                                    info["additional"] = setup.AdditionalPaths.ToArray();
                                }
                            }
                            e.Handled = true;
                        }

                        // send a UserClasspath
                        else if (command == "ASCompletion.GetUserClasspath")
                        {
                            Hashtable info = de.Data as Hashtable;
                            if (info != null && info.ContainsKey("language"))
                            {
                                IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                if (context != null && context.Settings != null &&
                                    context.Settings.UserClasspath != null)
                                {
                                    info["cp"] = new List <string>(context.Settings.UserClasspath);
                                }
                            }
                            e.Handled = true;
                        }
                        // update a UserClasspath
                        else if (command == "ASCompletion.SetUserClasspath")
                        {
                            Hashtable info = de.Data as Hashtable;
                            if (info != null && info.ContainsKey("language") && info.ContainsKey("cp"))
                            {
                                IASContext    context = ASContext.GetLanguageContext(info["language"] as string);
                                List <string> cp      = info["cp"] as List <string>;
                                if (cp != null && context != null && context.Settings != null)
                                {
                                    string[] pathes = new string[cp.Count];
                                    cp.CopyTo(pathes);
                                    context.Settings.UserClasspath = pathes;
                                }
                            }
                            e.Handled = true;
                        }
                        // send the language's default compiler path
                        else if (command == "ASCompletion.GetCompilerPath")
                        {
                            Hashtable info = de.Data as Hashtable;
                            if (info != null && info.ContainsKey("language"))
                            {
                                IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                if (context != null)
                                {
                                    info["compiler"] = context.GetCompilerPath();
                                }
                            }
                            e.Handled = true;
                        }

                        // show a language's compiler settings
                        else if (command == "ASCompletion.ShowSettings")
                        {
                            e.Handled = true;
                            IASContext context = ASContext.GetLanguageContext(cmdData);
                            if (context == null)
                            {
                                return;
                            }
                            string filter = "";
                            string name   = "";
                            switch (cmdData.ToUpper())
                            {
                            case "AS2": name = "AS2Context"; filter = "SDK"; break;

                            case "AS3": name = "AS3Context"; filter = "SDK"; break;

                            case "HAXE": name = "HaxeContext"; filter = "SDK"; break;

                            default: name = cmdData.ToUpper() + "Context"; break;
                            }
                            PluginBase.MainForm.ShowSettingsDialog(name, filter);
                        }

                        // Open types explorer dialog
                        else if (command == "ASCompletion.TypesExplorer")
                        {
                            TypesExplorer(null, null);
                        }

                        // call the Flash IDE
                        else if (command == "ASCompletion.CallFlashIDE")
                        {
                            if (flashErrorsWatcher == null)
                            {
                                flashErrorsWatcher = new FlashErrorsWatcher();
                            }
                            e.Handled = Commands.CallFlashIDE.Run(settingObject.PathToFlashIDE, cmdData);
                        }

                        // create Flash 8+ trust file
                        else if (command == "ASCompletion.CreateTrustFile")
                        {
                            if (cmdData != null)
                            {
                                string[] args = cmdData.Split(';');
                                if (args.Length == 2)
                                {
                                    e.Handled = Commands.CreateTrustFile.Run(args[0], args[1]);
                                }
                            }
                        }

                        //
                        else if (command == "ASCompletion.GetClassPath")
                        {
                            if (cmdData != null)
                            {
                                string[] args = cmdData.Split(';');
                                if (args.Length == 1)
                                {
                                    FileModel  model  = ASContext.Context.GetFileModel(args[0]);
                                    ClassModel aClass = model.GetPublicClass();
                                    if (!aClass.IsVoid())
                                    {
                                        Clipboard.SetText(aClass.QualifiedName);
                                        e.Handled = true;
                                    }
                                }
                            }
                        }

                        // Return requested language SDK list
                        else if (command == "ASCompletion.InstalledSDKs")
                        {
                            Hashtable info = de.Data as Hashtable;
                            if (info != null && info.ContainsKey("language"))
                            {
                                IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                if (context != null)
                                {
                                    info["sdks"] = context.Settings.InstalledSDKs;
                                }
                            }
                            e.Handled = true;
                        }
                    }

                    // Create a fake document from a FileModel
                    else if (command == "ProjectManager.OpenVirtualFile")
                    {
                        string cmdData = de.Data as string;
                        if (reVirtualFile.IsMatch(cmdData))
                        {
                            string[] path     = Regex.Split(cmdData, "::");
                            string   fileName = path[0] + Path.DirectorySeparatorChar
                                                + path[1].Replace('.', Path.DirectorySeparatorChar).Replace("::", Path.DirectorySeparatorChar.ToString());
                            FileModel found = ModelsExplorer.Instance.OpenFile(fileName);
                            if (found != null)
                            {
                                e.Handled = true;
                            }
                        }
                    }
                    break;
                }

                //
                // Actionscript context specific
                //
                if (ASContext.Context.IsFileValid)
                {
                    switch (e.Type)
                    {
                    case EventType.ProcessArgs:
                        TextEvent te = (TextEvent)e;
                        if (reArgs.IsMatch(te.Value))
                        {
                            // resolve current element
                            Hashtable details = ASComplete.ResolveElement(sci, null);
                            te.Value = ArgumentsProcessor.Process(te.Value, details);

                            if (te.Value.IndexOf("$") >= 0 && reCostlyArgs.IsMatch(te.Value))
                            {
                                ASResult result = ASComplete.CurrentResolvedContext.Result;
                                details = new Hashtable();
                                // Get closest list (Array or Vector)
                                string closestListName = "", closestListItemType = "";
                                ASComplete.FindClosestList(ASContext.Context, result.Context, sci.LineFromPosition(sci.CurrentPos), ref closestListName, ref closestListItemType);
                                details.Add("TypClosestListName", closestListName);
                                details.Add("TypClosestListItemType", closestListItemType);
                                // get free iterator index
                                string iterator = ASComplete.FindFreeIterator(ASContext.Context, ASContext.Context.CurrentClass, result.Context);
                                details.Add("ItmUniqueVar", iterator);
                                te.Value = ArgumentsProcessor.Process(te.Value, details);
                            }
                        }
                        break;

                    // menu commands
                    case EventType.Command:
                        string command = (e as DataEvent).Action ?? "";
                        if (command.StartsWith("ASCompletion."))
                        {
                            string cmdData = (e as DataEvent).Data as string;
                            // run MTASC
                            if (command == "ASCompletion.CustomBuild")
                            {
                                if (cmdData != null)
                                {
                                    ASContext.Context.RunCMD(cmdData);
                                }
                                else
                                {
                                    ASContext.Context.RunCMD("");
                                }
                                e.Handled = true;
                            }

                            // build the SWF using MTASC
                            else if (command == "ASCompletion.QuickBuild")
                            {
                                ASContext.Context.BuildCMD(false);
                                e.Handled = true;
                            }

                            // resolve element under cusor and open declaration
                            else if (command == "ASCompletion.GotoDeclaration")
                            {
                                ASComplete.DeclarationLookup(sci);
                                e.Handled = true;
                            }

                            // resolve element under cursor and send a CustomData event
                            else if (command == "ASCompletion.ResolveElement")
                            {
                                ASComplete.ResolveElement(sci, cmdData);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.MakeIntrinsic")
                            {
                                ASContext.Context.MakeIntrinsic(cmdData);
                                e.Handled = true;
                            }

                            // alternative to default shortcuts
                            else if (command == "ASCompletion.CtrlSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.CtrlShiftSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Shift | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.CtrlAltSpace")
                            {
                                ASComplete.OnShortcut(Keys.Control | Keys.Alt | Keys.Space, ASContext.CurSciControl);
                                e.Handled = true;
                            }
                            else if (command == "ASCompletion.ContextualGenerator")
                            {
                                if (ASContext.HasContext && ASContext.Context.IsFileValid)
                                {
                                    ASGenerator.ContextualGenerator(ASContext.CurSciControl);
                                }
                            }
                        }
                        return;

                    case EventType.ProcessEnd:
                        string procResult = (e as TextEvent).Value;
                        ASContext.Context.OnProcessEnd(procResult);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
 private void Fire_DataEvent(string Data, DataDirection Direction)
 {
     DataEvent?.Invoke(Data, Direction);
 }
Example #26
0
        public void operate(string type, string msg = "")
        {
            ThreadStart action = null;

            stateTitle = "";
            if (type == "init")
            {
                if (hwnd > 0)
                {
                    unbind();
                }
                action = () =>
                {
                    try
                    {
                        Thread.Sleep(3000);
                        init_window(int.Parse(msg));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                };
            }
            else if (type == "locate")
            {
                action = () =>
                {
                    locate(msg, setting.AutoTrans);
                };
            }
            else if (type == "shout")
            {
                action = () =>
                {
                    shout(msg);
                };
            }
            else if (type == "pause")
            {
                action = () =>
                {
                    setState("已暂停");
                };
            }
            else if (type == "screenshot")
            {
                action = () =>
                {
                    screenshot(new Random().Next() + ".bmp");
                };
            }
            else if (type == "fuhun-init")
            {
                stateTitle = "附魂";
                action     = () =>
                {
                    setState("报名中");
                    fuhun.Sign();
                    setState("准备竞技");
                    //findMap("中立-附魂战场");
                    DataEvent?.Invoke("fuhun-capture", fuhun.GetCapture());
                    setState("标记敌人中");
                    //DataEvent?.Invoke("fuhun-capture", @"E:\Users\Administrator\source\repos\WpfApp1\MyTool\bin\Debug\debug\fuhun\637159218502426004.bmp");
                };
            }
            else if (type == "fuhun-tag")
            {
                stateTitle = "附魂";
                action     = () =>
                {
                    setState("PK中");
                    fuhun.PK(msg);
                    DataEvent?.Invoke("fuhun-end", "");
                };
            }
            else if (type == "fight")
            {
                stateTitle = "打架";
                action     = () => fight.Action(msg);
            }
            else if (type == "kuafu-boss")
            {
                stateTitle = "跨服boss";
                action     = () => kuafuBoss.Action(msg);
            }
            else if (type == "game-setting")
            {
                setting = JsonConvert.DeserializeObject <GameSetting>(msg);
            }
            if (action != null)
            {
                killTask();
                thread = new Thread(action);
                thread.Start();
            }
        }
 private static void native_yFunctionUpdateCallback(YFUN_DESCR fundesc, IntPtr data)
 {
     if (!IntPtr.Zero.Equals(data))
     {
         for (int i = 0; i < YFunction._ValueCallbackList.Count; i++)
         {
             if (YFunction._ValueCallbackList[i].get_functionDescriptor() == fundesc)
             {
                 DataEvent ev = new DataEvent(YFunction._ValueCallbackList[i], Marshal.PtrToStringAnsi(data));
                 _DataEvents.Add(ev);
             }
         }
     }
 }
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            if (priority == HandlingPriority.Low)
            {
                switch (e.Type)
                {
                case EventType.ProcessArgs:
                    TextEvent te = e as TextEvent;
                    if (te.Value.IndexOf("$(FlexSDK)") >= 0)
                    {
                        te.Value = te.Value.Replace("$(FlexSDK)", contextInstance.GetCompilerPath());
                    }
                    break;

                case EventType.Command:
                    DataEvent de     = e as DataEvent;
                    string    action = de.Action;
                    if (action == "ProjectManager.OpenVirtualFile")
                    {
                        e.Handled = OpenVirtualFileModel(de.Data as String);
                    }
                    else if (!(settingObject as AS3Settings).DisableFDB &&
                             action == "AS3Context.StartDebugger")
                    {
                        string workDir = (PluginBase.CurrentProject != null)
                                ? Path.GetDirectoryName(PluginBase.CurrentProject.ProjectPath)
                                : Environment.CurrentDirectory;

                        string flexSdk = (settingObject as AS3Settings).FlexSDK;

                        // if the default sdk is not defined ask for project sdk
                        if (flexSdk == null || flexSdk == String.Empty)
                        {
                            flexSdk = PluginBase.MainForm.ProcessArgString("$(CompilerPath)");
                        }

                        e.Handled = FlexDebugger.Start(workDir, flexSdk, null);
                    }
                    else if (action == "AS3Context.StartProfiler")
                    {
                        if (profilerUI.AutoStart)
                        {
                            profilerUI.StartProfiling();
                        }
                    }
                    break;

                case EventType.Keys:
                    if (inMXML)
                    {
                        KeyEvent ke = e as KeyEvent;
                        if (ke.Value == ASCompletion.Context.ASContext.CommonSettings.GotoDeclaration)
                        {
                            if (MxmlComplete.GotoDeclaration())
                            {
                                ke.Handled    = true;
                                ke.ProcessKey = false;
                            }
                        }
                    }
                    break;
                }
                return;
            }

            else if (priority == HandlingPriority.Normal)
            {
                switch (e.Type)
                {
                case EventType.UIStarted:
                    contextInstance = new Context(settingObject);
                    AddToolbarItems();
                    // Associate this context with AS3 language
                    ASCompletion.Context.ASContext.RegisterLanguage(contextInstance, "as3");
                    ASCompletion.Context.ASContext.RegisterLanguage(contextInstance, "mxml");
                    break;

                case EventType.FileSave:
                case EventType.FileSwitch:
                    if (contextInstance != null)
                    {
                        contextInstance.OnFileOperation(e);
                    }

                    if (PluginBase.MainForm.CurrentDocument.IsEditable)
                    {
                        string ext = Path.GetExtension(PluginBase.MainForm.CurrentDocument.FileName);
                        inMXML = (ext.ToLower() == ".mxml");
                        MxmlComplete.IsDirty = true;
                    }
                    else
                    {
                        inMXML = false;
                    }
                    break;
                }
                return;
            }

            else if (priority == HandlingPriority.High)
            {
                if (e.Type == EventType.Command)
                {
                    string action = (e as DataEvent).Action;
                    if (action == "ProjectManager.Project")
                    {
                        FlexDebugger.Stop();
                        IProject project = PluginBase.CurrentProject;
                        viewButton.Enabled = project == null || project.Language == "as3" || project.Language == "haxe";
                    }
                    else if (action.StartsWith("FlashViewer."))
                    {
                        if (action == "FlashViewer.Closed")
                        {
                            FlexDebugger.Stop();
                        }
                        else if (action == "FlashViewer.External" || action == "FlashViewer.Default" ||
                                 action == "FlashViewer.Popup" || action == "FlashViewer.Document")
                        {
                            if (PluginBase.CurrentProject != null &&
                                PluginBase.CurrentProject.EnableInteractiveDebugger)
                            {
                                DataEvent de = new DataEvent(EventType.Command, "AS3Context.StartProfiler", null);
                                EventManager.DispatchEvent(this, de);

                                if (PluginBase.CurrentProject.TraceEnabled)
                                {
                                    de = new DataEvent(EventType.Command, "AS3Context.StartDebugger", null);
                                    EventManager.DispatchEvent(this, de);
                                }
                            }
                        }
                    }
                    else if (action == "FlashConnect")
                    {
                        ProfilerUI.HandleFlashConnect(sender, (e as DataEvent).Data);
                    }
                    else if (inMXML)
                    {
                        DataEvent de = e as DataEvent;
                        if (de.Action == "XMLCompletion.Element")
                        {
                            de.Handled = MxmlComplete.HandleElement(de.Data);
                        }
                        if (de.Action == "XMLCompletion.Namespace")
                        {
                            de.Handled = MxmlComplete.HandleNamespace(de.Data);
                        }
                        else if (de.Action == "XMLCompletion.CloseElement")
                        {
                            de.Handled = MxmlComplete.HandleElementClose(de.Data);
                        }
                        else if (de.Action == "XMLCompletion.Attribute")
                        {
                            de.Handled = MxmlComplete.HandleAttribute(de.Data);
                        }
                    }
                }
            }
        }
Example #29
0
        /// <summary>
        /// Invokes the ASCompletion contextual generator
        /// </summary>
        private void CodeGeneratorMenuItemClicked(Object sender, EventArgs e)
        {
            DataEvent de = new DataEvent(EventType.Command, "ASCompletion.ContextualGenerator", null);

            EventManager.DispatchEvent(this, de);
        }
Example #30
0
        public bool Build(Project project, bool runOutput, bool releaseMode)
        {
            // save modified files
            mainForm.CallCommand("SaveAllModified", null);

            string       compiler = null;
            InstalledSDK sdk      = null;

            if (project.IsCompilable)
            {
                sdk      = GetProjectSDK(project);
                compiler = GetCompilerPath(project, sdk);
            }
            project.TraceEnabled = !releaseMode;

            if (project.OutputType == OutputType.OtherIDE)
            {
                // compile using associated IDE
                string error;
                string command = project.GetOtherIDE(runOutput, releaseMode, out error);

                if (error != null)
                {
                    ErrorManager.ShowInfo(TextHelper.GetString(error));
                }
                else
                {
                    if (command == "FlashIDE")
                    {
                        RunFlashIDE(project, runOutput, releaseMode);
                    }
                    else
                    {
                        Hashtable data = new Hashtable();
                        data["command"]     = command;
                        data["project"]     = project;
                        data["runOutput"]   = runOutput;
                        data["releaseMode"] = releaseMode;
                        DataEvent de = new DataEvent(EventType.Command, "ProjectManager.RunWithAssociatedIDE", data);
                        EventManager.DispatchEvent(project, de);
                        if (de.Handled)
                        {
                            return(true);
                        }
                    }
                }
                return(false);
            }
            else if (project.OutputType == OutputType.CustomBuild)
            {
                // validate commands not empty
                if (project.PreBuildEvent.Trim().Length == 0 && project.PostBuildEvent.Trim().Length == 0)
                {
                    String info = TextHelper.GetString("Info.NoOutputAndNoBuild");
                    TraceManager.Add(info);
                }
            }
            else if (project.IsCompilable)
            {
                // ask the project to validate itself
                string error;
                project.ValidateBuild(out error);

                if (error != null)
                {
                    ErrorManager.ShowInfo(TextHelper.GetString(error));
                    return(false);
                }

                if (project.OutputPath.Length == 0)
                {
                    String info = TextHelper.GetString("Info.SpecifyValidOutputSWF");
                    ErrorManager.ShowInfo(info);
                    return(false);
                }

                if (compiler == null || (!Directory.Exists(compiler) && !File.Exists(compiler)))
                {
                    string info = TextHelper.GetString("Info.CheckSDKSettings");
                    MessageBox.Show(info, TextHelper.GetString("Title.ConfigurationRequired"), MessageBoxButtons.OK);
                    return(false);
                }
            }

            // close running AIR projector
            if (project.MovieOptions.Platform.StartsWith("AIR"))
            {
                foreach (Process proc in Process.GetProcessesByName("adl"))
                {
                    try { proc.Kill(); proc.WaitForExit(10 * 1000); }
                    catch { }
                }
            }

            return(FDBuild(project, runOutput, releaseMode, sdk));
        }
Example #31
0
 public CorrelatedSagaStateMachineMessageSink(ISagaRepository <TSaga> repository,
                                              ISagaPolicy <TSaga, TMessage> policy,
                                              DataEvent <TSaga, TMessage> dataEvent)
     : base(repository, policy, new CorrelatedSagaLocator <TMessage>(), (s, c) => GetHandlers(s, c, dataEvent))
 {
 }
Example #32
0
 /// <summary>
 /// Given an event, returns the name to use in the actual file
 /// I made this a method so we could maybe use nicer names later,
 /// for now it just returns the name of the event from the enum
 /// </summary>
 /// <param name="evnt"></param>
 /// <returns></returns>
 private static string GetNameForEvent(DataEvent evnt)
 {
     return(Enum.GetName(typeof(DataEvent), evnt));
 }
Example #33
0
 private void DataEventList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (SelectedEvent != null)
         SelectedEvent.Selected = false;
     SelectedEvent = (DataEvent)SelectedItem;
     if (SelectedEvent != null)
         SelectedEvent.Selected = true;
 }
Example #34
0
        public void UpdateASCompletion(IMainForm mainForm, Project project)
        {
            List <string> classPaths  = new List <string>();
            List <string> hiddenPaths = new List <string>();
            string        version;
            string        platform = "";

            if (project != null)
            {
                BuildActions.GetCompilerPath(project); // refresh project's SDK
                project.UpdateVars(true);

                // platform/version
                platform = project.MovieOptions.Platform;
                version  = project.MovieOptions.Version;
                if (platform != PlatformData.FLASHPLAYER_PLATFORM &&
                    project.MovieOptions.HasPlatformSupport && project.MovieOptions.PlatformSupport.IsFlashPlatform)
                {
                    version = PlatformData.ResolveFlashPlayerVersion(project.Language, platform, version);
                }

                // add project classpaths
                foreach (string cp in project.AbsoluteClasspaths)
                {
                    if (Directory.Exists(cp))
                    {
                        classPaths.Add(cp);
                    }
                }

                // add AS3 libraries
                string absPath;
                if (project is AS3Project)
                {
                    MxmlcOptions options = (project as AS3Project).CompilerOptions;
                    foreach (string relPath in options.IntrinsicPaths)
                    {
                        absPath = PathHelper.ResolvePath(relPath);
                        if (absPath == null)
                        {
                            absPath = project.GetAbsolutePath(relPath);
                        }
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (Directory.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                    foreach (string relPath in options.LibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                        else if (Directory.Exists(absPath))
                        {
                            string[] libs = Directory.GetFiles(absPath, "*.swc");
                            foreach (string lib in libs)
                            {
                                classPaths.Add(lib);
                            }
                        }
                    }
                    foreach (string relPath in options.IncludeLibraries)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (Directory.Exists(absPath) || File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                    foreach (string relPath in options.ExternalLibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (Directory.Exists(absPath) || File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                    foreach (string relPath in options.RSLPaths)
                    {
                        string[] parts = relPath.Split(',');
                        if (parts.Length < 2)
                        {
                            continue;
                        }
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null)
                        {
                            continue;
                        }
                        if (File.Exists(absPath))
                        {
                            classPaths.Add(absPath);
                        }
                    }
                }

                string dir = project.Directory;
                foreach (string hidPath in project.HiddenPaths)
                {
                    absPath = Path.Combine(dir, hidPath);
                    foreach (string cp in classPaths)
                    {
                        if (absPath.StartsWith(cp))
                        {
                            hiddenPaths.Add(absPath);
                            break;
                        }
                    }
                }
            }
            else
            {
                var targets       = PluginCore.PlatformData.SupportedLanguages["as3"].Platforms;
                var flashPlatform = targets[PlatformData.FLASHPLAYER_PLATFORM];
                version = flashPlatform.LastVersion.Value;
            }

            DataEvent de;
            Hashtable info = new Hashtable();

            // release old classpath
            if (currentLang != null && project == null)
            {
                info["lang"]        = currentLang;
                info["platform"]    = "";
                info["targetBuild"] = "";
                info["version"]     = "0.0";
                info["classpath"]   = null;
                info["hidden"]      = null;

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);
            }

            // set new classpath
            if (project != null)
            {
                currentLang = project.Language;

                info["platform"]    = platform;
                info["version"]     = version;
                info["targetBuild"] = project.TargetBuild;
                info["lang"]        = currentLang;
                info["classpath"]   = classPaths.ToArray();
                info["hidden"]      = hiddenPaths.ToArray();

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);

                project.AdditionalPaths = info.ContainsKey("additional") ? info["additional"] as string[] : null;
            }
            else
            {
                currentLang = null;
            }
        }
Example #35
0
        public void AddEvent(DataEvent dataEvent)
        {
            DataEvents.Add(dataEvent);

            if (Items.Count == 0)
            {
                Items.Add(dataEvent);
                return;
            }

            int index = FindInsersionPlace(dataEvent.Message.timestamp.Ticks, 0, Items.Count - 1);

            Items.Insert(index, dataEvent);
        }
Example #36
0
        /// <summary>
        /// Run NME project (after build)
        /// </summary>
        /// <param name="command">Project's custom run command</param>
        /// <returns>Execution handled</returns>
        static public bool Run(string command)
        {
            if (!string.IsNullOrEmpty(command)) // project has custom run command
            {
                return(false);
            }

            HaxeProject project = PluginBase.CurrentProject as HaxeProject;

            if (project == null || project.OutputType != OutputType.Application)
            {
                return(false);
            }

            string builder = HaxeProject.GetBuilder(project);

            if (builder == null)
            {
                return(true);
            }

            string config = project.TargetBuild;

            if (String.IsNullOrEmpty(config))
            {
                config = "flash";
            }
            else if (config.IndexOf("android") >= 0)
            {
                CheckADB();
            }

            if (project.TraceEnabled)
            {
                config += " -debug -Dfdb";
            }
            if (config.StartsWith("flash") && config.IndexOf("-DSWF_PLAYER") < 0)
            {
                config += GetSwfPlayer();
            }

            string args    = "run " + builder + " run \"" + project.OutputPathAbsolute + "\" " + config;
            string haxelib = GetHaxelib(project);

            if (config.StartsWith("html5") && ProjectManager.Actions.Webserver.Enabled) // webserver
            {
                foreach (string line in project.RawHXML)
                {
                    if (line.StartsWith("-js "))
                    {
                        string path = line.Substring(4);
                        path = path.Substring(0, path.LastIndexOf("/"));
                        ProjectManager.Actions.Webserver.StartServer(project.GetAbsolutePath(path));
                        return(true);
                    }
                }
            }

            if (config.StartsWith("flash") || config.StartsWith("html5")) // no capture
            {
                if (config.StartsWith("flash") && project.TraceEnabled)   // debugger
                {
                    DataEvent de = new DataEvent(EventType.Command, "AS3Context.StartProfiler", null);
                    EventManager.DispatchEvent(project, de);
                    de = new DataEvent(EventType.Command, "AS3Context.StartDebugger", null);
                    EventManager.DispatchEvent(project, de);
                }

                var infos = new ProcessStartInfo(haxelib, args);
                infos.WorkingDirectory = project.Directory;
                infos.WindowStyle      = ProcessWindowStyle.Hidden;
                Process.Start(infos);
            }
            else
            {
                string oldWD = PluginBase.MainForm.WorkingDirectory;
                PluginBase.MainForm.WorkingDirectory = project.Directory;
                PluginBase.MainForm.CallCommand("RunProcessCaptured", haxelib + ";" + args);
                PluginBase.MainForm.WorkingDirectory = oldWD;
            }
            return(true);
        }
Example #37
0
 public static PlazaEventItem Create(DataEvent evt)
 {
     GameObject gobj = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/PokerPlaza/PlazaEventItem"));
     gobj.GetComponent<PlazaEventItem>().SetData(evt);
     return gobj.GetComponent<PlazaEventItem>();
 }
Example #38
0
        // This method prints the values of the device (as a integer and the interpreted string) as well as the description of each bit.
        private static void Update(object sender, DataEvent e)
        {
            // The description and the value of the WTX are only printed on the console if the Interface, containing all auto-properties of the values is
            // not null (respectively empty) and if no calibration is done at that moment.

            if (_wtxDevice != null /* && (_isCalibrating==false)*/)
            {
                Console.Clear();

                if (_wtxDevice.ApplicationMode == 0)  // If the WTX device is in standard application/mode.
                {
                    Console.WriteLine("0-Taring | 1-Gross/net  | 2-Zeroing  | 3- Adjust zero | 4-Adjust nominal |\n5-Activate Data \t| 6-Manual taring \t      | 7-Weight storage\n");
                }
                else
                if (_wtxDevice.ApplicationMode == 1 || _wtxDevice.ApplicationMode == 2)     // If the WTX device is in filler application/mode.
                {
                    if (_showAllInputWords == false && mode == "Modbus")
                    {
                        Console.WriteLine("\n0-Taring  | 1-Gross/net  | 2-Clear dosing  | 3- Abort dosing | 4-Start dosing| \n5-Zeroing | 6-Adjust zero| 7-Adjust nominal| 8-Activate data | 9-Weight storage|m-Manual redosing | j-Connection to Jetbus | a-Show all input words 0 to 37 |\no-Show output words 9-44 | b-Bytes read from the register |\nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n");
                    }
                    else
                    if (_showAllInputWords == true && mode == "Modbus")
                    {
                        Console.WriteLine("\n0-Taring  | 1-Gross/net  | 2-Clear dosing  | 3- Abort dosing | 4-Start dosing| \n5-Zeroing | 6-Adjust zero| 7-Adjust nominal| 8-Activate data | 9-Weight storage|m-Manual redosing | j-Connection to Modbus | a-Show only input word 0 to 5 |\nb-Bytes read from the register |\nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n");
                    }

                    if (mode == "Jet" || mode == "Jetbus" || mode == "jet" || mode == "jetbus")
                    {
                        Console.WriteLine("\n0-Taring  | 1-Gross/net  | 2-Clear dosing  | 3- Abort dosing | 4-Start dosing| \n5-Zeroing | 6-Adjust zero| 7-Adjust nominal| 8-Activate data | 9-Weight storage|m-Manual redosing | j-Connection to Modbus | \nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n");
                    }
                }

                if (_wtxDevice.ApplicationMode == 0)   // If the device is in the standard mode (standard=0; filler=1 or filler=2)
                {
                    // The values are printed on the console according to the input - "numInputs":

                    if (_inputMode == 1)
                    {
                        Console.WriteLine("Net value:                     " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.NetValue);
                    }
                    else
                    if (_inputMode == 2 || _inputMode == 3 || _inputMode == 4)
                    {
                        Console.WriteLine("Net value:                     " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.NetValue);
                        Console.WriteLine("Gross value:                   " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.GrossValue);
                    }
                    else
                    if (_inputMode == 5)
                    {
                        Console.WriteLine("Net value:                     " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.NetValue);
                        Console.WriteLine("Gross value:                   " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.GrossValue);
                        Console.WriteLine("General weight error:          " + _wtxDevice.GeneralWeightError.ToString() + "\t  As an Integer:  " + _wtxDevice.GeneralWeightError);
                        Console.WriteLine("Scale alarm triggered:         " + _wtxDevice.LimitStatus.ToString() + "\t  As an Integer:  " + _wtxDevice.LimitStatus);
                        Console.WriteLine("Scale seal is open:            " + _wtxDevice.ScaleSealIsOpen.ToString() + "\t  As an Integer:  " + _wtxDevice.ScaleSealIsOpen);
                        Console.WriteLine("Manual tare:                   " + _wtxDevice.ManualTare.ToString() + "\t  As an Integer:  " + _wtxDevice.ManualTare);
                        Console.WriteLine("Weight type:                   " + _wtxDevice.WeightType + "\t  As an Integer:  " + _wtxDevice.WeightType);        //_wtxDevice.WeightTypeStringComment()
                        Console.WriteLine("Scale range:                   " + _wtxDevice.ScaleRange + "\t  As an Integer:  " + _wtxDevice.ScaleRange);        //_wtxDevice.ScaleRangeStringComment()
                        Console.WriteLine("Zero required/True zero:       " + _wtxDevice.ZeroRequired.ToString() + "\t  As an Integer:  " + _wtxDevice.ZeroRequired);
                        Console.WriteLine("Weight within center of zero:  " + _wtxDevice.WeightWithinTheCenterOfZero.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightWithinTheCenterOfZero);
                        Console.WriteLine("Weight in zero range:          " + _wtxDevice.WeightInZeroRange.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightInZeroRange);

                        Console.WriteLine("Limit status:                  " + _wtxDevice.LimitStatus.ToString() + "        As an Integer:  " + _wtxDevice.LimitStatus);               //_wtxDevice.LimitStatusStringComment()
                        Console.WriteLine("Weight moving:                 " + _wtxDevice.WeightMoving.ToString() + "          As an Integer: " + _wtxDevice.WeightMoving);            //_wtxDevice.WeightMovingStringComment()
                    }
                    else
                    if (_inputMode == 6 || _inputMode == 38)
                    {
                        Console.WriteLine("Net value:                     " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.NetValue);
                        Console.WriteLine("Gross value:                   " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.GrossValue);
                        Console.WriteLine("General weight error:          " + _wtxDevice.GeneralWeightError.ToString() + "\t  As an Integer:  " + _wtxDevice.GeneralWeightError);
                        Console.WriteLine("Scale alarm triggered:         " + _wtxDevice.LimitStatus.ToString() + "\t  As an Integer:  " + _wtxDevice.LimitStatus);
                        Console.WriteLine("Scale seal is open:            " + _wtxDevice.ScaleSealIsOpen.ToString() + "\t  As an Integer:  " + _wtxDevice.ScaleSealIsOpen);
                        Console.WriteLine("Manual tare:                   " + _wtxDevice.ManualTare.ToString() + "\t  As an Integer:  " + _wtxDevice.ManualTare);
                        Console.WriteLine("Weight type:                   " + _wtxDevice.WeightType + "\t  As an Integer:  " + _wtxDevice.WeightType);        //_wtxDevice.WeightTypeStringComment()
                        Console.WriteLine("Scale range:                   " + _wtxDevice.ScaleRange + "\t  As an Integer:  " + _wtxDevice.ScaleRange);        //_wtxDevice.ScaleRangeStringComment()
                        Console.WriteLine("Zero required/True zero:       " + _wtxDevice.ZeroRequired.ToString() + "\t  As an Integer:  " + _wtxDevice.ZeroRequired);
                        Console.WriteLine("Weight within center of zero:  " + _wtxDevice.WeightWithinTheCenterOfZero.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightWithinTheCenterOfZero);
                        Console.WriteLine("Weight in zero range:          " + _wtxDevice.WeightInZeroRange.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightInZeroRange);
                        Console.WriteLine("Application mode:              " + _wtxDevice.ApplicationMode.ToString() + "\t  As an Integer:  " + _wtxDevice.ApplicationMode);  //_wtxDevice.ApplicationModeStringComment()
                        Console.WriteLine("Decimal places:                " + _wtxDevice.Decimals.ToString() + "\t  As an Integer:  " + _wtxDevice.Decimals);
                        Console.WriteLine("Unit:                          " + _wtxDevice.UnitStringComment() + "\t  As an Integer:  " + _wtxDevice.Unit);
                        Console.WriteLine("Handshake:                     " + _wtxDevice.Handshake.ToString() + "\t  As an Integer:  " + _wtxDevice.Handshake);
                        Console.WriteLine("Status:                        " + statusCommentMethod() + "\t  As an Integer:  " + _wtxDevice.Status);                        //_wtxDevice.StatusStringComment()

                        Console.WriteLine("Limit status:                  " + limitCommentMethod() + "       As an Integer:  " + _wtxDevice.LimitStatus);                 //_wtxDevice.LimitStatusStringComment()
                        Console.WriteLine("Weight moving:                 " + _wtxDevice.WeightMoving.ToString() + "         As an Integer: " + _wtxDevice.WeightMoving); //_wtxDevice.WeightMovingStringComment()
                    }
                    else
                    {
                        Console.WriteLine("\nWrong input for the number of bytes, which should be read from the register!\nPlease enter 'b' to choose again.");
                    }
                }
                else
                if (_wtxDevice.ApplicationMode == 2 || _wtxDevice.ApplicationMode == 1)
                {
                    Console.WriteLine("Net value:                     " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.NetValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.NetValue);
                    Console.WriteLine("Gross value:                   " + _wtxDevice.NetGrossValueStringComment(_wtxDevice.GrossValue, _wtxDevice.Decimals) + "\t  As an Integer:  " + _wtxDevice.GrossValue);
                    Console.WriteLine("General weight error:          " + _wtxDevice.GeneralWeightError.ToString() + "\t  As an Integer:  " + _wtxDevice.GeneralWeightError);
                    Console.WriteLine("Scale alarm triggered:         " + _wtxDevice.LimitStatus.ToString() + "\t  As an Integer:  " + _wtxDevice.LimitStatus);
                    Console.WriteLine("Scale seal is open:            " + _wtxDevice.ScaleSealIsOpen.ToString() + "\t  As an Integer:  " + _wtxDevice.ScaleSealIsOpen);
                    Console.WriteLine("Manual tare:                   " + _wtxDevice.ManualTare.ToString() + "\t  As an Integer:  " + _wtxDevice.ManualTare);
                    Console.WriteLine("Weight type:                   " + _wtxDevice.WeightType + "\t  As an Integer:  " + _wtxDevice.WeightType);                      //_wtxDevice.WeightTypeStringComment()
                    Console.WriteLine("Scale range:                   " + _wtxDevice.ScaleRange + "\t  As an Integer:  " + _wtxDevice.ScaleRange);                      //_wtxDevice.ScaleRangeStringComment()
                    Console.WriteLine("Zero required/True zero:       " + _wtxDevice.ZeroRequired.ToString() + "\t  As an Integer:  " + _wtxDevice.ZeroRequired);
                    Console.WriteLine("Weight within center of zero:  " + _wtxDevice.WeightWithinTheCenterOfZero.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightWithinTheCenterOfZero);
                    Console.WriteLine("Weight in zero range:          " + _wtxDevice.WeightInZeroRange.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightInZeroRange);
                    Console.WriteLine("Application mode:              " + _wtxDevice.ApplicationMode.ToString() + "\t  As an Integer:  " + _wtxDevice.ApplicationMode);            //_wtxDevice.ApplicationModeStringComment()
                    Console.WriteLine("Decimal places:                " + _wtxDevice.Decimals.ToString() + "\t  As an Integer:  " + _wtxDevice.Decimals);
                    Console.WriteLine("Unit:                          " + _wtxDevice.UnitStringComment() + "\t  As an Integer:  " + _wtxDevice.Unit);
                    Console.WriteLine("Handshake:                     " + _wtxDevice.Handshake.ToString() + "\t  As an Integer:  " + _wtxDevice.Handshake);
                    Console.WriteLine("Status:                        " + statusCommentMethod() + "\t  As an Integer:  " + _wtxDevice.Status);                          //_wtxDevice.StatusStringComment()

                    Console.WriteLine("Limit status:                  " + limitCommentMethod() + "     As an Integer:  " + _wtxDevice.LimitStatus);                     //_wtxDevice.LimitStatusStringComment()
                    Console.WriteLine("Weight moving:                 " + _wtxDevice.WeightMoving.ToString() + "          As an Integer:  " + _wtxDevice.WeightMoving); //_wtxDevice.WeightMovingStringComment()

                    if (_showAllInputWords == true)
                    {
                        Console.WriteLine("Digital input  1:              " + _wtxDevice.Input1.ToString() + "\t  As an Integer:  " + _wtxDevice.Input1);
                        Console.WriteLine("Digital input  2:              " + _wtxDevice.Input2.ToString() + "\t  As an Integer:  " + _wtxDevice.Input2);
                        Console.WriteLine("Digital input  3:              " + _wtxDevice.Input3.ToString() + "\t  As an Integer:  " + _wtxDevice.Input3);
                        Console.WriteLine("Digital input  4:              " + _wtxDevice.Input4.ToString() + "\t  As an Integer:  " + _wtxDevice.Input4);

                        Console.WriteLine("Digital output 1:              " + _wtxDevice.Output1.ToString() + "\t  As an Integer:  " + _wtxDevice.Output1);
                        Console.WriteLine("Digital output 2:              " + _wtxDevice.Output2.ToString() + "\t  As an Integer:  " + _wtxDevice.Output2);
                        Console.WriteLine("Digital output 3:              " + _wtxDevice.Output3.ToString() + "\t  As an Integer:  " + _wtxDevice.Output3);
                        Console.WriteLine("Digital output 4:              " + _wtxDevice.Output4.ToString() + "\t  As an Integer:  " + _wtxDevice.Output4);

                        Console.WriteLine("Coarse flow:                   " + _wtxDevice.CoarseFlow.ToString() + "\t  As an Integer:  " + _wtxDevice.CoarseFlow);
                        Console.WriteLine("Fine flow:                     " + _wtxDevice.FineFlow.ToString() + "\t  As an Integer:  " + _wtxDevice.FineFlow);
                        Console.WriteLine("Ready:                         " + _wtxDevice.Ready.ToString() + "\t  As an Integer:  " + _wtxDevice.Ready);
                        Console.WriteLine("Re-dosing:                     " + _wtxDevice.ReDosing.ToString() + "\t  As an Integer:  " + _wtxDevice.ReDosing);

                        Console.WriteLine("Emptying:                      " + _wtxDevice.Emptying.ToString() + "\t  As an Integer:  " + _wtxDevice.Emptying);
                        Console.WriteLine("Flow error:                    " + _wtxDevice.FlowError.ToString() + "\t  As an Integer:  " + _wtxDevice.FlowError);
                        Console.WriteLine("Alarm:                         " + _wtxDevice.Alarm.ToString() + "\t  As an Integer:  " + _wtxDevice.Alarm);
                        Console.WriteLine("ADC Overload/Unterload:        " + _wtxDevice.AdcOverUnderload.ToString() + "\t  As an Integer:  " + _wtxDevice.AdcOverUnderload);

                        Console.WriteLine("Max.Dosing time:               " + _wtxDevice.MaxDosingTime.ToString() + "\t  As an Integer:  " + _wtxDevice.MaxDosingTime);
                        Console.WriteLine("Legal-for-trade operation:     " + _wtxDevice.LegalTradeOp.ToString() + "\t  As an Integer:  " + _wtxDevice.LegalTradeOp);
                        Console.WriteLine("Tolerance error+:              " + _wtxDevice.ToleranceErrorPlus.ToString() + "\t  As an Integer:  " + _wtxDevice.ToleranceErrorPlus);
                        Console.WriteLine("Tolerance error-:              " + _wtxDevice.ToleranceErrorMinus.ToString() + "\t  As an Integer:  " + _wtxDevice.ToleranceErrorMinus);

                        Console.WriteLine("Status digital input 1:        " + _wtxDevice.StatusInput1.ToString() + "\t  As an Integer:  " + _wtxDevice.StatusInput1);
                        Console.WriteLine("General scale error:           " + _wtxDevice.GeneralScaleError.ToString() + "\t  As an Integer:  " + _wtxDevice.GeneralScaleError);
                        Console.WriteLine("Filling process status:        " + _wtxDevice.FillingProcessStatus.ToString() + "\t  As an Integer:  " + _wtxDevice.FillingProcessStatus);
                        Console.WriteLine("Number of dosing results:      " + _wtxDevice.NumberDosingResults.ToString() + "\t  As an Integer:  " + _wtxDevice.NumberDosingResults);

                        Console.WriteLine("Dosing result:                 " + _wtxDevice.DosingResult.ToString() + "\t  As an Integer:  " + _wtxDevice.DosingResult);
                        Console.WriteLine("Mean value of dosing results:  " + _wtxDevice.MeanValueDosingResults.ToString() + "\t  As an Integer:  " + _wtxDevice.MeanValueDosingResults);
                        Console.WriteLine("Standard deviation:            " + _wtxDevice.StandardDeviation.ToString() + "\t  As an Integer:  " + _wtxDevice.StandardDeviation);
                        Console.WriteLine("Total weight:                  " + _wtxDevice.TotalWeight.ToString() + "\t  As an Integer:  " + _wtxDevice.TotalWeight);

                        Console.WriteLine("Fine flow cut-off point:       " + _wtxDevice.FineFlowCutOffPoint.ToString() + "\t  As an Integer:  " + _wtxDevice.FineFlowCutOffPoint);
                        Console.WriteLine("Coarse flow cut-off point:     " + _wtxDevice.CoarseFlowCutOffPoint.ToString() + "\t  As an Integer:  " + _wtxDevice.CoarseFlowCutOffPoint);
                        Console.WriteLine("Current dosing time:           " + _wtxDevice.CurrentDosingTime.ToString() + "\t  As an Integer:  " + _wtxDevice.CurrentDosingTime);
                        Console.WriteLine("Current coarse flow time:      " + _wtxDevice.CurrentCoarseFlowTime.ToString() + "\t  As an Integer:  " + _wtxDevice.CurrentCoarseFlowTime);
                        Console.WriteLine("Current fine flow time:        " + _wtxDevice.CurrentFineFlowTime.ToString() + "\t  As an Integer:  " + _wtxDevice.CurrentFineFlowTime);

                        Console.WriteLine("Parameter set (product):       " + _wtxDevice.ParameterSetProduct.ToString() + "\t  As an Integer:  " + _wtxDevice.ParameterSetProduct);
                        Console.WriteLine("Weight memory, Day:            " + _wtxDevice.WeightMemDay.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightMemDay);
                        Console.WriteLine("Weight memory, Month:          " + _wtxDevice.WeightMemMonth.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightMemMonth);
                        Console.WriteLine("Weight memory, Year:           " + _wtxDevice.WeightMemYear.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightMemYear);
                        Console.WriteLine("Weight memory, Seq.Number:     " + _wtxDevice.WeightMemSeqNumber.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightMemSeqNumber);
                        Console.WriteLine("Weight memory, gross:          " + _wtxDevice.WeightMemGross.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightMemGross);
                        Console.WriteLine("Weight memory, net:            " + _wtxDevice.WeightMemNet.ToString() + "\t  As an Integer:  " + _wtxDevice.WeightMemNet);

                        Console.WriteLine("\nPress 'a' again to hide the input words.");
                    }

                    if (_showAllOutputWords == true)
                    {
                        Console.WriteLine("\nOutput words:\n");

                        Console.WriteLine(" 9) Residual flow time:            " + _wtxDevice.ResidualFlowTime + " Press '9' and a value to write");
                        Console.WriteLine("10) Target filling weight:         " + _wtxDevice.TargetFillingWeight + " Press '10' and a value to write");
                        Console.WriteLine("12) Coarse flow cut-off point:     " + _wtxDevice.CoarseFlowCutOffPoint + " Press '12' and a value to write");
                        Console.WriteLine("14) Fine flow cut-off point:       " + _wtxDevice.FineFlowCutOffPoint + " Press '14' and a value to write");

                        Console.WriteLine("16) Minimum fine flow:             " + _wtxDevice.MinimumFineFlow + " Press '16' and a value to write");
                        Console.WriteLine("18) Optimization of cut-off points:" + _wtxDevice.OptimizationOfCutOffPoints + " Press '18' and a value to write");
                        Console.WriteLine("19) Maximum dosing time:           " + _wtxDevice.MaxDosingTime + " Press '19' and a value to write");
                        Console.WriteLine("20) Start with fine flow:          " + _wtxDevice.StartWithFineFlow + " Press '20' and a value to write");

                        Console.WriteLine("21) Coarse lockout time:           " + _wtxDevice.CoarseLockoutTime + " Press '21' and a value to write");
                        Console.WriteLine("22) Fine lockout time:             " + _wtxDevice.FineLockoutTime + " Press '22' and a value to write");
                        Console.WriteLine("23) Tare mode:                     " + _wtxDevice.TareMode + " Press '23' and a value to write");
                        Console.WriteLine("24) Upper tolerance limit + :      " + _wtxDevice.UpperToleranceLimit + " Press '24' and a value to write");

                        Console.WriteLine("26) Lower tolerance limit -:       " + _wtxDevice.LowerToleranceLimit + " Press '26' and a value to write");
                        Console.WriteLine("28) Minimum start weight:          " + _wtxDevice.MinimumStartWeight + " Press '28' and a value to write");
                        Console.WriteLine("30) Empty weight:                  " + _wtxDevice.EmptyWeight + " Press '30' and a value to write");
                        Console.WriteLine("32) Tare delay:                    " + _wtxDevice.TareDelay + " Press '32' and a value to write");

                        Console.WriteLine("33) Coarse flow monitoring time:   " + _wtxDevice.CoarseFlowMonitoringTime + " Press '33' and a value to write");
                        Console.WriteLine("34) Coarse flow monitoring:        " + _wtxDevice.CoarseFlowMonitoring + " Press '34' and a value to write");
                        Console.WriteLine("36) Fine flow monitoring:          " + _wtxDevice.FineFlowMonitoring + " Press '36' and a value to write");
                        Console.WriteLine("38) Fine flow monitoring time:     " + _wtxDevice.FineFlowMonitoringTime + " Press '38' and a value to write");

                        Console.WriteLine("40) Delay time after fine flow:    " + _wtxDevice.DelayTimeAfterFineFlow + " Press '40' and a value to write");
                        Console.WriteLine("41) Systematic difference:         " + _wtxDevice.SystematicDifference + " Press '41' and a value to write");
                        Console.WriteLine("42) Downwards dosing:              " + _wtxDevice.DownwardsDosing + " Press '42' and a value to write");
                        Console.WriteLine("43) Valve control:                 " + _wtxDevice.ValveControl + " Press '43' and a value to write");
                        Console.WriteLine("44) Emptying mode:                 " + _wtxDevice.EmptyingMode + " Press '44' and a value to write");

                        Console.WriteLine("\nPress 'o' again to hide the output words.");
                    }
                }
            }
        }