Exemplo n.º 1
0
        static void Main(string[] args)
        {
            sDelegate = StringCallback;

            TestClass testObj = new TestClass();

            voidInstance = testObj.Func1;
            voidInstance();

            voidInstance = testObj.Func2;
            voidInstance();

            Console.WriteLine();

            voidInstance += testObj.Func1;
            voidInstance += testObj.Func1;
            voidInstance += testObj.Func1;
            voidInstance += testObj.Func2;
            voidInstance();

            int c = testObj.Add(3, 5);

            testObj.ReturnResultWithCallback("Video", "Game", sDelegate);

            intDelegate += testObj.Sub;
            intDelegate += testObj.Add;
            intDelegate += testObj.Sub;

            int result = intDelegate(10, 2);

            Console.WriteLine("c = " + c);
            Console.WriteLine("result = " + result);

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Print(string st, StringDelegate method)
        {
            if (method != null)
                st = method(st);

            Console.WriteLine(st);
        }
Exemplo n.º 3
0
    public void Request(StringDelegate SuccessCallback = null, StringDelegate FailedCallback = null)
    {
        var req = new LogEventRequest();

        foreach (var item in dictionary)
        {
            req.SetEventAttribute(item.Key, item.Value.ToString());
        }
        req.SetEventKey(eventKey).Send((response) =>
        {
            if (response.HasErrors)
            {
                Debug.Log(eventKey + " request failed!\n" + response.Errors.JSON);
                if (FailedCallback != null)
                {
                    FailedCallback(response.JSONString);
                }
            }
            else
            {
                Debug.Log(eventKey + " request success!\n" + response.JSONString);
                if (SuccessCallback != null)
                {
                    SuccessCallback(response.JSONString);
                }
            }
        });
    }
Exemplo n.º 4
0
        static void Main05()
        {
            string mid = ", middle part,";

            //单参数
            StringDelegate lambda = param => {
                param += mid;
                param += " and this was added to the string.";
                return(param);
            };

            Console.WriteLine(lambda("Start of string"));

            Console.WriteLine();
            Console.WriteLine("----------------------------");
            Console.WriteLine();

            //多参数
            Func <double, double, double> mulFunc = (x, y) => x * y;

            Console.WriteLine(mulFunc(5, 6));

            Console.WriteLine();
            Console.WriteLine("----------------------------");
            Console.WriteLine();

            Action <Book> testAction = book => Console.WriteLine(book.Title);
            Book          book1      = new Book(27, "C#之美.");

            testAction(book1);
            Console.WriteLine();
        }
Exemplo n.º 5
0
        private void SafeChangeCurrent(string text)
        {
            if (currInfo.InvokeRequired)
            {
                text = "Information: " + _character.getInfoGathered();
                var del = new StringDelegate(SafeChangeCurrent);
                currInfo.Invoke(del, new object[] { text });
            }
            else
            {
                currInfo.Text = "Information: " + _character.getInfoGathered();
                if (_character.getInfoGathered() > HighestInfo)
                {
                    ChangeHighestScores();
                }
            }

            if (currSamp.InvokeRequired)
            {
                text = "Samples: " + _character.getInfoGathered();
                var del = new StringDelegate(SafeChangeCurrent);
                currSamp.Invoke(del, new object[] { text });
            }
            else
            {
                currSamp.Text = "Samples: " + _character.getSampleCollected();
                if (_character.getSampleCollected() > HighestSamp)
                {
                    ChangeHighestScores();
                }
            }
        }
Exemplo n.º 6
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            try
            {
                LoopingAnimationBase interaction = ii as LoopingAnimationBase;

                if (interaction.Paused)
                {
                    reason = delegate
                    {
                        return(Common.Localize("Pause:Disabled"));
                    };

                    return(false);
                }

                return(base.Test(ii, out reason));
            }
            catch (Exception e)
            {
                reason = null;

                Common.Exception(ii.InstanceActor, e);
                return(false);
            }
        }
