/// <summary>
        /// 選択中のアイテムが編集された場合、編集にあわせてオブジェクトを更新する。
        /// </summary>
        public void updateSelectedEventInstance()
        {
            VsqFileEx vsq = AppManager.getVsqFile();

            if (vsq == null)
            {
                return;
            }
            int      selected  = AppManager.getSelected();
            VsqTrack vsq_track = vsq.Track[selected];

            for (int i = 0; i < mEvents.Count; i++)
            {
                SelectedEventEntry item = mEvents[i];
                VsqEvent           ev   = null;
                if (item.track == selected)
                {
                    int internal_id = item.original.InternalID;
                    ev = vsq_track.findEventFromID(internal_id);
                }
                if (ev != null)
                {
                    mEvents[i] = new SelectedEventEntry(selected, ev, (VsqEvent)ev.clone());
                }
                else
                {
                    mEvents.RemoveAt(i);
                    i--;
                }
            }
        }
        public void removeEventRange(int[] ids)
        {
            List <int> v_ids = new List <int>(PortUtil.convertIntArray(ids));
            List <int> index = new List <int>();
            int        count = mEvents.Count;

            for (int i = 0; i < count; i++)
            {
                if (v_ids.Contains(mEvents[i].original.InternalID))
                {
                    index.Add(i);
                    if (index.Count == ids.Length)
                    {
                        break;
                    }
                }
            }
            count = index.Count;
            for (int i = count - 1; i >= 0; i--)
            {
                mEvents.RemoveAt(i);
            }
#if ENABLE_PROPERTY
            AppManager.propertyPanel.updateValue(AppManager.getSelected());
#endif
            checkSelectedItemExistence();
        }
        public void clearEvent()
        {
            mEvents.Clear();
#if ENABLE_PROPERTY
            AppManager.propertyPanel.updateValue(AppManager.getSelected());
#endif
            checkSelectedItemExistence();
        }
        public void handleUndoRedo_Click(Object sender, EventArgs e)
        {
            if (sender == btnUndo)
            {
                AppManager.undo();
            }
            else if (sender == btnRedo)
            {
                AppManager.redo();
            }
            else
            {
                return;
            }
            VsqFileEx vsq    = AppManager.getVsqFile();
            bool      exists = false;

            if (vsq != null)
            {
                exists = vsq.Track[AppManager.getSelected()].getCurve(m_curve.getName()).findElement(m_editing_id).index >= 0;
            }
#if DEBUG
            sout.println("FormCurvePointEdit#handleUndoRedo_Click; exists=" + exists);
#endif
            txtDataPointClock.Enabled = exists;
            txtDataPointValue.Enabled = exists;
            btnApply.Enabled          = exists;
            btnBackward.Enabled       = exists;
            btnBackward2.Enabled      = exists;
            btnBackward3.Enabled      = exists;
            btnForward.Enabled        = exists;
            btnForward2.Enabled       = exists;
            btnForward3.Enabled       = exists;

            if (exists)
            {
                AppManager.itemSelection.clearPoint();
                AppManager.itemSelection.addPoint(m_curve, m_editing_id);
            }

            if (mMainWindow != null)
            {
                mMainWindow.updateDrawObjectList();
                mMainWindow.refreshScreen();
            }
            btnUndo.Enabled = AppManager.editHistory.hasUndoHistory();
            btnRedo.Enabled = AppManager.editHistory.hasRedoHistory();
        }
        public void addEventAll(List <int> list)
        {
            clearTempo();
            clearTimesig();
            VsqEvent[] index    = new VsqEvent[list.Count];
            int        count    = 0;
            int        c        = list.Count;
            int        selected = AppManager.getSelected();

            for (Iterator <VsqEvent> itr = AppManager.getVsqFile().Track[selected].getEventIterator(); itr.hasNext();)
            {
                VsqEvent ev   = itr.next();
                int      find = -1;
                for (int i = 0; i < c; i++)
                {
                    if (list[i] == ev.InternalID)
                    {
                        find = i;
                        break;
                    }
                }
                if (0 <= find)
                {
                    index[find] = ev;
                    count++;
                }
                if (count == list.Count)
                {
                    break;
                }
            }
            for (int i = 0; i < index.Length; i++)
            {
                try
                {
                    if (!isEventContains(selected, index[i].InternalID))
                    {
                        mEvents.Add(new SelectedEventEntry(selected, index[i], (VsqEvent)index[i].clone()));
                    }
                }
                catch {; }
            }
#if ENABLE_PROPERTY
            AppManager.propertyPanel.updateValue(selected);
#endif
            checkSelectedItemExistence();
        }
        public FormBezierPointEditController(
            TrackSelector parent,
            CurveType curve_type,
            int selected_chain_id,
            int selected_point_id)
        {
            ui = (FormBezierPointEditUi) new FormBezierPointEditUiImpl(this);

            applyLanguage();
            m_parent     = parent;
            m_curve_type = curve_type;
            m_track      = AppManager.getSelected();
            m_chain_id   = selected_chain_id;
            m_point_id   = selected_point_id;
            bool               found    = false;
            VsqFileEx          vsq      = AppManager.getVsqFile();
            BezierCurves       attached = vsq.AttachedCurves.get(m_track - 1);
            List <BezierChain> chains   = attached.get(m_curve_type);

            for (int i = 0; i < chains.Count; i++)
            {
                if (chains[i].id == m_chain_id)
                {
                    found = true;
                    break;
                }
            }
            if (!found)
            {
                return;
            }
            bool smooth = false;

            foreach (var bp in attached.getBezierChain(m_curve_type, m_chain_id).points)
            {
                if (bp.getID() == m_point_id)
                {
                    m_point = bp;
                    smooth  =
                        (bp.getControlLeftType() != BezierControlType.None) ||
                        (bp.getControlRightType() != BezierControlType.None);
                    break;
                }
            }
            updateStatus();
        }
        private void removeEventCor(int id, bool silent)
        {
            int count = mEvents.Count;

            for (int i = 0; i < count; i++)
            {
                if (mEvents[i].original.InternalID == id)
                {
                    mEvents.RemoveAt(i);
                    break;
                }
            }
            if (!silent)
            {
#if ENABLE_PROPERTY
                AppManager.propertyPanel.updateValue(AppManager.getSelected());
#endif
            }
        }
        public FormCurvePointEdit(FormMain main_window, long editing_id, CurveType curve)
        {
            InitializeComponent();
            mMainWindow = main_window;
            registerEventHandlers();
            setResources();
            applyLanguage();
            m_editing_id = editing_id;
            m_curve      = curve;

            VsqBPPairSearchContext context = AppManager.getVsqFile().Track[AppManager.getSelected()].getCurve(m_curve.getName()).findElement(m_editing_id);

            txtDataPointClock.Text = context.clock + "";
            txtDataPointValue.Text = context.point.value + "";
            txtDataPointValue.SelectAll();

            btnUndo.Enabled = AppManager.editHistory.hasUndoHistory();
            btnRedo.Enabled = AppManager.editHistory.hasRedoHistory();
        }
        private void addEventCor(int id, bool silent)
        {
            clearTempo();
            clearTimesig();
            int selected = AppManager.getSelected();

            for (Iterator <VsqEvent> itr = AppManager.getVsqFile().Track[selected].getEventIterator(); itr.hasNext();)
            {
                VsqEvent ev = itr.next();
                if (ev.InternalID == id)
                {
                    if (isEventContains(selected, id))
                    {
                        // すでに選択されていた場合
                        int count = mEvents.Count;
                        for (int i = 0; i < count; i++)
                        {
                            SelectedEventEntry item = mEvents[i];
                            if (item.original.InternalID == id)
                            {
                                mEvents.RemoveAt(i);
                                break;
                            }
                        }
                    }

                    mEvents.Add(new SelectedEventEntry(selected, ev, (VsqEvent)ev.clone()));
                    if (!silent)
                    {
                        invokeSelectedEventChangedEvent(false);
                    }
                    break;
                }
            }
            if (!silent)
            {
#if ENABLE_PROPERTY
                AppManager.propertyPanel.updateValue(selected);
#endif
            }
        }
