Ejemplo n.º 1
0
        private void lbDestination_Drop(object sender, System.Windows.DragEventArgs e)
        {
            IList selected = (sender as System.Windows.Controls.ListBox).SelectedItems;

            ObservableCollection <object> dropped;
            NTFunctions dest   = null;
            NTFunctions source = null;

            if (sender == lbDestination)
            {
                source = m_SourceFunctions;
                dest   = m_DestinationFunctions;
            }
            else
            {
                dest   = m_SourceFunctions;
                source = m_DestinationFunctions;
            }

            try
            {
                dropped = e.Data.GetData("System.Windows.Controls.SelectedItemCollection") as ObservableCollection <object>;
                object[] objs = dropped.ToArray <object>();

                foreach (object o in objs)
                {
                    if (o.GetType().GetInterface(typeof(INTFunction).ToString()) != null)
                    {
                        source.Remove(o as INTFunction);
                    }

                    dest.Add(o as INTFunction);

                    if (sender == lbDestination)
                    {
                        AddFunction(o as INTFunction);
                    }
                    else
                    {
                        RemoveFunction(o as INTFunction);
                    }
                }
            }
            catch {}
        }
Ejemplo n.º 2
0
        private void InitFunctions()
        {
            m_SourceFunctions      = new NTFunctions();
            m_DestinationFunctions = new NTFunctions();

            INTFunction f1 = new EulerPhi();

            f1.Message += new NumberTheoryMessageDelegate(f1_Message);
            f1.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f1);

            INTFunction f3 = new EulerPhiValues();

            f3.Message += new NumberTheoryMessageDelegate(f1_Message);
            f3.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f3);

            INTFunction f2 = new Tau();

            f2.Message += new NumberTheoryMessageDelegate(f1_Message);
            f2.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f2);

            INTFunction f4 = new Rho();

            f4.Message += new NumberTheoryMessageDelegate(f1_Message);
            f4.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f4);

            INTFunction f5 = new EulerPhiSum();

            f5.Message += new NumberTheoryMessageDelegate(f1_Message);
            f5.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f5);

            INTFunction f6 = new TauValues();

            f6.Message += new NumberTheoryMessageDelegate(f1_Message);
            f6.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f6);

            INTFunction f7 = new PiX();

            f7.Message += new NumberTheoryMessageDelegate(f1_Message);
            f7.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f7);

            INTFunction f8 = new GCD();

            f8.Message += new NumberTheoryMessageDelegate(f1_Message);
            f8.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f8);

            INTFunction f9 = new LCM();

            f9.Message += new NumberTheoryMessageDelegate(f1_Message);
            f9.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f9);

            INTFunction f10 = new ModInv();

            f10.Message += new NumberTheoryMessageDelegate(f1_Message);
            f10.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f10);

            INTFunction f11 = new ExtEuclid();

            f11.Message += new NumberTheoryMessageDelegate(f1_Message);
            f11.OnStop  += new VoidDelegate(f1_OnStop);
            m_SourceFunctions.Add(f11);

            lbDestination.DataContext = m_DestinationFunctions;
            lbSource.DataContext      = m_SourceFunctions;
        }