public override void GetInspectionWarehouseRows() { if (SortBy == null) { SortBy = "it.Iserial"; } int?colorIserial = null; if (ColorPerRow != null) { colorIserial = ColorPerRow.Iserial; } int?iserial = null; if (ItemPerRow.Iserial > 0) { iserial = ItemPerRow.Iserial; } if (ItemPerRow.ItemGroup != null && (ItemPerRow.ItemGroup.ToLower().Contains("acc") || ItemPerRow.ItemGroup.ToLower().Contains("fp")) || (SelectedItemType != null && (SelectedItemType.ToLower().Contains("acc") || SelectedItemType.ToLower().Contains("fp")))) { WarehouseClient.GetAccWarehouseRowsAsync(WarehouseCode, SelectedItemType, iserial , colorIserial, SelectedSize, SelectedBatchNo); } else { WarehouseClient.GetItemDimensionsQuantitiesByDateAsync( WarehouseCode, iserial, ItemPerRow.ItemGroup, colorIserial, SelectedSize, SelectedBatchNo, DocDate); } }
/// <summary> /// navigates to the directory selected by the user /// </summary> private void OpenDir() { m_SelectedItem = -1; m_SelectedItemType = SelectedItemType.None; Path += "/" + Filename; Filename = ""; }
public virtual void GetInspectionWarehouseRows() { if (SortBy == null) { SortBy = "it.Iserial"; } int?colorIserial = null; if (ColorPerRow != null) { colorIserial = ColorPerRow.Iserial; } int?iserial = null; if (ItemPerRow.Iserial > 0) { iserial = ItemPerRow.Iserial; } if ((ItemPerRow.ItemGroup != null && (ItemPerRow.ItemGroup.ToLower().Contains("acc") || ItemPerRow.ItemGroup.ToLower().Contains("fp"))) || (SelectedItemType != null && (SelectedItemType.ToLower().Contains("acc") || SelectedItemType.ToLower().Contains("fp")))) { WarehouseClient.GetAccWarehouseRowsAsync(WarehouseCode, SelectedItemType, iserial , colorIserial, SelectedSize, SelectedBatchNo); } else { WarehouseClient.GetInspectionWarehouseRowsAsync(SearchResultList.Count, PageSize, SortBy, WarehouseCode, SelectedItemType, ItemPerRow.Code, (ColorPerRow != null ? ColorPerRow.Code : ""), SelectedSize, SelectedBatchNo); } }
private void lvDataSourceObjects_SelectedIndexChanged(object sender, System.EventArgs e) { CheckForInputSufficiency(); if (lvDataSourceObjects.SelectedItems.Count <= 0) { return; } if (selectedDataSource is IDbDriver) { IDbDriver dbDriver = selectedDataSource as IDbDriver; DataTable dt = dbDriver.GetTopTwoTable(lvDataSourceObjects.SelectedItems[0].Text); List <string> childCols = new List <string>(); foreach (DataColumn dc in dt.Columns) { childCols.Add(dc.ColumnName); } childCols.Sort(); cmbChildKey.DataSource = childCols; SelectedItemType = Dialogs.SelectedItemType.Table; } else if (selectedDataSource is Project) { Project project = selectedDataSource as Project; string viewName = lvDataSourceObjects.SelectedItems[0].Text; List <string> childCols = new List <string>(); if (project.Views.Contains(viewName) && lvDataSourceObjects.SelectedItems[0].Group.ToString().ToLowerInvariant().Equals("epi info forms")) { foreach (Epi.Fields.Field field in project.Views[viewName].Fields.DataFields) { childCols.Add(field.Name); } childCols.Sort(); cmbChildKey.DataSource = childCols; SelectedItemType = Dialogs.SelectedItemType.Form; } else if (lvDataSourceObjects.SelectedItems[0].Group.ToString().ToLowerInvariant().Equals("tables")) { IDbDriver dbDriver = project.CollectedData.GetDbDriver(); DataTable dt = dbDriver.GetTopTwoTable(lvDataSourceObjects.SelectedItems[0].Text); foreach (DataColumn dc in dt.Columns) { childCols.Add(dc.ColumnName); } childCols.Sort(); cmbChildKey.DataSource = childCols; SelectedItemType = Dialogs.SelectedItemType.Table; } } }
private static void OnDesignerStartSelect(object sender, MouseButtonEventArgs e) { _selectedItemType = _designerVewModel.ItemToDraw.SelectedItemType; if (_selectedItemType != SelectedItemType.SelectItem) { return; } _rubberbandSelectionStartPoint = e.GetPosition(_itemsPanel); _designerVewModel.SelectionService.ClearSelection(); _itemsPanel.Focus(); e.Handled = true; }
private static void OnDesignerStartDraw(object sender, MouseButtonEventArgs e) { _selectedItemType = _designerViewModel.ItemToDraw.SelectedItemType; if (_selectedItemType != SelectedItemType.DrawItem) { return; } _drawableInstance = Activator.CreateInstance(_designerViewModel.ItemToDraw.GetType()) as IDrawableItem; if (_drawableInstance == null) { return; } _selectionStartPoint = e.GetPosition(_itemsPanel); _drawableInstance.X1 = _selectionStartPoint.Value.X; _drawableInstance.Y1 = _selectionStartPoint.Value.Y; e.Handled = true; }
private string GenerateValidFileName(ListViewItem lvItem) { string baseName = ""; switch (lvItem.Text) { case "Class": baseName = "Class"; selectedItemType = SelectedItemType.Class; break; case "Interface": baseName = "Interface"; selectedItemType = SelectedItemType.Interface; break; } bool found = false; int filecounter = 1; string filename = ""; while (found == false) { filename = baseName + filecounter.ToString() + (_Language == ScriptLanguage.CSharp ? ".cs" : ".vb"); if (_CreatedFileNames != null) { if (_CreatedFileNames.Contains(filename) == false) { break; } } else { break; } filecounter++; } return(filename); }
public void SetSelectedItemType(SelectedItemType SelectedItemType) { if (selectedItemType == SelectedItemType) { return; } switch (SelectedItemType) { case SelectedItemType.Floor: rend.material = floorMarkerMaterial; break; case SelectedItemType.ClickableItem: rend.material = pickableItemMarkerMaterial; break; default: rend.material = otherMarkerMaterial; break; } selectedItemType = SelectedItemType; }
/////////////////////////////////////////////////////////// // navigates to the directory selected by the user /////////////////////////////////////////////////////////// private void OpenDir() { m_SelectedItem = -1; m_SelectedItemType = SelectedItemType.None; Path += "/" + Filename; Filename = ""; }
/////////////////////////////////////////////////////////// // draws a box with a list of directories and files /////////////////////////////////////////////////////////// private void FileBox(float x, float y, float width, float height) { // draw the box GUI.Box(new Rect(x, y, width - 20, height), ""); // setup directory info if (!System.IO.Directory.Exists(Path)) { vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Error", "Directory does not exist: '" + Path + "'"); Debug.LogError("Directory does not exist: " + Path); return; } DirectoryInfo directoryInfo = new DirectoryInfo(Path); FileInfo[] files = directoryInfo.GetFiles(); DirectoryInfo[] directories = directoryInfo.GetDirectories(); // create a scrollview for the appropriate amount of // files and directories int dirCount = directoryInfo.GetDirectories().Length; int fileCount = 0; foreach (FileInfo file in files) { if (!HasCorrectExtension(file.Name)) continue; fileCount++; } float viewSize = ((dirCount * 20) + (fileCount * 20) + 20); m_FileScrollPos = GUI.BeginScrollView(new Rect(x + 1, y + 1, width - 20 - 2, height - 2), m_FileScrollPos, new Rect(0, 0, 0, viewSize), false, false); // reset selection m_SelectedItemType = SelectedItemType.None; // --- draw directories --- int yPos = 0; foreach (DirectoryInfo directory in directories) { // possibly set selection to this item GUIStyle style; if (m_SelectedItem == yPos) { style = m_SelectedDirStyle; m_SelectedItemType = SelectedItemType.Dir; GUI.color = new Color(0.9f, 0.9f, 1, 1); } else { style = m_DirStyle; GUI.color = new Color(1, 1, 1, 1); } // draw the directory name and check for input if (GUI.Button(new Rect(5, (yPos * 20) + 5, width - 47, 20), directory.Name, style)) { // select item on single click m_SelectedItem = yPos; Filename = directory.Name; // open folder on double click if (DetectDoubleClick()) OpenDir(); } // draw the yellow folder icon (we just use a regular button for this). GUI.color = new Color(1, 0.94f, 0.47f, 1); GUI.Button(new Rect(10, (yPos * 20) + 3 + 5, 17, 14), ""); GUI.color = Color.white; // if the user has manually changed the filename to the same name // as this item, select it (even if it has not been clicked) if (m_FilenameDirty) { if (directory.Name == Filename) m_SelectedItem = yPos; } yPos++; } // --- draw files --- foreach (FileInfo file in files) { // if we're filtering for extension, skip items with the wrong one if (!HasCorrectExtension(file.Name)) continue; // possibly set selection to this item GUIStyle style; if (m_SelectedItem == yPos) { style = m_SelectedFileStyle; m_SelectedItemType = SelectedItemType.File; GUI.color = new Color(0.9f, 0.9f, 1, 1); } else { style = m_FileStyle; GUI.color = new Color(1, 1, 1, 1); } // draw the filename and check for input string name = file.Name; if (GUI.Button(new Rect(5, (yPos * 20) + 5, width - 47, 20), name, style)) { // select item on single click m_SelectedItem = yPos; Filename = file.Name; // open or save file on double click if (DetectDoubleClick()) { if (m_Mode == Mode.Open) DoOpen(); else DoSave(); } } // if the user has manually changed the filename to the same name // as this item, select it (even if it has not been clicked) if (m_FilenameDirty) { if (file.Name == Filename) m_SelectedItem = yPos; } yPos++; } GUI.color = new Color(1, 1, 1, 1); GUI.EndScrollView(); }
private void DoSave(bool overwriteExisting) { Result = null; // open directories if (m_SelectedItemType == SelectedItemType.Dir) { OpenDir(); return; } // force 'File' item type for non-existing file if (m_SelectedItemType == SelectedItemType.None) m_SelectedItemType = SelectedItemType.File; // check for bad filename if (Filename.Contains("\\") || Filename.Contains("/") || Filename.Contains(":") || Filename.Contains("*") || Filename.Contains("?") || Filename.Contains("\"") || Filename.Contains("<") || Filename.Contains(">") || Filename.Contains("|")) { vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Error", "A filename cannot contain any of the following characters: \\ / : * ? \" < > |"); return; } // append extension if none present in the filename if (!Filename.EndsWith(m_Extension)) Filename += "." + m_Extension; // execute callback if (m_SelectedItemType == SelectedItemType.File) ExecuteCallback(); // confirm if there was some problem with an existing file, and // if the user so chooses, save again after clearing the file if (!overwriteExisting && !string.IsNullOrEmpty(Result)) { vp_MessageBox.Create(vp_MessageBox.Mode.YesNo, "Confirm", Result, delegate(vp_MessageBox.Answer answer) { if (answer == vp_MessageBox.Answer.Yes) { try { File.Delete(Path + "/" + Filename); DoSave(true); // execute again without warning } catch { Debug.LogError("Error: Failed to overwrite file."); } } }); return; } }
private void cmdCancel_Click(object sender, EventArgs e) { txtName.Text = ""; selectedItemType = SelectedItemType.None; this.Hide(); }
/// <summary> /// interprets the user choice as a save operation and executes it /// </summary> private void DoSave(bool overwriteExisting) { Result = null; // open directories if (m_SelectedItemType == SelectedItemType.Dir) { OpenDir(); return; } // force 'File' item type for non-existing file if (m_SelectedItemType == SelectedItemType.None) { m_SelectedItemType = SelectedItemType.File; } // check for bad filename if (Filename.Contains("\\") || Filename.Contains("/") || Filename.Contains(":") || Filename.Contains("*") || Filename.Contains("?") || Filename.Contains("\"") || Filename.Contains("<") || Filename.Contains(">") || Filename.Contains("|")) { vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Error", "A filename cannot contain any of the following characters: \\ / : * ? \" < > |"); return; } // append extension if none present in the filename if (!Filename.EndsWith(m_Extension)) { Filename += "." + m_Extension; } // execute callback if (m_SelectedItemType == SelectedItemType.File) { ExecuteCallback(); } // confirm if there was some problem with an existing file, and // if the user so chooses, save again after clearing the file if (!overwriteExisting && !string.IsNullOrEmpty(Result)) { vp_MessageBox.Create(vp_MessageBox.Mode.YesNo, "Confirm", Result, delegate(vp_MessageBox.Answer answer) { if (answer == vp_MessageBox.Answer.Yes) { try { File.Delete(Path + "/" + Filename); DoSave(true); // execute again without warning } catch { Debug.LogError("Error: Failed to overwrite file."); } } }); return; } }
/// <summary> /// draws a box with a list of directories and files /// </summary> private void FileBox(float x, float y, float width, float height) { // draw the box GUI.Box(new Rect(x, y, width - 20, height), ""); // setup directory info if (!System.IO.Directory.Exists(Path)) { vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Error", "Directory does not exist: '" + Path + "'"); Debug.LogError("Directory does not exist: " + Path); return; } DirectoryInfo directoryInfo = new DirectoryInfo(Path); FileInfo[] files = directoryInfo.GetFiles(); DirectoryInfo[] directories = directoryInfo.GetDirectories(); // create a scrollview for the appropriate amount of // files and directories int dirCount = directoryInfo.GetDirectories().Length; int fileCount = 0; foreach (FileInfo file in files) { if (!HasCorrectExtension(file.Name)) { continue; } fileCount++; } float viewSize = ((dirCount * 20) + (fileCount * 20) + 20); m_FileScrollPos = GUI.BeginScrollView(new Rect(x + 1, y + 1, width - 20 - 2, height - 2), m_FileScrollPos, new Rect(0, 0, 0, viewSize), false, false); // reset selection m_SelectedItemType = SelectedItemType.None; // --- draw directories --- int yPos = 0; foreach (DirectoryInfo directory in directories) { // possibly set selection to this item GUIStyle style; if (m_SelectedItem == yPos) { style = m_SelectedDirStyle; m_SelectedItemType = SelectedItemType.Dir; GUI.color = new Color(0.9f, 0.9f, 1, 1); } else { style = m_DirStyle; GUI.color = new Color(1, 1, 1, 1); } // draw the directory name and check for input if (GUI.Button(new Rect(5, (yPos * 20) + 5, width - 47, 20), directory.Name, style)) { // select item on single click m_SelectedItem = yPos; Filename = directory.Name; // open folder on double click if (DetectDoubleClick()) { OpenDir(); } } // draw the yellow folder icon (we just use a regular button for this). GUI.color = new Color(1, 0.94f, 0.47f, 1); GUI.Button(new Rect(10, (yPos * 20) + 3 + 5, 17, 14), ""); GUI.color = Color.white; // if the user has manually changed the filename to the same name // as this item, select it (even if it has not been clicked) if (m_FilenameDirty) { if (directory.Name == Filename) { m_SelectedItem = yPos; } } yPos++; } // --- draw files --- foreach (FileInfo file in files) { // if we're filtering for extension, skip items with the wrong one if (!HasCorrectExtension(file.Name)) { continue; } // possibly set selection to this item GUIStyle style; if (m_SelectedItem == yPos) { style = m_SelectedFileStyle; m_SelectedItemType = SelectedItemType.File; GUI.color = new Color(0.9f, 0.9f, 1, 1); } else { style = m_FileStyle; GUI.color = new Color(1, 1, 1, 1); } // draw the filename and check for input string name = file.Name; if (GUI.Button(new Rect(5, (yPos * 20) + 5, width - 47, 20), name, style)) { // select item on single click m_SelectedItem = yPos; Filename = file.Name; // open or save file on double click if (DetectDoubleClick()) { if (m_Mode == Mode.Open) { DoOpen(); } else { DoSave(); } } } // if the user has manually changed the filename to the same name // as this item, select it (even if it has not been clicked) if (m_FilenameDirty) { if (file.Name == Filename) { m_SelectedItem = yPos; } } yPos++; } GUI.color = new Color(1, 1, 1, 1); GUI.EndScrollView(); }
private void DoSave(bool overwriteExisting) { // open directories if (m_SelectedItemType == SelectedItemType.Dir) { OpenDir(); return; } // force 'File' item type for non-existing file if (m_SelectedItemType == SelectedItemType.None) m_SelectedItemType = SelectedItemType.File; // check for bad filename if (Filename.Contains("\\") || Filename.Contains("/") || Filename.Contains(":") || Filename.Contains("*") || Filename.Contains("?") || Filename.Contains("\"") || Filename.Contains("<") || Filename.Contains(">") || Filename.Contains("|")) { vp_MessageBox.Create(vp_MessageBox.Mode.OK, "Error", "A filename cannot contain any of the following characters: \\ / : * ? \" < > |"); return; } // append extension if none present in the filename if (!Filename.EndsWith(m_Extension)) Filename += "." + m_Extension; // warn if file already exists if (!overwriteExisting && System.IO.File.Exists(Path + "/" + Filename)) { vp_MessageBox.Create(vp_MessageBox.Mode.YesNo, "Confirm", Filename + " already exists.\nDo you want to replace it?", delegate(vp_MessageBox.Answer answer) { if (answer == vp_MessageBox.Answer.Yes) DoSave(true); // execute again without warning }); return; } // execute callback if (m_SelectedItemType == SelectedItemType.File) ExecuteCallback(); }