Пример #1
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);
        }
Пример #2
0
        public void SetSynchronousContext(int contextHandle, IExecutable executableObject)
        {
            if (contextHandle == 0)
            {
                return;
            }

            var context = _registeredContexts[contextHandle];

            if (context.SuppressSynchronousContext)
            {
                return;
            }

            try {
                var mask         = executableObject.Mask;
                var plugInData   = executableObject.PlugInData;
                var nativeHelper = FileIOHelper.GetNativeHelper();

                if (!context.LocalRequestor && !executableObject.TreatAsLocal)
                {
                    Profile profile;
                    var     str = _preferences.GetString("SynchronousData");
                    if (str == "Default")
                    {
                        var str2 = _preferences.GetString("DefaultProfile");

                        if (str2 == string.Empty)
                        {
                            LogError("SetSynchronousContext",
                                     "Preference set to use default profile for synchronous execution, but no default profile set.");
                            mask       = null;
                            plugInData = null;
                        }
                        else
                        {
                            profile = nativeHelper.OpenProfile(Path.Combine(Paths.ProfilePath, str2 + ".pro"));
                            profile.Freeze();
                            mask       = profile.Mask;
                            plugInData = profile.PlugInData;
                        }
                    }
                    else if (str != "Embedded")
                    {
                        profile = nativeHelper.OpenProfile(Path.Combine(Paths.ProfilePath, str + ".pro"));
                        profile.Freeze();
                        mask       = profile.Mask;
                        plugInData = profile.PlugInData;
                    }
                }
                context.Object      = executableObject;
                context.Object.Mask = mask;
                if (plugInData != null)
                {
                    context.Object.PlugInData.ReplaceRoot(plugInData.RootNode);
                }
                if (!(context.SuppressAsynchronousContext || _preferences.GetString("AsynchronousData") != "Sync"))
                {
                    AsyncInit(context);
                }
                if (executableObject.AudioDeviceIndex != -1)
                {
                    context.SynchronousEngineInstance.SetAudioDevice(executableObject.AudioDeviceIndex);
                }
                if (executableObject.AudioDeviceVolume != 0)
                {
                    context.SynchronousEngineInstance.SetAudioDevice(executableObject.AudioDeviceIndex);
                }
            }
            catch (Exception exception) {
                LogError("SetSynchronousContext", exception);
            }
        }
Пример #3
0
 public int RequestContext(bool suppressAsynchronousContext, bool suppressSynchronousContext, Form keyInterceptor)
 {
     try {
         var num     = ((int)DateTime.Now.ToBinary()) + _registeredContexts.Count;
         var context = new ExecutionContext
         {
             SuppressAsynchronousContext = suppressAsynchronousContext, SuppressSynchronousContext = suppressSynchronousContext
         };
         var integer = _preferences.GetInteger("SoundDevice");
         context.SynchronousEngineInstance  = context.SuppressSynchronousContext ? null : new Engine8(_host, integer);
         context.AsynchronousEngineInstance = context.SuppressAsynchronousContext
             ? null : new Engine8(Engine8.EngineMode.Asynchronous, _host, integer);
         context.LocalRequestor = RequestorIsLocal(new StackTrace().GetFrame(1));
         context.Object         = null;
         context.KeyInterceptor = keyInterceptor;
         if (!context.SuppressAsynchronousContext)
         {
             byte[][]  mask;
             SetupData plugInData;
             var       str     = _preferences.GetString("AsynchronousData");
             var       str2    = ((str != "Default") && (str != "Sync")) ? str : _preferences.GetString("DefaultProfile");
             Profile   profile = null;
             if (str2.Length > 0)
             {
                 try {
                     var nativeIO = FileIOHelper.GetNativeHelper();
                     profile = nativeIO.OpenProfile(Path.Combine(Paths.ProfilePath, str2 + ".pro"));
                     profile.Freeze();
                 }
                 catch {
                     LogError("RequestContext", "Error loading profile " + str2);
                 }
             }
             if (profile == null)
             {
                 if (str == "Default")
                 {
                     LogError("RequestContext",
                              "Preference set to use default profile for asynchronous execution, but no default profile exists.");
                 }
                 mask       = null;
                 plugInData = null;
             }
             else
             {
                 mask           = profile.Mask;
                 plugInData     = profile.PlugInData;
                 context.Object = profile;
             }
             if (context.Object != null)
             {
                 context.Object.Mask = mask;
                 if (plugInData != null)
                 {
                     context.Object.PlugInData.ReplaceRoot(plugInData.RootNode);
                 }
                 AsyncInit(context);
             }
         }
         _registeredContexts[num] = context;
         return(num);
     }
     catch (Exception exception) {
         LogError("RequestContext", exception);
         return(0);
     }
 }