Beispiel #1
0
            /// <summary>
            /// Updates the Builder with any attributes set in the Id's Entity.
            /// </summary>
            /// <param name="service">The service.</param>
            /// <param name="info">The builder.</param>
            /// <returns></returns>
            private static Entity CreateEntity(IOrganizationService service, BuilderInfo info)
            {
                var entity  = info.Id.Entity;
                var builder = info.Builder;

                if (entity != null)
                {
                    foreach (var att in entity.Attributes)
                    {
                        builder.WithAttributeValue(att.Key, att.Value);
                    }
                }

                return(builder.Create(service));
            }
Beispiel #2
0
        public override void PropertyEntityHandler(BuilderInfo info)
        {
            _handler.Using(info.Type);
            var destInfo = _destType.GetProperty(info.MemberName);

            if (destInfo != null && destInfo.CanWrite)
            {
                if (destInfo.PropertyType == info.Type ||
                    info.Type.IsSubclassOf(destInfo.PropertyType) ||
                    info.Type.IsImplementFrom(destInfo.PropertyType))
                {
                    _script.AppendLine($"{DEST}.{destInfo.Name}={SRC}.{destInfo.Name};");
                }
            }
        }
        public virtual void Initialize(DataProcessor processor, TableDataBuilder parentTable)
        {
            Builders = new List<BuilderInfo>();
            foreach (var def in TableDefinitions)
            {
                var fieldMappers = def.FieldMappers.ToArray();
                foreach (var mapper in fieldMappers)
                {
                    mapper.Initialize(processor);
                }


                var builder = fieldMappers.Length == 0
                    ? null
                    : new TableDataBuilder(def.Name, fieldMappers);                

                var builderInfo = new BuilderInfo(builder);

                if( builder != null )                
                {
                    if (parentTable != null)
                    {
                        builder.LinkParentTable(parentTable);
                    }

                    builder.EnsureKey(KeyFactory.Default);

                    processor.TableMap.Tables.Add(builderInfo.Builder);
                }

                foreach (var fieldMapper in fieldMappers)
                {
                    fieldMapper.InitializeRelatedTables(processor, builderInfo.Builder);
                }

                if (def.TableMappers != null)
                {
                    foreach (var childTable in def.TableMappers)
                    {
                        builderInfo.Children.Add(childTable);
                        childTable.Initialize(processor, builder ?? parentTable);
                    }
                }

                Builders.Add(builderInfo);
            }
        }
        public virtual void Initialize(DataProcessor processor, TableDataBuilder parentTable)
        {
            Builders = new List <BuilderInfo>();
            foreach (var def in TableDefinitions)
            {
                var fieldMappers = def.FieldMappers.ToArray();
                foreach (var mapper in fieldMappers)
                {
                    mapper.Initialize(processor);
                }


                var builder = fieldMappers.Length == 0
                    ? null
                    : new TableDataBuilder(def.Name, fieldMappers);

                var builderInfo = new BuilderInfo(builder);

                if (builder != null)
                {
                    if (parentTable != null)
                    {
                        builder.LinkParentTable(parentTable);
                    }

                    builder.EnsureKey(KeyFactory.Default);

                    processor.TableMap.Tables.Add(builderInfo.Builder);
                }

                foreach (var fieldMapper in fieldMappers)
                {
                    fieldMapper.InitializeRelatedTables(processor, builderInfo.Builder);
                }

                if (def.TableMappers != null)
                {
                    foreach (var childTable in def.TableMappers)
                    {
                        builderInfo.Children.Add(childTable);
                        childTable.Initialize(processor, builder ?? parentTable);
                    }
                }

                Builders.Add(builderInfo);
            }
        }
        /// <summary>
        /// Updates the Builder with any attributes set in the Id's Entity.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="info">The builder.</param>
        /// <param name="cyclicAttributes">The cyclic attributes.</param>
        /// <param name="postCreateUpdates">The post create updates.</param>
        /// <returns></returns>
        private static Entity CreateEntity(IOrganizationService service, BuilderInfo info, IEnumerable <string> cyclicAttributes, List <Entity> postCreateUpdates)
        {
            var entity  = info.Id.Entity;
            var builder = info.Builder;

            if (entity != null)
            {
                foreach (var att in entity.Attributes)
                {
                    builder.WithAttributeValue(att.Key, att.Value);
                }
            }

            var attributes       = cyclicAttributes as string[] ?? cyclicAttributes.ToArray();
            var postCreateEntity = new Entity(info.Id);

            if (attributes.Length > 0)
            {
                var tmp = builder.Build();
                foreach (var att in attributes)
                {
                    var parentEntity = tmp.GetAttributeValue <EntityReference>(att);
                    if (parentEntity == null || service.GetEntityOrDefault(parentEntity.LogicalName, parentEntity.Id, new ColumnSet(false)) != null)
                    {
                        continue;
                    }

                    // parent hasn't been created yet, Add attribute to be updated, and remove attribute for creation
                    postCreateEntity[att] = parentEntity;
                    builder.WithAttributeValue(att, null);
                }
            }

            var createdEntity = builder.Create(service, false);

            if (postCreateEntity.Attributes.Any())
            {
                postCreateEntity.Id = createdEntity.Id;
                postCreateUpdates.Add(postCreateEntity);
            }

            return(createdEntity);
        }
        public static void RegisterItem(LG_DistributeItem item, Action <GameObject> onSpawn)
        {
            var info = FindInfoByItem(item);

            if (info == null)
            {
                info = new BuilderInfo();

                ItemUtil.SetGUID(item);

                _ItemBuilderDict.Add(ItemUtil.GetGUID(item), info);
            }

            //TODO: Refactor code
            ItemMessage.OnItemSpawned += (guid, gameObject) =>
            {
                if (guid == GetGUID(item))
                {
                    onSpawn?.Invoke(gameObject);
                }
            };
        }
