public void CheckVersionWriteLogin(object sender, string message, string version,string systemError) { if( !String.IsNullOrEmpty(version) ){ string fileName = System.IO.Path.GetFileNameWithoutExtension(version); Gtk.Application.Invoke(delegate { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("new_version_is",fileName),MainClass.Languages.Translate("download_version") , Gtk.MessageType.Info,null); int res= md.ShowDialog(); if(res==(int)Gtk.ResponseType.Yes){ RunUpdater(MainClass.User.Token); } }); } else if (String.IsNullOrEmpty(version) ) { int i = systemError.LastIndexOf(":"); string msg = systemError; if(i>-1) msg = systemError.Substring(i+1); if(msg.Trim().ToLower() == "(410) gone."){ ShowModalError(MainClass.Languages.Translate("your_account_expired"),""); } else ShowModalError(message,systemError); } }
protected override void OnActivated() { base.OnActivated (); MessageDialogs md = new MessageDialogs(new string[]{MainClass.Languages.Translate("delete_project_delete"),MainClass.Languages.Translate("cancel")}, MainClass.Languages.Translate("delete_project"), "", Gtk.MessageType.Question,MainClass.MainWindow); int resultAction = md.ShowDialog(); if(resultAction == -1){ MainClass.MainWindow.DeleteProject(); MainClass.MainWindow.SaveWorkspace(); } /*MessageDialogs md = new MessageDialogs(new string[]{MainClass.Languages.Translate("delete_project_unload"),MainClass.Languages.Translate("delete_project_delete"),MainClass.Languages.Translate("cancel")}, MainClass.Languages.Translate("delete_project"), MainClass.Languages.Translate("delete_project_f1"), Gtk.MessageType.Question,MainClass.MainWindow); int resultAction = md.ShowDialog(); switch (resultAction) { case -1: //"Unload" MainClass.MainWindow.UnloadProject(); MainClass.MainWindow.SaveWorkspace(); break; case -2://"Delete" MainClass.MainWindow.DeleteProject(); MainClass.MainWindow.SaveWorkspace(); break; default: //"Cancel" break; }*/ }
internal static WorkspaceUserFile OpenWorkspaceUserFile(string filePath) { if (System.IO.File.Exists(filePath)){ try{ using (FileStream fs = File.OpenRead(filePath)) { XmlSerializer serializer = new XmlSerializer(typeof(WorkspaceUserFile)); WorkspaceUserFile p = (WorkspaceUserFile)serializer.Deserialize(fs); p.FilePath = filePath; return p; } }catch{//(Exception ex){ WorkspaceUserFile p =new WorkspaceUserFile(filePath); return p; /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.OkCancel, MainClass.Languages.Translate("project_is_corrupted", filePath), MainClass.Languages.Translate("delete_corupted_project"), Gtk.MessageType.Question,null); int res = md.ShowDialog(); return null;*/ } }else { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_not_exit_f1", filePath), "", Gtk.MessageType.Error,null); md.ShowDialog(); return null; } }
public bool Load() { try { IniFile mpi = new IniFile(FilePath); this.Height = mpi.ReadInt("display", "height", 1); this.Width = mpi.ReadInt("display", "width", 1); this.Title = mpi.ReadString("info", "title", System.IO.Path.GetFileName(FilePath)); this.Author = mpi.ReadString("info", "author", " "); this.Url = mpi.ReadString("info", "url", " "); /*string tmp =mpi.ReadString("device", "tablet", " "); if(String.IsNullOrEmpty(tmp)) this.Tablet = false; */ int tmp =mpi.ReadInt("device", "tablet", 0); if(tmp ==1) { this.Tablet = true; } else this.Tablet = false; //this.Tablet = Convert.ToBoolean(mpi.ReadString("device", "tablet", " ")); return true; } catch { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), MainClass.Languages.Translate("error_load_resolution_file", FilePath), Gtk.MessageType.Error,null); ms.ShowDialog(); return false; } }
public void LoginNoWrite(object sender, string message) { lblStatus.LabelProp = MainClass.Languages.Translate("error_feedback"); buttonOk.Sensitive = true; MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_feedback"),message, Gtk.MessageType.Error,this); md.ShowDialog(); }
void OnRenameItemClick(object sender, EventArgs e) { MessageDialogs md; string message = ""; if (isDir) { if ((String.IsNullOrEmpty(selectedItem)) || !Directory.Exists(selectedItem)) { md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("file_not_exist_f1", selectedItem), "", Gtk.MessageType.Error); md.ShowDialog(); return; } } else { if ((String.IsNullOrEmpty(selectedItem)) || !File.Exists(selectedItem)) { md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("file_not_exist_f1", selectedItem), "", Gtk.MessageType.Error); md.ShowDialog(); return; } } string oldName = System.IO.Path.GetFileName(selectedItem); EntryDialog ed = new EntryDialog(oldName, MainClass.Languages.Translate("new_name")); int result = ed.Run(); if (result == (int)ResponseType.Ok) { string newName = ed.TextEntry; string newPath = ""; string msg = FileUtility.RenameItem(selectedItem, isDir, newName, out newPath); if (!String.IsNullOrEmpty(msg)) { message = MainClass.Languages.Translate("cannot_rename_file", selectedItem); if (isDir) { message = MainClass.Languages.Translate("cannot_rename_directory", selectedItem); } MessageDialogs mdd = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, message, msg, Gtk.MessageType.Error); mdd.ShowDialog(); return; } } ed.Destroy(); FillStore(true); }
protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { if (String.IsNullOrEmpty(entrTableName.Text)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_enter_table_name"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return; } if (fields.Count < 1) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("no_fileds_define"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return; } string tableName = entrTableName.Text; string sql = string.Format("CREATE TABLE {0}( ", tableName); for (int r = 0; r < fields.Count; r++) { string type = fields[r].Type; string defValue = fields[r].DefaultValue; sql = sql + fields[r].Name + " " + type; if (fields[r].NotNULL) { sql = sql + " " + "NOT NULL"; } if (!String.IsNullOrEmpty(defValue)) { if ((type.IndexOf("NUMERIC") > -1) || (type.IndexOf("INTEGER") > -1)) { sql = sql + " DEFAULT " + defValue; } else { sql = sql + " DEFAULT '" + defValue + "'"; } } if (r < fields.Count - 1) { sql = sql + ","; } } sql = sql + ") ;"; sqlLiteDal.RunSqlScalar(sql); //CreateTable(); this.Respond(ResponseType.Ok); }
public void LoginNoWrite(object sender, string message) { Console.WriteLine(message); lblStatus.LabelProp = MainClass.Languages.Translate("error_error"); MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_error"),message, Gtk.MessageType.Error,null); md.ShowDialog(); this.Respond(Gtk.ResponseType.Ok); }
public void LoginNoWrite(object sender, string message) { Console.WriteLine(message); lblStatus.LabelProp = MainClass.Languages.Translate("error_error"); MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_error"), message, Gtk.MessageType.Error, null); md.ShowDialog(); this.Respond(Gtk.ResponseType.Ok); }
private bool CheckPage0() { if (cbeWorkspace.ActiveText.Contains(" ")) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_work"), "", Gtk.MessageType.Error); md.ShowDialog(); return(false); } if (String.IsNullOrEmpty(cbeWorkspace.ActiveText)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_name"), "", Gtk.MessageType.Error); md.ShowDialog(); return(false); } if (String.IsNullOrEmpty(entrProjectName.Text)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_project_name"), "", Gtk.MessageType.Error); md.ShowDialog(); return(false); } if (entrProjectName.Text.Contains(" ")) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_proj"), "", Gtk.MessageType.Error); md.ShowDialog(); return(false); } TreeIter tiChb; cbeWorkspace.GetActiveIter(out tiChb); int type = Convert.ToInt32(storeWorkspace.GetValue(tiChb, 2)); if ((cbeWorkspace.Active < 0) || (type == 2)) { string workspaceName = cbeWorkspace.ActiveText; string workspaceRoot = System.IO.Path.Combine(feLocation.Path, workspaceName); string workspaceFile = System.IO.Path.Combine(workspaceRoot, workspaceName + ".msw"); if (File.Exists(workspaceFile)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_exist"), "", Gtk.MessageType.Error); md.ShowDialog(); return(false); } } return(true); }
private void GetTableStructure() { fieldsStore.Clear(); fields.Clear(); SqliteConnection conn = (SqliteConnection)sqlLiteDal.GetConnect(); SqliteDataReader dr = null; string sql = String.Format("PRAGMA table_info( '{0}' );", tableName); //DataTable dt = null; try { //dt = sqlLiteDal.RunSqlReader(sql); using (SqliteCommand cmd = conn.CreateCommand()) { cmd.CommandText = sql; dr = cmd.ExecuteReader(); } if (dr.HasRows) { while (dr.Read()) { string name = dr[1].ToString(); string type = dr[2].ToString(); bool notnull = Convert.ToBoolean(dr[3]); string dfltValue = dr[4].ToString(); //bool pk = Convert.ToBoolean(dr[5]); FieldTable ft = new FieldTable(name, type); ft.NotNULL = notnull; ft.DefaultValue = dfltValue; fields.Add(ft); fieldsStore.AppendValues(name, type, notnull.ToString(), dfltValue, ft); } } } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error, this); ms.ShowDialog(); } finally { if (dr != null) { dr.Close(); } dr = null; conn.Close(); conn = null; } }
public bool Save() { //appFile.Orientation = cbOrientation.ActiveText; try{ FillAppFile(); appFile.Save(); } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error); ms.ShowDialog(); return(false); } return(true); }
private void OpenProject() { TreeSelection ts = tvFiles.Selection; TreeIter ti = new TreeIter(); ts.GetSelected(out ti); TreePath[] tp = ts.GetSelectedRows(); if (tp.Length < 1) { return; } //string fileState = tvFiles.Model.GetValue(ti, 2).ToString(); string filePath = tvFiles.Model.GetValue(ti, 3).ToString(); string prjName = tvFiles.Model.GetValue(ti, 1).ToString(); int fileStat = (int)tvFiles.Model.GetValue(ti, 4); if (fileStat == (int)StatEnum.Open) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened", prjName), null, Gtk.MessageType.Error); md.ShowDialog(); return; } else if (fileStat == (int)StatEnum.Close) { MainClass.MainWindow.OpenProject(filePath, true); this.Respond(ResponseType.Ok); } else if (fileStat == (int)StatEnum.Not_Create) { AppFile appFile = new AppFile(filePath); string projectDir = appFile.Directory; if (!Directory.Exists(projectDir)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("application_foldes_not_exist"), projectDir, Gtk.MessageType.Error); md.ShowDialog(); return; } MainClass.MainWindow.ConvertAppToProject(appFile); this.Respond(ResponseType.Ok); } this.Respond(ResponseType.Ok); }
private bool CheckForm() { if (string.IsNullOrEmpty(entry3.Text)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_project_name"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return(false); } if (this.entry3.Text.Contains(" ")) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_proj"), "", Gtk.MessageType.Error); md.ShowDialog(); return(false); } return(true); }
public void CheckVersionWriteNoLogin(object sender, string message, string version,string systemError) { if( !String.IsNullOrEmpty(version) ){ string fileName = System.IO.Path.GetFileNameWithoutExtension(version); Gtk.Application.Invoke(delegate { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("new_version_is",fileName),MainClass.Languages.Translate("download_version"), Gtk.MessageType.Question,null); int res= md.ShowDialog(); if(res==(int)Gtk.ResponseType.Yes){ RunUpdater(""); } }); } else { ShowModalError(message,systemError); } }
private void Register() { if (String.IsNullOrEmpty(entrLoginR.Text)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("login_is_required"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return; } if (String.IsNullOrEmpty(entrPasswordR1.Text)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("password_is_required"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return; } if (entrPasswordR1.Text != entrPasswordR2.Text) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("password_dont_match"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return; } if (!CheckEmail(entrEmailR.Text)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("email_address_invalid"), "", Gtk.MessageType.Error, this); md.ShowDialog(); return; } try{ LoggUser log = new LoggUser(); log.Register(entrEmailR.Text, entrLoginR.Text, entrPasswordR1.Text, LoginYesWrite, LoginNoWrite); }catch (Exception ex) { ShowModalError(ex.Message); return; } this.Respond(Gtk.ResponseType.Ok); }
public bool Save() { try { IniFile mpi = new IniFile(FilePath); mpi.WriteString("info", "title", this.Title); mpi.WriteString("info", "author", this.Author); mpi.WriteString("info", "url", this.Url); mpi.WriteInt("display", "height", this.Height); mpi.WriteInt("display", "width", this.Width); mpi.WriteInt("device", "tablet", this.Tablet?1:0); mpi.Flush(); return true; } catch { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), MainClass.Languages.Translate("error_save_resolution_file" , FilePath), Gtk.MessageType.Error); ms.ShowDialog(); return false; } }
public bool Save() { try { IniFile mpi = new IniFile(FilePath); mpi.WriteString("info", "title", this.Title); mpi.WriteString("info", "author", this.Author); mpi.WriteString("info", "url", this.Url); mpi.WriteInt("display", "height", this.Height); mpi.WriteInt("display", "width", this.Width); mpi.WriteInt("device", "tablet", this.Tablet?1:0); mpi.Flush(); return(true); } catch { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), MainClass.Languages.Translate("error_save_resolution_file", FilePath), Gtk.MessageType.Error); ms.ShowDialog(); return(false); } }
public void CheckVersionWriteNoLogin(object sender, string message, string version, string systemError) { if (!String.IsNullOrEmpty(version)) { string fileName = System.IO.Path.GetFileNameWithoutExtension(version); Gtk.Application.Invoke(delegate { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("new_version_is", fileName), MainClass.Languages.Translate("download_version"), Gtk.MessageType.Question, null); int res = md.ShowDialog(); if (res == (int)Gtk.ResponseType.Yes) { RunUpdater(""); } }); } else { ShowModalError(message, systemError); } }
public IDbConnection GetConnect() { IDbConnection dbcon; // = new SqliteConnection(); try { // /*if(MainClass.Platform.IsMac){ * string connectionString = "Data Source="+database; * dbcon = new SQLiteConnection(connectionString); * dbcon.Open(); * } else {*/ //string connectionString = "URI=file:" + database+",version=3"; string connectionString = "URI=file:" + database + ",version=3"; dbcon = (IDbConnection) new SqliteConnection(connectionString); dbcon.Open(); //} } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, Gtk.MessageType.Error, null); ms.ShowDialog(); Tool.Logger.Error("GetConnect ->>" + ex.Message, null); dbcon = null; } return(dbcon); }
protected virtual void OnBtnCreateFieldClicked(object sender, System.EventArgs e) { SqlLiteAddFiled sqlAddField = new SqlLiteAddFiled(this); int result = sqlAddField.Run(); if (result == (int)ResponseType.Ok){ FieldTable ft = sqlAddField.FieldTable; if (ft!= null ){ FieldTable cdFind = fields.Find(x=>x.Name.ToUpper() ==ft.Name.ToUpper()); if (cdFind != null){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("fileds_exist", ft.Name), "", Gtk.MessageType.Error,this); md.ShowDialog(); sqlAddField.Destroy(); return; } fieldsStore.AppendValues(ft.Name,ft.Type,ft); fields.Add(ft); } } sqlAddField.Destroy(); }
public IDbConnection GetConnect() { IDbConnection dbcon;// = new SqliteConnection(); try {// /*if(MainClass.Platform.IsMac){ string connectionString = "Data Source="+database; dbcon = new SQLiteConnection(connectionString); dbcon.Open(); } else {*/ //string connectionString = "URI=file:" + database+",version=3"; string connectionString = "URI=file:" + database+",version=3"; dbcon = (IDbConnection)new SqliteConnection(connectionString); dbcon.Open(); //} } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, Gtk.MessageType.Error,null); ms.ShowDialog(); Tool.Logger.Error("GetConnect ->>" +ex.Message,null); dbcon = null; } return dbcon; }
public void CheckVersionWriteLogin(object sender, string message, string version, string systemError) { if (!String.IsNullOrEmpty(version)) { string fileName = System.IO.Path.GetFileNameWithoutExtension(version); Gtk.Application.Invoke(delegate { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("new_version_is", fileName), MainClass.Languages.Translate("download_version"), Gtk.MessageType.Info, null); int res = md.ShowDialog(); if (res == (int)Gtk.ResponseType.Yes) { RunUpdater(MainClass.User.Token); } }); } else if (String.IsNullOrEmpty(version)) { int i = systemError.LastIndexOf(":"); string msg = systemError; if (i > -1) { msg = systemError.Substring(i + 1); } if (msg.Trim().ToLower() == "(410) gone.") { ShowModalError(MainClass.Languages.Translate("your_account_expired"), ""); } else { ShowModalError(message, systemError); } } }
public bool Save() { if ((!modified) || (ic.ListPoint == null)) { return(true); } try { //string json = JsonConvert.SerializeObject(ic.ListPoint, Formatting.Indented); string json = ""; System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); oSerializer.RegisterConverters(new[] { new BarierPointJavaScriptConverter() }); string sJSON = oSerializer.Serialize(ic.ShapeListPoint); sJSON = sJSON.Replace("\"x\"", "x"); sJSON = sJSON.Replace("\"y\"", "y"); json = sJSON; using (StreamWriter file = new StreamWriter(fileBarierName)) { file.Write(json); file.Close(); file.Dispose(); } OnModifiedChanged(false); } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", fileName), ex.Message, Gtk.MessageType.Error); ms.ShowDialog(); return(false); } // do save return(true); }
private void OpenProject() { TreeSelection ts = tvFiles.Selection; TreeIter ti = new TreeIter(); ts.GetSelected(out ti); TreePath[] tp = ts.GetSelectedRows(); if (tp.Length < 1) return ; //string fileState = tvFiles.Model.GetValue(ti, 2).ToString(); string filePath = tvFiles.Model.GetValue(ti, 3).ToString(); string prjName = tvFiles.Model.GetValue(ti, 1).ToString(); int fileStat = (int)tvFiles.Model.GetValue(ti, 4); if (fileStat == (int)StatEnum.Open ){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_is_opened", prjName), null, Gtk.MessageType.Error); md.ShowDialog(); return ; } else if (fileStat == (int)StatEnum.Close ){ MainClass.MainWindow.OpenProject(filePath,true); this.Respond(ResponseType.Ok); } else if (fileStat == (int)StatEnum.Not_Create ){ AppFile appFile= new AppFile(filePath); string projectDir = appFile.Directory; if (!Directory.Exists(projectDir) ) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("application_foldes_not_exist"), projectDir, Gtk.MessageType.Error); md.ShowDialog(); return ; } MainClass.MainWindow.ConvertAppToProject(appFile); this.Respond(ResponseType.Ok); } this.Respond(ResponseType.Ok); }
private void GetTables() { tableModel.Clear(); tablesComboModel.Clear(); SqliteConnection conn = (SqliteConnection)sqlLiteDal.GetConnect(); SqliteDataReader dr = null; try { //conn.Open(); using (SqliteCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT name,sql FROM sqlite_master WHERE type='table' ORDER BY name;"; dr = cmd.ExecuteReader(); } if (dr.HasRows) { //int fieldcount = dr.FieldCount; int cnt = -1; while (dr.Read()) { string name = dr[0].ToString(); string schema = dr[1].ToString(); tablesComboModel.AppendValues(name, schema); cnt++; } cbTable.Active = cnt; countTables = cnt; } } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error,null); ms.ShowDialog(); } finally { if (dr != null) dr.Close(); dr = null; conn.Close(); conn = null; } /*string sql = "SELECT name,sql FROM sqlite_master WHERE type='table' ORDER BY name;"; DataTable dt = null; try { int i = -1; dt = sqlLiteDal.RunSqlReader(sql,null); if(dt != null ){ foreach ( DataRow row in dt.Rows ){ string name = row[0].ToString(); string schema = row[1].ToString(); tablesComboModel.AppendValues(name, schema); i++; } } cbTable.Active = i; countTables = i; } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error,null); ms.ShowDialog(); Logger.Error(ex.Message,null); } finally { }*/ }
protected virtual void OnBtnDeleteFieldClicked(object sender, System.EventArgs e) { TreeSelection ts = tvFields.Selection; TreeIter ti = new TreeIter(); ts.GetSelected(out ti); TreePath[] tp = ts.GetSelectedRows(); if (tp.Length < 1) { return; } FieldTable cd = (FieldTable)tvFields.Model.GetValue(ti, 4); if (cd == null) { return; } MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("delete_field", cd.Name), "", Gtk.MessageType.Question, this); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) { return; } string tempTable = "temp_" + tableName + "_backup"; string sqlBegin = "BEGIN TRANSACTION ;"; string sqlRename = String.Format(" ALTER TABLE {0} RENAME TO {1} ;", tableName, tempTable); string sqlReCreate = string.Format(" CREATE TABLE {0}( ", tableName); string colums = ""; int newCount = 0; for (int r = 0; r < fields.Count; r++) { if (fields[r].Name != cd.Name) { string dfltValue = fields[r].DefaultValue; string type = fields[r].Type; sqlReCreate = sqlReCreate + fields[r].Name + " " + type; if (fields[r].NotNULL) { sqlReCreate = sqlReCreate + " NOT NULL"; } if (!String.IsNullOrEmpty(dfltValue)) { if ((type.IndexOf("NUMERIC") > -1) || (type.IndexOf("INTEGER") > -1)) { sqlReCreate = sqlReCreate + " DEFAULT " + dfltValue; } else { if (!dfltValue.StartsWith("'")) { dfltValue = "'" + dfltValue; } if (!dfltValue.EndsWith("'")) { dfltValue = dfltValue + "'"; } sqlReCreate = sqlReCreate + " DEFAULT " + dfltValue; } } colums = colums + fields[r].Name; if (newCount < fields.Count - 2) { sqlReCreate = sqlReCreate + ","; colums = colums + ","; } newCount++; } } sqlReCreate = sqlReCreate + ") ;"; string sqlInsertInto = string.Format(" INSERT INTO {0}( {1} ) SELECT {1} FROM {2} ;", tableName, colums, tempTable); string sqlDropTable = string.Format(" DROP TABLE {0} ;", tempTable); string sqlEnd = "COMMIT ;"; string sql = sqlBegin + "\n" + sqlRename + "\n" + sqlReCreate + "\n" + sqlInsertInto + "\n" + sqlDropTable + "\n" + sqlEnd; //Console.WriteLine(sql); if (sqlLiteDal.RunSqlScalar(sql)) { //fields.Remove(cd); //fieldsStore.Remove(ref ti); GetTableStructure(); } else { // nepodarilo sa vymazanie, dam naspet //fields.Add(cd); } }
void OnRenameItemClick(object sender, EventArgs e) { MessageDialogs md; string message ="" ; if (isDir){ if ((String.IsNullOrEmpty(selectedItem)) || !Directory.Exists(selectedItem)){ md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("file_not_exist_f1",selectedItem),"", Gtk.MessageType.Error); md.ShowDialog(); return; } } else { if ((String.IsNullOrEmpty(selectedItem)) || !File.Exists(selectedItem)){ md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("file_not_exist_f1",selectedItem),"", Gtk.MessageType.Error); md.ShowDialog(); return; } } string oldName = System.IO.Path.GetFileName(selectedItem); EntryDialog ed = new EntryDialog(oldName,MainClass.Languages.Translate("new_name")); int result = ed.Run(); if (result == (int)ResponseType.Ok) { string newName = ed.TextEntry; string newPath =""; string msg = FileUtility.RenameItem(selectedItem,isDir, newName,out newPath ); if(!String.IsNullOrEmpty(msg)){ message = MainClass.Languages.Translate("cannot_rename_file",selectedItem); if(isDir) message = MainClass.Languages.Translate("cannot_rename_directory",selectedItem); MessageDialogs mdd = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, message,msg, Gtk.MessageType.Error); mdd.ShowDialog(); return; } } ed.Destroy(); FillStore (true); }
private bool CheckPage1() { if (String.IsNullOrEmpty(entrPage2PrjName.Text)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_project_name"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } if(entrPage2PrjName.Text.Contains(" ")){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_proj"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } return true; }
private void getSamples() { int xx, yy, w, h, d = 0; this.ParentWindow.GetGeometry(out xx, out yy, out w, out h, out d); Console.WriteLine("w X h: {0}; {1} ", w, h); w = this.Allocation.Width; int count = w / 140; Console.WriteLine("count " + count); Console.WriteLine("this.Allocation.Width " + this.Allocation.Width); string defaultIcon = System.IO.Path.Combine(MainClass.Paths.ResDir, "logo96.png"); DirectoryInfo dir = new DirectoryInfo(MainClass.Paths.SampleDir); LinkImageButton lbGM = new LinkImageButton(); lbGM.Icon = defaultIcon; lbGM.Label = MainClass.Languages.Translate("more_sample_label"); lbGM.LinkUrl = MainClass.Settings.SamplesBaseUrl; lbGM.WidthRequest = 140; WebButton lbOS = new WebButton(); lbOS.Label = MainClass.Languages.Translate("open_sample_label"); lbOS.LinkUrl = MainClass.Paths.SampleDir; if (!dir.Exists) { tblSamples.Attach(lbGM, (uint)0, (uint)1, (uint)(1), (uint)(2), AttachOptions.Fill, AttachOptions.Fill, 0, 0); tblSamples.ShowAll(); return; } DirectoryInfo[] listdi = dir.GetDirectories("*", SearchOption.TopDirectoryOnly); IComparer fileComparer = new CompareDirByDate(); Array.Sort(listdi, fileComparer); int no = 0; int x = 0; int y = 0; for (int i = listdi.Length - 1; i > -1; i--) { DirectoryInfo di = listdi[i]; string zipFile = System.IO.Path.Combine(di.FullName, di.Name + ".zip"); if (!File.Exists(zipFile)) { continue; } string pngFile = System.IO.Path.Combine(di.FullName, di.Name + ".png"); //if(!File.Exists(zipFile)) continue; string txtFile = System.IO.Path.Combine(di.FullName, di.Name + ".txt"); LinkImageButton lb = new LinkImageButton(); lb.Label = System.IO.Path.GetFileName(di.Name); //if (txtFile.Length > 0){ if (File.Exists(txtFile)) { string descr = ""; try{ using (StreamReader file = new StreamReader(txtFile)) { descr = file.ReadToEnd(); file.Close(); file.Dispose(); } } catch (Exception ex) { Tool.Logger.Error(ex.Message); descr = di.Name; } if (!String.IsNullOrEmpty(descr)) { descr = System.Text.RegularExpressions.Regex.Replace(descr, "<[^>]*>", string.Empty); descr = descr.Replace("\r", "").Replace("\n", ""); descr = descr.Replace("&", ""); string hover = descr; if (descr.Length > 75) { descr = descr.Substring(0, 75) + "..."; } //lb.Description =descr; lb.HoverMessage = hover; } } if (pngFile.Length > 0) { if (File.Exists(pngFile)) { lb.Icon = pngFile; } else { lb.Icon = defaultIcon; } } else { lb.Icon = defaultIcon; } lb.WidthRequest = 140; string fileName = zipFile; lb.Clicked += delegate(object sender, EventArgs e) { string prj = System.IO.Path.GetFileNameWithoutExtension(fileName); MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, prj, MainClass.Languages.Translate("do_you_want_import", prj), Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) { return; } MainClass.MainWindow.ImportProject(fileName, true); }; tblSamples.Attach(lb, (uint)x, (uint)(x + 1), (uint)(y + 1), (uint)(y + 2), AttachOptions.Fill, AttachOptions.Shrink, 0, 0); no++; x++; //if(x>4){ if (x >= count - 1) { break; } //if (no>8) break; } tblSamples.Attach(lbGM, (uint)x, (uint)(x + 1), (uint)(y + 1), (uint)(y + 2), AttachOptions.Fill, AttachOptions.Shrink, 0, 0); tblSamples.ShowAll(); }
private void GetTables() { tableModel.Clear(); tablesComboModel.Clear(); SqliteConnection conn = (SqliteConnection)sqlLiteDal.GetConnect(); SqliteDataReader dr = null; try { //conn.Open(); using (SqliteCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT name,sql FROM sqlite_master WHERE type='table' ORDER BY name;"; dr = cmd.ExecuteReader(); } if (dr.HasRows) { //int fieldcount = dr.FieldCount; int cnt = -1; while (dr.Read()) { string name = dr[0].ToString(); string schema = dr[1].ToString(); tablesComboModel.AppendValues(name, schema); cnt++; } cbTable.Active = cnt; countTables = cnt; } } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error, null); ms.ShowDialog(); } finally { if (dr != null) { dr.Close(); } dr = null; conn.Close(); conn = null; } /*string sql = "SELECT name,sql FROM sqlite_master WHERE type='table' ORDER BY name;"; * * DataTable dt = null; * try { * * int i = -1; * dt = sqlLiteDal.RunSqlReader(sql,null); * if(dt != null ){ * foreach ( DataRow row in dt.Rows ){ * string name = row[0].ToString(); * string schema = row[1].ToString(); * tablesComboModel.AppendValues(name, schema); * i++; * } * } * cbTable.Active = i; * countTables = i; * } catch (Exception ex) { * * MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error,null); * ms.ShowDialog(); * Logger.Error(ex.Message,null); * } finally { * * }*/ }
private void GetTableData(string table_name) { tableModel.Clear(); foreach (TreeViewColumn col in treeView.Columns) { treeView.RemoveColumn(col); } SqliteConnection dbcon = (SqliteConnection)sqlLiteDal.GetConnect(); //GetConnect(); if (dbcon == null) { return; } SqliteCommand dbcmd = dbcon.CreateCommand(); string sql = String.Format("SELECT * FROM '{0}';", table_name); dbcmd.CommandText = sql; SqliteDataReader reader = null; try { reader = dbcmd.ExecuteReader(); int numberCollumns = reader.FieldCount; if (numberCollumns < 1) { return; } Type[] type = new Type[numberCollumns]; CellRendererText rendererText = new CellRendererText(); for (int i = 0; i < numberCollumns; i++) { type[i] = typeof(string); TreeViewColumn column = new TreeViewColumn(reader.GetName(i).Replace("_", "__"), rendererText, "text", i); column.SortColumnId = i; column.Resizable = true; column.Reorderable = true; treeView.AppendColumn(column); } tableModel = new ListStore(type); while (reader.Read()) { string[] obj = new string[numberCollumns]; for (int j = 0; j < numberCollumns; j++) { obj[j] = reader.GetValue(j).ToString(); } tableModel.AppendValues(obj); } treeView.Model = tableModel; } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error); ms.ShowDialog(); } finally { if (reader != null) { reader.Close(); } reader = null; dbcmd.Dispose(); dbcmd = null; dbcon.Close(); dbcon = null; } }
public LibsManagerDialog(string libsInProject,Gtk.Window parentWindow) { this.TransientFor = parentWindow; this.Build(); if(!String.IsNullOrEmpty(libsInProject)){ libsInProject = libsInProject.Replace(",", " "); libsInProject = libsInProject.Replace(";", " "); string[] libs = libsInProject.Split(' '); projectLibs = new List<string>(libs); } else { projectLibs = new List<string>(); } tvLibs.Model = libstListStore; CellRendererToggle crt = new CellRendererToggle(); crt.Activatable = true; crt.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (libstListStore.GetIter (out iter, new TreePath(args.Path))) { bool old = (bool) libstListStore.GetValue(iter,2); string libSelect = (string) libstListStore.GetValue(iter,0); bool libMissing = (bool) libstListStore.GetValue(iter,3); string frameworkLibPath = (string) libstListStore.GetValue(iter,4); string state = (string) libstListStore.GetValue(iter,1); if(!MainClass.LicencesSystem.CheckFunction(libSelect,this)){ return; } int resultAction =0; if(old){ projectLibs.Remove(libSelect); } else{ if(libMissing){ MessageDialogs md = new MessageDialogs(new string[]{MainClass.Languages.Translate("as_link"),MainClass.Languages.Translate("copy_f2"),MainClass.Languages.Translate("cancel")}, MainClass.Languages.Translate("add_library_to_workspace",libSelect), "", Gtk.MessageType.Question,this); resultAction = md.ShowDialog(); //Console.WriteLine("resultAction->{0}",resultAction); switch (resultAction) { case -1: //"As Link" try{ MainClass.Tools.CreateLinks(frameworkLibPath,MainClass.Workspace.RootDirectory, true,true); state = MainClass.Languages.Translate("linked"); } catch (Exception ex){ MessageDialogs mdEror = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, ex.Message,"", Gtk.MessageType.Error); mdEror.ShowDialog(); return ; } break; case -2://"Copy" string fullLibDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory,libSelect); MainClass.Tools.CopyDirectory(frameworkLibPath,fullLibDir, true, true); state = MainClass.Languages.Translate("copied"); break; default: //"Cancel" break; } } projectLibs.Add(libSelect); } //LoadLibs(); libstListStore.SetValue(iter,2,!old); libstListStore.SetValue(iter,1,state); //} } }; tvLibs.AppendColumn("", crt , "active", 2); tvLibs.AppendColumn(MainClass.Languages.Translate("lib_name"), new Gtk.CellRendererText(), "text", 0); tvLibs.AppendColumn(MainClass.Languages.Translate("workspace_location"), new Gtk.CellRendererText(), "text", 1); LoadLibs(); }
public ImageToolsControl(ImageCanvas ic) : base(1, 6, false) { this.NRows = 1; this.NColumns = 10; this.ic = ic; tblButton = new Table(1, 5, false); toolbutton = new HButtonBox(); toolbutton.LayoutStyle = ButtonBoxStyle.Start; btnShowHideBarier = new ToggleButton(); btnShowHideBarier.Add(MainClass.Tools.CreatePicLabelWidget("barier-show.png", MainClass.Languages.Translate("show_barier_layer"))); btnShowHideBarier.Name = "btnShowHideBarier"; btnShowHideBarier.Relief = ReliefStyle.None; btnShowHideBarier.CanFocus = false; btnShowHideBarier.BorderWidth = 1; //btnShowHideBarier.WidthRequest = 75; btnShowHideBarier.TooltipText = MainClass.Languages.Translate("show_barier_layer_tt"); btnShowHideBarier.Toggled += delegate(object sender, EventArgs e) { this.ic.ShowBarierLayer = btnShowHideBarier.Active; SetSensitive(btnShowHideBarier.Active); }; btnEditBarierPoint = new ToggleButton(); btnEditBarierPoint.Name = "btnEditBarierPoint"; btnEditBarierPoint.Add(MainClass.Tools.CreatePicLabelWidget("barier-add.png", MainClass.Languages.Translate("edit_barier_point"))); btnEditBarierPoint.Relief = ReliefStyle.None; btnEditBarierPoint.CanFocus = false; btnEditBarierPoint.BorderWidth = 1; btnEditBarierPoint.TooltipText = MainClass.Languages.Translate("edit_barier_point_tt"); btnEditBarierPoint.Toggled += delegate(object sender, EventArgs e) { if (btnEditBarierPoint.Active) { btnDeleteBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; } }; btnDeleteBarierPoint = new ToggleButton(); btnDeleteBarierPoint.Name = "btnDeleteBarierPoint"; btnDeleteBarierPoint.Add(MainClass.Tools.CreatePicLabelWidget("barier-delete.png", MainClass.Languages.Translate("delete_barier_point"))); btnDeleteBarierPoint.Relief = ReliefStyle.None; btnDeleteBarierPoint.CanFocus = false; btnDeleteBarierPoint.BorderWidth = 1; btnDeleteBarierPoint.TooltipText = MainClass.Languages.Translate("delete_barier_point_tt"); btnDeleteBarierPoint.Toggled += delegate(object sender, EventArgs e) { if (btnDeleteBarierPoint.Active) { btnEditBarierPoint.Active = false; //btnAddBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; } }; btnDeleteBarier = new Button(); btnDeleteBarier.Name = "btnDeleteBarier"; btnDeleteBarier.Add(MainClass.Tools.CreatePicLabelWidget("barier-delete-all.png", MainClass.Languages.Translate("delete_barier"))); btnDeleteBarier.Relief = ReliefStyle.None; btnDeleteBarier.CanFocus = false; btnDeleteBarier.BorderWidth = 1; btnDeleteBarier.TooltipText = MainClass.Languages.Translate("delete_barier_tt"); btnDeleteBarier.Clicked += delegate(object sender, EventArgs e) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, "", MainClass.Languages.Translate("delete_barier_question"), Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) { return; } if (DeleteBarierLayerEvent != null) { DeleteBarierLayerEvent(null, null); } }; btnShowHideBarier.Active = false; //btnAddBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; btnDeleteBarierPoint.Active = false; btnEditBarierPoint.Active = false; SetSensitive(false); tblButton.Attach(btnShowHideBarier, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); //tblButton.Attach(btnAddBarierPoint,1,2,0,1,AttachOptions.Shrink,AttachOptions.Shrink,0,0); //tblButton.Attach(btnMovieBarierPoint,2,3,0,1,AttachOptions.Shrink,AttachOptions.Shrink,0,0); tblButton.Attach(btnEditBarierPoint, 1, 2, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); tblButton.Attach(btnDeleteBarierPoint, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); tblButton.Attach(btnDeleteBarier, 3, 4, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); tblButton.ShowAll(); this.Attach(tblButton, 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(new HSeparator(), 1, 2, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); Gtk.Button btnZoomIn = new Gtk.Button(new Image("zoom-in.png", IconSize.Button)); btnZoomIn.TooltipText = MainClass.Languages.Translate("zoom_in"); btnZoomIn.Relief = Gtk.ReliefStyle.None; btnZoomIn.CanFocus = false; btnZoomIn.Clicked += delegate { ZoomIn(); }; //btnZoomIn.WidthRequest = btnZoomIn.HeightRequest = 19; Gtk.Button btnZoomOriginal = new Gtk.Button(new Image("zoom-original.png", IconSize.Button)); btnZoomOriginal.TooltipText = MainClass.Languages.Translate("zoom_original"); btnZoomOriginal.Relief = Gtk.ReliefStyle.None; btnZoomOriginal.CanFocus = false; btnZoomOriginal.Clicked += delegate { cbeZoom.Active = 11; }; //btnZoomOriginal.WidthRequest = btnZoomOriginal.HeightRequest = 19; Gtk.Button btnZoomOut = new Gtk.Button(new Image("zoom-out.png", IconSize.Button)); btnZoomOut.TooltipText = MainClass.Languages.Translate("zoom_out"); btnZoomOut.Relief = Gtk.ReliefStyle.None; btnZoomOut.CanFocus = false; btnZoomOut.Clicked += delegate { ZoomOut(); }; //btnZoomOut.WidthRequest = btnZoomOut.HeightRequest = 19; string[] zoomCollection = new string[] { "3600%", "2400%", "1600%", "1200%", "800%", "700%", "600%", "500%", "400%", "300%", "200%", "100%", "66%", "50%", "33%", "25%", "16%", "12%", "8%", "5%" }; cbeZoom = new ComboBoxEntry(zoomCollection); cbeZoom.Active = 11; cbeZoom.WidthRequest = 70; cbeZoom.Changed += delegate(object sender, EventArgs e) { UpdateScale(); }; cbeZoom.Entry.FocusOutEvent += delegate(object o, FocusOutEventArgs args) { //Console.WriteLine("FocusOutEvent"); UpdateScale(); }; cbeZoom.Entry.FocusInEvent += delegate(object o, FocusInEventArgs args) { }; cbeZoom.Entry.Changed += delegate(object sender, EventArgs e) { //UpdateScale(); }; this.Attach(btnZoomOut, 2, 3, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(cbeZoom, 3, 4, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(btnZoomIn, 4, 5, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); this.Attach(btnZoomOriginal, 5, 6, 0, 1, AttachOptions.Shrink, AttachOptions.Shrink, 0, 0); //this.PackEnd(cbeZoom,false,false,1); }
public bool RunSqlScalar(string sql) { bool result = true; IDbConnection dbcon = GetConnect(); IDbCommand dbcmd = dbcon.CreateCommand(); if (dbcon == null) return false; //Console.WriteLine(sql); dbcmd.CommandText = sql; try { dbcmd.ExecuteScalar(); } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, Gtk.MessageType.Error); ms.ShowDialog(); result = false; } finally { dbcmd.Dispose(); dbcmd = null; dbcon.Close(); dbcon = null; } return result; }
private void getSamples() { int xx, yy, w, h, d = 0; this.ParentWindow.GetGeometry(out xx, out yy, out w, out h, out d); Console.WriteLine("w X h: {0}; {1} ",w,h); w = this.Allocation.Width; int count = w/140; Console.WriteLine("count "+count); Console.WriteLine("this.Allocation.Width "+this.Allocation.Width); string defaultIcon = System.IO.Path.Combine(MainClass.Paths.ResDir,"logo96.png"); DirectoryInfo dir = new DirectoryInfo(MainClass.Paths.SampleDir); LinkImageButton lbGM = new LinkImageButton(); lbGM.Icon = defaultIcon; lbGM.Label =MainClass.Languages.Translate("more_sample_label"); lbGM.LinkUrl =MainClass.Settings.SamplesBaseUrl; lbGM.WidthRequest = 140; WebButton lbOS = new WebButton(); lbOS.Label =MainClass.Languages.Translate("open_sample_label"); lbOS.LinkUrl =MainClass.Paths.SampleDir; if (!dir.Exists ){ tblSamples.Attach(lbGM,(uint)0,(uint)1,(uint)(1),(uint)(2),AttachOptions.Fill,AttachOptions.Fill,0,0); tblSamples.ShowAll(); return; } DirectoryInfo[] listdi = dir.GetDirectories("*",SearchOption.TopDirectoryOnly); IComparer fileComparer = new CompareDirByDate(); Array.Sort(listdi, fileComparer); int no =0; int x = 0; int y = 0; for(int i =listdi.Length-1 ; i>-1 ; i-- ){ DirectoryInfo di =listdi[i]; string zipFile = System.IO.Path.Combine(di.FullName,di.Name+".zip"); if(!File.Exists(zipFile)) continue; string pngFile = System.IO.Path.Combine(di.FullName,di.Name+".png"); //if(!File.Exists(zipFile)) continue; string txtFile = System.IO.Path.Combine(di.FullName,di.Name+".txt"); LinkImageButton lb = new LinkImageButton(); lb.Label = System.IO.Path.GetFileName(di.Name); //if (txtFile.Length > 0){ if(File.Exists(txtFile)){ string descr = ""; try{ using (StreamReader file = new StreamReader(txtFile)) { descr = file.ReadToEnd(); file.Close(); file.Dispose(); } } catch (Exception ex){ Tool.Logger.Error(ex.Message); descr = di.Name; } if (!String.IsNullOrEmpty(descr)){ descr = System.Text.RegularExpressions.Regex.Replace(descr, "<[^>]*>", string.Empty); descr = descr.Replace("\r","").Replace("\n",""); descr = descr.Replace("&",""); string hover =descr; if(descr.Length> 75) descr = descr.Substring(0,75)+"..."; //lb.Description =descr; lb.HoverMessage =hover; } } if (pngFile.Length > 0){ if(File.Exists(pngFile)) lb.Icon =pngFile; else lb.Icon = defaultIcon; }else { lb.Icon = defaultIcon; } lb.WidthRequest = 140; string fileName = zipFile; lb.Clicked+= delegate(object sender, EventArgs e) { string prj = System.IO.Path.GetFileNameWithoutExtension(fileName); MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, prj, MainClass.Languages.Translate("do_you_want_import",prj), Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) return ; MainClass.MainWindow.ImportProject(fileName,true); }; tblSamples.Attach(lb,(uint)x,(uint)(x+1),(uint)(y+1),(uint)(y+2),AttachOptions.Fill,AttachOptions.Shrink,0,0); no++; x++; //if(x>4){ if(x>=count-1){ break; } //if (no>8) break; } tblSamples.Attach(lbGM,(uint)x,(uint)(x+1),(uint)(y+1),(uint)(y+2),AttachOptions.Fill,AttachOptions.Shrink,0,0); tblSamples.ShowAll(); }
public ImageToolBarControl(ImageCanvas ic) { this.ic = ic; btnShowHideBarier = new ToggleToolButton("barier-show.png");//RadioToolButton(group1);//,"barier-show.png"); btnShowHideBarier.Label = MainClass.Languages.Translate("show_barier_layer"); btnShowHideBarier.Name = "btnShowHideBarier"; //btnShowHideBarier.Relief = ReliefStyle.None; btnShowHideBarier.CanFocus = false; btnShowHideBarier.BorderWidth = 1; //btnShowHideBarier.WidthRequest = 75; btnShowHideBarier.TooltipText = MainClass.Languages.Translate("show_barier_layer_tt"); btnShowHideBarier.Events = Gdk.EventMask.AllEventsMask;// | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask btnShowHideBarier.Toggled+= delegate(object sender, EventArgs e) { this.ic.ShowBarierLayer = btnShowHideBarier.Active; SetSensitive(btnShowHideBarier.Active); //Console.WriteLine("btnShowHideBarier.Toggled"); }; btnEditBarierPoint = new ToggleToolButton("barier-add.png");//new RadioToolButton(group2,"barier-add.png"); btnEditBarierPoint.Name = "btnEditBarierPoint"; btnEditBarierPoint.Label = MainClass.Languages.Translate("edit_barier_point"); //btnEditBarierPoint.Relief = ReliefStyle.None; btnEditBarierPoint.CanFocus = false; btnEditBarierPoint.BorderWidth = 1; btnEditBarierPoint.TooltipText = MainClass.Languages.Translate("edit_barier_point_tt"); btnEditBarierPoint.Toggled+= delegate(object sender, EventArgs e) { if(btnEditBarierPoint.Active){ btnDeleteBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; } }; btnDeleteBarierPoint = new ToggleToolButton("barier-delete.png");//new RadioToolButton(group2,"barier-delete.png"); btnDeleteBarierPoint.Name = "btnDeleteBarierPoint"; btnDeleteBarierPoint.Label = MainClass.Languages.Translate("delete_barier_point"); //btnDeleteBarierPoint.Relief = ReliefStyle.None; btnDeleteBarierPoint.CanFocus = false; btnDeleteBarierPoint.BorderWidth = 1; btnDeleteBarierPoint.TooltipText = MainClass.Languages.Translate("delete_barier_point_tt"); btnDeleteBarierPoint.Toggled+= delegate(object sender, EventArgs e) { if(btnDeleteBarierPoint.Active){ btnEditBarierPoint.Active = false; //btnAddBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; } }; btnDeleteBarier = new ToolButton("barier-delete-all.png"); btnDeleteBarier.Name = "btnDeleteBarier"; btnDeleteBarier.Label =MainClass.Languages.Translate("delete_barier"); btnDeleteBarier.CanFocus = false; btnDeleteBarier.BorderWidth = 1; btnDeleteBarier.TooltipText = MainClass.Languages.Translate("delete_barier_tt"); btnDeleteBarier.Clicked += delegate(object sender, EventArgs e) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, "", MainClass.Languages.Translate("delete_barier_question"), Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes){ return; } if(DeleteBarierLayerEvent!= null) DeleteBarierLayerEvent(null,null); }; SetSensitive(false); this.Insert (btnShowHideBarier, 0); this.Insert (btnEditBarierPoint, 1); this.Insert (btnDeleteBarierPoint, 2); this.Insert (btnDeleteBarier, 3); Gtk.ToolButton btnZoomIn = new Gtk.ToolButton("zoom-in.png"); btnZoomIn.Label = MainClass.Languages.Translate("zoom_in"); btnZoomIn.TooltipText = MainClass.Languages.Translate("zoom_in"); //btnZoomIn.Relief = Gtk.ReliefStyle.None; btnZoomIn.CanFocus = false; btnZoomIn.Clicked+= delegate { ZoomIn(); }; Gtk.ToolButton btnZoomOriginal = new Gtk.ToolButton("zoom-original.png"); btnZoomOriginal.Label = MainClass.Languages.Translate("zoom_original"); btnZoomOriginal.TooltipText = MainClass.Languages.Translate("zoom_original"); //btnZoomOriginal.Relief = Gtk.ReliefStyle.None; btnZoomOriginal.CanFocus = false; btnZoomOriginal.Clicked+= delegate { cbeZoom.Active = 11; }; //btnZoomOriginal.WidthRequest = btnZoomOriginal.HeightRequest = 19; Gtk.ToolButton btnZoomOut = new Gtk.ToolButton("zoom-out.png"); btnZoomOut.TooltipText = MainClass.Languages.Translate("zoom_out"); btnZoomOut.Label = MainClass.Languages.Translate("zoom_out"); //btnZoomOut.Relief = Gtk.ReliefStyle.None; btnZoomOut.CanFocus = false; btnZoomOut.Clicked+= delegate { ZoomOut(); }; string[] zoomCollection = new string[] { "3600%", "2400%", "1600%", "1200%", "800%", "700%", "600%", "500%", "400%", "300%", "200%", "100%", "66%", "50%", "33%", "25%", "16%", "12%", "8%", "5%" }; cbeZoom = new ComboBoxEntry(zoomCollection); cbeZoom.Active = 11; cbeZoom.WidthRequest = 70; cbeZoom.Changed+= delegate(object sender, EventArgs e) { UpdateScale(); }; cbeZoom.Entry.FocusOutEvent+= delegate(object o, FocusOutEventArgs args) { //Console.WriteLine("FocusOutEvent"); UpdateScale(); }; cbeZoom.Entry.FocusInEvent+= delegate(object o, FocusInEventArgs args) { }; cbeZoom.Entry.Changed+= delegate(object sender, EventArgs e) { //UpdateScale(); }; ToolItem tic = new ToolItem(); tic.Add(cbeZoom); this.Insert(new SeparatorToolItem(),4); this.Insert(btnZoomIn,5); this.Insert(btnZoomOut,6); this.Insert(tic,7); this.Insert(btnZoomOriginal,8); }
protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { if(WorkspaceName.Contains(" ")){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_work"),"", Gtk.MessageType.Error); md.ShowDialog(); return; } if(WorkspaceRoot.Contains(" ")){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_work_path"),"", Gtk.MessageType.Error); md.ShowDialog(); return; } if (String.IsNullOrEmpty(WorkspaceName)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_name"),"", Gtk.MessageType.Error); md.ShowDialog(); return; } if (String.IsNullOrEmpty(WorkspaceOutput)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_output"),"", Gtk.MessageType.Error); md.ShowDialog(); return; } if (String.IsNullOrEmpty(WorkspaceRoot)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_root"),"", Gtk.MessageType.Error); md.ShowDialog(); return; } if (project){ if (String.IsNullOrEmpty(ProjectName)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_project_name"),"", Gtk.MessageType.Error); md.ShowDialog(); return; } if(ProjectName.Contains(" ")){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_proj"),"", Gtk.MessageType.Error); md.ShowDialog(); return ; } } this.Respond(ResponseType.Ok); }
public LibsManagerDialog(string libsInProject, Gtk.Window parentWindow) { this.TransientFor = parentWindow; this.Build(); if (!String.IsNullOrEmpty(libsInProject)) { libsInProject = libsInProject.Replace(",", " "); libsInProject = libsInProject.Replace(";", " "); string[] libs = libsInProject.Split(' '); projectLibs = new List <string>(libs); } else { projectLibs = new List <string>(); } tvLibs.Model = libstListStore; CellRendererToggle crt = new CellRendererToggle(); crt.Activatable = true; crt.Toggled += delegate(object o, ToggledArgs args) { TreeIter iter; if (libstListStore.GetIter(out iter, new TreePath(args.Path))) { bool old = (bool)libstListStore.GetValue(iter, 2); string libSelect = (string)libstListStore.GetValue(iter, 0); bool libMissing = (bool)libstListStore.GetValue(iter, 3); string frameworkLibPath = (string)libstListStore.GetValue(iter, 4); string state = (string)libstListStore.GetValue(iter, 1); if (!MainClass.LicencesSystem.CheckFunction(libSelect, this)) { return; } int resultAction = 0; if (old) { projectLibs.Remove(libSelect); } else { if (libMissing) { MessageDialogs md = new MessageDialogs(new string[] { MainClass.Languages.Translate("as_link"), MainClass.Languages.Translate("copy_f2"), MainClass.Languages.Translate("cancel") }, MainClass.Languages.Translate("add_library_to_workspace", libSelect), "", Gtk.MessageType.Question, this); resultAction = md.ShowDialog(); //Console.WriteLine("resultAction->{0}",resultAction); switch (resultAction) { case -1: //"As Link" try{ MainClass.Tools.CreateLinks(frameworkLibPath, MainClass.Workspace.RootDirectory, true, true); state = MainClass.Languages.Translate("linked"); } catch (Exception ex) { MessageDialogs mdEror = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, ex.Message, "", Gtk.MessageType.Error); mdEror.ShowDialog(); return; } break; case -2: //"Copy" string fullLibDir = System.IO.Path.Combine(MainClass.Workspace.RootDirectory, libSelect); MainClass.Tools.CopyDirectory(frameworkLibPath, fullLibDir, true, true); state = MainClass.Languages.Translate("copied"); break; default: //"Cancel" break; } } projectLibs.Add(libSelect); } //LoadLibs(); libstListStore.SetValue(iter, 2, !old); libstListStore.SetValue(iter, 1, state); //} } }; tvLibs.AppendColumn("", crt, "active", 2); tvLibs.AppendColumn(MainClass.Languages.Translate("lib_name"), new Gtk.CellRendererText(), "text", 0); tvLibs.AppendColumn(MainClass.Languages.Translate("workspace_location"), new Gtk.CellRendererText(), "text", 1); LoadLibs(); }
private bool CheckPage0() { if(cbeWorkspace.ActiveText.Contains(" ")){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_work"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } if(String.IsNullOrEmpty(cbeWorkspace.ActiveText)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_name"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } if (String.IsNullOrEmpty(entrProjectName.Text)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_project_name"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } if(entrProjectName.Text.Contains(" ")){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_proj"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } TreeIter tiChb; cbeWorkspace.GetActiveIter(out tiChb); int type = Convert.ToInt32(storeWorkspace.GetValue(tiChb, 2)); if((cbeWorkspace.Active <0) || (type ==2) ){ string workspaceName = cbeWorkspace.ActiveText; string workspaceRoot =System.IO.Path.Combine(feLocation.Path,workspaceName); string workspaceFile = System.IO.Path.Combine(workspaceRoot, workspaceName + ".msw"); if(File.Exists(workspaceFile)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("workspace_exist"),"", Gtk.MessageType.Error); md.ShowDialog(); return false; } } return true; }
public bool Save() { //appFile.Orientation = cbOrientation.ActiveText; try{ FillAppFile(); appFile.Save(); } catch(Exception ex){ MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", appFile.ApplicationFile), ex.Message, Gtk.MessageType.Error); ms.ShowDialog(); return false; } return true; }
private void ShowModalError(string message,string message2) { Gtk.Application.Invoke(delegate { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, message, message2, Gtk.MessageType.Info,null); md.ShowDialog(); }); }
protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { if (WorkspaceName.Contains(" ")) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_work"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if (WorkspaceRoot.Contains(" ")) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_work_path"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if (String.IsNullOrEmpty(WorkspaceName)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_name"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if (String.IsNullOrEmpty(WorkspaceOutput)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_output"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if (String.IsNullOrEmpty(WorkspaceRoot)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_workspace_root"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if (project) { if (String.IsNullOrEmpty(ProjectName)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("please_set_project_name"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } if (ProjectName.Contains(" ")) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error_whitespace_proj"), "", Gtk.MessageType.Error); md.ShowDialog(); return; } } this.Respond(ResponseType.Ok); }
void OnDeleteItemClick(object sender, EventArgs e) { string message ="" ; if (isDir) { message = MainClass.Languages.Translate("question_delete_folder",selectedItem); } else { message = MainClass.Languages.Translate("question_delete_file",selectedItem); } MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, message, "", Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) return; string msg = FileUtility.DeleteItem(selectedItem,isDir); if(!String.IsNullOrEmpty(msg)){ message = MainClass.Languages.Translate("cannot_delete_file",selectedItem); MessageDialogs mdd = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, message,msg, Gtk.MessageType.Error); mdd.ShowDialog(); return; } FillStore (true); }
protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { if (String.IsNullOrEmpty(entrTableName.Text)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok,MainClass.Languages.Translate("please_enter_table_name"),"" , Gtk.MessageType.Error,this); md.ShowDialog(); return; } if (fields.Count<1){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok,MainClass.Languages.Translate("no_fileds_define"),"" , Gtk.MessageType.Error,this); md.ShowDialog(); return; } string tableName = entrTableName.Text; string sql = string.Format("CREATE TABLE {0}( ",tableName); for (int r=0; r<fields.Count;r++){ string type =fields[r].Type; string defValue =fields[r].DefaultValue; sql = sql+fields[r].Name+" "+type; if (fields[r].NotNULL) sql =sql+" "+"NOT NULL"; if (!String.IsNullOrEmpty(defValue)){ if ((type.IndexOf("NUMERIC")>-1) || (type.IndexOf("INTEGER")>-1)) { sql =sql+" DEFAULT "+defValue; } else { sql =sql+" DEFAULT '"+defValue+"'"; } } if (r<fields.Count-1) sql = sql+","; } sql = sql+") ;"; sqlLiteDal.RunSqlScalar(sql); //CreateTable(); this.Respond(ResponseType.Ok); }
public ImageEditor(string filePath) { fileName = filePath; fileBarierName = fileName + ".mso"; if (System.IO.File.Exists(fileBarierName)) { string barierFile; try { using (StreamReader file = new StreamReader(fileBarierName)) { barierFile = file.ReadToEnd(); file.Close(); file.Dispose(); } if (!string.IsNullOrEmpty(barierFile)) { //listPoint = JsonConvert.DeserializeObject<List<BarierPoint>>(barierFile); System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer(); jss.RegisterConverters(new[] { new BarierPointJavaScriptConverter() }); listPoint = jss.Deserialize <List <BarierPoint> >(barierFile); } } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("file_cannot_open", fileBarierName), ex.Message, Gtk.MessageType.Error, null); ms.ShowDialog(); } } editorAction = new Gtk.ActionGroup("imageeditor"); //ic = new ImageCanvas(filePath,listPoint); ic = new ImageCanvas(filePath, listPoint) { Name = "canvas", CanDefault = true, CanFocus = true, Events = (Gdk.EventMask) 16134 }; vbox = new Gtk.VBox(); /*Gdk.Color col = new Gdk.Color(255,255,0); * vbox.ModifyBg(StateType.Normal, col);*/ itc = new ImageToolBarControl(ic); //new ImageToolBarControl(ic); itc.DeleteBarierLayerEvent += delegate(object sender, EventArgs e) { if (System.IO.File.Exists(fileBarierName)) { try{ System.IO.File.Delete(fileBarierName); OnModifiedChanged(false); ic.DeleteBarier(); }catch (Exception ex) { MessageDialogs mdd = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_delete_file", fileBarierName), ex.Message, Gtk.MessageType.Error); mdd.ShowDialog(); } } else { ic.DeleteBarier(); } }; vbox.PackStart(itc, false, false, 0); ScrolledWindow sw = new Gtk.ScrolledWindow(); sw.ShadowType = Gtk.ShadowType.Out; sw.Hadjustment.ValueChanged += delegate(object sender, EventArgs e) { //Console.WriteLine("sw.Hadjustment -> {0}",sw.Hadjustment.Value); }; sw.Vadjustment.ValueChanged += delegate(object sender, EventArgs e) { //Console.WriteLine("sw.Vadjustment -> {0}",sw.Vadjustment.Value); }; Viewport vp = new Viewport() { ShadowType = ShadowType.None }; vp.ScrollEvent += delegate(object o, ScrollEventArgs args) { if (args.Event.State == ModifierType.ControlMask) { switch (args.Event.Direction) { case ScrollDirection.Down: case ScrollDirection.Right: itc.ZoomOut(); return; case ScrollDirection.Left: case ScrollDirection.Up: itc.ZoomIn(); return; } } }; vp.MotionNotifyEvent += delegate(object o, MotionNotifyEventArgs args) { Cairo.PointD offset = new Cairo.PointD(sw.Hadjustment.Value, sw.Vadjustment.Value); int x = (int)args.Event.X; int y = (int)args.Event.Y; if (ic.ConvertPointToCanvasPoint(offset, ref x, ref y)) { OnWriteToStatusbar(String.Format(statusFormat, x, y, ic.WidthImage, ic.HeightImage)); } if (itc.ToolState == ImageToolBarControl.ToolStateEnum.nothing) { return; } if (itc.ToolState == ImageToolBarControl.ToolStateEnum.editpoint) { ic.StepMovingPoint((int)args.Event.X, (int)args.Event.Y, offset); //OnModifiedChanged(true); } }; vp.ButtonReleaseEvent += delegate(object o, ButtonReleaseEventArgs args) { //Console.WriteLine("1_ButtonReleaseEvent"); if (args.Event.Button != 1) { return; } if (itc.ToolState == ImageToolBarControl.ToolStateEnum.nothing) { return; } Cairo.PointD offset = new Cairo.PointD(sw.Hadjustment.Value, sw.Vadjustment.Value); if (itc.ToolState == ImageToolBarControl.ToolStateEnum.editpoint) { ic.EndMovingPoint((int)args.Event.X, (int)args.Event.Y, offset); OnModifiedChanged(true); } }; vp.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { if (args.Event.Button != 1) { return; } if (itc.ToolState == ImageToolBarControl.ToolStateEnum.nothing) { return; } Cairo.PointD offset = new Cairo.PointD(sw.Hadjustment.Value, sw.Vadjustment.Value); if (itc.ToolState == ImageToolBarControl.ToolStateEnum.addpoint) { ic.AddPoint((int)args.Event.X, (int)args.Event.Y, offset); OnModifiedChanged(true); } else if (itc.ToolState == ImageToolBarControl.ToolStateEnum.deletepoint) { ic.DeletePoint((int)args.Event.X, (int)args.Event.Y, offset); OnModifiedChanged(true); } else if (itc.ToolState == ImageToolBarControl.ToolStateEnum.moviepoint) { ic.StartMovingPoint((int)args.Event.X, (int)args.Event.Y, offset); OnModifiedChanged(true); } else if (itc.ToolState == ImageToolBarControl.ToolStateEnum.editpoint) { if (args.Event.State == ModifierType.ShiftMask) { ic.DeletePoint((int)args.Event.X, (int)args.Event.Y, offset); OnModifiedChanged(true); return; } ic.EditPoint((int)args.Event.X, (int)args.Event.Y, offset); OnModifiedChanged(true); } }; sw.Add(vp); vp.Add(ic); vbox.PackEnd(sw, true, true, 0); ic.Show(); vp.Show(); vbox.ShowAll(); }
protected virtual void OnBtnDeleteFieldClicked(object sender, System.EventArgs e) { TreeSelection ts = tvFields.Selection; TreeIter ti = new TreeIter(); ts.GetSelected(out ti); TreePath[] tp = ts.GetSelectedRows(); if (tp.Length < 1) return ; FieldTable cd = (FieldTable)tvFields.Model.GetValue(ti, 2); if (cd == null) return; MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, MainClass.Languages.Translate("delete_field", cd.Name), "", Gtk.MessageType.Question,this); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) return; fields.Remove(cd); fieldsStore.Remove(ref ti); }
private void GetTableData(string table_name) { tableModel.Clear(); foreach (TreeViewColumn col in treeView.Columns) { treeView.RemoveColumn (col); } SqliteConnection dbcon = (SqliteConnection)sqlLiteDal.GetConnect();//GetConnect(); if (dbcon == null) return; SqliteCommand dbcmd = dbcon.CreateCommand(); string sql = String.Format("SELECT * FROM '{0}';", table_name); dbcmd.CommandText = sql; SqliteDataReader reader = null; try { reader = dbcmd.ExecuteReader(); int numberCollumns = reader.FieldCount; if (numberCollumns <1)return; Type[] type = new Type[numberCollumns]; CellRendererText rendererText = new CellRendererText(); for (int i=0; i<numberCollumns;i++){ type[i] =typeof(string); TreeViewColumn column = new TreeViewColumn(reader.GetName(i).Replace("_","__"), rendererText, "text", i); column.SortColumnId = i; column.Resizable = true; column.Reorderable = true; treeView.AppendColumn(column); } tableModel = new ListStore(type); while (reader.Read()) { string[] obj = new string[numberCollumns]; for (int j=0; j<numberCollumns;j++){ obj[j] = reader.GetValue(j).ToString(); } tableModel.AppendValues(obj); } treeView.Model = tableModel; } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error); ms.ShowDialog(); } finally { if (reader != null) reader.Close(); reader = null; dbcmd.Dispose(); dbcmd = null; dbcon.Close(); dbcon = null; } }
protected virtual void OnButtonOkClicked(object sender, System.EventArgs e) { if (String.IsNullOrEmpty(entrFieldName.Text)){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok,MainClass.Languages.Translate("please_enter_field_name"),"" , Gtk.MessageType.Error,this); md.ShowDialog(); return; } TreeIter ti; string typ=""; if(cbFieldType.GetActiveIter(out ti)){ typ = fieldTypeStore.GetValue(ti,0).ToString(); } fieldTable = new FieldTable(entrFieldName.Text,typ); fieldTable.NotNULL= chbNulable.Active; if (!String.IsNullOrEmpty(entrDefault.Text)) fieldTable.DefaultValue = entrDefault.Text; this.Respond(ResponseType.Ok); }
protected void OnButtonOkClicked(object sender, EventArgs e) { string feedText = ""; switch (notb.Page){ case 0: feedText = feedbackIssue.GetData(); break; case 1: feedText = feedbackQuestion.GetData(); break; case 2: feedText = feedbackSuggestion.GetData(); break; } Console.WriteLine(feedText); if(MainClass.Settings.Account == null) Console.WriteLine("Account IS NULL"); if(String.IsNullOrEmpty(MainClass.Settings.Account.Token)) Console.WriteLine("Token IS NULL"); if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("invalid_login_f1"),"", Gtk.MessageType.Error,this); md.ShowDialog(); Console.WriteLine("IS NULL"); return ; } buttonOk.Sensitive = false; if(string.IsNullOrEmpty(feedText)){ return; } lblStatus.LabelProp = "Sending..."; while (Gtk.Application.EventsPending ()) Gtk.Application.RunIteration (); LoggingInfo log = new LoggingInfo(); log.SendFeedback (feedText,LoginYesWrite,LoginNoWrite); //this.Respond(Gtk.ResponseType.Ok); }
internal static EmulatorDisplay Create(string filePath,int width,int height) { if (!System.IO.File.Exists(filePath)) { try{ EmulatorDisplay dd = new EmulatorDisplay(filePath); dd.Width = width; dd.Height = height; dd.Author = "Moscrif Ide Generator"; dd.Title = System.IO.Path.GetFileName(filePath); dd.Url =""; dd.Save(); return dd; }catch(Exception ex){ MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), ex.Message, Gtk.MessageType.Error); md.ShowDialog(); return null; } } else { //throw new FileNotFoundException(); MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), MainClass.Languages.Translate("file_notcreate_is_exist"), Gtk.MessageType.Error); md.ShowDialog(); return null; } }
public bool SaveAs(string newPath) { if (System.IO.File.Exists(newPath)) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, "", MainClass.Languages.Translate("overwrite_file", newPath), Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) return false; } try { System.IO.File.Copy(fileName,newPath); fileName = newPath; } catch (Exception ex) { MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("cannot_save_file", newPath), ex.Message, Gtk.MessageType.Error); ms.ShowDialog(); return false; } // do save return true; //return true; //throw new NotImplementedException (); }
public ImageToolBarControl(ImageCanvas ic) { this.ic = ic; btnShowHideBarier = new ToggleToolButton("barier-show.png"); //RadioToolButton(group1);//,"barier-show.png"); btnShowHideBarier.Label = MainClass.Languages.Translate("show_barier_layer"); btnShowHideBarier.Name = "btnShowHideBarier"; //btnShowHideBarier.Relief = ReliefStyle.None; btnShowHideBarier.CanFocus = false; btnShowHideBarier.BorderWidth = 1; //btnShowHideBarier.WidthRequest = 75; btnShowHideBarier.TooltipText = MainClass.Languages.Translate("show_barier_layer_tt"); btnShowHideBarier.Events = Gdk.EventMask.AllEventsMask; // | EventMask.ButtonReleaseMask | EventMask.PointerMotionMask btnShowHideBarier.Toggled += delegate(object sender, EventArgs e) { this.ic.ShowBarierLayer = btnShowHideBarier.Active; SetSensitive(btnShowHideBarier.Active); //Console.WriteLine("btnShowHideBarier.Toggled"); }; btnEditBarierPoint = new ToggleToolButton("barier-add.png"); //new RadioToolButton(group2,"barier-add.png"); btnEditBarierPoint.Name = "btnEditBarierPoint"; btnEditBarierPoint.Label = MainClass.Languages.Translate("edit_barier_point"); //btnEditBarierPoint.Relief = ReliefStyle.None; btnEditBarierPoint.CanFocus = false; btnEditBarierPoint.BorderWidth = 1; btnEditBarierPoint.TooltipText = MainClass.Languages.Translate("edit_barier_point_tt"); btnEditBarierPoint.Toggled += delegate(object sender, EventArgs e) { if (btnEditBarierPoint.Active) { btnDeleteBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; } }; btnDeleteBarierPoint = new ToggleToolButton("barier-delete.png"); //new RadioToolButton(group2,"barier-delete.png"); btnDeleteBarierPoint.Name = "btnDeleteBarierPoint"; btnDeleteBarierPoint.Label = MainClass.Languages.Translate("delete_barier_point"); //btnDeleteBarierPoint.Relief = ReliefStyle.None; btnDeleteBarierPoint.CanFocus = false; btnDeleteBarierPoint.BorderWidth = 1; btnDeleteBarierPoint.TooltipText = MainClass.Languages.Translate("delete_barier_point_tt"); btnDeleteBarierPoint.Toggled += delegate(object sender, EventArgs e) { if (btnDeleteBarierPoint.Active) { btnEditBarierPoint.Active = false; //btnAddBarierPoint.Active = false; //btnMovieBarierPoint.Active = false; } }; btnDeleteBarier = new ToolButton("barier-delete-all.png"); btnDeleteBarier.Name = "btnDeleteBarier"; btnDeleteBarier.Label = MainClass.Languages.Translate("delete_barier"); btnDeleteBarier.CanFocus = false; btnDeleteBarier.BorderWidth = 1; btnDeleteBarier.TooltipText = MainClass.Languages.Translate("delete_barier_tt"); btnDeleteBarier.Clicked += delegate(object sender, EventArgs e) { MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.YesNo, "", MainClass.Languages.Translate("delete_barier_question"), Gtk.MessageType.Question); int result = md.ShowDialog(); if (result != (int)Gtk.ResponseType.Yes) { return; } if (DeleteBarierLayerEvent != null) { DeleteBarierLayerEvent(null, null); } }; SetSensitive(false); this.Insert(btnShowHideBarier, 0); this.Insert(btnEditBarierPoint, 1); this.Insert(btnDeleteBarierPoint, 2); this.Insert(btnDeleteBarier, 3); Gtk.ToolButton btnZoomIn = new Gtk.ToolButton("zoom-in.png"); btnZoomIn.Label = MainClass.Languages.Translate("zoom_in"); btnZoomIn.TooltipText = MainClass.Languages.Translate("zoom_in"); //btnZoomIn.Relief = Gtk.ReliefStyle.None; btnZoomIn.CanFocus = false; btnZoomIn.Clicked += delegate { ZoomIn(); }; Gtk.ToolButton btnZoomOriginal = new Gtk.ToolButton("zoom-original.png"); btnZoomOriginal.Label = MainClass.Languages.Translate("zoom_original"); btnZoomOriginal.TooltipText = MainClass.Languages.Translate("zoom_original"); //btnZoomOriginal.Relief = Gtk.ReliefStyle.None; btnZoomOriginal.CanFocus = false; btnZoomOriginal.Clicked += delegate { cbeZoom.Active = 11; }; //btnZoomOriginal.WidthRequest = btnZoomOriginal.HeightRequest = 19; Gtk.ToolButton btnZoomOut = new Gtk.ToolButton("zoom-out.png"); btnZoomOut.TooltipText = MainClass.Languages.Translate("zoom_out"); btnZoomOut.Label = MainClass.Languages.Translate("zoom_out"); //btnZoomOut.Relief = Gtk.ReliefStyle.None; btnZoomOut.CanFocus = false; btnZoomOut.Clicked += delegate { ZoomOut(); }; string[] zoomCollection = new string[] { "3600%", "2400%", "1600%", "1200%", "800%", "700%", "600%", "500%", "400%", "300%", "200%", "100%", "66%", "50%", "33%", "25%", "16%", "12%", "8%", "5%" }; cbeZoom = new ComboBoxEntry(zoomCollection); cbeZoom.Active = 11; cbeZoom.WidthRequest = 70; cbeZoom.Changed += delegate(object sender, EventArgs e) { UpdateScale(); }; cbeZoom.Entry.FocusOutEvent += delegate(object o, FocusOutEventArgs args) { //Console.WriteLine("FocusOutEvent"); UpdateScale(); }; cbeZoom.Entry.FocusInEvent += delegate(object o, FocusInEventArgs args) { }; cbeZoom.Entry.Changed += delegate(object sender, EventArgs e) { //UpdateScale(); }; ToolItem tic = new ToolItem(); tic.Add(cbeZoom); this.Insert(new SeparatorToolItem(), 4); this.Insert(btnZoomIn, 5); this.Insert(btnZoomOut, 6); this.Insert(tic, 7); this.Insert(btnZoomOriginal, 8); }