Exemplo n.º 7
0
    public void Request(string eventKey, Dictionary <string, object> dictionary, StringDelegate SuccessCallback, StringDelegate FailedCallback = null)
    {
        var req = new LogEventRequest();

        req.SetEventKey(eventKey);
        foreach (var item in dictionary)
        {
            if (item.Value != null)
            {
                req.SetEventAttribute(item.Key, item.Value.ToString());
            }
            else
            {
                Debug.Log(item.Key + " has null value!");
            }
        }
        req.Send((response) =>
        {
            if (response.HasErrors)
            {
                if (FailedCallback != null)
                {
                    FailedCallback(response.JSONString);
                }
            }
            else
            {
                SuccessCallback(response.JSONString);
            }
        });
    }
Exemplo n.º 8
0
 private static void OnAuthFinished(ILoginResult result, StringDelegate tmpStringDelegate)
 {
     if (result.Error != null)
     {
         //there is an error
         Debug.Log(result.Error);
         if (tmpStringDelegate != null)
         {
             tmpStringDelegate("Error on authentification");
         }
     }
     else
     {
         //no errir
         if (FB.IsLoggedIn)
         {
             if (tmpStringDelegate != null)
             {
                 tmpStringDelegate("Sucess");
             }
             Debug.Log("logged in auth finished");
         }
         else
         {
             if (tmpStringDelegate != null)
             {
                 tmpStringDelegate("You canceled e.e");
             }
             Debug.Log("not logged in auth finished");
         }
     }
 }
Exemplo n.º 9
0
        public void MulticastDelegate()
        {
            StringDelegate StringDel = HelperClass.StringMethod;

            StringDel += HelperClass.StringMethod2;
            StringDel("Chapter 5 - Multicast delegate Method1");
        }
Exemplo n.º 10
0
    public static void Main()
    {
        StringDelegate <string> d = Program.PrintString;
        Program instance          = new Program();

        d += instance.PrintStringLength;
        d += delegate(string str)
        {
            Console.WriteLine("Uppercase: {0}", str.ToUpper());
            return(3);
        };

        int result = d("some string value");

        Console.WriteLine("Returned result: {0}", result);

        Func <string, int> predefinedIntParse = int.Parse;
        int number = predefinedIntParse("10");

        Console.WriteLine(number);

        Action <object> predefinedAction = Console.WriteLine;

        predefinedAction(1000);
    }
Exemplo n.º 11
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            try
            {
                LoopingAnimationBase interaction = ii as LoopingAnimationBase;

                if (interaction.Paused)
                {
                    reason = delegate
                    {
                        return Common.Localize("Pause:Disabled");
                    };

                    return false;
                }

                return base.Test(ii, out reason);
            }
            catch (Exception e)
            {
                reason = null;

                Common.Exception(ii.InstanceActor, e);
                return false;
            }
        }
Exemplo n.º 12
0
        public void shuher(object source, EventArgs e)
        {
            if (!forcibly)
            {
                //война с мусором

                /* Int32 totalMemory = Convert.ToInt32(GC.GetTotalMemory(false));
                 * log(Convert.ToString(totalMemory));
                 * if (totalMemory > 526200)
                 * {
                 * log("collect!!!");
                 *   GC.Collect();
                 *   GC.WaitForPendingFinalizers();
                 * }*/
                Point newpoint = Cursor.Position;
                if (newpoint != mouse_pos && is_mining_started)
                {
                    stringDelegate = new AutoMiner.StringDelegate(log);
                    richTextBox1.Invoke(stringDelegate, "mouse moving", Color.LightBlue);
                    mining_pause();
                    goto e;
                }
                mouse_pos = Cursor.Position;

                if (capture_image_is_moving() && is_mining_started)
                {
                    stringDelegate = new AutoMiner.StringDelegate(log);
                    richTextBox1.Invoke(stringDelegate, "screen changing", Color.LightBlue);
                    mining_pause();
                    goto e;
                }
                e :;
            }
        }
