public void Duplicate(ChangeControl control)
        {
            int index = ChangeParent.Children.IndexOf(control);

            if (index == -1)
            {
                return;
            }

            VersionController versionController = MainWindow.GetInstance().VersionController;
            Version           version           = openVersionRef.GetVersion().Result;
            ChangeRef         oldChangeRef      = version.Changes[index];
            string            guid         = Guid.NewGuid().ToString();
            string            relativePath = Path.Combine(version.VersionName, "changes", $"{guid}.json");
            ChangeRef         newChangeRef = new ChangeRef(versionController, guid, relativePath);

            version.Changes.Insert(index + 1, newChangeRef);

            Change     oldChange      = oldChangeRef.GetChange(false).Result;
            VersionRef releaseVersion = new VersionRef(versionController, oldChange.ReleaseVersion.RelativeFilePath, oldChange.ReleaseVersion.VersionName);
            Change     newChange      = new Change(versionController, guid, relativePath, oldChange.Title, oldChange.Description, releaseVersion);

            if (oldChange.AdditionalData != null)
            {
                newChange.AdditionalData = (JObject)oldChange.AdditionalData.DeepClone();
            }

            versionController.CacheChange(newChange);

            ChangeControl newControl = new ChangeControl(newChangeRef);

            ChangeParent.Children.Insert(index + 1, newControl);
        }
        public void Duplicate(VersionControl control)
        {
            int index = VersionParent.Children.IndexOf(control);

            if (index == -1)
            {
                return;
            }

            VersionController versionController = MainWindow.GetInstance().VersionController;
            ChangeLog         changeLog         = versionController.GetChangeLog().Result;
            VersionRef        oldVersionRef     = changeLog.Versions[index];
            string            duplicateName     = GetDuplicateName(oldVersionRef.VersionName);
            VersionRef        newVersionRef     = new VersionRef(versionController, oldVersionRef.RelativeFilePath, duplicateName);

            changeLog.Versions.Insert(index + 1, newVersionRef);
            VersionControl newControl = new VersionControl(newVersionRef);

            VersionParent.Children.Insert(index + 1, newControl);

            Version oldVersion = oldVersionRef.GetVersion(false).Result;
            Version version    = new Version(versionController, duplicateName, oldVersion.Description, oldVersion.DownloadLink, oldVersion.ReleaseDate, new System.Collections.Generic.List <ChangeRef>());

            if (oldVersion.AdditionalData != null)
            {
                version.AdditionalData = (JObject)oldVersion.AdditionalData.DeepClone();
            }

            foreach (ChangeRef oldChangeRef in oldVersion.Changes)
            {
                string    guid          = Guid.NewGuid().ToString();
                string    newChangePath = Path.Combine(version.VersionName, "changes", $"{guid}.json");
                ChangeRef newChangeRef  = new ChangeRef(versionController, guid, newChangePath);
                Change    oldChange     = oldChangeRef.GetChange(false).Result;
                Change    newChange     = new Change(versionController, guid, newChangePath, oldChange.Title, oldChange.Description, newVersionRef);
                if (oldChange.ReleaseVersion != null)
                {
                    newChange.ReleaseVersion = new VersionRef(versionController, newVersionRef.RelativeFilePath, newVersionRef.VersionName);
                }

                if (oldChange.AdditionalData != null)
                {
                    newChange.AdditionalData = (JObject)oldChange.AdditionalData.DeepClone();
                }

                version.Changes.Add(newChangeRef);
                versionController.CacheChange(newChange);
            }

            versionController.CacheVersion(version);
        }
        private void NewChangeButtonPressed(object sender, RoutedEventArgs args)
        {
            Version           version           = openVersionRef.GetVersion().Result;
            VersionController versionController = MainWindow.GetInstance().VersionController;

            string    guid         = Guid.NewGuid().ToString();
            string    relativePath = Path.Combine(version.VersionName, "changes", $"{guid}.json");
            ChangeRef changeRef    = new ChangeRef(versionController, guid, relativePath);

            version.Changes.Insert(0, changeRef);

            Change change = new Change(versionController, guid, relativePath, "New Change", string.Empty, openVersionRef);

            change.ReleaseVersion = new VersionRef(versionController, openVersionRef.RelativeFilePath, openVersionRef.VersionName);
            versionController.CacheChange(change);

            ChangeControl newControl = new ChangeControl(changeRef);

            ChangeParent.Children.Insert(0, newControl);

            ContentArea.GetInstance().OpenPage(ContentArea.PageType.Change, openVersionRef, changeRef);
        }