Beispiel #1
0
        public GenreEntry()
        {
            genre_model = new ListStore(typeof(string));
            Model       = genre_model;
            TextColumn  = 0;

            EntryCompletion c = new EntryCompletion();

            c.Model            = genre_model;
            c.TextColumn       = TextColumn;
            c.PopupCompletion  = true;
            c.InlineCompletion = true;
            //c.InlineSelection = true; // requires 2.12
            c.PopupSingleMatch = false;
            Entry.Completion   = c;

            foreach (string genre in ServiceManager.DbConnection.QueryEnumerable <string> (
                         "SELECT DISTINCT Genre FROM CoreTracks ORDER BY Genre"))
            {
                if (!String.IsNullOrEmpty(genre))
                {
                    genre_model.AppendValues(genre);
                }
            }
        }
Beispiel #2
0
    /* Constructor */
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();
        entry4.Activated    += new System.EventHandler(this.OnTextEntered);
        findEntry.Activated += new System.EventHandler(this.OnSearchActivated);
        glwidget1.CanFocus   = true;

        entry4.ModifyBase(StateType.Normal, new Gdk.Color(25, 25, 50));
        entry4.ModifyBg(StateType.Normal, new Gdk.Color(25, 25, 50));
        entry4.ModifyFg(StateType.Normal, new Gdk.Color(25, 25, 50));

        entry4.ModifyText(StateType.Normal, new Gdk.Color(240, 240, 240));
        entry4.ModifyCursor(new Gdk.Color(0, 240, 0), new Gdk.Color(0, 0, 255));

        if (GraphicsContext.ShareContexts)
        {
            GLWidget.GraphicsContextInitialized  += new System.EventHandler(this.OnGlwidgetInit);
            GLWidget.GraphicsContextShuttingDown += new System.EventHandler(this.OnWidgetShuttingDown);
        }
        else
        {
            glwidget1.Initialized  += new System.EventHandler(this.OnGlwidgetInit);
            glwidget1.ShuttingDown += new System.EventHandler(this.OnWidgetShuttingDown);
        }

        completer.DirsOnly    = true;
        completion            = new EntryCompletion();
        entry4.Completion     = completion;
        completion.TextColumn = 0;
        store                       = new ListStore(GType.String);
        completion.Model            = store;
        completion.MinimumKeyLength = 1;
        glwidget1.GrabFocus();
    }
Beispiel #3
0
        static void LoadHistory(string propertyName, ComboBoxEntry entry)
        {
            var ec = new EntryCompletion();

/*			entry.Changed += delegate {
 *                              if (!entry.Entry.HasFocus)
 *                                      entry.Entry.GrabFocus ();
 *
 *                      };*/


            entry.Entry.Completion = ec;
            var store = new ListStore(typeof(string));

            entry.Entry.Completion.Model = store;
            entry.Model = store;
            entry.Entry.ActivatesDefault = true;
            entry.TextColumn             = 0;
            var history = PropertyService.Get <string> (propertyName);

            if (!string.IsNullOrEmpty(history))
            {
                string[] items = history.Split(historySeparator);
                foreach (string item in items)
                {
                    if (string.IsNullOrEmpty(item))
                    {
                        continue;
                    }
                    store.AppendValues(item);
                }
                entry.Entry.Text = items[0];
            }
        }
Beispiel #4
0
        public TextEntry(string completionTable, string completionColumn)
        {
            if (completionTable == null || completionColumn == null)
            {
                return;
            }

            ListStore completion_model = new ListStore(typeof(string));

            foreach (string val in ServiceManager.DbConnection.QueryEnumerable <string> (String.Format(
                                                                                             "SELECT DISTINCT {1} FROM {0} ORDER BY {1}", completionTable, completionColumn)))
            {
                if (!String.IsNullOrEmpty(val))
                {
                    completion_model.AppendValues(val);
                }
            }

            Completion                  = new EntryCompletion();
            Completion.Model            = completion_model;
            Completion.TextColumn       = 0;
            Completion.PopupCompletion  = true;
            Completion.InlineCompletion = true;
            //Completion.InlineSelection = true; // requires 2.12
            Completion.PopupSingleMatch = false;
        }
Beispiel #5
0
        public LicenseEntry() : base(true)
        {
            license_model   = new ListStore(typeof(string));
            Model           = license_model;
            EntryTextColumn = 0;

            EntryCompletion c = new EntryCompletion();

            c.Model            = license_model;
            c.TextColumn       = EntryTextColumn;
            c.PopupCompletion  = true;
            c.InlineCompletion = true;
            c.InlineSelection  = true;
            c.PopupSingleMatch = false;
            Entry.Completion   = c;

            foreach (string license_uri in ServiceManager.DbConnection.QueryEnumerable <string> (
                         "SELECT DISTINCT LicenseUri FROM CoreTracks ORDER BY LicenseUri"))
            {
                if (!String.IsNullOrEmpty(license_uri))
                {
                    license_model.AppendValues(license_uri);
                }
            }
        }
 public override int GetHashCode()
 {
     unchecked
     {
         return(((EntryCompletion?.GetHashCode() ?? 0) * 397) ^ (int)EntryTypeUC);
     }
 }