Exemple #10
0
        public void draw(Graphics2D g, int width, int height)
        {
            if (mMainForm == null)
            {
                return;
            }
            lock (AppManager.mDrawObjects) {
                g.setColor(mBackgroundColor);
                g.fillRect(0, 0, width, height);

                g.setStroke(getStroke2px());
                g.setColor(FormMain.mColorNoteFill);
                int       key_width = AppManager.keyWidth;
                int       xoffset   = key_width + AppManager.keyOffset;
                VsqFileEx vsq       = AppManager.getVsqFile();

                int overview_dot_diam = 2;

                int selected           = AppManager.getSelected();
                List <DrawObject> objs = AppManager.mDrawObjects[selected - 1];

                // 平均ノートナンバーを調べる
                double sum   = 0.0;
                int    count = 0;
                foreach (var dobj in objs)
                {
                    if (dobj.mType == DrawObjectType.Note)
                    {
                        sum += dobj.mNote;
                        count++;
                    }
                }
                float average_note = (float)(sum / (double)count);

                foreach (var dobj in objs)
                {
                    int x = (int)(dobj.mClock * mOverviewPixelPerClock);
                    if (x < 0)
                    {
                        continue;
                    }
                    if (width - key_width < x)
                    {
                        break;
                    }
                    int y      = height - (height / 2 + (int)((dobj.mNote - average_note) * overview_dot_diam));
                    int length = (int)(dobj.mLength * mOverviewPixelPerClock);
                    if (length < overview_dot_diam)
                    {
                        length = overview_dot_diam;
                    }
                    g.drawLine(x + xoffset, y, x + length + xoffset, y);
                }

                g.setStroke(getStrokeDefault());
                int current_start = AppManager.clockFromXCoord(key_width);
                int current_end   = AppManager.clockFromXCoord(mMainForm.pictPianoRoll.getWidth());
                int x_start       = (int)(current_start * mOverviewPixelPerClock);
                int x_end         = (int)(current_end * mOverviewPixelPerClock);

                // 小節ごとの線
                int clock_start = 0;
                int clock_end   = (int)(width / mOverviewPixelPerClock);
                int premeasure  = vsq.getPreMeasure();
                g.setClip(null);
                Color pen_color = new java.awt.Color(0, 0, 0, 130);

                int    barcountx   = 0;
                string barcountstr = "";
                for (Iterator <VsqBarLineType> itr = vsq.getBarLineIterator(clock_end * 3 / 2); itr.hasNext();)
                {
                    VsqBarLineType bar = itr.next();
                    if (bar.clock() < clock_start)
                    {
                        continue;
                    }
                    if (width - key_width < barcountx)
                    {
                        break;
                    }
                    if (bar.isSeparator())
                    {
                        int barcount = bar.getBarCount() - premeasure + 1;
                        int x        = (int)(bar.clock() * mOverviewPixelPerClock);
                        if ((barcount % 5 == 0 && barcount > 0) || barcount == 1)
                        {
                            g.setColor(pen_color);
                            g.setStroke(getStroke2px());
                            g.drawLine(x + xoffset, 0, x + xoffset, height);

                            g.setStroke(getStrokeDefault());
                            if (!barcountstr.Equals(""))
                            {
                                g.setColor(Color.white);
                                g.setFont(AppManager.baseFont9);
                                g.drawString(barcountstr, barcountx + 1 + xoffset, 1 + AppManager.baseFont9Height / 2 - AppManager.baseFont9OffsetHeight + 1);
                            }
                            barcountstr = barcount + "";
                            barcountx   = x;
                        }
                        else
                        {
                            g.setColor(pen_color);
                            g.drawLine(x + xoffset, 0, x + xoffset, height);
                        }
                    }
                }
                g.setClip(null);
            }
        }
