Example #1
0
        void camera_NewFrame(object sender, EventArgs e)
        {
            Invalidate();

            if (camera != null)
            {
                try
                {
                    camera.Lock();
                    filterBmp        = new Bitmap(camera.LastFrame);
                    PCT_CANVAS.Image = Convolver.Execute(filterBmp, SOBEL_Gx);//Sobel.Execute(YUV.Execute(filterBmp));

                    MyDelegates.SetControlTextValue(LBL_IMAGE_SIZE, camera.LastFrame.Size);
                }
                catch (Exception ex)
                {
                    MyDelegates.SetControlTextValue(LBL_IMAGE_SIZE, ex);
                }
                finally
                {
                    camera.Unlock();
                }

                if (camera.FramesReceived % 12 == 0)
                {
                    thread = new Thread(Clean);
                    thread.Start();
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Program     objP        = new Program();
            MyDelegates objDelegate = new MyDelegates(objP.MethodOne); // pointing To Method.

            objDelegate += objP.MethodTwo;
            objDelegate += objP.MethodThree;
            objDelegate();
        }
Example #3
0
        static void Main(string[] args)
        {
            MyDelegates[] del  = new MyDelegates[10];
            Random        rnd  = new Random();
            Methods       meth = new Methods();

            for (int i = 0; i < 10; i++)
            {
                int a = Convert.ToInt32(rnd.Next(1, 5));
                switch (a)
                {
                case 1:
                    del[i] = meth.Add;
                    break;

                case 2:
                    del[i] = meth.Multiply;
                    break;

                case 3:
                    del[i] = meth.Division;
                    break;

                case 4:
                    del[i] = meth.Subtraction;
                    break;

                case 5:
                    del[i] = meth.Pow;
                    break;
                }
            }
            double num;

            Console.WriteLine("Введите число, над которым хотите проделать операции");
            num = double.Parse(Console.ReadLine());
            for (int j = 0; j < 10; j++)
            {
                num = del[j](num);
            }
        }
Example #4
0
        /// <p>
        /// Recursive method that iterates through the directory files
        /// applying the same process
        /// <p>
        private void ProcessFolder()
        {
            DirectoryInfo dirInfo = Directory.CreateDirectory(info.DirectoryName + @"\PROCESS");

            for (int i = 0; i < fileEntries.Length; i++)
            {
                try
                {
                    filterBmp = new Bitmap(fileEntries[i]);
                    ColorFinder.Execute(filterBmp, MIN, MAX).Save(dirInfo.FullName + @"\000" + i + ".PNG");
                }
                catch (Exception) { }
            }
            MyDelegates.SetControlTextValue(LBL_STAT, "Done");
        }
Example #5
0
        internal void _GetFonts()
        {
            try
            {
                MyFont = new UiFontConf();
                foreach (UiFontConf i in MainWindow.SqliteSource.EnumUiFont())
                {
                    MyFont.Brush     = i.Brush;
                    MyFont.FontSize  = i.FontSize;
                    MyFont.Fontname  = i.Fontname;
                    MyFont.Isbold    = i.Isbold;
                    MyFont.Isitalic  = i.Isitalic;
                    MyFont.ColorName = i.ColorName;
                }
                ChkIsBold.IsChecked   = MyFont.Isbold;
                ChkIsItalic.IsChecked = MyFont.Isitalic;

                foreach (var i in CboxFont.Items)
                {
                    if (i.Equals(MyFont.Fontname))
                    {
                        CboxFont.SelectedItem = i;
                    }
                }

                foreach (var i in CboxFontSize.Items)
                {
                    if (i.Equals(MyFont.FontSize))
                    {
                        CboxFontSize.SelectedItem = i;
                    }
                }

                foreach (var i in CboxColors.Items)
                {
                    var n = i.ToString().ToUpper();
                    if (n.Equals(MyFont.ColorName.ToUpper()))
                    {
                        CboxColors.SelectedItem = i;
                    }
                }
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.ToString());
            }
        }
Example #6
0
 /// <summary>
 /// add ResourceDictionary
 /// </summary>
 internal void _addresource()
 {
     try
     {
         List <TemplateLang> lang = Clanguage.Langs;
         ResourceDictionary  d    = new ResourceDictionary();
         foreach (TemplateLang i in lang)
         {
             if (i.Lang.ToUpper() == Clanguage.GetLangInClient())
             {
                 d.Source = new Uri(i.FileLink, UriKind.Absolute);
                 Resources.MergedDictionaries.Add(d);
             }
         }
     }
     catch (Exception ex)
     {
         MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
     }
 }
Example #7
0
        private void MnuGameClick(CheckBox c)
        {
            foreach (Games game in Game.GamesAvailable)
            {
                if (c.Content.ToString() == game.Name)
                {
                    if (c.IsChecked == true)
                    {
                        game.IsEnabled = true;
                        // disable all games in list (class)
                        foreach (Games g in Game.GamesAvailable)
                        {
                            if (g.Name != game.Name)
                            {
                                g.IsEnabled = false;
                            }
                        }
                        // uncheck all checkbox select one process (check box)
                        foreach (CheckBox i in _enumBoxsGames)
                        {
                            if (i.Content.ToString() != game.Name)
                            {
                                i.IsChecked = false;
                                // destroy object(s) if exist and jump game(s)
                                // destroy all object(s) draw
                                MyDelegates.DestroyObjectInGame(i.Content.ToString());
                            }
                        }
                    }
                    else
                    {
                        game.IsEnabled = false;

                        // destroy all object(s) draw
                        MyDelegates.DestroyObjectInGame(game.Name);
                    }
                }
            }
        }
Example #8
0
        private void MnuMyChannels(string s)
        {
            CanvasAllShowHide(false);

            // atualiza o canal
            if (s != null && s != Configuration.StConfiguration.Channel)
            {
                Configuration.StConfiguration.Channel = s;
            }

            // connect clicked
            // call connecion IRC
            try
            {
                // check se esta em chat send QUIT encerrar conexao
                //if(CanvasContent.Visibility == Visibility.Visible) { _Quit();}

                MenuChannels.Visibility = Visibility.Collapsed;
                MenuClose.Visibility    = Visibility.Visible;

                // kill thread if exist
                ThIrc?.Abort();
                ThIrc = new Thread(ThreadIrc)
                {
                    IsBackground = true
                };
                ThIrc.Start();
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
            }
            // save config in SQLite
            SqliteSource.UpdateSaved();

            //Console.WriteLine(s);
        }
Example #9
0
        public void SendToIrc(string s, bool iscommand = false)
        {
            if (ThIrc == null)
            {
                return;
            }
            string[] r = s.Split(new string[] { "/", " " }, StringSplitOptions.None);

            _output = new StreamWriter(_sock.GetStream());

            try
            {
                // check se for comando
                if (iscommand)
                {
                    if (r[0] == @"QUIT")
                    {
                        Application.Current.Dispatcher.Invoke(
                            DispatcherPriority.Normal, (Action) delegate
                        {
                            _output.Write("QUIT" + "\r\n");
                            _output.Flush();

                            //
                            //_Quit();
                            ListChat.Items.Clear();
                            CanvasWelcome.Visibility      = Visibility.Visible;
                            CanvasContent.Visibility      = Visibility.Hidden;
                            TxtSend.Visibility            = Visibility.Collapsed;
                            CanvasProgressring.Visibility = Visibility.Collapsed;
                            RingP.IsActive = false;
                            // mensagem de boas vindas
                            Effectfade(LblChan, Efeitos.Surgir, Resources.MergedDictionaries[0]["Status"].ToString(), 5, Color.DodgerBlue);
                            Title = Resources.MergedDictionaries[0]["Status"].ToString();
                        });
                        return;
                    }

                    switch (r[1])
                    {
                    // AUTH
                    case "AUTH":
                        string[] content = s.Split(new string[] { " ", "/" }, StringSplitOptions.None);
                        _output.Write(@"AUTH " + content[2] + @" " + content[3] + "\r\n");
                        _output.Flush();

                        MyDelegates.OnChatCallBack(@"system :", "Auth Sucess");
                        break;

                    // kick => KICK <#channel> <nick> <comment banned>
                    // exemplo : /KICK usuario comentario
                    case "KICK":
                        string[] k = s.Split(new string[] { "/", " " }, StringSplitOptions.None);
                        _output.Write(@"KICK " + MainWindow.Configuration.StConfiguration.Channel + " " + k[2] + " " + k[3] + "\r\n");
                        _output.Flush();
                        break;

                    // autokick
                    // exemplo : /ADDKICK usuario
                    case "ADDKICK":
                        string[] ak = s.Split(new string[] { "/", " " }, StringSplitOptions.None);
                        if (ak[2] != string.Empty)
                        {
                            Autokick.AddUser(ak[2]);
                        }

                        break;

                    // removeautokick
                    // ex: /REMOVEAUTOKICK usuario
                    case "REMOVEKICK":
                        string[] rk = s.Split(new string[] { "/", " " }, StringSplitOptions.None);
                        if (rk[2] != string.Empty)
                        {
                            Autokick.RemoveUser(rk[2]);
                        }

                        break;

                    // clearall
                    // ex: /CLEARAUTOKICK
                    case "CLEARKICK":
                        Autokick.ClearAll();

                        break;

                    // clear chat client
                    // exemplo : /CLEAR
                    case "CLEAR":
                        Application.Current.Dispatcher.Invoke(
                            DispatcherPriority.Normal, (Action) delegate
                        {
                            ListChat.Items.Clear();
                            MyDelegates.OnChatCallBack(@"system :", @"clean client chat");
                        });
                        break;

                    // envia comando TCP direto
                    // exemplos no site quakenet => https://www.quakenet.org/help/q-commands
                    case "CMD":
                        Application.Current.Dispatcher.Invoke(
                            DispatcherPriority.Normal, (Action) delegate
                        {
                            _output.Write(s.Replace("/CMD", string.Empty) + "\r\n");
                            _output.Flush();
                        });
                        break;

                    // Debug Show and Hide
                    case "DEBUGON":
                        Showconsole.ShowConsole();
                        break;

                    case "DEBUGOFF":
                        Showconsole.ShowConsole(false);
                        break;
                    }

                    return;
                }


                _output.Write("PRIVMSG " + Configuration.StConfiguration.Channel + " : " + s + "\r\n");
                _output.Flush();
                MyDelegates.OnChatCallBack(@"system :", s);
            }
            catch (Exception ex)
            {
                MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
            }
        }
Example #10
0
        /// <summary>
        /// thread creat for IRC service
        /// </summary>
        internal void ThreadIrc()
        {
            try
            {
                _sock = new TcpClient();
                _sock.Connect(Configuration.StConfiguration.Server,
                              Configuration.StConfiguration.Port);
                if (!_sock.Connected)
                {
                    MyDelegates.OnDebugMessageCallBack(@"failed to connect " + Environment.NewLine +
                                                       @"internal void ThreadIrc()");
                }

                _input  = new StreamReader(_sock.GetStream());
                _output = new StreamWriter(_sock.GetStream());

                _output.Write(
                    "USER " + Configuration.StConfiguration.Nick + " 0 * :" + Configuration.StConfiguration.Owner + "\r\n" +
                    "NICK " + Configuration.StConfiguration.Owner + "\r\n");
                _output.Flush();

                // check auth ssl
                if (Configuration.StConfiguration.AuthSsl.ToString() == @"true")
                {
                    // auth enabled
                    LoginSsl(Configuration.StConfiguration.Nick,
                             Configuration.StConfiguration.Password);
                    MyDelegates.OnCallStatus(Resources.MergedDictionaries[0]["AuthSslEnabled"].ToString());
                }
                else
                {
                    // auth disabled
                    Application.Current.Dispatcher.Invoke(
                        DispatcherPriority.Normal, (Action) delegate
                    {
                        MyDelegates.OnCallStatus(Resources.MergedDictionaries[0]["AuthSslDisabled"].ToString());
                    });
                }


                for (Buff = _input.ReadLine();; Buff = _input.ReadLine())
                {
                    if (Buff == null)
                    {
                        return;
                    }
                    MyDelegates.OnCallBackOut(Buff);

                    // send pong reply to any ping messages
                    if (Buff != null && Buff.StartsWith("PING"))
                    {
                        _output.Write(Buff.Replace("PING", "PONG") + "\r\n");
                        _output.Flush();
                    }
                    if (Buff != null && Buff[0] != ':')
                    {
                        continue;
                    }

                    if (Buff != null && Buff.Split(' ')[1] == "001")
                    {
                        _output.Write("MODE " + Configuration.StConfiguration.Nick + "+o \r\n" +
                                      "JOIN " + Configuration.StConfiguration.Channel + "\r\n");
                        _output.Flush();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult != -2146233040)
                {
                    MyDelegates.OnDebugMessageCallBack(ex.StackTrace);
                }
            }
        }