상속: System.Windows.Controls.UserControl
예제 #1
0
 public void Init(NoiseObject obj)
 {
     xIn1.Object = obj;
       xIn2.Object = obj;
       xIn3.Object = obj;
       xIn4.Object = obj;
       xOut.Object = obj;
 }
예제 #2
0
        private void xLoad_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog svfd = new Microsoft.Win32.OpenFileDialog();
              svfd.InitialDirectory = "C:\\";
              svfd.Filter = "NoiseTool files (*.nzt)|*.nzt";
              svfd.RestoreDirectory = true;
              bool? result = svfd.ShowDialog();
              if (result.HasValue && result.Value == true)
              {
            while(mObjects.Count > 0) obj_Close(mObjects[0], null);
            xGradient.GradientDefs.Clear();

            try
            {
              using (StreamReader sr = new StreamReader(svfd.FileName))
              {
            String links = "";
            String line;
            while ((line = sr.ReadLine()) != null)
            {
              string[] words = line.Split(seperator);
              if (words[0] == "App")
              {
                try {
                  Boundary.Object.X = Convert.ToInt32(words[1]);
                  Boundary.Object.Y = Convert.ToInt32(words[2]);
                  Boundary.Object.W = Convert.ToInt32(words[3]);
                  Boundary.Object.H = Convert.ToInt32(words[4]);
                }
                catch (Exception) { }
                xBoundary.DataContext = null;
                xBoundary.DataContext = Boundary.Object;

                string name = "";
                for (int i = 5; i < words.Length; ++i) name += (i == 5 ? "" : " ") + words[i];
                xGradientPicker.SelectedItem = xGradient.GetGradient(name);
              }

              else if (words[0] == "Gradient")
                xGradient.Load(sr);

              else if (words[0] == "Object")
              {
                int type = 0;
                try { type = Convert.ToInt32(words[1]); } catch (Exception) { type = 0; }

                NoiseObject obj = new NoiseObject(type);
                obj.Width = 200;
                obj.Height = 200;
                xBoard.Children.Add(obj);
                Canvas.SetLeft(obj, mCreateAt.X);
                Canvas.SetTop(obj, mCreateAt.Y);
                Canvas.SetZIndex(obj, 1);
                mObjects.Add(obj);
                Canvas.SetZIndex(obj, 2);

                obj.xGradient.ItemsSource = xGradient.GradientDefs;

                obj.Raise += new EventHandler<EventArgs>(obj_Raise);
                obj.Link += new EventHandler<LinkEventArgs>(obj_Link);
                obj.Erase += new EventHandler<LinkEventArgs>(obj_Erase);
                obj.NeedUpdate += new EventHandler<EventArgs>(obj_Move);
                obj.NeedApply += new EventHandler<EventArgs>(obj_NeedApply);
                obj.Relink += new EventHandler<EventArgs>(obj_Relink);
                obj.Close += new EventHandler<EventArgs>(obj_Close);
                obj.Rendered += new EventHandler<EventArgs>(obj_Rendered);

                links += obj.Load(sr);
              }
            }
            sr.Close();

            string[] objlinks = links.Split(seperator2);
            foreach (string link in objlinks)
            {
              if (link.Length == 0) continue;
              string[] ids = link.Split(seperator);
              if (ids.Length != 6) continue;
              NoiseObject target = GetObjectByName(ids[0]);
              NoiseObject in1 = GetObjectByName(ids[2]);
              if (in1 != null)
              {
                obj_Link(in1, new LinkEventArgs(LinkType.Out, in1.xLinks.xOut));
                obj_Link(target, new LinkEventArgs(LinkType.In1, target.xLinks.xIn1));
              }
              NoiseObject in2 = GetObjectByName(ids[3]);
              if (in2 != null)
              {
                obj_Link(in2, new LinkEventArgs(LinkType.Out, in2.xLinks.xOut));
                obj_Link(target, new LinkEventArgs(LinkType.In2, target.xLinks.xIn2));
              }
              NoiseObject in3 = GetObjectByName(ids[4]);
              if (in3 != null)
              {
                obj_Link(in3, new LinkEventArgs(LinkType.Out, in3.xLinks.xOut));
                obj_Link(target, new LinkEventArgs(LinkType.In3, target.xLinks.xIn3));
              }
              NoiseObject in4 = GetObjectByName(ids[5]);
              if (in4 != null)
              {
                obj_Link(in4, new LinkEventArgs(LinkType.Out, in4.xLinks.xOut));
                obj_Link(target, new LinkEventArgs(LinkType.In4, target.xLinks.xIn4));
              }
            }
            OnLoad("");
              }
            }
            catch (Exception )
            {
            }
              }
        }
예제 #3
0
        private void MenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            xLogo.Visibility = Visibility.Collapsed;

              mCreateAt.Y += 50;
              if (mCreateAt.Y > Height - 100)
              {
            mCreateAt.Y = 50;
            mCreateAt.X += 50;
              }

              MenuItem item = e.Source as MenuItem;
              int type = 0;
              if (item.Header       as string == "New Generator") type = 0;
              else if (item.Header  as string == "New In Modifier") type = 2;
              else if (item.Header  as string == "New Out Modifier") type = 1;
              else if (item.Header  as string == "New Combiner") type = 3;

              NoiseObject obj = new NoiseObject(type);
              obj.Width = 200;
              obj.Height = 200;
              xBoard.Children.Add(obj);
              Canvas.SetLeft(obj, mCreateAt.X);
              Canvas.SetTop(obj, mCreateAt.Y);
              Canvas.SetZIndex(obj, 1);
              mObjects.Add(obj);
              Canvas.SetZIndex(obj, 2);

              GradientDef def = xGradientPicker.SelectedItem as GradientDef;
              obj.SetGradient(def);

              obj.xGradient.ItemsSource = xGradient.GradientDefs;
              obj.xGradient.SelectedItem = def;
              obj.mLocalGradient = false;

              obj.Raise += new EventHandler<EventArgs>(obj_Raise);
              obj.Link += new EventHandler<LinkEventArgs>(obj_Link);
              obj.Erase += new EventHandler<LinkEventArgs>(obj_Erase);
              obj.NeedUpdate += new EventHandler<EventArgs>(obj_Move);
              obj.NeedApply += new EventHandler<EventArgs>(obj_NeedApply);
              obj.Relink += new EventHandler<EventArgs>(obj_Relink);
              obj.Close += new EventHandler<EventArgs>(obj_Close);
              obj.Rendered += new EventHandler<EventArgs>(obj_Rendered);
        }
예제 #4
0
        void obj_Raise(object sender, EventArgs e)
        {
            NoiseObject el = sender as NoiseObject;

              foreach (NoiseObject child in mObjects)
              {
            Canvas.SetZIndex(child, 1);
            child.Select(false);
              }
              Canvas.SetZIndex(el, 2);
              el.Select(true);

              xParameters.DataContext = el.Parameters;
              mCurrentObj = el;
              xRange.Text = el.Range;
        }
예제 #5
0
 void Cascade(NoiseObject obj)
 {
     foreach (LinkLine l in mLines)
       {
     if (l.Source == obj)
     {
       l.Target.Apply();
       Cascade(l.Target);
     }
       }
 }