protected override void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de) { RegistryKey r = null; using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "{0}\\ShellEx\\{1}", ext, ShellExGuid))) { CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de); } if (r == null) { using (r = Registry.ClassesRoot.OpenSubKey(string.Format(CultureInfo.InvariantCulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", ext, ShellExGuid))) { CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de); } } if (r == null) { string type = CheckStringValue(form, rk, PerceivedType, de); using (r = OpenSubKey(form, Registry.ClassesRoot, string.Format(CultureInfo.InstalledUICulture, "SystemFileAssociations\\{0}\\ShellEx\\{1}", type, ShellExGuid), de)) { CheckValue(form, r, null, new string[] { ThumnailCacheGuid }, de); } } }
public void MapCtrl_MethodsWithNoUserInteraction() { var focus = false; System.Threading.Thread t = new System.Threading.Thread(() => { var sut = new MainCtrl(); var form = new MainForm(); sut.InitMindMate(form); MainMenuCtrl mainMenuCtrl = new MainMenuCtrl(form.MainMenu, sut); form.MainMenuCtrl = mainMenuCtrl; form.Shown += (sender, args) => { sut.ReturnFocusToMapView(); sut.Bold(true); focus = sut.CurrentMapCtrl.MapView.Tree.RootNode.Bold; sut.ClearSelectionFormatting(); sut.Copy(); sut.Cut(); sut.SetBackColor(Color.White); sut.SetFontFamily("Arial"); sut.SetFontSize(15); sut.SetForeColor(Color.Blue); sut.SetMapViewBackColor(Color.White); sut.Strikethrough(true); sut.Subscript(); sut.Superscript(); sut.Underline(true); }; Timer timer = new Timer { Interval = 50 }; //timer is used because the Dirty property is updated in the next event of GUI thread. timer.Tick += delegate { if (timer.Tag == null) { timer.Tag = "First Event Fired"; } else if (timer.Tag.Equals("First Event Fired")) { timer.Tag = "Second Event Fired"; } else { foreach(var f in sut.PersistenceManager) { f.IsDirty = false; //to avoid save warning dialog } form.Close(); } }; timer.Start(); form.ShowDialog(); timer.Stop(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(focus); }
public static IConnection CreateConnection(FavoriteConfigurationElement Favorite, TerminalTabControlItem TerminalTabPage, MainForm parentForm) { IConnection conn = null; ; switch (Favorite.Protocol) { case "VNC": conn = new VNCConnection(); break; case "VMRC": conn = new VMRCConnection(); break; case "RAS": conn = new RASConnection(); break; case "Telnet": conn = new TerminalConnection(); break; case "ICA Citrix": conn = new ICAConnection(); break; case "HTTP": conn = new HTTPConnection(); break; case "HTTPS": conn = new HTTPConnection(); break; default: conn = new RDPConnection(); break; } conn.Favorite = Favorite; TerminalTabPage.Connection = conn; conn.TerminalTabPage = TerminalTabPage; conn.ParentForm = parentForm; return conn; }
/// <summary> /// Get Certificate with Password /// </summary> /// <param name="main">Main Form that has Certificate and Password</param> /// <returns>Client Side Certificate</returns> public static X509Certificate2 GetCertificate(MainForm main) { if (main.CertificateFileName == string.Empty || main.CertificatePassword == string.Empty) throw new Exception("Please provide valid Certificate and/or Password."); return new X509Certificate2(main.CertificateFileName, main.CertificatePassword); }
public AppContext() { this.f1 = new MainForm(); this.f1.manualOnLoad(); this.f1.Visible = false; this.f1.VisibleChanged += new EventHandler(this.f1_VisibleChanged); }
public SilkroadTunnel(SilkroadProxy silkroadProxy, List<SilkroadTunnel> tunnels, MainForm mainForm) { _remoteIP = "123.30.200.6"; _remotePort = 15779; _silkroadProxy = silkroadProxy; _localContext = new Context(); _localContext.MySecurity.GenerateSecurity(true, true, true); _remoteContext = new Context(); _localContext.MyRelaySecurity = _remoteContext.MySecurity; _remoteContext.MyRelaySecurity = _localContext.MySecurity; _contexts = new List<Context>(); _contexts.Add(_localContext); _contexts.Add(_remoteContext); _tunnels = tunnels; _mainForm = mainForm; if (_mainForm != null) { _charracter = new Charracter(_mainForm); } }
/// <summary> /// Constructor for the class /// </summary> /// <param name="frm">The parent form</param> /// <param name="page">Page the field will belong to</param> public UpperCaseTextFieldDefinition(MainForm frm, Page page) : base(frm) { InitializeComponent(); this.mode = FormMode.Create; this.page = page; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { InitializeTraceLevel(); AppContainer container = new AppContainer(); MainForm form = new MainForm(); container.Add(form); logger.Info("Starting CodeBuilder"); Application.Run(form); logger.Info("CodeBuilder Exit"); } catch (Exception ex) { logger.Error("Startup", ex); MessageBoxHelper.DisplayFailure(ex.Message); } InternalTrace.Close(); }
/// <summary> /// Constructor for the class /// </summary> /// <param name="givenView">The View to load check code for</param> /// <param name="givenMainForm">The main form</param> public DataDictionary(View givenView, MainForm givenMainForm) { view = givenView; project = view.Project; mainForm = givenMainForm; Construct(); }
public SledGotoService( MainForm mainForm, IControlHostService controlHostService) { m_mainForm = mainForm; m_controlHostService = controlHostService; }
public FirstLoginProvForm(DataRow row,MainForm mainW,int user) { InitializeComponent(); //bindeos this.currentDataRow = row; this.mainWindow = mainW; this.corporateName.Text = this.currentDataRow[0].ToString(); this.txt1 = this.corporateName.Text; this.Mail.Text = this.currentDataRow[1].ToString(); this.txt2 = this.Mail.Text; this.Phone.Text = this.currentDataRow[2].ToString(); this.txt3 = this.Phone.Text; this.address.Text = this.currentDataRow[3].ToString(); this.txt4 = this.address.Text; this.postalCode.Text = this.currentDataRow[4].ToString(); this.txt5 = this.postalCode.Text; this.City.Text = this.currentDataRow[5].ToString(); this.txt6 = this.City.Text; this.Cuit.Text = this.currentDataRow[6].ToString(); this.txt7 = this.Cuit.Text; this.entry.Text = this.currentDataRow[7].ToString(); this.txt8 = this.entry.Text; this.ContactNumber.Text = this.currentDataRow[8].ToString(); this.txt9 = this.ContactNumber.Text; this.userid = user; }
/// <summary> /// Default constructor for the class /// </summary> public DataTablePropertiesDialog(MainForm frm, Project currentProject, View view) : base(frm) { InitializeComponent(); project = currentProject; currentView = view; }
public Search(MainForm.CheckInstallDirsCB checkInstallDirsCB, MainForm.updateProgressCallback updateProgressCB, MainForm.listViewAddCallBack listViewAddCB) : this() { this.checkInstallDirsCB = checkInstallDirsCB; this.updateProgressCB = updateProgressCB; this.listViewAddCB = listViewAddCB; }
public static ObjectChooser CreateObjectChooser(MainForm.DoWaitCallback doWaitCB, MainForm.StopWaitCallback stopWaitCB, MainForm.updateProgressCallback updateProgressCB, MainForm.listViewAddCallBack listViewAddCB, CatalogType resourceType, EventHandler<MainForm.SelectedIndexChangedEventArgs> selectedIndexChangedHandler, EventHandler<MainForm.ItemActivateEventArgs> itemActivateHandler) { ObjectChooser res; if (!objectChooserCache.ContainsKey(resourceType)) { res = new ObjectChooser(doWaitCB, stopWaitCB, updateProgressCB, listViewAddCB, resourceType); res.SelectedIndexChanged += selectedIndexChangedHandler; res.ItemActivate += itemActivateHandler; return res; } res = objectChooserCache[resourceType]; res.SelectedIndexChanged = null; res.SelectedItem = null; res.listView1.SelectedItems.Clear(); res.SelectedIndexChanged += selectedIndexChangedHandler; res.ItemActivate = null; res.ItemActivate += itemActivateHandler; return res; }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PrgForm = new MainForm(); Application.Run(PrgForm); }
public ConfigForm(MainForm fmMain) { InitializeComponent(); this.fmMain = fmMain; cbDbs.Text = MainForm.myCmdMgr.Config.local; btnOK.Focus(); }
public CoreEnvelopeDesignForm(MainForm main_Form) { InitializeComponent(); dataGridViewParaInput.Columns[1].ValueType = System.Type.GetType("System.Decimal"); mainForm = main_Form; }
/// <summary> /// Constructor of the Variable Definition dialog /// </summary> /// <param name="frm">The main form</param> public VariableDefinitionDialog(MainForm frm) : base(frm) { // This call is required by the Windows Form Designer. InitializeComponent(); LoadVarTypes(); }
public CaptureStrategy GetStrategy(CaptureType captureType, MainForm mainForm) { CaptureStrategy strategy = null; switch (captureType) { case CaptureType.Screen: strategy = new CaptureScreen(mainForm); break; case CaptureType.ActiveWindow: strategy = new CaptureActiveWindow(mainForm); break; case CaptureType.ActiveMonitor: strategy = new CaptureActiveMonitor(mainForm); break; case CaptureType.Rectangle: case CaptureType.RectangleWindow: case CaptureType.Polygon: case CaptureType.Freehand: strategy = new CaptureRegion(mainForm); break; case CaptureType.CustomRegion: strategy = new CaptureCustomRegion(mainForm); break; case CaptureType.LastRegion: strategy = new CaptureLastRegion(mainForm); break; } return strategy; }
public static void DailyScheduleView(DataGridView view, MainForm mainForm) { if (view.DataSource == null) { return; } view.ColumnHeadersVisible = false; view.RowHeadersVisible = false; view.DefaultCellStyle.WrapMode = DataGridViewTriState.True; view.AutoResizeColumns(); view.AutoResizeRows(); view.AllowUserToResizeColumns = false; view.AllowUserToResizeRows = false; // LessonId view.Columns[0].Visible = false; view.Columns[0].Width = 0; // Ring view.Columns[1].Width = 56; view.Columns[1].DefaultCellStyle.Font = new Font(view.DefaultCellStyle.Font.FontFamily, 14); view.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; // LessonSummary // view.Columns[2].Width = Percent(88, view.Width); view.Columns[2].Width = view.Width - view.Columns[1].Width - 20; }
private static void Initialize() { mainForm = new MainForm(); globalHook = new globalKeyboardHook(); globalHook.HookedKeys.Add(Keys.Home); globalHook.KeyDown += OnGlobalKeyDown; }
public MainController() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); cypher = new Cypher(); form = new MainForm(this); }
static void Main() { if (Control.ModifierKeys == (Keys.Control | Keys.Shift)) { Globals.EDITION = Edition.Research; } else if (Control.ModifierKeys == Keys.Shift) { Globals.EDITION = Edition.Lite; } else if (Control.ModifierKeys == Keys.Control) { Globals.EDITION = Edition.Grammar; } else // default { Globals.EDITION = Edition.Standard; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm form = new MainForm(); // disable the X close button of the form //IntPtr system_menu_handle = GetSystemMenu(form.Handle, false); //DisableCloseIcon(system_menu_handle); Application.Run(form); }
public ProfileExporter(MainForm mainForm) { InitializeComponent(); this.mainForm = mainForm; Profiles = mainForm.Profiles.AllProfiles; }
/// <summary> /// Constructor /// </summary> public TrafficVolumeForm(VerkehrSteuerung steuerung, MainForm mainForm, NodeSteuerung nodeController) { this.m_steuerung = steuerung; this.m_mainForm = mainForm; this.m_nodeController = nodeController; InitializeComponent(); this.splitContainer1.Panel2MinSize = 260; UpdateListboxLayout(); GetTrafficVolume(); this.m_steuerung.StartPointsChanged += new VerkehrSteuerung.StartPointsChangedEventHandler(m_steuerung_StartPointsChanged); this.m_steuerung.DestinationPointsChanged += new VerkehrSteuerung.DestinationPointsChangedEventHandler(m_steuerung_DestinationPointsChanged); this.m_steuerung.GlobalTrafficMultiplierChanged += new VerkehrSteuerung.GlobalTrafficMultiplierChangedEventHandler(m_steuerung_GlobalTrafficMultiplierChanged); this.m_steuerung.CarTargetVelocityChanged += new VerkehrSteuerung.CarTargetVelocityChangedEventHandler(m_steuerung_CarTargetVelocityChanged); this.m_steuerung.TruckTargetVelocityChanged += new VerkehrSteuerung.TruckTargetVelocityChangedEventHandler(m_steuerung_TruckTargetVelocityChanged); this.m_steuerung.BusTargetVelocityChanged += new VerkehrSteuerung.BusTargetVelocityChangedEventHandler(m_steuerung_BusTargetVelocityChanged); this.m_steuerung.TramTargetVelocityChanged += new VerkehrSteuerung.TramTargetVelocityChangedEventHandler(m_steuerung_TramTargetVelocityChanged); renderOptions.renderLineNodes = false; renderOptions.renderNodeConnections = true; renderOptions.renderVehicles = false; renderOptions.performClipping = false; renderOptions.clippingRect = new Rectangle(0, 0, 10000, 10000); renderOptions.renderIntersections = false; renderOptions.renderLineChangePoints = false; renderOptions.renderLineNodeDebugData = false; renderOptions.renderNodeConnectionDebugData = false; renderOptions.renderVehicleDebugData = false; }
public override void RestoreForm(MainForm form) { if (form.Opacity == 0.0) form.Opacity = 1.0; form.Show(); }
public ConfigDocument(MainForm form) { InitializeComponent(); ShowHint = DockState.Document; Show(form.DockPanel); SetEditor(GetEditor()); }
public static void UpdateGUI(MainForm form, ProgressState progress = null) { int i = 0; int count = Program.Context.Movies.Distinct().Count(); float perc = 100 / (float)count; foreach (Movie file in Program.Context.Movies.Where(p => p.Status == Types.ItemStatus.Synced).OrderBy(p => p.Title).Include(p => p.Art).Include(p => p.Genres)) { progress.SetSubText("(" + (i+1) + "/" + Program.Context.Movies.Count() + ") " + file.Title); form.scanningBackgroundWorker.ReportProgress(progress.Value, progress); form.Invoke(new Action(() => { PosterCard pc = form.MovieCards.ContainsKey(file.ImdbId) ? form.MovieCards[file.ImdbId] : new PosterCard(); pc.Title = file.Title + (file.Year.HasValue ? $" ({file.Year.Value})" : ""); pc.Synopsis = file.Plot; pc.Genres = "Genres: " + string.Join(", ", file.Genres.Select(p => p.Name)); pc.Rating = "Rating: " + (file.Rating?.Name); if (!string.IsNullOrWhiteSpace(file.Art?.CachePath)) pc.Image = Bitmap.FromFile(file.Art.CachePath); if (!form.MovieCards.ContainsKey(file.ImdbId)) { pc.Dock = DockStyle.Fill; form.tlOverview.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, perc)); form.tlOverview.Controls.Add(pc, i++, 0); form.MovieCards.Add(file.ImdbId, pc); } pc.Movie = file; pc.CustomClick += form.Poster_click; })); } }
public FindDialog(MainForm mainForm) { this.mainForm = mainForm; this.InitializeComponent(); this.Owner = mainForm; this.ShowMessage("No results available.", 0); }
public SizesForm(object Parent) { parent = (MainForm)Parent; InitializeComponent(); trackBar1.Minimum = trackBar2.Minimum = trackBar3.Minimum = trackBar4.Minimum = trackBar7.Minimum = trackBar8.Minimum = 1; trackBar1.Maximum = trackBar2.Maximum = trackBar3.Maximum = trackBar4.Maximum = trackBar7.Maximum = 100; trackBar8.Maximum = 20; trackBar5.Minimum = trackBar6.Minimum = 4; trackBar5.Maximum = trackBar6.Maximum = 32; trackBar1.Value = (int)(Constants.SphereRadius * 100); trackBar2.Value = (int)(Constants.CylinderRadius * 100); trackBar3.Value = (int)(Constants.CameraTranslateSpeed * 100); trackBar4.Value = (int)(Constants.CameraRotateSpeed * 500); trackBar5.Value = Constants.CylinderSlices; trackBar6.Value = Constants.SphereSlices; trackBar7.Value = (int)(Constants.AxisLength * 10); trackBar8.Value = (int)(Constants.AxisRadius * 100); label3.Text = trackBar1.Value.ToString(); label4.Text = trackBar2.Value.ToString(); label5.Text = trackBar3.Value.ToString(); label7.Text = trackBar4.Value.ToString(); label9.Text = trackBar5.Value.ToString(); label11.Text = trackBar6.Value.ToString(); label14.Text = trackBar7.Value.ToString(); label15.Text = trackBar8.Value.ToString(); checkBox1.Checked = Constants.DrawAxis; }
private App(MainForm form) { this.MainForm = form; }
protected override void ProcessLine(String line) { //MainForm.Logger("line: " + line); Dictionary <String, Object> response = JsonConvert.DeserializeObject <Dictionary <string, Object> >(line); if (response.ContainsKey("method") && response.ContainsKey("params")) { string method = (string)response["method"]; JArray parameters = (JArray)response["params"]; if (method.Equals("mining.set_difficulty")) { try { mMutex.WaitOne(5000); } catch (Exception) { } mDifficulty = (double)parameters[0]; try { mMutex.ReleaseMutex(); } catch (Exception) { } MainForm.Logger("Difficulty set to " + (double)parameters[0] + "."); } else if (method.Equals("mining.notify") && (mJob == null || mJob.ID != (string)parameters[0])) { try { mMutex.WaitOne(5000); } catch (Exception) { } mJob = (new Job(this, (string)parameters[0], (string)parameters[2], (string)parameters[3], (string)parameters[7])); try { mMutex.ReleaseMutex(); } catch (Exception) { } MainForm.Logger("Received new job: " + parameters[0]); } else if (method.Equals("mining.set_extranonce")) { try { mMutex.WaitOne(5000); } catch (Exception) { } mPoolExtranonce = (String)parameters[0]; try { mMutex.ReleaseMutex(); } catch (Exception) { } MainForm.Logger("Received new extranonce: " + parameters[0]); } else if (method.Equals("client.reconnect")) { throw new Exception("client.reconnect"); } else { MainForm.Logger("Unknown stratum method: " + line); } } else if (response.ContainsKey("id") && response.ContainsKey("result")) { var ID = response["id"].ToString(); bool result = (response["result"] == null) ? false : (bool)response["result"]; if (ID == "3" && !result) { throw (UnrecoverableException = new UnrecoverableException("Authorization failed.")); } else if ((ID != "1" && ID != "2" && ID != "3") && result && !MainForm.DevFeeMode) { MainForm.Logger("Share #" + ID + " accepted."); ReportShareAcceptance(); } else if ((ID != "1" && ID != "2" && ID != "3") && !result && !MainForm.DevFeeMode) { MainForm.Logger("Share #" + ID + " rejected: " + (String)(((JArray)response["error"])[1])); ReportShareRejection(); } } else { MainForm.Logger("Unknown JSON message: " + line); } }
public RoomViewController(MainForm mainForm) { this.mainForm = mainForm; mainForm.roomsTable.DataError += RoomsTable_DataError; mainForm.roomSaveToolStripButton.Click += RoomSaveToolStripButton_Click; }
private void _tbMaximumBlackPercent_TextChanged(object sender, EventArgs e) { _tbMaximumBlackPercent.Text = MainForm.IsValidNumber(_tbMaximumBlackPercent.Text, 0, 100); }
/// <summary> /// Initialises a new instance of the <see cref="IRCMarshal"/> class. /// </summary> /// <param name="connection">The connection to marshal data to and from.</param> /// <param name="tabHost">The TabControl that hosts the server and channel tabs.</param> /// <param name="autoCommands">A queue of commands to automatically execute once a connection is fully established.</param> /// <param name="parent">The owning form.</param> public IRCMarshal(Connection connection, TabControl tabHost, List<string> autoCommands, MainForm parent) { this.tabHost = tabHost; this.parent = parent; this.previousNickName = connection.Nickname; this.AwaitingModeMessage = true; this.AwaitingUserHostMessage = true; this.connection = connection; this.SetupConnectionEventHandlers(); this.channels = new List<IRCChannel>(); this.messageQueue = new Queue<Message>(15); this.channelBrowser = new ChannelBrowser(this); if (autoCommands != null) { this.autoCommands = autoCommands; } else { this.autoCommands = new List<string>(); } this.queueResetEvent = new AutoResetEvent(false); this.queueProcessingThread = new Thread(this.ProcessQueue); this.queueProcessingThread.Start(); }
/// <summary> /// Method for load messages. /// </summary> /// <param name="mailMessage">The mail messages.</param> /// <param name="type">The mail sender type.</param> public void LoadMessage(MailMessage mailMessage, MailSenderType type) { // the current mailbox. string mailbox = MainForm.GetInstance().GetSelectedMailbox(); // retrieve the message body. string body = Facade.GetInstance().GetMessageBodyString(mailMessage, mailbox); // load message to. if (type == MailSenderType.Reply) { this.tbTo.Text = mailMessage.From; } else if (type == MailSenderType.ReplyToAll) { string to = mailMessage.From; if (to.Length > 0) { to = string.Concat(to, ", ", mailMessage.To); } this.tbTo.Text = to; } // load message subject. if (type == MailSenderType.Reply || type == MailSenderType.ReplyToAll) { this.tbSubject.Text = string.Concat("Re: ", mailMessage.Subject); } else if (type == MailSenderType.Forward) { this.tbSubject.Text = string.Concat("Fwd: ", mailMessage.Subject); } // TODO: load message attachments. // load message body. if (type == MailSenderType.Reply || type == MailSenderType.ReplyToAll) { StringBuilder sb = new StringBuilder(); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append("On "); sb.Append(mailMessage.SentDate); sb.Append(", "); sb.Append(mailMessage.From); sb.Append(" wrote:"); sb.Append(Environment.NewLine); sb.Append(body); this.htmlEditorControl.InnerText = sb.ToString(); } else if (type == MailSenderType.Forward) { StringBuilder sb = new StringBuilder(); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append("---------- Forwarded message ----------"); sb.Append(Environment.NewLine); sb.Append("From: "); sb.Append(mailMessage.From); sb.Append(Environment.NewLine); sb.Append("Date: "); sb.Append(mailMessage.SentDate); sb.Append(Environment.NewLine); sb.Append("Subject: "); sb.Append(mailMessage.Subject); sb.Append(Environment.NewLine); sb.Append("To: "); sb.Append(mailMessage.To); sb.Append(Environment.NewLine); sb.Append(Environment.NewLine); sb.Append(body); sb.Append(Environment.NewLine); this.htmlEditorControl.InnerText = sb.ToString(); } }
private void bt_Run_Click(object sender, EventArgs e) { if (rtb_midasin.Text.Length == 0) { rtb_midasout.Text = "没有输入Midas格式的选择集"; return; } List <int> nns = SelectCollection.StringToList(rtb_midasin.Text); MainForm mmf = this.Owner as MainForm;//主窗口 ModelForm1 mf = mmf.ModelForm; MidasGenModel.model.Bmodel mm = mf.CurModel; List <Triangle> Tras = mm.getDelaunayTriangleByNodes(nns); rtb_midasout.Clear();//清屏 rtb_midasout.AppendText("\n转换成功,共" + Tras.Count.ToString() + "个三角形"); //进行三角形过滤 if (cb_Con.Checked) { double Ang_con = double.Parse(tb_Ang.Text); List <Triangle> TransNew = new List <Triangle>(); //畸形三角形过滤 foreach (Triangle tt in Tras) { if (tt.getMaxAngle() <= Ang_con) { TransNew.Add(tt); } } Tras = TransNew;//更新新的三角形集合 rtb_midasout.AppendText("\n进行△过滤后,共" + Tras.Count.ToString() + "个三角形"); } //下面转换成板单元命令流 int i = 1; rtb_midasout.AppendText("\n*ELEMENT"); foreach (Triangle ang in Tras) { MidasGenModel.DelaunayTriangulator.Point pt1 = ang.Vertex1; MidasGenModel.DelaunayTriangulator.Point pt2 = ang.Vertex2; MidasGenModel.DelaunayTriangulator.Point pt3 = ang.Vertex3; int n1 = mm.getNode(pt1.X, pt1.Y, pt1.Z); int n2 = mm.getNode(pt2.X, pt2.Y, pt2.Z); int n3 = mm.getNode(pt3.X, pt3.Y, pt3.Z); int iNum = i + iMaxElem;//单元号 string trout = "\n " + iNum.ToString() + ", PLATE, 5, 2, " + n1 + ", " + n2 + ", " + n3; rtb_midasout.AppendText(trout); //提示信息输出 label1.Text = "提示:板单元" + i.ToString() + "已生成..."; this.Refresh(); i++; } //更新最大单元号 iMaxElem = iMaxElem + i; }
static void Main(string[] args) { #if DEBUG // Set omapi.dll debug level in debug builds if (Environment.GetEnvironmentVariable("OMDEBUG") == null) { Environment.SetEnvironmentVariable("OMDEBUG", "1"); } #endif try { // Default to only logging UI exceptions logUiExceptionsOnly = true; // Exception handling Application.ThreadException += Application_ThreadException; // UI thread exceptions Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); // Force UI exceptions through our handler AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // non-UI thread exceptions // Run the application Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Command-line options string logFile = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "log.txt"; string configDumpFile = null; // Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + "dump.csv"; string downloadDumpFile = null; bool noUpdateCheck = false; string startupPath = null; int resetIfUnresponsive = 3; int positional = 0; int uac = 0; for (int i = 0; i < args.Length; i++) { if (args[i].ToLower() == "-log") { logFile = args[++i]; } else if (args[i].ToLower() == "-configlog" || args[i].ToLower() == "-dump") { configDumpFile = args[++i]; } else if (args[i].ToLower() == "-downloadlog") { downloadDumpFile = args[++i]; } else if (args[i].ToLower() == "-noupdatecheck") { noUpdateCheck = true; } else if (args[i].ToLower() == "-folder") { startupPath = args[++i]; } else if (args[i].ToLower() == "-noreset") { resetIfUnresponsive = 0; } else if (args[i].ToLower() == "-uac:none") { uac = 0; } else if (args[i].ToLower() == "-uac:ask") { uac = 1; } else if (args[i].ToLower() == "-uac:always") { uac = 2; } else if (args[i].ToLower() == "-uac:require") { uac = 3; } else if (args[i][0] == '-' || args[i][0] == '/') { string error = "ERROR: Ignoring unknown option: " + args[i]; Console.Error.WriteLine(error); MessageBox.Show(null, error, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //if (positional == 0) { loadFile = args[i]; } //else { string error = "ERROR: Ignoring positional parameter #" + (positional + 1) + ": " + args[i]; Console.Error.WriteLine(error); MessageBox.Show(null, error, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } positional++; } } Splash splashScreen = new Splash(); splashScreen.Started += (s, e) => { Console.WriteLine("Splash: ...shown..."); MainForm mainForm = new MainForm(uac, configDumpFile, downloadDumpFile, noUpdateCheck, startupPath, resetIfUnresponsive); //mainForm.LogFile = logFile; mainForm.Started += (sender, e2) => { Console.WriteLine("Splash: ...main app started..."); splashScreen.Invoke(new Action(() => splashScreen.Hide())); }; mainForm.FormClosed += (sender, e2) => { splashScreen.Close(); //Application.ExitThread(); }; mainForm.Show(); }; Console.WriteLine("Splash: showing..."); //splashScreen.Show(); ApplicationContext ac = new ApplicationContext(splashScreen); Application.Run(ac); } catch (Exception ex) { string error = "Sorry, a fatal application error occurred (exception in main function).\r\n\r\n" + "Exception: " + ex.ToString() + "\r\n\r\n" + "Stack trace: " + ex.StackTrace + ""; MessageBox.Show(error, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(-1); } }
// Determines if the specified port is in use by the TracerX service by attempting to connect to it. private static void TryConnecting(int port) { try { using (ProxyFileEnum serviceProxy = new ProxyFileEnum()) { serviceProxy.SetHost("localhost:" + port); int serviceInterfaceVersion = serviceProxy.ExchangeVersion(1); // Getting here without an exception means the TracerX service is listening on the port. // Depending on the version, we may be able to get additional info. if (serviceInterfaceVersion < 3) { // That's all we can get (the interface version). MainForm.ShowMessageBox("The specified port is in use by another process that's running the TracerX service."); } else { string processExe; string processVersion; string processAccount; if (serviceInterfaceVersion < 5) { serviceProxy.GetServiceHostInfo(out processExe, out processVersion, out processAccount); } else { // As of version 5, we can get whether the service is impersonating // clients or not with GetServiceHostInfo2, but we don't need to. serviceProxy.GetServiceHostInfo(out processExe, out processVersion, out processAccount); } string msg = "The specified port is in use by another process that's running the TracerX service."; if (processExe != null) { msg += "\n\nExecutable: " + processExe; if (processVersion != null) { msg += " (version " + processVersion + ")"; } } if (processAccount != null) { msg += "\n\nAccount: " + processAccount; } MainForm.ShowMessageBox(msg); } } } catch (Exception ex) { // Assume this means the process using the port is not TracerX. MainForm.ShowMessageBox("The specified port is in use by another process."); } }
private void _tbMinimumInvertHeight_TextChanged(object sender, EventArgs e) { _tbMinimumInvertHeight.Text = MainForm.IsValidNumber(_tbMinimumInvertHeight.Text, 0, 10000); }
private bool SaveCrew() { if (_crewGuid == MainForm.zeroGuid) { if (!checkSameName(tbName.Text, MainForm.zeroGuid)) { return(false); } if (!checkSameID(tbPersonalID.Text, MainForm.zeroGuid)) { return(false); } OleDbCommand cmd = new OleDbCommand("", connection); Guid newGuid = Guid.NewGuid(); cmd.CommandText = "insert into CREW (CREW_GUID,CREW_NAME,CREW_POSITION_GUID,PERSONAL_ID,CREW_NOTES) \n" + "values(" + MainForm.GuidToStr(newGuid) + ",'" + MainForm.StrToSQLStr(tbName.Text) + "'," + MainForm.GuidToStr(MainForm.StrToGuid(cbPosition.SelectedValue.ToString())) + ",'" + MainForm.StrToSQLStr(tbPersonalID.Text) + "','" + MainForm.StrToSQLStr(tbNotes.Text) + "')"; if (MainForm.cmdExecute(cmd) < 0) { MessageBox.Show("Failed to create new record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { _crewGuid = newGuid; return(true); } } else { if (!checkSameName(tbName.Text, _crewGuid)) { return(false); } ; if (!checkSameID(tbPersonalID.Text, _crewGuid)) { return(false); } OleDbCommand cmd = new OleDbCommand("", connection); cmd.CommandText = "update CREW set \n" + "CREW_NAME='" + MainForm.StrToSQLStr(tbName.Text) + "', \n" + "CREW_POSITION_GUID=" + MainForm.GuidToStr(MainForm.StrToGuid(cbPosition.SelectedValue.ToString())) + ",\n" + "PERSONAL_ID='" + MainForm.StrToSQLStr(tbPersonalID.Text) + "', \n" + "CREW_NOTES='" + MainForm.StrToSQLStr(tbNotes.Text) + "' \n" + "where CREW_GUID=" + MainForm.GuidToStr(_crewGuid); if (MainForm.cmdExecute(cmd) < 0) { MessageBox.Show("Failed to update record", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } else { return(true); } } }
// Worker thread private void WorkerThread( ) { // buffer to read stream var buffer = new byte[BufferSize]; // HTTP web request HttpWebRequest request = null; // web responce WebResponse response = null; // stream for JPEG downloading Stream stream = null; // random generator to add fake parameter for cache preventing var rand = new Random((int)Helper.Now.Ticks); // download start time and duration TimeSpan span; var res = ReasonToFinishPlaying.StoppedByUser; int err = 0; while (!_stopEvent.WaitOne(0, false) && !MainForm.Reallyclose) { int total = 0; try { // set download start time DateTime start = Helper.Now; // create request if (!_preventCaching) { // request without cache prevention request = (HttpWebRequest)WebRequest.Create(_source); } else { // request with cache prevention request = (HttpWebRequest)WebRequest.Create(_source + ((_source.IndexOf('?') == -1) ? '?' : '&') + "fake=" + rand.Next( )); } if (_userAgent != null) { request.UserAgent = _userAgent; } // set proxy if (_proxy != null) { request.Proxy = _proxy; } if (_usehttp10) { request.ProtocolVersion = HttpVersion.Version10; } // set timeout value for the request request.Timeout = _requestTimeout; request.AllowAutoRedirect = true; // set timeout value for the request // set login and password if ((_login != null) && (_password != null) && (_login != string.Empty)) { request.Credentials = new NetworkCredential(_login, _password); } // set connection group name if (_useSeparateConnectionGroup) { request.ConnectionGroupName = GetHashCode( ).ToString(CultureInfo.InvariantCulture); } // force basic authentication through extra headers if required var authInfo = ""; if (!String.IsNullOrEmpty(_login)) { authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(_login + ":" + _password)); request.Headers["Authorization"] = "Basic " + authInfo; } if (!String.IsNullOrEmpty(_cookies)) { _cookies = _cookies.Replace("[AUTH]", authInfo); var myContainer = new CookieContainer(); string[] coll = _cookies.Split(';'); foreach (var ckie in coll) { if (!String.IsNullOrEmpty(ckie)) { string[] nv = ckie.Split('='); if (nv.Length == 2) { var cookie = new Cookie(nv[0].Trim(), nv[1].Trim()); myContainer.Add(new Uri(request.RequestUri.ToString()), cookie); } } } request.CookieContainer = myContainer; } if (!String.IsNullOrEmpty(Headers)) { Headers = Headers.Replace("[AUTH]", authInfo); string[] coll = _cookies.Split(';'); foreach (var hdr in coll) { if (!String.IsNullOrEmpty(hdr)) { string[] nv = hdr.Split('='); if (nv.Length == 2) { request.Headers.Add(nv[0], nv[1]); } } } } // get response response = request.GetResponse( ); // get response stream stream = response.GetResponseStream( ); stream.ReadTimeout = _requestTimeout; // loop while (!_stopEvent.WaitOne(0, false)) { // check total read if (total > BufferSize - ReadSize) { total = 0; } // read next portion from stream int read; if ((read = stream.Read(buffer, total, ReadSize)) == 0) { break; } total += read; // increment received bytes counter _bytesReceived += read; } if (!_stopEvent.WaitOne(0, false)) { // increment frames counter _framesReceived++; // provide new image to clients if (NewFrame != null) { using (var bitmap = (Bitmap)Image.FromStream(new MemoryStream(buffer, 0, total))) { // notify client NewFrame(this, new NewFrameEventArgs(bitmap)); // release the image } //var decoder = new JpegBitmapDecoder(new MemoryStream(buffer, 0, total), BitmapCreateOptions.None, BitmapCacheOption.OnLoad); //BitmapSource frame = decoder.Frames[0]; //Bitmap bmp = BitmapFromSource(frame); //NewFrame(this, new NewFrameEventArgs(bmp)); //bmp.Dispose(); ////// release the image ////bmp.Dispose(); //bmp = null; } } // wait for a while ? if (_frameInterval > 0) { // get download duration span = Helper.Now.Subtract(start); // miliseconds to sleep int msec = _frameInterval - (int)span.TotalMilliseconds; if ((msec > 0) && (_stopEvent.WaitOne(msec, false))) { break; } } err = 0; } catch (ThreadAbortException) { break; } catch (Exception ex) { // provide information to clients MainForm.LogErrorToFile(ex.Message); err++; if (err > 3) { res = ReasonToFinishPlaying.DeviceLost; break; } //if ( VideoSourceError != null ) //{ // VideoSourceError( this, new VideoSourceErrorEventArgs( exception.Message ) ); //} // wait for a while before the next try Thread.Sleep(250); } finally { // abort request if (request != null) { try { request.Abort(); } catch { } request = null; } // close response stream if (stream != null) { try { stream.Close(); } catch { //somehow can be disposed already? } stream = null; } // close response if (response != null) { try { response.Close(); } catch { } response = null; } } // need to stop ? if (_stopEvent.WaitOne(0, false)) { break; } } if (PlayingFinished != null) { PlayingFinished(this, res); } }
public static void LoadPlugins(MainForm MainWindow, ToolStrip MainToolbar) { string pluginPath = Path.Combine(Application.StartupPath, "Plugins"); if (!Directory.Exists(pluginPath)) { return; } var libraries = Directory.GetFiles(pluginPath, "*.dll"); foreach (var lib in libraries) { var asm = Assembly.LoadFrom(lib); var pluginTypes = asm.GetTypes().Where(tp => tp.IsAssignableTo(typeof(PluginBase))); foreach (var type in pluginTypes) { var pluginInstance = Activator.CreateInstance(type) as PluginBase; loadedPlugins.Add(pluginInstance); if (pluginInstance.MenuItems != null && pluginInstance.MenuItems.Length > 0) { MainToolbar.Items.Add(new ToolStripSeparator()); foreach (var item in pluginInstance.MenuItems) { switch (item.ItemType) { case PluginMenuItemType.Button: var btn = new ToolStripButton(); btn.ToolTipText = item.Tooltip; btn.Image = item.Image; btn.DisplayStyle = ToolStripItemDisplayStyle.Image; btn.Text = item.Tooltip; btn.Tag = new MenuItemIdentifier { PluginId = pluginInstance.PluginId, ItemId = item.Id }; btn.Enabled = false; btn.Click += PluginElement_Click; MainToolbar.Items.Add(btn); pluginItems.Add(btn); break; case PluginMenuItemType.Dropdown: var dd = new ToolStripDropDownButton(); dd.ToolTipText = item.Tooltip; dd.Image = item.Image; dd.Text = item.Tooltip; dd.DisplayStyle = ToolStripItemDisplayStyle.Image; dd.Tag = new MenuItemIdentifier { PluginId = pluginInstance.PluginId, ItemId = item.Id }; dd.Enabled = false; dd.Click += PluginElement_Click; if (item.DropdownItems != null) { foreach (var drop in item.DropdownItems) { var ddd = new ToolStripMenuItem(); ddd.Text = drop.Text; ddd.Image = drop.Image; ddd.Tag = new MenuItemIdentifier { PluginId = pluginInstance.PluginId, ItemId = drop.Id }; ddd.Click += PluginElement_Click; dd.DropDownItems.Add(ddd); } } MainToolbar.Items.Add(dd); pluginItems.Add(dd); break; } } } pluginInstance.OpenNewWindow += PluginInstance_OpenNewWindow; pluginInstance.RequestCharSet += PluginInstance_RequestCharSet; pluginInstance.AddUpdateCharSet += PluginInstance_AddUpdateCharSet; pluginInstance.DeleteCharSet += PluginInstance_DeleteCharSet; pluginInstance.RequestCharSetIndex += PluginInstance_RequestCharSetIndex; pluginInstance.OpenEditorWindow += PluginInstance_OpenEditorWindow; pluginInstance.Initialize(); } } }
public static void Main(string[] args) { // It's important to call these before starting the app; otherwise theming and bitmaps // may not render correctly. Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714 // Set up localization support early on, so that user-readable strings will be localized // during the initialization phase below. Use XML files that are embedded resources. Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture; Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer()); // Enable metadata driven property editing for the DOM DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>()); // Create a type catalog with the types of components we want in the application var catalog = new TypeCatalog( typeof(SettingsService), // persistent settings and user preferences dialog typeof(StatusService), // status bar at bottom of main Form typeof(CommandService), // handles commands in menus and toolbars typeof(ControlHostService), // docking control host typeof(AtfUsageLogger), // logs computer info to an ATF server typeof(CrashLogger), // logs unhandled exceptions to an ATF server typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save typeof(FileDialogService), // standard Windows file dialogs typeof(DocumentRegistry), // central document registry with change notification typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup typeof(RecentDocumentCommands), // standard recent document commands in File menu typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close typeof(MainWindowTitleService), // tracks document changes and updates main form title typeof(TabbedControlSelector), // enable ctrl-tab selection of documents and controls within the app typeof(ContextRegistry), // central context registry with change notification typeof(StandardFileExitCommand), // standard File exit menu command typeof(StandardEditCommands), // standard Edit menu commands for copy/paste typeof(StandardEditHistoryCommands), // standard Edit menu commands for undo/redo typeof(StandardSelectionCommands), // standard Edit menu selection commands typeof(StandardLayoutCommands), // standard Format menu layout commands typeof(StandardViewCommands), // standard View menu commands //StandardPrintCommands does not currently work with Direct2D //typeof(StandardPrintCommands), // standard File menu print commands typeof(HelpAboutCommand), // Help -> About command typeof(PaletteService), // global palette, for drag/drop instancing typeof(HistoryLister), // vistual list of undo/redo stack typeof(PropertyEditor), // property grid for editing selected objects typeof(GridPropertyEditor), // grid control for editing selected objects typeof(PropertyEditingCommands), // commands for PropertyEditor and GridPropertyEditor, like Reset, // Reset All, Copy Value, Paste Value, Copy All, Paste All typeof(PrototypeLister), // editable palette of instantiable item groups typeof(Outputs), // passes messages to all log writers typeof(ErrorDialogService), // displays errors to the user in a message box typeof(DiagramTheme), // rendering theme for diagrams typeof(Editor), // editor which manages FSM documents and controls typeof(PaletteClient), // component which adds items to palette typeof(DefaultTabCommands), // provides the default commands related to document tab Controls typeof(SchemaLoader), // loads schema and extends types typeof(PythonService), // scripting service for automated tests typeof(ScriptConsole), // provides a dockable command console for entering Python commands typeof(AtfScriptVariables), // exposes common ATF services as script variables typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service ); // Set up the MEF container with these components var container = new CompositionContainer(catalog); // Configure the main Form var batch = new CompositionBatch(); var mainForm = new MainForm(new ToolStripContainer()) { Text = Application.ProductName, Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage)) }; Sce.Atf.Direct2D.D2dFactory.EnableResourceSharing(mainForm.Handle); // Add the main Form instance to the container batch.AddPart(mainForm); batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-FSM-Editor-Sample".Localize())); container.Compose(batch); // Initialize components that require it. Initialization often can't be done in the constructor, // or even after imports have been satisfied by MEF, since we allow circular dependencies between // components, via the System.Lazy class. IInitializable allows components to defer some operations // until all MEF composition has been completed. container.InitializeAll(); // Show the main form and start message handling. The main Form Load event provides a final chance // for components to perform initialization and configuration. Application.Run(mainForm); // Give components a chance to clean up. container.Dispose(); }
private static readonly Bitmap VillagerList = Properties.Resources.Villagers; // currently for GC only /// <inheritdoc/> /// <summary> /// Initializes a new VillagerControl object. /// </summary> /// <param name="mainFormReference">The main form reference, which is used by the item editor subcontrols.</param> /// <param name="index">The index of the control.</param> /// <param name="saveFile">The currently open <see cref="T:ACSE.Save" />.</param> /// <param name="villager">The <see cref="T:ACSE.Villager" /> that is being edited.</param> /// <param name="villagers">A dictionary of <see cref="T:ACSE.SimpleVillager" />s and their villager ids.</param> /// <param name="villagerNames">An array of villager names.</param> /// <param name="personalityTypes">An array of personality names.</param> public VillagerControl(MainForm mainFormReference, int index, Save saveFile, Villager villager, Dictionary <ushort, SimpleVillager> villagers, string[] villagerNames, string[] personalityTypes) { Index = index; _saveFile = saveFile; _villager = villager; _villagers = villagers; _villagerNames = villagerNames; _personalityTypes = personalityTypes; FlowDirection = FlowDirection.LeftToRight; AutoSize = true; Margin = new Padding(0); MaximumSize = new Size(0, 66); // Set up controls that are always used _indexLabel = new Label { AutoSize = false, Size = new Size(45, 32), TextAlign = ContentAlignment.MiddleCenter, Text = index == 16 ? "Islander" : (index + 1).ToString() }; var margin = CalculateControlVerticalMargin(_indexLabel); _indexLabel.Margin = new Padding(0, margin, 0, margin); _villagerSelectionBox = new ComboBox { Size = new Size(120, 32), DropDownStyle = ComboBoxStyle.DropDownList }; margin = CalculateControlVerticalMargin(_villagerSelectionBox); _villagerSelectionBox.Margin = new Padding(0, margin, 10, margin); _villagerSelectionBox.Items.AddRange(_villagerNames); for (var i = 0; i < _villagers.Count; i++) { if (villagers.ElementAt(i).Key != _villager.Data.VillagerId) { continue; } _villagerSelectionBox.SelectedIndex = i; break; } _villagerSelectionBox.SelectedIndexChanged += (s, e) => VillagerSelectionBoxChanged(); _personalityBox = new ComboBox { Size = new Size(80, 32), DropDownStyle = ComboBoxStyle.DropDownList }; margin = CalculateControlVerticalMargin(_personalityBox); _personalityBox.Margin = new Padding(0, margin, 10, margin); _personalityBox.Items.AddRange(_personalityTypes); _personalityBox.SelectedIndex = _villager.Data.Personality % _personalityTypes.Length; _personalityBox.SelectedIndexChanged += (o, e) => PersonalityChanged(); _catchphraseBox = new TextBox { Size = new Size(100, 32), MaxLength = _villager.Offsets.CatchphraseSize, Text = _villager.Data.Catchphrase }; margin = CalculateControlVerticalMargin(_catchphraseBox); _catchphraseBox.Margin = new Padding(0, margin, 10, margin); _catchphraseBox.TextChanged += (s, e) => CatchphraseChanged(); _shirtEditor = new SingleItemEditor(mainFormReference, _villager.Data.Shirt, 16); margin = CalculateControlVerticalMargin(_shirtEditor); _shirtEditor.Margin = new Padding(0, margin, 10, margin); _shirtEditor.ItemChanged += delegate(object sender, ItemChangedEventArgs e) { _villager.Data.Shirt = e.NewItem; }; if (_villager.Data.Umbrella != null) { _umbrellaEditor = new SingleItemEditor(mainFormReference, _villager.Data.Umbrella, 16); margin = CalculateControlVerticalMargin(_umbrellaEditor); _umbrellaEditor.Margin = new Padding(0, margin, 10, margin); } // Add controls to flow panel Controls.Add(_indexLabel); Controls.Add(_villagerSelectionBox); Controls.Add(_personalityBox); Controls.Add(_catchphraseBox); Controls.Add(_shirtEditor); Controls.Add(_umbrellaEditor); // Set up controls that are used on a per-save generation basis switch (_saveFile.SaveGeneration) { case SaveGeneration.N64: case SaveGeneration.GCN: case SaveGeneration.iQue: // e+ exclusive controls TODO: These will probably be used in City Folk as well. if (_saveFile.SaveType == SaveType.DoubutsuNoMoriEPlus || _saveFile.SaveType == SaveType.AnimalForestEPlus) { _nameBox = new TextBox { Size = new Size(60, 32), Text = _villager.Name, MaxLength = _saveFile.SaveType == SaveType.AnimalForestEPlus ? 8 : 6 }; margin = CalculateControlVerticalMargin(_nameBox); _nameBox.Margin = new Padding(0, margin, 10, margin); _nameBox.TextChanged += (s, e) => NameTextChanged(); _importDlcButton = new Button { Text = "Import DLC Data", AutoSize = true }; margin = CalculateControlVerticalMargin(_importDlcButton); _importDlcButton.Margin = new Padding(0, margin, 10, margin); _importDlcButton.Click += (s, e) => ImportDlcVillager(); Controls.Add(_nameBox); Controls.Add(_importDlcButton); } _villagerPreviewBox = new OffsetablePictureBox { Size = new Size(64, 64), Image = VillagerList, Offset = (_villager.Data.VillagerId < 0xE000 || _villager.Data.VillagerId > 0xE0EB) ? new Point(64 * 6, 64 * 23) : new Point(64 * ((_villager.Data.VillagerId & 0xFF) % 10), 64 * ((_villager.Data.VillagerId & 0xFF) / 10)) }; Controls.Add(_villagerPreviewBox); break; case SaveGeneration.NDS: case SaveGeneration.Wii: case SaveGeneration.N3DS: _carpetWallpaperEditor = new ItemEditor(mainFormReference, new[] { _villager.Data.Carpet, _villager.Data.Wallpaper }, 2, 16); margin = CalculateControlVerticalMargin(_carpetWallpaperEditor); _carpetWallpaperEditor.Margin = new Padding(0, margin, 10, margin); _musicEditor = new SingleItemEditor(mainFormReference, _villager.Data.Song, 16); margin = CalculateControlVerticalMargin(_musicEditor); _musicEditor.Margin = new Padding(0, margin, 10, margin); _furnitureEditor = new ItemEditor(mainFormReference, _villager.Data.Furniture, _villager.Data.Furniture.Length, 16); margin = CalculateControlVerticalMargin(_furnitureEditor); _furnitureEditor.Margin = new Padding(0, margin, 10, margin); Controls.Add(_carpetWallpaperEditor); Controls.Add(_musicEditor); Controls.Add(_furnitureEditor); if (_saveFile.SaveGeneration == SaveGeneration.N3DS) { _boxedCheckBox = new CheckBox { Text = "Boxed", Checked = _villager.Boxed() }; margin = CalculateControlVerticalMargin(_boxedCheckBox); _boxedCheckBox.Margin = new Padding(0, margin, 10, margin); _boxedCheckBox.CheckedChanged += (o, e) => BoxedCheckBoxChanged(); Controls.Add(_boxedCheckBox); } break; case SaveGeneration.Unknown: break; default: Console.Write($"Unhandled save generation {_saveFile.SaveGeneration}!"); break; } }
private void panel1_Paint(object sender, PaintEventArgs e) { MainForm.DialogPanel_Paint(sender, e); }
protected abstract void Check(MainForm form, string ext, RegistryKey rk, DataEntry[] de);
public static void ProcessGlobalMessage(int nId, MainForm mf) { if (mf == null) { throw new ArgumentNullException("mf"); } IpcParamEx ipcMsg = LoadIpcInfoFile(nId); if (ipcMsg == null) { return; } if (ipcMsg.Message == CmdOpenDatabase) { mf.UIBlockAutoUnlock(true); mf.EnsureVisibleForegroundWindow(true, true); mf.UIBlockAutoUnlock(false); // Don't try to open another database while a dialog // is displayed (3489098) if (GlobalWindowManager.WindowCount > 0) { return; } string[] vArgs = CommandLineArgs.SafeDeserialize(ipcMsg.Param0); if (vArgs == null) { Debug.Assert(false); return; } CommandLineArgs args = new CommandLineArgs(vArgs); Program.CommandLineArgs.CopyFrom(args); mf.OpenDatabase(mf.IocFromCommandLine(), KeyUtil.KeyFromCommandLine( Program.CommandLineArgs), true); } else if (ipcMsg.Message == CmdOpenEntryUrl) { OpenEntryUrl(ipcMsg, mf); } else if (ipcMsg.Message == CmdIpcEvent) { try { if (IpcUtilEx.IpcEvent == null) { return; } string strName = ipcMsg.Param0; if (string.IsNullOrEmpty(strName)) { Debug.Assert(false); return; } string[] vArgs = CommandLineArgs.SafeDeserialize(ipcMsg.Param1); if (vArgs == null) { Debug.Assert(false); return; } CommandLineArgs clArgs = new CommandLineArgs(vArgs); IpcEventArgs e = new IpcEventArgs(strName, clArgs); IpcUtilEx.IpcEvent(null, e); } catch (Exception) { Debug.Assert(false); } } else { Debug.Assert(false); } }
/// <summary> /// /// </summary> /// <param name="main"></param> /// <param name="t"></param> /// <param name="info"></param> /// <param name="i">位置</param> /// <param name="listview"></param> /// <param name="selectindex">选择索引</param> /// <returns></returns> public static ListViewItem GetItemView(this MainForm main, Item t, int i, ListView listview, bool fullname, bool hascolor, bool has2category) { ListViewItem vitem = new ListViewItem(); ItemClassInfo info = main.DataHelper.GetItemInfo(t.ItemClass); t.Attach(info); vitem.Tag = t; vitem.Text = (t.ItemName == null ? t.ItemClass : t.ItemName); if (fullname && t.Attributes != null) { string head = ""; foreach (ItemAttribute attr in t.Attributes) { if (attr.Type == ItemAttributeType.ENHANCE) { head = "+" + attr.Value + " "; break; } } foreach (ItemAttribute attr in t.Attributes) { if (attr.Type == ItemAttributeType.SYNTHESISGRADE) { head = "【" + attr.Value.Split('/')[0] + "】"; break; } } foreach (ItemAttribute attr in t.Attributes) { if (attr.Type == ItemAttributeType.PREFIX) { EnchantInfo einfo = main.DataHelper.GetEnchant(attr.Value); head += "【" + (einfo == null ? attr.Value : einfo.Name) + "】"; break; } } foreach (ItemAttribute attr in t.Attributes) { if (attr.Type == ItemAttributeType.SUFFIX) { EnchantInfo einfo = main.DataHelper.GetEnchant(attr.Value); head += "【" + (einfo == null ? attr.Value : einfo.Name) + "】"; break; } } foreach (ItemAttribute attr in t.Attributes) { if (attr.Type == ItemAttributeType.QUALITY) { head += "★" + attr.Arg + " "; break; } else if (attr.Type == ItemAttributeType.VALUE) { vitem.Text = vitem.Text.Replace("{0}", attr.Value); } } if (!string.IsNullOrEmpty(head)) { vitem.Text = head + vitem.Text; } } if (i % 2 == 0) { vitem.BackColor = Color.GhostWhite; } else { vitem.BackColor = Color.White; } vitem.SubItems.Add("" + t.Count); if (has2category) { vitem.SubItems.Add("" + t.MainCategory); } vitem.SubItems.Add("" + t.SubCategory); if (hascolor) { vitem.UseItemStyleForSubItems = false; int colorIndex = vitem.SubItems.Count; vitem.SubItems.Add(""); // + (t.Color1 == 0 ? "" : t.Color1.ToString("x"))); vitem.SubItems.Add(""); // + (t.Color1 == 0 || t.Color2 == 0 ? "" : t.Color2.ToString("x"))); vitem.SubItems.Add(""); // + (t.Color1 == 0 || t.Color3 == 0 ? "" : t.Color3.ToString("x"))); vitem.SubItems[colorIndex].BackColor = t.Color1.GetColor(); vitem.SubItems[colorIndex + 1].BackColor = t.Color2.GetColor(); vitem.SubItems[colorIndex + 2].BackColor = t.Color3.GetColor(); vitem.SubItems[colorIndex].ForeColor = vitem.SubItems[colorIndex].BackColor; vitem.SubItems[colorIndex + 1].ForeColor = vitem.SubItems[colorIndex + 1].BackColor; vitem.SubItems[colorIndex + 2].ForeColor = vitem.SubItems[colorIndex + 2].BackColor; } vitem.SubItems.Add("" + t.Time); vitem.ToolTipText = t.ToString(); return(vitem); }
private bool checkSameID(string personalID, Guid crewGuidValue) { //Check for records with the same Personal ID OleDbCommand cmd = new OleDbCommand("", connection); cmd.CommandText = "select Count(PERSONAL_ID) \n" + "from CREW \n" + "where PERSONAL_ID like '" + MainForm.StrToSQLStr(personalID) + "' \n" + "and LEN(PERSONAL_ID)>0 \n" + "and CREW_GUID<>" + MainForm.GuidToStr(crewGuidValue); int recs = (int)cmd.ExecuteScalar(); if (recs > 0) { //There is record with the same name cmd.CommandText = "select CREW_NAME, PERSONAL_ID \n" + "from CREW \n" + "where PERSONAL_ID like '" + MainForm.StrToSQLStr(personalID) + "' \n" + "and LEN(PERSONAL_ID)>0 \n" + "and CREW_GUID<>" + MainForm.GuidToStr(crewGuidValue); OleDbDataReader mReader = cmd.ExecuteReader(); int recsReader = 0; string msgText = ""; while (mReader.Read()) { if (msgText.Length == 0) { msgText = "Name : \"" + mReader[0].ToString() + "\"; Personal ID : \"" + mReader[1].ToString() + "\""; } else { msgText = msgText + "\n" + "Name : \"" + mReader[0].ToString() + "\"; Personal ID : \"" + mReader[1].ToString() + "\""; } recsReader++; } if (recsReader == 1) { msgText = "There is a record with the same Personal ID: \n\n" + msgText; } else { msgText = "There are " + recsReader.ToString() + " records with the same Personal ID: \n\n" + msgText; } msgText = msgText + "\n\n Would you like to save this record?"; var res1 = MessageBox.Show(msgText, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res1 == DialogResult.Yes) { return(true); } else { return(false); } } else { return(true); } }