Beispiel #7
0
        public override void PropertyOnceTypeHandler(BuilderInfo info)
        {
            _handler.Using(info.Type);
            var destInfo = _destType.GetProperty(info.MemberName);

            if (destInfo != null && destInfo.CanWrite)
            {
                if (destInfo.PropertyType == info.Type)
                {
                    _script.AppendLine($"{DEST}.{destInfo.Name}={SRC}.{destInfo.Name};");
                }
                else
                {
                    if ((destInfo.PropertyType.IsPrimitive || destInfo.PropertyType == typeof(string)) &&
                        (info.Type.IsPrimitive || info.Type == typeof(string))
                        )
                    {
                        _script.AppendLine($"{DEST}.{destInfo.Name}=Convert.To{destInfo.PropertyType.GetDevelopName()}({SRC}.{destInfo.Name});");
                    }
                }
            }
        }
Beispiel #8
0
        void ViewDesigner(ITextDocument document)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            var builderInfo = BuilderInfo.FindCodeBehind(document.FilePath);

            if (builderInfo == null)
            {
                return;
            }
            var codeFile = builderInfo.GetDesignFile(document.FilePath);

            if (!File.Exists(codeFile))
            {
                return;
            }

            IVsWindowFrame frame;
            IVsUIHierarchy hierarchy;
            uint           itemid;

            VsShellUtilities.OpenDocumentWithSpecificEditor(ServiceProvider, codeFile, Constants.EtoPreviewEditorFactory_guid, VSConstants.LOGVIEWID.Primary_guid, out hierarchy, out itemid, out frame);
            ErrorHandler.ThrowOnFailure(frame.Show());
        }
Beispiel #9
0
        //static readonly object ViewCodeKey = new object();

        public void TextViewCreated(IWpfTextView textView)
        {
            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            if (textViewAdapter == null)
            {
                return;
            }

            var info = BuilderInfo.Find(document.FilePath);

            if (info != null)
            {
                // add commands to view form or code
                //textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => ViewDesigner(document)));
                //textView.Properties.AddProperty(ViewCodeKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewCode, () => ViewCode(document)));
                if (string.Equals(info.Extension, ".xeto", StringComparison.OrdinalIgnoreCase))
                {
                    textView.Properties.GetOrCreateSingletonProperty(() => new XamlCompletionHandler(textViewAdapter, textView, this));
                }
            }
            else if (BuilderInfo.IsCodeBehind(document.FilePath))
            {
                textView.Properties.AddProperty(ViewFormKey, new AdapterCommand(textViewAdapter, ServiceProvider, VSConstants.GUID_VSStandardCommandSet97, (uint)VSConstants.VSStd97CmdID.ViewForm, () => {
                    Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
                    ViewDesigner(document);
                }));
            }
        }