Exemplo n.º 13
0
        public static int test_0_unbox_this()
        {
            int            x  = 10;
            StringDelegate d5 = new StringDelegate(x.ToString);

            return(d5() == "10" ? 0 : 1);
        }
Exemplo n.º 14
0
        public static void Main()
        {
            int sumDelegateAddedMethods           = 1;                   // delegate add anonymous method
            StringDelegate <string> multiDelegate = delegate(string str) // short syntax
            {
                Console.WriteLine("\nUpperCase {0}", str.ToUpper());
                return(1);
            };

            // Add more methods (+=)
            multiDelegate           += MultiDelegates.PrintStringOne; // static method
            sumDelegateAddedMethods += multiDelegate("PrintStringOne()");

            MultiDelegates instance = new MultiDelegates();

            multiDelegate           += instance.PrintStringTwo; // instance method
            sumDelegateAddedMethods += multiDelegate("PrintStringTwo()");

            multiDelegate           += MultiDelegates.PrintStringThree; // static method
            sumDelegateAddedMethods += multiDelegate("Print String Three()");
            Console.WriteLine("\nDelegate added {0} methods.", sumDelegateAddedMethods);

            multiDelegate -= MultiDelegates.PrintStringThree;
            Console.Write("\nDelegate removed PrintStringThree ->");
            multiDelegate("Print only:");
        }
Exemplo n.º 15
0
        public FileManager(string filename, StringDelegate onNewExerciseDetected)
        {
            if (onNewExerciseDetected == null)
            {
                throw new ArgumentNullException("onNewExerciseDetected");
            }
            if (string.IsNullOrWhiteSpace(filename))
            {
                throw new ArgumentNullException("filename");
            }

            try
            {
                _NewExerciseDetected = onNewExerciseDetected;

                _Filename = Path.GetFullPath(filename);

                _FileSystemWatcher = new FileSystemWatcher();
                _FileSystemWatcher.IncludeSubdirectories = false;
                _FileSystemWatcher.NotifyFilter          = NotifyFilters.LastWrite;
                _FileSystemWatcher.Filter              = Path.GetFileName(_Filename);
                _FileSystemWatcher.Path                = Path.GetDirectoryName(_Filename);
                _FileSystemWatcher.Changed            += new FileSystemEventHandler(_FileSystemWatcher_Changed);
                _FileSystemWatcher.Error              += new ErrorEventHandler(_FileSystemWatcher_Error);
                _FileSystemWatcher.EnableRaisingEvents = true;

                ReadAndClearFile(_Filename);
            }
            catch (Exception ex)
            {
                LOG.Error(ex);
                _FileSystemWatcher = null;
            }
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            // Init StringDel member equal to function x
            StringDelegate strUpp = ToUpperCase;

            Console.WriteLine("This is the UPPERCASE delegate function result");
            strUpp("=> this is now uppercase");
            strUpp.Invoke("=> also this too!");

            StringDelegate strLow = ToLowerCase;

            Console.WriteLine("\nTHIS IS THE lowercase DELEGATE FUNCTION result");
            strLow("==> this is now LOWERcase");
            strLow.Invoke("==> SAME AS THIS ONE\n");

            strLow = ToUpperCase; // Set strLow to diff function
            strLow("=> We have reassigned this delegate variable to strLow but to the Uppercase function!\n");

            strLow = ToLowerCase; // Reset strLow back
            Writing("This is some text", strUpp);

            Console.WriteLine();
            Writing1("ALSO MORE TEXT", strLow);

            Console.ReadLine();
        }
Exemplo n.º 17
0
        public override bool Test(InteractionInstance inst, out StringDelegate reason)
        {
            if (!base.Test(inst, out reason)) return false;

            OmniCareer career = Career as OmniCareer;
            return (career != null);
        }
