Exemplo n.º 1
0
 protected void OnButtonApplyClicked(object sender, EventArgs e)
 {
     fixedSheme.Foreach((b) => {
         if (b is Button && (b as Button).Relief == ReliefStyle.Half)
         {
             try {
                 StoloviPresenter.CheckUniqueOznaka(StoloviPresenter.GetStol(b.Name), entryOznaka.Text);
                 StoloviPresenter.Update(b.Name, entryOznaka.Text);
                 b.Name = entryOznaka.Text;
                 labelOznakaStola.Text = entryOznaka.Text;
                 SaveToXml();
                 OnTableSelection(b.Name);
             } catch (ArgumentException ae) {
                 DialogBox.ShowError(new Gtk.Window(Gtk.WindowType.Popup), ae.Message);
             }
             return;
         }
     });
 }
Exemplo n.º 2
0
        protected void Data_Received(object o, DragDataReceivedArgs args)
        {
            bool success = false;

            Gtk.Widget source = Gtk.Drag.GetSourceWidget(args.Context);
            string     data   = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data);

            switch (args.Info)
            {
            case 0:              // uri-list
                string[] uri_list = Regex.Split(data, "\r\n");
                foreach (string u in uri_list)
                {
                    //if(u.Length > 0)
                    //System.Console.WriteLine("Got URI {0}", u);
                }
                success = true;
                break;

            case 1:             // table
                success = true;
                string name = "NewTable";
                if (source is Button)                  // Samo razmještaj stola
                {
                    name = (source as Button).Name;
                }
                else                      //Drag&Drop novog stola - INSERT
                {
                    int brojStolica;
                    switch (data)
                    {
                    case "Table2Chair": brojStolica = 2; break;

                    case "Table4Chair": brojStolica = 4; break;

                    case "Table6Chair": brojStolica = 6; break;

                    case "Table8Chair": brojStolica = 8; break;

                    default: brojStolica = 2; break;
                    }

                    bool notUnique = true;
                    for (int i = 1; notUnique; i++)
                    {
                        name = "NewTable" + i;
                        Stol s = new Stol(name, brojStolica);
                        try {
                            StoloviPresenter.CheckUniqueOznaka(s, name);
                            StoloviPresenter.Add(s);
                            notUnique = false;
                        } catch (ArgumentException) {}
                    }
                    entryOznaka.Text = "";
                }

                AddNewTableButtonImage(name, data, args.X, args.Y, size);
                SaveToXml();
                break;
            }
            Gtk.Drag.Finish(args.Context, success, true, args.Time);
        }