I have a method where I want to copy the contents of one object to another so modifying one won't change the other. So as discussed here I need to clone the two objects: Clone two objects.
But my problem is the LightningChartUltimate class is from a dll. And I can't make it implement IClonable. Can anyone tell me what my options are to create a copy of the chart so any changes to the new object won't affect the chart?
public void SaveImage(string fileName,
                      TargetImageFormat imgFormat,
                      double width, double height, double fontscale,
                      bool launchExplorerAfterSave,LightningChartUltimate chart)
{
    double originalMarkerFontSize = 0;
    try
    {
        if (File.Exists(fileName))
            File.Delete(fileName);
        TargetImageFormat imageFormat = imgFormat;
        BitmapAntialiasOptions option = new BitmapAntialiasOptions();
        option.ActualPixelWeight = 1;
        option.ResolutionDivider = 1;
        option.BlurRadius = 0;
        LightningChartUltimate TempChart = new LightningChartUltimate();
        TempChart = chart; //THE PROBLEM IS IF I UPDATE TempChart IT INTERNALLY AFFECTS chart object. AND chart is being used at so many other places.
        originalMarkerFontSize = m_ChartFontForSeriesEventMarker.Size;
        TempChart.Title.Font.Size = TempChart.Title.Font.Size * fontscale;
        TempChart.ViewXY.XAxes[0].Title.Font.Size = TempChart.ViewXY.XAxes[0].Title.Font.Size * fontscale;
        TempChart.ViewXY.YAxes[0].Title.Font.Size = TempChart.ViewXY.YAxes[0].Title.Font.Size * fontscale;
        TempChart.ViewXY.XAxes[0].LabelsFont.Size = TempChart.ViewXY.XAxes[0].LabelsFont.Size * fontscale;
        TempChart.ViewXY.YAxes[0].LabelsFont.Size = TempChart.ViewXY.YAxes[0].LabelsFont.Size * fontscale;
        TempChart.ViewXY.LegendBoxes[0].SeriesTitleFont.Size *= fontscale;
        SeriesEventMarker marker = new SeriesEventMarker();
        marker.Label.Font.Size = m_ChartFontForSeriesEventMarker.Size * fontscale;
        TempChart.Width = width;
        TempChart.Height = height;
        using (FileStream stream = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write))
        {
            TempChart.SaveToStream(stream, imageFormat, option,
                    Convert.ToInt32(width), Convert.ToInt32(height));
                    //chart.SaveToFile(string.Format("{0}.{1}",fileName,imgFormat.ToLower()), option, (int)imageSaveSize.Width, (int)imageSaveSize.Height);
        }
    }
    catch (Exception exception)
    {
        SystemDebugLogLogger.LogError(exception, "LightningChartUserControl:Error in SaveImage");
        throw exception;
    }
    finally
    {
        m_ChartFontForSeriesEventMarker.Size = originalMarkerFontSize;
    }
}
 
    