Exemplo n.º 18
0
        /// <summary>
        /// displayText is used to send a new message to log view. New messages will appear on a new line with a numbered line indicator.
        /// </summary>
        /// <param name="s"></param>
        public void displayText(string s)
        {
            // if call is coming from thread other than that of richResponse
            // the text is sent to a delegated function and which will call displayText on the same thread

            if (this.richResponse.InvokeRequired)
            {
                StringDelegate d = new StringDelegate(displayText);
                this.Invoke(d, new object[] { s });
            }
            else
            {
                // remove first string from output
                output = output.Substring(output.IndexOf("\n") + 1);

                // add the new string
                output += "\n" + response++ + ": " + s;

                // display it
                richResponse.Text = output;
            }

            //output = output.Substring(output.IndexOf("\n") + 1);
            //output += "\n" + response++ + ": " + s;
        }
Exemplo n.º 19
0
        public void SetList(string name, StringDelegate cb)
        {
            var pop = GetName(name).GetComponent <UIPopupList> ();

            EventDelegate.Add(pop.onChange, delegate {
                cb(pop.value);
            });
        }
Exemplo n.º 20
0
        /*------------------------ FIELDS REGION ------------------------*/

        /*------------------------ METHODS REGION ------------------------*/
        public void Main()
        {
            StringDelegate stringDelegate = PrintAndToUpperString;

            stringDelegate += PrintAndToLowerString;

            stringDelegate?.Invoke("Abc");
        }
Exemplo n.º 21
0
    public static void Loggin(StringDelegate resultt)
    {
        List <string> permissions = new List <string> ();

        permissions.Add("public_profile");
        permissions.Add("publish_actions");
        FB.LogInWithReadPermissions(permissions, (ILoginResult result) => OnAuthFinished(result, resultt));
    }
 public static void Main()
 {
     var del = new StringDelegate<string>(PrintString); // triabva da se ukaje v diamantentie skobi kakav ste bade parametara na Generic delegata
     var md = new GenericDelegates(); // instancia na tekustia klas(sazdavam obekt)
     del += md.PrintStringLength;
     var result = del("Pesho");
     Console.WriteLine(result); // ste otpechata 2- rezultata ot poslednia method, a otgore ste otpechata komandite ot vseki method
 }
Exemplo n.º 23
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            if (!base.Test(ii, out reason))
            {
                return(false);
            }

            return((base.Career as ProSports).HasWinLossRecordMetric());
        }
Exemplo n.º 24
0
        private void InvokeOnNewImeComposition(string s)
        {
            StringDelegate d = OnNewImeComposition;

            if (d != null)
            {
                d(s);
            }
        }
Exemplo n.º 25
0
        static void Print(string st, StringDelegate method)
        {
            if (method != null)
            {
                st = method(st);
            }

            Console.WriteLine(st);
        }
Exemplo n.º 26
0
        public SelectPdfDialog(ref StringDelegate loadPdfDelegate)
        {
            InitializeComponent();

            var uc = new PdfHost();
            this.WindowsFormHost.Child = uc;            

            loadPdfDelegate += uc.LoadPdf;
        }        
Exemplo n.º 27
0
 private void socket_CouldNotConnect(string SocketID)
 {
     try {
         StringDelegate couldNotConnectEvent = new StringDelegate(CouldNotConnect);
         _invoke.Invoke(couldNotConnectEvent, SocketID);
     } catch (Exception ex) {
         throw ex;
     }
 }
Exemplo n.º 28
0
        public EditPartDialog(ref StringDelegate loadPdf)
        {
            InitializeComponent();

            var uc = new UserClient.Controls.PdfHost();
            this.WindowsFormsHost.Child = uc;

            loadPdf += uc.LoadPdf;
        }
	public static void Main()
	{
	    var del = new StringDelegate(PrintString);
	    var md = new MultiDelegates();
	    del += md.PrintStringLength;

	    int result = del("Pesho");
	    Console.WriteLine(result);
	}