Exemple #11
0
        public void showPrefs(Form Parent, System.Drawing.Point location, bool showVBCfg)
        {
            try {
                if (mDialogPreference == null)
                {
                    mDialogPreference = new Preference();
                }
                mDialogPreference.setBaseFont(new Font(AppManager.editorConfig.BaseFontName, java.awt.Font.PLAIN, AppManager.FONT_SIZE9));
                mDialogPreference.setScreenFont(new Font(AppManager.editorConfig.ScreenFontName, java.awt.Font.PLAIN, AppManager.FONT_SIZE9));
                mDialogPreference.setWheelOrder(AppManager.editorConfig.WheelOrder);
                mDialogPreference.setCursorFixed(AppManager.editorConfig.CursorFixed);
                mDialogPreference.setDefaultVibratoLength(AppManager.editorConfig.DefaultVibratoLength);
                mDialogPreference.setAutoVibratoThresholdLength(AppManager.editorConfig.AutoVibratoThresholdLength);
                mDialogPreference.setAutoVibratoType1(AppManager.editorConfig.AutoVibratoType1);
                mDialogPreference.setAutoVibratoType2(AppManager.editorConfig.AutoVibratoType2);
                mDialogPreference.setAutoVibratoTypeCustom(AppManager.editorConfig.AutoVibratoTypeCustom);
                mDialogPreference.setEnableAutoVibrato(AppManager.editorConfig.EnableAutoVibrato);
                mDialogPreference.setPreSendTime(AppManager.editorConfig.PreSendTime);
                mDialogPreference.setControlCurveResolution(AppManager.editorConfig.ControlCurveResolution);
                mDialogPreference.setDefaultSingerName(AppManager.editorConfig.DefaultSingerName);
                mDialogPreference.setScrollHorizontalOnWheel(AppManager.editorConfig.ScrollHorizontalOnWheel);
                mDialogPreference.setMaximumFrameRate(AppManager.editorConfig.MaximumFrameRate);
                mDialogPreference.setKeepLyricInputMode(AppManager.editorConfig.KeepLyricInputMode);
                mDialogPreference.setPxTrackHeight(AppManager.editorConfig.PxTrackHeight);
                mDialogPreference.setMouseHoverTime(AppManager.editorConfig.getMouseHoverTime());
                mDialogPreference.setPlayPreviewWhenRightClick(AppManager.editorConfig.PlayPreviewWhenRightClick);
                mDialogPreference.setCurveSelectingQuantized(AppManager.editorConfig.CurveSelectingQuantized);
                mDialogPreference.setCurveVisibleAccent(AppManager.editorConfig.CurveVisibleAccent);
                mDialogPreference.setCurveVisibleBre(AppManager.editorConfig.CurveVisibleBreathiness);
                mDialogPreference.setCurveVisibleBri(AppManager.editorConfig.CurveVisibleBrightness);
                mDialogPreference.setCurveVisibleCle(AppManager.editorConfig.CurveVisibleClearness);
                mDialogPreference.setCurveVisibleDecay(AppManager.editorConfig.CurveVisibleDecay);
                mDialogPreference.setCurveVisibleDyn(AppManager.editorConfig.CurveVisibleDynamics);
                mDialogPreference.setCurveVisibleGen(AppManager.editorConfig.CurveVisibleGendorfactor);
                mDialogPreference.setCurveVisibleOpe(AppManager.editorConfig.CurveVisibleOpening);
                mDialogPreference.setCurveVisiblePit(AppManager.editorConfig.CurveVisiblePit);
                mDialogPreference.setCurveVisiblePbs(AppManager.editorConfig.CurveVisiblePbs);
                mDialogPreference.setCurveVisiblePor(AppManager.editorConfig.CurveVisiblePortamento);
                mDialogPreference.setCurveVisibleVel(AppManager.editorConfig.CurveVisibleVelocity);
                mDialogPreference.setCurveVisibleVibratoDepth(AppManager.editorConfig.CurveVisibleVibratoDepth);
                mDialogPreference.setCurveVisibleVibratoRate(AppManager.editorConfig.CurveVisibleVibratoRate);
                mDialogPreference.setCurveVisibleFx2Depth(AppManager.editorConfig.CurveVisibleFx2Depth);
                mDialogPreference.setCurveVisibleHarmonics(AppManager.editorConfig.CurveVisibleHarmonics);
                mDialogPreference.setCurveVisibleReso1(AppManager.editorConfig.CurveVisibleReso1);
                mDialogPreference.setCurveVisibleReso2(AppManager.editorConfig.CurveVisibleReso2);
                mDialogPreference.setCurveVisibleReso3(AppManager.editorConfig.CurveVisibleReso3);
                mDialogPreference.setCurveVisibleReso4(AppManager.editorConfig.CurveVisibleReso4);
                mDialogPreference.setCurveVisibleEnvelope(AppManager.editorConfig.CurveVisibleEnvelope);
#if ENABLE_MIDI
                mDialogPreference.setMidiInPort(AppManager.editorConfig.MidiInPort.PortNumber);
#endif
#if ENABLE_MTC
                m_preference_dlg.setMtcMidiInPort(AppManager.editorConfig.MidiInPortMtc.PortNumber);
#endif
                Vector <String>  resamplers = new Vector <String>();
                Vector <Boolean> with_wine  = new Vector <Boolean>();
                int size = AppManager.editorConfig.getResamplerCount();
                for (int i = 0; i < size; i++)
                {
                    resamplers.add(AppManager.editorConfig.getResamplerAt(i));
                    with_wine.add(AppManager.editorConfig.isResamplerWithWineAt(i));
                }
                mDialogPreference.setResamplersConfig(resamplers, with_wine);
                mDialogPreference.setPathWavtool(AppManager.editorConfig.PathWavtool);
                mDialogPreference.setWavtoolWithWine(AppManager.editorConfig.WavtoolWithWine);
                mDialogPreference.setUtausingers(AppManager.editorConfig.UtauSingers);
                mDialogPreference.setSelfDeRomantization(AppManager.editorConfig.SelfDeRomanization);
                mDialogPreference.setAutoBackupIntervalMinutes(AppManager.editorConfig.AutoBackupIntervalMinutes);
                mDialogPreference.setUseSpaceKeyAsMiddleButtonModifier(AppManager.editorConfig.UseSpaceKeyAsMiddleButtonModifier);
                mDialogPreference.setPathAquesTone(AppManager.editorConfig.PathAquesTone);
                mDialogPreference.setPathAquesTone2(AppManager.editorConfig.PathAquesTone2);
                mDialogPreference.setUseProjectCache(AppManager.editorConfig.UseProjectCache);
                mDialogPreference.setAquesToneRequired(!AppManager.editorConfig.DoNotUseAquesTone);
                mDialogPreference.setAquesTone2Requried(!AppManager.editorConfig.DoNotUseAquesTone2);
                mDialogPreference.setVocaloid1Required(!AppManager.editorConfig.DoNotUseVocaloid1);
                mDialogPreference.setVocaloid2Required(!AppManager.editorConfig.DoNotUseVocaloid2);
                mDialogPreference.setBufferSize(AppManager.editorConfig.BufferSizeMilliSeconds);
                mDialogPreference.setDefaultSynthesizer(AppManager.editorConfig.DefaultSynthesizer);
                mDialogPreference.setUseUserDefinedAutoVibratoType(AppManager.editorConfig.UseUserDefinedAutoVibratoType);
                mDialogPreference.setWinePrefix(AppManager.editorConfig.WinePrefix);
                mDialogPreference.setWineTop(AppManager.editorConfig.WineTop);
                mDialogPreference.setWineBuiltin(AppManager.editorConfig.WineTopBuiltin);
                mDialogPreference.setEnableWideCharacterWorkaround(AppManager.editorConfig.UseWideCharacterWorkaround);

                String old_wine_prefix = AppManager.editorConfig.WinePrefix;
                String old_wine_top    = AppManager.editorConfig.getWineTop();

                mDialogPreference.Location = location;

                //Show the special voicebank config menu if it's requested
                if (showVBCfg)
                {
                    mDialogPreference.showEasySetupUtauVB();
                }

                DialogResult dr = AppManager.showModalDialog(mDialogPreference, Parent);
                if (dr == DialogResult.OK)
                {
                    String old_base_font_name = AppManager.editorConfig.BaseFontName;
                    float  old_base_font_size = AppManager.editorConfig.BaseFontSize;
                    Font   new_base_font      = mDialogPreference.getBaseFont();
                    if (!old_base_font_name.Equals(new_base_font.getName()) ||
                        old_base_font_size != new_base_font.getSize2D())
                    {
                        AppManager.editorConfig.BaseFontName = mDialogPreference.getBaseFont().getName();
                        AppManager.editorConfig.BaseFontSize = mDialogPreference.getBaseFont().getSize2D();
                        //updateMenuFonts();
                    }

                    AppManager.editorConfig.ScreenFontName = mDialogPreference.getScreenFont().getName();
                    AppManager.editorConfig.WheelOrder     = mDialogPreference.getWheelOrder();
                    AppManager.editorConfig.CursorFixed    = mDialogPreference.isCursorFixed();

                    AppManager.editorConfig.DefaultVibratoLength       = mDialogPreference.getDefaultVibratoLength();
                    AppManager.editorConfig.AutoVibratoThresholdLength = mDialogPreference.getAutoVibratoThresholdLength();
                    AppManager.editorConfig.AutoVibratoType1           = mDialogPreference.getAutoVibratoType1();
                    AppManager.editorConfig.AutoVibratoType2           = mDialogPreference.getAutoVibratoType2();
                    AppManager.editorConfig.AutoVibratoTypeCustom      = mDialogPreference.getAutoVibratoTypeCustom();

                    AppManager.editorConfig.EnableAutoVibrato = mDialogPreference.isEnableAutoVibrato();
                    AppManager.editorConfig.PreSendTime       = mDialogPreference.getPreSendTime();
                    AppManager.editorConfig.Language          = mDialogPreference.getLanguage();
                    if (!Messaging.getLanguage().Equals(AppManager.editorConfig.Language))
                    {
                        Messaging.setLanguage(AppManager.editorConfig.Language);
                        //applyLanguage();
                        mDialogPreference.applyLanguage();
                        //AppManager.mMixerWindow.applyLanguage();
                        //if (mVersionInfo != null && !mVersionInfo.IsDisposed) {
                        //    mVersionInfo.applyLanguage();
                        //}
#if ENABLE_PROPERTY
                        AppManager.propertyWindow.applyLanguage();
                        AppManager.propertyPanel.updateValue(AppManager.getSelected());
#endif
                        //if (mDialogMidiImportAndExport != null) {
                        //    mDialogMidiImportAndExport.applyLanguage();
                        //}
                    }

                    AppManager.editorConfig.ControlCurveResolution  = mDialogPreference.getControlCurveResolution();
                    AppManager.editorConfig.DefaultSingerName       = mDialogPreference.getDefaultSingerName();
                    AppManager.editorConfig.ScrollHorizontalOnWheel = mDialogPreference.isScrollHorizontalOnWheel();
                    AppManager.editorConfig.MaximumFrameRate        = mDialogPreference.getMaximumFrameRate();
                    int fps = 1000 / AppManager.editorConfig.MaximumFrameRate;
                    //timer.Interval = (fps <= 0) ? 1 : fps;
                    //applyShortcut();
                    AppManager.editorConfig.KeepLyricInputMode = mDialogPreference.isKeepLyricInputMode();
                    if (AppManager.editorConfig.PxTrackHeight != mDialogPreference.getPxTrackHeight())
                    {
                        AppManager.editorConfig.PxTrackHeight = mDialogPreference.getPxTrackHeight();
                        //updateDrawObjectList();
                    }
                    AppManager.editorConfig.setMouseHoverTime(mDialogPreference.getMouseHoverTime());
                    AppManager.editorConfig.PlayPreviewWhenRightClick = mDialogPreference.isPlayPreviewWhenRightClick();
                    AppManager.editorConfig.CurveSelectingQuantized   = mDialogPreference.isCurveSelectingQuantized();

                    AppManager.editorConfig.CurveVisibleAccent       = mDialogPreference.isCurveVisibleAccent();
                    AppManager.editorConfig.CurveVisibleBreathiness  = mDialogPreference.isCurveVisibleBre();
                    AppManager.editorConfig.CurveVisibleBrightness   = mDialogPreference.isCurveVisibleBri();
                    AppManager.editorConfig.CurveVisibleClearness    = mDialogPreference.isCurveVisibleCle();
                    AppManager.editorConfig.CurveVisibleDecay        = mDialogPreference.isCurveVisibleDecay();
                    AppManager.editorConfig.CurveVisibleDynamics     = mDialogPreference.isCurveVisibleDyn();
                    AppManager.editorConfig.CurveVisibleGendorfactor = mDialogPreference.isCurveVisibleGen();
                    AppManager.editorConfig.CurveVisibleOpening      = mDialogPreference.isCurveVisibleOpe();
                    AppManager.editorConfig.CurveVisiblePit          = mDialogPreference.isCurveVisiblePit();
                    AppManager.editorConfig.CurveVisiblePbs          = mDialogPreference.isCurveVisiblePbs();
                    AppManager.editorConfig.CurveVisiblePortamento   = mDialogPreference.isCurveVisiblePor();
                    AppManager.editorConfig.CurveVisibleVelocity     = mDialogPreference.isCurveVisibleVel();
                    AppManager.editorConfig.CurveVisibleVibratoDepth = mDialogPreference.isCurveVisibleVibratoDepth();
                    AppManager.editorConfig.CurveVisibleVibratoRate  = mDialogPreference.isCurveVisibleVibratoRate();
                    AppManager.editorConfig.CurveVisibleFx2Depth     = mDialogPreference.isCurveVisibleFx2Depth();
                    AppManager.editorConfig.CurveVisibleHarmonics    = mDialogPreference.isCurveVisibleHarmonics();
                    AppManager.editorConfig.CurveVisibleReso1        = mDialogPreference.isCurveVisibleReso1();
                    AppManager.editorConfig.CurveVisibleReso2        = mDialogPreference.isCurveVisibleReso2();
                    AppManager.editorConfig.CurveVisibleReso3        = mDialogPreference.isCurveVisibleReso3();
                    AppManager.editorConfig.CurveVisibleReso4        = mDialogPreference.isCurveVisibleReso4();
                    AppManager.editorConfig.CurveVisibleEnvelope     = mDialogPreference.isCurveVisibleEnvelope();

#if ENABLE_MIDI
                    AppManager.editorConfig.MidiInPort.PortNumber = mDialogPreference.getMidiInPort();
#endif
#if ENABLE_MTC
                    AppManager.editorConfig.MidiInPortMtc.PortNumber = m_preference_dlg.getMtcMidiInPort();
#endif
#if ENABLE_MIDI || ENABLE_MTC
                    //updateMidiInStatus();
                    //reloadMidiIn();
#endif

                    Vector <String>  new_resamplers = new Vector <String>();
                    Vector <Boolean> new_with_wine  = new Vector <Boolean>();
                    mDialogPreference.copyResamplersConfig(new_resamplers, new_with_wine);
                    AppManager.editorConfig.clearResampler();
                    for (int i = 0; i < new_resamplers.size(); i++)
                    {
                        AppManager.editorConfig.addResampler(new_resamplers.get(i), new_with_wine.get(i));
                    }
                    AppManager.editorConfig.PathWavtool     = mDialogPreference.getPathWavtool();
                    AppManager.editorConfig.WavtoolWithWine = mDialogPreference.isWavtoolWithWine();

                    AppManager.editorConfig.UtauSingers.clear();
                    for (Iterator <SingerConfig> itr = mDialogPreference.getUtausingers().iterator(); itr.hasNext();)
                    {
                        SingerConfig sc = itr.next();
                        AppManager.editorConfig.UtauSingers.add((SingerConfig)sc.clone());
                    }
                    AppManager.reloadUtauVoiceDB();

                    AppManager.editorConfig.SelfDeRomanization                = mDialogPreference.isSelfDeRomantization();
                    AppManager.editorConfig.AutoBackupIntervalMinutes         = mDialogPreference.getAutoBackupIntervalMinutes();
                    AppManager.editorConfig.UseSpaceKeyAsMiddleButtonModifier = mDialogPreference.isUseSpaceKeyAsMiddleButtonModifier();

#if ENABLE_AQUESTONE
                    var old_aquestone_config = Tuple.Create(AppManager.editorConfig.PathAquesTone, AppManager.editorConfig.DoNotUseAquesTone);
                    AppManager.editorConfig.PathAquesTone     = mDialogPreference.getPathAquesTone();
                    AppManager.editorConfig.DoNotUseAquesTone = !mDialogPreference.isAquesToneRequired();
                    if (old_aquestone_config.Item1 != AppManager.editorConfig.PathAquesTone ||
                        old_aquestone_config.Item2 != AppManager.editorConfig.DoNotUseAquesTone)
                    {
                        VSTiDllManager.reloadAquesTone();
                    }

                    var old_aquestone2_config = Tuple.Create(AppManager.editorConfig.PathAquesTone2, AppManager.editorConfig.DoNotUseAquesTone2);
                    AppManager.editorConfig.PathAquesTone2     = mDialogPreference.getPathAquesTone2();
                    AppManager.editorConfig.DoNotUseAquesTone2 = !mDialogPreference.isAquesTone2Required();
                    if (old_aquestone2_config.Item1 != AppManager.editorConfig.PathAquesTone2 ||
                        old_aquestone2_config.Item2 != AppManager.editorConfig.DoNotUseAquesTone2)
                    {
                        VSTiDllManager.reloadAquesTone2();
                    }
#endif
                    //updateRendererMenu();

                    //AppManager.editorConfig.__revoked__WaveFileOutputFromMasterTrack = mDialogPreference.isWaveFileOutputFromMasterTrack();
                    //AppManager.editorConfig.__revoked__WaveFileOutputChannel = mDialogPreference.getWaveFileOutputChannel();
                    if (AppManager.editorConfig.UseProjectCache && !mDialogPreference.isUseProjectCache())
                    {
                        // プロジェクト用キャッシュを使用していたが,使用しないように変更された場合.
                        // プロジェクト用キャッシュが存在するなら,共用のキャッシュに移動する.
                        String file = AppManager.getFileName();
                        if (file != null && !file.Equals(""))
                        {
                            String dir             = PortUtil.getDirectoryName(file);
                            String name            = PortUtil.getFileNameWithoutExtension(file);
                            String projectCacheDir = Path.Combine(dir, name + ".cadencii");
                            String commonCacheDir  = Path.Combine(AppManager.getCadenciiTempDir(), AppManager.getID());
                            if (Directory.Exists(projectCacheDir))
                            {
                                VsqFileEx vsq = AppManager.getVsqFile();
                                for (int i = 1; i < vsq.Track.size(); i++)
                                {
                                    // wavを移動
                                    String wavFrom = Path.Combine(projectCacheDir, i + ".wav");
                                    String wavTo   = Path.Combine(commonCacheDir, i + ".wav");
                                    if (!System.IO.File.Exists(wavFrom))
                                    {
                                        continue;
                                    }
                                    if (System.IO.File.Exists(wavTo))
                                    {
                                        try {
                                            PortUtil.deleteFile(wavTo);
                                        }
                                        catch (Exception ex) {
                                            Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                            serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                            continue;
                                        }
                                    }
                                    try {
                                        PortUtil.moveFile(wavFrom, wavTo);
                                    }
                                    catch (Exception ex) {
                                        Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                        serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                    }

                                    // xmlを移動
                                    String xmlFrom = Path.Combine(projectCacheDir, i + ".xml");
                                    String xmlTo   = Path.Combine(commonCacheDir, i + ".xml");
                                    if (!System.IO.File.Exists(xmlFrom))
                                    {
                                        continue;
                                    }
                                    if (System.IO.File.Exists(xmlTo))
                                    {
                                        try {
                                            PortUtil.deleteFile(xmlTo);
                                        }
                                        catch (Exception ex) {
                                            Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                            serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                            continue;
                                        }
                                    }
                                    try {
                                        PortUtil.moveFile(xmlFrom, xmlTo);
                                    }
                                    catch (Exception ex) {
                                        Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                        serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                    }
                                }

                                // projectCacheDirが空なら,ディレクトリごと削除する
                                String[] files = PortUtil.listFiles(projectCacheDir, "*.*");
                                if (files.Length <= 0)
                                {
                                    try {
                                        PortUtil.deleteDirectory(projectCacheDir);
                                    }
                                    catch (Exception ex) {
                                        Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                                        serr.println("FormMain#menuSettingPreference_Click; ex=" + ex);
                                    }
                                }

                                // キャッシュのディレクトリを再指定
                                AppManager.setTempWaveDir(commonCacheDir);
                            }
                        }
                    }
                    AppManager.editorConfig.UseProjectCache               = mDialogPreference.isUseProjectCache();
                    AppManager.editorConfig.DoNotUseVocaloid1             = !mDialogPreference.isVocaloid1Required();
                    AppManager.editorConfig.DoNotUseVocaloid2             = !mDialogPreference.isVocaloid2Required();
                    AppManager.editorConfig.BufferSizeMilliSeconds        = mDialogPreference.getBufferSize();
                    AppManager.editorConfig.DefaultSynthesizer            = mDialogPreference.getDefaultSynthesizer();
                    AppManager.editorConfig.UseUserDefinedAutoVibratoType = mDialogPreference.isUseUserDefinedAutoVibratoType();
                    AppManager.editorConfig.WinePrefix                 = mDialogPreference.getWinePrefix();
                    AppManager.editorConfig.WineTop                    = mDialogPreference.getWineTop();
                    AppManager.editorConfig.WineTopBuiltin             = mDialogPreference.isWineBuiltin();
                    AppManager.editorConfig.UseWideCharacterWorkaround = mDialogPreference.isEnableWideCharacterWorkaround();

                    //trackSelector.prepareSingerMenu(VsqFileEx.getTrackRendererKind(AppManager.getVsqFile().Track.get(AppManager.getSelected())));
                    //trackSelector.updateVisibleCurves();

                    //updateRendererMenu();
                    AppManager.updateAutoBackupTimerStatus();

                    // editorConfig.PxTrackHeightが変更されている可能性があるので,更新が必要
                    //controller.setStartToDrawY(calculateStartToDrawY(vScroll.Value));

                    //if (menuVisualControlTrack.Checked) {
                    //    splitContainer1.setPanel2MinSize(trackSelector.getPreferredMinSize());
                    //}

                    AppManager.saveConfig();
                    //applyLanguage();
#if ENABLE_SCRIPT
                    //updateScriptShortcut();
#endif

                    //updateDrawObjectList();
                    //refreshScreen();
                }
            }
            catch (Exception ex) {
                Logger.write(typeof(FormMain) + ".menuSettingPreference_Click; ex=" + ex + "\n");
                AppManager.debugWriteLine("FormMain#menuSettingPreference_Click; ex=" + ex);
            }
        }
