コード例 #1
0
ファイル: SequencesList.cs プロジェクト: gumik/SCTIGR
        public void SetSequences(string[] sequences)
        {
            var children = vbox.Children.Clone() as ICollection<Gtk.Widget>;
            foreach (var control in children)
            {
                control.Destroy();
            }

            foreach (var sequence in sequences)
            {
                var sequenceControl = new SequenceControl() { Text = sequence, Visible = true };
                vbox.Add(sequenceControl);
            }
        }
コード例 #2
0
ファイル: ProfileControl.cs プロジェクト: gumik/SCTIGR
        private void SequenceAdded(string sequence, int begin)
        {
            Console.WriteLine(string.Format("{0} at {1}", sequence, begin));
            if (begin < 0)
            {
                InsertEmptyToAll(0, -begin);
                begin = 0;
            }

            var text = sequence.Clone() as string;

            foreach (var widget in vbox)
            {
                var sequenceControl = widget as SequenceControl;
                if (sequenceControl == null) continue;

                if (sequenceControl.Text.Length < begin)
                {
                    sequenceControl.Text += string.Concat(Enumerable.Repeat(' ', begin - sequenceControl.Text.Length));
                    sequenceControl.Text += text;
                    UpdateSequence();
                    return;
                }
                else if (sequence.Length + begin < sequenceControl.Text.Length - 2
                         && IsSpace(sequenceControl.Text, begin, sequence.Length))
                {
                    var sb = new StringBuilder();

                    sb.Append(sequenceControl.Text.Substring(0, begin));
                    sb.Append(sequence);
                    sb.Append(sequenceControl.Text.Substring(begin + sequence.Length));

                    sequenceControl.Text = sb.ToString();
                    UpdateSequence();
                    return;
                }
            }

            if (begin > 0)
            {
                text = text.Insert(0, string.Concat(Enumerable.Repeat(' ', begin)));
            }
            var sc = new SequenceControl() { Text = text, Visible = true };
            vbox.Add(sc);

            UpdateSequence();
        }