Exemplo n.º 30
0
        public Heartbeat(string instanceName, BoolDelegate greenCondition, BoolDelegate yellowCondition, StringDelegate callerStatusString)
        {
            heartbeatStatus = new HeartbeatStatus();
            heartbeatStatus.InstanceName = instanceName;

            _greenCondition += greenCondition;
            _yellowCondition += yellowCondition;
            _callerStatusString += callerStatusString;
        }
Exemplo n.º 31
0
 /// <summary>
 ///
 /// </summary>
 public static void RequestAddress(StringDelegate i_req)
 {
     if (main == null)
     {
         Log.e("BluetoothScannerGUI", "No BluetoothScannerGUI instance here.");
         return;
     }
     main.AddRequest(i_req);
 }
Exemplo n.º 32
0
        private static string ReadProcessOutput(Process cmdLineProcess,
                                                ref string errorMessage, string fileName)
        {
            StringDelegate outputStreamAsyncReader
                = new StringDelegate(cmdLineProcess.StandardOutput.ReadToEnd);
            StringDelegate errorStreamAsyncReader
                = new StringDelegate(cmdLineProcess.StandardError.ReadToEnd);

            IAsyncResult outAR
                = outputStreamAsyncReader.BeginInvoke(null, null);
            IAsyncResult errAR = errorStreamAsyncReader.BeginInvoke(null, null);

            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                /* WaitHandle.WaitAll fails on single-threaded
                 * apartments. Poll for completion instead:
                 */
                while (!(outAR.IsCompleted && errAR.IsCompleted))
                {
                    /* Check again every 10 milliseconds: */
                    Thread.Sleep(10);
                }
            }
            else
            {
                WaitHandle[] arWaitHandles = new WaitHandle[2];
                arWaitHandles[0] = outAR.AsyncWaitHandle;
                arWaitHandles[1] = errAR.AsyncWaitHandle;

                if (!WaitHandle.WaitAll(arWaitHandles))
                {
                    throw new Exception(
                              String.Format("Command line aborted: {0}", fileName));

                    /* Note: arguments aren't also shown in the
                     * exception as they might contain privileged
                     * information (such as passwords).
                     */
                }
            }

            string results = outputStreamAsyncReader.EndInvoke(outAR);

            errorMessage = errorStreamAsyncReader.EndInvoke(errAR);

            /* At this point the process should surely have exited,
             * since both the error and output streams have been fully read.
             * To be paranoid, let's check anyway...
             */
            if (!cmdLineProcess.HasExited)
            {
                cmdLineProcess.WaitForExit();
            }

            return(results);
        }
        private static string ReadProcessOutput(Process cmdLineProcess, 
                ref string errorMessage, string fileName)
        {
            int iTimeoutCounter=0;
            StringDelegate outputStreamAsyncReader
               = new StringDelegate(cmdLineProcess.StandardOutput.ReadToEnd);
            StringDelegate errorStreamAsyncReader
               = new StringDelegate(cmdLineProcess.StandardError.ReadToEnd);

            IAsyncResult outAR
                = outputStreamAsyncReader.BeginInvoke(null, null);
            IAsyncResult errAR = errorStreamAsyncReader.BeginInvoke(null, null);

            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                /* WaitHandle.WaitAll fails on single-threaded
                 * apartments. Poll for completion instead:
                 */
                while (!(outAR.IsCompleted && errAR.IsCompleted) && iTimeoutCounter<10*5*60)
                {
                    /* Check again every 10 milliseconds: */
                    Thread.Sleep(100);
                    iTimeoutCounter++;
                }
            }
            else
            {
                WaitHandle[] arWaitHandles = new WaitHandle[2];
                arWaitHandles[0] = outAR.AsyncWaitHandle;
                arWaitHandles[1] = errAR.AsyncWaitHandle;

                if (!WaitHandle.WaitAll(arWaitHandles))
                {
                    //throw new CommandLineException(
                      //  String.Format("Command line aborted: {0}", fileName));
                    /* Note: arguments aren't also shown in the
                     * exception as they might contain privileged
                     * information (such as passwords).
                     */
                }
            }

            string results = outputStreamAsyncReader.EndInvoke(outAR);
            errorMessage = errorStreamAsyncReader.EndInvoke(errAR);

            /* At this point the process should surely have exited,
             * since both the error and output streams have been fully read.
             * To be paranoid, let's check anyway...
             */
            if (!cmdLineProcess.HasExited)
            {
                cmdLineProcess.WaitForExit();
            }

            return results;
        }
