示例#1
0
        private bool RegisterFileType(string fileExtension, IUIPlugIn inputPlugin)
        {
            IUIPlugIn plugInInterface;

            fileExtension = fileExtension.ToLower();
            if (_registeredFileTypes.TryGetValue(fileExtension, out plugInInterface))
            {
                return(false);
            }
            _registeredFileTypes[fileExtension] = inputPlugin;
            return(true);
        }
示例#2
0
        private void ChangeSequenceName(IUIPlugIn pluginInstance, string newName)
        {
            var fileExt = pluginInstance.Sequence.FileIOHandler.FileExtension();

            if (!newName.EndsWith(fileExt))
            {
                newName = newName + fileExt;
            }
            pluginInstance.Sequence.Name = newName;
            saveToolStripMenuItem.Text   = string.Format("Save ({0})", pluginInstance.Sequence.Name);
            ((Form)pluginInstance).Text  = pluginInstance.Sequence.Name + " - " + pluginInstance.Sequence.FileIOHandler.Name();
        }
示例#3
0
        private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var plugIns = new IUIPlugIn[_registeredFileTypes.Values.Count];

            _registeredFileTypes.Values.CopyTo(plugIns, 0);
            using (var preferencesDialog = new PreferencesDialog()) {
                if (preferencesDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                _preferences.Reload();
                NotifyAll(Notification.PreferenceChange);
            }
        }