Beispiel #10
0
 public Delegate TypeRouter(BuilderInfo info)
 {
     foreach (var item in _handlers)
     {
         return(item.MatchType(info.DeclaringType)?  item.TypeRouter(info.DeclaringType) :  default);
 internal BaseBuilder(BuilderInfo taskBuilder)
 {
     tb = taskBuilder;
 }
 internal TriggerBuilder(BuilderInfo taskBuilder, MonthsOfTheYear moy)
     : this(taskBuilder)
 {
     TaskDef.Triggers.Add(trigger = new MonthlyTrigger() { MonthsOfYear = moy });
 }
 internal TriggerBuilder(BuilderInfo taskBuilder, DaysOfTheWeek dow)
     : this(taskBuilder)
 {
     TaskDef.Triggers.Add(trigger = new MonthlyDOWTrigger(dow));
 }
 internal MonthlyTriggerBuilder(BuilderInfo taskBuilder, MonthsOfTheYear moy)
     : base(taskBuilder)
 {
     this.trb = new TriggerBuilder(taskBuilder, moy);
 }
Beispiel #15
0
 public override void FieldArrayEntityHandler(BuilderInfo info)
 {
     SetField(info);
 }
Beispiel #16
0
 public override void EntityReturnHandler(BuilderInfo info)
 {
     _script.Append($"return {DEST};");
 }
        /// <summary>
        /// Display optimization
        /// </summary>
        /// <param name="localstartX"></param>
        /// <param name="localstartY"></param>
        private void ShowOptim(float localstartX, float localstartY, float width, float height)
        {
            try
            {
                Rect zone = new Rect(localstartX, localstartY, width, height);
                GUI.color = new Color(.8f, .8f, .8f, 1f);
                GUI.Box(zone, "");
                GUI.color = Color.white;

                string tooltip = "Remove all banks and Presets not used in the Midi file list";

                GUIContent content;
                if (MidiPlayerGlobal.ImSFCurrent != null)
                {
                    float xpos = localstartX + xpostitlebox;
                    float ypos = localstartY + ypostitlebox;
                    content = new GUIContent()
                    {
                        text = "Extract Patchs & Waves from " + MidiPlayerGlobal.ImSFCurrent.SoundFontName, tooltip = tooltip
                    };
                    EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), content, styleBold);
                    ypos += itemHeight;// + espace;

                    if (MidiPlayerGlobal.ImSFCurrent.PatchCount == 0 || MidiPlayerGlobal.ImSFCurrent.WaveCount == 0)
                    {
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), "No patchs and waves has been yet extracted from the Soundfont.", styleRed);
                        ypos += itemHeight / 1f; // + espace;
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), "On the right panel, select one bank for instruments and", styleRed);
                        ypos += itemHeight / 2f; // + espace;
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), "optional, one bank for drums kit, others banks will be removed.", styleRed);
                        ypos += itemHeight / 1f; // + espace;
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), "Then, choose between 'Optimize from Midi file list'", styleRed);
                        ypos += itemHeight / 2f; // + espace;
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), "or 'Extract all Patchs & Waves' with the buttons below.", styleRed);

                        ypos += itemHeight;// + espace;
                    }
                    else
                    {
                        string infoSf = string.Format("Patch count: {0}   Wave count:{1}   Wave size:{2}",
                                                      MidiPlayerGlobal.ImSFCurrent.PatchCount,
                                                      MidiPlayerGlobal.ImSFCurrent.WaveCount,
                                                      (MidiPlayerGlobal.ImSFCurrent.WaveSize < 1000000) ?
                                                      Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000d).ToString() + " Ko"
                                :
                                                      Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000000d).ToString() + " Mo"
                                                      );
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380 + 85, itemHeight), infoSf);

                        ypos += 2 * heightLine;
                    }
                    int widthCheck = 110;

                    /*
                     * KeepAllZones = GUI.Toggle(new Rect(xpos, ypos, widthCheck, itemHeight), KeepAllZones, new GUIContent("Keep all Zones", "Keep all Waves associated with a Patch regardless of notes and velocities played in Midi files.\n Usefull if you want transpose Midi files."));
                     * xpos += widthCheck + espace;
                     * KeepAllPatchs = GUI.Toggle(new Rect(xpos, ypos, widthCheck, itemHeight), KeepAllPatchs, new GUIContent("Keep all Patchs", "Keep all Patchs and waves found in the SoundFont selected.\nWarning : a huge volume of files coud be created"));
                     * xpos += widthCheck + +2 * espace;
                     * RemoveUnusedWaves = GUI.Toggle(new Rect(xpos, ypos, widthCheck + 40, itemHeight), RemoveUnusedWaves, new GUIContent("Remove unused waves", "If check, keep only waves used by your midi files"));
                     * ypos += itemHeight;// + espace;
                     */

                    // Always true
                    RemoveUnusedWaves = true;
                    xpos = localstartX + xpostitlebox;
                    Rect rect = new Rect(xpos, ypos, widthCheck * 2 + espace, buttonHeight);
