Esempio n. 1
0
        private void btnCopy_Click(object sender, RoutedEventArgs e)
        {
            if (NowTimePoint == 0)
            {
                return;
            }
            GetNumberDialog c = new GetNumberDialog(mw, "CopyToFrameNumberColon", false, LiTime, true);

            if (c.ShowDialog() == true)
            {
                int[] x = new int[100];
                for (int i = 0; i < Dic[LiTime[NowTimePoint - 1]].Count(); i++)
                {
                    x[i] = Dic[LiTime[NowTimePoint - 1]][i];
                }
                //如果已经有该时间点,替换
                if (LiTime.Contains(c.OneNumber))
                {
                    Dic[c.OneNumber] = x;
                    for (int i = 0; i < LiTime.Count; i++)
                    {
                        if (LiTime[i] == c.OneNumber)
                        {
                            NowTimePoint = i + 1;
                            break;
                        }
                    }
                }
                else
                {
                    (DataContext as FrameUserControlViewModel).InsertTimePoint(c.OneNumber, x);
                }
            }
        }
Esempio n. 2
0
        private void lbColor_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            GetNumberDialog dialog = new GetNumberDialog(mw, "NewColorColon", false);

            if (dialog.ShowDialog() == true)
            {
                Color OldColor = NumToBrush(int.Parse(lbColor.SelectedItem.ToString())).Color;
                foreach (Rectangle r in controlRectangles)
                {
                    Color color = ((SolidColorBrush)r.Fill).Color;
                    color.A = 255;

                    if (color == OldColor)
                    {
                        Color NewColor = NumToBrush(dialog.OneNumber).Color;
                        NewColor.A = 120;
                        r.Fill     = new SolidColorBrush(NewColor);
                    }
                }
                lbColor.Items[lbColor.SelectedIndex] = dialog.OneNumber.ToString();
            }
        }
        /// <summary>
        /// 添加或删除时间节点
        /// </summary>
        /// <param name="str"></param>
        private void AddOrDeleteTimePoint(String str)
        {
            if (str.Equals("Add"))
            {
                GetNumberDialog dialog = new GetNumberDialog(StaticConstant.mw, "TheFrameOfTheNewNodeColon", false, model.LiTime, false);
                if (dialog.ShowDialog() == true)
                {
                    int[] x = new int[100];
                    for (int j = 0; j < 100; j++)
                    {
                        x[j] = 0;
                    }
                    InsertTimePoint(dialog.OneNumber, x);
                }
            }
            else if (str.Equals("AddStart"))
            {
                //如果已经有该时间点,报错
                if (model.LiTime.Contains(0))
                {
                    new MessageDialog(StaticConstant.mw, "TheFrameHasATimeNode").ShowDialog();
                }
                else
                {
                    int[] x = new int[100];
                    for (int i = 0; i < 100; i++)
                    {
                        x[i] = 0;
                    }
                    InsertTimePoint(0, x);
                }
            }
            else if (str.Equals("Delete"))
            {
                if (model.LiTime.Count == 0)
                {
                    return;
                }

                OkOrCancelDialog oocd = new OkOrCancelDialog(StaticConstant.mw, "WhetherToDeleteTheTimeNode");
                if (oocd.ShowDialog() == true)
                {
                    model.NowData.Remove(model.LiTime[model.NowTimePoint - 1]);
                    model.LiTime.RemoveAt(model.NowTimePoint - 1);
                    if (model.LiTime.Count == 0)
                    {
                        model.NowTimePoint = 0;
                    }
                    else
                    {
                        if (model.NowTimePoint == 1)
                        {
                            model.NowTimePoint = 1;
                        }
                        else
                        {
                            model.NowTimePoint--;
                        }
                    }
                    model.AllTimePoint -= 1;

                    List <int> li = model.LiTime;
                    model.LiTime = li;
                }
            }
            else
            {
                String strTime = str.Trim();
                if (strTime.Trim().Equals(""))
                {
                    return;
                }
                int time = 0;
                try
                {
                    if (strTime.Contains("+"))
                    {
                        //当前时间 +
                        time = int.Parse(strTime) + int.Parse(str.Substring(1));
                    }
                    else if (strTime.Contains("-"))
                    {
                        //当前时间 -
                        time = int.Parse(strTime) - int.Parse(str.Substring(1));
                    }
                    else
                    {
                        //当前时间
                        time = int.Parse(strTime);
                    }
                    if (time < 0)
                    {
                        new MessageDialog(StaticConstant.mw, "TheInputFormatIsIncorrect").ShowDialog();
                        return;
                    }
                }
                catch
                {
                    new MessageDialog(StaticConstant.mw, "TheInputFormatIsIncorrect").ShowDialog();
                    return;
                }
                //如果已经有该时间点,报错
                if (model.LiTime.Contains(time))
                {
                    new MessageDialog(StaticConstant.mw, "TheFrameHasATimeNode").ShowDialog();
                }
                else
                {
                    int[] x = new int[100];
                    for (int i = 0; i < 100; i++)
                    {
                        x[i] = 0;
                    }
                    InsertTimePoint(time, x);
                }
            }
        }