Esempio n. 1
0
        public void OnExit()
        {
            if (AddonManager.CurrentAddon != null && AddonManager.CurrentAddon.Effect != null)
            {
                int.TryParse(extendBoxH.Text.Trim(), out var extH);
                int.TryParse(extendBoxV.Text.Trim(), out var extV);

                var effect = new Effect
                {
                    Animated            = animated.Text == "true",
                    BlendsBackground    = blendsBackground.Text == "true",
                    CrossSampling       = crossSampling.Text == "true",
                    ExtendBoxVertical   = extH,
                    ExtendBoxHorizontal = extV,
                    MustPredraw         = mustPreDraw.Text == "true",
                    PreservesOpaqueness = preservesOpaqueness.Text == "true",
                    Parameters          = AddonManager.CurrentAddon.Effect.Parameters,
                    Code = AddonManager.CurrentAddon.Effect.Code
                };

                AddonManager.CurrentAddon.Effect        = effect;
                AddonManager.CurrentAddon.AddonCategory = category.Text;
                AddonManager.SaveCurrentAddon();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// this saves the currently selected addon
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveAddon_Click(object sender, RoutedEventArgs e)
        {
            AddonManager.CurrentAddon = new C3Addon
            {
                Name          = string.Empty,
                Class         = string.Empty,
                Company       = string.Empty,
                Author        = string.Empty,
                Description   = string.Empty,
                AddonCategory = string.Empty,
                Type          = PluginType.SingleGlobalPlugin,
                Effect        = new Effect(),
                ThemeCss      = string.Empty,
                ThemeLangauge = string.Empty,
                IconXml       = ResourceReader.Insatnce.GetResourceText("c3IDE.Templates.Files.icon.svg"),
                CreateDate    = DateTime.Now
            };

            Enum.TryParse <PluginType>(AddonTypeDropdown.SelectedValue.ToString(), out var pluginType);
            var addonCategory = string.IsNullOrWhiteSpace(AddonCategoryDropdown.Text)? "other": AddonCategoryDropdown.Text;

            AddonManager.CurrentAddon.Name          = AddonNameText.Text;
            AddonManager.CurrentAddon.Class         = AddonClassText.Text.Replace(" ", string.Empty).Trim();
            AddonManager.CurrentAddon.Company       = AuthorText.Text.Replace(" ", string.Empty).Trim();
            AddonManager.CurrentAddon.Author        = AuthorText.Text;
            AddonManager.CurrentAddon.AddonId       = IdText.Text.Replace(" ", string.Empty).Trim();
            AddonManager.CurrentAddon.Description   = DescriptionText.Text;
            AddonManager.CurrentAddon.Type          = pluginType;
            AddonManager.CurrentAddon.AddonCategory = addonCategory;
            AddonManager.CurrentAddon.IconXml       = IconXml;
            AddonManager.CurrentAddon.Template      = TemplateFactory.Insatnce.CreateTemplate(pluginType);
            AddonManager.CurrentAddon.LastModified  = DateTime.Now;

            //add version
            AddonManager.CurrentAddon.MajorVersion    = 1;
            AddonManager.CurrentAddon.MinorVersion    = 0;
            AddonManager.CurrentAddon.RevisionVersion = 0;
            AddonManager.CurrentAddon.BuildVersion    = 0;

            //validate addon
            if (!AddonManager.ValidateCurrentAddon())
            {
                NotificationManager.PublishErrorNotification("addon data fields cannot be blank");
                return;
            }

            AddonMetadataGrid.IsEnabled = false;
            await Task.Run(() =>
            {
                IsSaved = true;
                AddonManager.CompileTemplates();
                AddonManager.SaveCurrentAddon();
                AddonManager.LoadAllAddons();
            });

            AddonMetadataGrid.IsEnabled = true;
            AddonManager.LoadAddon(AddonManager.CurrentAddon);
            NotificationManager.PublishNotification($"{AddonManager.CurrentAddon.Name} has been saved successfully");
            WindowManager.ChangeWindow(ApplicationWindows.DashboardWindow);
        }
Esempio n. 3
0
        /// <summary>
        /// global save
        /// </summary>
        /// <param name="compile"></param>
        public void Save(bool compile = true, bool force = false)
        {
            WindowManager.CurrentWindow.OnExit();

            if (AddonManager.CurrentAddon != null)
            {
                Searcher.Insatnce.UpdateFileIndex(AddonManager.CurrentAddon, WindowManager.CurrentWindow);
                AddonManager.SaveCurrentAddon();
                OpenNotification($"Saved {AddonManager.CurrentAddon.Name} successfully.");

                //parse all addons for new code completions
                CodeCompletionFactory.Insatnce.ParseAddon(AddonManager.CurrentAddon);

                if ((OptionsManager.CurrentOptions.CompileOnSave && compile) || force)
                {
                    if (!ControlHelper.Insatnce.IsWindowOpen <PopoutCompileWindow>())
                    {
                        //open popout compile window
                        ApplicationWindows.PopoutCompileWindow = new PopoutCompileWindow();
                        ApplicationWindows.PopoutCompileWindow.Show();
                    }

                    ApplicationWindows.PopoutCompileWindow.LogText.Text = string.Empty;
                    ApplicationWindows.PopoutCompileWindow.LogText.Text = "starting addon compilation...";
                    Task.Run(() => AddonCompiler.Insatnce.CompileAddon(AddonManager.CurrentAddon, false));
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// handles changing switching conditions
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ConditionListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ConditionListBox.SelectedIndex == -1)
            {
                return;
            }

            //save current selection
            if (_selectedCondition != null)
            {
                _selectedCondition.Ace               = AceTextEditor.Text;
                _selectedCondition.Language          = LanguageTextEditor.Text;
                _selectedCondition.Code              = CodeTextEditor.Text;
                _selectedCondition.Category          = Category.Text;
                _conditions[_selectedCondition.Id]   = _selectedCondition;
                AddonManager.CurrentAddon.Conditions = _conditions;
                AddonManager.SaveCurrentAddon();
            }

            //load new selection
            var selectedKey = ((KeyValuePair <string, Condition>)ConditionListBox.SelectedItem).Key;

            _selectedCondition = _conditions[selectedKey];

            Category.Text           = _selectedCondition.Category;
            AceTextEditor.Text      = _selectedCondition.Ace;
            LanguageTextEditor.Text = _selectedCondition.Language;
            CodeTextEditor.Text     = _selectedCondition.Code;

            folding.UpdateFoldings(aceFoldingManager, CodeTextEditor.Document);
        }
Esempio n. 5
0
        private async void ChangeAddonName_Click(object sender, RoutedEventArgs e)
        {
            if (AddonListBox.SelectedIndex == -1)
            {
                NotificationManager.PublishErrorNotification("error changing addon name, no c3addon selected");
                return;
            }

            var currentAddon = (C3Addon)AddonListBox.SelectedItem;

            AddonManager.LoadAddon(currentAddon);

            var newName = await WindowManager.ShowInputDialog("Change Addon Name", "enter new addon name", currentAddon.Name);

            var oldName = currentAddon.Name;

            if (!string.IsNullOrWhiteSpace(newName))
            {
                AddonManager.CurrentAddon.Name = newName;
                Searcher.Insatnce.GlobalFind(oldName, this, newName);

                AddonManager.SaveCurrentAddon();
                AddonManager.LoadAllAddons();
                ApplicationWindows.DashboardWindow.OnExit();
                ApplicationWindows.DashboardWindow.OnEnter();
            }
        }
Esempio n. 6
0
 private void BuildVersionPlus_Click(object sender, RoutedEventArgs e)
 {
     AddonManager.CurrentAddon.BuildVersion++;
     AddonManager.UpdateAddonJsonVersion();
     AddonManager.SaveCurrentAddon();
     Build.Text = AddonManager.CurrentAddon.BuildVersion.ToString();
 }
Esempio n. 7
0
 /// <summary>
 /// handles when the effect code window loses focus
 /// </summary>
 public void OnExit()
 {
     if (AddonManager.CurrentAddon != null)
     {
         AddonManager.CurrentAddon.Effect.Code = EffectPluginTextEditor.Text;
         AddonManager.SaveCurrentAddon();
     }
 }
Esempio n. 8
0
 public void OnExit()
 {
     if (AddonManager.CurrentAddon != null)
     {
         AddonManager.CurrentAddon.ThemeCss = CssTextEditor.Text;
         AddonManager.SaveCurrentAddon();
     }
 }
Esempio n. 9
0
 /// <summary>
 /// handles when the language windows loses focus
 /// </summary>
 public void OnExit()
 {
     if (AddonManager.CurrentAddon != null)
     {
         AddonManager.CurrentAddon.LanguageProperties = PropertyLanguageTextEditor.Text;
         AddonManager.CurrentAddon.LanguageCategories = CategoryLanguageTextEditor.Text;
         AddonManager.SaveCurrentAddon();
     }
 }
Esempio n. 10
0
 private void SaveIcon_Click(object sender, RoutedEventArgs e)
 {
     AddonManager.CurrentAddon.IconXml = IconXml;
     AddonManager.SaveCurrentAddon();
     AddonManager.LoadAllAddons();
     ApplicationWindows.DashboardWindow.OnExit();
     ApplicationWindows.DashboardWindow.OnEnter();
     this.Close();
 }
Esempio n. 11
0
 private void ResetIcon_Click(object sender, RoutedEventArgs e)
 {
     AddonManager.CurrentAddon.IconXml = ResourceReader.Insatnce.GetResourceText("c3IDE.Templates.Files.icon.svg");
     AddonManager.SaveCurrentAddon();
     AddonManager.LoadAllAddons();
     ApplicationWindows.DashboardWindow.OnExit();
     ApplicationWindows.DashboardWindow.OnEnter();
     this.Close();
 }
Esempio n. 12
0
        public void OnExit()
        {
            if (AddonManager.CurrentAddon != null)
            {
                AddonManager.CurrentAddon.C2RunTime = C2RuntimeTextEditor.Text;
                AddonManager.SaveCurrentAddon();
            }

            folding.UpdateFoldings(c2FoldingManager, C2RuntimeTextEditor.Document);
        }
Esempio n. 13
0
        /// <summary>
        /// handles when the instance window loses focus
        /// </summary>
        public void OnExit()
        {
            if (AddonManager.CurrentAddon != null)
            {
                AddonManager.CurrentAddon.InstanceEditTime = EditTimeInstanceTextEditor.Text;
                AddonManager.CurrentAddon.InstanceRunTime  = RunTimeInstanceTextEditor.Text;
                AddonManager.SaveCurrentAddon();
            }

            folding.UpdateFoldings(edittimeFoldingManager, EditTimeInstanceTextEditor.Document);
            folding.UpdateFoldings(runtimeFoldingManager, RunTimeInstanceTextEditor.Document);
        }
Esempio n. 14
0
        public void OnExit()
        {
            if (AddonManager.CurrentAddon != null)
            {
                if (_selectedParam != null)
                {
                    _selectedParam.Json = AddonTextEditor.Text;
                    _selectedParam.Lang = LangTextEditor.Text;

                    _params[_selectedParam.Key] = _selectedParam;
                }

                AddonManager.CurrentAddon.Effect.Parameters = _params;
                AddonManager.SaveCurrentAddon();
            }
        }
Esempio n. 15
0
        /// <summary>
        /// handles expression window losinf focus
        /// </summary>
        public void OnExit()
        {
            if (AddonManager.CurrentAddon != null)
            {
                //save the current selected expression
                if (_selectedExpression != null)
                {
                    _selectedExpression.Ace              = AceTextEditor.Text;
                    _selectedExpression.Language         = LanguageTextEditor.Text;
                    _selectedExpression.Code             = CodeTextEditor.Text;
                    _selectedExpression.Category         = Category.Text;
                    _expressions[_selectedExpression.Id] = _selectedExpression;
                }

                AddonManager.CurrentAddon.Expressions = _expressions;
                AddonManager.SaveCurrentAddon();
            }

            folding.UpdateFoldings(aceFoldingManager, CodeTextEditor.Document);
        }
Esempio n. 16
0
        /// <summary>
        /// handles when the addon window is no longer the main window
        /// </summary>
        public void OnExit()
        {
            if (AddonManager.CurrentAddon != null)
            {
                if (_selectedFile != null)
                {
                    //only update content for readable text files
                    switch (_selectedFile.Extention.ToLower())
                    {
                    case ".js":
                    case ".html":
                    case ".css":
                    case ".txt":
                    case ".json":
                    case ".xml":
                        _selectedFile.Content = FileTextEditor.Text;
                        break;
                    }
                    _selectedFile.C2Folder   = C2RuntimeFolder.IsChecked != null && C2RuntimeFolder.IsChecked.Value;
                    _selectedFile.C3Folder   = C3RuntimeFolder.IsChecked != null && C3RuntimeFolder.IsChecked.Value;
                    _selectedFile.Rootfolder = RootFolder.IsChecked != null && RootFolder.IsChecked.Value;
                    _selectedFile.Domfolder  = DomScript.IsChecked != null && DomScript.IsChecked.Value;
                    //_selectedFile.Bytes = Encoding.ASCII.GetBytes(FileTextEditor.Text);
                    _selectedFile.FileType       = FileTypeDropDown.Text;
                    _selectedFile.PluginTemplate = TemplateHelper.ThirdPartyFile(_selectedFile);
                    _selectedFile.Compress       = CompressFile.IsChecked != null && CompressFile.IsChecked.Value;
                    _selectedFile.PlainText      = PlainText.IsChecked != null && PlainText.IsChecked.Value;
                }

                AddonManager.CurrentAddon.ThirdPartyFiles = new Dictionary <string, ThirdPartyFile>();
                foreach (var thirdPartyFile in _files)
                {
                    AddonManager.CurrentAddon.ThirdPartyFiles.Add(thirdPartyFile.ID, thirdPartyFile);
                }

                AddonManager.CurrentAddon.AddonJson = AddonTextEditor.Text;
                AddonManager.SaveCurrentAddon();
            }
        }
Esempio n. 17
0
        private void ParameterListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ParameterListBox.SelectedIndex == -1)
            {
                return;
            }

            if (_selectedParam != null)
            {
                _selectedParam.Json         = AddonTextEditor.Text;
                _selectedParam.Lang         = LangTextEditor.Text;
                _params[_selectedParam.Key] = _selectedParam;
                AddonManager.CurrentAddon.Effect.Parameters = _params;
                AddonManager.SaveCurrentAddon();
            }

            var selectedKey = ((KeyValuePair <string, EffectParameter>)ParameterListBox.SelectedItem).Key;

            _selectedParam = _params[selectedKey];

            AddonTextEditor.Text = _selectedParam.Json;
            LangTextEditor.Text  = _selectedParam.Lang;
        }
Esempio n. 18
0
        //todo: we want to use the same guid, to overwrite existing addon.
        //todo: we want to parse a different version of the .c3ide file with relative paths
        //todo: abstract this functionaility out to a helper class

        /// <summary>
        /// when a file is dropped into the list box, if the file is a .c3ide file parse the file and load the addon
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AddonFile_OnDrop(object sender, DragEventArgs e)
        {
            try
            {
                var     file = ((string[])e.Data.GetData(DataFormats.FileDrop))?.FirstOrDefault();
                var     info = new FileInfo(file);
                C3Addon c3addon;

                if (info.Extension.Contains("c3ide"))
                {
                    var addonInfo = File.ReadAllLines(info.FullName)[0];
                    if (addonInfo == "@@METADATA")
                    {
                        c3addon = ProjectManager.ReadProject(info.FullName);
                    }
                    else
                    {
                        var data = File.ReadAllText(info.FullName);
                        c3addon = JsonConvert.DeserializeObject <C3Addon>(data);
                    }

                    //when you import the project, it should not overwrite any other project
                    if (OptionsManager.CurrentOptions.OverwriteGuidOnImport)
                    {
                        c3addon.Id = Guid.NewGuid();
                    }

                    c3addon.LastModified = DateTime.Now;

                    //get the plugin template
                    c3addon.Template = TemplateFactory.Insatnce.CreateTemplate(c3addon.Type);

                    var addonIndex = AddonManager.AllAddons.Count - 1;
                    AddonManager.CurrentAddon = c3addon;
                    AddonManager.SaveCurrentAddon();
                    AddonManager.LoadAllAddons();
                    AddonListBox.ItemsSource = AddonManager.AllAddons;
                    AddonManager.LoadAddon(c3addon);
                }
                else if (info.Extension.Contains("c3addon"))
                {
                    var result = await WindowManager.ShowDialog("(EXPERIMENTAL) Importing C3Addon File", "Importing a C3addon file is an experimental feature. Please verify your file was improted correctly. If you encounter an issue please open a Github Issue Ticket");

                    if (result)
                    {
                        c3addon = await C3AddonImporter.Insatnce.Import(info.FullName);

                        AddonManager.LoadAddon(c3addon);
                        AddonManager.SaveCurrentAddon();
                        AddonManager.LoadAllAddons();
                        AddonListBox.ItemsSource = AddonManager.AllAddons;
                        AddonManager.LoadAddon(c3addon);
                    }
                }
                else if (info.Extension.Contains("c2addon"))
                {
                    var result = await WindowManager.ShowDialog("(VERY EXPERIMENTAL) Importing C2Addon File", "Importing a C2addon file is an very experimental feature and expected to have BUGS. THIS DOES NOT FULLY CONVERT YOUR ADDON, it will attempt to generate stubs for the ACES. if you run into any issue importing please file Github Issue Ticket, please include the c2addon your trying to convert to help identify the issues, NOT ALL ISSUE WILL BE RESOLVED but i will do my best!!!");

                    if (result)
                    {
                        c3addon = await C2AddonImporter.Insatnce.Import2Addon(info.FullName);

                        AddonManager.LoadAddon(c3addon);
                        AddonManager.SaveCurrentAddon();
                        AddonManager.LoadAllAddons();
                        AddonListBox.ItemsSource = AddonManager.AllAddons;
                        AddonManager.LoadAddon(c3addon);
                    }
                }
                //else if (info.Extension.Contains("svg"))
                //{
                //    //todo: need to find a way to drag items into list box item
                //}
                else
                {
                    throw new InvalidOperationException("invalid file type, for import");
                }
            }
            catch (Exception exception)
            {
                LogManager.AddErrorLog(exception);
                NotificationManager.PublishErrorNotification($"error importing file, check import.log => {Path.Combine(OptionsManager.CurrentOptions.DataPath, "import.log")}");
            }
        }