/// <summary> /// 同じイメージが存在するかチェックする /// </summary> /// <param name="clImage">イメージ</param> /// <returns>存在フラグ</returns> public static bool IsExistImageFromImage(Image clImage) { if (clImage == null) { return(false); } string clHash = ClsTool.GetMD5FromImage(clImage); foreach (int inKey in ClsSystem.mDicImage.Keys) { ClsDatImage clDatImage = ClsSystem.mDicImage[inKey]; if (clDatImage.mImgOrigin == null) { continue; } string clHashTmp = ClsTool.GetMD5FromImage(clDatImage.mImgOrigin); if (!clHashTmp.Equals(clHash)) { continue; } return(true); } return(false); }
private void FormMain_Load(object sender, EventArgs e) { //以下、初期化処理 ClsTool.Init(); PreViewCenter = new Point(0, 0); mScreenScroll = new Point(0, 0); ImageMan = new ImageManagerBase(); TimeLine = new TIMELINEbase(); this.mFormImageList = new FormImageList(); this.mFormImageList.Show(); this.mFormControl = new FormControl(this); this.mFormControl.mTimeLine = TimeLine; this.mFormControl.Show(); this.mFormAttribute = new FormAttribute(this); this.mFormAttribute.Show(); mFormControl.mTimeLine = TimeLine;//ControlFormに通達 //Ver2 mFormCell = new FormCell(this); mFormCell.IM = ImageMan; mFormCell.Show(); AlingForms(); //背景の再描画をキャンセル(ちらつき抑制) //効果いまいち this.SetStyle(ControlStyles.Opaque, true); }
/// <summary> /// 読み込み処理 /// </summary> /// <param name="clXmlElem">xmlエレメント</param> public void Load(XmlElement clXmlElem) { XmlNodeList clListNode = clXmlElem.ChildNodes; this.mID = ClsTool.GetIntFromXmlNodeList(clListNode, "ID"); this.mPath = ClsTool.GetStringFromXmlNodeList(clListNode, "Path"); //以下、各管理クラス作成処理 foreach (XmlNode clNode in clListNode) { if ("Rect".Equals(clNode.Name)) { this.mRect = new ClsDatRect(); this.mRect.Load(clNode); continue; } } //以下、イメージ復元処理 Bitmap clImage = (Bitmap)Bitmap.FromFile(this.mPath); if (this.mRect != null) { //以下、イメージカット処理 Rectangle stRect = new Rectangle(this.mRect.mX, this.mRect.mY, this.mRect.mW, this.mRect.mH); clImage = clImage.Clone(stRect, clImage.PixelFormat); } this.SetImage(clImage); }
/// <summary> /// 読み込み処理 /// </summary> /// <param name="clXmlNode">xmlノード</param> public void Load(XmlNode clXmlNode) { XmlNodeList clListNode = clXmlNode.ChildNodes; string clTypeOption = ClsTool.GetStringFromXmlNodeList(clListNode, "TypeOption"); this.mTypeOption = (EnmTypeOption)Enum.Parse(typeof(EnmTypeOption), clTypeOption); //以下、各管理クラス作成処理 foreach (XmlNode clNode in clListNode) { if (!"KeyFrame".Equals(clNode.Name)) { continue; } bool isEnable1 = false; bool isEnable2 = false; object clValue1 = ClsParam.GetDefaultValue1(this.mTypeOption); object clValue2 = ClsParam.GetDefaultValue2(this.mTypeOption); ClsDatKeyFrame clDatKeyFrame = new ClsDatKeyFrame(this.mTypeOption, 0, isEnable1, isEnable2, null, null, clValue1, clValue2); clDatKeyFrame.Load(clNode); this.mDicKeyFrame[clDatKeyFrame.mFrameNo] = clDatKeyFrame; continue; } }
/// <summary> /// xml形式でベクター3を ClsSystem.mFileBuffer に出力する処理 /// </summary> /// <param name="clHeader">ヘッダー</param> /// <param name="clName">要素名</param> /// <param name="clVec">ベクトル</param> public static void AppendElement(string clHeader, string clName, ClsVector3 clVec) { ClsTool.AppendElementStart(clHeader, clName); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "X", clVec.X); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Y", clVec.Y); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Z", clVec.Z); ClsTool.AppendElementEnd(clHeader, clName); }
public static string GetMD5FromFile(string clPath) { byte[] pchBuffer = File.ReadAllBytes(clPath); string clHash = ClsTool.GetMD5FromMemory(pchBuffer); string stHash = clPath.GetHashCode().ToString(); return(clHash); }
/// <summary> /// 読み込み処理 /// </summary> /// <param name="clXmlElem">xmlエレメント</param> public void Load(XmlNode clXmlElem) { XmlNodeList clListNode = clXmlElem.ChildNodes; this.mX = ClsTool.GetIntFromXmlNodeList(clListNode, "X"); this.mY = ClsTool.GetIntFromXmlNodeList(clListNode, "Y"); this.mW = ClsTool.GetIntFromXmlNodeList(clListNode, "W"); this.mH = ClsTool.GetIntFromXmlNodeList(clListNode, "H"); }
private void AddItem(string clPath) { Image clImage = Bitmap.FromFile(clPath); byte[] pchBuffer = ClsTool.ImageToByteArray(clImage); string clMD5 = ClsTool.GetMD5FromMemory(pchBuffer); this.AddItem(clPath, clMD5, clImage); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clHeader">ヘッダー</param> public void Save(string clHeader) { //以下、イメージ保存処理 ClsTool.AppendElementStart(clHeader, "Rect"); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "X", this.mX); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Y", this.mY); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "W", this.mW); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "H", this.mH); ClsTool.AppendElementEnd(clHeader, "Rect"); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clHeader">ヘッダー</param> public void Save(string clHeader) { //以下、イメージ保存処理 ClsTool.AppendElementStart(clHeader, "Image"); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "ID", this.mID); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Path", this.mPath); if (this.mRect != null) { this.mRect.Save(clHeader + ClsSystem.FILE_TAG); } ClsTool.AppendElementEnd(clHeader, "Image"); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clHeader">ヘッダー</param> public void Save(string clHeader) { //以下、オプション保存処理 ClsTool.AppendElementStart(clHeader, "Option"); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "TypeOption", this.mTypeOption.ToString()); //以下、キーフレーム保存処理 foreach (int inKey in this.mDicKeyFrame.Keys) { ClsDatKeyFrame clDatKeyFrame = this.mDicKeyFrame[inKey]; clDatKeyFrame.Save(clHeader + ClsSystem.FILE_TAG); } ClsTool.AppendElementEnd(clHeader, "Option"); }
/// <summary> /// XmlNodeListからVector3を生成して返す /// </summary> /// <param name="clListNode">ノードリスト</param> /// <param name="clName">要素名</param> /// <returns>int値</returns> public static ClsVector3 GetVecFromXmlNodeList(XmlNodeList clListNode, string clName) { ClsVector3 clValue = null; foreach (XmlNode clNode in clListNode) { if (clName.Equals(clNode.Name)) { clValue = ClsTool.GetVecFromXmlNode(clNode); return(clValue); } } clValue = new ClsVector3(); return(clValue); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clHeader">ヘッダー</param> public void Save(string clHeader) { //以下、モーション保存処理 ClsTool.AppendElementStart(clHeader, "Motion"); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "ID", this.mID); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Name", this.mName); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "FrameNum", this.mMaxFrameNum); //以下、エレメントリスト保存処理 foreach (ClsDatElem clDatElem in this.mListElem) { clDatElem.Save(clHeader + ClsSystem.FILE_TAG); } ClsTool.AppendElementEnd(clHeader, "Motion"); }
/// <summary> /// 辞書をJsonに変更する処理 /// </summary> /// <param name="clDic">辞書</param> /// <returns>Json</returns> public static string DictionaryToJson(Dictionary <string, object> clDic) { string clJsonData = ""; clJsonData += "{"; int inCnt = 0; int inMax = clDic.Keys.Count; foreach (string clKey in clDic.Keys) { object clVal = clDic[clKey] as object; if (clVal is Dictionary <string, object> ) { clJsonData += "\"" + clKey + "\":"; clJsonData += ClsTool.DictionaryToJson(clVal as Dictionary <string, object>); } else if (clVal is string) { clJsonData += "\"" + clKey + "\":\"" + clVal + "\""; } else if (clVal is int?) { if (clVal == null) { clVal = 0; } clJsonData += "\"" + clKey + "\":" + clVal; } else { clJsonData += "\"" + clKey + "\":" + clVal; } inCnt++; if (inCnt < inMax) { clJsonData += ","; } } clJsonData += "}"; return(clJsonData); }
/// <summary> /// エレメントのコントロール描画処理 /// </summary> /// <param name="g">描画管理クラス</param> /// <param name="inSelectLineNo">選択中のライン番号</param> /// <param name="inWidth">描画先の幅</param> /// <param name="inHeight">描画先の高さ</param> /// <param name="clFont">フォント管理クラス</param> public void DrawControl(Graphics g, int inSelectLineNo, int inWidth, int inHeight, Font clFont) { //以下、表示しなくてはいけない種別かどうかチェックする処理 bool isDraw = ClsDatOption.IsDraw(this.mTypeOption); if (!isDraw) { return; } //以下、横ライン描画処理 int inY = FormControl.CELL_HEIGHT; //g.DrawLine(Pens.Black, 0, inY, inWidth, inY); //以下、背景を塗る処理 if (inSelectLineNo == this.mLineNo) { //選択中Elementsの背景強調 SolidBrush sb = new SolidBrush(Color.DarkGreen); g.FillRectangle(sb, 0, this.mLineNo * FormControl.CELL_HEIGHT, inWidth, FormControl.CELL_HEIGHT); } else { if (this.mLineNo % 2 == 0) { SolidBrush sb = new SolidBrush(Color.Black); g.FillRectangle(sb, 0, this.mLineNo * FormControl.CELL_HEIGHT, inWidth, FormControl.CELL_HEIGHT); } else { SolidBrush sb = new SolidBrush(Color.FromArgb(0xFF, 20, 20, 30)); g.FillRectangle(sb, 0, this.mLineNo * FormControl.CELL_HEIGHT, inWidth, FormControl.CELL_HEIGHT); } } //以下、名前描画処理 string clName = ClsTool.CnvTypeOption2Name(this.mTypeOption); if (!string.IsNullOrEmpty(clName)) { string clBlank = this.GetTabBlank(); g.DrawString(clBlank + clName, clFont, Brushes.White, 69, this.mLineNo * FormControl.CELL_HEIGHT + 2); } }
//RectAngle Cut:分離:9/19:amami private void CutPeace(Image SrcImage, Rectangle rect, string path) { //以下、画像切り取り処理 Rectangle stRectSrc = rect; Bitmap clImageDst = new Bitmap(stRectSrc.Width, stRectSrc.Height); using (Graphics g = Graphics.FromImage(clImageDst)) { Rectangle stRectDst = new Rectangle(0, 0, stRectSrc.Width, stRectSrc.Height); g.DrawImage(SrcImage, stRectDst, stRectSrc, GraphicsUnit.Pixel); } //以下、ハッシュ値を取得する処理 byte[] pchBuffer = ClsTool.ImageToByteArray(clImageDst); string clMD5 = ClsTool.GetMD5FromMemory(pchBuffer); //以下、アイテム追加処理 this.AddItem(path + Environment.NewLine + "cut " + stRectSrc.ToString(), clMD5, clImageDst); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clFilePath">ファイルパス</param> public static void Save(string clFilePath) { ClsSystem.mFileBuffer = new StringBuilder(); //以下、プロジェクトファイル保存処理 string clLine = "?xml version=\"1.0\" encoding=\"utf-8\"?"; ClsTool.AppendElementStart("", clLine); clLine = "HanimProjectData xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""; ClsTool.AppendElementStart("", clLine); string clHeader = ClsSystem.FILE_TAG; string clHeaderName = "hap"; ClsTool.AppendElement(clHeader, "Header", clHeaderName); int inVersion = 1; ClsTool.AppendElement(clHeader, "Ver", inVersion); //以下、イメージリスト保存処理 foreach (int inKey in ClsSystem.mDicImage.Keys) { ClsDatImage clDatImage = ClsSystem.mDicImage[inKey]; clDatImage.Save(clHeader); } //以下、モーションリスト保存処理 foreach (int inKey in ClsSystem.mDicMotion.Keys) { ClsDatMotion clDatMotion = ClsSystem.mDicMotion[inKey]; clDatMotion.Save(clHeader); } ClsTool.AppendElementEnd("", "HanimProjectData"); //以下、プロジェクトファイル保存処理 string clBuffer = ClsSystem.mFileBuffer.ToString(); File.WriteAllText(clFilePath, clBuffer, Encoding.UTF8); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clHeader">ヘッダー</param> public void Save(string clHeader) { //以下、キーフレーム保存処理 ClsTool.AppendElementStart(clHeader, "KeyFrame"); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Frame", this.mFrameNo); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Value1", this.mValue1.ToString()); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Value2", this.mValue1.ToString()); //以下、トゥイーン保存処理 if (this.mTween1 != null) { this.mTween1.Save("Tween1", clHeader + ClsSystem.FILE_TAG); } if (this.mTween2 != null) { this.mTween2.Save("Tween2", clHeader + ClsSystem.FILE_TAG); } ClsTool.AppendElementEnd(clHeader, "KeyFrame"); }
/// <summary> /// 読み込み処理 /// </summary> /// <param name="clXmlNode">xmlノード</param> public void Load(XmlNode clXmlNode) { XmlNodeList clListNode = clXmlNode.ChildNodes; string clParam = ClsTool.GetStringFromXmlNodeList(clListNode, "Param"); this.mParam = (EnmParam)Enum.Parse(typeof(EnmParam), clParam); this.mLength = ClsTool.GetIntFromXmlNodeList(clListNode, "Length"); this.mPos = ClsTool.GetVecFromXmlNodeList(clListNode, "Pos"); //以下、各管理クラス作成処理 foreach (XmlNode clNode in clListNode) { if ("Vec".Equals(clNode.Name)) { ClsVector3 clVec = ClsTool.GetVecFromXmlNode(clNode); this.mListVec.Add(clVec); continue; } } }
/// <summary> /// 読み込み処理 /// </summary> /// <param name="clXmlElem">xmlエレメント</param> public void Load(XmlElement clXmlElem) { XmlNodeList clListNode = clXmlElem.ChildNodes; this.mID = ClsTool.GetIntFromXmlNodeList(clListNode, "ID"); this.mName = ClsTool.GetStringFromXmlNodeList(clListNode, "Name"); this.mMaxFrameNum = ClsTool.GetIntFromXmlNodeList(clListNode, "FrameNum"); //以下、各管理クラス作成処理 foreach (XmlNode clNode in clListNode) { if ("Elem".Equals(clNode.Name)) { ClsDatElem clDatElem = new ClsDatElem(this, null, 0.0f, 0.0f); clDatElem.Load(clNode); this.mListElem.Add(clDatElem); continue; } } }
/// <summary> /// 保存処理 /// </summary> public void Save() { //以下、パス生成処理 string clFileName = ClsTool.GetAppFileName(); string clPath = ClsPath.GetPath(clFileName + ".setting"); //以下、Json作成処理 DataContractJsonSerializer clSerializer = new DataContractJsonSerializer(typeof(ClsSetting)); MemoryStream clMemStream = new MemoryStream(); clSerializer.WriteObject(clMemStream, this); string clBuffer = Encoding.UTF8.GetString(clMemStream.ToArray()); //FileHistoryを最大数 10 に制限する if (mFileHistory.Count() > 10) { mFileHistory.RemoveRange(10, mFileHistory.Count() - 10); } //以下、保存処理 File.WriteAllText(clPath, clBuffer); }
/// <summary> /// 保存処理 /// </summary> /// <param name="clName">名前</param> /// <param name="clHeader">ヘッダー</param> public void Save(string clName, string clHeader) { //以下、トゥイーン保存処理 ClsTool.AppendElementStart(clHeader, clName); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Param", this.mParam.ToString()); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Length", this.mLength); ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Pos", this.mPos); //以下、ベクトルリスト保存処理 int inMax = this.mListVec.Count; if (inMax >= 1) { int inCnt; for (inCnt = 0; inCnt < inMax; inCnt++) { ClsTool.AppendElement(clHeader + ClsSystem.FILE_TAG, "Vec", this.mListVec[inCnt]); } } ClsTool.AppendElementEnd(clHeader, clName); }
private static int mSelectLineNo; //現在選択中のライン番号 /// <summary> /// 初期化処理 /// </summary> public static void Init() { //以下、保存データ読み込み処理 ClsSystem.mSetting = null; string clFileName = ClsTool.GetAppFileName(); string clPath = ClsPath.GetPath(clFileName + ".setting"); bool isExist = File.Exists(clPath); if (isExist) { try { using (FileStream clStream = new FileStream(clPath, FileMode.Open)) { DataContractJsonSerializer clSerializer = new DataContractJsonSerializer(typeof(ClsSetting)); ClsSystem.mSetting = (ClsSetting)clSerializer.ReadObject(clStream); clStream.Close(); } } catch (Exception) { ClsSystem.mSetting = null; } } if (ClsSystem.mSetting == null) { ClsSystem.mSetting = new ClsSetting(); ClsSystem.mSetting.Save(); } //以下、データ初期化処理 ClsSystem.mDicImage = new Dictionary <int, ClsDatImage>(); ClsSystem.mMotionSelectKey = -1; ClsSystem.mDicMotion = new Dictionary <int, ClsDatMotion>(); ClsSystem.mSelectFrameNo = -1; ClsSystem.mSelectLineNo = -1; }
/// <summary> /// 初期化処理 /// </summary> /// <param name="clElem">選択中のエレメント</param> /// <param name="inSelectFrameNo">選択中のフレーム番号</param> /// <param name="inMaxFrameNum">フレーム数</param> public void Init(ClsDatElem clElem, int inSelectFrameNo, int inMaxFrameNum) { if (clElem == null) { this.Text = "Attribute"; this.groupBox_Param.Enabled = false; this.mSelectElem = null; this.mSelectFrameNo = 0; } else { this.Text = ClsTool.GetWindowName("Attribute", clElem, inSelectFrameNo); this.groupBox_Param.Enabled = true; this.mSelectElem = clElem; this.mSelectFrameNo = inSelectFrameNo; //以下、チェック状態の設定 if (!this.mLocked) { ClsParam clParam = clElem.GetParamNow(inSelectFrameNo, inMaxFrameNum); this.SetParam(clParam, inSelectFrameNo); } } }
/// <summary> /// ウィンドウ名を設定する /// </summary> /// <param name="clName">ウィンドウ名</param> public void SetName(ClsDatMotion clMotion) { this.Text = ClsTool.GetWindowName("Control", clMotion); this.RefreshAll(); }
/// <summary> /// 読み込み処理 /// </summary> /// <param name="clXmlNode">xmlノード</param> public void Load(XmlNode clXmlNode) { XmlNodeList clListNode = clXmlNode.ChildNodes; this.mFrameNo = ClsTool.GetIntFromXmlNodeList(clListNode, "Frame"); string clValue1 = ClsTool.GetStringFromXmlNodeList(clListNode, "Value1"); string clValue2 = ClsTool.GetStringFromXmlNodeList(clListNode, "Value2"); switch (this.mTypeOption) { case EnmTypeOption.NONE: this.mValue1 = null; break; case EnmTypeOption.DISPLAY: this.mValue1 = Convert.ToBoolean(clValue1); break; case EnmTypeOption.FLIP: this.mValue1 = Convert.ToBoolean(clValue1); this.mValue2 = Convert.ToBoolean(clValue2); break; case EnmTypeOption.POSITION: case EnmTypeOption.ROTATION: case EnmTypeOption.SCALE: case EnmTypeOption.OFFSET: this.mValue1 = Convert.ToSingle(clValue1); this.mValue2 = Convert.ToSingle(clValue2); break; case EnmTypeOption.TRANSPARENCY: this.mValue1 = Convert.ToSingle(clValue1); break; case EnmTypeOption.COLOR: this.mValue1 = Convert.ToInt32(clValue1); break; case EnmTypeOption.USER_DATA: this.mValue1 = clValue1; break; } //以下、各管理クラス作成処理 foreach (XmlNode clNode in clListNode) { if ("Tween1".Equals(clNode.Name)) { ClsDatTween clDatTween = new ClsDatTween(EnmParam.NONE, 0, null, null); clDatTween.Load(clNode); this.mTween1 = clDatTween; continue; } if ("Tween2".Equals(clNode.Name)) { ClsDatTween clDatTween = new ClsDatTween(EnmParam.NONE, 0, null, null); clDatTween.Load(clNode); this.mTween2 = clDatTween; continue; } } }