Beispiel #7
0
        private bool TimeZoneMatchFunc(EntryCompletion compl, string key, TreeIter iter)
        {
            key = key.Trim().Replace(' ', '_');

            return(((string)compl.Model.GetValue(iter, 1)).Contains(key, StringComparison.OrdinalIgnoreCase) ||   // region
                   ((string)compl.Model.GetValue(iter, 2)).StartsWith(key, StringComparison.OrdinalIgnoreCase) || // abbr
                   ((string)compl.Model.GetValue(iter, 0)).Substring(3).StartsWith(key));                         // offset
        }
Beispiel #8
0
        private void HandleEdgeActionTargetEditingStarted(object o, EditingStartedArgs args)
        {
            Entry entry = args.Editable as Entry;

            if (entry == null)
            {
                return;
            }

            d_editingEntry = entry;
            d_editingPath  = args.Path;

            if (d_treeview.NodeStore.FindPath(args.Path).EdgeAction == null)
            {
                entry.Text = "";
            }

            d_editingEntry.KeyPressEvent += delegate(object source, KeyPressEventArgs a) {
                OnEntryKeyPressed(a, d_rendererTarget, TargetEdited);
            };

            if (d_link.Output == null)
            {
                return;
            }

            EntryCompletion           completion = new EntryCompletion();
            ListStore                 props      = new ListStore(typeof(string));
            Dictionary <string, bool> found      = new Dictionary <string, bool>();

            Wrappers.Node grp = d_link.Output;

            if (grp != null)
            {
                foreach (string name in grp.VariableInterface.Names)
                {
                    props.AppendValues(name);
                    found[name] = true;
                }
            }

            foreach (Variable prop in d_link.Output.Variables)
            {
                if (!found.ContainsKey(prop.Name))
                {
                    props.AppendValues(prop.Name);
                }
            }

            completion.Model            = props;
            completion.TextColumn       = 0;
            completion.InlineSelection  = true;
            completion.InlineCompletion = true;

            entry.Completion = completion;
        }
Beispiel #9
0
    /* Constructor */
    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();

        //System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Highest;
        this.Fullscreen();

        //Determining number of CPU cores
        int coreCount = 0;

        foreach (var item in new System.Management.ManagementObjectSearcher("Select NumberOfCores from Win32_Processor").Get())         //needs reference to System.Management
        {
            coreCount += int.Parse(item["NumberOfCores"].ToString());
        }
        System.Diagnostics.Debug.WriteLine("The number of cores on this computer is {0}.", coreCount);

        //Setting maximum number of threads running in parallel (during I/O operations)
        MaxDegreeOfParallelism = (int)Math.Floor((double)coreCount / 2);       //needs to be determined for smooth animations (I/O operations highly affect OpenGL rendering performance, so the number of threads doing I/O in parallel have to be limited)
        System.Diagnostics.Debug.WriteLine("The number of cores used for parallel I/O operations is equal to NumberOfCores divided by 2, that is {0}.", MaxDegreeOfParallelism);


        entry4.Activated    += new System.EventHandler(this.OnTextEntered);
        findEntry.Activated += new System.EventHandler(this.OnSearchActivated);
        glwidget1.CanFocus   = true;

        entry4.ModifyBase(StateType.Normal, new Gdk.Color(25, 25, 50));
        entry4.ModifyBg(StateType.Normal, new Gdk.Color(25, 25, 50));
        entry4.ModifyFg(StateType.Normal, new Gdk.Color(25, 25, 50));

        entry4.ModifyText(StateType.Normal, new Gdk.Color(240, 240, 240));
        entry4.ModifyCursor(new Gdk.Color(0, 240, 0), new Gdk.Color(0, 0, 255));

        if (OpenTK.Graphics.GraphicsContext.ShareContexts)
        {
            GLWidget.GraphicsContextInitialized  += new System.EventHandler(this.OnGlwidgetInit);
            GLWidget.GraphicsContextShuttingDown += new System.EventHandler(this.OnWidgetShuttingDown);
        }
        else
        {
            glwidget1.Initialized  += new System.EventHandler(this.OnGlwidgetInit);
            glwidget1.ShuttingDown += new System.EventHandler(this.OnWidgetShuttingDown);
        }

        completer.DirsOnly    = true;
        completion            = new EntryCompletion();
        entry4.Completion     = completion;
        completion.TextColumn = 0;
        store                       = new ListStore(GType.String);
        completion.Model            = store;
        completion.MinimumKeyLength = 1;
        glwidget1.GrabFocus();

        MainThreadDispatcher = Dispatcher.CurrentDispatcher;
    }
        private bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            var house = (HouseDTO)completion.Model.GetValue(iter, 0);

            if (house == null)
            {
                return(false);
            }
            var houseName = house.ComplexNumber;

            return(Regex.IsMatch(houseName, $"{Regex.Escape(Text)}", RegexOptions.IgnoreCase));
        }