Exemple #12
0
        /// <summary>
        /// コンポーネントの描画関数です
        /// </summary>
        /// <param name="g"></param>
        public void paint(Graphics g1)
        {
            int       width  = Width;
            int       height = Height;
            Rectangle rc     = new Rectangle(0, 0, width, height);

            Graphics2D g = (Graphics2D)g1;

            // 背景を塗りつぶす
            g.setStroke(getStrokeDefault());
            g.setColor(Color.gray);
            g.fillRect(rc.x, rc.y, rc.width, rc.height);

            if (AppManager.skipDrawingWaveformWhenPlaying && AppManager.isPlaying())
            {
                // 左側のボタン部との境界線
                g.setColor(mBorderColor);
                g.drawLine(0, 0, 0, height);

                g.setColor(Color.black);
                PortUtil.drawStringEx(
                    g,
                    "(hidden for performance)",
                    AppManager.baseFont8,
                    rc,
                    PortUtil.STRING_ALIGN_CENTER,
                    PortUtil.STRING_ALIGN_CENTER);
                return;
            }

            // スケール線を描く
            int half_height = height / 2;

            g.setColor(Color.black);
            g.drawLine(0, half_height, width, half_height);

            // 描画コンテキストを用いて波形を描画
            int             selected = AppManager.getSelected();
            WaveDrawContext context  = mDrawer[selected - 1];

            if (context != null)
            {
                if (mAutoMaximize)
                {
                    context.draw(
                        g,
                        Color.black,
                        rc,
                        AppManager.clockFromXCoord(AppManager.keyWidth),
                        AppManager.clockFromXCoord(AppManager.keyWidth + width),
                        AppManager.getVsqFile().TempoTable,
                        AppManager.mMainWindowController.getScaleX());
                }
                else
                {
                    context.draw(
                        g,
                        Color.black,
                        rc,
                        AppManager.clockFromXCoord(AppManager.keyWidth),
                        AppManager.clockFromXCoord(AppManager.keyWidth + width),
                        AppManager.getVsqFile().TempoTable,
                        AppManager.mMainWindowController.getScaleX(),
                        mScale);
                }
            }

            // 左側のボタン部との境界線
            g.setColor(mBorderColor);
            g.drawLine(0, 0, 0, height);

            // ソングポジション
            int song_pos_x = AppManager.xCoordFromClocks(AppManager.getCurrentClock()) - AppManager.keyWidth;

            if (0 < song_pos_x)
            {
                g.setColor(Color.white);
                g.setStroke(getStroke2px());
                g.drawLine(song_pos_x, 0, song_pos_x, height);
            }
        }
        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;
        }
        public void commonButton_Click(Object sender, EventArgs e)
        {
            VsqBPList list = AppManager.getVsqFile().Track[AppManager.getSelected()].getCurve(m_curve.getName());
            VsqBPPairSearchContext search = list.findElement(m_editing_id);
            int index = search.index;

            if (sender == btnForward)
            {
                index++;
            }
            else if (sender == btnBackward)
            {
                index--;
            }
            else if (sender == btnBackward2)
            {
                index -= 5;
            }
            else if (sender == btnForward2)
            {
                index += 5;
            }
            else if (sender == btnForward3)
            {
                index += 10;
            }
            else if (sender == btnBackward3)
            {
                index -= 10;
            }

            if (index < 0)
            {
                index = 0;
            }

            if (list.size() <= index)
            {
                index = list.size() - 1;
            }

            VsqBPPair bp = list.getElementB(index);

            m_editing_id = bp.id;
            int clock = list.getKeyClock(index);

            txtDataPointClock.TextChanged -= commonTextBox_TextChanged;
            txtDataPointValue.TextChanged -= commonTextBox_TextChanged;
            txtDataPointClock.Text         = clock + "";
            txtDataPointValue.Text         = bp.value + "";
            txtDataPointClock.TextChanged += commonTextBox_TextChanged;
            txtDataPointValue.TextChanged += commonTextBox_TextChanged;

            txtDataPointValue.Focus();
            txtDataPointValue.SelectAll();

            AppManager.itemSelection.clearPoint();
            AppManager.itemSelection.addPoint(m_curve, bp.id);
            if (mMainWindow != null)
            {
                mMainWindow.ensureVisible(clock);
                mMainWindow.refreshScreen();
            }
        }