public Sampler2d(Map2d map, TextureWrap wrapMode, FilteringType filtering = FilteringType.Best, bool useMipmaps = true) { this.Map = map; this.Filtering = filtering; this.WrapMode = wrapMode; this.UseMipmaps = useMipmaps; }
public void Operate(FilteringType ft) { double[] fs = null; switch (ft) { case FilteringType.Parabolic: fs = ps; break; case FilteringType.Median: fs = ms; break; case FilteringType.Sliding: fs = ss; break; default: break; } double[] sinSp = GetSineSpectrum(fs); double[] cosinSp = GetCosineSpectrum(fs); asp = GetAmplSpectrum(sinSp, cosinSp); psp = GetPhaseSpectrum(sinSp, cosinSp); }
public bool DoesRowComplyWithFilters(DataRow dr, string[] filter, FilteringType ft) { if (ft == FilteringType.StartWith) { for (int c = 0; c < dr.ItemArray.Length; c++) { if (filter[c] == null || filter[c] == "") { continue; } else { switch (Columns[c].Type) { case ColumnType.Unknown: case ColumnType.Text: if (dr.ItemArray[c].ToString().ToLower().IndexOf(filter[c]) != 0) { return(false); } break; case ColumnType.CheckBox: break; default: break; } } } } return(true); }
// Constructor with default parameters values and with reference to base class's constructor public Beer( string title = "Title unknown", string manufacturer = "Manufacturer unknown", AlcoholContent alcoholContentClass = AlcoholContent.None, List <KeyValuePair <Packaging, double?> > packAndVolume = null, BeerType Type = BeerType.None, FilteringType Filtering = FilteringType.None ) : base(title, manufacturer, alcoholContentClass, packAndVolume) { this.Type = Type; this.Filtering = Filtering; NumberOfBeers++; }
public bool DoesRowComplyWithFilters(string[] filter, FilteringType ft) { if (ft == FilteringType.StartWith) { for (int c = 0; c < Cells.Count; c++) { if (filter[c] == null || filter[c] == "") { continue; } else { if (Cells[c].GetValue().ToLower().IndexOf(filter[c]) != 0) { return(false); } } } } return(true); }
/// <summary> /// Gets a new buffer with the specified size. /// </summary> /// <returns>The scaled buffer.</returns> /// <param name="NewSize">New size.</param> public PixelBuffer GetScaledBuffer(Vector2i newSize, FilteringType filtering) { FreeImageBitmap Scaled; using (FreeImageBitmap Bmp = new FreeImageBitmap(BufferSize.Width, BufferSize.Height, BufferSize.Width * 4, PixelFormat.Format32bppArgb, Pixels)) { // Get scaled bitmap Scaled = Bmp.GetScaledInstance(newSize, (FREE_IMAGE_FILTER)filtering); } PixelBuffer buffer = new PixelBuffer(newSize); // Convert from GBRA to RGBA int z = 0; for (int i = newSize.Height - 1; i >= 0; i--, z++) { Marshal.Copy(Scaled.Bits + (z * newSize.Width * 4), buffer.Pixels, i * newSize.Width * 4, newSize.Width * 4); } Scaled.Dispose(); return(buffer); }
//public void ApplyFilters(string[] filters, FilteringType ft ) //{ // if (filters.Length == 0) // return; // filters = ToLowerCase(filters); // for (int r = 0; r < Data.Count; r++) // { // if (!Data[r].DoesRowComplyWithFilters(filters, ft)) // { // Data.RemoveAt(r); // TODO: Toto je mozna velice casove narocne. Take bych nehodici se polozky oznacit jako deactive a potom je nepouzivat. // r--; // } // } //} public void ApplyFilters(string[] filters, FilteringType ft) { StayAfterFiltering = new bool[SourceData.Rows.Count]; if (filters.Length == 0) { return; } filters = ToLowerCase(filters); for (int r = 0; r < SourceData.Rows.Count; r++) { if (!DoesRowComplyWithFilters(SourceData.Rows[r], filters, ft)) { StayAfterFiltering[r] = false; //SourceData.Rows.RemoveAt(r); // TODO: Toto je mozna velice casove narocne. Take bych nehodici se polozky oznacit jako deactive a potom je nepouzivat. //r--; } else { StayAfterFiltering[r] = true; } } }
void ShowIntellisense(string FilterString, List<ISqlObject> ComplementaryObjects, FilteringType Filter = FilteringType.Any) { bool QualifierBehind = false; int AutoCompleteLength = 0; List<string> Data; if (IsIntellisenseOn) { AutocompleteDialog.Close(); } Data = FilterString.Split('.').ToList(); CompletionDataProvider completionDataProvider; switch (Data.Count) { case 1://filter string 1 word, so is an schema or a dbobject or a temp object(alias, #table or @table) completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, null, Data[0], null); AutoCompleteLength = Data[0].Length; break; case 2://filter string 2 word, must be an schema, object or an object, child if (DataProvider.DbObjects.Any(X => X.Schema.Equals(Data[0], StringComparison.CurrentCultureIgnoreCase))) completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, Data[0], Data[1], null); else completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, null, Data[0], Data[1]); AutoCompleteLength = Data[1].Length; QualifierBehind = true; break; case 3://filter string 3 word, must be an schema, object, child completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, Data[0], Data[1], Data[2]); AutoCompleteLength = Data[2].Length; break; default://no filter string, show empty case 0://no filter string, show empty completionDataProvider = new CompletionDataProvider(null, PopIList, null, "", null); AutoCompleteLength = 0; break; } completionDataProvider.FilteringOption = Filter; completionDataProvider.ComplementaryObjects = ComplementaryObjects; //CompletionDataProvider completionDataProvider = new CompletionDataProvider(DataProvider, PopIList, FilterString); //SQLSCCProvider(CurChilds, Vars, DataProvider, PopIList, FilterString, CurrentFilter, FireAt); AutocompleteDialog = AutoCompleteWindow.ShowCompletionWindow( this, Query, "sql", completionDataProvider, ' ', AutoCompleteStartOffset + (FilterString.Length - AutoCompleteLength),//AutoCompleteStartOffset, AutoCompleteStartOffset + FilterString.Length,//FilterString.Length QualifierBehind ); if (AutocompleteDialog != null) { AutocompleteDialog.Closing += ISense_Closing; AutocompleteDialog.Closed += CodeCompletionWindowClosed; } }
//Process hot keys bool Query_DoProcessDialogKey(Keys keyData) { bool NoEcho = true, Echo = false; int CurPos; string TxtBef, TxtAft, CurrentWord; Token CurrentToken, LastToken; // Echo == true, then NoEcho == false #region Key shortcut processing switch (keyData) { case Keys.F5://Execute query if (BtnExecute.Enabled) BtnExecute_Click(null, null); return NoEcho; case Keys.Shift | Keys.F5://Stop execution if (BtnStop.Enabled) BtnStop_Click(null, null); return NoEcho; case Keys.Control | Keys.F5://Forced stop execution if (BtnExtremeStop.Enabled) BtnExtremeStop_Click(null, null); return NoEcho; case Keys.Control | Keys.C://Comment selection / Collapse outlining if (LastKeyPressed == (Keys.Control | Keys.K)) {//comment selection, or current line LastKeyPressed = Keys.Space;//clean the last key pressed aux var, to avoid wrong behavior if (Query.Enabled) BtnComment_Click(null, null); return NoEcho; } else if (LastKeyPressed == (Keys.Control | Keys.O)) {//collapse outlining LastKeyPressed = Keys.Space;//clean the last key pressed aux var, to avoid wrong behavior if (Query.Enabled) collapseToolStripMenuItem_Click(null, null); return NoEcho; } return Echo; case Keys.Control | Keys.U://Uncomment selection / to lower case the selection if (LastKeyPressed == (Keys.Control | Keys.K)) { LastKeyPressed = Keys.Space;//clean the last key pressed aux var, to avoid wrong behavior if (Query.Enabled) BtnUncomment_Click(null, null); return NoEcho; } else {//to lower case the selection toLowerCaseToolStripMenuItem1_Click(null, null); } return NoEcho; case Keys.Control | Keys.Shift | Keys.U://to upper case selection toUpperCseToolStripMenuItem_Click(null, null); break; case Keys.Control | Keys.F://Open search dialog BtnSearch_Click(null, null); return NoEcho; case Keys.Control | Keys.F3: string lookFor; if (Query.ActiveTextAreaControl.TextArea.SelectionManager.HasSomethingSelected) { lookFor = Query.ActiveTextAreaControl.TextArea.SelectionManager.SelectedText; } else { Token selToken; TokenList tokens = Query.Text.GetTokens(); selToken = tokens.GetTokenAtOffset(Query.CurrentOffset()); lookFor = selToken.Text; } if (_findForm == null) _findForm = new SearchAndReplace(); if (!String.IsNullOrEmpty(lookFor) && lookFor.Trim(' ', '\t', '\r', '\n').Length > 0) { _findForm.SetSearchString(lookFor); FindNext(true, false, String.Format("Specified text: {0}, was not found.", _findForm.LookFor)); return NoEcho; } break; case Keys.F3://Search next (forward) if (_findForm != null && !String.IsNullOrEmpty(_findForm.LookFor) && _findForm.LookFor.Trim(' ', '\t', '\r', '\n').Length > 0) { FindNext(true, false, String.Format("Specified text: {0}, was not found.", _findForm.LookFor)); } return NoEcho; case Keys.Shift | Keys.F3://Search next (Backward) if (_findForm != null && !String.IsNullOrEmpty(_findForm.LookFor) && _findForm.LookFor.Trim(' ', '\t', '\r', '\n').Length > 0) { FindNext(true, true, String.Format("Specified text: {0}, was not found.", _findForm.LookFor)); } return NoEcho; case Keys.F2://Toggle bookmark BtnBookmark_Click(null, null); return NoEcho; case Keys.Shift | Keys.F2://Go to previous bookmark BtnPrevious_Click(null, null); return NoEcho; case Keys.Control | Keys.F2://Go to next bookmark BtnNext_Click(null, null); return NoEcho; case Keys.Control | Keys.Shift | Keys.F2://Clear bookmarks BtnClearBookmarks_Click(null, null); return NoEcho; case Keys.Control | Keys.G://Save to file BtnSave_Click(null, null); return NoEcho; case Keys.Control | Keys.L://Load file BtnLoad_Click(null, null); return NoEcho; case Keys.Control | Keys.W://Hide/show results tab BtnShowHideResults_Click(null, null); return NoEcho; case Keys.F12://go to definition Token selToken2; TokenList tokens2 = Query.Text.GetTokens(); selToken2 = tokens2.GetTokenAtOffset(Query.CurrentOffset()); if (selToken2 != null && selToken2.Type == TokenType.WORD) { ISqlObject Obj = DataProvider.IsSqlObject(selToken2.Text); if (Obj != null) { Parent.AddQueryForm(Obj.Name, Obj.Script, DataProvider); } } return NoEcho; case Keys.Control | Keys.E://Expand outlining if (LastKeyPressed == (Keys.Control | Keys.O)) { LastKeyPressed = Keys.Space;//clean the last key pressed aux var, to avoid wrong behavior if (Query.Enabled) expandToolStripMenuItem_Click(null, null); return NoEcho; } return NoEcho; case Keys.Control | Keys.T://Toggle outlining if (LastKeyPressed == (Keys.Control | Keys.O)) { LastKeyPressed = Keys.Space; //clean the last key pressed aux var, to avoid wrong behavior if (Query.Enabled) toggleToolStripMenuItem_Click(null, null); return NoEcho; } else { break; } } #endregion CurPos = Query.CurrentOffset(); TxtBef = Query.Document.GetText(0, CurPos); TxtAft = Query.Document.GetText(CurPos, Query.Text.Length - CurPos); #region Autocomplete/intellisense code if (IsIntellisenseOn) { #region Code to handle the key pressed if the "intellisense" is active switch (keyData) { case Keys.Back: AutocompleteDialog.Close(); if (!String.IsNullOrEmpty(CurrentFilterString)) { CurrentFilterString = CurrentFilterString.Remove(CurrentFilterString.Length - 1); CancelAutoCompleteClosure = true; ShowIntellisense(CurrentFilterString, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); } return NoEcho; case Keys.Escape: AutocompleteDialog.Close(); curFiltering = FilteringType.None; break; case Keys.OemMinus: CurrentFilterString += "-"; ShowIntellisense(CurrentFilterString, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return Echo; case Keys.OemMinus | Keys.Shift: CurrentFilterString += "_"; ShowIntellisense(CurrentFilterString, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return Echo; case (Keys)65601: case Keys.A: case (Keys)65602: case Keys.B: case (Keys)65603: case Keys.C: case (Keys)65604: case Keys.D: case (Keys)65605: case Keys.E: case (Keys)65606: case Keys.F: case (Keys)65607: case Keys.G: case (Keys)65608: case Keys.H: case (Keys)65609: case Keys.I: case (Keys)65610: case Keys.J: case (Keys)65611: case Keys.K: case (Keys)65612: case Keys.L: case (Keys)65613: case Keys.M: case (Keys)65614: case Keys.N: case (Keys)65615: case Keys.O: case (Keys)65616: case Keys.P: case (Keys)65617: case Keys.Q: case (Keys)65618: case Keys.R: case (Keys)65619: case Keys.S: case (Keys)65620: case Keys.T: case (Keys)65621: case Keys.U: case (Keys)65622: case Keys.V: case (Keys)65623: case Keys.W: case (Keys)65624: case Keys.X: case (Keys)65625: case Keys.Y: case (Keys)65626: case Keys.Z: case Keys.NumPad0: case Keys.NumPad1: case Keys.NumPad2: case Keys.NumPad3: case Keys.NumPad4: case Keys.NumPad5: case Keys.NumPad6: case Keys.NumPad7: case Keys.NumPad8: case Keys.NumPad9: case System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.MButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.MButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.MButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.RButton | System.Windows.Forms.Keys.MButton | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.Back | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.LButton | System.Windows.Forms.Keys.Back | System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: case System.Windows.Forms.Keys.ShiftKey | System.Windows.Forms.Keys.Space: CurrentFilterString += ((char)keyData).ToString(); ShowIntellisense(CurrentFilterString, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return Echo; case Keys.Delete: case Keys.Left: case Keys.Right: return NoEcho; default: if (IsIntellisenseOn) return Echo; else return NoEcho; } #endregion } else { LastKeyPressed = keyData; #region Code to handle the key pressed if the intellisense is inactive switch (keyData) { case Keys.Control | Keys.OemPeriod://ctrl + . , Show autocomplete case Keys.Space | Keys.Control://ctrl + space, Show autocomplete CurrentToken = TxtBef.GetLastToken(); if (CurrentToken.Type == TokenType.EMPTYSPACE || CurrentToken.Type == TokenType.COMMA) { CurrentWord = ""; } else { CurrentWord = CurrentToken.Text; } CurrentFilterString = CurrentWord; AutoCompleteStartOffset = CurPos - CurrentWord.Length; curFiltering = FilteringType.Smart; ShowIntellisense(CurrentWord, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return NoEcho; case Keys.T | Keys.Control://ctrl + T , Show autocomplete for "field" items CurrentToken = TxtBef.GetLastToken(); if (CurrentToken.Type == TokenType.EMPTYSPACE || CurrentToken.Type == TokenType.COMMA) { CurrentWord = ""; } else { CurrentWord = CurrentToken.Text; } CurrentFilterString = CurrentWord; AutoCompleteStartOffset = CurPos - CurrentWord.Length; curFiltering = FilteringType.FieldItem; ShowIntellisense(CurrentWord, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return NoEcho; case Keys.Space://if the text before is an @ or an #, show posible vars or temp tables LastToken = TxtBef.GetLastToken(); if (LastToken.Text == "@") { TokenList Tokens = Query.Text.GetTokens(); List<string> Helper = new List<string>(); foreach (Token t in Tokens.List.Where(X => X.Type == TokenType.VARIABLE)) { string buff = t.Text.Contains(".") ? t.Text.Split('.')[0] : t.Text; if (!Helper.Contains(buff, StringComparer.CurrentCultureIgnoreCase)) Helper.Add(buff); } if (Helper.Count > 0) { ObjectSelector Os = new ObjectSelector("Variables detected on script", "Select variable", Helper); if (Os.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Query.InsertString(Os.SelectedObject.Length > 0 && Os.SelectedObject.StartsWith("@") ? Os.SelectedObject.Substring(1) : Os.SelectedObject); return NoEcho; } else { return Echo; } } return Echo; } else if (LastToken.Text == "#") { TokenList Tokens = Query.Text.GetTokens(); List<string> Helper = new List<string>(); foreach (Token t in Tokens.List.Where(X => X.Type == TokenType.TEMPTABLE)) { string buff = t.Text.Contains(".") ? t.Text.Split('.')[0] : t.Text; if (!Helper.Contains(buff, StringComparer.CurrentCultureIgnoreCase)) Helper.Add(buff); } if (Helper.Count > 0) { ObjectSelector Os = new ObjectSelector("Variables temp tables on script", "Select table", Helper); if (Os.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Query.InsertString(Os.SelectedObject.Length > 0 && Os.SelectedObject.StartsWith("#") ? Os.SelectedObject.Substring(1) : Os.SelectedObject); return NoEcho; } else { return Echo; } } return Echo; } else if (LastToken.Text.Equals("from", StringComparison.CurrentCultureIgnoreCase) || LastToken.Text.Equals("join", StringComparison.CurrentCultureIgnoreCase)) { Query.InsertString(" "); CurrentFilterString = ""; AutoCompleteStartOffset = CurPos + 1; curFiltering = FilteringType.FieldItem; ShowIntellisense("", GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return NoEcho; } break; case Keys.OemPeriod: case Keys.Decimal://show Sql Object childs... if any Query.InsertString("."); CurPos = Query.CurrentOffset(); TxtBef = Query.Document.GetText(0, CurPos); TxtAft = Query.Document.GetText(CurPos, Query.Text.Length - CurPos); CurrentToken = TxtBef.GetLastToken(); if (CurrentToken.Type == TokenType.EMPTYSPACE || CurrentToken.Type == TokenType.COMMA) { CurrentWord = ""; } else { CurrentWord = CurrentToken.Text; } CurrentFilterString = CurrentWord; AutoCompleteStartOffset = CurPos - CurrentWord.Length; curFiltering = FilteringType.Smart; ShowIntellisense(CurrentWord, GetAliasesAndAuxiliarTables(Query.Text), curFiltering); return NoEcho; case Keys.S | Keys.Control://ctrl + s , show list of snippets List<string> SnippetsNames = new List<string>(); List<string> SnippetsValues = new List<string>(); foreach (Snippet sn in Parent.GetSnippetList()) { SnippetsNames.Add(sn.Name); SnippetsValues.Add(sn.ShortCut); } ObjectSelector SnSelector = new ObjectSelector("Snippets detected", "Select the snippet, to insert his shortcut", SnippetsValues, SnippetsNames, false, 1); if (SnSelector.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Query.InsertString(SnSelector.SelectedObject); return NoEcho; } else { return Echo; } break; case Keys.Tab://check if it is a request for a snippet, a variable or a temp table LastToken = TxtBef.GetLastToken(); if (LastToken.Text == "@") { TokenList Tokens = Query.Text.GetTokens(); List<string> Helper = new List<string>(); foreach (Token t in Tokens.List.Where(X => X.Type == TokenType.VARIABLE)) { string buff = t.Text.Contains(".") ? t.Text.Split('.')[0] : t.Text; if (!Helper.Contains(buff, StringComparer.CurrentCultureIgnoreCase)) Helper.Add(buff); } if (Helper.Count > 0) { ObjectSelector Os = new ObjectSelector("Variables detected on script", "Select variable", Helper); if (Os.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Query.InsertString(Os.SelectedObject.Length > 0 && Os.SelectedObject.StartsWith("@") ? Os.SelectedObject.Substring(1) : Os.SelectedObject); return NoEcho; } else { return Echo; } } return Echo; } else if (LastToken.Text == "#") { TokenList Tokens = Query.Text.GetTokens(); List<string> Helper = new List<string>(); foreach (Token t in Tokens.List.Where(X => X.Type == TokenType.TEMPTABLE)) { string buff = t.Text.Contains(".") ? t.Text.Split('.')[0] : t.Text; if (!Helper.Contains(buff, StringComparer.CurrentCultureIgnoreCase)) Helper.Add(buff); } if (Helper.Count > 0) { ObjectSelector Os = new ObjectSelector("Variables temp tables on script", "Select table", Helper); if (Os.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Query.InsertString(Os.SelectedObject.Length > 0 && Os.SelectedObject.StartsWith("#") ? Os.SelectedObject.Substring(1) : Os.SelectedObject); return NoEcho; } else { return Echo; } } return Echo; } else if (LastToken.Type == TokenType.WORD) {//check for snippet string SnippetScript = Parent.IsInsertSnippet(LastToken.Text); if (!String.IsNullOrEmpty(SnippetScript)) { int Offset = Query.CurrentOffset(); Query.SetSelectionByOffset(Offset - LastToken.Text.Length, Offset); InsertSnippet(SnippetScript); return NoEcho; } return Echo; } break; default: //this.Text = keyData.ToString(); return Echo; } #endregion } #endregion return Echo; }
public MappedMaterial(Map2d map, TextureWrap wrapMode, FilteringType filtering = FilteringType.Best) { this.Map = map; this.Sampler = new Sampler2d(map, wrapMode, filtering); }