Beispiel #11
0
 bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
 {
     if (searchSearchProvider == null)
     {
         var val = completion.Model.GetValue(iter, (int)СompletionColumn.Tilte).ToString();
         return(val.IndexOf(key, StringComparison.CurrentCultureIgnoreCase) > -1);
     }
     else
     {
         var val = completion.Model.GetValue(iter, (int)СompletionColumn.Item);
         return(searchSearchProvider.Match(val, key));
     }
 }
Beispiel #12
0
        public bool LogicEntryCompletionMatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            if (Completing)
            {
                return(false);
            }

            key = key == null ? null : key.Normalize(NormalizationForm.FormC);
            string name = completion.Model.GetValue(iter, completion.TextColumn) as string;
            int    pos  = entry.Position - 1;

            return(completion_logic.MatchFunc(name, key, pos));
        }
Beispiel #13
0
    private void InitTaskCombobox()
    {
        ListStore taskStore = new ListStore(typeof(String));

        foreach (String s in dbManager.getTasks())
        {
            taskStore.AppendValues(s);
        }
        taskCombobox.Model = taskStore;
        Gtk.EntryCompletion com = new EntryCompletion();
        com.Model      = taskStore;
        com.TextColumn = 0;
        taskCombobox.Entry.Completion = com;
    }
Beispiel #14
0
        /// <summary>
        /// Autocomplete the specified entry and list.
        /// </summary>
        /// <returns>The autocomplete.</returns>
        /// <param name="entry">Entry.</param>
        /// <param name="list">List.</param>
        public static void Autocomplete(this Entry entry, List <string> list)
        {
            EntryCompletion completionSeasons = new EntryCompletion();
            ListStore       storeSeasons      = new ListStore(typeof(string));

            foreach (string item in list)
            {
                storeSeasons.AppendValues(item);
            }

            entry.Completion = new EntryCompletion {
                Model      = storeSeasons,
                TextColumn = 0
            };
        }
        public StreetEntry()
        {
            Binding = new BindingControler <StreetEntry>(this, new Expression <Func <StreetEntry, object> >[]
            {
                w => w.FiasGuid, w => w.StreetName, w => w.StreetDistrict, w => w.StreetTypeName, w => w.StreetTypeNameShort
            });

            Completion = new EntryCompletion();
            Completion.MinimumKeyLength = 0;
            Completion.MatchSelected   += Completion_MatchSelected;
            Completion.MatchFunc        = (completion, key, iter) => true;
            var cell = new CellRendererText();

            Completion.PackStart(cell, true);
            Completion.SetCellDataFunc(cell, OnCellLayoutDataFunc);
        }
        public HouseEntry()
        {
            Binding = new BindingControler <HouseEntry>(this, new Expression <Func <HouseEntry, object> >[]
            {
                w => w.FiasGuid,
                w => w.BuildingName
            });

            Completion = new EntryCompletion();
            Completion.MinimumKeyLength = 0;
            Completion.MatchSelected   += Completion_MatchSelected;
            Completion.MatchFunc        = Completion_MatchFunc;
            var cell = new CellRendererText();

            Completion.PackStart(cell, true);
            Completion.SetCellDataFunc(cell, OnCellLayoutDataFunc);
        }
        public CityEntry()
        {
            Binding = new BindingControler <CityEntry>(this, new Expression <Func <CityEntry, object> >[]
            {
                w => w.FiasGuid, w => w.CityTypeName, w => w.CityTypeNameShort, w => w.CityName
            });

            Completion = new EntryCompletion();
            Completion.MinimumKeyLength = 0;
            Completion.MatchSelected   += Completion_MatchSelected;
            Completion.MatchFunc        = (completion, key, iter) => true;
            var cell = new CellRendererText();

            Completion.PackStart(cell, true);
            Completion.SetCellDataFunc(cell, OnCellLayoutDataFunc);

            FocusOutEvent += OnFocusOutEvent;
        }