Exemplo n.º 34
0
        static void Main()
        {
            StringDelegate strDel = DisplayUpper;

            strDel += DisplayLength;
            strDel("accenture");
            strDel -= DisplayUpper;
            strDel("hello");
            Console.ReadLine();
        }
Exemplo n.º 35
0
        public void RefMethod(ref int a)
        {
            // Method invoked.
            StringDelegate delegateInstance = MethodInvokedEvent;

            if (delegateInstance != null)
            {
                delegateInstance("RefMethod");
            }
        }
Exemplo n.º 36
0
        public void SimpleMethod(int a, string b, EventArgs c)
        {
            // Method invoked.
            StringDelegate delegateInstance = MethodInvokedEvent;

            if (delegateInstance != null)
            {
                delegateInstance("SimpleMethod");
            }
        }
Exemplo n.º 37
0
        public void VariableParametersTest(params object[] parameters)
        {
            // Method invoked.
            StringDelegate delegateInstance = MethodInvokedEvent;

            if (delegateInstance != null)
            {
                delegateInstance("VariableParametersTest");
            }
        }
Exemplo n.º 38
0
        void draw_START()
        {
            time_of_start = total_time;

            stringDelegate = new AutoMiner.StringDelegate(log);
            richTextBox1.Invoke(stringDelegate, DateTime.Now.TimeOfDay.ToString().Substring(0, 8) + "  started", Color.MediumSpringGreen);

            drawDelegate = new AutoMiner.DrawDelegate(drawLine);
            picBox.Invoke(drawDelegate, Color.Black, time_of_stop, 10 + day * 20 + day, total_time, 10 + day * 20 + day);
        }
Exemplo n.º 39
0
        private static void DelegatesDemo()
        {
            StringDelegate <string> d = MultiDelegates.PrintString;

            d += new MultiDelegates().PrintStringLength;

            int result = d("some string value");

            Console.WriteLine("Returned result: {0}", result);
        }
Exemplo n.º 40
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            if (!base.Test(ii, out reason)) return false;

            Business career = OmniCareer.Career<Business>(Career);
            if ((career != null) && (career.CurLevel != null))
            {
                return OmniCareer.HasMetric<MetricMeetingsHeld>(Career);
            }
            return false;
        }
Exemplo n.º 41
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            if (!base.Test(ii, out reason)) return false;

            Education career = OmniCareer.Career<Education>(Career);
            if ((career != null) && (career.CurLevel != null))
            {
                return OmniCareer.HasMetric<MetricLecturesGiven>(Career);
            }
            return false;
        }
    public static void Main()
    {
        var del = new StringDelegate(MultiDelegatesMain.PrintString); // statichen e i se izvikva direktno ot klasa v koito e

        var md = new MultiDelegatesMain(); // instancia na tekustia klas(sazdavam obekt)
        del += md.PrintStringLength;

        var result = del("Pesho");
        Console.WriteLine(result);

            // ste otpechata 2- rezultata ot poslednia method, a otgore ste otpechata komandite ot vseki method
    }
Exemplo n.º 43
0
        public ServerRealTick()
        {

            
            newProviderName = Providers.RealTick;
            _bw = new System.ComponentModel.BackgroundWorker();
            _bw.DoWork += new System.ComponentModel.DoWorkEventHandler(_bw_DoWork);
            newRegisterSymbols += new SymbolRegisterDel(ServerRealTick_newRegisterSymbols);
            newSendOrderRequest += new OrderDelegateStatus(ServerRealTick_newSendOrderRequest);
            newOrderCancelRequest += new LongDelegate(ServerRealTick_newOrderCancelRequest);
            newFeatureRequest += new MessageArrayDelegate(ServerRealTick_newFeatureRequest);
            newPosList += new PositionArrayDelegate(ServerRealTick_gotSrvPosList);
            newAcctRequest += new StringDelegate(ServerRealTick_newAcctRequest);
        }
