예제 #1
0
        public void propertyGrid_PropertyValueChanged(Object s, PropertyValueChangedEventArgs e)
        {
            AppManager.mMainWindow.setPrograssBarVisible(true);
            AppManager.mMainWindow.setPrograssBarName("应用属性");
            Object[] selobj = propertyGrid.SelectedObjects;
            int      len    = selobj.Length;

            AppManager.mMainWindow.setPrograssBarMaxium(len);
            AppManager.mMainWindow.setPrograssBarValue(0);

            VsqEvent[] items = new VsqEvent[len];
            for (int i = 0; i < len; i++)
            {
                SelectedEventEntry proxy = (SelectedEventEntry)selobj[i];
                items[i] = proxy.editing;
                Application.DoEvents();
            }
            CadenciiCommand run = new CadenciiCommand(VsqCommand.generateCommandEventReplaceRange(m_track, items));

            if (CommandExecuteRequired != null)
            {
                CommandExecuteRequired(this, run);
            }
            for (int i = 0; i < len; i++)
            {
                AppManager.itemSelection.addEvent(items[i].InternalID);
                AppManager.mMainWindow.setPrograssBarValue(i);
                Application.DoEvents();
            }
            propertyGrid.Refresh();
            setEditing(false);
            AppManager.mMainWindow.setPrograssBarVisible(false);
        }
예제 #2
0
 /// <summary>
 /// パレットツールを実行します
 /// </summary>
 /// <param name="id">実行するパレットツールのID</param>
 /// <param name="track">編集対象のトラック番号</param>
 /// <param name="vsq_event_intrenal_ids">編集対象のInternalIDのリスト</param>
 /// <param name="button">パレットツールが押し下げられた時のマウスボタンの種類</param>
 /// <returns>パレットツールによって編集が加えられた場合true。そうでなければfalse(パレットツールがエラーを起こした場合も含む)。</returns>
 public static boolean invokePaletteTool( String id, int track, int[] vsq_event_intrenal_ids, MouseButtons button ) {
     if ( loadedTools.containsKey( id ) ) {
         VsqFileEx vsq = AppManager.getVsqFile();
         VsqTrack item = (VsqTrack)vsq.Track.get( track ).clone();
         Object objPal = loadedTools.get( id );
         if ( objPal == null ) {
             return false;
         }
         if ( !(objPal is IPaletteTool) ) {
             return false;
         }
         IPaletteTool pal = (IPaletteTool)objPal;
         boolean edited = false;
         try {
             edited = pal.edit( item, vsq_event_intrenal_ids, button );
         } catch ( Exception ex ) {
             AppManager.showMessageBox(
                 PortUtil.formatMessage( _( "Palette tool '{0}' reported an error.\nPlease copy the exception text and report it to developper." ), id ),
                 "Error",
                 cadencii.windows.forms.Utility.MSGBOX_DEFAULT_OPTION,
                 cadencii.windows.forms.Utility.MSGBOX_ERROR_MESSAGE );
             serr.println( typeof( PaletteToolServer ) + ".invokePaletteTool; ex=" + ex );
             edited = false;
         }
         if ( edited ) {
             CadenciiCommand run = VsqFileEx.generateCommandTrackReplace( track, item, vsq.AttachedCurves.get( track - 1 ) );
             AppManager.editHistory.register( vsq.executeCommand( run ) );
         }
         return edited;
     } else {
         return false;
     }
 }
