public override bool Process(Pic.DAL.SQLite.PPDataContext db, TreeNode tn) { if (!tn.IsComponent) return true; try { string filePath = tn.Documents(db)[0].File.Path(db); Pic.Plugin.Component comp = _compLoader.LoadComponent(filePath); if (null != _callback && null != comp) _callback.Info(string.Format("Successfully loaded component {0}", tn.Name)); else _callback.Error(string.Format("Failed to load component {0}", tn.Name)); Pic.Plugin.ParameterStack stack = comp.BuildParameterStack(null); foreach (Pic.Plugin.Parameter param in stack) { if (param.IsMajoration) continue; // only add parameter description TryAndAddString( param.Description ); // ParameterMulti ? Pic.Plugin.ParameterMulti paramMulti = param as Pic.Plugin.ParameterMulti; if (null != paramMulti) { foreach (string sText in paramMulti.DisplayList) TryAndAddString(sText); } } } catch (Exception ex) { if (null != _callback) _callback.Error(ex.Message); } return true; }
public override void SetComponent(Pic.Plugin.Component comp) { if (null == comp) return; // get client PLMPackServiceClient client = WCFClientSingleton.Instance.Client; // retrieve component _compGuid = comp.Guid; BuildCardboardProfile(); }
partial void UpdatePic(Pic instance);
private void detach_Pics(Pic entity) { this.SendPropertyChanging(); entity.Item = null; }
private void Bind_Pic() { var X = List_Account.Select(P => P.Account_Time); var Y = List_Account.Select(P => P.Account_Price); List <Car_Account> List_AccTemp = List_Account; List <SelectResult> Temp_result = new List <SelectResult>(); #region 地点处理 if (CB_Province.SelectedIndex > 0) { if (CB_City.SelectedIndex > 0) { if (CB_Shop.SelectedIndex > 0) { List_AccTemp = List_AccTemp.Where(P => P.Account_Shop == ShopID).ToList(); } else { } } else { } } #endregion #region 时间处理 if (CB_Year.SelectedIndex > 0) { List_AccTemp = List_AccTemp.Where(P => P.Account_Time.Year == Convert.ToInt32(CB_Year.SelectedItem.ToString())).ToList(); if (CB_Month.SelectedIndex > 0) { List_AccTemp = List_AccTemp.Where(P => P.Account_Time.Month == Convert.ToInt32(CB_Month.SelectedItem.ToString())).ToList(); if (CB_Day.SelectedIndex > 0) { int day = DateTime.DaysInMonth( Convert.ToInt32(CB_Year.SelectedItem.ToString()), Convert.ToInt32(CB_Month.SelectedItem.ToString())); List_AccTemp = List_AccTemp.Where(P => P.Account_Time.Day == Convert.ToInt32(CB_Day.SelectedItem.ToString())).ToList(); for (int i = 0; i < 24; i++) { SelectResult k = (from P in List_AccTemp where (P.Account_Time.Hour == i) group P by P.Account_Time.Hour into K select new SelectResult { Time = i, Price = K.Sum(P => P.Account_Price) }).FirstOrDefault(); Temp_result.Add(k ?? new SelectResult() { Price = 0, Time = i }); } } else { int day = DateTime.DaysInMonth( Convert.ToInt32(CB_Year.SelectedItem.ToString()), Convert.ToInt32(CB_Month.SelectedItem.ToString())); for (int i = 1; i <= day; i++) { SelectResult k = (from P in List_AccTemp where (P.Account_Time.Day == i) group P by P.Account_Time.Day into K select new SelectResult { Time = i, Price = K.Sum(P => P.Account_Price) }).FirstOrDefault(); Temp_result.Add(k ?? new SelectResult() { Price = 0, Time = i }); } } } else { for (int i = 1; i <= 12; i++) { SelectResult k = (from P in List_AccTemp where (P.Account_Time.Month == i) group P by P.Account_Time.Month into K select new SelectResult { Time = i, Price = K.Sum(P => P.Account_Price) }).FirstOrDefault(); Temp_result.Add(k ?? new SelectResult() { Price = 0, Time = i }); } } } else { for (int i = DateTime.Now.Year - 5; i <= DateTime.Now.Year; i++) { SelectResult k = (from P in List_AccTemp where (P.Account_Time.Year == i) group P by P.Account_Time.Year into K select new SelectResult { Time = i, Price = K.Sum(P => P.Account_Price) }).FirstOrDefault(); Temp_result.Add(k ?? new SelectResult() { Price = 0, Time = i }); } } #endregion Pic.Series["交易额"].Points.DataBind(Temp_result, "Time", "Price", "AxisLabel=Time,Label=Price"); Pic.Series["交易额"].ChartType = SeriesChartType.Column; Pic.Series["交易额"].IsValueShownAsLabel = true; //Pic.Series["S1"].Points.DataBindXY(X,Y); //foreach (DataPoint point in Pic.Series["S1"].Points) //{ // point["Exploded"] = "false"; // if(point.AxisLabel= //} //Pic.DataSource = Temp_result; Pic.DataBind(); }
protected int GetImageIndex(Pic.DAL.SQLite.TreeNode tn) { if (tn.IsDocument) { Pic.DAL.SQLite.PPDataContext db = new Pic.DAL.SQLite.PPDataContext(); Pic.DAL.SQLite.Document doc = tn.Documents(db)[0]; string docTypeName = doc.DocumentType.Name.ToLower(); Dictionary<string, int> format2iconDictionnary = new Dictionary<string, int>() { {"parametric component" , 2}, {"treedim des" , 3}, {"autodesk dxf" , 4}, {"adobe acrobat" , 5}, {"adobe illustrator" , 8}, {"raster image" , 9}, {"ms word" , 10}, {"ms excel" , 11}, {"ms powerpoint" , 12}, {"open office write" , 13}, {"open office calc" , 14}, {"artioscad" , 15}, {"treedim des3" , 17} }; if (format2iconDictionnary.ContainsKey(docTypeName)) return format2iconDictionnary[docTypeName]; else return 0; } else { if (string.Equals(tn.Name, "Root", StringComparison.CurrentCultureIgnoreCase)) return 16; // Root else return 0; } }
public ActionResult OnPostSave() { if ((this.Request != null) && (this.Request.Form != null)) { bool IsTemplate = false; /****************** * * public int tid { get; set; } * public int state { get; set; } * [DataMember] * public int reason { get; set; } * [DataMember] * public int PercentComplete { get; set; } * [DataMember] * public string Desc { get; set; } * [DataMember] * public List<Pic> pics { get; set; } * [DataMember] * public List<BOMLine> bom { get; set; } * [DataMember] * public string comments { get; set; } * ******************/ string fStr = "% Comp"; try { uint pctComp = uint.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "pctComp").Value); fStr = "Status"; ulong status = ulong.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskState").Value); fStr = "Reason"; ulong reason = ulong.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskReason").Value); fStr = "Priority"; task.Priority = int.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskPriority").Value); task.SetTaskStatus((CTask.eTaskStatus)status, (CTask.eTaskStatus)reason, (int)pctComp); taskData.state = (int)status; taskData.reason = (int)reason; taskData.PercentComplete = (int)pctComp; fStr = "Title must be filled"; string title = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskTitle").Value).Trim(); if (title.Length == 0) { throw new ArgumentNullException("bad title"); } taskData.Title = task.Description = title; fStr = "Task Id"; taskData.tid = task.Id = int.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskId").Value); fStr = "Parent Task Id"; string ptid = this.Request.Form.FirstOrDefault(kv => kv.Key == "parentTaskId").Value; task.ParentTaskId = ((ptid.Length > 0) ? int.Parse(ptid) : (int?)null); fStr = "Task Type"; task.Type = int.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskType").Value); fStr = "Person Id"; task.PersonId = int.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskPersonId").Value); if (!task.PersonId.HasValue || (task.PersonId <= 0)) { task.PersonId = null; } var oldTask = _context.Task.AsNoTracking().FirstOrDefaultAsync(t => (t.Id == task.Id) && (((int)t.Type & (int)eTaskType.AutoPersonID) != 0)).Result; if (oldTask != null) { if (task.PersonId != oldTask.PersonId) { task.Type &= ~(int)eTaskType.AutoPersonID; // Remove Auto Person state since user change person. } } fStr = "Committed Cost"; String ccostStr = this.Request.Form.FirstOrDefault(kv => kv.Key == "taskCommittedCost").Value; if (ccostStr.Trim().Length > 0) { task.CommittedCost = decimal.Parse(ccostStr); } else { task.CommittedCost = 0; } fStr = "Total Cost"; String tcostStr = this.Request.Form.FirstOrDefault(kv => kv.Key == "taskTotalCost").Value; if (tcostStr.Trim().Length > 0) { task.TotalCost = decimal.Parse(tcostStr); } else { task.TotalCost = 0; } IsTemplate = (task.Type & (int)CTask.eTaskType.Template) != 0; if (IsTemplate) { fStr = "Template Task"; // Make sure to initialize ABOVE and also get these HERE only for a Template Task. int dueType = Int32.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskCreateDue").Value); if (dueType != 0) { // Get Template Type int dueValue = 0; if ((dueType == (int)CTask.eTaskType.Hours_Before_Start) || (dueType == (int)CTask.eTaskType.Hours_After_Start) || (dueType == (int)CTask.eTaskType.Hours_Before_End) || (dueType == (int)CTask.eTaskType.Hours_After_End) || (dueType == (int)CTask.eTaskType.Days_Before_Start) || (dueType == (int)CTask.eTaskType.Days_After_Start) || (dueType == (int)CTask.eTaskType.Days_Before_End) || (dueType == (int)CTask.eTaskType.Days_After_End) || (dueType == (int)CTask.eTaskType.Weeks_Before_Start) || (dueType == (int)CTask.eTaskType.Weeks_After_Start) || (dueType == (int)CTask.eTaskType.Weeks_Before_End) || (dueType == (int)CTask.eTaskType.Weeks_After_End) || (dueType == (int)CTask.eTaskType.Months_Before_Start) || (dueType == (int)CTask.eTaskType.Months_After_Start) || (dueType == (int)CTask.eTaskType.Months_Before_End) || (dueType == (int)CTask.eTaskType.Months_After_End) || (dueType == (int)CTask.eTaskType.Day_Of_Week_SunMon) || (dueType == (int)CTask.eTaskType.Every_Num_Years)) { dueValue = Int32.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskCreateDueVal").Value); } else if (dueType == (int)CTask.eTaskType.Day_Of_Week_SunMon) { String dueStr = this.Request.Form.FirstOrDefault(kv => kv.Key == "taskCreateDueVal").Value; if (dueStr.Length > 0) { dueStr = dueStr.Trim().ToLower(); if (dueStr.IndexOf("su") == 0) { dueValue = 1; } else if ((dueStr.IndexOf("m") == 0)) { dueValue = 2; } else if ((dueStr.IndexOf("tu") == 0)) { dueValue = 3; } else if ((dueStr.IndexOf("w") == 0)) { dueValue = 4; } else if ((dueStr.IndexOf("th") == 0)) { dueValue = 5; } else if ((dueStr.IndexOf("f") == 0)) { dueValue = 6; } else if ((dueStr.IndexOf("sa") == 0)) { dueValue = 7; } else { return(this.Content("Fail: Week Day needs to start with M, Tu, W, Th, Fr, Sa or Su")); // Send back results } } } int eachType = Int32.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskCreateEach").Value); if (eachType == (int)CTask.eTaskType.Day_from_Due_till) { String TillDayStr = this.Request.Form.FirstOrDefault(kv => kv.Key == "TillDay").Value; if (TillDayStr.Trim().Length > 0) { bool TillFail = true; String[] numStr = TillDayStr.Split('/', '.', '-'); if (numStr.Count() == 2) { if (Int32.TryParse(numStr[0], out int TillMo) && Int32.TryParse(numStr[1], out int TillDay)) { try { task.EstimatedDoneDate = new DateTime(2020, TillMo, TillDay); } catch { } TillFail = !task.EstimatedDoneDate.HasValue; } if (TillFail) { return(this.Content("Fail: Day_from_Due_till needs to have a valid Month/Day with a / . or - separator")); // Send back results } } } } if ((eachType == (int)CTask.eTaskType.Due_Day) || (eachType == (int)CTask.eTaskType.Num_Start_Date)) { string mdStr = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskDueDate").Value).Trim(); if (mdStr.Length >= 10) { string dateOnly = mdStr.Substring(0, 10); task.DueDate = DateTime.ParseExact(dateOnly, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); } else { return(this.Content("Fail: A valid Due Date must be set with Every : Month n Day")); // Send back results } } task.SetTaskType((CTask.eTaskType)dueType, (CTask.eTaskType)eachType, dueValue); } fStr = "Role123"; taskData.Role1 = long.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskRole1").Value); taskData.Role2 = long.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskRole2").Value); taskData.Role3 = long.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskRole3").Value); } fStr = "Task Doc"; task.PlanLink = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskDoc").Value); fStr = "Detail Text"; taskData.Detail = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskDetail").Value); fStr = "Comments"; taskData.comments = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskComments").Value); fStr = "Pics"; string[] pics = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(this.Request.Form.FirstOrDefault(kv => kv.Key == "pics").Value); fStr = "Pic Titles"; string[] picTitles = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(this.Request.Form.FirstOrDefault(kv => kv.Key == "picTitles").Value); if (pics.Length == picTitles.Length) { for (int i = 0; i < pics.Length; ++i) { Pic pobj = new Pic(task.Id, i + 1, CCommon.UnencodeQuotes(picTitles[i]), pics[i]); taskData.pics.Add(pobj); } } else { return(this.Content("Fail: Pics=" + pics.Length + " DOES NOT MATCH Pic Titles=" + picTitles.Length)); // Send back results } fStr = "Costs /BOM"; var sBOM = this.Request.Form.FirstOrDefault(kv => kv.Key == "bom").Value; taskData.bom = Newtonsoft.Json.JsonConvert.DeserializeObject <List <BOMLine> >(sBOM); fStr = "Due/Est.Done Date"; string msDueStr = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskDueDate").Value).Trim(); DateTime dueDateTime = new DateTime(); if (msDueStr.Length > 0) { //dueDateTime = DateTime.ParseExact(msDueStr, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture); dueDateTime = DateTime.Parse(msDueStr, System.Globalization.CultureInfo.CurrentCulture); } taskData.FixedDueDate = bool.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "fixedDueDate").Value); if (taskData.FixedDueDate) { if (msDueStr.Length > 0) { task.DueDate = dueDateTime; } else { task.DueDate = null; } if (!IsTemplate) { task.EstimatedDoneDate = null; } } else { if (!IsTemplate) { if (msDueStr.Length > 0) { task.EstimatedDoneDate = dueDateTime; } else { task.EstimatedDoneDate = null; } task.DueDate = null; } } fStr = "Completed Date"; string msDoneStr = CCommon.UnencodeQuotes(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskDoneDate").Value).Trim(); if (msDoneStr.Length > 0) { int slashIdx = msDoneStr.IndexOf("/"); if ((slashIdx > 0) && (slashIdx <= 2)) { task.ActualDoneDate = DateTime.ParseExact(msDoneStr, "M/d/yyyy h:mm:ss tt", System.Globalization.CultureInfo.CurrentCulture); } else { long msSinceUXEpoc = long.Parse(msDoneStr); task.ActualDoneDate = DateTimeOffset.FromUnixTimeMilliseconds(msSinceUXEpoc).DateTime.ToLocalTime(); } } else { task.ActualDoneDate = null; } task.EstimatedManHours = 0; task.RequiredSkills = ""; if (IsTemplate) { // Remove exist non-done tasks so new ones can be created without task multiplicity Models.Task.RemoveActiveChildTasks(_context, task.Id); } fStr = "Save File Update"; taskData.Write(hostEnv); fStr = "DB Update"; _context.Attach(task).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); if (IsTemplate) { // Generate possibly new Tasks based on template add/changes AutoGen ag = new AutoGen(_context); ag.GenTasks(hostEnv, task.Id); } if (dueDateTime != DateTime.MinValue) { NotifyUserTaskDue(hostEnv, _config, _userManager, _context, 24); // Send out notications if needed. } } catch (Exception e) { return(this.Content("Fail: " + fStr + " e.msg=" + e.Message)); // Send back results } return(this.Content("Success:" + task.Id)); // Send back results } return(this.Content("Fail: Bad/Missing Request")); // Send back results }
/// <summary> /// Save control values in parameter stack /// </summary> /// <param name="stack">Parameter stack passed as ref</param> private bool SaveControlValues(ref Pic.Plugin.ParameterStack stack) { if (null == stack) return false; // load some parameters from majorations if (null != _profileLoader) { foreach (Parameter param in stack.ParameterList) { if (_profileLoader.HasParameter(param)) stack.SetDoubleParameter(param.Name, _profileLoader.GetParameterDValue(param.Name)); } } // load other parameters foreach (Control ctrl in Panel2.Controls) { if (ctrl.GetType() == typeof(NumericUpDown)) { NumericUpDown nud = ctrl as NumericUpDown; if (nud.Name.Equals("nudThickness")) { _thickness = Convert.ToDouble(nud.Value); if (stack.HasParameter("ep1")) stack.SetDoubleParameter("ep1", _thickness); if (stack.HasParameter("th1")) stack.SetDoubleParameter("th1", _thickness); } else foreach (Parameter param in stack.ParameterList) { if (nud.Name.Equals("nud" + param.Name)) { if (param.GetType() == typeof(ParameterDouble)) { ParameterDouble paramDouble = param as ParameterDouble; try { paramDouble.Value = Convert.ToDouble(nud.Value); } catch (Exception ex) { _log.Error(ex.ToString()); } } else if (param.GetType() == typeof(ParameterInt)) { ParameterInt paramInt = param as ParameterInt; try { paramInt.Value = Convert.ToInt32(nud.Value); } catch (Exception /*ex*/) { } } } } } else if (ctrl.GetType() == typeof(CheckBox)) { CheckBox chkb = ctrl as CheckBox; foreach (Parameter param in stack.ParameterList) { ParameterBool paramBool = param as ParameterBool; if (null != paramBool && chkb.Name.Equals("chkb" + param.Name)) paramBool.Value = chkb.Checked; } } else if (ctrl.GetType() == typeof(ComboBox)) { ComboBox cb = ctrl as ComboBox; foreach (Parameter param in stack.ParameterList) { ParameterMulti paramMulti = param as ParameterMulti; if (null != paramMulti && cb.Name.Equals("cb" + param.Name)) paramMulti.Value = cb.SelectedIndex; } } } return true; }
void Start() { KeepData saveData = SaveData._Sav.GetSaveData(); Itemsave s = GameObject.FindObjectOfType <Itemsave> (); Debug.Log(saveData._Slidery); for (int q = 0; q < saveData._HaveItemOn.Count; q++) { GameObject dj = GameObject.Instantiate(btn); dj.transform.SetParent(_DJL); dj.GetComponent <Button> ().image.sprite = s._item [saveData._HaveItemOn[q]]; dj.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(45 + 85 * q, 44); _dj.Add(dj); } for (int t = 0; t < saveData._IsUclockItem.Count; t++) { if (saveData._IsUclockItem[t] == true) { _dj [t].GetComponent <Button> ().image.sprite = null; _dj [t].GetComponent <Button> ().image.color = new Color(0, 0, 0, 0); //saveData._HaveItemOn [t] = 10; _dj[t].transform.SetParent(_DJ); } } for (int q = 0; q < saveData._HaveItemOn.Count; q++) { if (saveData._HaveItemOn [q] < 10) { _dj [q].GetComponent <Button> ().image.sprite = s._item [saveData._HaveItemOn [q]]; _dj [q].GetComponent <Button> ().image.color = new Color(1, 1, 1, 1); } } _itemPic = new List <Pic> (saveData._HaveItemId.Count); for (int i = 0; i < saveData._HaveItemId.Count; i++) { Pic item = GameObject.Instantiate(_itemPrefab); item._Id = saveData._HaveItemId [i]; //更新技能点 Gx(item); item.GetComponentInChildren <Text> ().text = saveData._HaveItemName [saveData._HaveItemId [i]]; item.Shuoming.text = "" + item._shuoming [saveData._HaveItemId [i]]; item.pic.sprite = item._pic [saveData._HaveItemId[i]]; item.transform.SetParent(_canvas); x = -196 * (Mathf.Pow(-1, (i % colunm_count))); saveData._Slidery = 118 - 195 * (i / colunm_count); SaveData._Sav.SaveGameData(); item.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(x, saveData._Slidery); //已解锁道具个数大于可装备道具个数 item._Use.onClick.AddListener(delegate() { //道具装备个数小于道具解锁个数 if (saveData._Djnum < saveData._IsUclockItemNum) { if (item._Id < 10) { Click(item._Id, item); saveData._Djnum++; SaveData._Sav.SaveGameData(); } } }); // 把道具图片加入列表 _itemPic.Add(item); for (int t = 0; t < item._Skill.Count; t++) { SkillJs(t, item, item._Id); } } for (int k = 0; k < _dj.Count; k++) { int index = k; if (saveData._IsUclockItem [k] == true) { _dj [k].GetComponent <Button> ().onClick.AddListener(delegate() { if (saveData._Djnum > 0) { DropItem(index); } }); } } for (int k = 0; k < saveData._HaveItemOn.Count; k++) { int index = k; if (saveData._IsUclockItem [k] == true) { _dj[k].GetComponent <Button>().onClick.AddListener(delegate() { if (saveData._Djnum > 0) { DropItem(index); } }); } // 装备栏为空处理 if (saveData._HaveItemOn [k] == -1 && saveData._IsUclockItem[k] == true) { _dj[k].GetComponent <Button>().image.sprite = null; } // 有装备处理 for (int j = 0; j < 10; j++) { if (saveData._HaveItemOn [k] == j) { _dj[k].GetComponent <Button>().image.sprite = s._item [j]; } } } }
/// <summary> /// 卸下该栏装备 /// </summary> /// <param name="i">The index.</param> void DropItem(int i) { // 卸下空道具,退出 if (_dj [i].GetComponent <Button>().image.sprite == null) { return; } KeepData saveData = SaveData._Sav.GetSaveData(); // 卸下道具,图片为空 //if (saveData._HaveItemOn [i] != 10 && saveData._IsUclockItem [i] == true) { saveData._HaveItemId.Add(saveData._HaveItemOn [i]); saveData._ItemId.Remove(saveData._HaveItemOn [i]); saveData._HaveItemOn.Remove(i); SaveData._Sav.SaveGameData(); _dj [i].GetComponent <Button> ().image.sprite = null; _dj [i].SetActive(false); //Destroy (_dj [i]); saveData._Djnum--; SaveData._Sav.SaveGameData(); //} // 更新道具栏 int z = saveData._HaveItemId.Count - 1; Pic item = GameObject.Instantiate(_itemPrefab); item._Id = saveData._HaveItemId [z]; //更新技能点 Gx(item); item.GetComponentInChildren <Text> ().text = saveData._HaveItemName [saveData._HaveItemId [z]]; item.Shuoming.text = "" + item._shuoming [saveData._HaveItemId [i]]; item.pic.sprite = item._pic [saveData._HaveItemId[i]]; item.transform.SetParent(_canvas); x = -196 * (Mathf.Pow(-1, (z % colunm_count))); saveData._Slidery = 118 - 195 * (z / colunm_count); SaveData._Sav.SaveGameData(); item.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(x, saveData._Slidery); item._Use.onClick.AddListener(delegate() { //道具装备个数小于道具解锁个数 if (saveData._Djnum < saveData._IsUclockItemNum) { if (item._Id < 10) { Click2(item._Id, item); saveData._Djnum++; SaveData._Sav.SaveGameData(); } } }); // 把道具图片加入列表 _itemPic.Add(item); for (int t = 0; t < item._Skill.Count; t++) { SkillJs(t, item, item._Id); } GameObject dj = GameObject.Instantiate(btn); dj.transform.SetParent(_DJ); dj.GetComponent <Button> ().image.sprite = null; dj.GetComponent <Button> ().image.color = new Color(0, 0, 0, 0); dj.transform.GetComponent <RectTransform> ().anchoredPosition = new Vector2(75 + 150 * saveData._Djnum, -50); _dj.Add(dj); _dj.Reverse(); }
protected override void DrawSpecific(Pic.Factory2D.PicGraphics graphics) { // get text size double textWidth = 0.0, textHeight = 0.0; graphics.GetTextSize(Text, PicGraphics.TextType.FT_COTATION, out textWidth, out textHeight); // offset points Vector2D pt2, pt3; GetOffsetPoints(out pt2, out pt3); // find out if is middle quotation bool middle = IsMiddleQuotation(pt2, pt3, textWidth, textHeight); if (!middle && !_globalCotationProperties._showDeportedCotations) return; // draw extremity segments if (_shortLines || PicGlobalCotationProperties.ShowShortCotationLines) { double arrowLength = graphics.DX_inv(_globalCotationProperties._arrowLength); Vector2D vecI = _pt0-pt2; vecI.Normalize(); vecI *= arrowLength; graphics.DrawLine(LineType, pt2 + vecI, pt2 - vecI); graphics.DrawLine(LineType, pt3 + vecI, pt3 - vecI); } else { graphics.DrawLine(LineType, _pt0, pt2); graphics.DrawLine(LineType, _pt1, pt3); } // draw arrow line Vector2D ptText; DrawArrowLine(graphics, pt2, pt3, textWidth, textHeight, out ptText, out middle); // draw text graphics.DrawText(Text, PicGraphics.TextType.FT_COTATION, ptText, PicGraphics.HAlignment.HA_CENTER, PicGraphics.VAlignment.VA_MIDDLE, TextDirection); // draw arrows heads DrawArrowHead(graphics, pt2, (middle ? 1.0 : -1.0) * (pt2 - pt3)); DrawArrowHead(graphics, pt3, (middle ? 1.0 : -1.0) * (pt3 - pt2)); }
/// <summary> /// Plugin validated handler /// </summary> void _generatorCtrl_PluginValidated(object sender, Pic.Plugin.GeneratorCtrl.GeneratorCtrlEventArgs e) { this.DialogResult = DialogResult.OK; Close(); }
public static long CreatePic(Pic pic) { return(DatabaseProvider.GetInstance().CreatePic(pic)); }
public Form3() { InitializeComponent(); pic = new Pic(); }
private void Pic_MouseEnter(object sender, EventArgs e) { Pic.Focus(); }
public void Dispose() { gic.Dispose(); Pic.Dispose(); }
public override void HandleRequest(HttpListenerContext context) { NameValueCollection query; using (var rdr = new StreamReader(context.Request.InputStream)) query = HttpUtility.ParseQueryString(rdr.ReadToEnd()); if (query.AllKeys.Length == 0) { string queryString = string.Empty; string currUrl = context.Request.RawUrl; int iqs = currUrl.IndexOf('?'); if (iqs >= 0) { query = HttpUtility.ParseQueryString((iqs < currUrl.Length - 1) ? currUrl.Substring(iqs + 1) : String.Empty); } } Pics pics = new Pics(); pics.Offset = query["offset"] != null?Convert.ToInt32(query["offset"]) : 0; pics.Pictures = new List <Pic>(); int count = 0; using (var db = new Database(Program.Settings.GetValue("conn"))) { var cmd = db.CreateQuery(); cmd.CommandText = "SELECT COUNT(id) FROM sprites"; count = ((int)(long)cmd.ExecuteScalar()); cmd = db.CreateQuery(); cmd.CommandText = "SELECT * FROM sprites"; using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { int id = rdr.GetInt32("id"); string guid = rdr.GetString("guid"); string name = rdr.GetString("name"); int dataType = rdr.GetInt32("dataType"); string[] tags = rdr.GetString("tags").Split(','); if (query["tags"] != null) { List <string> tagList = new List <string>(tags); bool succeded = true; foreach (var i in query["tags"].Trim().Split(',')) { if (!tagList.Contains(i.Trim())) { succeded = false; } } if (!succeded) { continue; } } if (query["dataType"] != null && Convert.ToInt32(query["dataType"]) != dataType) { continue; } if (query["guid"] != null) { //if (query["guid"] == "Admin") // continue; if (query["guid"] != guid) { continue; } } var pic = new Pic { Id = id, DataType = dataType, PicName = name, Tags = string.Join(",", tags) }; if (query["myGUID"] == guid) { pic.Mine = ""; } pics.Pictures.Add(pic); } } } int num = 0; if (query["offset"] != null) { pics.Pictures.RemoveRange(0, (Convert.ToInt32(query["offset"]) > count) ? count : Convert.ToInt32(query["offset"])); } if (query["num"] != null) { if ((num = Convert.ToInt32(query["num"])) < count) { pics.Pictures.RemoveRange(num, count - num); } } var ms = new MemoryStream(); var serializer = new XmlSerializer(pics.GetType(), new XmlRootAttribute(pics.GetType().Name) { Namespace = "" }); var xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Encoding = Encoding.UTF8; xws.Indent = true; XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws); serializer.Serialize(xtw, pics, pics.Namespaces); }
public void GetParameterValue(ref Pic.Plugin.Parameter param) { if (null == _majorationList) _majorationList = LoadMajorationList(); ParameterDouble parameterDouble = param as ParameterDouble; if (null != parameterDouble) parameterDouble.Value = _majorationList[param.Name]; }
public ResultOrderList GetBriefingList(string JSon) { try { string UserID = string.Empty; string CompID = string.Empty; string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1 string getType = string.Empty; //方向 string rows = string.Empty; string sortType = string.Empty; string sort = string.Empty; string datetype = string.Empty; string ordertype = string.Empty; #region//JSon取值 JsonData JInfo = JsonMapper.ToObject(JSon); if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompID"].ToString() != "" && JInfo["CriticalOrderID"].ToString() != "" && JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" && JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "" && JInfo["DateType"].ToString() != "" && JInfo["OrderType"].ToString() != "") { UserID = JInfo["UserID"].ToString(); CompID = JInfo["CompID"].ToString(); criticalOrderID = JInfo["CriticalOrderID"].ToString(); getType = JInfo["GetType"].ToString(); rows = JInfo["Rows"].ToString(); sortType = JInfo["SortType"].ToString(); sort = JInfo["Sort"].ToString(); datetype = JInfo["DateType"].ToString(); ordertype = JInfo["OrderType"].ToString(); } else { return(new ResultOrderList() { Result = "F", Description = "参数异常" }); } #endregion //判断登录信息是否异常 Hi.Model.SYS_Users one = new Hi.Model.SYS_Users(); if (!new Common().IsLegitUser(int.Parse(UserID), out one, int.Parse(CompID == "" ? "0" : CompID))) { return new ResultOrderList() { Result = "F", Description = "登录信息异常" } } ; //判断经销商信息是否异常 Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Convert.ToInt32(CompID)); if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0) { return new ResultOrderList() { Result = "F", Description = "核心企业异常" } } ; DateTime date = DateTime.Now; DateTime date_start = new DateTime(); DateTime date_end = date.AddDays(1); //string strdate_start = string.Empty; // string strdate_end = date_end.ToString("yyyy-MM-dd"); string strwhere = ""; switch (datetype) { case "0": date_start = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); //strdate_start = date_start.ToString("yyyy-MM-dd"); break; case "1": DateTime startWeek = date.AddDays(1 - Convert.ToInt32(date.DayOfWeek.ToString("d"))); date_start = new DateTime(startWeek.Year, startWeek.Month, startWeek.Day, 0, 0, 0); //strdate_start = date_start.ToString("yyyy-MM-dd"); break; case "2": date_start = new DateTime(date.Year, date.Month, 1); //strdate_start = date_start.ToString("yyyy-MM-dd"); break; default: return(new ResultOrderList() { Result = "F", Description = "时间段类型异常" }); break; } switch (ordertype) { case "0": strwhere = " and isnull(dr,0)=0 and Otype!=9 and CompID=" + comp.ID + " and OState in (2,3,4,5,7) and CreateDate>='" + date_start + "' and CreateDate<='" + date_end + "'"; break; case "1": strwhere = " and isnull(dr,0)=0 and CompID=" + comp.ID + " and CreateDate>='" + date_start + "' and CreateDate<='" + date_end + "' and ReturnState =3"; break; case "2": string sql = "SELECT distinct orderID FROM [dbo].[CompCollection_view] where OrderID not in(select ID from Dis_Order where ISNULL(dr,0)=0 and (Otype=9 or OState not in(2,3,4,5,7)) and CompID=" + comp.ID + ") and status!=3 and CompID=" + comp.ID + " and Date>='" + date_start + "' and Date<'" + date_end + "' AND vedf9=1 "; DataTable dt_pay = SqlHelper.Query(SqlHelper.LocalSqlServer, sql).Tables[0]; string where = ""; for (int i = 0; i < dt_pay.Rows.Count; i++) { if (ClsSystem.gnvl(dt_pay.Rows[i]["orderID"], "") != "") { where += ","; where += ClsSystem.gnvl(dt_pay.Rows[i]["orderID"], ""); } } where = where.Substring(1, where.Length - 1); strwhere = " and id in (" + where + ")"; break; default: return(new ResultOrderList() { Result = "F", Description = "订单类型异常" }); break; } if (sortType == "1") //价格排序 { sortType = "CreateDate"; } else if (sortType == "2") //价格排序 { sortType = "TotalAmount"; } else { sortType = "ID"; } string strsql = new Common().PageSqlString(criticalOrderID, "ID", "DIS_Order", sortType, sort, strwhere, getType, rows); if (strsql == "") { return new ResultOrderList() { Result = "F", Description = "基础数据异常" } } ; #region 赋值 List <Order> OrderList = new List <Order>(); DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql); if (ds.Tables.Count == 0) { return new ResultOrderList() { Result = "T", Description = "没有更多数据" } } ; DataTable orderList = ds.Tables[0]; if (orderList != null) { if (orderList.Rows.Count == 0) { return new ResultOrderList() { Result = "T", Description = "没有更多数据" } } ; foreach (DataRow row in orderList.Rows) { Order order = new Order(); Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(int.Parse(row["ID"].ToString())); if (orderModel == null || orderModel.dr == 1) { return new ResultOrderList() { Result = "F", Description = "订单异常" } } ; order.OrderID = orderModel.ID.ToString(); order.CompID = orderModel.CompID.ToString(); order.CompName = comp.CompName; order.State = Common.GetCompOrderType(orderModel.OState, orderModel.PayState, orderModel.Otype, orderModel.ReturnState); string IsEnSend, IsEnPay, IsEnReceive, IsEnReturn, IsEnAudit; Common.GetEspecialType(orderModel.OState.ToString(), orderModel.PayState.ToString(), orderModel.Otype.ToString(), orderModel.ReturnState.ToString(), out IsEnSend, out IsEnPay, out IsEnAudit, out IsEnReceive, out IsEnReturn); order.IsEnSend = IsEnSend; order.IsEnPay = IsEnPay; order.IsEnAudit = IsEnAudit; order.IsEnReceive = IsEnReceive; order.IsEnReturn = IsEnReturn; order.Otype = orderModel.Otype.ToString(); order.AddType = orderModel.AddType.ToString(); order.OState = orderModel.OState.ToString(); order.PayState = orderModel.PayState.ToString(); order.ReturnState = orderModel.ReturnState.ToString(); order.DisID = orderModel.DisID.ToString(); Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(orderModel.DisID); if (dis == null || dis.AuditState == 0 || dis.dr == 1) { return new ResultOrderList() { Result = "F", Description = "经销信息商异常" } } ; order.DisName = dis.DisName; order.DisUserID = orderModel.DisUserID.ToString(); Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(order.DisUserID)); //if (user == null || user.IsEnabled == 0 || user.dr == 1) // return new ResultOrderList() { Result = "F", Description = "经销商用户信息异常" }; //order.DisUserName = orderModel.DisUserName; if (user != null && user.IsEnabled == 1 && user.dr == 0) { order.DisUserName = user.TrueName; } else { order.DisUserName = ""; } order.AddrID = orderModel.AddrID.ToString(); order.ReceiptNo = orderModel.ReceiptNo; if (ClsSystem.gnvl(orderModel.ArriveDate, "") != "0001/1/1 0:00:00" && ClsSystem.gnvl(orderModel.ArriveDate, "") != "") { order.ArriveDate = orderModel.ArriveDate.ToString("yyyy-MM-dd"); } if (!string.IsNullOrEmpty(orderModel.AddrID.ToString())) { Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(orderModel.AddrID); if (addr != null) { order.Zip = addr.Zip; } } order.Address = orderModel.Address; order.Contact = orderModel.Principal; order.Phone = orderModel.Phone; order.TotalAmount = orderModel.AuditAmount.ToString("0.00"); order.AuditTotalAmount = orderModel.AuditAmount.ToString("0.00"); order.PayedAmount = orderModel.PayedAmount.ToString("0.00"); order.CreateUserID = orderModel.CreateUserID.ToString(); order.CreateDate = orderModel.CreateDate.ToString("yyyy-MM-dd HH:mm"); order.ReturnMoneyDate = orderModel.ReturnMoneyDate.ToString(); order.ReturnMoneyUser = orderModel.ReturnMoneyUser; order.ReturnMoneyUserId = orderModel.ReturnMoneyUserId.ToString(); List <Hi.Model.DIS_OrderOut> outList = new Hi.BLL.DIS_OrderOut().GetList("", " OrderID='" + orderModel.ID + "' and CompID='" + orderModel.CompID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (outList.Count != 0) { Hi.Model.DIS_OrderOut orderOut = new Hi.Model.DIS_OrderOut(); foreach (Hi.Model.DIS_OrderOut Out in outList) { orderOut = Out; } order.SendID = orderOut.ID.ToString(); order.SendDate = orderOut.SendDate.ToString(); ////order.Express = orderOut.Express; ////order.ExpressNo = orderOut.ExpressNo; ////order.ExpressPerson = orderOut.ExpressPerson; ////order.ExpressTel = orderOut.ExpressTel; ////order.ExpressBao = orderOut.ExpressBao; ////order.PostFee = orderOut.PostFee.ToString("0.00"); order.ActionUser = orderOut.ActionUser; List <Hi.Model.DIS_Logistics> exlist = Common.GetExpress(orderOut.ID.ToString()); if (exlist != null) { order.SendRemark = exlist[0].Context; } order.IsAudit = orderOut.IsAudit.ToString(); order.AuditUserID = orderOut.AuditUserID.ToString(); order.AuditDate = orderOut.AuditDate.ToString(); order.AuditRemark = orderOut.AuditRemark == null ? "" : orderOut.AuditRemark.ToString(); order.SignDate = orderOut.SignDate.ToString(); order.IsSign = orderOut.IsSign.ToString(); order.SignUserId = orderOut.SignUserId.ToString(); order.SignUser = orderOut.SignUser; order.SignRemark = orderOut.SignRemark; } //todo:不知道的排序 //order.SortIndex = orderModel.SortIndex.ToString(); order.IsDel = orderModel.dr.ToString(); //明细 List <OrderDetail> orderDetail = new List <OrderDetail>(); List <Hi.Model.DIS_OrderDetail> detailList = new Hi.BLL.DIS_OrderDetail().GetList("", " OrderID='" + orderModel.ID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", ""); if (detailList == null) //|| detailList.Count==0 { return new ResultOrderList() { Result = "F", Description = "订单明细异常" } } ; List <Hi.Model.BD_GoodsAttrs> list_attrs = null; foreach (Hi.Model.DIS_OrderDetail detail in detailList) { string SKUName = string.Empty; OrderDetail ordetail = new OrderDetail(); ordetail.SKUID = detail.GoodsinfoID.ToString(); //通过GoodsInfoID找到GoodsID Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID); if (goodsInfo == null) { //if (goodsInfo == null || goodsInfo.IsEnabled == false || goodsInfo.dr == 1) return new ResultOrderList() { Result = "F", Description = "SKU信息异常" } } ; ordetail.ProductID = goodsInfo.GoodsID.ToString(); //通过GoodsID找到GoodsName Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID); if (goods == null) { //if (goods == null || goods.IsEnabled == 0 | goods.dr == 1) return new ResultOrderList() { Result = "F", Description = "商品异常" } } ; ordetail.ProductName = goods.GoodsName; SKUName += goods.GoodsName; list_attrs = new Hi.BLL.BD_GoodsAttrs().GetList("AttrsName", "GoodsID = " + goodsInfo.GoodsID + " and CompID = " + comp.ID + " and ISNULL(dr,0) = 0", ""); if (list_attrs != null && list_attrs.Count != 0) { foreach (Hi.Model.BD_GoodsAttrs attr in list_attrs) { SKUName += attr.AttrsName; } } ordetail.SKUName = SKUName; //todo:描述是什么 ordetail.ValueInfo = goodsInfo.ValueInfo; ordetail.SalePrice = detail.Price.ToString("0.00"); ordetail.TinkerPrice = detail.AuditAmount.ToString("0.00"); ordetail.Num = detail.GoodsNum.ToString("0.00"); ordetail.Remark = detail.Remark; //ordetail.IsPro = .Trim() == "0" || detail.vdef1.Trim() == "" ? "0" : "1"; //是否是促销商品 //是否是促销商品 ordetail.IsPro = ClsSystem.gnvl(detail.vdef1, "").Trim() == "0" || ClsSystem.gnvl(detail.vdef1, "").Trim() == "" ? "0" : "1"; if (ordetail.IsPro != "0") { ordetail.ProNum = detail.vdef5; if (detail.vdef1 != "" && detail.vdef1.Length > 0) { Hi.Model.BD_Promotion pro = new Hi.BLL.BD_Promotion().GetModel(Convert.ToInt32(detail.vdef1)); if (pro != null) { List <Hi.Model.BD_PromotionDetail> dList = new Hi.BLL.BD_PromotionDetail().GetList( "", " ProID=" + pro.ID + " and GoodInfoID ='" + ordetail.SKUID + "' and dr=0", ""); string info = string.Empty; if (dList != null && dList.Count > 0) { if (pro.Type == 0 && pro.ProType == 1) { info = "赠品"; } else if (pro.Type == 0 && pro.ProType == 2) { info = "商品优惠价" + dList[0].GoodsPrice.ToString("0.00"); } else if (pro.Type == 1 && pro.ProType == 3) { info = "商品数量满" + pro.Discount.ToString("0.00") + "赠" + dList[0].GoodsPrice.ToString("0.00") + dList[0].GoodsUnit; } else if (pro.Type == 1 && pro.ProType == 4) { info = "商品打折" + pro.Discount.ToString("0.00") + "%"; } } ordetail.proInfo = new PromotionInfo() { ProID = detail.vdef1, ProTitle = pro.ProTitle, ProInfos = info, Type = pro.Type.ToString(), ProTpye = pro.ProType.ToString(), Discount = pro.Discount.ToString("0.00"), ProStartTime = pro.ProStartTime.ToString("yy-MM-dd"), ProEndTime = pro.ProEndTime.ToString("yy-MM-dd") }; } } } List <Pic> Pic = new List <Pic>(); if (goods.Pic != "" && goods.Pic != "X") { Pic pic = new Pic(); pic.ProductID = goodsInfo.GoodsID.ToString(); pic.IsDeafult = "1"; pic.PicUrl = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" + goods.Pic; Pic.Add(pic); } ordetail.ProductPicUrlList = Pic; orderDetail.Add(ordetail); } order.OrderDetailList = orderDetail; OrderList.Add(order); } } else { return(new ResultOrderList() { Result = "F", Description = "没有更多数据" }); } #endregion return(new ResultOrderList() { Result = "T", Description = "获取成功", OrderList = OrderList }); } catch (Exception ex) { Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetBriefingList:" + JSon); return(new ResultOrderList() { Result = "F", Description = "参数异常" }); } }
// recursive insertion mathod public TreeNode InsertNodeAndParents(Pic.DAL.SQLite.TreeNode tn, Pic.DAL.SQLite.PPDataContext db) { // failed ! if (null == tn) return null; TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_TREENODE, tn.ParentNodeID.Value)); if (null == parentNode) parentNode = InsertNodeAndParents(Pic.DAL.SQLite.TreeNode.GetById(db, tn.ParentNodeID.Value), db); Pic.DAL.SQLite.TreeBuilder treeBuilder = new Pic.DAL.SQLite.TreeBuilder(); // remove _DUMMY_ tree node parentNode.Nodes.Clear(); treeBuilder.PopulateChildren(this, parentNode, tn.ParentNodeID.Value); return FindNode(null, new NodeTag(NodeTag.NodeType.NT_TREENODE, tn.ID)); }
protected void DrawArrowHead(Pic.Factory2D.PicGraphics graphics, Vector2D pt, double angle) { DrawArrowHead(graphics, pt, new Vector2D(Math.Cos(angle * Math.PI / 180.0), Math.Sin(angle * Math.PI / 180.0))); }
protected int GetSelectedImageIndex(Pic.DAL.SQLite.TreeNode tn) { if (tn.IsDocument) return GetImageIndex(tn); else { if (string.Equals(tn.Name, "Root", StringComparison.CurrentCultureIgnoreCase)) return 16; // Root else return 1; } }
protected void DrawArrowHead(Pic.Factory2D.PicGraphics graphics, Vector2D pt, Vector2D director) { director.Normalize(); Vector2D normal = new Vector2D(-director.Y, director.X); double angleRad = _globalCotationProperties._arrowHeadAngle * Math.PI / 180.0; double arrowLength = graphics.DX_inv(_globalCotationProperties._arrowLength); // lower part of arrow head graphics.DrawLine(LineType , pt - arrowLength * (Math.Cos(angleRad) * director + Math.Sin(angleRad) * normal) , pt); // upper part of arrow head graphics.DrawLine(LineType , pt - arrowLength * (Math.Cos(angleRad) * director - Math.Sin(angleRad) * normal) , pt); }
/// <summary> /// /// </summary> /// <param name="Filename"></param> /// <param name="latDeg"></param> /// <param name="latMin"></param> /// <param name="latSec"></param> /// <param name="lonDeg"></param> /// <param name="lonMin"></param> /// <param name="lonSec"></param> private static void WriteLongLat(string Filename, byte latDeg, byte latMin, double latSec, byte lonDeg, byte lonMin, double lonSec) { const int length = 25; Image Pic; byte secHelper; byte secRemains; PropertyItem[] PropertyItems; string FilenameTemp; System.Drawing.Imaging.Encoder Enc = System.Drawing.Imaging.Encoder.Transformation; EncoderParameters EncParms = new EncoderParameters(1); EncoderParameter EncParm; ImageCodecInfo CodecInfo = GetEncoderInfo("image/jpeg"); // load the image to change Pic = Image.FromFile(Filename); PropertyItems = Pic.PropertyItems; int oldArrLength = PropertyItems.Length; PropertyItem[] newProperties = new PropertyItem[oldArrLength]; Pic.PropertyItems.CopyTo(newProperties, 0); newProperties[0].Id = 0x0002; newProperties[0].Type = 5;//5-R 4-L 3-S newProperties[0].Len = length; newProperties[0].Value = new byte[length]; try { for (int i = 0; i < length; i++) { newProperties[0].Value[i] = 0; } } catch { } //PropertyItems[0].Value = Pic.GetPropertyItem(4).Value; // bDescription; newProperties[0].Value[0] = latDeg; newProperties[0].Value[8] = (byte)latMin; secHelper = (byte)(latSec / 2.56); secRemains = (byte)((latSec - (secHelper * 2.56)) * 100); newProperties[0].Value[16] = secRemains; // add to the sum bellow x_x_*17_+16 newProperties[0].Value[17] = secHelper; // multiply by 2.56 newProperties[0].Value[20] = 100; Pic.SetPropertyItem(newProperties[0]); newProperties[1].Id = 0x0004; newProperties[1].Type = 5; //5-R 4-L 3-S newProperties[1].Len = length; newProperties[1].Value = new byte[length]; try { for (int i = 0; i < length; i++) { newProperties[1].Value[i] = 0; } } catch (Exception e) { Console.WriteLine("Error {0}", e.ToString()); } newProperties[1].Value[0] = lonDeg; newProperties[1].Value[8] = lonMin; secHelper = (byte)(lonSec / 2.56); secRemains = (byte)((lonSec - (secHelper * 2.56)) * 100); newProperties[1].Value[16] = secRemains; // add to the sum bellow x_x_*17_+16 newProperties[1].Value[17] = secHelper; // multiply by 2.56 newProperties[1].Value[20] = 100; // multiply by 2.56 //PropertyItem current = Pic.GetPropertyItem(2); Pic.SetPropertyItem(newProperties[1]); //GPS Version newProperties[0].Id = 0x0000; newProperties[0].Type = 1; newProperties[0].Len = 4; newProperties[0].Value[0] = 2; newProperties[0].Value[1] = 2; newProperties[0].Value[2] = 0; newProperties[0].Value[3] = 0; Pic.SetPropertyItem(newProperties[0]); //GPS Lat REF newProperties[0].Id = 0x0001; newProperties[0].Type = 2; newProperties[0].Len = 2; newProperties[0].Value[0] = 78; newProperties[0].Value[1] = 0; Pic.SetPropertyItem(newProperties[0]); //GPS Lon REF newProperties[0].Id = 0x0003; newProperties[0].Type = 2; //5-R 4-L 3-S newProperties[0].Len = 2; newProperties[0].Value[0] = 69; newProperties[0].Value[1] = 0; Pic.SetPropertyItem(newProperties[0]); // we cannot store in the same image, so use a temporary image instead FilenameTemp = Filename + ".temp"; // for lossless rewriting must rotate the image by 90 degrees! EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate90); EncParms.Param[0] = EncParm; // now write the rotated image with new description Pic.Save(FilenameTemp, CodecInfo, EncParms); // for computers with low memory and large pictures: release memory now Pic.Dispose(); Pic = null; GC.Collect(); // delete the original file, will be replaced later System.IO. File.Delete(Filename); // now must rotate back the written picture Pic = Image.FromFile(FilenameTemp); EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate270); EncParms.Param[0] = EncParm; Pic.Save(Filename, CodecInfo, EncParms); // release memory now Pic.Dispose(); Pic = null; GC.Collect(); // delete the temporary picture System.IO. File.Delete(FilenameTemp); }
public async Task <IHttpActionResult> PostPicture() { try { var encoded = await Request.Content.ReadAsStringAsync(); var bytes = Convert.FromBase64String(encoded); var json = Encoding.ASCII.GetString(bytes); var final = JsonConvert.DeserializeObject <IDictionary <string, object> >(json); //Gather attributes string uid = (string)final["uid"]; string mime = (string)final["mime"]; //Sanitize first, will save as uri encoded = encoded.Replace("/", ""); encoded = encoded.Replace("+", ""); encoded = encoded.Replace("=", ""); //Generate PID //p(encodedFirstTen)(uid skip3 then Ten)(Random 2 digit numb)(encodedreversedFive); string picid = (string)"p" + encoded.Substring(0, 10) + uid.Substring(3, 10) + new Random().Next(10, 99) + encoded.Substring(50, 5); Debug.WriteLine("\nCreated Pic:\n" + picid); //Get b64 string pic64 = (string)final["data"]; //Sav Picture [returns path] string path = PicManager.SavePicture(pic64, uid, picid, mime); //Create pics object Pic pic = new Pic(); //Assign Attributes //Dates pic.CreationDate = DateTime.Now; pic.ModifiedDate = DateTime.Now; //Check dates Debug.WriteLine("DATECHECK => " + pic.CreationDay + " " + pic.CreationMonth + " "); //Mandatory! pic.Uid = uid; pic.Pid = picid; pic.Location = path; pic.Name = (string)final["name"]; //Everything else is optional, you can serialize it to the database now! //Check for Location if (final.ContainsKey("Lon")) { pic.Lon = (string)final["Lon"]; pic.Lat = (string)final["Lat"]; } await session.Add(pic); //Return ok return(new OkResult(Request)); } catch (Exception e) { //Return bad Debug.WriteLine(e.Message); return(new BadRequestErrorMessageResult(e.Message, this)); } }
private void attach_Pics(Pic entity) { this.SendPropertyChanging(); entity.Item = this; }
public override void HandleRequest(HttpListenerContext context) { NameValueCollection query; using (var rdr = new StreamReader(context.Request.InputStream)) query = HttpUtility.ParseQueryString(rdr.ReadToEnd()); if (query.AllKeys.Length == 0) { string queryString = string.Empty; string currUrl = context.Request.RawUrl; int iqs = currUrl.IndexOf('?'); if (iqs >= 0) { query = HttpUtility.ParseQueryString((iqs < currUrl.Length - 1) ? currUrl.Substring(iqs + 1) : String.Empty); } } Pics pics = new Pics(); pics.Offset = query["offset"] != null ? Convert.ToInt32(query["offset"]) : 0; pics.Pictures = new List<Pic>(); int count = 0; using(var db = new Database(Program.Settings.GetValue("conn"))) { var cmd = db.CreateQuery(); cmd.CommandText = "SELECT COUNT(id) FROM sprites"; count = ((int) (long) cmd.ExecuteScalar()); cmd = db.CreateQuery(); cmd.CommandText = "SELECT * FROM sprites"; using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { int id = rdr.GetInt32("id"); string guid = rdr.GetString("guid"); string name = rdr.GetString("name"); int dataType = rdr.GetInt32("dataType"); string[] tags = rdr.GetString("tags").Split(','); if (query["tags"] != null) { List<string> tagList = new List<string>(tags); bool succeded = true; foreach (var i in query["tags"].Trim().Split(',')) { if (!tagList.Contains(i.Trim())) succeded = false; } if (!succeded) continue; } if (query["dataType"] != null && Convert.ToInt32(query["dataType"]) != dataType) continue; if (query["guid"] != null) { //if (query["guid"] == "Admin") // continue; if (query["guid"] != guid) continue; } var pic = new Pic { Id = id, DataType = dataType, PicName = name, Tags = string.Join(",", tags) }; if (query["myGUID"] == guid) { pic.Mine = ""; } pics.Pictures.Add(pic); } } } int num = 0; if (query["offset"] != null) pics.Pictures.RemoveRange(0, (Convert.ToInt32(query["offset"]) > count) ? count : Convert.ToInt32(query["offset"])); if (query["num"] != null) if ((num = Convert.ToInt32(query["num"])) < count) pics.Pictures.RemoveRange(num, count - num); var ms = new MemoryStream(); var serializer = new XmlSerializer(pics.GetType(), new XmlRootAttribute(pics.GetType().Name) { Namespace = "" }); var xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Encoding = Encoding.UTF8; xws.Indent = true; XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws); serializer.Serialize(xtw, pics, pics.Namespaces); }
partial void InsertPic(Pic instance);
protected override void DrawSpecific(Pic.Factory2D.PicGraphics graphics) { }
partial void DeletePic(Pic instance);
// process methods to be implemented public abstract bool Process(Pic.DAL.SQLite.PPDataContext db, TreeNode tn);
//For to change image to the last blocks line private void Changepicture(Pic block) { block.BackgroundImage = Image.FromFile("../../Sprites/1.5.png"); }
// finish public virtual void Finalize(Pic.DAL.SQLite.PPDataContext db) { }
//static Cursor cursor = NativeMethods.LoadCustomCursorSafe(Application.StartupPath + "\\cur\\pencil.cur", Cursors.Default); //public override Cursor Cursor { get { return cursor; } } public override void OnMouseDown(MouseEventArgs e) { MouseMoved(e.Button, Pic.PointToPicture(e.Location)); }
void TrySavePicture(string name, Stream stream, int itemID, DBDataContext db) { int maximgSize = 550; try { System.Drawing.Image img = System.Drawing.Image.FromStream(stream); if (img.PhysicalDimension.Width > 500 && img.PhysicalDimension.Width > img.PhysicalDimension.Height) { img = (System.Drawing.Image)(new Bitmap(img, new System.Drawing.Size(maximgSize, (int)(maximgSize / img.PhysicalDimension.Width * img.PhysicalDimension.Height)))); } if (img.PhysicalDimension.Height > maximgSize && img.PhysicalDimension.Height > img.PhysicalDimension.Width) { img = (System.Drawing.Image)(new Bitmap(img, new System.Drawing.Size((int)(maximgSize / img.PhysicalDimension.Height * img.PhysicalDimension.Width), maximgSize))); } Pic pic = new Pic() { ItemID = itemID, path = "" }; db.Pics.InsertOnSubmit(pic); db.SubmitChanges(); string filename = string.Format("item{0}_img{1}.png", itemID, pic.ID); pic.path = string.Format("/img/items/{0}", filename); img.Save(string.Format("{0}/{1}", Server.MapPath("/img/items/"), filename), System.Drawing.Imaging.ImageFormat.Png); db.SubmitChanges(); } catch (Exception ex) { } }
public bool HasParameter(Pic.Plugin.Parameter param) { if (null == _majorationList) _majorationList = LoadMajorationList(); return _majorationList.ContainsKey(param.Name); }
public object InsertTreeNode(object parentObj, Pic.DAL.SQLite.TreeNode node) { TreeNode treeNodeNew = new TreeNode(node.Name, GetImageIndex(node), GetSelectedImageIndex(node)); treeNodeNew.Tag = new NodeTag( node.IsDocument ? NodeTag.NodeType.NT_DOCUMENT : NodeTag.NodeType.NT_TREENODE , node.ID , node.Name , node.Description , node.Thumbnail.GetImage()); treeNodeNew.ToolTipText = node.Description; if (node.IsDocument) treeNodeNew.ContextMenuStrip = node.IsComponent ? GetComponentMenu() : GetLeafMenu(); else treeNodeNew.ContextMenuStrip = GetBranchMenu(); TreeNode treeNodeParent = parentObj as TreeNode; if (null == treeNodeParent) Nodes.Add(treeNodeNew); else { // find index int index = 0; foreach (TreeNode tn in treeNodeParent.Nodes) { NodeTag tag = tn.Tag as NodeTag; if (tag == null) continue; if (string.Compare(tn.Text, node.Name) == -1) ++index; } treeNodeParent.Nodes.Insert(index, treeNodeNew); } return treeNodeNew; }
public byte[] GetExportFile(string fileExt, Pic.Plugin.ParameterStack stack) { // build factory Pic.Factory2D.PicFactory factory = new Pic.Factory2D.PicFactory(); Component.CreateFactoryEntities(factory, stack); if (_reflectionX) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionX)); if (_reflectionY) factory.ProcessVisitor(new PicVisitorTransform(Transform2D.ReflectionY)); // instantiate filter PicFilter filter = (_showCotations ? PicFilter.FilterNone : PicFilter.FilterCotation) & PicFilter.FilterNoZeroEntities; // get bounding box Pic.Factory2D.PicVisitorBoundingBox visitorBoundingBox = new Pic.Factory2D.PicVisitorBoundingBox(); factory.ProcessVisitor(visitorBoundingBox, filter); Pic.Factory2D.Box2D box = visitorBoundingBox.Box; // add margins : 5 % of the smallest value among height box.AddMarginHorizontal(box.Width * 0.05); box.AddMarginVertical(box.Height * 0.05); string author = Application.ProductName + " (" + Application.CompanyName + ")"; string title = Application.ProductName + " export"; string fileFormat = fileExt.StartsWith(".") ? fileExt.Substring(1) : fileExt; fileFormat = fileFormat.ToLower(); // get file content if (string.Equals("des", fileFormat)) { Pic.Factory2D.PicVisitorDesOutput visitor = new Pic.Factory2D.PicVisitorDesOutput(); visitor.Author = author; factory.ProcessVisitor(visitor, filter); return visitor.GetResultByteArray(); } else if (string.Equals("dxf", fileFormat)) { Pic.Factory2D.PicVisitorOutput visitor = new Pic.Factory2D.PicVisitorDxfOutput(); visitor.Author = author; factory.ProcessVisitor(visitor, filter); return visitor.GetResultByteArray(); } else if (string.Equals("pdf", fileFormat)) { Pic.Factory2D.PicGraphicsPdf graphics = new PicGraphicsPdf(box); graphics.Author = author; graphics.Title = title; factory.Draw(graphics, filter); return graphics.GetResultByteArray(); } else if (string.Equals("ai", fileFormat) || string.Equals("cf2", fileFormat)) { Pic.Factory2D.PicVisitorDiecutOutput visitor = new Pic.Factory2D.PicVisitorDiecutOutput(fileFormat); visitor.Author = author; visitor.Title = title; factory.ProcessVisitor(visitor, filter); return visitor.GetResultByteArray(); } else throw new Exception("Invalid file format:" + fileFormat); }
private static void writeDescriptionInImage(string filename, string newArtist, string newCopyright, string newDescription) { Image Pic; PropertyItem[] PropertyItems; byte[] bArtist = new Byte[newArtist.Length]; byte[] bCopyright = new Byte[newCopyright.Length]; byte[] bDescription = new Byte[newDescription.Length]; int i; string FilenameTemp; Encoder Enc = Encoder.Transformation; EncoderParameters EncParms = new EncoderParameters(1); EncoderParameter EncParm; ImageCodecInfo CodecInfo = GetEncoderInfo("image/jpeg"); // copy description into byte array for (i = 0; i < newArtist.Length; i++) { bArtist[i] = (byte)newArtist[i]; } for (i = 0; i < newCopyright.Length; i++) { bCopyright[i] = (byte)newCopyright[i]; } for (i = 0; i < newDescription.Length; i++) { bDescription[i] = (byte)newDescription[i]; } // load the image to change Pic = Image.FromFile(filename); // PropertyItem propertyAuthor = CreatePropertyImage(); // propertyAuthor.Id = 0x013b; // propertyAuthor.Type = 2; // propertyAuthor.Len = newAuthor.Length; // propertyAuthor.Value = bAuthor; // Pic.SetPropertyItem(propertyAuthor); // // PropertyItem propertyCopyright = CreatePropertyImage(); // propertyCopyright.Id = 0x8298; // propertyCopyright.Type = 2; // propertyCopyright.Len = newCopyright.Length; // propertyCopyright.Value = bCopyright; // Pic.SetPropertyItem(propertyCopyright); // // PropertyItem propertyDescription = CreatePropertyImage(); // propertyDescription.Id = 0x010e; // propertyDescription.Type = 2; // propertyDescription.Len = newDescription.Length; // propertyDescription.Value = bDescription; // Pic.SetPropertyItem(propertyDescription); // put the new description into the right property item PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x010e; // 0x010e as specified in EXIF standard PropertyItems[0].Type = 2; PropertyItems[0].Len = newDescription.Length; PropertyItems[0].Value = bDescription; Pic.SetPropertyItem(PropertyItems[0]); PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x8298; PropertyItems[0].Type = 2; PropertyItems[0].Len = newCopyright.Length; PropertyItems[0].Value = bCopyright; Pic.SetPropertyItem(PropertyItems[0]); PropertyItems = Pic.PropertyItems; PropertyItems[0].Id = 0x013b; PropertyItems[0].Type = 2; PropertyItems[0].Len = newArtist.Length; PropertyItems[0].Value = bArtist; Pic.SetPropertyItem(PropertyItems[0]); PropertyItems = Pic.PropertyItems; // we cannot store in the same image, so use a temporary image instead FilenameTemp = filename + ".temp"; // for lossless rewriting must rotate the image by 90 degrees! EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate90); EncParms.Param[0] = EncParm; // now write the rotated image with new description Pic.Save(FilenameTemp, CodecInfo, EncParms); // for computers with low memory and large pictures: release memory now Pic.Dispose(); Pic = null; GC.Collect(); // delete the original file, will be replaced later System.IO.File.Delete(filename); // now must rotate back the written picture Pic = Image.FromFile(FilenameTemp); EncParm = new EncoderParameter(Enc, (long)EncoderValue.TransformRotate270); EncParms.Param[0] = EncParm; Pic.Save(filename, CodecInfo, EncParms); // release memory now Pic.Dispose(); Pic = null; GC.Collect(); // delete the temporary picture System.IO.File.Delete(FilenameTemp); }