Exemplo n.º 44
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            try
            {
                LoopingAnimationBase interaction = ii as LoopingAnimationBase;

                mIterations = interaction.Iterations;

                return base.Test(ii, out reason);
            }
            catch (Exception e)
            {
                reason = null;

                Common.Exception(ii.InstanceActor, e);
                return false;
            }
        }
 void shell_NewStatusToReport(string status)
 {
     if (textBoxStatus.InvokeRequired)
     {
         StringDelegate sd = new StringDelegate(shell_NewStatusToReport);
         textBoxStatus.Invoke(sd, new object[1] { status });
     }
     else
     {
         bool scrollToBottom = true;
         if (textBoxStatus.SelectionStart != textBoxStatus.Text.Length)
             scrollToBottom = false;
         textBoxStatus.Text += status + "\r\n";
         if (scrollToBottom)
         {
             textBoxStatus.SelectionStart = textBoxStatus.Text.Length;
             textBoxStatus.ScrollToCaret();
         }
     }
 }
Exemplo n.º 46
0
    public static void Main()
    {
        MulticastDelegatesExample example = 
            new MulticastDelegatesExample();

        StringDelegate printDelegate =
            new StringDelegate(example.PrintString);

        PrintInvocationList(printDelegate);
        // Prints: ( PrintString )

        printDelegate = (StringDelegate)
            Delegate.Combine(printDelegate, printDelegate);
        PrintInvocationList(printDelegate);
        // Prints: ( PrintString PrintString )

        StringDelegate printLengthDelegate =
            new StringDelegate(example.PrintStringLength);

        StringDelegate printWithDateDelegate =
            new StringDelegate(PrintStringWithDate);

        StringDelegate combinedDelegate = (StringDelegate)
            Delegate.Combine(printDelegate, printLengthDelegate);

        PrintInvocationList(combinedDelegate);
        // Prints: ( PrintString PrintStringLength )

        combinedDelegate = (StringDelegate)
            Delegate.Combine(combinedDelegate, printWithDateDelegate);

        PrintInvocationList(combinedDelegate);
        // Prints: ( PrintString PrintStringLength PrintStringWithDate )

        // Invoke the delegate
        combinedDelegate("test");
    }
Exemplo n.º 47
0
        //public void ProcessLogMulti(string text)
        //{
        //    writeGlobal("MULTI", text);
        //    writeMulti(text);
        //}
        public void RegisterID(string ID)
        {
            if (InvokeRequired)
            {
                StringDelegate registerIDDelegate = new StringDelegate(RegisterID);
                BeginInvoke(registerIDDelegate, new object[] { ID });
            }
            else
            {
                LogBox box = searchTextBox(ID);

                if (box == null)
                {
                    box = createIDTab(ID,true,true);
                    _hashtable.Add(ID, box);
                }
            }
        }
 public void SetCurrentItem(string txt)
 {
     if (Thread.CurrentThread != Dispatcher.Thread)
     {
         StringDelegate _delegate = new StringDelegate(SetCurrentItem);
         Dispatcher.Invoke(DispatcherPriority.Normal, _delegate, txt);
     }
     else
     {
         lblCurrentItem.Text = txt;
     }
 }
Exemplo n.º 49
0
        private void AddTextToConsole(string text)
        {
            if (this.Console.InvokeRequired)
            {
                StringDelegate sd = new StringDelegate(AddTextToConsole);
                this.Console.Invoke(sd, new object[] { text });
                return;
            }

            this.Console.Text += text;
        }