Beispiel #18
0
        public (string, Widget) CreateCompletionEntry()
        {
            // create completion object and assign it to entry
            var completion = new EntryCompletion();
            var entry      = new Entry();

            entry.Completion = completion;

            // create values store
            var store = new ListStore(typeof(string));

            store.AppendValues("An example to search for");
            store.AppendValues("Better example");
            store.AppendValues("Better and bigger example");
            store.AppendValues("Some other example");

            // assign treemodel as the completion
            completion.Model = store;

            // lets override the default match function so we can use the contains mode
            // instead of the default startswith
            completion.MatchFunc = (EntryCompletion comp, string key, TreeIter iter) =>
            {
                if (string.IsNullOrEmpty(key))
                {
                    return(false);
                }

                var o = comp.Model.GetValue(iter, 0);
                var stringToSearch = o as string;

                if (!string.IsNullOrEmpty(stringToSearch))
                {
                    return(stringToSearch.IndexOf(key, System.StringComparison.InvariantCultureIgnoreCase) >= 0);
                }

                return(false);
            };

            completion.TextColumn = 0;


            return("Completion Entry:", entry);
        }
Beispiel #19
0
        void OnLocationEditingStarted(object sender, Gtk.EditingStartedArgs args)
        {
            if (Entity.ProjectRows.Count == 0)
            {
                return;
            }

            var entry      = args.Editable as Entry;
            var completion = new EntryCompletion();
            var list       = new ListStore(typeof(string));

            foreach (var txt in Entity.ProjectRows.Where(x => !String.IsNullOrWhiteSpace(x.Location)).Select(x => x.Location.Trim()).Distinct())
            {
                list.AppendValues(txt);
            }
            completion.Model      = list;
            completion.TextColumn = 0;
            entry.Completion      = completion;
        }
Beispiel #20
0
        bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            var val = (string)completion.Model.GetValue(iter, 0);

            return(Regex.IsMatch(val, String.Format("{0}", Regex.Escape(this.Text)), RegexOptions.IgnoreCase));
        }
Beispiel #21
0
        bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            var val = completion.Model.GetValue(iter, (int)columns.Street).ToString().ToLower();

            return(Regex.IsMatch(val, String.Format("\\b{0}.*", Regex.Escape(this.Text.ToLower()))));
        }
Beispiel #22
0
        bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            var val = completion.Model.GetValue(iter, (int)СompletionColumn.Item);

            return(RepresentationModel.SearchFilterNodeFunc(val, key));
        }
Beispiel #23
0
        public bool LogicEntryCompletionMatchFunc(EntryCompletion completion, string key, TreeIter iter)
        {
            if (Completing)
            {
                return(false);
            }

            // If this is the fist comparison for this key, convert the key (which is the entire search string)
            // into just the part that is relevant to completing this tag name.
            if (key != last_key)
            {
                last_key = key;

                int pos = entry.Position - 1;
                if (key == null || key.Length == 0 || pos < 0 || pos > key.Length - 1)
                {
                    transformed_key = String.Empty;
                }
                else if (key [pos] == '(' || key [pos] == ')' || key [pos] == ',')
                {
                    transformed_key = String.Empty;
                }
                else
                {
                    int start = 0;
                    for (int i = entry.Position - 1; i >= 0; i--)
                    {
                        if (key [i] == ' ' || key [i] == ')' || key [i] == '(')
                        {
                            //Console.WriteLine ("have start break char at {0}", i);
                            start = i + 1;
                            break;
                        }
                    }

                    int end = key.Length - 1;
                    for (int j = entry.Position - 1; j < key.Length; j++)
                    {
                        if (key [j] == ' ' || key [j] == ')' || key [j] == '(')
                        {
                            end = j - 1;
                            break;
                        }
                    }

                    //Console.WriteLine ("start = {0} end = {1}", start, end);

                    int len = end - start + 1;
                    if (len > 0 && start < last_key.Length)
                    {
                        transformed_key = last_key.Substring(start, end - start + 1);
                    }
                    else
                    {
                        transformed_key = String.Empty;
                    }
                }
                //Console.WriteLine ("transformed key {0} into {1}", key, transformed_key);
            }

            if (transformed_key == String.Empty)
            {
                return(false);
            }

            string name = completion.Model.GetValue(iter, completion.TextColumn) as string;

            // Ignore null or names that are too short
            if (name == null || name.Length <= transformed_key.Length)
            {
                return(false);
            }

            //Console.WriteLine ("entered = {0} compared to {1}", transformed_key, name);
            return(String.Compare(transformed_key, name.Substring(0, transformed_key.Length), true) == 0);
        }
Beispiel #24
0
 bool Completion_MatchFunc(EntryCompletion completion, string key, TreeIter iter)
 {
     return(true);
 }
 public void Dispose() => EntryCompletion?.Complete();