#if MPTK_PRO
                    if (GUI.Button(rect, new GUIContent("Optimize from Midi file list", "Your list of Midi files will be scanned to identify patchs and zones useful")))
                    {
                        KeepAllPatchs = false;
                        KeepAllZones  = false;
                        OptimInfo     = new BuilderInfo();
                        SoundFontOptim.OptimizeSFFromMidiFiles(OptimInfo, KeepAllPatchs, KeepAllZones, RemoveUnusedWaves);
                        //listPatchs = PatchOptim.PatchUsed();
                    }

                    xpos += 3 * espace + 2 * widthCheck;
                    rect  = new Rect(xpos, ypos, buttonWidth, buttonHeight);
                    if (GUI.Button(rect, new GUIContent("Extract all Patchs & Waves", "All patchs and waves will be extracted from the Soundfile")))
                    {
                        KeepAllPatchs = true;
                        KeepAllZones  = true;
                        OptimInfo     = new BuilderInfo();
                        SoundFontOptim.OptimizeSFFromMidiFiles(OptimInfo, KeepAllPatchs, KeepAllZones, RemoveUnusedWaves);
                        //listPatchs = PatchOptim.PatchUsed();
                    }
#else
                    if (GUI.Button(rect, new GUIContent("Optimize from Midi file list [PRO]", "You need to setup some midi files before to launch ths optimization")))
                    {
                        PopupWindow.Show(rect, new GetVersionPro());
                    }
                    xpos += 3 * espace + 2 * widthCheck;
                    rect  = new Rect(xpos, ypos, buttonWidth, buttonHeight);
                    if (GUI.Button(rect, new GUIContent("Extract all Patchs & Waves [PRO]", "")))
                    {
                        PopupWindow.Show(rect, new GetVersionPro());
                    }
