示例#1
0
        private void lbbutton_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            try
            {
                var item = ItemsControl.ContainerFromElement(sender as ListBox, e.OriginalSource as DependencyObject) as ListBoxItem;
                if (item != null)
                {
                    autoprimisred = true;
                    chekupdate();
                    btn_spis elem = item.Content as btn_spis;

                    elem.setvibran(!elem.vibran);

                    lbbutton.Items.Refresh();

                    if (!elem.vibran)
                    {
                        string text = elem.name;
                        tb1.SelectedText = text;
                        tb1.CaretIndex   = tb1.SelectionLength + tb1.SelectionStart;
                        tb1.Focus();
                    }
                }
            }
            catch (Exception exx)
            {
                MessageBox.Show(exx.Message);
            }
        }
示例#2
0
        public Prim3(string path, string text)
        {
            InitializeComponent();
            BD.path         = path; //укажем файл бд
            this.text_otvet = text.Trim();

            //PRIM=a2131231232321;AVTO=asdasdasda
            // MessageBox.Show(this.text_otvet);

            if (text_otvet.Contains("PRIM=") && text_otvet.Contains(";AVTO=") && text_otvet.Contains(";EDIT="))
            {
                try
                {
                    PRIM = (text_otvet.Split(';'))[0].Substring(5);
                }
                catch
                {
                    PRIM = "";
                }
                try
                {
                    AUTO = (text_otvet.Split(';'))[1].Substring(5).Trim('^');
                }
                catch
                {
                    AUTO = "";
                }
                try
                {
                    EDIT = (text_otvet.Split(';'))[2].Substring(5);
                }
                catch
                {
                    EDIT = "0";
                }
                try
                {
                    SAUTO = (text_otvet.Split(';'))[3].Substring(6).Trim('^');
                }
                catch
                {
                    SAUTO = "";
                }
            }
            else
            {
                PRIM  = text_otvet;
                AUTO  = "";
                SAUTO = "";
                EDIT  = "0";
            }

            //


            if (EDIT.Equals("1"))
            {
                tb3.IsEnabled = true;
                cb1.IsChecked = true;
            }
            else
            {
                tb3.IsEnabled = false;
                cb1.IsChecked = false;
            }
            OleDbDataReader reader = BD.conn("SELECT STCommentD.Name, STCommentD.ID, STCommentDchasto.Chastota FROM STCommentD LEFT JOIN STCommentDchasto ON STCommentD.ID = STCommentDchasto.IDComment ORDER BY STCommentDchasto.Chastota DESC");

            while (reader.Read())
            {
                int Chasto = 0;
                if (reader["Chastota"].ToString() != "")
                {
                    Chasto = Convert.ToInt32(reader["Chastota"]);
                }
                result.Add(new MyTable()
                {
                    ID     = reader["ID"].ToString(),
                    Name   = reader["Name"].ToString(),
                    Chasto = Chasto
                });
            }
            reader.Close();

            loadpage();                  //загрузка полож окна
            proverka_uhoda_za_granicu(); //проверка ухода за границу
            tb2.Focus();

            string t = PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';');

            tb1.Text = t;
            tb3.Text = AUTO;

            if (!AUTO.Equals(""))
            {
                string[] split_AUTO = AUTO.Split('^');

                foreach (string elem in split_AUTO)
                {
                    var      splitelemrech = elem.Split('#');
                    btn_spis elemnew;
                    if (splitelemrech.Length == 2)
                    {
                        elemnew = new btn_spis()
                        {
                            name = splitelemrech[1].Trim(), id = splitelemrech[0].Trim()
                        };
                    }
                    else
                    {
                        elemnew = new btn_spis()
                        {
                            name = elem.Trim()
                        };
                    }

                    /*
                     * string[] splitenable = elem.Split('#');
                     * var elemnew = new btn_spis() {
                     *  name = splitenable[0],
                     *  vibran = splitenable.Length==2? splitenable[1]=="1":true
                     * };*/
                    spisbtn.Add(elemnew);
                    lbbutton.Items.Add(elemnew);
                }
            }

            //   MessageBox.Show(SAUTO);
            if (!SAUTO.Equals(""))
            {
                string[] split_SAUTO = SAUTO.Split('^');

                foreach (string elem in split_SAUTO)
                {
                    // var elemnew = new btn_spis() { name = elem.Trim() };
                    var splitelemrech = elem.Split('#');
                    var elemnew       = new btn_spis()
                    {
                        name = splitelemrech[1].Trim(), id = splitelemrech[0].Trim()
                    };


                    /*
                     * string[] splitenable = elem.Split('#');
                     * var elemnew = new btn_spis() {
                     *  name = splitenable[0],
                     *  vibran = splitenable.Length==2? splitenable[1]=="1":true
                     * };*/

                    var findelem = spisbtn.Find(x => x.id == elemnew.id);

                    if (findelem != null)
                    {
                        // MessageBox.Show(findelem.name +" "+ elemnew.name);
                        if (findelem.name.Trim().ToLower() == elemnew.name.Trim().ToLower()) //просто крести
                        {
                            findelem.setvibran(false);                                       //показываес что элемент крестик
                        }
                        else  //крестик и  указываем что изменен1
                        {
                            findelem.setvibran(false, true);  //показываес что элемент крестик
                            lvstalo.Items.Add(new bilostalo()
                            {
                                bilo = elemnew.name, stalo = findelem.name, deystvie = "Изменено", colorbg = "#66FFF500"
                            });
                            // bilo.Items.Add(elemnew);
                            // stalo.Items.Add(findelem);
                            spisbtnSAUTO.Add(elemnew);
                        }
                    }
                    else
                    {
                        logdlas += elemnew.name + " - АВТОПРИМЕЧАНИЕ УДАЛЕНО" + Environment.NewLine;
                        spisbtnSAUTO.Add(elemnew);
                        lvstalo.Items.Add(new bilostalo()
                        {
                            bilo = elemnew.name, stalo = "", deystvie = "Удалено", colorbg = "#66FF0000"
                        });
                        //  bilo.Items.Add(elemnew);
                        //  stalo.Items.Add(null);
                    }


                    // lbbutton.Items.Add(elemnew);
                }
            }
            if (spisbtnSAUTO.Count == 0)
            {
                ddddd.Height = new GridLength(0);
            }


            //  tbizmen.Text= logdlas;


            tb1.CaretIndex = tb1.Text.Length;
        }