Exemplo n.º 50
0
 private void ReadStream(StreamReader reader, char firstChar, StringDelegate del)
 {
     StringBuilder buffer = new StringBuilder(256);
     buffer.Append(firstChar);
     lock (this)
     {
         while (reader.Peek() > -1)
         {
             char ch = (char)reader.Read();
             buffer.Append(ch);
         }
         if (del != null)
             del(buffer.ToString());
     }
 }
Exemplo n.º 51
0
        public override bool Test(InteractionInstance ii, out StringDelegate reason)
        {
            if (!base.Test(ii, out reason)) return false;

            return (base.Career as ProSports).HasWinLossRecordMetric();
        }
Exemplo n.º 52
0
        public frmDownloader(string urldownload,string urlstore,bool top)
        {
            try
            {
                //
                // Required for Windows Form Designer support
                //
                InitializeComponent();

                //
                // TODO: Add any constructor code after InitializeComponent call
                //
                //this.fileNameChanger = new StringDelegate(this.ChangeFileName);
                this.statusChanger = new StringDelegate(this.ChangeStatus);
                this.singlePercentChanger = new IntDelegate(this.ChangeSinglePercent);
                //this.totalPercentChanger = new IntDelegate(this.ChangeTotalPercent);
                //this.activeStateChanger = new BoolsDelegate(this.ChangeActiveState);

                //initialize the urls settings.
                this.strurldownload=urldownload;
                this.strurlStore=urlstore;
                this.TopMost=true;
                this.ShowInTaskbar=false;
                this.chkDwndCompl.Checked=true;
                this.chkDwndCompl.Enabled=false;
                this.btnCancel.Enabled =false;
            }
            catch(Exception exp)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Managecontents==>frmDownloader.cs 178",exp,null,false);

            }
        }
Exemplo n.º 53
0
 public void SetTitleText(string txt)
 {
     if (lblTitle.InvokeRequired)
     {
         StringDelegate _delegate = new StringDelegate(SetTitleText);
         lblTitle.Invoke(_delegate, new object[] { txt });
     }
     else
     {
         lblTitle.Text = txt;
     }
 }
Exemplo n.º 54
0
 public EditPartVM()
 {
     loadPdf = new StringDelegate(delegate (string a) { });
 }
Exemplo n.º 55
0
    IEnumerator WaitForRequest(WWW www, StringDelegate callback)
    {
        yield return www;

        // check for errors
        if (www.error == null)
        {
            callback(www.text);
        }
    }
        private void SerialReadThread(string portName)
        {
            StringDelegate lineReceivedDelegate = new StringDelegate(SerialLineReceived);
            string outstandingText = String.Empty;
            byte[] buf = new byte[1];
            sp = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
            sp.ReadTimeout = 1000;
            sp.Open();

            while (true)
            {
                try
                {
                    int res = sp.Read(buf, 0, 1);

                    if (res <= 0) continue;
                    if (buf[0] == 10)
                    {
                        GT.Program.BeginInvoke(lineReceivedDelegate, outstandingText);
                        outstandingText = String.Empty;
                    }
                    else if (buf[0] < 128)
                    {
                        outstandingText = outstandingText + (char)buf[0];
                    }
                }
                catch
                {
                    Debug.Print("Exception reading serial line");
                    Thread.Sleep(100);
                }
            }
        }
Exemplo n.º 57
0
 public EditPartVM(int id)
 {
     this.id = id;
     loadPdf = new StringDelegate(delegate (string a) { });
 }
Exemplo n.º 58
0
 public string CallStringDelegate(StringDelegate d)
 {
     return d();
 }
Exemplo n.º 59
0
 public SelectPdfDialogVM(int partID)
 {
     this.partID = partID;
     Setup();
     this.loadPdf = new StringDelegate(delegate (string a) { });
 }
Exemplo n.º 60
0
	public static int test_0_unbox_this () {
		int x = 10;
		StringDelegate d5 = new StringDelegate (x.ToString);
		return d5 () == "10" ? 0 : 1;
	}