#endif
                    ypos += itemHeight + espace;


                    if (MidiPlayerGlobal.ImSFCurrent.PatchCount != 0 && MidiPlayerGlobal.ImSFCurrent.WaveCount != 0)
                    {
                        //
                        // Show patch list
                        //
                        xpos = localstartX + xpostitlebox;
                        EditorGUI.LabelField(new Rect(xpos, ypos, 380, itemHeight), "List of available Patchs:");
                        ypos += itemHeight / 2f;
                        List <string> patchList = new List <string>();
                        for (int i = 0; i < MidiPlayerGlobal.MPTK_ListPreset.Count; i++)
                        {
                            if (!string.IsNullOrEmpty(MidiPlayerGlobal.MPTK_ListPreset[i]))
                            {
                                patchList.Add(string.Format("Instrument - Patch: [{0:000}] {1}", i, MidiPlayerGlobal.MPTK_ListPreset[i]));
                            }
                        }
                        for (int i = 0; i < MidiPlayerGlobal.MPTK_ListDrum.Count; i++)
                        {
                            if (!string.IsNullOrEmpty(MidiPlayerGlobal.MPTK_ListDrum[i]))
                            {
                                patchList.Add(string.Format("Drum - Midi note: [{0:000}] {1}", i, MidiPlayerGlobal.MPTK_ListDrum[i]));
                            }
                        }

                        float heightAvailable = height - (ypos - (localstartY + ypostitlebox)) - 16;
                        Rect  listVisibleRect = new Rect(localstartX, ypos, width - 5, heightAvailable);
                        GUI.color = new Color(.8f, .8f, .8f, 1f);
                        GUI.Box(new Rect(localstartX + 5, ypos + 5, width - 30, heightAvailable - 4), "");
                        Rect listContentRect = new Rect(0, 0, width - 20, patchList.Count * itemHeight + 5);

                        scrollPosListPatchs = GUI.BeginScrollView(listVisibleRect, scrollPosListPatchs, listContentRect);
                        float boxY = 0;

                        foreach (string patchInfo in patchList)
                        {
                            GUI.color = new Color(.7f, .7f, .7f, 1f);
                            float boxX = 5;
                            GUI.Box(new Rect(boxX, boxY + 5, width - 30, itemHeight), "");
                            GUI.color = Color.white;
                            EditorGUI.LabelField(new Rect(boxX, boxY + 9, 300, itemHeight), patchInfo);
                            boxY += itemHeight;
                        }
                        GUI.EndScrollView();


                        ypos += heightAvailable + heightLine;



                        //List<PatchOptim> listPatchs = PatchOptim.PatchUsed();

                        //float heightAvailable = height - (ypos - (localstartY + ypostitlebox)) - 15 - 4 * heightLine;
                        //Rect listVisibleRect = new Rect(localstartX, ypos, width - 5, heightAvailable);
                        //Rect listContentRect = new Rect(0, 0, width - 20, listPatchs.Count * itemHeight + 5);

                        //scrollPosListPatchs = GUI.BeginScrollView(listVisibleRect, scrollPosListPatchs, listContentRect);
                        //float boxY = 0;

                        //for (int i = 0; i < listPatchs.Count; i++)
                        //{
                        //    GUI.color = new Color(.7f, .7f, .7f, 1f);
                        //    float boxX = 5;
                        //    GUI.Box(new Rect(boxX, boxY + 5, width - 30, itemHeight), "");
                        //    GUI.color = Color.white;
                        //    PatchOptim patch = listPatchs[i];
                        //    string patchinfo = string.Format("{0,15} [{1:000}] {2}", patch.Drum?"Drum":"Instrument", patch.Patch, patch.Name);
                        //    //content = new GUIContent() { text = patchinfo, tooltip = MidiPlayerGlobal.CurrentMidiSet.MidiFiles[i] };
                        //    EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), patchinfo);

                        //    //boxX += 280 + espace;
                        //    //patch.Selected = GUI.Toggle(new Rect(boxX, boxY + 9, 80, buttonHeight), patch.Selected, "Selected");

                        //    boxY += itemHeight;
                        //}
                        //GUI.EndScrollView();
                        //ypos += heightAvailable + heightLine;
                    }
                    //
                    // Show stat
                    //
                    //EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, ypos, 100, heightLine), "Patch count :");
                    //EditorGUI.LabelField(new Rect(localstartX + xpostitlebox + 110, ypos, 100, heightLine), MidiPlayerGlobal.ImSFCurrent.PatchCount.ToString());
                    //ypos += heightLine;

                    //string strSize = "";
                    //if (MidiPlayerGlobal.ImSFCurrent.WaveSize < 1000000)
                    //    strSize = Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000d).ToString() + " Ko";
                    //else
                    //    strSize = Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000000d).ToString() + " Mo";

                    //EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, ypos, 100, heightLine), "Wave count :");
                    //EditorGUI.LabelField(new Rect(localstartX + xpostitlebox + 110, ypos, 100, heightLine), MidiPlayerGlobal.ImSFCurrent.WaveCount.ToString());
                    //ypos += heightLine;

                    //EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, ypos, 100, heightLine), "Wave size :");
                    //EditorGUI.LabelField(new Rect(localstartX + xpostitlebox + 110, ypos, 100, heightLine), strSize);
                    //ypos += heightLine;
                }
                else
                {
                    content = new GUIContent()
                    {
                        text = "No SoundFont selected", tooltip = tooltip
                    };
                    EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, localstartY + ypostitlebox, 300, itemHeight), content, styleBold);
                }
            }
            catch (Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
        /// <summary>
        /// Display, add, remove Soundfont
        /// </summary>
        /// <param name="localstartX"></param>
        /// <param name="localstartY"></param>
        private void ShowListSoundFonts(float localstartX, float localstartY, float width, float height)
        {
            try
            {
                Rect zone = new Rect(localstartX, localstartY, width, height);
                GUI.color = new Color(.8f, .8f, .8f, 1f);
                GUI.Box(zone, "");
                GUI.color = Color.white;
                if (MidiPlayerGlobal.CurrentMidiSet != null && MidiPlayerGlobal.CurrentMidiSet.SoundFonts != null)
                {
                    string caption = "SoundFont available";
                    if (MidiPlayerGlobal.CurrentMidiSet.SoundFonts.Count == 0)
                    {
                        caption = "No SoundFont available yet";
                        MidiPlayerGlobal.ImSFCurrent = null;
                    }

                    GUIContent content = new GUIContent()
                    {
                        text = caption, tooltip = "Each SoundFonts contains a set of bank of sound. \nOnly one SoundFont can be active at the same time for the midi player"
                    };
                    EditorGUI.LabelField(new Rect(localstartX + xpostitlebox, localstartY + ypostitlebox, 300, itemHeight), content, styleBold);
                    Rect rect = new Rect(width - buttonWidth, localstartY + ypostitlebox, buttonWidth, buttonHeight);
#if MPTK_PRO
                    if (GUI.Button(rect, "Add SoundFont"))
                    {
                        //if (EditorUtility.DisplayDialog("Import SoundFont", "This action could take time, do you confirm ?", "Ok", "Cancel"))
                        {
                            SoundFontOptim.AddSoundFont();
                            scrollPosSoundFont = Vector2.zero;
                            KeepAllPatchs      = false;
                            KeepAllZones       = false;
                            //listPatchs = PatchOptim.PatchUsed();
                        }
                    }
#else
                    if (GUI.Button(rect, "Add SoundFont [PRO]"))
                    {
                        try
                        {
                            PopupWindow.Show(rect, new GetVersionPro());
                        }
                        catch (Exception)
                        {
                            // generate some weird exception ...
                        }
                    }
#endif

                    Rect listVisibleRect = new Rect(localstartX, localstartY + itemHeight, width - 5, height - itemHeight - 5);
                    Rect listContentRect = new Rect(0, 0, width - 20, MidiPlayerGlobal.CurrentMidiSet.SoundFonts.Count * itemHeight + 5);

                    scrollPosSoundFont = GUI.BeginScrollView(listVisibleRect, scrollPosSoundFont, listContentRect);
                    float boxY = 0;

                    for (int i = 0; i < MidiPlayerGlobal.CurrentMidiSet.SoundFonts.Count; i++)
                    {
                        SoundFontInfo sf = MidiPlayerGlobal.CurrentMidiSet.SoundFonts[i];

                        GUI.color = new Color(.7f, .7f, .7f, 1f);
                        float boxX = 5;
                        GUI.Box(new Rect(boxX, boxY + 5, width - 30, itemHeight), "");
                        GUI.color = Color.white;

                        content = new GUIContent()
                        {
                            text = sf.Name, tooltip = ""
                        };
                        EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), content);

                        if (sf.Name == MidiPlayerGlobal.CurrentMidiSet.ActiveSounFontInfo.Name)
                        {
                            GUI.color = ToolsEditor.ButtonColor;
                        }

                        boxX += 200 + espace;
                        if (GUI.Button(new Rect(boxX, boxY + 9, 80, buttonHeight), "Select"))
                        {
#if MPTK_PRO
                            OptimInfo = new BuilderInfo();
#endif
                            MidiPlayerGlobal.CurrentMidiSet.SetActiveSoundFont(i);
                            string soundPath = Path.Combine(Application.dataPath + "/", MidiPlayerGlobal.PathToSoundfonts);
                            soundPath = Path.Combine(soundPath + "/", sf.Name);
                            ToolsEditor.LoadImSF(soundPath, sf.Name);
                            MidiPlayerGlobal.CurrentMidiSet.Save();
                            if (MidiPlayerGlobal.ImSFCurrent != null)
                            {
                                KeepAllPatchs     = MidiPlayerGlobal.ImSFCurrent.KeepAllPatchs;
                                KeepAllZones      = MidiPlayerGlobal.ImSFCurrent.KeepAllZones;
                                RemoveUnusedWaves = MidiPlayerGlobal.ImSFCurrent.RemoveUnusedWaves;
                                if (Application.isPlaying)
                                {
                                    MidiPlayerGlobal.MPTK_SelectSoundFont(null);
                                }
                            }
                            //listPatchs = PatchOptim.PatchUsed();
                        }
                        boxX += 80 + espace;

                        GUI.color = Color.white;
                        rect      = new Rect(boxX, boxY + 9, 80, buttonHeight);
                        if (GUI.Button(rect, "Remove"))
                        {
#if MPTK_PRO
                            OptimInfo = new BuilderInfo();
                            string soundFontPath = Path.Combine(Application.dataPath + "/", MidiPlayerGlobal.PathToSoundfonts);
                            string path          = Path.Combine(soundFontPath, sf.Name);
                            if (!string.IsNullOrEmpty(path) && EditorUtility.DisplayDialog("Delete SoundFont", "Are you sure to delete all the content of this folder ? " + path, "ok", "cancel"))
                            {
                                try
                                {
                                    Directory.Delete(path, true);
                                    File.Delete(path + ".meta");
                                }
                                catch (Exception ex)
                                {
                                    Debug.Log("Remove SF " + ex.Message);
                                }
                                AssetDatabase.Refresh();
                                ToolsEditor.CheckMidiSet();
                            }
#else
                            try
                            {
                                PopupWindow.Show(rect, new GetVersionPro());
                            }
                            catch (Exception)
                            {
                                // generate some weird exception ...
                            }
#endif
                        }

                        GUI.color = Color.white;

                        //boxX = 5;
                        //boxY += itemHeight;
                        //if (MidiPlayerGlobal.ImSFCurrent.WaveSize < 1000000)
                        //    strSize = Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000d).ToString() + " Ko";
                        //else
                        //    strSize = Math.Round((double)MidiPlayerGlobal.ImSFCurrent.WaveSize / 1000000d).ToString() + " Mo";
                        //string.Format("Patch count: {0} Wave count:{1} Wave size:{2}", MidiPlayerGlobal.ImSFCurrent.PatchCount, MidiPlayerGlobal.ImSFCurrent.WaveCount, strSize);

                        //content = new GUIContent() { text = sf.Name, tooltip = "" };
                        //EditorGUI.LabelField(new Rect(boxX, boxY + 9, 200, itemHeight), content);

                        boxY += itemHeight;
                    }
                    GUI.EndScrollView();
                }
            }
            catch (Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
 internal ActionBuilder(BuilderInfo taskBuilder, string path)
     : base(taskBuilder)
 {
     TaskDef.Actions.Add(new ExecAction(path));
 }
 internal BaseBuilder(BuilderInfo taskBuilder)
 {
     tb = taskBuilder;
 }
 internal TriggerBuilder(BuilderInfo taskBuilder, TaskTriggerType taskTriggerType)
     : this(taskBuilder)
 {
     TaskDef.Triggers.Add(trigger = Trigger.CreateTrigger(taskTriggerType));
 }
 internal IntervalTriggerBuilder(BuilderInfo taskBuilder, short interval)
     : base(taskBuilder)
 {
     this.interval = interval;
 }
Beispiel #23
0
        /// <summary>
        /// Return information about a midifile : patch change, copyright, ...
        /// </summary>
        /// <param name="pathfilename"></param>
        /// <param name="Info"></param>
        static public void GeneralInfo(string pathfilename, BuilderInfo Info)
        {
            try
            {
                int NumberBeatsMeasure;
                int NumberQuarterBeat;
                Debug.Log("Open midifile :" + pathfilename);
                MidiLoad midifile = new MidiLoad();
                midifile.Load(pathfilename);
                if (midifile != null)
                {
                    Info.Add(string.Format("Format: {0}", midifile.midifile.FileFormat));
                    Info.Add(string.Format("Tracks: {0}", midifile.midifile.Tracks));
                    Info.Add(string.Format("Ticks Quarter Note: {0}", midifile.midifile.DeltaTicksPerQuarterNote));

                    //if (false)
                    {
                        foreach (TrackMidiEvent trackEvent in midifile.MidiSorted)
                        {
                            if (trackEvent.Event.CommandCode == MidiCommandCode.NoteOn)
                            {
                                // Not used
                                //if (((NoteOnEvent)trackEvent.Event).OffEvent != null)
                                //{
                                //    //infoTrackMidi[e.Channel].Events.Add((NoteOnEvent)e);
                                //    NoteOnEvent noteon = (NoteOnEvent)trackEvent.Event;
                                //}
                            }
                            else if (trackEvent.Event.CommandCode == MidiCommandCode.NoteOff)
                            {
                                Debug.Log("NoteOff");
                            }
                            else if (trackEvent.Event.CommandCode == MidiCommandCode.ControlChange)
                            {
                                // Not used
                                //ControlChangeEvent controlchange = (ControlChangeEvent)e;
                                //Debug.Log(string.Format("CtrlChange  Track:{0} Channel:{1,2:00} {2}", track, e.Channel, controlchange.ToString()));
                            }
                            else if (trackEvent.Event.CommandCode == MidiCommandCode.PatchChange)
                            {
                                PatchChangeEvent change = (PatchChangeEvent)trackEvent.Event;
                                Info.Add(BuildInfoTrack(trackEvent) + string.Format("PatchChange {0,3:000} {1}", change.Patch, PatchChangeEvent.GetPatchName(change.Patch)), 2);
                            }
                            else if (trackEvent.Event.CommandCode == MidiCommandCode.MetaEvent)
                            {
                                MetaEvent meta = (MetaEvent)trackEvent.Event;
                                switch (meta.MetaEventType)
                                {
                                case MetaEventType.SetTempo:
                                    TempoEvent tempo = (TempoEvent)meta;
                                    Info.Add(BuildInfoTrack(trackEvent) + string.Format("SetTempo Tempo:{0} MicrosecondsPerQuarterNote:{1}", Math.Round(tempo.Tempo, 0), tempo.MicrosecondsPerQuarterNote), 2);
                                    //tempo.Tempo
                                    break;

                                case MetaEventType.TimeSignature:

                                    TimeSignatureEvent timesig = (TimeSignatureEvent)meta;
                                    // Numerator: counts the number of beats in a measure.
                                    // For example a numerator of 4 means that each bar contains four beats.

                                    // Denominator: number of quarter notes in a beat.0=ronde, 1=blanche, 2=quarter, 3=eighth, etc.
                                    // Set default value
                                    NumberBeatsMeasure = timesig.Numerator;
                                    NumberQuarterBeat  = System.Convert.ToInt32(System.Math.Pow(2, timesig.Denominator));
                                    Info.Add(BuildInfoTrack(trackEvent) + string.Format("TimeSignature Beats Measure:{0} Beat Quarter:{1}", NumberBeatsMeasure, NumberQuarterBeat), 2);
                                    break;

                                case MetaEventType.SequenceTrackName:   // Sequence / Track Name
                                case MetaEventType.ProgramName:
                                case MetaEventType.TrackInstrumentName: // Track instrument name
                                case MetaEventType.TextEvent:           // Text event
                                case MetaEventType.Copyright:           // Copyright
                                    Info.Add(BuildInfoTrack(trackEvent) + ((TextEvent)meta).Text, 1);
                                    break;

                                case MetaEventType.Lyric:     // lyric
                                case MetaEventType.Marker:    // marker
                                case MetaEventType.CuePoint:  // cue point
                                case MetaEventType.DeviceName:
                                    //Info.Add(BuildInfoTrack(trackEvent) + string.Format("{0} '{1}'", meta.MetaEventType.ToString(), ((TextEvent)meta).Text));
                                    break;
                                }
                            }
                            else
                            {
                                // Other midi event
                                //Debug.Log(string.Format("Track:{0} Channel:{1,2:00} CommandCode:{2,3:000} AbsoluteTime:{3,6:000000}", track, e.Channel, e.CommandCode.ToString(), e.AbsoluteTime));
                            }
                        }
                    }
                    //else DebugMidiSorted(midifile.MidiSorted);
                }
                else
                {
                    Info.Add("Error reading midi file");
                }
            }
            catch (System.Exception ex)
            {
                MidiPlayerGlobal.ErrorDetail(ex);
            }
        }
Beispiel #24
0
 public override void EntityStartHandler(BuilderInfo info)
 {
     _script.Append($@"if({SRC}==null){{return null;}}");
     _script.Append($"var {DEST} = new {_destType.GetDevelopName()}();");
 }
Beispiel #25
0
 public override void FieldIDictionaryHandler(BuilderInfo info)
 {
     SetField(info);
 }
Beispiel #26
0
 public override void FieldArrayOnceTypeHandler(BuilderInfo info)
 {
     SetField(info);
 }
 internal WeeklyTriggerBuilder(BuilderInfo taskBuilder, short interval)
     : base(taskBuilder)
 {
     TaskDef.Triggers.Add(trigger = new WeeklyTrigger() { WeeksInterval = interval });
 }
Beispiel #28
0
 public override void FieldCollectionHandler(BuilderInfo info)
 {
     SetField(info);
 }
 internal TriggerBuilder(BuilderInfo taskBuilder)
     : base(taskBuilder)
 {
 }
 internal MonthlyDOWTriggerBuilder(BuilderInfo taskBuilder, DaysOfTheWeek dow)
     : base(taskBuilder)
 {
     this.trb = new TriggerBuilder(taskBuilder, dow);
 }
 internal TriggerBuilder(BuilderInfo taskBuilder)
     : base(taskBuilder)
 {
 }
 internal IntervalTriggerBuilder(BuilderInfo taskBuilder, short interval)
     : base(taskBuilder)
 {
     this.interval = interval;
 }
Beispiel #33
0
 public override void PropertyArrayOnceTypeHandler(BuilderInfo info)
 {
     SetProperty(info);
 }
 internal TriggerBuilder(BuilderInfo taskBuilder, DaysOfTheWeek dow)
     : this(taskBuilder)
 {
     TaskDef.Triggers.Add(trigger = new MonthlyDOWTrigger(dow));
 }
Beispiel #35
0
 public override void PropertyArrayEntityHandler(BuilderInfo info)
 {
     SetProperty(info);
 }
 internal TriggerBuilder(BuilderInfo taskBuilder, TaskTriggerType taskTriggerType)
     : this(taskBuilder)
 {
     TaskDef.Triggers.Add(trigger = Trigger.CreateTrigger(taskTriggerType));
 }
Beispiel #37
0
 public override void PropertyICollectionHandler(BuilderInfo info)
 {
     SetProperty(info);
 }
 internal ActionBuilder(BuilderInfo taskBuilder, string path)
     : base(taskBuilder)
 {
     TaskDef.Actions.Add(new ExecAction(path));
 }
Beispiel #39
0
 public override void PropertyIDictionaryHandler(BuilderInfo info)
 {
     SetProperty(info);
 }
 public Delegate TypeRouter(BuilderInfo info)
 {
     //构造函数处理: 不存在public无参构造函数无法克隆;
     if (info.DeclaringType.GetConstructor(new Type[0]) == null)
     {
         return(default);
 internal MonthlyDOWTriggerBuilder(BuilderInfo taskBuilder, DaysOfTheWeek dow)
     : base(taskBuilder)
 {
     this.trb = new TriggerBuilder(taskBuilder, dow);
 }