コード例 #1
0
        private void lbMain_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbMain.SelectedIndex == -1)
            {
                return;
            }
            BaseUserControl baseUserControl = gMain.Children[0] as BaseUserControl;

            baseUserControl.filePath = mw.LastProjectPath + baseUserControl._fileType + @"\" + lbMain.SelectedItem.ToString();
            baseUserControl.LoadFile(lbMain.SelectedItem.ToString());
        }
コード例 #2
0
        public void IntoUserControl(String fileName, bool checkFileName)
        {
            if (fileName.EndsWith(".mid"))
            {
                TabItem item = new TabItem
                {
                    Header  = fileName,
                    Content = userControls[0]
                };
                tcMain.Items.Add(item);
            }
            else
            {
                for (int i = 0; i < userControls.Count; i++)
                {
                    if (fileName.EndsWith(userControls[i]._fileExtension))
                    {
                        TabItem item = new TabItem
                        {
                            Header  = fileName,
                            Content = userControls[i]
                        };
                        tcMain.Items.Add(item);
                        break;
                    }
                }
            }
            BaseUserControl baseUserControl = tcMain.Items[0] as BaseUserControl;

            if (!fileName.EndsWith(".lightScript"))
            {
            }
            else
            {
                //关闭文件选择器
                //CloseFileControl();
                //baseUserControl = mw.gCenter.Children[0] as BaseUserControl;
                if (baseUserControl.filePath.Equals(mw.LastProjectPath + baseUserControl._fileType + @"\" + fileName) && checkFileName)
                {
                    return;
                }
                if (baseUserControl is ScriptUserControl)
                {
                    (baseUserControl as ScriptUserControl)._bIsEdit = false;
                }
            }
            baseUserControl.filePath = mw.LastProjectPath + baseUserControl._fileType + @"\" + fileName;
            baseUserControl.LoadFile(fileName);
        }
コード例 #3
0
        public void IntoUserControl(String fileName)
        {
            for (int i = 0; i < tcMain.Items.Count; i++)
            {
                if (fileName.Equals(TabItem2FileName(tcMain.Items[i] as TabItem)))
                {
                    tcMain.SelectedIndex = i;
                    return;
                }
            }

            TabItem item = null;

            if (fileName.EndsWith(".mid"))
            {
                item = new TabItem
                {
                    Content = userControls[0]
                };
            }
            else
            {
                for (int i = 0; i < userControls.Count; i++)
                {
                    if (fileName.EndsWith(userControls[i]._fileExtension))
                    {
                        if (userControls[i] is PlayUserControl)
                        {
                            item = new TabItem
                            {
                                Content = playuc
                            };
                        }
                        else
                        {
                            item = new TabItem
                            {
                                Content = userControls[i].GetBaseUserControl(mw)
                            };
                        }
                        break;
                    }
                }
            }
            if (item == null)
            {
                return;
            }
            StackPanel sp = new StackPanel
            {
                Orientation = Orientation.Horizontal
            };

            TextBlock tb = new TextBlock()
            {
                Text       = fileName,
                FontSize   = 14,
                Background = new SolidColorBrush(Colors.Transparent),
                Foreground = (SolidColorBrush)Resources["TabItemTextColor"]
            };

            sp.Children.Add(tb);

            TextBlock tbStar = new TextBlock()
            {
                Text       = " *",
                FontSize   = 14,
                Background = new SolidColorBrush(Colors.Transparent),
                Foreground = (SolidColorBrush)Resources["TabItemTextColor"]
            };

            tbStar.Visibility = Visibility.Collapsed;
            sp.Children.Add(tbStar);

            Grid grid = new Grid
            {
                Margin = new Thickness(5, 0, 0, 0)
            };

            grid.MouseLeftButtonDown += Grid_MouseLeftButtonDown;

            Image image = new Image()
            {
                Width  = 15,
                Height = 15,
                Source = ResourcesUtils.Resources2BitMap("close_gray.png"),
            };

            grid.Children.Add(image);

            sp.Children.Add(grid);

            item.Header = sp;
            tcMain.Items.Add(item);

            tcMain.SelectedIndex = tcMain.Items.Count - 1;

            BaseUserControl baseUserControl = ((TabItem)tcMain.Items[tcMain.SelectedIndex]).Content as BaseUserControl;

            if (fileName.EndsWith(".lightScript"))
            {
                //关闭文件选择器
                //CloseFileControl();
                //baseUserControl = mw.gCenter.Children[0] as BaseUserControl;
                if (baseUserControl.filePath.Equals(mw.LastProjectPath + baseUserControl._fileType + @"\" + fileName))
                {
                    return;
                }
                if (baseUserControl is ScriptUserControl)
                {
                    (baseUserControl as ScriptUserControl)._bIsEdit = false;
                }
            }

            baseUserControl.filePath = mw.LastProjectPath + baseUserControl._fileType + @"\" + fileName;
            baseUserControl.LoadFile(fileName);
        }
コード例 #4
0
        private void Storyboard_Completed(object sender, EventArgs e)
        {
            foo();
            async void foo()
            {
                await Task.Delay(400);

                if (lbFile.SelectedItem == null)
                {
                    mw.cMost.Children.RemoveAt(mw.cMost.Children.Count - 1);
                    return;
                }

                //mw.cMost.Children.RemoveAt(mw.cMost.Children.Count-1);

                String          fileName        = (lbFile.SelectedItem as ListBoxItem).Content.ToString();
                BaseUserControl baseUserControl = null;

                if (fileName.EndsWith(".mid"))
                {
                    IntoUserControl(0);
                }
                else
                {
                    for (int i = 0; i < userControls.Count; i++)
                    {
                        if (fileName.EndsWith(userControls[i]._fileExtension))
                        {
                            IntoUserControl(i);
                            break;
                        }
                    }
                }

                //if (mw.cMost.Children.Count == 0)
                //    return;
                //是否是制作灯光的用户控件
                baseUserControl = (mw.contentUserControls[1] as EditUserControl).tcMain.Items[0] as BaseUserControl;

                if (!fileName.EndsWith(".lightScript"))
                {
                }
                else
                {
                    //关闭文件选择器
                    //CloseFileControl();
                    //baseUserControl = mw.gCenter.Children[0] as BaseUserControl;
                    selectedItem = sender as ListBoxItem;

                    if (baseUserControl.filePath.Equals(mw.LastProjectPath + baseUserControl._fileType + @"\" + fileName))
                    {
                        return;
                    }
                    if (baseUserControl is ScriptUserControl)
                    {
                        (baseUserControl as ScriptUserControl)._bIsEdit = false;
                    }
                }
                baseUserControl.filePath = mw.LastProjectPath + baseUserControl._fileType + @"\" + fileName;
                baseUserControl.LoadFile(fileName);
                //if (baseUserControl is ScriptUserControl)
                //{
                //    (baseUserControl as ScriptUserControl).InitMyContent();
                //}
            }
        }