예제 #1
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();
            }
        }
예제 #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);
        }
예제 #3
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();
 }
예제 #4
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();
 }
예제 #5
0
        /// <summary>
        /// main window constructor
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            try
            {
                //set application callbacks
                AddonManager.AddLoadedCallback((s) =>
                {
                    Title = $"C3IDE - {s.AddonId} - {s.Id}";
                    AddonLoadDelegate();
                });

                //setup callback
                NotificationManager.SetInfoCallback(OpenNotification);
                NotificationManager.SetErrorCallback(OpenErrorNotification);
                OptionsManager.OptionChangedCallback = OptionChanged;

                //load data
                AddonManager.LoadAllAddons();

                //setup window manager
                WindowManager.MainWindow         = this;
                WindowManager.OpenFindAndReplace = OpenFindAndReplace;
                WindowManager.SetWindowChangeCallback(NavigateToWindow);
                WindowManager.ShowDialog         = ShowDialogBox;
                WindowManager.ShowInputDialog    = ShowInputDialogBox;
                WindowManager.ShowLoadingOverlay = ShowLoadingOverlay;
                WindowManager.CurrentWindow      = ApplicationWindows.DashboardWindow;

                //setup themes and menu
                ThemeManager.SetupTheme();
                MenuManager.SetupMainMenu();

                //setup default view
                SetupMenus(PluginType.SingleGlobalPlugin);
                ActiveItem.Content = ApplicationWindows.DashboardWindow;
                ApplicationWindows.DashboardWindow.OnEnter();
                OptionChanged(OptionsManager.CurrentOptions);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                LogManager.AddErrorLog(ex);
                throw;
            }
        }
예제 #6
0
        /// <summary>
        /// builds the c3addon zip file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BuildSelectedAddon_Click(object sender, RoutedEventArgs e)
        {
            if (AddonListBox.SelectedIndex == -1)
            {
                NotificationManager.PublishErrorNotification("error building c3addon, no c3addon selected");
                return;
            }

            var currentAddon = (C3Addon)AddonListBox.SelectedItem;

            AddonManager.LoadAddon(currentAddon);
            AddonExporter.Insatnce.ExportAddon(AddonManager.CurrentAddon);
            ProcessHelper.Insatnce.StartProcess(OptionsManager.CurrentOptions.C3AddonPath);
            AddonManager.IncrementVersion();

            AddonManager.LoadAllAddons();
            AddonListBox.ItemsSource = AddonManager.AllAddons;
        }
예제 #7
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")}");
            }
        }