private void Button_Click(object sender, RoutedEventArgs e)
        {
            ModuleBoundaryDescription mbd = (ModuleBoundaryDescription)ParentModule;
            string theText = theTextBox.Text;

            mbd.SetDescription(theText);
        }
Пример #2
0
        //check to see if there is a description and if not
        //if a file name contains at least one space, it is treated as the description of the content
        void SetDescription(string fileName)
        {
            if (!useDescription)
            {
                return;
            }
            ModuleBoundaryDescription mbd = (ModuleBoundaryDescription)FindModule("BoundaryDescription");

            if (mbd == null)
            {
                return;
            }

            string textFilePath = Path.ChangeExtension(fileName, "txt");

            if (File.Exists(textFilePath))
            {
                string fullCommandText = File.ReadAllText(textFilePath);
                mbd.SetDescription(fullCommandText);
                string[] words = fullCommandText.Split(' ');
                countDown = words.Length + 1;
                return;
            }

            string name = Path.GetFileNameWithoutExtension(fileName);

            if (useDescription)
            {
                //remove digits and text within parentheses
                string name1   = "";
                bool   inParen = false;
                foreach (char c in name)
                {
                    if (c == '(')
                    {
                        inParen = true;
                    }
                    if (!inParen && !char.IsDigit(c))
                    {
                        name1 += c;
                    }
                    if (c == ')')
                    {
                        inParen = false;
                    }
                }
                mbd.SetDescription(name1);
                string[] words = name1.Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
                countDown = words.Length + 1;
            }
        }
        public override bool Draw(bool checkDrawTimer)
        {
            if (!base.Draw(checkDrawTimer))
            {
                return(false);
            }
            //this has a timer so that no matter how often you might call draw, the dialog
            //only updates 10x per second

            //use a line like this to gain access to the parent's public variables
            //ModuleEmpty parent = (ModuleEmpty)base.Parent1;

            //here are some other possibly-useful items
            //theCanvas.Children.Clear();
            //Point windowSize = new Point(theCanvas.ActualWidth, theCanvas.ActualHeight);
            //Point windowCenter = new Point(windowSize.X / 2, windowSize.Y / 2);
            //float scale = (float)Math.Min(windowSize.X, windowSize.Y) / 12;
            //if (scale == 0) return false;

            ModuleBoundaryDescription mbd = (ModuleBoundaryDescription)ParentModule;

            currentDescription.Text = mbd.descriptionString;
            return(true);
        }