示例#3
0
        public Prim2(string path, string text)
        {
            InitializeComponent();
            BD.path         = path; //укажем файл бд
            this.text_otvet = text.Trim();
            // MessageBox.Show(this.text_otvet);
            //PRIM=a2131231232321;AVTO=asdasdasda//


            if (text_otvet.Contains("PRIM=") && text_otvet.Contains(";AVTO=") && text_otvet.Contains(";EDIT="))
            {
                try
                {
                    PRIM = (text_otvet.Split(';'))[0].Substring(5);
                }
                catch
                {
                    PRIM = "";
                }
                try
                {
                    AUTO = (text_otvet.Split(';'))[1].Substring(5).Trim('^');
                }
                catch
                {
                    AUTO = "";
                }
                try
                {
                    EDIT = (text_otvet.Split(';'))[2].Substring(5);
                }
                catch
                {
                    EDIT = "0";
                }
            }
            else
            {
                PRIM = text_otvet;
                AUTO = "";
                EDIT = "0";
            }



            if (EDIT.Equals("1"))
            {
                tb3.IsEnabled = true;
                cb1.IsChecked = true;
            }
            else
            {
                tb3.IsEnabled = false;
                cb1.IsChecked = false;
            }
            OleDbDataReader reader = BD.conn("SELECT STCommentD.Name, STCommentD.ID, STCommentDchasto.Chastota FROM STCommentD LEFT JOIN STCommentDchasto ON STCommentD.ID = STCommentDchasto.IDComment ORDER BY STCommentDchasto.Chastota DESC");

            while (reader.Read())
            {
                int Chasto = 0;
                if (reader["Chastota"].ToString() != "")
                {
                    Chasto = Convert.ToInt32(reader["Chastota"]);
                }
                result.Add(new MyTable()
                {
                    ID     = reader["ID"].ToString(),
                    Name   = reader["Name"].ToString(),
                    Chasto = Chasto
                });
            }

            loadpage();                  //загрузка полож окна
            proverka_uhoda_za_granicu(); //проверка ухода за границу
            tb2.Focus();

            string t = PRIM.Replace('#', '"').Replace('$', ';').Replace('@', ',').Replace('№', '/').Replace('^', ' ').Replace('|', ';');

            tb1.Text = t;
            tb3.Text = AUTO;

            if (!AUTO.Equals(""))
            {
                string[] split_AUTO = AUTO.Split('^');

                foreach (string elem in split_AUTO)
                {
                    var splitelemrech = elem.Split('#');
                    var elemnew       = new btn_spis()
                    {
                        name = splitelemrech.Length == 2? splitelemrech [1]: elem
                    };
                    spisbtn.Add(elemnew);
                    lbbutton.Items.Add(elemnew);
                }
            }

            //  lbbutton.ItemsSource = spisbtn;


            tb1.CaretIndex = tb1.Text.Length;
        }