예제 #3
0
        /// <summary>
        /// スクリプトを実行します。
        /// </summary>
        /// <param name="evsd"></param>
        public static boolean invokeScript(String id, VsqFileEx vsq)
        {
            ScriptInvoker script_invoker = null;

            if (scripts.containsKey(id))
            {
                script_invoker = scripts.get(id);
            }
            else
            {
                return(false);
            }
            if (script_invoker != null && script_invoker.scriptDelegate != null)
            {
                try {
                    VsqFileEx          work = (VsqFileEx)vsq.clone();
                    ScriptReturnStatus ret  = ScriptReturnStatus.ERROR;
                    if (script_invoker.scriptDelegate is EditVsqScriptDelegate)
                    {
                        boolean b_ret = ((EditVsqScriptDelegate)script_invoker.scriptDelegate).Invoke(work);
                        if (b_ret)
                        {
                            ret = ScriptReturnStatus.EDITED;
                        }
                        else
                        {
                            ret = ScriptReturnStatus.ERROR;
                        }
                    }
                    else if (script_invoker.scriptDelegate is EditVsqScriptDelegateEx)
                    {
                        boolean b_ret = ((EditVsqScriptDelegateEx)script_invoker.scriptDelegate).Invoke(work);
                        if (b_ret)
                        {
                            ret = ScriptReturnStatus.EDITED;
                        }
                        else
                        {
                            ret = ScriptReturnStatus.ERROR;
                        }
                    }
                    else if (script_invoker.scriptDelegate is EditVsqScriptDelegateWithStatus)
                    {
                        ret = ((EditVsqScriptDelegateWithStatus)script_invoker.scriptDelegate).Invoke(work);
                    }
                    else if (script_invoker.scriptDelegate is EditVsqScriptDelegateExWithStatus)
                    {
                        ret = ((EditVsqScriptDelegateExWithStatus)script_invoker.scriptDelegate).Invoke(work);
                    }
                    else
                    {
                        ret = ScriptReturnStatus.ERROR;
                    }
                    if (ret == ScriptReturnStatus.ERROR)
                    {
                        AppManager.showMessageBox(_("Script aborted"), "Cadencii", cadencii.windows.forms.Utility.MSGBOX_DEFAULT_OPTION, cadencii.windows.forms.Utility.MSGBOX_INFORMATION_MESSAGE);
                    }
                    else if (ret == ScriptReturnStatus.EDITED)
                    {
                        CadenciiCommand run = VsqFileEx.generateCommandReplace(work);
                        AppManager.editHistory.register(vsq.executeCommand(run));
                    }
                    String           config_file          = configFileNameFromScriptFileName(script_invoker.ScriptFile);
                    FileOutputStream fs                   = null;
                    boolean          delete_xml_when_exit = false; // xmlを消すときtrue
                    try {
                        fs = new FileOutputStream(config_file);
                        script_invoker.Serializer.serialize(fs, null);
                    } catch (Exception ex) {
                        serr.println("AppManager#invokeScript; ex=" + ex);
                        delete_xml_when_exit = true;
                    } finally {
                        if (fs != null)
                        {
                            try {
                                fs.close();
                                if (delete_xml_when_exit)
                                {
                                    PortUtil.deleteFile(config_file);
                                }
                            } catch (Exception ex2) {
                                serr.println("AppManager#invokeScript; ex2=" + ex2);
                            }
                        }
                    }
                    return(ret == ScriptReturnStatus.EDITED);
                } catch (Exception ex) {
                    AppManager.showMessageBox(_("Script runtime error:") + " " + ex, _("Error"), cadencii.windows.forms.Utility.MSGBOX_DEFAULT_OPTION, cadencii.windows.forms.Utility.MSGBOX_INFORMATION_MESSAGE);
                    serr.println("AppManager#invokeScript; ex=" + ex);
                }
            }
            else
            {
                AppManager.showMessageBox(_("Script compilation failed."), _("Error"), cadencii.windows.forms.Utility.MSGBOX_DEFAULT_OPTION, cadencii.windows.forms.Utility.MSGBOX_WARNING_MESSAGE);
            }
            return(false);
        }
        private void applyValue(bool mode_clock)
        {
            if (!m_changed)
            {
                return;
            }
            int value = m_curve.getDefault();

            try {
                value = int.Parse(txtDataPointValue.Text);
            } catch (Exception ex) {
                Logger.write(typeof(FormCurvePointEdit) + ".applyValue; ex=" + ex + "\n");
                return;
            }
            if (value < m_curve.getMinimum())
            {
                value = m_curve.getMinimum();
            }
            else if (m_curve.getMaximum() < value)
            {
                value = m_curve.getMaximum();
            }

            int clock = 0;

            try {
                clock = int.Parse(txtDataPointClock.Text);
            } catch (Exception ex) {
                Logger.write(typeof(FormCurvePointEdit) + ".applyValue; ex=" + ex + "\n");
                return;
            }

            int       selected  = AppManager.getSelected();
            VsqTrack  vsq_track = AppManager.getVsqFile().Track[selected];
            VsqBPList src       = vsq_track.getCurve(m_curve.getName());
            VsqBPList list      = (VsqBPList)src.clone();

            VsqBPPairSearchContext context = list.findElement(m_editing_id);

            list.move(context.clock, clock, value);
            CadenciiCommand run = new CadenciiCommand(VsqCommand.generateCommandTrackCurveReplace(selected,
                                                                                                  m_curve.getName(),
                                                                                                  list));
            EditedZone zone = new EditedZone();

            Utility.compareList(zone, new VsqBPListComparisonContext(list, src));
            List <EditedZoneUnit> zoneUnits = new List <EditedZoneUnit>();

            foreach (var item in zone.iterator())
            {
                zoneUnits.Add(item);
            }
            AppManager.editHistory.register(AppManager.getVsqFile().executeCommand(run));

            txtDataPointClock.Text = clock + "";
            txtDataPointValue.Text = value + "";

            if (mMainWindow != null)
            {
                mMainWindow.setEdited(true);
                mMainWindow.ensureVisible(clock);
                mMainWindow.refreshScreen();
            }

            if (mode_clock)
            {
                txtDataPointClock.SelectAll();
            }
            else
            {
                txtDataPointValue.SelectAll();
            }

            btnUndo.Enabled = AppManager.editHistory.hasUndoHistory();
            btnRedo.Enabled = AppManager.editHistory.hasRedoHistory();
            m_changed       = false;
        }