コード例 #1
0
        public SectionWindow(Registration registration, SectionObjectRec section, IMainWindowServices mainWindow)
        {
            this.registration = registration;
            this.section      = section;
            this.mainWindow   = mainWindow;

            InitializeComponent();
            this.Icon = OutOfPhase.Properties.Resources.Icon2;

            this.textBoxSectionText.TextService = Program.Config.EnableDirectWrite ? TextEditor.TextService.DirectWrite : TextEditor.TextService.Uniscribe;
            this.textBoxSectionText.AutoIndent  = Program.Config.AutoIndent;

            DpiChangeHelper.ScaleFont(this, Program.Config.AdditionalUIZoom);

            menuStripManager.SetGlobalHandler(mainWindow);
            menuStripManager.HookUpTextEditorWindowHelper(this.textEditorWindowHelper);
            menuStripManager.HookUpTextBoxWindowHelper(this.textBoxWindowHelper);

            documentBindingSource.Add(mainWindow.Document);
            sectionObjectRecBindingSource.Add(section);

            textBoxSectionName.TextChanged += new EventHandler(textBoxSectionName_TextChanged);
            GlobalNameChanged();

            registration.Register(section, this);
        }
コード例 #2
0
        private void buttonEditSection_Click(object sender, EventArgs e)
        {
            {
                SectionObjectRec selectedSection = myListBoxSections.SelectedItem as SectionObjectRec;
                if (selectedSection != null)
                {
                    if (!registration.Activate(selectedSection))
                    {
                        new SectionWindow(registration, selectedSection, mainWindow).Show();
                    }
                    return;
                }
            }

            {
                TrackObjectRec selectedTrack = myListBoxSections.SelectedItem as TrackObjectRec;
                if (selectedTrack != null)
                {
                    if (selectedTrack.Section != null)
                    {
                        if (!registration.Activate(selectedTrack.Section))
                        {
                            new SectionWindow(registration, selectedTrack.Section, mainWindow).Show();
                        }
                    }
                    return;
                }
            }
        }
コード例 #3
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            SectionObjectRec newSection = new SectionObjectRec(document);

            document.SectionList.Add(newSection);
            RebuildScrollingList();
            myListBoxSections.SelectItem(newSection, true /*clearOtherSelections*/);
            buttonEditSection_Click(null, null);
        }
コード例 #4
0
        private void buttonDeleteSection_Click(object sender, EventArgs e)
        {
            SectionObjectRec selectedSection = myListBoxSections.SelectedItem as SectionObjectRec;

            if (selectedSection != null)
            {
                DialogResult result = MessageBox.Show("Delete selected section?", "Delete Section", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (result == DialogResult.Yes)
                {
                    if (registration.CloseAll(selectedSection))
                    {
                        document.RemoveSection(selectedSection);
                        RebuildScrollingList();
                    }
                }
            }
        }
コード例 #5
0
        private void buttonChangeSection_Click(object sender, EventArgs e)
        {
            TrackObjectRec track = myListBoxSections.SelectedItem as TrackObjectRec;

            if (track != null)
            {
                using (SectionChooseDialog dialog = new SectionChooseDialog(document.SectionList, track.Section))
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        SectionObjectRec section = dialog.SelectedSection;
                        track.Section = section;
                        RebuildScrollingList();
                    }
                }
            }
        }
コード例 #6
0
        public SectionChooseDialog(MyBindingList <SectionObjectRec> sections, SectionObjectRec defaultSection)
        {
            InitializeComponent();
            this.Icon = OutOfPhase.Properties.Resources.Icon2;

            DpiChangeHelper.ScaleFont(this, Program.Config.AdditionalUIZoom);

            string nullSection = "(None)";

            displayList.Add(nullSection);
            foreach (SectionObjectRec section in sections)
            {
                displayList.Add(section);
            }

            myListBoxSections.SetUnderlying(displayList, GetDisplayText);
            myListBoxSections.SelectItem(defaultSection != null ? (object)defaultSection : (object)nullSection, true /*clearOtherSelections*/);
            myListBoxSections.DoubleClick2 += MyListBoxSections_DoubleClick;
        }
コード例 #7
0
        private void RebuildScrollingList()
        {
            object selection = myListBoxSections.SelectedItem;

            displayList.Clear();

            TrackObjectRec[] tracks = new List <TrackObjectRec>(document.TrackList).ToArray();

            /* set stable sort subkey */
            for (int i = 0; i < tracks.Length; i++)
            {
                tracks[i].AuxVal = i;
            }

            Array.Sort(
                tracks,
                delegate(TrackObjectRec left, TrackObjectRec right)
            {
                return(Synthesizer.SynthStateRec.CompareTracksOnSection(left, right, document.SectionList));
            });

            SectionObjectRec section  = null;
            bool             firstTry = true;

            for (int i = 0; i < tracks.Length; i++)
            {
                TrackObjectRec track = tracks[i];

                /* create the section name header */
                if (firstTry || (section != track.Section))
                {
                    firstTry = false;
                    section  = track.Section;
                    if (section == null)
                    {
                        displayList.Add((string)"(Default)");
                    }
                    else
                    {
                        displayList.Add(section);
                    }
                }

                /* add the track item */
                displayList.Add(track);
            }

            /* add any sections we missed */
            for (int j = 0; j < document.SectionList.Count; j++)
            {
                section = document.SectionList[j];

                bool referenced = false;
                for (int i = 0; !referenced && (i < tracks.Length); i++)
                {
                    TrackObjectRec track = document.TrackList[i];
                    if (track.Section == section)
                    {
                        referenced = true;
                    }
                }

                if (!referenced)
                {
                    displayList.Add(section);
                }
            }

            for (int i = 0; i < displayList.Count; i++)
            {
                if (selection == displayList[i])
                {
                    myListBoxSections.SelectItem(i, true /*clearOtherSelections*/);
                }
            }
        }