예제 #1
0
        /// <summary>
        /// 指定されたパスのファイルからSequenceDataを作成します。拡張子は自動的に付加されます。
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static SequenceData RetrieveState(string path)
        {
            SequenceData ret = new SequenceData();

            if (!File.Exists(path + DefaultExtensionForHeader))
            {
                string ext = Path.GetExtension(path);
                if (ext == DefaultExtensionForHeader || ext == DefaultExtensionForValues || ext == DefaultExtensionForBorder)
                {
                    path = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path));
                    if (!File.Exists(path + DefaultExtensionForHeader))
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            string titlePath    = string.Format("{0}{1}", path, DefaultExtensionForHeader);
            string sequencePath = string.Format("{0}{1}", path, DefaultExtensionForValues);
            string borderPath   = string.Format("{0}{1}", path, DefaultExtensionForBorder);

            using (FileStream titleStream = new FileStream(titlePath, FileMode.Open)) {
                ret.RetrieveDataHeader(titleStream);
            }
            ret.Values        = TimeSeriesValues.Deserialize(sequencePath);
            ret.Borders       = LabelingBorders.Deserialize(borderPath);
            ret.IsDataChanged = false;
            return(ret);
        }
예제 #2
0
        /// <summary>
        /// ラベル系列からデータを作成します
        /// </summary>
        /// <param name="labelSequence">ラベル系列</param>
        /// <param name="title">このデータに与えるタイトル</param>
        /// <param name="colorPalette">ラベル名からラベルの色を生成するディクショナリ</param>
        /// <returns></returns>
        public static SequenceData FromLabelSequence(ICSLabelSequence labelSequence, string title, IDictionary <string, Color> colorPalette)
        {
            if (labelSequence == null)
            {
                throw new ArgumentNullException("labelSequence", "'labelSequence' cannot be null");
            }
            TimeSeriesValues newSeqeunce = new TimeSeriesValues(title);
            LabelingBorders  newBorder   = new LabelingBorders();

            foreach (var label in labelSequence.EnumerateLabels())
            {
                newSeqeunce[label.BeginTime] = new decimal?[] { label.BeginTime };
                newBorder.SetBorder(label.BeginTime, label.LabelText);
            }
            newSeqeunce[labelSequence.Duration] = new decimal?[] { labelSequence.Duration };
            newBorder.SetBorder(labelSequence.Duration, newBorder.DefaultName);

            if (colorPalette != null)
            {
                foreach (var pair in colorPalette)
                {
                    newBorder.SetColor(pair.Key, pair.Value);
                }
            }

            SequenceData ret = new SequenceData(newSeqeunce, newBorder, title);

            ret.Type = SequenceType.Label;
            return(ret);
        }
 /// <summary>
 /// カラムを選択する対象となるSequenceValuesを関連付けます。
 /// </summary>
 /// <param title="resultSequence"></param>
 public void AttachSequence(SequenceData sequence)
 {
     if (sequence == null)
     {
         throw new ArgumentNullException("sequence", "'sequence' cannot be null");
     }
     _sequence = sequence;
     setContents();
 }
 public void AttachSequenceData(SequenceData sequence)
 {
     _sequence = sequence;
     _map.Clear();
     if (_sequence != null)
     {
         foreach (string label in _sequence.Borders.GetLabelNames(false))
         {
             _map.Add(label, label);
         }
     }
     updateDataGridView();
 }
 private void commitColorMap()
 {
     foreach (var seqPair in _colorMap)
     {
         SequenceData data = _controller.GetSequenceByTitle(seqPair.Key);
         if (data == null)
         {
             continue;
         }
         foreach (var labelPair in seqPair.Value)
         {
             data.Borders.SetColor(labelPair.Key, labelPair.Value);
         }
     }
     _colorMap.Clear();
 }
        private void setSequenceList()
        {
            listViewSequence.Items.Clear();
            SequenceView focusedViewer = _controller.GetFocusedView();
            SequenceData focusedData   = null;

            if (focusedViewer != null)
            {
                focusedData = focusedViewer.Sequence;
            }
            foreach (var data in _controller.GetSequenceList())
            {
                if ((data.Type & SequenceType.Label) != 0)
                {
                    ListViewItem item = new ListViewItem(data.Title);
                    item.Checked = focusedData == data;
                    listViewSequence.Items.Add(item);
                }
            }
        }
        Dictionary <string, IList <Color> > getLabelColors()
        {
            Dictionary <string, IList <Color> > ret = new Dictionary <string, IList <Color> >();

            foreach (ListViewItem item in listViewSequence.Items)
            {
                if (!item.Checked)
                {
                    continue;
                }
                SequenceData data = _controller.GetSequenceByTitle(item.Text);
                if (data == null)
                {
                    continue;
                }
                Dictionary <string, Color> palette = data.Borders.GetColorPalette();
                if (!palette.ContainsKey(""))
                {
                    palette[""] = Color.White;
                }
                IDictionary <string, Color> map;
                if (!_colorMap.TryGetValue(item.Text, out map))
                {
                    map = new Dictionary <string, Color>();
                }
                foreach (var pair in palette)
                {
                    if (!ret.ContainsKey(pair.Key))
                    {
                        ret[pair.Key] = new List <Color>();
                    }
                    Color color;
                    if (!map.TryGetValue(pair.Key, out color))
                    {
                        color = pair.Value;
                    }
                    ret[pair.Key].Add(color);
                }
            }
            return(ret);
        }
 public DialogSequenceOperation(ISequenceOperation ope, SequenceViewerController controller, SequenceData current, IList <ProcParam <SequenceProcEnv> > paramList)
 {
     InitializeComponent();
     _operator            = new Operation.OperationExecution(ope, controller, current);
     _operator.Parameters = paramList;
     panelSub             = _operator.GetPanel();
     panelSub.Dock        = DockStyle.Fill;
     panelMain.Controls.Add(panelSub);
     this.Text = ope.GetTitle();
     this.textSelected.Text = current.Title;
     textExplain.Text       = ope.GetDescription();
 }
 public DialogSequenceOperation(ISequenceOperation ope, SequenceViewerController controller, SequenceData current)
     : this(ope, controller, current, null)
 {
 }
 public void SetItemsFromSequence(SequenceData sequence)
 {
     this.SetItemsFromSequenceValues(sequence.Values);
 }
