Exemple #1
0
 public ResolutionDialog(Gtk.Window parentWindow)
 {
     this.TransientFor = parentWindow;
     resolution = new Rule();
     resolution.Id=0;
     InitializeDialog();
 }
Exemple #2
0
        public ResolutionDialog(Rule resolution,Gtk.Window parentWindow)
        {
            this.TransientFor = parentWindow;
            this.resolution =resolution;
            InitializeDialog();
            entrName.Text = resolution.Name;
            entrSpecific.Text = resolution.Specific;

            sbWidth.Value= resolution.Width;
            sbHeight.Value= resolution.Height;
            chbCreateFile.Active = false;
            chbCreateFile.Visible= false;
        }
        protected virtual void OnBtnAddRulesClicked(object sender, System.EventArgs e)
        {
            if(!MainClass.LicencesSystem.CheckFunction("conditions",parentWindow)){
                return;
            }

            TreeSelection ts = tvConditions.Selection;

            TreeIter ti = new TreeIter();
            ts.GetSelected(out ti);

            TreePath[] tp = ts.GetSelectedRows();
            if (tp.Length < 1)
                return ;

            Condition cd = (Condition)tvConditions.Model.GetValue(ti, 2);
            if (cd == null) return;

            EntryDialog ed = new EntryDialog("",MainClass.Languages.Translate("new_rule"),parentWindow);
            int result = ed.Run();
            if (result == (int)ResponseType.Ok){
                string newStr = ed.TextEntry;
                if (!String.IsNullOrEmpty(newStr) ){

                    int maxCountRule = 0;
                    foreach (Rule rlf in cd.Rules){
                        if (maxCountRule < rlf.Id) maxCountRule = rlf.Id;
                    }

                    Rule rlFind = cd.Rules.Find(x=>x.Name.ToUpper() ==newStr.ToUpper());
                    if (rlFind != null){

                        MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("rule_is_exist", rlFind.Name), "", Gtk.MessageType.Error,parentWindow);
                        md.ShowDialog();
                        ed.Destroy();
                        return;
                    }

                    Rule rl= new Rule();
                    rl.Name =newStr;
                    maxCountRule++;
                    rl.Id = maxCountRule;
                    ruleStore.AppendValues(maxCountRule,rl.Name,rl);

                    Condition cd2 = conditions.Find(x => x.Id == cd.Id);
                    cd2.Rules.Add(rl);
                    conditionStore.SetValues(ti,cd2.Id,cd2.Name,cd2);

                }
            }
            ed.Destroy();
        }