示例#4
0
        private DialogResult CheckDirty(IUIPlugIn pluginInstance)
        {
            var none = DialogResult.None;

            if (!pluginInstance.IsDirty)
            {
                return(none);
            }
            var str = pluginInstance.Sequence.Name ?? "this unnamed sequence";

            none = MessageBox.Show(string.Format("Save changes to {0}?", str), Vendor.ProductName,
                                   MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            if (none == DialogResult.Yes)
            {
                Save(pluginInstance);
            }
            return(none);
        }
示例#5
0
        /// <summary>
        /// Save the file, routed to the appropriate plugin
        /// </summary>
        /// <param name="pluginInstance"></param>
        /// <returns>If a save action was performed</returns>
        private bool Save(IUIPlugIn pluginInstance)
        {
            if (pluginInstance == null)
            {
                return(false);
            }

            var plugInInterface = pluginInstance;

            if ((plugInInterface.IsDirty && string.IsNullOrEmpty(plugInInterface.Sequence.Name)) && !GetNewSequenceInfo(pluginInstance))
            {
                return(false);
            }

            UpdateHistoryImages(plugInInterface.Sequence.FileName);

            // If the sequenceType is not set, set it to Vixen Plus
            if (plugInInterface.Sequence.FileIOHandler == null)
            {
                // this should never be true, if it is we don't want to blow up, but notify and continue.
                MessageBox.Show("Interesting!",
                                "You should never see this, but if you do, I didn't want to blow up on you\n" + "Let Macebobo on Diychristmas.org know, please.\n" +
                                "I'm going to set your sequence file handler type to Vixen Plus - he'll know what that means\n" + "And I can continue gracefully.\n" +
                                "Sorry about that! Carry on.");
                plugInInterface.Sequence.FileIOHandler = FileIOHelper.GetNativeHelper();
            }

            plugInInterface.SaveTo();

            if (plugInInterface.Sequence.FileIOHandler.CanOpen())
            {
                AddToFileHistory(plugInInterface.Sequence.FileName);
            }

            if (_preferences.GetBoolean("ShowSaveConfirmation"))
            {
                MessageBox.Show(Resources.VixenPlusForm_SequenceSaved, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

            return(true);
        }
示例#6
0
 private bool SaveAs(IUIPlugIn pluginInstance)
 {
     return(GetNewSequenceInfo(pluginInstance) && Save(pluginInstance));
 }
示例#7
0
        private bool GetNewSequenceInfo(IUIPlugIn pluginInstance)
        {
            var saveFilters        = FileIOHelper.GetSaveFilters();
            var filters            = saveFilters.Split('|');
            var currentFilter      = pluginInstance.Sequence.FileIOHandler.DialogFilterList();
            var currentFilterIndex = int.MinValue;

            for (var i = 0; i < filters.Count(); i += 2)
            {
                if (!currentFilter.StartsWith(filters[i]))
                {
                    continue;
                }
                currentFilterIndex = i / 2;
                break;
            }

            saveFileDialog1.Filter           = saveFilters;
            saveFileDialog1.FilterIndex      = currentFilterIndex == int.MinValue ? 0 : currentFilterIndex;
            saveFileDialog1.InitialDirectory = Paths.SequencePath;
            saveFileDialog1.FileName         = String.IsNullOrEmpty(pluginInstance.Sequence.FileName) ? string.Empty : Path.GetFileNameWithoutExtension(pluginInstance.Sequence.FileName);
            saveFileDialog1.AddExtension     = true;
            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            var newFilterIndex = saveFileDialog1.FilterIndex - 1;

            // Okay format changed...
            if (currentFilterIndex != newFilterIndex)
            {
                var newFileIOHandler = FileIOHelper.GetHelperByName(filters[newFilterIndex * 2]);

                // Since Vixen+ is native, it has the lowest filter index of any of the list
                // Other file formats will be higher and thus may lose data or functionality when down versioning
                // or cross sequence formatting.  In some cases it won't matter, in other it will be very important.
                if (newFilterIndex > currentFilterIndex)
                {
                    if (
                        MessageBox.Show(
                            string.Format("{0}\n\nOld Format: {1}\nNewFormat: {2}\n\n{3}\n\n{4}\n\n{5}",
                                          "WARNING! A possible loss of data may occur from this change!",
                                          pluginInstance.Sequence.FileIOHandler.Name(),
                                          newFileIOHandler.Name(),
                                          "This will impact your sequence and " + ((pluginInstance.Sequence.Profile == null ? "embedded" : "attached") + " profile"),
                                          "Proceed with saving in this format?",
                                          "In other words, press OK if you have a backup.")
                            , "Possible loss of data!",
                            MessageBoxButtons.OKCancel,
                            MessageBoxIcon.Warning,
                            MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }

                //Okay they want the change, get the new handler and make it so

                pluginInstance.Sequence.FileIOHandler = newFileIOHandler; // this automatically handles embedded data

                // he we handle profiles.
                if (pluginInstance.Sequence.Profile != null)
                {
                    pluginInstance.Sequence.Profile.FileIOHandler = newFileIOHandler;
                    if (newFileIOHandler.SupportsProfiles)
                    {
                        newFileIOHandler.SaveProfile(pluginInstance.Sequence.Profile);
                    }
                }
            }

            ChangeSequenceName(pluginInstance, saveFileDialog1.FileName);

            return(true);
        }
示例#8
0
        /// <summary>
        /// Save the file, routed to the appropriate plugin
        /// </summary>
        /// <param name="pluginInstance"></param>
        /// <returns>If a save action was performed</returns>
        private bool Save(IUIPlugIn pluginInstance)
        {
            if (pluginInstance == null) {
                return false;
            }

            var plugInInterface = pluginInstance;
            if ((plugInInterface.IsDirty && string.IsNullOrEmpty(plugInInterface.Sequence.Name)) && !GetNewSequenceInfo(pluginInstance)) {
                return false;
            }

            UpdateHistoryImages(plugInInterface.Sequence.FileName);

            // If the sequenceType is not set, set it to Vixen Plus
            if (plugInInterface.Sequence.FileIOHandler == null) {
                // this should never be true, if it is we don't want to blow up, but notify and continue.
                MessageBox.Show("Interesting!",
                    "You should never see this, but if you do, I didn't want to blow up on you\n" + "Let Macebobo on Diychristmas.org know, please.\n" +
                    "I'm going to set your sequence file handler type to Vixen Plus - he'll know what that means\n" + "And I can continue gracefully.\n"+
                    "Sorry about that! Carry on.");
                plugInInterface.Sequence.FileIOHandler = FileIOHelper.GetNativeHelper();
            }

            plugInInterface.SaveTo();

            if (plugInInterface.Sequence.FileIOHandler.CanOpen()) {
                AddToFileHistory(plugInInterface.Sequence.FileName);
            }

            if (_preferences.GetBoolean("ShowSaveConfirmation")) {
                MessageBox.Show(Resources.VixenPlusForm_SequenceSaved, Vendor.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }

            return true;
        }
示例#9
0
 private bool SaveAs(IUIPlugIn pluginInstance)
 {
     return (GetNewSequenceInfo(pluginInstance) && Save(pluginInstance));
 }
示例#10
0
 private bool RegisterFileType(string fileExtension, IUIPlugIn inputPlugin)
 {
     IUIPlugIn plugInInterface;
     fileExtension = fileExtension.ToLower();
     if (_registeredFileTypes.TryGetValue(fileExtension, out plugInInterface)) {
         return false;
     }
     _registeredFileTypes[fileExtension] = inputPlugin;
     return true;
 }
示例#11
0
        private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var plugIns = new IUIPlugIn[_registeredFileTypes.Values.Count];
            _registeredFileTypes.Values.CopyTo(plugIns, 0);
            using (var preferencesDialog = new PreferencesDialog()) {
                if (preferencesDialog.ShowDialog() != DialogResult.OK) {
                    return;
                }

                _preferences.Reload();
                NotifyAll(Notification.PreferenceChange);
            }
        }
示例#12
0
        private bool GetNewSequenceInfo(IUIPlugIn pluginInstance)
        {
            var saveFilters = FileIOHelper.GetSaveFilters();
            var filters = saveFilters.Split('|');
            var currentFilter = pluginInstance.Sequence.FileIOHandler.DialogFilterList();
            var currentFilterIndex = int.MinValue;
            for (var i = 0; i < filters.Count(); i += 2) {
                if (!currentFilter.StartsWith(filters[i])) {
                    continue;
                }
                currentFilterIndex = i / 2;
                break;
            }

            saveFileDialog1.Filter = saveFilters;
            saveFileDialog1.FilterIndex = currentFilterIndex == int.MinValue ? 0 : currentFilterIndex;
            saveFileDialog1.InitialDirectory = Paths.SequencePath;
            saveFileDialog1.FileName = String.IsNullOrEmpty(pluginInstance.Sequence.FileName) ? string.Empty : Path.GetFileNameWithoutExtension(pluginInstance.Sequence.FileName);
            saveFileDialog1.AddExtension = true;
            if (saveFileDialog1.ShowDialog() != DialogResult.OK) {
                return false;
            }

            var newFilterIndex = saveFileDialog1.FilterIndex - 1;

            // Okay format changed...
            if (currentFilterIndex != newFilterIndex) {

                var newFileIOHandler = FileIOHelper.GetHelperByName(filters[newFilterIndex * 2]);

                // Since Vixen+ is native, it has the lowest filter index of any of the list
                // Other file formats will be higher and thus may lose data or functionality when down versioning
                // or cross sequence formatting.  In some cases it won't matter, in other it will be very important.
                if (newFilterIndex > currentFilterIndex) {
                    if (
                        MessageBox.Show(
                            string.Format("{0}\n\nOld Format: {1}\nNewFormat: {2}\n\n{3}\n\n{4}\n\n{5}",
                                "WARNING! A possible loss of data may occur from this change!",
                                pluginInstance.Sequence.FileIOHandler.Name(),
                                newFileIOHandler.Name(),
                                "This will impact your sequence and " + ((pluginInstance.Sequence.Profile == null ? "embedded" : "attached") + " profile"),
                                "Proceed with saving in this format?",
                                "In other words, press OK if you have a backup.")
                        , "Possible loss of data!",
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Warning,
                        MessageBoxDefaultButton.Button2) == DialogResult.Cancel)
                    {

                        return false;
                    }
                }

                //Okay they want the change, get the new handler and make it so

                pluginInstance.Sequence.FileIOHandler = newFileIOHandler; // this automatically handles embedded data

                // he we handle profiles.
                if (pluginInstance.Sequence.Profile != null) {
                    pluginInstance.Sequence.Profile.FileIOHandler = newFileIOHandler;
                    if (newFileIOHandler.SupportsProfiles) {
                        newFileIOHandler.SaveProfile(pluginInstance.Sequence.Profile);
                    }
                }
            }

            ChangeSequenceName(pluginInstance, saveFileDialog1.FileName);

            return true;
        }
示例#13
0
 private DialogResult CheckDirty(IUIPlugIn pluginInstance)
 {
     var none = DialogResult.None;
     if (!pluginInstance.IsDirty) {
         return none;
     }
     var str = pluginInstance.Sequence.Name ?? "this unnamed sequence";
     none = MessageBox.Show(string.Format("Save changes to {0}?", str), Vendor.ProductName,
         MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
     if (none == DialogResult.Yes) {
         Save(pluginInstance);
     }
     return none;
 }
示例#14
0
 private void ChangeSequenceName(IUIPlugIn pluginInstance, string newName)
 {
     var fileExt = pluginInstance.Sequence.FileIOHandler.FileExtension();
     if (!newName.EndsWith(fileExt)) {
         newName = newName + fileExt;
     }
     pluginInstance.Sequence.Name = newName;
     saveToolStripMenuItem.Text = string.Format("Save ({0})", pluginInstance.Sequence.Name);
     ((Form) pluginInstance).Text = pluginInstance.Sequence.Name + " - " + pluginInstance.Sequence.FileIOHandler.Name();
 }