예제 #11
0
        /// <summary>
        /// ストリームからデータを復元します
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public static SequenceData Deserialize(XmlReader reader)
        {
            SequenceData ret = null;

            reader.ReadStartElement(typeof(SequenceData).Name);
            byte[]          titleBytes = null, sequenceBytes = null;
            LabelingBorders border     = null;
            string          tmp;
            MemoryStream    tmpStream;
            StreamWriter    tmpWriter;

            for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None; reader.MoveToContent())
            {
                if (reader.IsEmptyElement)
                {
                    reader.Skip();
                    continue;
                }
                switch (reader.Name)
                {
                case "Title":
                    tmp       = reader.ReadElementContentAsString();
                    tmpStream = new MemoryStream();
                    tmpWriter = new StreamWriter(tmpStream);
                    tmpWriter.Write(tmp);
                    tmpWriter.Flush();
                    titleBytes = tmpStream.ToArray();
                    break;

                case "Sequence":
                    tmp       = reader.ReadElementContentAsString();
                    tmpStream = new MemoryStream();
                    tmpWriter = new StreamWriter(tmpStream);
                    tmpWriter.Write(tmp);
                    tmpWriter.Flush();
                    sequenceBytes = tmpStream.ToArray();
                    break;

                case "Border":
                    reader.ReadStartElement();
                    border = LabelingBorders.Deserialize(reader.ReadSubtree());
                    for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None; reader.MoveToContent())
                    {
                        reader.Skip();
                    }
                    reader.ReadEndElement();
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }
            reader.ReadEndElement();
            if (titleBytes != null && sequenceBytes != null && border != null)
            {
                ret         = new SequenceData();
                ret.Borders = border;
                using (MemoryStream stream2 = new MemoryStream(sequenceBytes)) {
                    ret.Values = TimeSeriesValues.Deserialize(stream2);
                }
                using (MemoryStream stream2 = new MemoryStream(titleBytes)) {
                    ret.RetrieveDataHeader(stream2);
                }
            }
            return(ret);
        }
예제 #12
0
        /// <summary>
        /// ストリームからデータを復元します
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static SequenceData Deserialize(Stream stream)
        {
            XmlReader reader = XmlReader.Create(stream);

            return(SequenceData.Deserialize(reader));
        }
예제 #13
0
 /// <summary>
 /// コピーコンストラクタ
 /// </summary>
 /// <param name="sequence"></param>
 public SequenceData(SequenceData sequence)
     : this(new TimeSeriesValues(sequence.Values), new LabelingBorders(sequence.Borders), sequence.Title)
 {
     this.Type = sequence.Type;
 }