Esempio n. 1
0
        private void FileMenu_SaveCurrent_Click(object sender, RoutedEventArgs e)
        {
            if (GlobalState.CurrentExportFormatName == null)
            {
                GlobalState.CurrentExportFormatName = "TrackMaker.ExportXMLv2";
            }

            Type EXType = Type.GetType(GlobalState.CurrentExportFormatName);

            IExportFormat IEXF = (IExportFormat)Activator.CreateInstance(EXType);

            IEXF.Export(CurrentProject);

            //refactoring probably needed

            string CurrentlyOpenFile = GlobalState.GetCurrentOpenFile();

            if (CurrentlyOpenFile == null || CurrentlyOpenFile == "")
            {
                Error.Throw("Error!", "Failed to set currently open file!", ErrorSeverity.Error, 231);
                return;
            }

            Title = $"Track Maker 2.1 - [{GlobalState.GetCurrentOpenFile()}]";
        }
Esempio n. 2
0
        /// <summary>
        /// Method name: RunIEX()
        ///
        /// Runs the import/export (Version 515)
        /// </summary>
        private bool RunIEX()
        {
            // Old code - dano move when we can do easy previews due to multitab
            // Stop the ticktimer while importing or exporting because we need to do this stuff.
            MnWindow.TickTimer.Stop();

            switch (Type)
            {
            case FormatType.Import:
                ImportResult IResult = ExpFormat.Import();

                switch (IResult.Status)
                {
                case ExportResults.Cancelled:
                    MnWindow.TickTimer.Start();
                    return(true);

                case ExportResults.Error:
                    MnWindow.TickTimer.Start();
                    return(false);

                case ExportResults.OK:
                    if (IResult.Project.FileName == null)
                    {
                        Error.Throw("Fatal Error!", "Failed to set current file name", ErrorSeverity.Error, 190);
                        return(false);        // possibly extend subsequent else
                    }
                    else
                    {
                        GlobalState.SetCurrentOpenFile(IResult.Project.FileName);
                    }

                    //may bindings work?
                    MnWindow.Title = $"Track Maker 2.0 - {GlobalState.GetCurrentOpenFile()}";

                    // we are not setting current project before, usually you wouldn't need to do this hack
                    MnWindow.CurrentProject = IResult.Project;

                    MnWindow.TickTimer.Start();
                    MnWindow.UpdateLayout();


                    return(true);
                }
                // this shouldn't run
                return(true);

            case FormatType.Export:

                if (ExpFormat is IImageExportFormat)
                {
                    IImageExportFormat IIEF = (IImageExportFormat)ExpFormat;

                    // surely allowing (bool == bool?) would be more intuitive for users
                    bool IsFullQuality    = (bool)QualityControl.QualityControl_FullQuality.IsChecked;
                    bool IsHalfQuality    = (bool)QualityControl.QualityControl_HalfQuality.IsChecked;
                    bool IsQuarterQuality = (bool)QualityControl.QualityControl_QuarterQuality.IsChecked;
                    bool IsEighthQuality  = (bool)QualityControl.QualityControl_EighthQuality.IsChecked;

                    if (IsFullQuality)
                    {
                        IIEF.Quality = ImageQuality.Full;
                    }
                    if (IsHalfQuality)
                    {
                        IIEF.Quality = ImageQuality.Half;
                    }
                    if (IsQuarterQuality)
                    {
                        IIEF.Quality = ImageQuality.Quarter;
                    }
                    if (IsEighthQuality)
                    {
                        IIEF.Quality = ImageQuality.Eighth;
                    }

                    // need to make this priscilla-specific
                    return(ExpFormat.Export(MnWindow.CurrentProject));
                }
                else
                {
                    ExpFormat.Export(MnWindow.CurrentProject);
                }

                // wish VS allowed the same var names under different code paths
                Project CurProject = MnWindow.CurrentProject;

                if (CurProject.FileName != null && CurProject.FileName != "")
                {
                    MnWindow.Title = $"Track Maker 2.0 - {CurProject.FileName}";
                }
                MnWindow.UpdateLayout();
                MnWindow.TickTimer.Start();


                Close();
                return(true);
            }

            return(false);
        }